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);
            });
        }
        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);
        }
        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);
        }
        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 #5
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 #7
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 #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);

            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 #10
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);
        }