Added Tizen implementation
This commit is contained in:
Родитель
027cd0f946
Коммит
28f281dd9d
|
@ -0,0 +1,19 @@
|
|||
<Project Sdk="Tizen.NET.Sdk/1.1.5">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>tizen40</TargetFramework>
|
||||
<AssemblyName>GraphicsControls.Sample.Tizen</AssemblyName>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Xamarin.Forms" Version="5.0.0.1905" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\GraphicsControls.Sample\GraphicsControls.Sample.csproj" />
|
||||
<ProjectReference Include="..\GraphicsControls\GraphicsControls.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Platform.Tizen;
|
||||
using System.Graphics.Skia.Views;
|
||||
|
||||
namespace GraphicsControls.Sample.Tizen
|
||||
{
|
||||
class Program : FormsApplication
|
||||
{
|
||||
protected override void OnCreate()
|
||||
{
|
||||
base.OnCreate();
|
||||
var app = new App();
|
||||
app.UserAppTheme = OSAppTheme.Light;
|
||||
LoadApplication(app);
|
||||
}
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
var app = new Program();
|
||||
var option = new InitializationOptions(app)
|
||||
{
|
||||
DisplayResolutionUnit = DisplayResolutionUnit.DP(true),
|
||||
UseSkiaSharp = true
|
||||
};
|
||||
Forms.Init(option);
|
||||
app.Run(args);
|
||||
}
|
||||
}
|
||||
}
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 253 KiB |
Двоичные данные
src/GraphicsControls.Sample.Tizen/shared/res/GraphicsControls.Sample.Tizen.png
Normal file
Двоичные данные
src/GraphicsControls.Sample.Tizen/shared/res/GraphicsControls.Sample.Tizen.png
Normal file
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 9.9 KiB |
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns="http://tizen.org/ns/packages" api-version="4" package="org.tizen.example.GraphicsControls.Sample.Tizen" version="1.0.0">
|
||||
<profile name="common" />
|
||||
<ui-application appid="org.tizen.example.GraphicsControls.Sample.Tizen"
|
||||
exec="GraphicsControls.Sample.Tizen.dll"
|
||||
type="dotnet"
|
||||
multiple="false"
|
||||
taskmanage="true"
|
||||
nodisplay="false"
|
||||
launch_mode="single"
|
||||
>
|
||||
<label>GraphicsControls.Sample.Tizen</label>
|
||||
<icon>GraphicsControls.Sample.Tizen.png</icon>
|
||||
<metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true" />
|
||||
</ui-application>
|
||||
</manifest>
|
|
@ -6,6 +6,7 @@
|
|||
xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
|
||||
x:Class="GraphicsControls.Sample.MainPage"
|
||||
ios:Page.UseSafeArea="true"
|
||||
BackgroundColor="White"
|
||||
Title="GraphicsControls">
|
||||
<ScrollView
|
||||
BackgroundColor="{AppThemeBinding Light=White, Dark=Black}">
|
||||
|
|
|
@ -13,6 +13,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GraphicsControls.Sample.iOS
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GraphicsControls.Sample", "GraphicsControls.Sample\GraphicsControls.Sample.csproj", "{41B421AF-5731-4B8F-BEDE-96155879D929}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GraphicsControls.Sample.Tizen", "GraphicsControls.Sample.Tizen\GraphicsControls.Sample.Tizen.csproj", "{F89D5E3A-5531-412B-A8B2-D4E8A9F07B9E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GraphicsControls.Sample.Android", "GraphicsControls.Sample.Android\GraphicsControls.Sample.Android.csproj", "{2EE53371-EFD9-4304-A231-93E6F75DBC81}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -59,6 +63,36 @@ Global
|
|||
{41B421AF-5731-4B8F-BEDE-96155879D929}.Release|iPhone.Build.0 = Release|Any CPU
|
||||
{41B421AF-5731-4B8F-BEDE-96155879D929}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
|
||||
{41B421AF-5731-4B8F-BEDE-96155879D929}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
|
||||
{F89D5E3A-5531-412B-A8B2-D4E8A9F07B9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F89D5E3A-5531-412B-A8B2-D4E8A9F07B9E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F89D5E3A-5531-412B-A8B2-D4E8A9F07B9E}.Debug|iPhone.ActiveCfg = Debug|Any CPU
|
||||
{F89D5E3A-5531-412B-A8B2-D4E8A9F07B9E}.Debug|iPhone.Build.0 = Debug|Any CPU
|
||||
{F89D5E3A-5531-412B-A8B2-D4E8A9F07B9E}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
|
||||
{F89D5E3A-5531-412B-A8B2-D4E8A9F07B9E}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
|
||||
{F89D5E3A-5531-412B-A8B2-D4E8A9F07B9E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F89D5E3A-5531-412B-A8B2-D4E8A9F07B9E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F89D5E3A-5531-412B-A8B2-D4E8A9F07B9E}.Release|iPhone.ActiveCfg = Release|Any CPU
|
||||
{F89D5E3A-5531-412B-A8B2-D4E8A9F07B9E}.Release|iPhone.Build.0 = Release|Any CPU
|
||||
{F89D5E3A-5531-412B-A8B2-D4E8A9F07B9E}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
|
||||
{F89D5E3A-5531-412B-A8B2-D4E8A9F07B9E}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
|
||||
{2EE53371-EFD9-4304-A231-93E6F75DBC81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2EE53371-EFD9-4304-A231-93E6F75DBC81}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2EE53371-EFD9-4304-A231-93E6F75DBC81}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
{2EE53371-EFD9-4304-A231-93E6F75DBC81}.Debug|iPhone.ActiveCfg = Debug|Any CPU
|
||||
{2EE53371-EFD9-4304-A231-93E6F75DBC81}.Debug|iPhone.Build.0 = Debug|Any CPU
|
||||
{2EE53371-EFD9-4304-A231-93E6F75DBC81}.Debug|iPhone.Deploy.0 = Debug|Any CPU
|
||||
{2EE53371-EFD9-4304-A231-93E6F75DBC81}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
|
||||
{2EE53371-EFD9-4304-A231-93E6F75DBC81}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
|
||||
{2EE53371-EFD9-4304-A231-93E6F75DBC81}.Debug|iPhoneSimulator.Deploy.0 = Debug|Any CPU
|
||||
{2EE53371-EFD9-4304-A231-93E6F75DBC81}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2EE53371-EFD9-4304-A231-93E6F75DBC81}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2EE53371-EFD9-4304-A231-93E6F75DBC81}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||
{2EE53371-EFD9-4304-A231-93E6F75DBC81}.Release|iPhone.ActiveCfg = Release|Any CPU
|
||||
{2EE53371-EFD9-4304-A231-93E6F75DBC81}.Release|iPhone.Build.0 = Release|Any CPU
|
||||
{2EE53371-EFD9-4304-A231-93E6F75DBC81}.Release|iPhone.Deploy.0 = Release|Any CPU
|
||||
{2EE53371-EFD9-4304-A231-93E6F75DBC81}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
|
||||
{2EE53371-EFD9-4304-A231-93E6F75DBC81}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
|
||||
{2EE53371-EFD9-4304-A231-93E6F75DBC81}.Release|iPhoneSimulator.Deploy.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -67,6 +101,8 @@ Global
|
|||
{474A33AE-06A4-4219-9545-17751EBF3F84} = {4F0017DB-8A18-4153-A129-782B29DECF51}
|
||||
{27FAE6FC-C7E2-4B63-B713-906A59A0C0DF} = {465D03D3-BA73-4E52-BBEA-02DC54647BC6}
|
||||
{41B421AF-5731-4B8F-BEDE-96155879D929} = {465D03D3-BA73-4E52-BBEA-02DC54647BC6}
|
||||
{F89D5E3A-5531-412B-A8B2-D4E8A9F07B9E} = {465D03D3-BA73-4E52-BBEA-02DC54647BC6}
|
||||
{2EE53371-EFD9-4304-A231-93E6F75DBC81} = {465D03D3-BA73-4E52-BBEA-02DC54647BC6}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {475B4FFA-17B6-449C-9D09-DE4E2B0D2F4B}
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
using GraphicsControls;
|
||||
using GraphicsControls.Tizen;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Platform.Tizen;
|
||||
using EEntry = ElmSharp.Entry;
|
||||
using ESize = ElmSharp.Size;
|
||||
|
||||
[assembly: ExportRenderer(typeof(BorderlessEditor), typeof(BorderlessEditorRenderer))]
|
||||
namespace GraphicsControls.Tizen
|
||||
{
|
||||
public class BorderlessEditorRenderer : EditorRenderer
|
||||
{
|
||||
protected override EEntry CreateNativeControl()
|
||||
{
|
||||
var entry = new EEntry(Forms.NativeParent)
|
||||
{
|
||||
IsSingleLine = false,
|
||||
};
|
||||
return entry;
|
||||
}
|
||||
|
||||
protected override Size MinimumSize()
|
||||
{
|
||||
return new ESize(NativeView.MinimumWidth, NativeView.MinimumHeight).ToDP();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
using GraphicsControls;
|
||||
using GraphicsControls.Tizen;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Platform.Tizen;
|
||||
using EEntry = ElmSharp.Entry;
|
||||
|
||||
[assembly: ExportRenderer(typeof(BorderlessEntry), typeof(BorderlessEntryRenderer))]
|
||||
namespace GraphicsControls.Tizen
|
||||
{
|
||||
public class BorderlessEntryRenderer : EntryRenderer
|
||||
{
|
||||
|
||||
protected override EEntry CreateNativeControl()
|
||||
{
|
||||
var entry = new EEntry(Forms.NativeParent)
|
||||
{
|
||||
IsSingleLine = true,
|
||||
};
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,225 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Internals;
|
||||
using Xamarin.Forms.Platform.Tizen;
|
||||
using ElmSharp;
|
||||
using System.Graphics.Skia.Views;
|
||||
using GraphicsControls.Tizen;
|
||||
|
||||
using Point = System.Graphics.Point;
|
||||
using EPoint = ElmSharp.Point;
|
||||
using GraphicsView = GraphicsControls.GraphicsView;
|
||||
using XForms = Xamarin.Forms.Forms;
|
||||
using Layout = Xamarin.Forms.Layout;
|
||||
|
||||
[assembly: ExportRenderer(typeof(GraphicsView), typeof(GraphicsViewRenderer))]
|
||||
namespace GraphicsControls.Tizen
|
||||
{
|
||||
[Preserve(AllMembers = true)]
|
||||
public class GraphicsViewRenderer : LayoutRenderer
|
||||
{
|
||||
const int MinHeight = 32;
|
||||
EvasObjectEvent<EvasMouseEventArgs> _mouseUp;
|
||||
EvasObjectEvent<EvasMouseEventArgs> _mouseDown;
|
||||
EvasObjectEvent<EvasMouseEventArgs> _mouseMove;
|
||||
SkiaGraphicsView _skiaGraphicsView;
|
||||
new GraphicsView Element => base.Element as GraphicsView;
|
||||
|
||||
public GraphicsViewRenderer()
|
||||
{
|
||||
RegisterPropertyHandler(AutomationProperties.HelpTextProperty, UpdateAutomationHelpText);
|
||||
RegisterPropertyHandler(AutomationProperties.NameProperty, UpdateAutomationName);
|
||||
}
|
||||
|
||||
protected override void OnElementChanged(ElementChangedEventArgs<Layout> e)
|
||||
{
|
||||
if (e.OldElement != null)
|
||||
{
|
||||
((GraphicsView)e.OldElement).Invalidated -= OnDrawInvalidated;
|
||||
}
|
||||
|
||||
if (e.NewElement != null)
|
||||
{
|
||||
((GraphicsView)e.NewElement).Invalidated += OnDrawInvalidated;
|
||||
|
||||
SetNativeControl(new Xamarin.Forms.Platform.Tizen.Native.Canvas(Forms.NativeParent));
|
||||
|
||||
_skiaGraphicsView = new SkiaGraphicsView(XForms.NativeParent);
|
||||
_skiaGraphicsView.Drawable = Element;
|
||||
_skiaGraphicsView.Show();
|
||||
_mouseDown = new EvasObjectEvent<EvasMouseEventArgs>(_skiaGraphicsView, EvasObjectCallbackType.MouseDown, EvasMouseEventArgs.Create);
|
||||
_mouseUp = new EvasObjectEvent<EvasMouseEventArgs>(_skiaGraphicsView, EvasObjectCallbackType.MouseUp, EvasMouseEventArgs.Create);
|
||||
_mouseMove = new EvasObjectEvent<EvasMouseEventArgs>(_skiaGraphicsView, EvasObjectCallbackType.MouseMove, EvasMouseEventArgs.Create);
|
||||
_mouseDown.On += OnMouseDown;
|
||||
_mouseUp.On += OnMouseUp;
|
||||
_mouseMove.On += OnMouseMove;
|
||||
Control.Children.Add(_skiaGraphicsView);
|
||||
Control.LayoutUpdated += OnLayoutUpdated;
|
||||
}
|
||||
base.OnElementChanged(e);
|
||||
}
|
||||
|
||||
void OnLayoutUpdated(object sender, Xamarin.Forms.Platform.Tizen.Native.LayoutEventArgs e)
|
||||
{
|
||||
_skiaGraphicsView.Geometry = NativeView.Geometry;
|
||||
_skiaGraphicsView.Invalidate();
|
||||
}
|
||||
|
||||
private void OnMouseDown(object sender, EvasMouseEventArgs e)
|
||||
{
|
||||
Element?.OnTouchDown(new Point(Forms.ConvertToScaledDP(e.Point.X), Forms.ConvertToScaledDP(e.Point.Y)));
|
||||
}
|
||||
|
||||
private void OnMouseUp(object sender, EvasMouseEventArgs e)
|
||||
{
|
||||
Element?.OnTouchUp(new Point(Forms.ConvertToScaledDP(e.Point.X), Forms.ConvertToScaledDP(e.Point.Y)));
|
||||
}
|
||||
|
||||
private void OnMouseMove(object sender, EvasMouseEventArgs e)
|
||||
{
|
||||
Element?.OnTouchMove(new Point(Forms.ConvertToScaledDP(e.Point.X), Forms.ConvertToScaledDP(e.Point.Y)));
|
||||
}
|
||||
|
||||
protected override void OnElementReady()
|
||||
{
|
||||
base.OnElementReady();
|
||||
Element?.Load();
|
||||
Element?.AttachComponents();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
Element?.Unload();
|
||||
Element?.DetachComponents();
|
||||
|
||||
if (_mouseDown != null)
|
||||
{
|
||||
_mouseDown.On -= OnMouseDown;
|
||||
_mouseDown.Dispose();
|
||||
}
|
||||
|
||||
if (_mouseUp != null)
|
||||
{
|
||||
_mouseUp.On -= OnMouseUp;
|
||||
_mouseUp.Dispose();
|
||||
}
|
||||
|
||||
if (_mouseMove != null)
|
||||
{
|
||||
_mouseMove.On -= OnMouseMove;
|
||||
_mouseMove.Dispose();
|
||||
}
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
void OnDrawInvalidated(object sender, EventArgs e)
|
||||
{
|
||||
_skiaGraphicsView?.Invalidate();
|
||||
}
|
||||
|
||||
void UpdateAutomationHelpText()
|
||||
{
|
||||
_skiaGraphicsView?.SetAccessibilityDescription(Element);
|
||||
}
|
||||
|
||||
void UpdateAutomationName()
|
||||
{
|
||||
_skiaGraphicsView?.SetAccessibilityName(Element);
|
||||
}
|
||||
}
|
||||
|
||||
public class EvasMouseEventArgs : EventArgs
|
||||
{
|
||||
IntPtr _nativeEventInfo;
|
||||
|
||||
public EPoint Point { get; private set; }
|
||||
|
||||
public EPoint CanvasPoint { get; private set; }
|
||||
|
||||
public EvasEventFlag Flags
|
||||
{
|
||||
get
|
||||
{
|
||||
IntPtr offset = Marshal.OffsetOf<EvasEventMouseDown>("event_flags");
|
||||
return (EvasEventFlag)Marshal.ReadIntPtr(_nativeEventInfo, (int)offset);
|
||||
}
|
||||
set
|
||||
{
|
||||
IntPtr offset = Marshal.OffsetOf<EvasEventMouseDown>("event_flags");
|
||||
Marshal.WriteIntPtr(_nativeEventInfo, (int)offset, (IntPtr)value);
|
||||
}
|
||||
}
|
||||
|
||||
EvasMouseEventArgs(IntPtr info)
|
||||
{
|
||||
_nativeEventInfo = info;
|
||||
var evt = Marshal.PtrToStructure<EvasEventMouseDown>(info);
|
||||
Point = evt.output;
|
||||
CanvasPoint = evt.canvas;
|
||||
}
|
||||
|
||||
static public EvasMouseEventArgs Create(IntPtr data, IntPtr obj, IntPtr info)
|
||||
{
|
||||
return new EvasMouseEventArgs(info);
|
||||
}
|
||||
}
|
||||
|
||||
[NativeStruct("Evas_Event_Mouse_Down", Include = "Elementary.h", PkgConfig = "elementary")]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
struct EvasEventMouseDown
|
||||
{
|
||||
public int button;
|
||||
public EPoint output;
|
||||
public EPoint canvas;
|
||||
public IntPtr data;
|
||||
public IntPtr modifiers;
|
||||
public IntPtr locks;
|
||||
public EvasButtonFlag flags;
|
||||
public uint timestamp;
|
||||
public EvasEventFlag event_flags;
|
||||
public IntPtr dev;
|
||||
public IntPtr event_source;
|
||||
double radius;
|
||||
double radius_x;
|
||||
double radius_y;
|
||||
double pressure;
|
||||
double angle;
|
||||
};
|
||||
|
||||
public enum NativeStructArch
|
||||
{
|
||||
All = 0,
|
||||
Only32Bits = 1,
|
||||
Only64Bits = 2
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class, AllowMultiple = true)]
|
||||
public class NativeStructAttribute : Attribute
|
||||
{
|
||||
private readonly string _structName;
|
||||
|
||||
public NativeStructAttribute(string structName)
|
||||
{
|
||||
_structName = structName;
|
||||
}
|
||||
|
||||
public string StructName => _structName;
|
||||
|
||||
public string PkgConfig { get; set; }
|
||||
|
||||
public string Include { get; set; }
|
||||
|
||||
public NativeStructArch Arch { get; set; }
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum EvasButtonFlag
|
||||
{
|
||||
DoubleClick = 0,
|
||||
TripleClick = 1,
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="MSBuild.Sdk.Extras/2.1.2">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.0;netstandard2.1;Xamarin.iOS10;MonoAndroid10.0;Xamarin.Mac20;</TargetFrameworks>
|
||||
<TargetFrameworks>netstandard2.0;netstandard2.1;Xamarin.iOS10;MonoAndroid10.0;Xamarin.Mac20;tizen40</TargetFrameworks>
|
||||
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);uap10.0.17763;netcoreapp3.1;net472;net471</TargetFrameworks>
|
||||
<AssemblyName>GraphicsControls</AssemblyName>
|
||||
<RootNamespace>GraphicsControls</RootNamespace>
|
||||
|
@ -103,6 +103,8 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup Condition=" $(TargetFramework.StartsWith('tizen')) ">
|
||||
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
|
||||
<PackageReference Include="Tizen.NET" Version="4.0.0" />
|
||||
<PackageReference Include="JonLipsky.System.Graphics.Skia" Version="0.1.36" />
|
||||
<Compile Include="**\*.tizen.cs" />
|
||||
<Compile Include="**\*.tizen.*.cs" />
|
||||
</ItemGroup>
|
||||
|
|
Загрузка…
Ссылка в новой задаче