예제 #1
0
        private void textBox_LostFocus(object sender, System.Windows.RoutedEventArgs e)
        {
            EnableEdit = false;
            BindingExpression be = textBox.GetBindingExpression(TextBox.TextProperty);

            be.UpdateSource();
            OnValueManualChanged?.Invoke();
        }
예제 #2
0
 private void TextBox_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
 {
     switch (e.Key)
     {
     case Key.Enter:
     case Key.Escape:
         EnableEdit = false;
         BindingExpression be = textBox.GetBindingExpression(TextBox.TextProperty);
         be.UpdateSource();
         OnValueManualChanged?.Invoke();
         break;
     }
 }
예제 #3
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;
            }
        }