Exemplo n.º 1
0
        public EngineNS.Vector2 GetMousePos()
        {
            var screenPos = new ResourceLibrary.Win32.POINT();

            if (ResourceLibrary.Win32.GetCursorPos(ref screenPos))
            {
                return(new EngineNS.Vector2(screenPos.X, screenPos.Y));
            }

            return(EngineNS.Vector2.Zero);
        }
        private void Arrow_Bottom_B_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            SelectRectHeight++;

            var delta = (int)(ImageViewBox.Width / Image_Pic.Width);
            var pt    = new ResourceLibrary.Win32.POINT();

            ResourceLibrary.Win32.GetCursorPos(ref pt);
            ResourceLibrary.Win32.SetCursorPos(pt.X, pt.Y + delta);

            e.Handled = true;
        }
        private void Arrow_Right_L_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            if (SelectRectWidth > 0)
            {
                SelectRectWidth--;
            }

            var delta = (int)(ImageViewBox.Width / Image_Pic.Width);
            var pt    = new ResourceLibrary.Win32.POINT();

            ResourceLibrary.Win32.GetCursorPos(ref pt);
            ResourceLibrary.Win32.SetCursorPos(pt.X - delta, pt.Y);

            e.Handled = true;
        }
Exemplo n.º 4
0
        private void textBlock_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            if (IsReadOnly)
            {
                return;
            }

            mDraged     = true;
            mMouseMoved = false;

            mScreenHeightCount = 0;
            var screenPos = new ResourceLibrary.Win32.POINT();

            ResourceLibrary.Win32.GetCursorPos(ref screenPos);
            mMouseDownScreenRect = System.Windows.Forms.Screen.GetWorkingArea(new System.Drawing.Point(screenPos.X, screenPos.Y));

            var textBlock = e.OriginalSource as TextBlock;

            mMouseLeftButtonDownPoint = e.GetPosition(textBlock);
            mValueStore = NumericObject;
            //Mouse.Capture(textBlock);
            textBlock.CaptureMouse();
            e.Handled = true;
        }
Exemplo n.º 5
0
        private void textBlock_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
        {
            if (mDraged)
            {
                var screenPos = new ResourceLibrary.Win32.POINT();
                ResourceLibrary.Win32.GetCursorPos(ref screenPos);
                if (screenPos.Y <= mMouseDownScreenRect.Top)
                {
                    screenPos.Y = mMouseDownScreenRect.Bottom - 1;
                    ResourceLibrary.Win32.SetCursorPos(screenPos.X, screenPos.Y);
                    mScreenHeightCount--;
                }
                else if (screenPos.Y >= mMouseDownScreenRect.Bottom)
                {
                    screenPos.Y = mMouseDownScreenRect.Top + 1;
                    ResourceLibrary.Win32.SetCursorPos(screenPos.X, screenPos.Y);
                    mScreenHeightCount++;
                }

                var pos = e.GetPosition((UIElement)sender);
                pos.Y += mScreenHeightCount * mMouseDownScreenRect.Height;
                if (mMouseMoved == false)
                {
                    var length = pos.Y - mMouseLeftButtonDownPoint.Y;
                    if (System.Math.Abs(length) > 0)
                    {
                        mMouseMoved = true;
                    }
                }

                var delta = mMouseLeftButtonDownPoint.Y - pos.Y;

                Attribute attr = null;
                if (BindProperty != null)
                {
                    attr = BindProperty.Attributes[typeof(EngineNS.Editor.Editor_MultipleOfTwoAttribute)] as EngineNS.Editor.Editor_MultipleOfTwoAttribute;
                }
                if (attr != null)
                {
                    if (System.Math.Abs(delta) > 10)
                    {
                        if (NumericObject.GetType() == typeof(SByte))
                        {
                            if (delta > 0)
                            {
                                var value = (SByte)NumericObject;
                                NumericObject = (SByte)(value * 2);
                            }
                            else
                            {
                                var value = (SByte)NumericObject;
                                NumericObject = (SByte)(value / 2);
                            }
                        }
                        else if (NumericObject.GetType() == typeof(Int16))
                        {
                            if (delta > 0)
                            {
                                var value = (Int16)NumericObject;
                                NumericObject = (Int16)(value * 2);
                            }
                            else
                            {
                                var value = (Int16)NumericObject;
                                NumericObject = (Int16)(value / 2);
                            }
                        }
                        else if (NumericObject.GetType() == typeof(Int32))
                        {
                            if (delta > 0)
                            {
                                var value = (Int32)NumericObject;
                                NumericObject = (Int32)(value * 2);
                            }
                            else
                            {
                                var value = (Int32)NumericObject;
                                NumericObject = (Int32)(value / 2);
                            }
                        }
                        else if (NumericObject.GetType() == typeof(Int64))
                        {
                            if (delta > 0)
                            {
                                var value = (Int64)NumericObject;
                                NumericObject = (Int64)(value * 2);
                            }
                            else
                            {
                                var value = (Int64)NumericObject;
                                NumericObject = (Int64)(value / 2);
                            }
                        }
                        else if (NumericObject.GetType() == typeof(Byte))
                        {
                            if (delta > 0)
                            {
                                var value = (Byte)NumericObject;
                                NumericObject = (Byte)(value * 2);
                            }
                            else
                            {
                                var value = (Byte)NumericObject;
                                NumericObject = (Byte)(value / 2);
                            }
                        }
                        else if (NumericObject.GetType() == typeof(UInt16))
                        {
                            if (delta > 0)
                            {
                                var value = (UInt16)NumericObject;
                                NumericObject = (UInt16)(value * 2);
                            }
                            else
                            {
                                var value = (UInt16)NumericObject;
                                NumericObject = (UInt16)(value / 2);
                            }
                        }
                        else if (NumericObject.GetType() == typeof(UInt32))
                        {
                            if (delta > 0)
                            {
                                var value = (UInt32)NumericObject;
                                NumericObject = (UInt32)(value * 2);
                            }
                            else
                            {
                                var value = (UInt32)NumericObject;
                                NumericObject = (UInt32)(value / 2);
                            }
                        }
                        else if (NumericObject.GetType() == typeof(UInt64))
                        {
                            if (delta > 0)
                            {
                                var value = (UInt64)NumericObject;
                                NumericObject = (UInt64)(value * 2);
                            }
                            else
                            {
                                var value = (UInt64)NumericObject;
                                NumericObject = (UInt64)(value / 2);
                            }
                        }
                        else if (NumericObject.GetType() == typeof(Single))
                        {
                            if (delta > 0)
                            {
                                var value = (Single)NumericObject;
                                NumericObject = (Single)(value * 2);
                            }
                            else
                            {
                                var value = (Single)NumericObject;
                                NumericObject = (Single)(value / 2);
                            }
                        }
                        else if (NumericObject.GetType() == typeof(Double))
                        {
                            if (delta > 0)
                            {
                                var value = (Double)NumericObject;
                                NumericObject = (Double)(value * 2);
                            }
                            else
                            {
                                var value = (Double)NumericObject;
                                NumericObject = (Double)(value / 2);
                            }
                        }

                        mMouseLeftButtonDownPoint = pos;
                    }
                }
                else
                {
                    //if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
                    //    delta *= 2;
                    if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                    {
                        delta /= 20;
                    }

                    if (NumericObject.GetType() == typeof(SByte))
                    {
                        SByte value = (SByte)mValueStore;
                        value += (SByte)delta;
                        if (IsShiftDown)
                        {
                            value = (SByte)(value / 5 * 5);
                        }
                        NumericObject = value;
                    }
                    else if (NumericObject.GetType() == typeof(Int16))
                    {
                        Int16 value = (Int16)mValueStore;
                        value += (Int16)delta;
                        if (IsShiftDown)
                        {
                            value = (Int16)(value / 5 * 5);
                        }
                        NumericObject = value;
                    }
                    else if (NumericObject.GetType() == typeof(Int32))
                    {
                        Int32 value = (Int32)mValueStore;
                        value += (Int32)delta;
                        if (IsShiftDown)
                        {
                            value = (Int32)(value / 5 * 5);
                        }
                        NumericObject = value;
                    }
                    else if (NumericObject.GetType() == typeof(Int64))
                    {
                        Int64 value = (Int64)mValueStore;
                        value += (Int64)delta;
                        if (IsShiftDown)
                        {
                            value = (Int64)(value / 5 * 5);
                        }
                        NumericObject = value;
                    }
                    else if (NumericObject.GetType() == typeof(Byte))
                    {
                        Byte value = (Byte)mValueStore;
                        value += (Byte)delta;
                        if (IsShiftDown)
                        {
                            value = (Byte)(value / 5 * 5);
                        }
                        NumericObject = value;
                    }
                    else if (NumericObject.GetType() == typeof(UInt16))
                    {
                        UInt16 value = (UInt16)mValueStore;
                        value += (UInt16)delta;
                        if (IsShiftDown)
                        {
                            value = (UInt16)(value / 5 * 5);
                        }
                        NumericObject = value;
                    }
                    else if (NumericObject.GetType() == typeof(UInt32))
                    {
                        UInt32 value = (UInt32)mValueStore;
                        value += (UInt32)delta;
                        if (IsShiftDown)
                        {
                            value = (UInt32)(value / 5 * 5);
                        }
                        NumericObject = value;
                    }
                    else if (NumericObject.GetType() == typeof(UInt64))
                    {
                        UInt64 value = (UInt64)mValueStore;
                        value += (UInt64)delta;
                        if (IsShiftDown)
                        {
                            value = (UInt64)(value / 5 * 5);
                        }
                        NumericObject = value;
                    }
                    else if (NumericObject.GetType() == typeof(Single))
                    {
                        Single value = (Single)mValueStore;
                        value += (Single)delta;
                        if (IsShiftDown)
                        {
                            value = (int)value / 5 * 5;
                        }
                        NumericObject = value;
                    }
                    else if (NumericObject.GetType() == typeof(Double))
                    {
                        Double value = (Double)mValueStore;
                        value += delta;
                        if (IsShiftDown)
                        {
                            value = (int)value / 5 * 5;
                        }
                        NumericObject = value;
                    }
                }

                OnValueManualChanged?.Invoke();
                e.Handled = true;
            }
        }