Exemplo n.º 1
0
        public TesterView() : base()
        {
            GraphicsPlatform.Register(NativeGraphicsService.Instance);

            tableSource = new TesterTableViewSource();
            tableSource.ScenarioSelected += (drawable) => {
                graphicsView.Drawable = drawable;
            };

            tableView = new NSTableView();
            tableView.AddColumn(new NSTableColumn()
            {
                Width = 300,
            });
            tableView.Source = tableSource;
            //tableView.BackgroundColor = NSColor.White;

            AddSubview(tableView);

            graphicsView = new SkiaGraphicsView();
            AddSubview(graphicsView);

            Layout();

            tableView.SelectRow(0, false);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        public WrapperView(EvasObject parent) : base(parent)
        {
            _drawableCanvas = new Lazy <SkiaGraphicsView>(() =>
            {
                var view = new SkiaGraphicsView(parent)
                {
                    IgnorePixelScaling = true,
                    Drawable           = new MauiDrawable(),
                    PassEvents         = true
                };
                view.Show();
                Children.Add(view);
                view.Lower();
                Content?.RaiseTop();
                return(view);
            });

            _clipperView = new Lazy <SKClipperView>(() =>
            {
                var clipper = new SKClipperView(parent)
                {
                    PassEvents = true
                };
                clipper.DrawClip += OnClipPaint;
                clipper.Show();
                clipper.DeviceScalingFactor = (float)DeviceInfo.ScalingFactor;
                Children.Add(clipper);
                clipper.Lower();
                Content?.RaiseTop();
                return(clipper);
            });

            LayoutUpdated += OnLayout;
        }
Exemplo n.º 4
0
        private void CreateTesterView()
        {
            Window window = new Window("GraphicsTester")
            {
                AvailableRotations = DisplayRotation.Degree_0 | DisplayRotation.Degree_180 | DisplayRotation.Degree_270 | DisplayRotation.Degree_90
            };

            window.Show();
            window.BackButtonPressed += (s, e) =>
            {
                EcoreMainloop.Quit();
            };

            Conformant conformant = new Conformant(window);

            conformant.Show();

            Naviframe navi = new Naviframe(window)
            {
                PreserveContentOnPop     = true,
                DefaultBackButtonEnabled = true
            };

            navi.Show();

            GenList list = new GenList(window)
            {
                AlignmentX = -1,
                AlignmentY = -1,
                WeightX    = 1,
                WeightY    = 1
            };
            GenItemClass defaultClass = new GenItemClass("default")
            {
                GetTextHandler = (data, part) =>
                {
                    var scenario = data as AbstractScenario;
                    return(scenario == null ? "" : scenario.GetType().Name);
                }
            };

            foreach (var scenario in ScenarioList.Scenarios)
            {
                list.Append(defaultClass, scenario);
            }

            SkiaGraphicsView graphicsView = new SkiaGraphicsView(window)
            {
                AlignmentX      = -1,
                AlignmentY      = -1,
                WeightX         = 1,
                WeightY         = 1,
                BackgroundColor = Color.White
            };

            graphicsView.Show();

            list.ItemSelected += (s, e) =>
            {
                var scenario = ScenarioList.Scenarios[e.Item.Index - 1];
                graphicsView.Drawable = scenario;
                navi.Push(graphicsView, scenario.GetType().Name);
            };
            list.Show();
            navi.Push(list, "GraphicsTester.Skia.Tizen");
            conformant.SetContent(navi);
        }
Exemplo n.º 5
0
 public static void UpdateDrawable(this SkiaGraphicsView platformGraphicsView, IGraphicsView graphicsView)
 {
     platformGraphicsView.Drawable = graphicsView.Drawable;
 }