コード例 #1
0
 public DocumentNavigatorWindow(DockingManager manager)
     : this()
 {
     _manager = manager;
     Keyboard.AddKeyUpHandler(this, new KeyEventHandler(this.OnKeyUp));
     Keyboard.AddKeyDownHandler(this, new KeyEventHandler(this.OnKeyDown));
 }
コード例 #2
0
        /// <summary>
        /// Construct new MapZoom object that manages the RenderTransform of the given target object.
        /// The target object must have a parent container.
        /// </summary>
        /// <param name="target">The target object we will be zooming.</param>
        public MapZoom(FrameworkElement target)
        {
            this._container = target.Parent  as ScrollViewer;
            this._target    = target;

            _target.MouseMove  += new MouseEventHandler(OnMouseMove);
            _target.MouseWheel += new MouseWheelEventHandler(OnMouseWheel);

            Keyboard.AddKeyDownHandler(_target, new KeyEventHandler(OnKeyDown));
            Keyboard.AddKeyUpHandler(_target, new KeyEventHandler(OnKeyUp));

            //_target.Focusable = true;
            //_target.Focus();

            _scale = _target.LayoutTransform as ScaleTransform;
            if (_scale == null)
            {
                _target.LayoutTransform = _scale = new ScaleTransform();
            }
            this._zoom = this._newZoom = _scale.ScaleX;

            // track changes made by the ScrolLViewer.
            //this._translate.Changed += new EventHandler(OnTranslateChanged);
            this._scale.Changed += new EventHandler(OnScaleChanged);
        }
コード例 #3
0
        private void renterLibNumber_GotFocus(object sender, RoutedEventArgs e)
        {
            readDataFlag = true;

            Keyboard.AddKeyDownHandler(renterLibNumber, keyDownHandler);
            Keyboard.AddKeyUpHandler(renterLibNumber, keyUpHandler);
        }
コード例 #4
0
ファイル: InputDeviceHelper.cs プロジェクト: veselink1/SGL
        public InputDeviceHelper(DependencyObject context)
        {
            if (Thread.CurrentThread.GetApartmentState() != ApartmentState.STA)
            {
                throw new InvalidOperationException("The calling thread must be STA!");
            }

            Dispatcher = Dispatcher.CurrentDispatcher;

            var keys = Enum.GetValues(typeof(Key)).Cast <Key>().ToArray();

            _kbState = new Dictionary <Key, bool>(keys.Length);
            foreach (var key in keys)
            {
                _kbState[key] = false;
            }

            var mouseButtons = Enum.GetValues(typeof(MouseButton)).Cast <MouseButton>().ToArray();

            _mbState = new Dictionary <MouseButton, bool>(mouseButtons.Length);
            foreach (var button in mouseButtons)
            {
                _mbState[button] = false;
            }

            Keyboard.AddKeyUpHandler(context, OnKeyStateChanged);
            Keyboard.AddKeyDownHandler(context, OnKeyStateChanged);
            Keyboard.AddLostKeyboardFocusHandler(context, OnKeyboardFocusChanged);
            Mouse.AddMouseUpHandler(context, OnMouseButtonStateChanged);
            Mouse.AddMouseDownHandler(context, OnMouseButtonStateChanged);
        }
コード例 #5
0
    protected override void OnAttached()
    {
        Keyboard.AddPreviewKeyDownHandler(ListView, PreviewKeyDownHandler);
        Keyboard.AddKeyUpHandler(ListView, KeyUpHandler);

        base.OnAttached();
    }
コード例 #6
0
    private static void KeyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        var keybinding = (d as KeyUpBinding);

        Keyboard.AddKeyUpHandler(App.Current.MainWindow, (s, ku) =>
        {
            if (keybinding.Command != null && ku.Key == keybinding.Key && ku.IsUp)
            {
                keybinding.Command.Execute(null);
            }
        });
    }
コード例 #7
0
ファイル: KeyUpBinding.cs プロジェクト: UB-Mannheim/hbs
        private static void KeyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var keybinding = d as KeyUpBinding;

            Keyboard.AddKeyUpHandler(Application.Current.MainWindow, (s, ku) =>
            {
                if (keybinding.Command != null && ku.Key == keybinding.Key && ku.IsUp)
                {
                    Dispatcher.CurrentDispatcher.BeginInvoke((Action)(() => { keybinding.Command.Execute(null); }),
                                                             DispatcherPriority.Input);
                }
            });
        }
コード例 #8
0
        public GraphControl()
        {
            guid = IdManager.getGuid();

            this.Focusable = true;
            Keyboard.Focus(this);
            Keyboard.AddKeyDownHandler(this, OnKeyDown);
            Keyboard.AddKeyUpHandler(this, OnKeyUp);

            brush = new SolidColorBrush();
            nodes = new List <Node>()
            {
                new Node(50, 50, 150, 100, "SampleNode", new HandleConstruct(HandleType.Input, HandleDataType.Path), new HandleConstruct(HandleType.Input, HandleDataType.Bool), new HandleConstruct(HandleType.Output, HandleDataType.Path), new HandleConstruct(HandleType.Output, HandleDataType.Bool)),
                new Node(100, 50, 150, 100, "SampleNode", new HandleConstruct(HandleType.Input, HandleDataType.Path), new HandleConstruct(HandleType.Input, HandleDataType.Bool), new HandleConstruct(HandleType.Output, HandleDataType.Path), new HandleConstruct(HandleType.Output, HandleDataType.Bool)),
                new Node(150, 50, 150, 100, "SampleNode", new HandleConstruct(HandleType.Input, HandleDataType.Path), new HandleConstruct(HandleType.Input, HandleDataType.Bool), new HandleConstruct(HandleType.Output, HandleDataType.Path), new HandleConstruct(HandleType.Output, HandleDataType.Bool)),
            };

            mousePos = new Point(0, 0);

            _inserter = new Inserter(new Size(150, 250));
            _inserter.AddNodeElement <Node>("Base Node");
            _inserter.AddNodeElement <Node>("Folder/Node");
            _inserter.AddNodeElement <Node>("Folder/Folder2/Sample Node");
            _inserter.AddNodeElement <Node>("1");
            _inserter.AddNodeElement <Node>("2");
            _inserter.AddNodeElement <Node>("3");
            _inserter.AddNodeElement <Node>("4");
            _inserter.AddNodeElement <Node>("5");
            _inserter.AddNodeElement <Node>("6");
            _inserter.AddNodeElement <Node>("7");
            _inserter.AddNodeElement <Node>("8");
            _inserter.AddNodeElement <Node>("9");
            _inserter.AddNodeElement <Node>("10");
            _inserter.AddNodeElement <Node>("11");
            _inserter.AddNodeElement <Node>("12");
            _inserter.AddNodeElement <Node>("13");
            _inserter.AddNodeElement <Node>("14");

            // var y = Serialisation.SerialzeGraph(this);
            // Console.WriteLine(y);

            Serialisation.DeserializeGraph(
                "{\"id\":15658816,\"offset\":\"0,0\",\"nodes\":[{\"id\":1484882,\"pos\":\"50,50\",\"size\":\"150,100\",\"handles\":[{\"id\":51717130,\"HandleType\":0,\"HandleDataType\":0,\"connectedTo\":-1},{\"id\":76566748,\"HandleType\":0,\"HandleDataType\":3,\"connectedTo\":-1},{\"id\":62435764,\"HandleType\":1,\"HandleDataType\":0,\"connectedTo\":-1},{\"id\":50246420,\"HandleType\":1,\"HandleDataType\":3,\"connectedTo\":-1}]},{\"id\":46016738,\"pos\":\"100,50\",\"size\":\"150,100\",\"handles\":[{\"id\":26722482,\"HandleType\":0,\"HandleDataType\":0,\"connectedTo\":-1},{\"id\":55123457,\"HandleType\":0,\"HandleDataType\":3,\"connectedTo\":-1},{\"id\":43477822,\"HandleType\":1,\"HandleDataType\":0,\"connectedTo\":-1},{\"id\":45107328,\"HandleType\":1,\"HandleDataType\":3,\"connectedTo\":-1}]},{\"id\":84178410,\"pos\":\"150,50\",\"size\":\"150,100\",\"handles\":[{\"id\":10713050,\"HandleType\":0,\"HandleDataType\":0,\"connectedTo\":-1},{\"id\":1532512,\"HandleType\":0,\"HandleDataType\":3,\"connectedTo\":-1},{\"id\":34662742,\"HandleType\":1,\"HandleDataType\":0,\"connectedTo\":-1},{\"id\":22373670,\"HandleType\":1,\"HandleDataType\":3,\"connectedTo\":-1}]}]}"
                , this);
        }
コード例 #9
0
        void AddSpaceObjectEvents(Control so2)
        {
            so2.Loaded    += new RoutedEventHandler(SpaceObject_loaded);
            so2.Unloaded  += new RoutedEventHandler(SpaceObject_unloaded);
            so2.MouseDown += new MouseButtonEventHandler(SpaceObject_MouseDown);
            so2.MouseUp   += new MouseButtonEventHandler(SpaceObject_MouseUp);
            so2.KeyDown   += new KeyEventHandler(Canvas_KeyDown);
            so2.KeyUp     += new KeyEventHandler(Canvas_KeyUp);
            Keyboard.AddKeyDownHandler(so2, Canvas_KeyDown);
            Keyboard.AddKeyUpHandler(so2, Canvas_KeyUp);
            SpaceObject so = so2 as SpaceObject;

            if (so != null)
            {
                so.LocationChanged += new EventHandler(SpaceObject_LocationChanged);
            }
            so2.ContextMenu = ObjectMenu;
        }
コード例 #10
0
ファイル: MapZoom.cs プロジェクト: sergey-rush/GraphBuilder
        /// <summary>
        /// Construct new MapZoom object that manages the RenderTransform of the given target object.
        /// The target object must have a parent container.
        /// </summary>
        /// <param name="target">The target object we will be zooming.</param>
        public MapZoom(FrameworkElement target)
        {
            this._container = target.Parent as FrameworkElement;
            this._target    = target;

            _container.MouseMove  += new MouseEventHandler(OnMouseMove);
            _container.MouseWheel += new MouseWheelEventHandler(OnMouseWheel);

            Keyboard.AddKeyDownHandler(_container, new KeyEventHandler(OnKeyDown));
            Keyboard.AddKeyUpHandler(_container, new KeyEventHandler(OnKeyUp));

            _container.Focusable = true;
            _container.Focus();

            // Try and reuse the existing TransformGroup if we can.
            TransformGroup g = target.RenderTransform as TransformGroup;

            if (g != null)
            {
                this._scale     = g.Children.Count > 1 ? g.Children[0] as ScaleTransform : null;
                this._translate = g.Children.Count > 0 ? g.Children[1] as TranslateTransform : null;
                if (this._scale == null || this._translate == null)
                {
                    g = null; // then the TransformGroup cannot be re-used
                }
            }
            if (g == null)
            {
                g           = new TransformGroup();
                this._scale = new ScaleTransform(1, 1);
                g.Children.Add(this._scale);
                this._translate = new TranslateTransform();
                g.Children.Add(this._translate);
                target.RenderTransform = g;
            }

            this._zoom = this._newZoom = _scale.ScaleX;

            // track changes made by the ScrolLViewer.
            this._translate.Changed += new EventHandler(OnTranslateChanged);
            this._scale.Changed     += new EventHandler(OnScaleChanged);
        }
コード例 #11
0
        private void Initialize(FrameworkElement target)
        {
            _container = target.Parent as FrameworkElement;
            _target    = target;

            _container.MouseMove  += new MouseEventHandler(OnMouseMove);
            _container.MouseWheel += new MouseWheelEventHandler(OnMouseWheel);

            Keyboard.AddKeyDownHandler(_container, new KeyEventHandler(OnKeyDown));
            Keyboard.AddKeyUpHandler(_container, new KeyEventHandler(OnKeyUp));

            _container.Focusable = true;
            _container.Focus();

            // Try and reuse the existing TransformGroup if we can.
            if (target.RenderTransform is TransformGroup g)
            {
                _scale     = g.Children.Count > 1 ? g.Children[0] as ScaleTransform : null;
                _translate = g.Children.Count > 0 ? g.Children[1] as TranslateTransform : null;
                if (_scale == null || _translate == null)
                {
                    g = null; // then the TransformGroup cannot be re-used
                }
            }
            else
            //if (g == null)
            {
                g      = new TransformGroup();
                _scale = new ScaleTransform(1, 1);
                g.Children.Add(_scale);
                _translate = new TranslateTransform();
                g.Children.Add(_translate);
                target.RenderTransform = g;
            }

            _value = _newZoom = _scale.ScaleX;

            // track changes made by the ScrolLViewer.
            _translate.Changed += new EventHandler(OnTranslateChanged);
            _scale.Changed     += new EventHandler(OnScaleChanged);
        }
コード例 #12
0
        /// <summary>
        /// Отвязка и привязка событий к мыше и клавиатуре в зависимости от выбранного типа интрумента
        /// </summary>
        public void SetToolType(DrawToolType type)
        {
            switch (this.ToolType)
            {
            case DrawToolType.Pointer:
                Mouse.RemoveMouseDownHandler(this.window, this.toolMouseDown);
                Mouse.RemoveMouseUpHandler(this.window, this.toolMouseUp);
                Mouse.RemoveMouseMoveHandler(this.window, this.toolMouseMove);
                Keyboard.RemoveKeyDownHandler(this.window, this.toolKeyDown);
                Keyboard.RemoveKeyUpHandler(this.window, this.toolKeyUp);
                Mouse.RemoveMouseDownHandler(this.dotsControl, this.dotsControl_MouseDown);
                Mouse.RemoveMouseUpHandler(this.dotsControl, this.dotsControl_MouseUp);
                Mouse.RemoveMouseMoveHandler(this.dotsControl, this.dotsControl_MouseMove);
                this.selectShapes(null);
                break;

            case DrawToolType.Polyline:
                Mouse.RemoveMouseDownHandler(this.canvas, this.polylineToolMouseDown);
                Mouse.RemoveMouseUpHandler(this.window, this.polylineToolMouseUp);
                Mouse.RemoveMouseMoveHandler(this.window, this.polylineToolMouseMove);
                this.canvas.Cursor = null;
                this.lastShape     = null;
                break;

            case DrawToolType.Rectangle:
                Mouse.RemoveMouseDownHandler(this.canvas, this.rectangleToolMouseDown);
                Mouse.RemoveMouseUpHandler(this.window, this.rectangleToolMouseMouseUp);
                Mouse.RemoveMouseMoveHandler(this.window, this.rectangleToolMouseMove);
                this.canvas.Cursor = null;
                this.lastShape     = null;
                break;

            case DrawToolType.Delete:
                Mouse.RemoveMouseDownHandler(this.canvas, this.deleteToolMouseDown);
                Mouse.RemoveMouseMoveHandler(this.window, this.deleteToolMouseMove);
                if (this.lastShape != null)
                {
                    this.lastShape.SetDeletingStyle(false);
                    this.lastShape = null;
                }
                break;
            }

            this.ToolType = type;

            switch (this.ToolType)
            {
            case DrawToolType.Pointer:
                Mouse.AddMouseDownHandler(this.dotsControl, this.dotsControl_MouseDown);
                Mouse.AddMouseUpHandler(this.dotsControl, this.dotsControl_MouseUp);
                Mouse.AddMouseDownHandler(this.window, this.toolMouseDown);
                Mouse.AddMouseUpHandler(this.window, this.toolMouseUp);
                Mouse.AddMouseMoveHandler(this.window, this.toolMouseMove);
                Mouse.AddMouseMoveHandler(this.dotsControl, this.dotsControl_MouseMove);
                Keyboard.AddKeyDownHandler(this.window, this.toolKeyDown);
                Keyboard.AddKeyUpHandler(this.window, this.toolKeyUp);
                break;

            case DrawToolType.Polyline:
                Mouse.AddMouseDownHandler(this.canvas, this.polylineToolMouseDown);
                Mouse.AddMouseUpHandler(this.window, this.polylineToolMouseUp);
                Mouse.AddMouseMoveHandler(this.window, this.polylineToolMouseMove);
                this.canvas.Cursor = Cursors.Cross;
                break;

            case DrawToolType.Rectangle:
                Mouse.AddMouseDownHandler(this.canvas, this.rectangleToolMouseDown);
                Mouse.AddMouseUpHandler(this.window, this.rectangleToolMouseMouseUp);
                Mouse.AddMouseMoveHandler(this.window, this.rectangleToolMouseMove);
                this.canvas.Cursor = Cursors.Cross;
                break;

            case DrawToolType.Delete:
                Mouse.AddMouseDownHandler(this.canvas, this.deleteToolMouseDown);
                Mouse.AddMouseMoveHandler(this.window, this.deleteToolMouseMove);
                break;
            }
        }
コード例 #13
0
 public KeyboardManager(DependencyObject dependencyObject)
 {
     Keyboard.AddKeyDownHandler(dependencyObject, KeyEventHandler);
     Keyboard.AddKeyUpHandler(dependencyObject, KeyUpHandler);
 }
コード例 #14
0
 protected override void OnAttached()
 {
     Keyboard.AddKeyDownHandler(ListView, ListenKeyDown);
     Keyboard.AddKeyUpHandler(ListView, ListenKeyUp);
     base.OnAttached();
 }
コード例 #15
0
 public void InitKeyboardHook(FrameworkElement mainWindows)
 {
     Keyboard.AddKeyDownHandler(mainWindows, FrameworkElementOnKeyChanged);
     Keyboard.AddKeyUpHandler(mainWindows, FrameworkElementOnKeyChanged);
 }