Ejemplo n.º 1
0
 private void ArrowsClick(EnumDirection arrow)
 {
     if (!IsMouseDown)
     {
         var curPos   = Mouse.GetPosition(BorderSlider);
         var setMouse = BorderSlider.PointToScreen(mCenter);
         var value    = curPos - mCenter;
         if (ControlPressed)
         {
             value.Y *= (precision * precision);
             value.X *= (precision * precision);
         }
         else
         {
             value.Y *= precision;
             value.X *= precision;
         }
         if (arrow == EnumDirection.X)
         {
             value.Y = 0.0;
         }
         else
         {
             value.X = 0.0;
         }
         UpdatePosition(value, arrow);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Change IsMouseDown state
 /// </summary>
 private void Slider_MouseDown(object sender, MouseButtonEventArgs e)
 {
     if (target.IsMouseOver)
     {
         IsMouseDown     = true;
         IsMouseReseting = 2;
         var setMouse = BorderSlider.PointToScreen(mCenter);
         SetCursorPos((int)setMouse.X, (int)setMouse.Y);
         target.CaptureMouse();
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Simply grab a 1*1 pixel from the current color image, and
        /// use that and copy the new 1*1 image pixels to a byte array and
        /// then construct a Color from that.
        /// </summary>
        private void Slider_MouseMove(object sender, MouseEventArgs e)
        {
            e.Handled = true;
            if (!IsMouseDown)
            {
                return;
            }


            if (IsMouseReseting > 0)
            {
                IsMouseReseting--;
                return;
            }


            if (!shiftPressed)
            {
                shiftPressed = Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift);
            }


            try
            {
                IsMouseReseting++;
                var curPos   = Mouse.GetPosition(BorderSlider);
                var setMouse = BorderSlider.PointToScreen(mCenter);
                var value    = curPos - mCenter;
                if (!(value.X == 0.0 && value.Y == 0.0))
                {
                    if (shiftPressed)
                    {
                        if (direction == EnumDirection.Both)
                        {
                            //we must set a direction
                            if (Math.Abs(value.X) > Math.Abs(value.Y))
                            {
                                arrowY.Visibility = System.Windows.Visibility.Hidden;
                                direction         = EnumDirection.X;
                            }
                            else
                            {
                                arrowX.Visibility = System.Windows.Visibility.Hidden;
                                direction         = EnumDirection.Y;
                            }
                        }

                        if (direction == EnumDirection.X)
                        {
                            value.Y = 0.0;
                        }
                        else
                        {
                            value.X = 0.0;
                        }
                    }

                    if (ControlPressed)
                    {
                        arrowX.Width = constSmallArrows;
                        arrowY.Width = constSmallArrows;

                        value.X *= precision;
                        value.Y *= precision;
                    }
                    else
                    {
                        arrowX.Width = constBigArrows;
                        arrowY.Width = constBigArrows;
                    }

                    UpdatePosition(value, direction);
                }

                SetCursorPos((int)setMouse.X, (int)setMouse.Y);
            }
            catch
            {
                //not much we can do
            }
        }