Example #1
0
        private void ProcessDocumentKey(NNodeKeyEventArgs args)
        {
            // the only key the document processes is the tab
            if (args.KeyCode != Keys.Tab)
            {
                return;
            }

            NShape newFocusedShape = null;
            NShape curFocusedShape = (document.FocusedElement as NShape);

            // if there is no currently focused shape
            if (curFocusedShape == null)
            {
                curFocusedShape = (document.ActiveLayer.GetChildAt(0) as NShape);
            }
            else
            {
                // get focused shape index
                int index = document.ActiveLayer.IndexOfChild(curFocusedShape);

                // increase or decrease depending on whether the shift was pressed
                if (args.Shift)
                {
                    index--;
                }
                else
                {
                    index++;
                }

                // clamp to valid index
                if (index < 0)
                {
                    index = document.ActiveLayer.ChildrenCount(null) - 1;
                }
                else if (index >= document.ActiveLayer.ChildrenCount(null))
                {
                    index = 0;
                }

                // get new focused node
                newFocusedShape = (document.ActiveLayer.GetChildAt(index) as NShape);
            }

            // focus the new node
            FocusShape(newFocusedShape);

            // mark event as handled and processed
            args.Handled   = true;
            args.Processed = markEventsAsProcessedCheck.Checked;
        }
Example #2
0
        private void EventSinkService_NodeKeyUp(NNodeKeyEventArgs args)
        {
            // process document key
            if (args.Node is NDrawingDocument)
            {
                ProcessDocumentKey(args);
                document.SmartRefreshAllViews();
                return;
            }

            // process shape key
            if (args.Node is NShape)
            {
                ProcessShapeKey(args);
                document.SmartRefreshAllViews();
                return;
            }
        }
Example #3
0
        private void ProcessShapeKey(NNodeKeyEventArgs args)
        {
            if (args.KeyData != Keys.Left &&
                args.KeyData != Keys.Right &&
                args.KeyData != Keys.Up &&
                args.KeyData != Keys.Down)
            {
                return;
            }

            NShape      shape  = (args.Node as NShape);
            NRectangleF bounds = shape.Bounds;

            switch (args.KeyData)
            {
            case Keys.Left:
                bounds.Translate(-5, 0);
                break;

            case Keys.Right:
                bounds.Translate(5, 0);
                break;

            case Keys.Up:
                bounds.Translate(0, -5);
                break;

            case Keys.Down:
                bounds.Translate(0, 5);
                break;
            }

            shape.Bounds = bounds;
            document.SmartRefreshAllViews();

            // mark event as handled and processed
            args.Handled   = true;
            args.Processed = markEventsAsProcessedCheck.Checked;
        }