Exemplo n.º 1
0
        private void MainGFX_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
        {
            SpriteObject obj = (lstSprites.SelectedItem as SpriteObject);

            if (obj != null)
            {
                switch (Keyboard.Modifiers)
                {
                case ModifierKeys.Alt:
                    break;

                case ModifierKeys.Control:
                    obj.Position   += 0.2 * ((Vector)e.GetPosition(MainGFX) - objMoveRefpoint);
                    objMoveRefpoint = (Vector)e.GetPosition(MainGFX);
                    break;

                case ModifierKeys.None:
                    objMoveRefpoint = (Vector)e.GetPosition(MainGFX);
                    break;

                case ModifierKeys.Shift:
                    if ((e.RightButton == MouseButtonState.Released) && (e.LeftButton == MouseButtonState.Pressed))
                    {
                        obj.Position = (Vector)e.GetPosition(MainGFX) - MainGFX.DrawingOffset;
                    }
                    break;

                case ModifierKeys.Windows:
                    break;

                default:
                    break;
                }
                if (e.RightButton == MouseButtonState.Pressed)
                {
                    double newY = obj.SizeV.Y + (e.GetPosition(MainGFX) - objResizeRefpoint).Y;
                    double newX = obj.SizeV.X + (e.GetPosition(MainGFX) - objResizeRefpoint).X;
                    if (newY < 1)
                    {
                        newY = 1;
                    }
                    if (newX < 1)
                    {
                        newX = 1;
                    }
                    objResizeRefpoint = (Vector)e.GetPosition(MainGFX);
                    if (Keyboard.Modifiers == ModifierKeys.Shift)
                    {
                        obj.SizeV = new Vector(newX, newY);
                    }
                    else
                    {
                        obj.ZoomPreserveAspectRatio(height: newY);
                    }
                }
            }
        }