Beispiel #1
0
        protected override void OnAttached()
        {
            var rect = Control.Geometry;

            _surfaceLayout = new ElmSharp.Layout(Container);
            _surfaceLayout.Show();
            _surface = new ElmSharp.Wearable.CircleSurface(_surfaceLayout);
            _surfaceLayout.Geometry = rect;
            _surfaceLayout.StackAbove(Control);

            CircleSurfaceEffectBehavior.SetSurface(Element, _surface);

            _showEvent    = new EvasObjectEvent(Control, EvasObjectCallbackType.Show);
            _hideEvent    = new EvasObjectEvent(Control, EvasObjectCallbackType.Hide);
            _restackEvent = new EvasObjectEvent(Control, EvasObjectCallbackType.Restack);
            _moveEvent    = new EvasObjectEvent(Control, EvasObjectCallbackType.Move);
            _resizeEvent  = new EvasObjectEvent(Control, EvasObjectCallbackType.Resize);

            _showEvent.On    += ControlShowed;
            _hideEvent.On    += ControlHided;
            _restackEvent.On += ControlRestacked;
            _moveEvent.On    += ControlChanged;
            _resizeEvent.On  += ControlChanged;

            Element.PropertyChanging += ElementPropertyChanging;
            Element.PropertyChanged  += ElementPropertyChanged;

            EcoreMainloop.Post(() =>
            {
                var obj = CircleSurfaceEffectBehavior.GetRotaryFocusObject(Element);
                ActivateRotaryFocusable(obj);
            });
        }
Beispiel #2
0
        public TwoButtonPageWidget(EvasObject parent) : base(parent)
        {
            _frame = new ElmSharp.Layout(parent);
            _frame.SetTheme("popup", "base", "circle");
            SetPartContent("overlay", _frame);
            _frame.Show();

            _buttonLayer = new ElmSharp.Layout(_frame);
            _buttonLayer.SetTheme("popup", "buttons2", "popup/circle");
            _frame.SetPartContent("elm.swallow.action_area", _buttonLayer);
            _buttonLayer.Show();

            _outbox = new ObservableBox(parent);
            _outbox.SetAlignment(NamedHint.Fill, NamedHint.Fill);
            _outbox.SetWeight(NamedHint.Expand, NamedHint.Expand);
            _outbox.SetLayoutCallback(() => { });

            _frame.SetPartContent("elm.swallow.content", _outbox);
            _outbox.Show();

            _canvas = new Canvas(_outbox);
            EcoreMainloop.Post(OnLayout);
            _outbox.PackEnd(_canvas);
            _canvas.Show();

            _buttons = new ElmSharp.Button[2];
            _overlap = false;
        }
Beispiel #3
0
 public void Remove(EvasObject view)
 {
     InternalStack.Remove(view);
     UnPack(view);
     UpdateTopView();
     EcoreMainloop.Post(() =>
     {
         view?.Unrealize();
     });
 }
Beispiel #4
0
 public static void DisposeOnMainThread(this SharedEvasImage image)
 {
     if (EcoreMainloop.IsMainThread)
     {
         image.Unrealize();
     }
     else
     {
         EcoreMainloop.Post(() => {
             image.Unrealize();
         });
     }
 }
Beispiel #5
0
        public static async void Post(Action action)
        {
            await _mutex.WaitAsync().ConfigureAwait(false);

            try
            {
                EcoreMainloop.Post(action);
            }
            finally
            {
                _mutex.Release();
            }
        }
Beispiel #6
0
 public void Pop()
 {
     if (_lastTop != null)
     {
         var tobeRemoved = _lastTop;
         InternalStack.Remove(tobeRemoved);
         UnPack(tobeRemoved);
         UpdateTopView();
         // if Pop was called by removed page,
         // Unrealize cause deletation of NativeCallback, it could be a cause of crash
         EcoreMainloop.Post(() =>
         {
             tobeRemoved.Unrealize();
         });
     }
 }
Beispiel #7
0
 public static /*async*/ void RunOnDispatcher(Action action)
 {
     //Async call
     EcoreMainloop.Post(action);
 }
Beispiel #8
0
        public override void Run(Window window)
        {
            Conformant conformant = new Conformant(window);

            conformant.Show();
            Box outterBox = new Box(window)
            {
                AlignmentX   = -1,
                AlignmentY   = -1,
                WeightX      = 1,
                WeightY      = 1,
                IsHorizontal = false,
            };

            outterBox.Show();
            conformant.SetContent(outterBox);

            Scroller scroller = new Scroller(window)
            {
                AlignmentX  = -1,
                AlignmentY  = -1,
                WeightX     = 1,
                WeightY     = 1,
                ScrollBlock = ScrollBlock.Vertical
            };

            scroller.Show();


            Box innerBox = new Box(window)
            {
                AlignmentX   = -1,
                AlignmentY   = -1,
                WeightX      = 1,
                WeightY      = 1,
                IsHorizontal = true,
            };

            innerBox.Show();
            scroller.SetContent(innerBox);

            var    rects = new List <Rectangle>();
            Random rnd   = new Random();

            for (int i = 0; i < 30; i++)
            {
                var rect = new Rectangle(window)
                {
                    AlignmentX = -1,
                    AlignmentY = -1,
                    WeightX    = 1,
                    WeightY    = 1,
                    Color      = Color.FromRgb(rnd.Next(0, 255), rnd.Next(0, 255), rnd.Next(0, 255)),
                };
                rect.Show();
                innerBox.PackEnd(rect);
                rects.Add(rect);
            }
            ;

            innerBox.SetLayoutCallback(() =>
            {
                System.Console.WriteLine("!!!! update layout");
                System.Console.WriteLine("MinimumWith = {0}", innerBox.MinimumWidth);
            });
            for (int i = 0; i < rects.Count; i++)
            {
                rects[i].Geometry = new Rect(i / 3 * 400 + innerBox.Geometry.X, i % 3 * 400 + innerBox.Geometry.Y, 400, 400);
            }
            innerBox.MinimumWidth = (int)Math.Ceiling(rects.Count / 3.0) * 400;

            Button btn = new Button(window)
            {
                AlignmentX = -1,
                WeightX    = 1,
                Text       = "Remove"
            };

            btn.Clicked += (s, e) =>
            {
                System.Console.WriteLine("current index {0}", _currentIndex);
                System.Console.WriteLine("Before Current Region : {0}", scroller.CurrentRegion);
                int last = rects.Count - 1;
                innerBox.UnPack(rects[last]);
                rects[last].Hide();
                rects.RemoveAt(last);

                System.Console.WriteLine(" innerBox MinimumWith = {0}", innerBox.MinimumWidth);
                System.Console.WriteLine("After Current Region : {0}", scroller.CurrentRegion);

                EcoreMainloop.Post(() =>
                {
                    System.Console.WriteLine("On idler Current Region : {0}", scroller.CurrentRegion);
                });

                EcoreMainloop.AddTimer(0, () =>
                {
                    System.Console.WriteLine("After 0 sec Current Region : {0}", scroller.CurrentRegion);
                    return(false);
                });
            };
            scroller.Scrolled += (s, e) =>
            {
                System.Console.WriteLine("Scrolled to {0}", scroller.CurrentRegion);
                System.Console.WriteLine("in scrolling MinimumWith = {0}", innerBox.MinimumWidth);
            };

            btn.Show();

            outterBox.PackEnd(btn);
            outterBox.PackEnd(scroller);
        }
Beispiel #9
0
        public override void Run(Window window)
        {
            Conformant conformant = new Conformant(window);

            conformant.Show();
            Box outterBox = new Box(window)
            {
                AlignmentX   = -1,
                AlignmentY   = -1,
                WeightX      = 1,
                WeightY      = 1,
                IsHorizontal = false,
            };

            outterBox.Show();
            conformant.SetContent(outterBox);

            Scroller scroller = new Scroller(window)
            {
                AlignmentX  = -1,
                AlignmentY  = -1,
                WeightX     = 1,
                WeightY     = 1,
                ScrollBlock = ScrollBlock.Vertical
            };

            scroller.Show();


            Box innerBox = new Box(window)
            {
                AlignmentX   = -1,
                AlignmentY   = -1,
                WeightX      = 1,
                WeightY      = 1,
                IsHorizontal = true,
            };

            innerBox.Show();
            scroller.SetContent(innerBox);

            Rectangle[] rects = new Rectangle[5];
            Random      rnd   = new Random();

            for (int i = 0; i < 5; i++)
            {
                rects[i] = new Rectangle(window)
                {
                    AlignmentX = -1,
                    AlignmentY = -1,
                    WeightX    = 1,
                    WeightY    = 1,
                    Color      = Color.FromRgb(rnd.Next(0, 255), rnd.Next(0, 255), rnd.Next(0, 255)),
                };
                rects[i].Show();
                rects[i].MinimumWidth = 300;
                innerBox.PackEnd(rects[i]);
            }
            innerBox.MinimumWidth = 300 * 5;
            _currentIndex         = 4;


            Button btn = new Button(window)
            {
                AlignmentX = -1,
                WeightX    = 1,
                Text       = "Remove"
            };

            btn.Clicked += (s, e) =>
            {
                System.Console.WriteLine("current index {0}", _currentIndex);
                System.Console.WriteLine("Before Current Region : {0}", scroller.CurrentRegion);
                innerBox.UnPack(rects[_currentIndex]);
                innerBox.MinimumWidth = 300 * _currentIndex;
                rects[_currentIndex].Hide();
                _currentIndex--;
                System.Console.WriteLine("After Current Region : {0}", scroller.CurrentRegion);

                EcoreMainloop.Post(() =>
                {
                    System.Console.WriteLine("On idler Current Region : {0}", scroller.CurrentRegion);
                });

                EcoreMainloop.AddTimer(0, () =>
                {
                    System.Console.WriteLine("After 0 sec Current Region : {0}", scroller.CurrentRegion);
                    return(false);
                });
            };
            scroller.Scrolled += (s, e) =>
            {
                System.Console.WriteLine("Scrolled to {0}", scroller.CurrentRegion);
            };

            btn.Show();

            outterBox.PackEnd(btn);
            outterBox.PackEnd(scroller);
        }
Beispiel #10
0
        void Initialize()
        {
            Window window = new Window("ElottieSharpGallery")
            {
                AvailableRotations = DisplayRotation.Degree_0 | DisplayRotation.Degree_180 | DisplayRotation.Degree_270 | DisplayRotation.Degree_90
            };

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

            var conformant = new Conformant(window);

            conformant.Show();

            var            surface        = new CircleSurface(conformant);
            CircleScroller circleScroller = new CircleScroller(conformant, surface)
            {
                AlignmentX = -1,
                AlignmentY = -1,
                WeightX    = 1,
                WeightY    = 1,
                VerticalScrollBarVisiblePolicy   = ScrollBarVisiblePolicy.Invisible,
                HorizontalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Auto,
                ScrollBlock = ScrollBlock.Vertical,
                HorizontalPageScrollLimit = 1,
            };

            ((IRotaryActionWidget)circleScroller).Activate();
            circleScroller.SetPageSize(1.0, 1.0);
            circleScroller.Show();
            conformant.SetContent(circleScroller);

            var box = new Box(window)
            {
                AlignmentX   = -1,
                AlignmentY   = -1,
                WeightX      = 1,
                WeightY      = 1,
                IsHorizontal = true,
            };

            box.Show();
            circleScroller.SetContent(box);

            for (int i = 0; i < 10; i++)
            {
                _views[i] = new LottieAnimationView(window)
                {
                    AlignmentX = -1,
                    AlignmentY = -1,
                    WeightX    = 1,
                    WeightY    = 1,
                    AutoRepeat = true,
                };
                _views[i].Show();

                var path = Path.Combine(DirectoryInfo.Resource, _files[i]);
                _views[i].SetAnimation(path);

                if (i == 0)
                {
                    _views[i].Play();
                }

                box.PackEnd(_views[i]);
            }

            circleScroller.Scrolled += (s, e) =>
            {
                if (_currentIndex != circleScroller.HorizontalPageIndex)
                {
                    int oldIndex = _currentIndex;
                    _currentIndex = circleScroller.HorizontalPageIndex;
                    EcoreMainloop.Post(() =>
                    {
                        if (_views[oldIndex].IsPlaying)
                        {
                            _views[oldIndex].Stop();
                        }
                        _views[_currentIndex].Play();
                    });
                }
            };
        }