Exemple #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);
            });
        }
Exemple #2
0
        public Task PostAsync(Action action)
        {
            var tcs = new TaskCompletionSource <bool>();

            if (EcoreMainloop.IsMainThread)
            {
                try
                {
                    action?.Invoke();
                    tcs.SetResult(true);
                }
                catch (Exception ex)
                {
                    tcs.SetException(ex);
                }
            }
            else
            {
                EcoreMainloop.PostAndWakeUp(() =>
                {
                    try
                    {
                        action?.Invoke();
                        tcs.SetResult(true);
                    }
                    catch (Exception ex)
                    {
                        tcs.SetException(ex);
                    }
                });
            }

            return(tcs.Task);
        }
Exemple #3
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;
        }
Exemple #4
0
        public void RunStandalone(string[] args)
        {
            ResourceDir = Path.Combine(Path.GetDirectoryName(typeof(TestRunner).GetTypeInfo().Assembly.Location), "res");

            EcoreSynchronizationContext.Initialize();

            var          testCases = GetTestCases();
            TestCaseBase theTest   = null;

            if (args.Count() > 0)
            {
                theTest = testCases.Where((testCase) => testCase.TestName == args[0] || testCase.GetType().ToString() == args[0]).FirstOrDefault();
            }

            if (theTest != null)
            {
                StartTC(theTest);
                EcoreMainloop.Begin();
            }
            else
            {
                CreateFirstPage(testCases);
                EcoreMainloop.Begin();
            }

            Elementary.Shutdown();
        }
Exemple #5
0
        public async Task PostAsync(Func <Task> action)
        {
            var tcs = new TaskCompletionSource <bool>();

            if (EcoreMainloop.IsMainThread)
            {
                try
                {
                    await action?.Invoke();

                    tcs.SetResult(true);
                }
                catch (Exception ex)
                {
                    tcs.SetException(ex);
                }
            }
            else
            {
                EcoreMainloop.PostAndWakeUp(async() =>
                {
                    try
                    {
                        await action?.Invoke();
                        tcs.SetResult(true);
                    }
                    catch (Exception ex)
                    {
                        tcs.SetException(ex);
                    }
                });
            }

            await tcs.Task;
        }
Exemple #6
0
        public TizenHost(Func <WinUI.Application> appBuilder, string[] args = null)
        {
            Elementary.Initialize();
            Elementary.ThemeOverlay();

            _current = this;

            _appBuilder = appBuilder;
            _args       = args;


            _args ??= Environment
            .GetCommandLineArgs()
            .Skip(1)
            .ToArray();

            bool EnqueueNative(DispatcherQueuePriority priority, DispatcherQueueHandler callback)
            {
                EcoreMainloop.PostAndWakeUp(() => callback());

                return(true);
            }

            Windows.System.DispatcherQueue.EnqueueNativeOverride = EnqueueNative;

            Windows.UI.Core.CoreDispatcher.DispatchOverride        = (d) => EcoreMainloop.PostAndWakeUp(d);
            Windows.UI.Core.CoreDispatcher.HasThreadAccessOverride = () => EcoreMainloop.IsMainThread;

            _tizenApplication = new TizenApplication(this);
            _tizenApplication.Run(_args);
        }
        public Task <IDecodedImage <SharedEvasImage> > DecodeAsync(Stream imageData, string path, ImageSource source, ImageInformation imageInformation, TaskParameter parameters)
        {
            if (imageData == null)
            {
                throw new ArgumentNullException(nameof(imageData));
            }

            TaskCompletionSource <IDecodedImage <SharedEvasImage> > tcs = new TaskCompletionSource <IDecodedImage <SharedEvasImage> >();

            ImageService.Instance.Config.MainThreadDispatcher.PostAsync(() =>
            {
                SharedEvasImage img = new SharedEvasImage(MainWindow);
                img.IsFilled        = true;
                img.Show();
                img.SetStream(imageData);
                imageData.TryDispose();

                img.AddRef();
                EcoreMainloop.AddTimer(1.0, () => {
                    img.RemoveRef();
                    return(false);
                });

                imageInformation.SetOriginalSize(img.Size.Width, img.Size.Height);
                imageInformation.SetCurrentSize(img.Size.Width, img.Size.Height);

                // DOWNSAMPLE
                if (parameters.DownSampleSize != null && (parameters.DownSampleSize.Item1 > 0 || parameters.DownSampleSize.Item2 > 0))
                {
                    // Calculate inSampleSize
                    int downsampleWidth  = parameters.DownSampleSize.Item1;
                    int downsampleHeight = parameters.DownSampleSize.Item2;

                    if (parameters.DownSampleUseDipUnits)
                    {
                        downsampleWidth  = downsampleWidth.DpToPixels();
                        downsampleHeight = downsampleHeight.DpToPixels();
                    }

                    int scaleDownFactor = CalculateScaleDownFactor(img.Size.Width, img.Size.Height, downsampleWidth, downsampleHeight);

                    if (scaleDownFactor > 1)
                    {
                        //System.//Console.WriteLine("GenerateImageAsync:: DownSample with {0}", scaleDownFactor);
                        imageInformation.SetCurrentSize(
                            (int)((double)img.Size.Width / scaleDownFactor),
                            (int)((double)img.Size.Height / scaleDownFactor));
                        EvasInterop.evas_object_image_load_scale_down_set(img.RealHandle, scaleDownFactor);
                    }
                }

                tcs.SetResult(new DecodedImage <SharedEvasImage>()
                {
                    Image = img
                });
            }).ConfigureAwait(false);

            return(tcs.Task);
        }
        public override void Run(Window window)
        {
            Log.Debug(TestName, "CircleProgressBar run");
            Conformant conformant = new Conformant(window);

            conformant.Show();

            var surface           = new CircleSurface(conformant);
            CircleProgressBar pb1 = new CircleProgressBar(conformant, surface)
            {
                AlignmentX = -1,
                AlignmentY = -1,
                WeightX    = 1,
                WeightY    = 1,

                // bar
                Value        = 0,
                Maximum      = 100,
                Minimum      = 0,
                BarRadius    = 100,
                BarLineWidth = 15,
                BarColor     = Color.Green,

                // background
                BackgroundRadius    = 100,
                BackgroundLineWidth = 15,
                BackgroundColor     = Color.Aqua,
            };

            pb1.Show();
            conformant.SetContent(pb1);
            Label lb1 = new Label(window)
            {
                Text = string.Format("S {0} %", pb1.Value),
            };

            lb1.Resize(window.ScreenSize.Width, window.ScreenSize.Height);
            lb1.Move(160, window.ScreenSize.Height / 2 - 40);
            lb1.Show();

            EcoreMainloop.AddTimer(0.05, () =>
            {
                if (pb1.Value == pb1.Maximum / 2)
                {
                    // Test purpose : set disable
                    pb1.IsEnabled = false;
                }

                if (pb1.Value == pb1.Maximum)
                {
                    EcoreMainloop.RemoveTimer(pb1);
                }

                pb1.Value += 1;
                lb1.Text   = string.Format("S {0} %", pb1.Value);

                return(true);
            });
        }
        protected override Task <SharedEvasImage> GenerateImageAsync(string path, ImageSource source, Stream imageData, ImageInformation imageInformation, bool enableTransformations, bool isPlaceholder)
        {
            if (imageData == null)
            {
                throw new ArgumentNullException(nameof(imageData));
            }

            ThrowIfCancellationRequested();

            TaskCompletionSource <SharedEvasImage> tcs = new TaskCompletionSource <SharedEvasImage>();

            MainThreadDispatcher.PostAsync(() =>
            {
                SharedEvasImage img = new SharedEvasImage(MainWindow);
                img.IsFilled        = true;
                img.Show();
                img.SetStream(imageData);
                imageData.TryDispose();

                img.AddRef();
                EcoreMainloop.AddTimer(1.0, () => {
                    img.RemoveRef();
                    return(false);
                });

                imageInformation.SetOriginalSize(img.Size.Width, img.Size.Height);
                imageInformation.SetCurrentSize(img.Size.Width, img.Size.Height);

                // DOWNSAMPLE
                if (Parameters.DownSampleSize != null && (Parameters.DownSampleSize.Item1 > 0 || Parameters.DownSampleSize.Item2 > 0))
                {
                    // Calculate inSampleSize
                    int downsampleWidth  = Parameters.DownSampleSize.Item1;
                    int downsampleHeight = Parameters.DownSampleSize.Item2;

                    if (Parameters.DownSampleUseDipUnits)
                    {
                        downsampleWidth  = DpiToPixels(downsampleWidth);
                        downsampleHeight = DpiToPixels(downsampleHeight);
                    }

                    int scaleDownFactor = CalculateScaleDownFactor(img.Size.Width, img.Size.Height, downsampleWidth, downsampleHeight);

                    if (scaleDownFactor > 1)
                    {
                        //System.//Console.WriteLine("GenerateImageAsync:: DownSample with {0}", scaleDownFactor);
                        imageInformation.SetCurrentSize(
                            (int)((double)img.Size.Width / scaleDownFactor),
                            (int)((double)img.Size.Height / scaleDownFactor));
                        EvasInterop.evas_object_image_load_scale_down_set(img.RealHandle, scaleDownFactor);
                    }
                }
                tcs.SetResult(img);
            });
            return(tcs.Task);
        }
Exemple #10
0
 public void Remove(EvasObject view)
 {
     InternalStack.Remove(view);
     UnPack(view);
     UpdateTopView();
     EcoreMainloop.Post(() =>
     {
         view?.Unrealize();
     });
 }
        public override void Run(Window window)
        {
            Log.Debug(TestName, "CircleProgressBar run");
            Conformant conformant = new Conformant(window);

            conformant.Show();

            Naviframe naviframe = new Naviframe(window);

            naviframe.Show();
            conformant.SetContent(naviframe);

            var surface           = new CircleSurface(conformant);
            CircleProgressBar pb1 = new CircleProgressBar(naviframe, surface)
            {
                AlignmentX = -1,
                AlignmentY = -1,
                WeightX    = 1,
                WeightY    = 1,
                Value      = 0,
                Maximum    = 100,
                Minimum    = 0,
            };

            pb1.Show();
            naviframe.Push(pb1, null, "empty");

            Label lb1 = new Label(window)
            {
                Text = string.Format("S {0} %", pb1.Value),
            };

            lb1.Resize(window.ScreenSize.Width, window.ScreenSize.Height);
            lb1.Move(160, window.ScreenSize.Height / 2 - 40);
            lb1.Show();

            EcoreMainloop.AddTimer(0.05, () =>
            {
                if (pb1.Value == pb1.Maximum / 2)
                {
                    // Test purpose : set disable
                    pb1.IsEnabled = false;
                }

                if (pb1.Value == pb1.Maximum)
                {
                    EcoreMainloop.RemoveTimer(pb1);
                }

                pb1.Value += 1;
                lb1.Text   = string.Format("S {0} %", pb1.Value);

                return(true);
            });
        }
Exemple #12
0
 static void PlatformBeginInvokeOnMainThread(Action action)
 {
     if (PlatformIsMainThread)
     {
         action();
     }
     else
     {
         EcoreMainloop.PostAndWakeUp(action);
     }
 }
        public IDisposable Schedule <TState>(TState state, Func <IScheduler, TState, IDisposable> action)
        {
            var innerDisp = new SingleAssignmentDisposable();

            EcoreMainloop.PostAndWakeUp(() => {
                if (!innerDisp.IsDisposed)
                {
                    innerDisp.Disposable = action(this, state);
                }
            });
            return(innerDisp);
        }
Exemple #14
0
 public static void DisposeOnMainThread(this SharedEvasImage image)
 {
     if (EcoreMainloop.IsMainThread)
     {
         image.Unrealize();
     }
     else
     {
         EcoreMainloop.Post(() => {
             image.Unrealize();
         });
     }
 }
Exemple #15
0
        public static async void PostAndWakeUp(Action action)
        {
            await _mutex.WaitAsync().ConfigureAwait(false);

            try
            {
                EcoreMainloop.PostAndWakeUp(action);
            }
            finally
            {
                _mutex.Release();
            }
        }
Exemple #16
0
        public static async void Quit()
        {
            await _mutex.WaitAsync().ConfigureAwait(false);

            try
            {
                EcoreMainloop.Quit();
            }
            finally
            {
                _mutex.Release();
            }
        }
Exemple #17
0
        public TizenHost(Func <WinUI.Application> appBuilder)
        {
            Elementary.Initialize();
            Elementary.ThemeOverlay();

            _current = this;

            _appBuilder = appBuilder;

            Windows.UI.Core.CoreDispatcher.DispatchOverride        = (d) => EcoreMainloop.PostAndWakeUp(d);
            Windows.UI.Core.CoreDispatcher.HasThreadAccessOverride = () => EcoreMainloop.IsMainThread;

            _tizenApplication = new TizenApplication(this);
            _tizenApplication.Run(Environment.GetCommandLineArgs());
        }
Exemple #18
0
        public TizenHost(Func <WinUI.Application> appBuilder, string[]?args = null)
        {
            Elementary.Initialize();
            Elementary.ThemeOverlay();

            _current = this;

            _appBuilder = appBuilder;

            Windows.UI.Core.CoreDispatcher.DispatchOverride        = (d) => EcoreMainloop.PostAndWakeUp(d);
            Windows.UI.Core.CoreDispatcher.HasThreadAccessOverride = () => EcoreMainloop.IsMainThread;

            _tizenApplication = new TizenApplication(this);
            _tizenApplication.Run(args);
        }
Exemple #19
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();
         });
     }
 }
Exemple #20
0
        public override void Run(Window window)
        {
            Log.Debug(TestName, "CircleProgressBar run");
            Conformant conformant = new Conformant(window);

            conformant.Show();

            var surface = new CircleSurface(conformant);

            CircleProgressBar pb1 = new CircleProgressBar(conformant, surface)
            {
                AlignmentX = -1,
                AlignmentY = -1,
                WeightX    = 1,
                WeightY    = 1,

                // default
                Value        = 20,
                Maximum      = 100,
                Minimum      = 0,
                BarRadius    = 80,
                BarLineWidth = 6,

                // background
                BackgroundRadius    = 80,
                BackgroundLineWidth = 6,
            };

            pb1.Show();
            conformant.SetContent(pb1);
            Label lb1 = new Label(window)
            {
                Text = string.Format("{0} %", pb1.Value),
            };

            lb1.Resize(window.ScreenSize.Width, window.ScreenSize.Height);
            lb1.Move(170, window.ScreenSize.Height / 2 - 20);
            lb1.Show();

            EcoreMainloop.AddTimer(0.05, () =>
            {
                pb1.Value += 1;
                lb1.Text   = string.Format("{0} %", pb1.Value);

                return(true);
            });
        }
        public IDisposable Schedule <TState>(TState state, TimeSpan dueTime, Func <IScheduler, TState, IDisposable> action)
        {
            var  innerDisp   = Disposable.Empty;
            bool isCancelled = false;

            IntPtr timer = EcoreMainloop.AddTimer(dueTime.TotalSeconds, () => {
                if (!isCancelled)
                {
                    innerDisp = action(this, state);
                }
                return(false);
            });

            return(Disposable.Create(() => {
                isCancelled = true;
                EcoreMainloop.RemoveTimer(timer);
                innerDisp.Dispose();
            }));
        }
Exemple #22
0
        /// <summary>
        /// Creates a WpfHost element to host a Uno-Skia into a WPF application.
        /// </summary>
        /// <remarks>
        /// If args are omitted, those from Environment.GetCommandLineArgs() will be used.
        /// </remarks>
        public TizenHost(Func <WinUI.Application> appBuilder, string[] args = null)
        {
            Elementary.Initialize();
            Elementary.ThemeOverlay();

            _current = this;

            _appBuilder = appBuilder;
            _args       = args;


            _args ??= Environment
            .GetCommandLineArgs()
            .Skip(1)
            .ToArray();

            Windows.UI.Core.CoreDispatcher.DispatchOverride
                = (d) => EcoreMainloop.PostAndWakeUp(d);

            _tizenApplication = new TizenApplication(this);
            _tizenApplication.Run(_args);
        }
 static void UIExit()
 {
     EcoreMainloop.Quit();
 }
Exemple #24
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);
        }
Exemple #25
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);
        }
Exemple #26
0
        public override void Run(Window window)
        {
            var square = window.GetInnerSquare();

            Background bg = new Background(window)
            {
                AlignmentX = -1,
                AlignmentY = -1,
                WeightX    = 1,
                WeightY    = 1,
                Color      = Color.Gray
            };

            bg.Show();
            window.AddResizeObject(bg);

            Conformant conformant = new Conformant(window);

            conformant.Show();


            int   number  = 0;
            bool  bReturn = true;
            Label label1  = new Label(window);

            label1.Geometry = new Rect(square.X, square.Y, square.Width, square.Height / 2);

            Button btnTimerSwitch = new Button(window);

            btnTimerSwitch.Text     = "Timer : On";
            btnTimerSwitch.Geometry = new Rect(square.X, square.Y + square.Height / 2, square.Width, square.Height / 2);

            Func <bool> handler = () =>
            {
                label1.Text = (++number).ToString();
                label1.EdjeObject["elm.text"].TextStyle = "DEFAULT='color=#000000 font_size=64 align=left valign=bottom wrap=word'";
                return(bReturn);
            };
            IntPtr prevId = EcoreMainloop.AddTimer(1.0, handler);

            btnTimerSwitch.Clicked += (s, e) =>
            {
                if (bReturn)
                {
                    bReturn             = false;
                    btnTimerSwitch.Text = "Timer : Off";
                }
                else
                {
                    bReturn             = true;
                    btnTimerSwitch.Text = "Timer : On";
                    EcoreMainloop.RemoveTimer(prevId);
                    prevId = EcoreMainloop.AddTimer(1.0, handler);
                }
            };

            window.BackButtonPressed += (s, e) =>
            {
                EcoreMainloop.RemoveTimer(prevId);
            };

            label1.Show();
            btnTimerSwitch.Show();
        }
        public override void Run(Window window)
        {
            Log.Debug(TestName, "CircleProgressBar run");
            Conformant conformant = new Conformant(window);

            conformant.Show();

            var surface           = new CircleSurface(conformant);
            CircleProgressBar pb1 = new CircleProgressBar(conformant, surface)
            {
                AlignmentX = -1,
                AlignmentY = -1,
                WeightX    = 1,
                WeightY    = 1,

                // Test purpose :  to test property related with angle

                // bar
                Maximum         = 100,
                BarRadius       = 100,
                BarLineWidth    = 20,
                BarColor        = Color.Green,
                BarAngleOffset  = 90,
                BarAngle        = 90,
                BarAngleMaximum = 180,

                // background
                BackgroundRadius      = 100,
                BackgroundLineWidth   = 20,
                BackgroundColor       = Color.Aqua,
                BackgroundAngleOffset = 90,
                BackgroundAngle       = 180,
            };

            pb1.Show();
            conformant.SetContent(pb1);
            Label lb1 = new Label(window)
            {
                Text = string.Format("V {0} %", pb1.Value),
            };

            lb1.Resize(window.ScreenSize.Width, window.ScreenSize.Height);
            lb1.Move(160, window.ScreenSize.Height / 2 - 40);
            lb1.Show();

            Label lb2 = new Label(window)
            {
                Text = string.Format("A {0} ", pb1.BarAngle),
            };

            lb2.Resize(window.ScreenSize.Width, window.ScreenSize.Height);
            lb2.Move(160, window.ScreenSize.Height / 2);
            lb2.Show();

            EcoreMainloop.AddTimer(0.5, () =>
            {
                pb1.Value += 1;

                lb1.Text = string.Format("V {0} %", pb1.Value);
                lb2.Text = string.Format("A {0} ", pb1.BarAngle);

                return(true);
            });
        }
Exemple #28
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);
        }
Exemple #29
0
 public static /*async*/ void RunOnDispatcher(Action action)
 {
     //Async call
     EcoreMainloop.Post(action);
 }
Exemple #30
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();
                    });
                }
            };
        }