Exemplo n.º 1
0
        private void PickerSite_MouseMove(object sender, MouseEventArgs e)
        {
            var pt = e.GetPosition(PickerSite);
            var c  = cpRender.HitTest((int)pt.X, (int)pt.Y);

            if (c == System.Drawing.Color.Empty && e.LeftButton != MouseButtonState.Pressed)
            {
                Cursor = Cursors.Arrow;
            }
            else
            {
                Cursor = Cursors.Cross;
            }

            if (dragPick)
            {
                var ev = new ColorHitEventArgs(c);

                ColorOver?.Invoke(this, ev);

                if (e.LeftButton == MouseButtonState.Pressed)
                {
                    SetSelectedColor(c);
                    ColorHit?.Invoke(this, ev);
                }
            }
        }
Exemplo n.º 2
0
        void OnTouch(object sender, TouchActionEventArgs args)
        {
            if (args.Type == TouchActionType.Pressed || args.Type == TouchActionType.Moved)
            {
                var pt = new UniPoint(args.Location.X, args.Location.Y);
                selCoord = pt;

                pt.X -= (Width - cpRender.Bounds.Width) / 2;
                pt.Y -= (Height - cpRender.Bounds.Height) / 2;

                if (!cpRender.Bounds.Contains((System.Drawing.PointF)pt))
                {
                    selCoord = null;
                    Canvas.InvalidateSurface();

                    return;
                }

                var c = cpRender.HitTest((int)pt.X, (int)pt.Y);
                if (c == System.Drawing.Color.Empty)
                {
                    selCoord = null;
                    Canvas.InvalidateSurface();
                    return;
                }

                Canvas.InvalidateSurface();
                SetSelectedColor(c);

                ColorHit?.Invoke(this, new ColorHitEventArgs(c));
            }
            else if (args.Type == TouchActionType.Moved)
            {
                var pt = new UniPoint(args.Location.X, args.Location.Y);

                pt.X -= (Width - cpRender.Bounds.Width) / 2;
                pt.Y -= (Height - cpRender.Bounds.Height) / 2;

                if (!cpRender.Bounds.Contains((System.Drawing.PointF)pt))
                {
                    return;
                }

                var c = cpRender.HitTest((int)pt.X, (int)pt.Y);
                if (c == System.Drawing.Color.Empty)
                {
                    return;
                }

                ColorOver?.Invoke(this, new ColorHitEventArgs(c));
            }
        }