Esempio n. 1
0
        public override void DisableEvent(object eventId)
        {
            if (eventId is WidgetEvent)
            {
                var ev = (WidgetEvent)eventId;
                switch (ev)
                {
                case WidgetEvent.KeyPressed:
                    Widget.PreviewKeyDown -= WidgetKeyDownHandler;
                    break;

                case WidgetEvent.KeyReleased:
                    Widget.PreviewKeyUp -= WidgetKeyUpHandler;
                    break;

                case WidgetEvent.TextInput:
                    TextCompositionManager.RemovePreviewTextInputHandler(Widget, WidgetPreviewTextInputHandler);
                    break;

                case WidgetEvent.ButtonPressed:
                    Widget.MouseDown -= WidgetMouseDownHandler;
                    break;

                case WidgetEvent.ButtonReleased:
                    Widget.MouseUp -= WidgetMouseUpHandler;
                    break;

                case WidgetEvent.MouseEntered:
                    Widget.MouseEnter -= WidgetMouseEnteredHandler;
                    break;

                case WidgetEvent.MouseExited:
                    Widget.MouseLeave -= WidgetMouseExitedHandler;
                    break;

                case WidgetEvent.MouseMoved:
                    Widget.MouseMove -= WidgetMouseMoveHandler;
                    break;

                case WidgetEvent.BoundsChanged:
                    Widget.SizeChanged -= WidgetOnSizeChanged;
                    break;

                case WidgetEvent.MouseScrolled:
                    Widget.MouseWheel -= WidgetMouseWheelHandler;
                    break;
                }

                enabledEvents &= ~ev;

                if ((ev & dragDropEvents) != 0 && (enabledEvents & dragDropEvents) == 0)
                {
                    // All drag&drop events have been disabled
                    Widget.DragOver  -= WidgetDragOverHandler;
                    Widget.Drop      -= WidgetDropHandler;
                    Widget.DragLeave -= WidgetDragLeaveHandler;
                }
            }
        }
Esempio n. 2
0
        public override void OnApplyTemplate()
        {
            if (_textBox != null)
            {
                TextCompositionManager.RemovePreviewTextInputHandler(_textBox, PreviewTextInputHandler);
                _textBox.TextChanged    -= TextBox_TextChanged;
                _textBox.PreviewKeyDown -= TextBox_PreviewKeyDown;
                _textBox.LostFocus      -= TextBox_LostFocus;
            }

            base.OnApplyTemplate();

            _textBox  = GetTemplateChild(ElementTextBox) as TextBox;
            _errorTip = GetTemplateChild(ElementErrorTip) as UIElement;

            if (_textBox != null)
            {
                _textBox.SetBinding(SelectionBrushProperty, new Binding(SelectionBrushProperty.Name)
                {
                    Source = this
                });
#if !(NET40 || NET45 || NET451 || NET452 || NET46 || NET461 || NET462 || NET47 || NET471 || NET472)
                _textBox.SetBinding(SelectionTextBrushProperty, new Binding(SelectionTextBrushProperty.Name)
                {
                    Source = this
                });
#endif
                _textBox.SetBinding(SelectionOpacityProperty, new Binding(SelectionOpacityProperty.Name)
                {
                    Source = this
                });
                _textBox.SetBinding(CaretBrushProperty, new Binding(CaretBrushProperty.Name)
                {
                    Source = this
                });

                TextCompositionManager.AddPreviewTextInputHandler(_textBox, PreviewTextInputHandler);
                _textBox.TextChanged    += TextBox_TextChanged;
                _textBox.PreviewKeyDown += TextBox_PreviewKeyDown;
                _textBox.LostFocus      += TextBox_LostFocus;
                _textBox.Text            = CurrentText;
            }
        }
Esempio n. 3
0
        public override void OnApplyTemplate()
        {
            if (_textBox != null)
            {
                TextCompositionManager.RemovePreviewTextInputHandler(_textBox, PreviewTextInputHandler);
                _textBox.TextChanged    -= _textBox_TextChanged;
                _textBox.PreviewKeyDown -= TextBox_PreviewKeyDown;
                _textBox.LostFocus      -= TextBox_LostFocus;
            }

            base.OnApplyTemplate();

            _textBox = GetTemplateChild(ElementTextBox) as TextBox;

            if (_textBox != null)
            {
                TextCompositionManager.AddPreviewTextInputHandler(_textBox, PreviewTextInputHandler);
                _textBox.TextChanged    += _textBox_TextChanged;
                _textBox.PreviewKeyDown += TextBox_PreviewKeyDown;
                _textBox.LostFocus      += TextBox_LostFocus;
                _textBox.Text            = CurrentText;
            }
        }