Microsoft.Maui.Graphics.Con.../README.md

136 строки
5.3 KiB
Markdown
Исходник Обычный вид История

2021-02-01 11:49:15 +03:00
# Experimental GraphicsControls
2021-01-03 21:25:48 +03:00
Xamarin.Forms allows you to define the user interface once for multiple platforms. It offers an abstraction layer that is converted on each platform into native controls.
While the native controls proposal is great as it offers the native experience (appearance, performance, etc). it has certain adjacent limitations like customization possibilities etc.
2021-01-04 14:16:10 +03:00
_What if you could choose at any time between using the native control or a drawn control with the native look and feel?_
2021-01-03 21:25:48 +03:00
2021-02-01 11:49:15 +03:00
**GraphicsControls** is a library that offers the controls available in Xamarin.Forms Visual allowing to choose between **Cupertino, Fluent and Material** but, instead of creating native controls, are **drawn controls**. This project is a **.NET experiment** related to Xamarin / .NET MAUI with different tests to validate the interest and feasibility of drawn controls but is not covered by Microsoft support.
2021-01-03 21:25:48 +03:00
<img src="images/graphicscontrols.png" Width="220" />
There is currently support for:
* **iOS** using CoreGraphics
* **macOS** using CoreGraphics
* **Android** using Android Graphics
2021-01-29 19:08:38 +03:00
* **Tizen** using SkiaSharp
2021-01-03 21:25:48 +03:00
Soon, support will be added to:
* **Linux** using SkiaSharp
2021-01-29 19:08:38 +03:00
* **UWP** using Win2D
2021-01-03 21:25:48 +03:00
* **WPF** using SharpDX
2021-01-21 21:43:07 +03:00
<img src="images/graphicscontrols-platforms.png" Width="600" />
2021-01-21 21:46:14 +03:00
**NOTE:** Are you interested in having more information? You have a detailed [video](https://www.youtube.com/watch?v=hLcpAgWCHf4)!.
2021-01-06 14:43:17 +03:00
#### System.Graphics
This project is using **System.Graphics**.
2021-01-21 21:43:07 +03:00
[System.Graphics](https://github.com/jonlipsky/System.Graphics) is a cross-platform graphics library for iOS, Android, Windows, macOS and Linux completely in C#. With this library you can use a common API to target multiple abstractions allowing you to share your drawing code between platforms, or mix and match graphics implentations within a singular application.
2021-01-06 14:43:17 +03:00
2021-01-03 21:25:48 +03:00
## What controls are available?
Currently there are the following controls:
* **ActivityIndicator** (Cupertino, Fluent, Material)
* **BoxView**
* **Button** (Cupertino, Fluent, Material)
* **CheckBox** (Cupertino, Fluent, Material)
2021-01-08 20:51:34 +03:00
* **Editor** (Cupertino, Fluent, Material)
2021-01-03 21:25:48 +03:00
* **Entry** (Cupertino, Fluent, Material)
2021-01-24 14:15:33 +03:00
* **Frame**
2021-01-03 21:25:48 +03:00
* **ProgressBar** (Cupertino, Fluent, Material)
* **RadioButton** (Cupertino, Fluent, Material)
* **Slider** (Cupertino, Fluent, Material)
* **Stepper** (Cupertino, Fluent, Material)
* **Switch** (Cupertino, Fluent, Material)
Work in progress:
2021-01-21 21:43:07 +03:00
* DatePicker (Cupertino, Fluent, Material)
* TimePicker (Cupertino, Fluent, Material)
2021-01-03 21:25:48 +03:00
The controls have the same properties and events as those existing in Xamarin.Forms.
## Features
The main features are:
#### Drawn controls
The controls are drawn getting a pixel perfect option to adjust in the same way on all the platforms.
<img src="images/graphicscontrols-isenabled.gif" Width="220" />
#### Easy to extend
2021-01-04 14:16:10 +03:00
_Do you want to extend a drawn control?_ Create your own control class, inherit from the drawn control and override the **Draw** method.
2021-01-03 21:25:48 +03:00
```
public class CustomControl : GraphicsView
{
public override void Draw(ICanvas canvas, RectangleF dirtyRect)
{
base.Draw(canvas, dirtyRect);
}
}
```
On the other hand, if you want to modify how a specific layer of an existing control is drawn, you just have to overwrite the method that draws the layer.
```
public class CustomSlider : Slider
{
protected override void DrawSliderThumb(ICanvas canvas, RectangleF dirtyRect)
{
base.DrawSliderThumb(canvas, dirtyRect);
}
}
```
Also can add new layers, delete existing layers or reorganize the priority when drawing the layers.
2021-01-03 21:25:48 +03:00
#### Dark Theme support
All controls, in the different visual modes (Cupertino, Fluent and Material) supports both light and dark theme.
<img src="images/graphicscontrols-darktheme.gif" Width="220" />
#### RTL support (Work in progress)
All controls support RTL.
<img src="images/graphicscontrols-rtl.png" Width="220" />
2021-01-03 21:29:07 +03:00
#### Mobile & Desktop support
<img src="images/graphicscontrols-mac.gif" Width="600" />
2021-01-06 21:31:55 +03:00
#### Accesibility support
Building an accessible application ensures that the application is usable by people who approach the user interface with a range of needs and experiences.
GraphicsControls will allow to set AutomationProperties, which in turn set native accessibility values.
(Work in progress)
2021-01-03 21:25:48 +03:00
#### Performance
2021-01-03 21:28:03 +03:00
Some native controls are complex. For example, Entry using Visual Material is made up of different elements. When using it, each of the different elements must be instantiated (the text box, the placeholder text, etc.). Using the drawn control, create an instance of a Canvas and draw the content. The time required to instantiate etc is shorter.
2021-01-06 14:43:17 +03:00
<img src="images/graphicscontrols-performance.png" Width="600" />
## Goals
* Have pixel-perfect drawn controls working on all the Xamarin.Forms supported platforms.
2021-01-06 14:45:03 +03:00
* High performance and customization options controls.
2021-02-01 11:40:52 +03:00
* In the short term, the goal is to have the controls for Xamarin.Forms, in the future they could reach Comet, .NET MAUI, etc.
2021-02-01 11:49:15 +03:00
## Contributing
As an experimental project, there are several active areas of development and we're looking for your feedback to help set the direction for this project. Please check it out and let us know any feedback you have on the project by logging issues in this repo.
Thank you!
2021-02-01 11:40:52 +03:00
## Copyright and license
Code released under the [MIT license](https://opensource.org/licenses/MIT).