Avalonia Code OnlyItaliano

Volumes › Volume 1

The chapter that opens the book, as it is printed: how the volume is made, who it is for, what you need.

Before you begin

Preface

A program with windows, which runs the same way on Windows, macOS and Linux, written in a single language: that is what this series teaches you to build. The language is C#, on .NET 10; the windows are drawn by Avalonia, an open library that draws everything by itself, and so behaves the same way everywhere. Almost everything you find about Avalonia describes the windows in XAML, a markup language; here instead everything is C#, and the compiler checks every line. The title of the series, Avalonia Code Only, comes from this.

To write a window in code you first have to know the code. This first volume is all C#: no windows, only console programs, the ones you use to learn a language because they show you straight away what happens. It starts from the installation and gets as far as threads, Task and await, measured in real programs. The windows begin in Volume 2, which starts exactly where this one ends.

The series has ten volumes:

  1. The C# language: types, objects, generics, exceptions, files, threads, Task and async. This book.
  2. Desktop interfaces: Avalonia in code, the controls, the themes, the architectures and the threads of the interface.
  3. 2D graphics: drawing and animation with Avalonia.
  4. Advanced 2D graphics: Skia, Direct2D, images.
  5. 3D graphics: 3D from scratch with OpenGL.
  6. Advanced 3D graphics: Vulkan and Direct3D.
  7. Audio.
  8. Video.
  9. Devices, data and network.
  10. System, deployment and quality.

Each volume stands on its own, but they all start from what this one teaches.

Who this book is for

You need a computer with Windows, macOS or Linux, and the will to type the examples instead of only reading them.

How the book is organised

ChaptersWhat
I.1–I.2from source to program, the .NET SDK, Visual Studio Code
I.3–I.5types, variables, expressions, decisions, loops, collections, methods
I.6–I.9classes and objects, inheritance and interfaces, delegates and events, generics, null and extensions
I.10–I.14errors and exceptions, files and text, JSON, XML, how to organise a program: MVC, MVP, MVVM
I.15–I.18threads, Task, async and await, and async in practice
AppendicesA–C: the quick reference, how the figures are made, the glossary

Every chapter carries the number of its volume: I.6 is the sixth chapter of Volume 1, II.10 the tenth of Volume 2, and §I.6.3 the third section of chapter I.6. So a cross-reference such as “chapter I.16” also tells you which book to open.

Every chapter begins with What you will learn and ends with three boxes: Common mistakes, the mistakes people really make, with the remedy; Key points, the chapter in a few lines; Exercises, to do with the editor open. That is where the real learning happens.

Reading paths

The house rules

The code of the examples follows a few rules, always the same ones, and the book explains them along the way:

The tools and the code of the examples

You need:

All the code of the book, one project for each program of the examples, can be downloaded free of charge from the series website, https://raval.aratoingegneria.it. The examples are under the MIT licence: you can use them, change them and put them in your own programs, even in the ones you sell, as long as you keep the copyright notice.

Every program of the examples has been compiled without a single warning, and every figure has been drawn by the real program (Appendix B).

Typographical conventions

Back to volume 1