void ApplyTranslation(EvasMap map, ERect geometry, ref bool changed)
        {
            var shiftX = Forms.ConvertToScaledPixel(Element.TranslationX);
            var shiftY = Forms.ConvertToScaledPixel(Element.TranslationY);

            // apply translation, i.e. move/shift the object a little
            if (shiftX != 0 || shiftY != 0)
            {
                if (changed)
                {
                    // special care is taken to apply the translation last
                    Point3D p;
                    for (int i = 0; i < 4; i++)
                    {
                        p    = map.GetPointCoordinate(i);
                        p.X += shiftX;
                        p.Y += shiftY;
                        map.SetPointCoordinate(i, p);
                    }
                }
                else
                {
                    // in case when we only need translation, then construct the map in a simpler way
                    geometry.X += shiftX;
                    geometry.Y += shiftY;
                    map.PopulatePoints(geometry, 0);

                    changed = true;
                }
            }
        }
Exemple #2
0
        void EventHandler(RotaryEventArgs args)
        {
            if (args.IsClockwise)
            {
                degrees += 10;
            }
            else
            {
                degrees -= 10;
            }

            if (degrees < 0)
            {
                degrees = 360;
            }
            else if (degrees > 360)
            {
                degrees = 0;
            }

            Rect    r   = rect.Geometry;
            EvasMap map = new EvasMap(4);

            map.PopulatePoints(rect, 0);
            map.Rotate(degrees, r.X + r.Width / 2, r.Y + r.Height / 2);
            rect.EvasMap      = map;
            rect.IsMapEnabled = true;
        }
        /// <summary>
        /// Changes the rotation of the given hand image.
        /// </summary>
        /// <param name="img">The image to be modified.</param>
        /// <param name="time">The time value used to calculate the angle.</param>
        /// <param name="maxTime">The maximal value the <code>time</code>
        /// parameter (12 for hours, 60 for minutes and seconds).</param>
        private void _updateHand(Image img, int time, int maxTime)
        {
            double rotation = time / (float)maxTime * 360.0;

            EvasMap map = new EvasMap(4);

            map.PopulatePoints(img, 0);
            map.Rotate(rotation, 180, 180);
            img.EvasMap      = map;
            img.IsMapEnabled = true;
        }
Exemple #4
0
        public override void Run(Window window)
        {
            Log.Debug("window id is " + window.Handle.ToString());
            Rect square = window.GetInnerSquare();

            Log.Debug(square.ToString());

            Rectangle redSquare = new Rectangle(window)
            {
                Color    = Color.Red,
                Geometry = square
            };

            redSquare.Show();

            double degrees = 0;

            RotaryEventHandler handler = (args) =>
            {
                if (args.IsClockwise)
                {
                    degrees += 10;
                }
                else
                {
                    degrees -= 10;
                }

                if (degrees < 0)
                {
                    degrees = 360;
                }
                else if (degrees > 360)
                {
                    degrees = 0;
                }

                Rect    rect = redSquare.Geometry;
                EvasMap map  = new EvasMap(4);
                map.PopulatePoints(redSquare, 0);
                map.Rotate(degrees, rect.X + rect.Width / 2, rect.Y + rect.Height / 2);
                redSquare.EvasMap      = map;
                redSquare.IsMapEnabled = true;
            };

            RotaryEventManager.Rotated += handler;

            window.BackButtonPressed += (s, e) =>
            {
                RotaryEventManager.Rotated -= handler;
                Log.Debug("handler is Removed!!!!!!!");
            };
        }
Exemple #5
0
        IntPtr OnIconCallback(IntPtr data, IntPtr window, ref int xoff, ref int yoff)
        {
            EvasObject icon   = null;
            EvasObject parent = new CustomWindow(NativeView, window);

            if (s_currentDragStateData.DataPackage.Image != null)
            {
                icon = GetImageIcon(parent);
            }
            else if (NativeView is ShapeView)
            {
                icon = GetShapeView(parent);
            }
            else
            {
                icon = GetDefaultIcon(parent);
            }
            var bound = NativeView.Geometry;

            bound.X       = 0;
            bound.Y       = 0;
            icon.Geometry = bound;

            if (icon is Native.Label)
            {
                icon.Resized += (s, e) =>
                {
                    var map = new EvasMap(4);
                    map.PopulatePoints(icon.Geometry, 0);
                    map.Zoom(0.5, 0.5, 0, 0);
                    icon.IsMapEnabled = true;
                    icon.EvasMap      = map;
                };
            }
            else
            {
                var map = new EvasMap(4);
                map.PopulatePoints(icon.Geometry, 0);
                map.Zoom(0.5, 0.5, 0, 0);
                icon.IsMapEnabled = true;
                icon.EvasMap      = map;
            }


            return(icon);
        }
Exemple #6
0
        public static void UpdateTransformation(this EvasObject platformView, IView?view)
        {
            if (view == null)
            {
                return;
            }

            // prepare the EFL effect structure
            Rect    geometry = platformView.Geometry;
            EvasMap map      = new EvasMap(4);

            map.PopulatePoints(geometry, 0);

            bool changed = false;

            view.ApplyScale(map, geometry, ref changed);
            view.ApplyRotation(platformView, map, geometry, ref changed);
            view.ApplyTranslation(map, geometry, ref changed);

            platformView.IsMapEnabled = changed;

            if (changed)
            {
                platformView.EvasMap = map;
                if (!s_movedHandlers.ContainsKey(platformView))
                {
                    // not registered moved handler
                    s_movedHandlers[platformView] = () => platformView.UpdateTransformation(view);
                    platformView.Moved           += OnMoved;
                }
            }
            else
            {
                if (s_movedHandlers.ContainsKey(platformView))
                {
                    // need to unregister moved handler
                    platformView.Moved -= OnMoved;
                    s_movedHandlers.Remove(platformView);
                }
            }
        }
Exemple #7
0
        void ApplyTransformation()
        {
            EvasMap map      = new EvasMap(4);
            Rect    geometry = _box1.Geometry;

            map.PopulatePoints(geometry, 0);

            map.Rotate3D(0, 0, _angle, (int)(geometry.X + geometry.Width * 0.5), (int)(geometry.Y + geometry.Height * 0.5), 0);

            Point3D p;

            for (int i = 0; i < 4; i++)
            {
                p    = map.GetPointCoordinate(i);
                p.X += _totalX;
                p.Y += _totalY;
                map.SetPointCoordinate(i, p);
            }
            _box1.EvasMap      = map;
            _box1.IsMapEnabled = true;
        }
        protected virtual void ApplyTransformation()
        {
            if (null == NativeView)
            {
                Log.Error("Trying to apply transformation to the non-existent native control");
                return;
            }

            // prepare the EFL effect structure
            ERect   geometry = NativeView.Geometry;
            EvasMap map      = new EvasMap(4);

            map.PopulatePoints(geometry, 0);

            bool changed = false;

            ApplyRotation(map, geometry, ref changed);
            ApplyScale(map, geometry, ref changed);
            ApplyTranslation(map, geometry, ref changed);

            NativeView.IsMapEnabled = changed;
            if (changed)
            {
                NativeView.EvasMap = map;
                if (!_movedCallbackEnabled)
                {
                    _movedCallbackEnabled = true;
                    NativeView.Moved     += OnMoved;
                }
            }
            else
            {
                if (_movedCallbackEnabled)
                {
                    _movedCallbackEnabled = false;
                    NativeView.Moved     -= OnMoved;
                }
            }
        }
Exemple #9
0
        public override void Run(Window window)
        {
            var square = window.GetInnerSquare();

            var box = new Box(window)
            {
                Geometry        = new Rect(square.X, square.Y, square.Width, square.Height / 2),
                BackgroundColor = Color.Gray
            };

            box.Show();

            var text = new Label(box)
            {
                Text       = "<span color=#ffffff font_size=30>Target</span>",
                AlignmentX = -1.0,
                AlignmentY = -1.0,
                WeightX    = 1.0,
                WeightY    = 1.0,
            };

            text.Show();

            box.PackEnd(text);

            double angle = 0.0;

            var reset = new Button(box)
            {
                Text     = "Reset",
                Geometry = new Rect(square.X, square.Y + square.Height / 2, square.Width, square.Height / 6)
            };

            reset.Show();

            double zx = 1.0;
            double zy = 1.0;

            reset.Clicked += (object sender, EventArgs e) =>
            {
                text.IsMapEnabled = false;
                angle             = 0.0;
                zx = 1.0;
                zy = 1.0;
            };

            var zoom = new Button(box)
            {
                Text     = "Zoom Target",
                Geometry = new Rect(square.X, square.Y + square.Height / 2 + square.Height / 6, square.Width, square.Height / 6)
            };

            zoom.Show();

            zoom.Clicked += (object sender, EventArgs e) =>
            {
                zx += 0.1;
                zy += 0.1;
                var map = new EvasMap(4);
                var g   = text.Geometry;
                map.PopulatePoints(g, 0);
                map.Rotate3D(0, 0, angle, g.X + g.Width / 2, g.Y + g.Height / 2, 0);
                map.Zoom(zx, zy, g.X, g.Y);
                text.EvasMap      = map;
                text.IsMapEnabled = true;
            };

            var rotate = new Button(box)
            {
                Text     = "Rotate Target",
                Geometry = new Rect(square.X, square.Y + square.Height / 2 + square.Height * 2 / 6, square.Width, square.Height / 6)
            };

            rotate.Show();

            rotate.Clicked += (object sender, EventArgs e) =>
            {
                angle += 5.0;
                var map = new EvasMap(4);
                var g   = text.Geometry;
                map.PopulatePoints(g, 0);
                map.Rotate3D(0, 0, angle, g.X + g.Width / 2, g.Y + g.Height / 2, 0);
                map.Zoom(zx, zy, g.X, g.Y);
                text.EvasMap      = map;
                text.IsMapEnabled = true;
            };
        }
Exemple #10
0
        public override void Run(Window window)
        {
            Conformant conformant = new Conformant(window);

            conformant.Show();
            Box table = new Box(window)
            {
                BackgroundColor = Color.White,
            };

            conformant.SetContent(table);
            table.Show();

            ProgressBar pb1 = new ProgressBar(window)
            {
                Text       = "ProgressBar Test",
                Style      = "process_medium",
                Value      = 0.1,
                AlignmentX = 0,
                AlignmentY = 0,
                WeightX    = 0,
                WeightY    = 1
            };

            pb1.PlayPulse();
            Label lb1 = new Label(window)
            {
                AlignmentX = -1,
                AlignmentY = -1,
                WeightX    = 1,
                WeightY    = 1,
            };

            Button bt1 = new Button(window)
            {
                Text       = "Increase Value",
                AlignmentX = -1,
                AlignmentY = 0,
                WeightX    = 1,
                WeightY    = 1
            };

            bt1.Clicked += (s, e) =>
            {
                Random rand = new Random(DateTime.UtcNow.Millisecond);
                pb1.Color = new Color(rand.Next(255), rand.Next(255), rand.Next(255));
                lb1.Text  = pb1.Color.ToString();
            };

            Button bt2 = new Button(window)
            {
                Text       = "zoom",
                AlignmentX = -1,
                AlignmentY = 0,
                WeightX    = 1,
                WeightY    = 1
            };

            bt2.Clicked += (s, e) =>
            {
                var map = new EvasMap(4);
                var g   = pb1.Geometry;
                map.PopulatePoints(g, 0);
                map.Zoom(2, 2, g.X, g.Y);
                pb1.EvasMap      = map;
                pb1.IsMapEnabled = true;
            };

            table.PackEnd(pb1);
            table.PackEnd(lb1);
            table.PackEnd(bt1);
            table.PackEnd(bt2);

            pb1.Show();
            lb1.Show();
            bt1.Show();
            bt2.Show();
        }
Exemple #11
0
        public override void Run(Window window)
        {
            var square = window.GetInnerSquare();
            var box    = new Box(window)
            {
                Geometry        = new Rect(square.X, square.Y, square.Width, square.Height / 2),
                BackgroundColor = Color.Gray
            };

            box.Show();

            var group = new Box(box)
            {
                IsHorizontal    = true,
                BackgroundColor = Color.White,
            };

            group.Show();

            var x = new Label(group)
            {
                Text = "X",
            };

            x.Show();

            var y = new Label(group)
            {
                Text = "Y",
            };

            y.Show();

            var z = new Label(group)
            {
                Text = "Z",
            };

            z.Show();
            group.PackEnd(x);
            group.PackEnd(y);
            group.PackEnd(z);

            var top = new Rectangle(box)
            {
                Color = Color.Red,
            };

            top.SetAlignment(-1.0, -1.0); // fill
            top.SetWeight(1.0, 1.0);      // expand
            top.Show();

            var bottom = new Rectangle(box)
            {
                Color = Color.Green,
            };

            bottom.SetAlignment(-1.0, -1.0); // fill
            bottom.SetWeight(1.0, 1.0);      // expand
            bottom.Show();

            double angle = 0.0;

            var reset = new Button(box)
            {
                Text     = "Reset",
                Geometry = new Rect(square.X, square.Y + square.Height / 2, square.Width, square.Height / 6)
            };

            reset.Show();

            reset.Clicked += (object sender, EventArgs e) =>
            {
                group.IsMapEnabled = false;
                x.IsMapEnabled     = false;
                angle = 0.0;
            };

            var zoom = new Button(box)
            {
                Text     = "Zoom group",
                Geometry = new Rect(square.X, square.Y + square.Height / 2 + square.Height / 6, square.Width, square.Height / 6)
            };

            zoom.Show();

            zoom.Clicked += (object sender, EventArgs e) =>
            {
                var map = new EvasMap(4);
                var g   = group.Geometry;
                map.PopulatePoints(g, 0);
                map.Zoom(3.0, 3.0, g.X + g.Width / 2, g.Y + g.Height / 2);
                group.EvasMap      = map;
                group.IsMapEnabled = true;
            };

            var rotate = new Button(box)
            {
                Text     = "Rotate X",
                Geometry = new Rect(square.X, square.Y + square.Height / 2 + square.Height * 2 / 6, square.Width, square.Height / 6)
            };

            rotate.Show();

            rotate.Clicked += (object sender, EventArgs e) =>
            {
                angle += 5.0;

                var map = new EvasMap(4);
                var g   = x.Geometry;
                map.PopulatePoints(g, 0);
                map.Rotate3D(0, 0, angle, g.X + g.Width / 2, g.Y + g.Height / 2, 0);
                x.EvasMap      = map;
                x.IsMapEnabled = true;
            };

            box.PackEnd(top);
            box.PackEnd(group);
            box.PackEnd(bottom);
        }
Exemple #12
0
        public override void Run(Window window)
        {
            var box = new Box(window)
            {
                IsHorizontal = false,
            };

            box.SetAlignment(-1.0, -1.0);
            box.SetWeight(1.0, 1.0);
            box.Show();

            var text = new Label(box)
            {
                Text       = "<span color=#ffffff font_size=30>Target</span>",
                AlignmentX = -1.0,
                AlignmentY = -1.0,
                WeightX    = 1.0,
                WeightY    = 1.0,
            };

            text.Show();

            var textBox = new Box(box)
            {
                AlignmentX = -1.0,
                WeightX    = 1.0,
                WeightY    = 0.7,
            };

            textBox.PackEnd(text);
            textBox.Show();

            double angle = 0.0;

            var reset = new Button(box)
            {
                Text       = "Reset",
                AlignmentX = -1.0,
                WeightX    = 1.0,
                WeightY    = 0.1,
            };

            reset.Show();

            double zx = 1.0;
            double zy = 1.0;

            reset.Clicked += (object sender, EventArgs e) =>
            {
                text.IsMapEnabled = false;
                angle             = 0.0;
                zx = 1.0;
                zy = 1.0;
            };

            var zoom = new Button(box)
            {
                Text       = "Zoom Target",
                AlignmentX = -1.0,
                WeightX    = 1.0,
                WeightY    = 0.1,
            };

            zoom.Show();

            zoom.Clicked += (object sender, EventArgs e) =>
            {
                zx += 0.1;
                zy += 0.1;
                var map = new EvasMap(4);
                var g   = text.Geometry;
                map.PopulatePoints(g, 0);
                map.Rotate3D(0, 0, angle, g.X + g.Width / 2, g.Y + g.Height / 2, 0);
                map.Zoom(zx, zy, g.X, g.Y);
                text.EvasMap      = map;
                text.IsMapEnabled = true;
            };

            var rotate = new Button(box)
            {
                Text       = "Rotate Target",
                AlignmentX = -1.0,
                WeightX    = 1.0,
                WeightY    = 0.1,
            };

            rotate.Show();

            rotate.Clicked += (object sender, EventArgs e) =>
            {
                angle += 5.0;
                var map = new EvasMap(4);
                var g   = text.Geometry;
                map.PopulatePoints(g, 0);
                map.Rotate3D(0, 0, angle, g.X + g.Width / 2, g.Y + g.Height / 2, 0);
                map.Zoom(zx, zy, g.X, g.Y);
                text.EvasMap      = map;
                text.IsMapEnabled = true;
            };

            box.PackEnd(textBox);
            box.PackEnd(reset);
            box.PackEnd(zoom);
            box.PackEnd(rotate);

            box.Resize(window.ScreenSize.Width, window.ScreenSize.Height);
            box.Move(0, 0);
        }
Exemple #13
0
        /*
         * void ApplyRotation(EvasMap map, Rect geometry, ref bool changed)
         * {
         *  var rotationX = Element.RotationX;
         *  var rotationY = Element.RotationY;
         *  var rotationZ = Element.Rotation;
         *  var anchorX = Element.AnchorX;
         *  var anchorY = Element.AnchorY;
         *
         *  // apply rotations
         *  if (rotationX != 0 || rotationY != 0 || rotationZ != 0)
         *  {
         *      map.Rotate3D(rotationX, rotationY, rotationZ, (int)(geometry.X + geometry.Width * anchorX),
         *                                                    (int)(geometry.Y + geometry.Height * anchorY), 0);
         *      changed = true;
         *  }
         * }
         *
         * void ApplyScale(EvasMap map, Rect geometry, ref bool changed)
         * {
         *  var scale = Element.Scale;
         *
         *  // apply scale factor
         *  if (scale != 1.0)
         *  {
         *      map.Zoom(scale, scale,
         *          geometry.X + (int)(geometry.Width * view.AnchorX),
         *          geometry.Y + (int)(geometry.Height * Element.AnchorY));
         *      changed = true;
         *  }
         * }
         *
         * void ApplyTranslation(EvasMap map, Rect geometry, ref bool changed)
         * {
         *  var shiftX = Forms.ConvertToScaledPixel(Element.TranslationX);
         *  var shiftY = Forms.ConvertToScaledPixel(Element.TranslationY);
         *
         *  // apply translation, i.e. move/shift the object a little
         *  if (shiftX != 0 || shiftY != 0)
         *  {
         *      if (changed)
         *      {
         *          // special care is taken to apply the translation last
         *          Point3D p;
         *          for (int i = 0; i < 4; i++)
         *          {
         *              p = map.GetPointCoordinate(i);
         *              p.X += shiftX;
         *              p.Y += shiftY;
         *              map.SetPointCoordinate(i, p);
         *          }
         *      }
         *      else
         *      {
         *          // in case when we only need translation, then construct the map in a simpler way
         *          geometry.X += shiftX;
         *          geometry.Y += shiftY;
         *          map.PopulatePoints(geometry, 0);
         *
         *          changed = true;
         *      }
         *  }
         * }
         */

        /// <summary>
        /// Set Matrix of view instance.
        /// </summary>
        internal static void SetMatrix(this EvasObject view, ReactNative.UIManager.MatrixMathHelper.MatrixDecompositionContext matrix, bool reset)
        {
            if (view == null)
            {
                throw new ArgumentNullException(nameof(view));
            }

            double TranslationX = 0;
            double TranslationY = 0;
            double rotationX    = 0;
            double rotationY    = 0;
            double rotationZ    = 0;
            double ScaleX       = 1;
            double ScaleY       = 1;

            if (matrix != null)
            {
                TranslationX = matrix.translation[0];
                TranslationY = matrix.translation[1];
                rotationX    = matrix.rotationDegrees[0];
                rotationY    = matrix.rotationDegrees[1];
                rotationZ    = matrix.rotationDegrees[2];
                ScaleX       = matrix.scale[0];
                ScaleY       = matrix.scale[1];
            }

            var map = new EvasMap(4);
            var g   = view.Geometry;

            map.PopulatePoints(g, 0);

            //setScale
            map.Zoom(ScaleX, ScaleY,
                     view.Geometry.X + (int)(view.Geometry.Width * 0.5),
                     view.Geometry.Y + (int)(view.Geometry.Height * 0.5));

            //setRotation
            map.Rotate3D(rotationX, rotationY, rotationZ,
                         (int)(view.Geometry.X + view.Geometry.Width * 0.5), (int)(view.Geometry.Y + view.Geometry.Height * 0.5), 0);

            //setTranslation
            var shiftX = TranslationX;
            var shiftY = TranslationY;

            Point3D p;

            for (int i = 0; i < 4; i++)
            {
                p    = map.GetPointCoordinate(i);
                p.X += (int)shiftX;
                p.Y += (int)shiftY;
                map.SetPointCoordinate(i, p);
            }

            view.EvasMap      = map;
            view.IsMapEnabled = true;

            if (!reset)
            {
                if (matrix != null)
                {
                    s_properties.GetOrCreateValue(view).matrix = matrix.Clone();
                }
            }
        }