Ejemplo n.º 1
0
        private void CreateRadialMenuForSelectionBox()
        {
            double startAngle = 90;
            Point worldCoords = this.graphController.GetNorthEastPositionOfSelectionBox();
            NodePart part = NodePart.NorthEast;
            worldCoords.Offset(-Configurations.CenterOffsetX, Configurations.CenterOffsetY);

            Dictionary<int, string> menuItems = new Dictionary<int, string>();
            Dictionary<int, string> overloadedItems = new Dictionary<int, string>();

            if (this.lastHoveredNodePart != part || this.lastHoveredNodeId != int.MaxValue)
            {
                this.graphController.DoCreateRadialMenu(part, uint.MaxValue);
                lastHoveredNodePart = part;
                lastHoveredNodeId = uint.MaxValue;
                selectedMenuId = int.MinValue;
            }

            this.graphController.GetMenuItems(out menuItems, out overloadedItems);
            if (menuItems != null && menuItems.Count > 0)
            {
                radialMenu = new RadialMenu(uint.MaxValue, worldCoords, Configurations.CircleRadius, menuItems, startAngle, part);
                this.children.Add(radialMenu.GetRadialVisual());
                ScrollToMenuVisual(radialMenu.GetRadialVisual(), radialMenu.GetMenuWidth());

                if (Application.Current != null && (Application.Current.MainWindow != null))
                {
                    if (Application.Current.MainWindow.IsFocused == false)
                    {
                        Application.Current.MainWindow.Activate();
                        Application.Current.MainWindow.Topmost = true;
                        Application.Current.MainWindow.Topmost = false;
                        Application.Current.MainWindow.Focus();
                    }
                }
                Keyboard.Focus(this.graphCanvas.graphCanvas);
            }
        }
Ejemplo n.º 2
0
        internal void CreateRadialMenuForPreview(Point pt, uint bubbleId)
        {
            if (radialMenu != null)
                return;

            ModifierKeys keys = Keyboard.Modifiers;
            if (keys.HasFlag(ModifierKeys.Control))
                return;

            lastHoveredBubbleId = bubbleId;

            double startAngle = 90;
            Point worldCoords = pt;
            NodePart part = NodePart.NorthEast;
            worldCoords.Offset(-Configurations.CenterOffsetX, Configurations.CenterOffsetY);

            Dictionary<int, string> menuItems = new Dictionary<int, string>();
            Dictionary<int, string> overloadedItems = new Dictionary<int, string>();

            IInfoBubble infoBubble = null;
            this.graphController.GetInfoBubble(bubbleId, out infoBubble);
            if (infoBubble != null)
            {
                States nodeState;
                graphController.GetNodeState(infoBubble.OwnerId, out nodeState);
                bool textualPreviewFlag = nodeState.HasFlag(States.TextualPreview);
                bool geometryPreviewFlag = nodeState.HasFlag(States.GeometryPreview);
                if (textualPreviewFlag == false && geometryPreviewFlag == false)
                {
                    textualPreviewFlag = true;
                    geometryPreviewFlag = true;
                }

                if (textualPreviewFlag)
                    menuItems.Add(Configurations.GeometricOutput, "Geometric Preview");
                if (geometryPreviewFlag)
                    menuItems.Add(Configurations.TextualOutput, "Textual Preview");
                if (nodeState.HasFlag(States.PreviewHidden))
                    menuItems.Add(Configurations.HidePreview, "Show Preview");
                else
                    menuItems.Add(Configurations.HidePreview, "Hide Preview");
            }

            if (this.lastHoveredNodePart != part || this.lastHoveredNodeId != int.MaxValue)
            {
                this.graphController.DoCreateRadialMenu(part, bubbleId);
                lastHoveredNodePart = part;
                lastHoveredNodeId = uint.MaxValue;
                selectedMenuId = int.MinValue;
            }

            if (menuItems != null && menuItems.Count > 0)
            {
                radialMenu = new RadialMenu(bubbleId, worldCoords, Configurations.CircleRadius, menuItems, startAngle, part);
                this.children.Add(radialMenu.GetRadialVisual());
                ScrollToMenuVisual(radialMenu.GetRadialVisual(), radialMenu.GetMenuWidth());

                if (Application.Current != null && (Application.Current.MainWindow != null))
                {
                    if (Application.Current.MainWindow.IsFocused == false)
                    {
                        Application.Current.MainWindow.Activate();
                        Application.Current.MainWindow.Topmost = true;
                        Application.Current.MainWindow.Topmost = false;
                        Application.Current.MainWindow.Focus();
                    }
                }
                Keyboard.Focus(this.graphCanvas.graphCanvas);
            }
        }
Ejemplo n.º 3
0
        private void CreateRadialMenu(uint nodeId, NodePart part, Point subRadialMenuOffset)
        {
            ModifierKeys keys = Keyboard.Modifiers;
            if (keys.HasFlag(ModifierKeys.Control))
                return;
            Rect result;
            NodeType type;
            double startAngle;
            Point worldCoords;

            if (this.Controller.GetNodePartRegion(nodeId, NodePart.None, mouseDownPosition, out result, out type) == false)
                return;
            worldCoords = result.Location;

            switch (part)
            {
                case NodePart.NorthEast:
                    startAngle = 90;
                    worldCoords.X += result.Width;
                    worldCoords.Offset(-Configurations.CenterOffsetX, Configurations.CenterOffsetY);
                    break;
                case NodePart.North:
                    startAngle = 180;
                    this.Controller.GetNodePartRegion(nodeId, NodePart.North, mouseDownPosition, out result, out type);
                    worldCoords.X += result.Width;
                    worldCoords.Offset(Configurations.CenterOffsetX, Configurations.CenterOffsetY);
                    break;
                case NodePart.NorthWest:
                    startAngle = 180;
                    worldCoords.Offset(Configurations.CenterOffsetX, Configurations.CenterOffsetY);
                    break;
                case NodePart.South:
                    startAngle = 270;
                    this.Controller.GetNodePartRegion(nodeId, NodePart.South, mouseDownPosition, out result, out type);
                    worldCoords.X += result.Width;
                    worldCoords.Y += result.Height;
                    worldCoords.Offset(Configurations.CenterOffsetX, -Configurations.CenterOffsetY);
                    break;
                default:
                    startAngle = 90;
                    worldCoords.X += result.Width;
                    worldCoords.Offset(-Configurations.CenterOffsetX, Configurations.CenterOffsetY);
                    break;
            }

            Dictionary<int, string> menuItems = null;
            Dictionary<int, string> overloadedItems = null;
            if (this.lastHoveredNodePart != part || this.lastHoveredNodeId != nodeId)
            {
                this.graphController.DoCreateRadialMenu(part, nodeId);
                lastHoveredNodePart = part;
                lastHoveredNodeId = nodeId;
                selectedMenuId = int.MinValue;
            }
            this.graphController.GetMenuItems(out menuItems, out overloadedItems);
            if (null != menuItems && (menuItems.Count > 0))
            {
                radialMenu = new RadialMenu(nodeId, worldCoords, Configurations.CircleRadius, menuItems, startAngle, part);
                this.children.Add(radialMenu.GetRadialVisual());
                ScrollToMenuVisual(radialMenu.GetRadialVisual(), radialMenu.GetMenuWidth());

                if (Application.Current != null && (Application.Current.MainWindow != null))
                {
                    if (Application.Current.MainWindow.IsFocused == false)
                    {
                        Application.Current.MainWindow.Activate();
                        Application.Current.MainWindow.Topmost = true;
                        Application.Current.MainWindow.Topmost = false;
                        Application.Current.MainWindow.Focus();
                    }
                }
                Keyboard.Focus(this.graphCanvas.graphCanvas);
            }
        }