Beispiel #1
0
        void ApplyScale(EvasMap map, ERect geometry, ref bool changed)
        {
            var scale = Element.Scale;

            // apply scale factor
            if (scale != 1.0)
            {
                map.Zoom(scale, scale,
                         geometry.X + (int)(geometry.Width * Element.AnchorX),
                         geometry.Y + (int)(geometry.Height * Element.AnchorY));
                changed = true;
            }
        }
Beispiel #2
0
        internal static void ApplyScale(this IView view, EvasMap map, Rect geometry, ref bool changed)
        {
            var scale  = view.Scale;
            var scaleX = view.ScaleX * scale;
            var scaleY = view.ScaleY * scale;

            // apply scale factor
            if (scaleX != 1.0 || scaleY != 1.0)
            {
                map.Zoom(scaleX, scaleY,
                         geometry.X + (int)(geometry.Width * view.AnchorX),
                         geometry.Y + (int)(geometry.Height * view.AnchorY));
                changed = true;
            }
        }
Beispiel #3
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);
        }
Beispiel #4
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;
            };
        }
Beispiel #5
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();
        }
Beispiel #6
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);
        }
Beispiel #7
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);
        }
Beispiel #8
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();
                }
            }
        }