예제 #1
0
        private void viewPane_MouseUp(object sender, PointerRoutedEventArgs e)
        {
            Windows.UI.Input.PointerPoint ptrPt = e.GetCurrentPoint((UIElement)(sender));
            CalcPoint   mousePos = new CalcPoint(ptrPt.Position);
            MouseButton mB       = MouseButton.NONE;

            MouseObject mousePoint;

            if (leftpointer != null)
            {
                if (leftpointer.PointerId.Equals(e.Pointer.PointerId))
                {
                    leftpointer = null;
                    mB          = MouseButton.LEFT;
                }
            }

            if (rightpointer != null)
            {
                if (rightpointer.PointerId.Equals(e.Pointer.PointerId))
                {
                    rightpointer = null;
                    mB           = MouseButton.RIGHT;
                }
            }

            mousePoint = new MouseObject(mB, mousePos);

            mouse.viewPane_Released(mousePoint);
        }
예제 #2
0
        public void CreateBoundBox()
        {
            int       xmin;
            int       xmax;
            int       ymin;
            int       ymax;
            CalcPoint start = this.nodes.First();
            CalcPoint end   = this.nodes.Last();

            if (start.X >= end.X)
            {
                xmax         = start.X;
                xmin         = end.X;
                masteredge.X = 0;
            }
            else
            {
                xmin         = start.X;
                xmax         = end.X;
                masteredge.X = 1;
            }
            if (start.Y >= end.Y)
            {
                ymax         = start.Y;
                ymin         = end.Y;
                masteredge.Y = 0;
            }
            else
            {
                ymin         = start.Y;
                ymax         = end.Y;
                masteredge.Y = 1;
            }
            boundbox = new Rect(xmin - pixborder, ymin - pixborder, xmax - xmin + 2 * pixborder, ymax - ymin + 2 * pixborder);
        }
예제 #3
0
        private void viewPane_UpdateMousePos(object sender, PointerRoutedEventArgs e)
        {
            Windows.UI.Input.PointerPoint ptrPt = e.GetCurrentPoint((UIElement)(sender));
            lastMousePosition = new CalcPoint(ptrPt.Position);

            //status += "Posx:" + mousePos.X + "/ " + mousePos.Y + "\n";
        }
예제 #4
0
        public void ReBridge(CalcPoint start, CalcPoint end)
        {
            //Task.Run(() =>
            //{
            nodes      = new List <CalcPoint>();
            startPoint = start;
            endPoint   = end;
            nodes.Add(startPoint);

            angle = CalculateAngle();
            if (angle < 270 && angle >= 90)
            {
                direction = Direction.RIGHT;
            }
            else if (angle < 90 && angle >= -90)
            {
                direction = Direction.DOWN;
            }
            else if (angle < -90 && angle >= -270)
            {
                direction = Direction.LEFT;
            }
            else if (angle < (-270) || angle >= 270)
            {
                direction = Direction.UP;
            }

            CalculateDistance();
            CaculateMiddlePoint();
            AddBasicNodes();
            //});

            textNode = new NodeLabel(middlePoint.X, middlePoint.Y, 20, 20, true);
            textNode.SetText("Bridge");
        }
예제 #5
0
        private void viewPane_MouseDown(object sender, PointerRoutedEventArgs e)
        {
            Windows.UI.Input.PointerPoint ptrPt = e.GetCurrentPoint((UIElement)(sender));
            CalcPoint   mousePos = new CalcPoint(ptrPt.Position);
            MouseButton mB       = MouseButton.NONE;
            MouseObject mousePoint;

            //status2 += "Mouse Down" + "\n";

            if (ptrPt.Properties.IsRightButtonPressed)
            {
                rightpointer = e.Pointer;
                mB           = MouseButton.RIGHT;
            }

            if (ptrPt.Properties.IsLeftButtonPressed)
            {
                leftpointer = e.Pointer;
                mB          = MouseButton.LEFT;
            }

            if (ptrPt.Properties.IsMiddleButtonPressed)
            {
                leftpointer = e.Pointer;
                mB          = MouseButton.MIDDLE;
            }

            mousePoint = new MouseObject(mB, mousePos);

            mouse.viewPane_Pressed(mousePoint);
        }
예제 #6
0
        public void viewPane_Released(MouseObject mousObj)
        {
            CalcPoint mousePos = mousObj.currentMousePos;

            if (GlobalNodeHandler.TabletSelected)
            {
                if (GlobalNodeHandler.adding && tickcnt - clickstartcount < 10)
                {
                    if (GlobalNodeHandler.clickedNode == null && GlobalNodeHandler.clickedLabel == null)
                    {
                        if (GlobalNodeHandler.CreateNewNode(mousePos.X, mousePos.Y, true))
                        {
                            CalcPoint CreatePoint;
                            CreatePoint = new CalcPoint(mousePos.X - GlobalNodeHandler.clickedNode.width,
                                                        mousePos.Y - GlobalNodeHandler.clickedNode.height);

                            GlobalNodeHandler.ShowTextBox(CreatePoint, activetext);
                            repaint(this, new EventArgs());
                        }
                    }
                }
                if (dragging)
                {
                    dragging = false;
                    int x = mousePos.X;
                    int y = mousePos.Y;
                    if (selectedGroup.Count != 0)
                    {
                        diffPoints = new List <CalcPoint>();
                    }
                    else if (GlobalNodeHandler.clickedNode != null)
                    {
                        GlobalNodeHandler.clickedNode.SetPosition(mousePos.X, mousePos.Y, true);
                        GlobalNodeHandler.clickedNode.setHovered(false);
                        GlobalNodeHandler.clickedNode = null;
                        repaint(this, new EventArgs());
                    }
                }
                if (transformPoint.X != 0 || transformPoint.Y != 0)
                {
                    transformPoint = new CalcPoint();
                    transformnode.SetScaled(true);
                    transformnode.UpdatePivots();
                    transformnode.UpdateTransformRec();
                    transformnode.updateRepresentation();
                    repaint(this, new EventArgs());
                    transformnode = null;
                }
                if (dragView)
                {
                    dragView = false;
                    repaint(this, new EventArgs());
                }
            }
            else if (GlobalNodeHandler.mouseSelected)
            {
                viewPane_MouseUp(mousObj);
            }
        }
예제 #7
0
        private void ZOOMOUT_PointerPressed(object sender, PointerRoutedEventArgs e)
        {
            double    delta    = -200d;
            CalcPoint mousePos = new CalcPoint(Window.Current.CoreWindow.Bounds.Width / 2, Window.Current.CoreWindow.Bounds.Height / 2);

            GlobalNodeHandler.Zoom((mousePos), delta);
            repaint(this, new EventArgs());
        }
예제 #8
0
        public CalcPoint GetCenter()
        {
            CalcPoint center = new CalcPoint();

            center.X = this.xpos + this.width / 2;
            center.Y = this.ypos + this.height / 2;
            return(center);
        }
예제 #9
0
        public List <CalcPoint> GetNodeListRelativeTo(CalcPoint point)
        {
            nodes.Add(endPoint);
            for (int x = nodes.Count - 1; x >= 0; x--)
            {
                nodes[x] = new CalcPoint(nodes[x].X - point.X, nodes[x].Y - point.Y);
            }

            return(nodes);
        }
예제 #10
0
        public void ExpandOnAnchor(CalcPoint Anchor, double factor)
        {
            //factor = 1.0;
            CalcPoint diff;

            diff   = new CalcPoint(Anchor.X - this.LabelCenter.X, Anchor.Y - this.LabelCenter.Y);
            diff.X = (int)(diff.X * factor - diff.X);
            diff.Y = (int)(diff.Y * factor - diff.Y);
            this.SetPosition(this.LabelCenter.X - diff.X, this.LabelCenter.Y - diff.Y, true);
        }
예제 #11
0
 public void MoveBoundBox(CalcPoint direction)
 {
     if (boundBox != null)
     {
         if (boundBox.Width > 0 && boundBox.Width > 0)
         {
             boundBox.X = boundBox.X - direction.X;
             boundBox.Y = boundBox.Y - direction.Y;
         }
     }
 }
예제 #12
0
        public Bridge GetPivotPoints(MindNode node1, MindNode node2)
        {
            Point     directionmdifier1 = (new Bridge(node1.GetCenter(), node2.GetCenter(), this.NodeColor)).PointDirection();
            Point     directionmdifier2 = (new Bridge(node2.GetCenter(), node1.GetCenter(), this.NodeColor)).PointDirection();
            CalcPoint startpoint        = new CalcPoint(node1.GetCenter().X + node1.width * directionmdifier1.X / 2,
                                                        node1.GetCenter().Y + node1.height * directionmdifier1.Y / 2);
            CalcPoint endpoint = new CalcPoint(node2.GetCenter().X + node2.width * directionmdifier2.X / 2,
                                               node2.GetCenter().Y + node2.height * directionmdifier2.Y / 2);

            return(new Bridge(startpoint, endpoint, this.NodeColor));
        }
예제 #13
0
        public void CopyExt(Bridge ext)
        {
            this.nodes = ext.nodes;

            this.angle       = ext.angle;
            this.middlePoint = ext.middlePoint;
            this.direction   = ext.direction;

            this.textNode.boundBox = ext.textNode.boundBox;

            this.textNode.UpdateWidth();
            this.updateRepresentation();
        }
예제 #14
0
        public void ExpandOnAnchor(CalcPoint Anchor, double factor)
        {
            //factor = 1.0;
            CalcPoint diff;

            for (int i = nodes.Count - 1; i >= 0; i--)
            {
                diff     = new CalcPoint(Anchor.X - nodes[i].X, Anchor.Y - nodes[i].Y);
                diff.X   = (int)(diff.X * factor - diff.X);
                diff.Y   = (int)(diff.Y * factor - diff.Y);
                nodes[i] = new CalcPoint(nodes[i].X - diff.X, nodes[i].Y - diff.Y);
            }
        }
예제 #15
0
        public static void ShowTextBox(CalcPoint position, TextBox box)
        {
            box.Visibility = Windows.UI.Xaml.Visibility.Visible;

            box.Margin = new Thickness(position.X, position.Y, 0, 0);

            if (GlobalNodeHandler.clickedNode != null)
            {
                box.Text = GlobalNodeHandler.clickedNode.text;
            }

            box.Focus(FocusState.Programmatic);
            box.SelectionStart = box.Text.Length;
        }
예제 #16
0
 public static void PseudoZoom(CalcPoint p, double delta)
 {
     GlobalNodeHandler.zoom *= ((double)(delta * 0.001d) + 1);
     //log2.Info("Wheelfired:" + ((double)(e.Delta* 0.002d) + 1));
     if (GlobalNodeHandler.zoom >= 0.4)
     {
         GlobalNodeHandler.masterNode.PseudoScale(GlobalNodeHandler.zoom);
         //log2.Info(zoom);
         GlobalNodeHandler.viewNode.ExpandOnAnchor(p, ((double)(delta * 0.001d) + 1));
     }
     else
     {
         GlobalNodeHandler.zoom = 0.4d;
     }
 }
예제 #17
0
        public void MoveViewRelativePix(CalcPoint direction)
        {
            for (int i = childNodes.Count - 1; i >= 0; i--)
            {
                if (childNodes[i].width > 0 && childNodes[i].height > 0)
                {
                    childNodes[i].SetPosition((int)(childNodes[i].xpos - direction.X), (int)(childNodes[i].ypos - direction.Y), false);

                    childNodes[i].UpdatePosition();
                    for (int x = childNodes[i].connections.Count - 1; x >= 0; x--)
                    {
                        childNodes[i].connections[x].MoveBoundBox(direction);
                        childNodes[i].connections[x].textNode.MoveBoundBox(direction);
                    }
                }
            }
        }
예제 #18
0
        public void ExpandOnAnchor(CalcPoint Anchor, double factor)
        {
            //factor = 1.0;
            Point diff;

            for (int i = childNodes.Count - 1; i >= 0; i--)
            {
                if (childNodes[i].width > 0 && childNodes[i].height > 0)
                {
                    diff   = new Point(Anchor.X + xoffset - childNodes[i].GetCenter().X, Anchor.Y + yoffset - childNodes[i].GetCenter().Y);
                    diff.X = (int)(diff.X * factor - diff.X);
                    diff.Y = (int)(diff.Y * factor - diff.Y);
                    childNodes[i].SetPosition((int)(childNodes[i].xpos - diff.X), (int)(childNodes[i].ypos - diff.Y), false);

                    for (int x = childNodes[i].connections.Count - 1; x >= 0; x--)
                    {
                        childNodes[i].UpdatePivots();
                        childNodes[i].UpdatePosition();
                    }
                }
            }
        }
예제 #19
0
 public void UpdateCenter()
 {
     LabelCenter = new CalcPoint((int)(boundBox.X + boundBox.Width / 2), (int)(boundBox.X + boundBox.Width / 2));
 }
예제 #20
0
 public CalcPoint Add(CalcPoint other)
 {
     return(new CalcPoint(this.X + other.X, this.Y + other.Y));
 }
예제 #21
0
        public void viewPane_MouseDown(MouseObject mousObj)
        {
            CalcPoint mousePos = mousObj.currentMousePos;

            if (GlobalNodeHandler.pick1.BoxContains(mousePos.ToPoint()) && GlobalNodeHandler.pick1.isVisible)
            {
                if (GlobalNodeHandler.pick1.ChangeColorTo(mousePos.ToPoint()))
                {
                    if (GlobalNodeHandler.typing)
                    {
                        if (GlobalNodeHandler.clickedNode != null)
                        {
                            GlobalNodeHandler.clickedNode.TextColor = ColorPicker.selectedcolor;
                        }
                        if (GlobalNodeHandler.clickedLabel != null)
                        {
                            GlobalNodeHandler.clickedLabel.TextColor = ColorPicker.selectedcolor;
                        }
                    }

                    repaint(this, new EventArgs());
                }
            }
            else
            {
                if (mousObj.thisButton.Equals(MouseButton.LEFT))
                {
                    clickstartcount = tickcnt;

                    if ((GlobalNodeHandler.clickedNode = GlobalNodeHandler.viewNode.ContainsChildNode(mousePos.X, mousePos.Y)) == null)
                    {
                        surpressMouseup = false;
                        if (selectedGroup.Count != 0)
                        {
                            foreach (MindNode m in selectedGroup)
                            {
                                m.setHovered(false);
                            }
                            selectedGroup   = new List <MindNode>();
                            diffPoints      = new List <CalcPoint>();
                            surpressMouseup = true;
                        }

                        mouseStartPoint = mousePos;
                        dragRec         = true;
                    }
                }
                if (mousObj.thisButton.Equals(MouseButton.MIDDLE))
                {
                    if ((GlobalNodeHandler.clickedNode = GlobalNodeHandler.viewNode.ContainsChildNode(mousePos.X, mousePos.Y)) != null)
                    {
                        MainPage.status2 += "Middle Chosen" + "\n";
                        GlobalNodeHandler.clickedNode.NodeColor = ColorPicker.selectedcolor;
                        GlobalNodeHandler.clickedNode.updateRepresentation();
                        repaint(this, new EventArgs());;
                    }
                    else if ((GlobalNodeHandler.clickedLabel = GlobalNodeHandler.viewNode.ContainsChildLabel(mousePos.X, mousePos.Y)) != null)
                    {
                        GlobalNodeHandler.clickedLabel.NodeColor = ColorPicker.selectedcolor;
                        GlobalNodeHandler.clickedLabel.updateRepresentation();
                        repaint(this, new EventArgs());;
                    }
                }
                if (mousObj.thisButton.Equals(MouseButton.RIGHT))
                {
                    if ((GlobalNodeHandler.clickedNode = GlobalNodeHandler.viewNode.ContainsChildNode(mousePos.X, mousePos.Y)) != null)
                    {
                        MainPage.status2 += "IsRight CLicked" + "\n";
                        MindNodeAction action = new MindNodeAction(GlobalNodeHandler.clickedNode);
                        if (mousePos.X < GlobalNodeHandler.clickedNode.xpos + 5)
                        {
                            transformrecx       = -1;
                            transformStart      = mousePos;
                            startWidth          = GlobalNodeHandler.clickedNode.width;
                            NodeStart           = new CalcPoint(GlobalNodeHandler.clickedNode.xpos, GlobalNodeHandler.clickedNode.ypos);
                            action.sourceSize.X = startWidth;
                            action.id           = 6;
                            action.name         = "Transform";
                            GlobalNodeHandler.actionLog.AddAction(action);
                        }
                        else if (mousePos.X > GlobalNodeHandler.clickedNode.xpos + GlobalNodeHandler.clickedNode.width - 5)
                        {
                            transformrecx       = 1;
                            transformStart      = mousePos;
                            startWidth          = GlobalNodeHandler.clickedNode.width;
                            NodeStart           = new CalcPoint(GlobalNodeHandler.clickedNode.xpos, GlobalNodeHandler.clickedNode.ypos);
                            action.sourceSize.X = startWidth;
                            action.id           = 6;
                            action.name         = "Transform";
                            GlobalNodeHandler.actionLog.AddAction(action);
                        }
                        else if (mousePos.Y < GlobalNodeHandler.clickedNode.ypos + 5)
                        {
                            transformrecy       = -1;
                            transformStart      = mousePos;
                            startHeight         = GlobalNodeHandler.clickedNode.height;
                            NodeStart           = new CalcPoint(GlobalNodeHandler.clickedNode.xpos, GlobalNodeHandler.clickedNode.ypos);
                            action.sourceSize.Y = startHeight;
                            action.id           = 6;
                            action.name         = "Transform";
                            GlobalNodeHandler.actionLog.AddAction(action);
                        }
                        else if (mousePos.Y > GlobalNodeHandler.clickedNode.ypos + GlobalNodeHandler.clickedNode.height - 5)
                        {
                            transformrecy       = 1;
                            transformStart      = mousePos;
                            startHeight         = GlobalNodeHandler.clickedNode.height;
                            NodeStart           = new CalcPoint(GlobalNodeHandler.clickedNode.xpos, GlobalNodeHandler.clickedNode.ypos);
                            action.sourceSize.Y = startHeight;
                            action.id           = 6;
                            action.name         = "Transform";
                            GlobalNodeHandler.actionLog.AddAction(action);
                        }
                        else
                        {
                            if (GlobalNodeHandler.clickedNode.getSelected())
                            {
                                GlobalNodeHandler.clickedNode.setHovered(false);
                            }

                            if (selectedGroup.Count != 0)
                            {
                                MindNodeAction moveaction = new MindNodeAction(2, "MoveNodes");

                                foreach (MindNode m in selectedGroup)
                                {
                                    diffPoints.Add(new CalcPoint(m.xpos - GlobalNodeHandler.clickedNode.xpos, m.ypos - GlobalNodeHandler.clickedNode.ypos));

                                    moveaction.startpoint.Push(new CalcPoint(m.xpos, m.ypos));
                                    moveaction.involvedNodes.Push(m);
                                }
                                GlobalNodeHandler.actionLog.AddAction(moveaction);
                            }
                            else
                            {
                                MindNodeAction moveaction = new MindNodeAction(2, "MoveNodes", GlobalNodeHandler.clickedNode);
                                moveaction.startpoint.Push(new CalcPoint(GlobalNodeHandler.clickedNode.xpos, GlobalNodeHandler.clickedNode.ypos));
                                GlobalNodeHandler.actionLog.AddAction(moveaction);
                            }
                            dragging = true;
                        }
                    }
                    else
                    {
                        mouseStartPoint = mousePos;
                        dragView        = true;
                    }
                }
            }
        }
예제 #22
0
        public void UndoLast()
        {
            if (undoactions.Count >= 1)
            {
                MindNodeAction action = undoactions.Last();
                undoactions.Remove(action);
                switch (action.name)
                {
                case "CreateNode":
                    if (action.involvedNodes.Count >= 1)
                    {
                        MindNode createdNode = action.involvedNodes.Pop();
                        redoactions.Add(new MindNodeAction(1, "DeleteNode", createdNode));
                        createdNode.DeleteNode();
                    }
                    break;

                case "DeleteNode":
                    if (action.involvedNodes.Count >= 1)
                    {
                        MindNode deletednode = action.involvedNodes.Pop();
                        redoactions.Add(new MindNodeAction(0, "CreateNode", deletednode));
                        if (deletednode.parent != null)
                        {
                            deletednode.parent.AddChildNoStyle(deletednode, false);
                        }
                        // Refresh Pivot Representation after reinstating node
                        deletednode.UpdatePivots();
                    }
                    break;

                case "MoveNodes":
                    if (action.involvedNodes.Count >= 1)
                    {
                        MindNodeAction newaction = new MindNodeAction(2, "MoveNodes");
                        foreach (MindNode movedNode in action.involvedNodes)
                        {
                            newaction.involvedNodes.Push(movedNode);
                            newaction.startpoint.Push(new CalcPoint(movedNode.xpos, movedNode.ypos));

                            if (action.startpoint.Count > 0)
                            {
                                CalcPoint oldPos = action.startpoint.Pop();

                                movedNode.SetPosition(oldPos.X, oldPos.Y, false);
                            }
                            // Refresh Pivot Representation after moving node
                            movedNode.UpdatePivots();
                        }
                        redoactions.Add(newaction);
                    }
                    break;

                case "ConnectNodes":
                    if (action.involvedNodes.Count >= 2)
                    {
                        MindNodeAction newAction = new MindNodeAction(3, "DeleteConnections");
                        for (int i = 0; i < action.involvedNodes.Count / 2; i++)
                        {
                            MindNode rightnode = action.involvedNodes.Pop();
                            MindNode leftnode  = action.involvedNodes.Pop();

                            newAction.involvedNodes.Push(leftnode);
                            newAction.involvedNodes.Push(rightnode);

                            leftnode.DeleteConnection(rightnode);
                        }
                        redoactions.Add(newAction);
                    }
                    break;

                case "DeleteConnections":
                    if (action.involvedNodes.Count >= 2)
                    {
                        MindNodeAction newAction = new MindNodeAction(3, "ConnectNodes");
                        for (int i = 0; i < action.involvedNodes.Count / 2; i++)
                        {
                            MindNode rightnode = action.involvedNodes.Pop();
                            MindNode leftnode  = action.involvedNodes.Pop();

                            newAction.involvedNodes.Push(leftnode);
                            newAction.involvedNodes.Push(rightnode);

                            leftnode.AddConnection(rightnode);

                            // Refresh Pivot Representation after reinstating connection
                            leftnode.UpdatePivots();
                        }

                        redoactions.Add(newAction);
                    }
                    break;

                case "ChangeText":
                    if (action.involvedNodes.Count >= 1)
                    {
                        MindNodeAction newaction = new MindNodeAction(4, "ChangeText");

                        MindNode changedNode = action.involvedNodes.Pop();
                        newaction.text = changedNode.text;
                        newaction.involvedNodes.Push(changedNode);

                        changedNode.SetText(action.text);

                        redoactions.Add(newaction);
                    }
                    else if (action.involvedLabel != null)
                    {
                        MindNodeAction newaction = new MindNodeAction(4, "ChangeText");

                        NodeLabel changedLabel = action.involvedLabel;
                        newaction.text          = changedLabel.GetText();
                        newaction.involvedLabel = changedLabel;

                        changedLabel.SetText(action.text);

                        redoactions.Add(newaction);
                    }
                    break;

                case "Transform":
                    if (action.involvedNodes.Count >= 1)
                    {
                        MindNodeAction newaction = new MindNodeAction(5, "Transform");

                        MindNode changedNode = action.involvedNodes.Pop();
                        newaction.sourceSize.X = changedNode.width;
                        newaction.sourceSize.Y = changedNode.height;
                        newaction.startpoint.Push(new CalcPoint(changedNode.xpos, changedNode.ypos));
                        newaction.involvedNodes.Push(changedNode);

                        if (action.sourceSize.X != -1)
                        {
                            changedNode.width = action.sourceSize.X;
                            changedNode.SetScaled(false);
                        }
                        if (action.sourceSize.Y != -1)
                        {
                            changedNode.height = action.sourceSize.Y;
                            changedNode.SetScaled(false);
                        }

                        CalcPoint oldPos = action.startpoint.Pop();
                        if (oldPos != null)
                        {
                            changedNode.SetPosition(oldPos.X, oldPos.Y, false);
                        }

                        // Refresh Pivot Representation after resetting transformation
                        changedNode.UpdatePivots();
                        changedNode.updateRepresentation();

                        redoactions.Add(newaction);
                    }
                    break;
                }
            }
        }
예제 #23
0
        public async void viewPane_Pressed(MouseObject mousObj)
        {
            CalcPoint mousePos = mousObj.currentMousePos;

            if (GlobalNodeHandler.TabletSelected)
            {
                if (!GlobalNodeHandler.typing)
                {
                    if (GlobalNodeHandler.pick1.BoxContains(mousePos.ToPoint()))
                    {
                        if (GlobalNodeHandler.pick1.ChangeColorTo(mousePos.ToPoint()))
                        {
                            repaint(this, new EventArgs());
                        }
                    }
                    else
                    {
                        if (GlobalNodeHandler.transforming)
                        {
                            if ((transformnode = GlobalNodeHandler.viewNode.ContainsTRecChild(mousePos.X, mousePos.Y)) != null)
                            {
                                MindNodeAction action = new MindNodeAction(6, "Transform", transformnode);
                                transformStart      = mousePos;
                                startWidth          = transformnode.width;
                                startHeight         = transformnode.height;
                                action.sourceSize.X = startWidth;
                                action.sourceSize.Y = startHeight;
                                action.startpoint.Push(new CalcPoint(transformnode.xpos, transformnode.ypos));
                                dragView = false;

                                NodeStart = new CalcPoint(transformnode.xpos, transformnode.ypos);

                                if (mousePos.X < transformnode.xpos + transformInBorder)
                                {
                                    transformPoint.X = -1;
                                }
                                else if (mousePos.X > transformnode.xpos + transformnode.width - transformInBorder)
                                {
                                    transformPoint.X = 1;
                                }
                                if (mousePos.Y < transformnode.ypos + transformInBorder)
                                {
                                    transformPoint.Y = -1;
                                }
                                else if (mousePos.Y > transformnode.ypos + transformnode.height - transformInBorder)
                                {
                                    transformPoint.Y = 1;
                                }
                                GlobalNodeHandler.actionLog.AddAction(action);
                            }
                        }
                        if (GlobalNodeHandler.connecting)
                        {
                            if (GlobalNodeHandler.clickedNode != null)
                            {
                                GlobalNodeHandler.clickedNode.setSelected(false);
                            }
                        }


                        if ((GlobalNodeHandler.clickedNode = GlobalNodeHandler.viewNode.ContainsChildNode(mousePos.X, mousePos.Y)) == null)
                        {
                            GlobalNodeHandler.clickedLabel = GlobalNodeHandler.viewNode.ContainsChildLabel(mousePos.X, mousePos.Y);
                            GlobalNodeHandler.rightNode    = null;
                            mouseStartPoint = mousePos;
                            if (transformnode == null)
                            {
                                dragView = true;
                            }
                            clickstartcount = tickcnt;

                            if (GlobalNodeHandler.coloring)
                            {
                                if (GlobalNodeHandler.clickedLabel != null)
                                {
                                    GlobalNodeHandler.clickedLabel.NodeColor = ColorPicker.selectedcolor;
                                    GlobalNodeHandler.clickedLabel.updateRepresentation();
                                    repaint(this, new EventArgs());;
                                }
                            }

                            if (GlobalNodeHandler.paste)
                            {
                                await GlobalNodeHandler.settings.RestoreFromClipboard(mousePos.X, mousePos.Y);
                            }
                        }
                        else
                        {
                            if (mousObj.thisButton.Equals(MouseButton.LEFT))
                            {
                                if (GlobalNodeHandler.coloring)
                                {
                                    if (GlobalNodeHandler.clickedNode != null)
                                    {
                                        GlobalNodeHandler.clickedNode.NodeColor = ColorPicker.selectedcolor;
                                        GlobalNodeHandler.clickedNode.updateRepresentation();
                                        repaint(this, new EventArgs());;
                                    }
                                }
                                if (GlobalNodeHandler.jumping)
                                {
                                    GlobalNodeHandler.JumpInto(GlobalNodeHandler.clickedNode);
                                    repaint(this, new EventArgs());
                                }
                                if (GlobalNodeHandler.copy)
                                {
                                    GlobalNodeHandler.settings.CopyToClipboard(GlobalNodeHandler.clickedNode);
                                }
                                else if (GlobalNodeHandler.cut)
                                {
                                    GlobalNodeHandler.settings.CopyToClipboard(GlobalNodeHandler.clickedNode);
                                    GlobalNodeHandler.actionLog.AddAction(new MindNodeAction(1, "DeleteNode", GlobalNodeHandler.clickedNode));
                                    GlobalNodeHandler.clickedNode.DeleteAllConnections();
                                    GlobalNodeHandler.clickedNode.DeleteNode();
                                    repaint(this, new EventArgs());
                                }
                                else if (GlobalNodeHandler.connecting)
                                {
                                    if (GlobalNodeHandler.rightNode == null)
                                    {
                                        GlobalNodeHandler.rightNode = GlobalNodeHandler.clickedNode;
                                        GlobalNodeHandler.rightNode.setSelected(true);
                                    }
                                    else if (!GlobalNodeHandler.clickedNode.Equals(GlobalNodeHandler.rightNode))
                                    {
                                        GlobalNodeHandler.rightNode.setSelected(false);
                                        if (GlobalNodeHandler.rightNode.AddConnection(GlobalNodeHandler.clickedNode))
                                        {
                                            GlobalNodeHandler.actionLog.AddAction(new MindNodeAction(3, "ConnectNodes", GlobalNodeHandler.rightNode, GlobalNodeHandler.clickedNode));
                                        }
                                        GlobalNodeHandler.rightNode.UpdateBridgesRepresentation();
                                        GlobalNodeHandler.clickedNode = null;
                                        GlobalNodeHandler.rightNode   = null;
                                    }
                                    repaint(this, new EventArgs());
                                }
                                else if (GlobalNodeHandler.disconnecting)
                                {
                                    if (GlobalNodeHandler.rightNode == null)
                                    {
                                        GlobalNodeHandler.rightNode = GlobalNodeHandler.clickedNode;
                                        GlobalNodeHandler.rightNode.setSelected(true);
                                    }
                                    else
                                    {
                                        GlobalNodeHandler.rightNode.setSelected(false);

                                        if (GlobalNodeHandler.rightNode.connNodes.Contains(GlobalNodeHandler.clickedNode))
                                        {
                                            GlobalNodeHandler.actionLog.AddAction(new MindNodeAction(4, "DeleteConnections", GlobalNodeHandler.rightNode, GlobalNodeHandler.clickedNode));
                                        }
                                        else
                                        {
                                            GlobalNodeHandler.actionLog.AddAction(new MindNodeAction(4, "DeleteConnections", GlobalNodeHandler.clickedNode, GlobalNodeHandler.rightNode));
                                        }

                                        GlobalNodeHandler.rightNode.DeleteConnection(GlobalNodeHandler.clickedNode);
                                        GlobalNodeHandler.clickedNode.DeleteConnection(GlobalNodeHandler.rightNode);


                                        GlobalNodeHandler.clickedNode = null;
                                        GlobalNodeHandler.rightNode   = null;
                                    }
                                    repaint(this, new EventArgs());
                                }
                                else if (GlobalNodeHandler.deleting)
                                {
                                    MindNodeAction action = new MindNodeAction(3, "DeleteConnections");
                                    action.involvedNodes.Push(GlobalNodeHandler.clickedNode);
                                    foreach (MindNode m in GlobalNodeHandler.clickedNode.connNodes)
                                    {
                                        action.involvedNodes.Push(GlobalNodeHandler.clickedNode);
                                        action.involvedNodes.Push(m);
                                    }
                                    foreach (MindNode m in GlobalNodeHandler.clickedNode.backconnNodes)
                                    {
                                        action.involvedNodes.Push(m);
                                        action.involvedNodes.Push(GlobalNodeHandler.clickedNode);
                                    }
                                    GlobalNodeHandler.actionLog.AddAction(action);

                                    GlobalNodeHandler.clickedNode.DeleteAllConnections();

                                    GlobalNodeHandler.actionLog.AddAction(new MindNodeAction(1, "DeleteNode", GlobalNodeHandler.clickedNode));
                                    GlobalNodeHandler.viewNode.DeleteNode(GlobalNodeHandler.clickedNode);
                                    repaint(this, new EventArgs());
                                }
                                else if (GlobalNodeHandler.moving)
                                {
                                    if (selectedGroup.Count != 0)
                                    {
                                        MindNodeAction moveaction = new MindNodeAction(2, "MoveNodes");
                                        foreach (MindNode m in selectedGroup)
                                        {
                                            diffPoints.Add(new CalcPoint(m.xpos - GlobalNodeHandler.clickedNode.xpos, m.ypos - GlobalNodeHandler.clickedNode.ypos));
                                            moveaction.startpoint.Push(new CalcPoint(m.xpos, m.ypos));
                                            moveaction.involvedNodes.Push(m);
                                        }
                                        GlobalNodeHandler.actionLog.AddAction(moveaction);
                                    }
                                    else
                                    {
                                        MindNodeAction moveaction = new MindNodeAction(2, "MoveNodes", GlobalNodeHandler.clickedNode);
                                        moveaction.startpoint.Push(new CalcPoint(GlobalNodeHandler.clickedNode.xpos, GlobalNodeHandler.clickedNode.ypos));
                                        GlobalNodeHandler.actionLog.AddAction(moveaction);
                                    }
                                    dragging = true;
                                }
                            }
                        }
                        if (GlobalNodeHandler.placelabel)
                        {
                            if (GlobalNodeHandler.clickedNode != null)
                            {
                                activetext.Text = GlobalNodeHandler.clickedNode.text;
                                GlobalNodeHandler.ShowTextBox(mousObj.currentMousePos, activetext);
                                GlobalNodeHandler.actionLog.AddAction(new MindNodeAction(5, "ChangeText", GlobalNodeHandler.clickedNode, GlobalNodeHandler.clickedNode.text));
                                GlobalNodeHandler.typing = true;
                            }
                            else if (GlobalNodeHandler.clickedLabel != null)
                            {
                                activetext.Text = GlobalNodeHandler.clickedLabel.GetText();
                                GlobalNodeHandler.ShowTextBox(mousObj.currentMousePos, activetext);
                                GlobalNodeHandler.actionLog.AddAction(new MindNodeAction(5, "ChangeText", GlobalNodeHandler.clickedLabel, GlobalNodeHandler.clickedLabel.GetText()));
                                GlobalNodeHandler.typing = true;
                            }
                        }
                    }
                }
            }
            else if (GlobalNodeHandler.mouseSelected)
            {
                viewPane_MouseDown(mousObj);
            }
        }
예제 #24
0
 public void ThisAdd(CalcPoint other)
 {
     this.X += other.X;
     this.Y += other.Y;
 }
예제 #25
0
        public void viewPane_MouseUp(MouseObject mousObj)
        {
            CalcPoint mousePos = mousObj.currentMousePos;

            //MainPage.status2 += "Released"+"" + ptrPt.Properties.IsRightButtonPressed.ToString();

            if (mousObj.thisButton.Equals(MouseButton.LEFT))
            {
                if (tickcnt - clickstartcount < 10 && !surpressMouseup)
                {
                    surpressMouseup = false;
                    //System.out.println("mouseclick");
                    if (!GlobalNodeHandler.typing)
                    {
                        if ((GlobalNodeHandler.clickedNode = GlobalNodeHandler.viewNode.ContainsChildNode(mousePos.X, mousePos.Y)) == null)
                        {
                            if (!dragView)
                            {
                                if ((GlobalNodeHandler.clickedLabel = GlobalNodeHandler.viewNode.ContainsChildLabel(mousePos.X, mousePos.Y)) != null)
                                {
                                    activetext.Visibility = Visibility.Visible;
                                    activetext.Margin     = new Thickness(currentFormPosition.X, currentFormPosition.Y, 0, 0);
                                    activetext.Text       = GlobalNodeHandler.clickedLabel.GetText();
                                    GlobalNodeHandler.actionLog.AddAction(new MindNodeAction(5, "ChangeText", GlobalNodeHandler.clickedLabel, GlobalNodeHandler.clickedLabel.GetText()));
                                    GlobalNodeHandler.typing = true;
                                }
                                else
                                {
                                    if (GlobalNodeHandler.CreateNewNode(mousePos.X, mousePos.Y, true))
                                    {
                                        CalcPoint CreatePoint = new CalcPoint();

                                        if (currentFormPosition != null)
                                        {
                                            CreatePoint = new CalcPoint(currentFormPosition.X - GlobalNodeHandler.clickedNode.width,
                                                                        currentFormPosition.Y - GlobalNodeHandler.clickedNode.height);
                                        }

                                        GlobalNodeHandler.ShowTextBox(CreatePoint, activetext);
                                        repaint(this, new EventArgs());
                                    }
                                }
                            }
                        }
                        else
                        {
                            activetext.Visibility = Visibility.Visible;
                            activetext.Margin     = new Thickness(currentFormPosition.X, currentFormPosition.Y, 0, 0);
                            activetext.Text       = GlobalNodeHandler.clickedNode.text;
                            GlobalNodeHandler.actionLog.AddAction(new MindNodeAction(5, "ChangeText", GlobalNodeHandler.clickedNode, GlobalNodeHandler.clickedNode.text));

                            GlobalNodeHandler.typing = true;
                        }
                    }
                    if (dragRec)
                    {
                        mouseEndPoint = mousePos;
                        dragRec       = false;

                        selectedGroup = GlobalNodeHandler.viewNode.ChildrenInRec(selectionRec);
                        foreach (MindNode m in selectedGroup)
                        {
                            m.setHovered(true);
                        }

                        selectionRec = new Rect(0, 0, 0, 0);
                        repaint(this, new EventArgs());
                    }
                    else if (dragView)
                    {
                        dragView = false;
                        repaint(this, new EventArgs());
                    }
                }
            }
            if (mousObj.thisButton.Equals(MouseButton.RIGHT))
            {
                if (transformrecx != 0 || transformrecy != 0)
                {
                    if (transformrecx != 0)
                    {
                        transformrecx = 0;
                    }
                    if (transformrecy != 0)
                    {
                        transformrecy = 0;
                    }
                    GlobalNodeHandler.clickedNode.SetScaled(true);
                    GlobalNodeHandler.clickedNode.updateRepresentation();
                    repaint(this, new EventArgs());
                }
                if (dragging)
                {
                    dragging = false;
                    int x = mousePos.X;
                    int y = mousePos.Y;

                    if (selectedGroup.Count != 0)
                    {
                        diffPoints = new List <CalcPoint>();
                    }
                    else if (GlobalNodeHandler.clickedNode != null)
                    {
                        GlobalNodeHandler.clickedNode.SetPosition(x, y, true);
                        GlobalNodeHandler.clickedNode.setHovered(false);
                        GlobalNodeHandler.clickedNode = null;
                        repaint(this, new EventArgs());
                    }
                }
                else if (dragView)
                {
                    dragView = false;
                    repaint(this, new EventArgs());
                }
            }
        }
예제 #26
0
 public MouseObject(MouseButton pressedButton, CalcPoint currentMousePos)
 {
     this.thisButton      = pressedButton;
     this.currentMousePos = currentMousePos;
 }
예제 #27
0
        public void timer1_Tick(object sender, object e)
        {
            int x = currentViewPanePosition.X;
            int y = currentViewPanePosition.Y;

            tickcnt++;
            if (GlobalNodeHandler.typing)
            {
                FocusText(this, new EventArgs());
            }
            if (tickcnt - MainPage.startcnt > 10 && MainPage.scrolling)
            {
                MainPage.scrollcnt = 0;
                MainPage.scrolling = false;
                GlobalNodeHandler.viewNode.UpdateViewRepresentation();
                repaint(this, new EventArgs());
            }
            if (transformPoint.X != 0)
            {
                transformnode.width = startWidth + transformPoint.X * (x - transformStart.X);

                if (transformnode.width < 10)
                {
                    transformnode.width = 10;
                }
                else if (transformPoint.X == -1)
                {
                    transformnode.xpos = NodeStart.X - (transformStart.X - x);
                }
                repaint(this, new EventArgs());
            }
            if (transformPoint.Y != 0)
            {
                transformnode.height = startHeight + transformPoint.Y * (y - transformStart.Y);
                if (transformnode.height < 10)
                {
                    transformnode.height = 10;
                }
                else if (transformPoint.Y == -1)
                {
                    transformnode.ypos = NodeStart.Y - (transformStart.Y - y);
                }
                repaint(this, new EventArgs());
            }
            if (selectedGroup.Count == 0 && !dragging)
            {
                if (tempNode == null)
                {
                    tempNode = GlobalNodeHandler.viewNode.ContainsChildNode(x, y);
                    if (tempNode != null)
                    {
                        MainPage.status2 += "Hovered over child" + "\n";
                    }
                }
                else
                {
                    if (!hoveractive)
                    {
                        MainPage.status2 += "Hovered is true" + "\n";
                        tempNode.setHovered(true);
                        repaint(this, new EventArgs());
                    }
                    hoveractive = true;
                    if (!tempNode.Contains(x, y))
                    {
                        hoveractive = false;
                        tempNode.setHovered(false);
                        tempNode = null;
                        repaint(this, new EventArgs());
                    }
                }
            }
            else if (dragging)
            {
                if (selectedGroup.Count == 0)
                {
                    GlobalNodeHandler.clickedNode.SetPosition(x, y, true);
                    GlobalNodeHandler.clickedNode.UpdatePivots();
                    GlobalNodeHandler.clickedNode.UpdateBridgesRepresentation();
                    GlobalNodeHandler.clickedNode.UpdateBridgesRepresentationInward();
                    GlobalNodeHandler.clickedNode.setHovered(true);
                }
                else
                {
                    GlobalNodeHandler.clickedNode.SetPosition(x, y, true);
                    GlobalNodeHandler.clickedNode.UpdatePivots();
                    GlobalNodeHandler.clickedNode.setHovered(true);
                    if (selectedGroup.Contains(GlobalNodeHandler.clickedNode))
                    {
                        for (int i = 0; i < diffPoints.Count; i++)
                        {
                            selectedGroup.ElementAt(i).SetPosition(GlobalNodeHandler.clickedNode.xpos + diffPoints.ElementAt(i).X, GlobalNodeHandler.clickedNode.ypos + diffPoints.ElementAt(i).Y, false);
                            selectedGroup.ElementAt(i).UpdatePivots();
                        }
                    }
                    else if (diffPoints.Count != 0)
                    {
                        foreach (MindNode m in selectedGroup)
                        {
                            m.setHovered(false);
                        }
                        selectedGroup = new List <MindNode>();
                        diffPoints    = new List <CalcPoint>();
                    }
                }

                repaint(this, new EventArgs());
            }
            if (dragRec)
            {
                mouseEndPoint = new CalcPoint(x, y);
                if (mouseStartPoint.X < mouseEndPoint.X && mouseStartPoint.Y < mouseEndPoint.Y)
                {
                    selectionRec = new Rect(mouseStartPoint.X, mouseStartPoint.Y, mouseEndPoint.X - mouseStartPoint.X, mouseEndPoint.Y - mouseStartPoint.Y);
                }
                else if (mouseStartPoint.X > mouseEndPoint.X && mouseStartPoint.Y > mouseEndPoint.Y)
                {
                    selectionRec = new Rect(mouseEndPoint.X, mouseEndPoint.Y, mouseStartPoint.X - mouseEndPoint.X, mouseStartPoint.Y - mouseEndPoint.Y);
                }
                else if (mouseStartPoint.X > mouseEndPoint.X && mouseStartPoint.Y < mouseEndPoint.Y)
                {
                    selectionRec = new Rect(mouseEndPoint.X, mouseStartPoint.Y, mouseStartPoint.X - mouseEndPoint.X, mouseEndPoint.Y - mouseStartPoint.Y);
                }
                else if (mouseStartPoint.X < mouseEndPoint.X && mouseStartPoint.Y > mouseEndPoint.Y)
                {
                    selectionRec = new Rect(mouseStartPoint.X, mouseEndPoint.Y, mouseEndPoint.X - mouseStartPoint.X, mouseStartPoint.Y - mouseEndPoint.Y);
                }

                repaint(this, new EventArgs());;
            }
            else if (dragView)
            {
                mouseEndPoint = new CalcPoint(x, y);
                CalcPoint relative = new CalcPoint(mouseStartPoint.X - mouseEndPoint.X, mouseStartPoint.Y - mouseEndPoint.Y);
                mouseStartPoint = mouseEndPoint;

                GlobalNodeHandler.viewNode.MoveViewRelativePix(relative);
                repaint(this, new EventArgs());
            }
        }
예제 #28
0
        //private static readonly ILog log = LogManager.GetLogger(typeof(Bridge));

        public Bridge(CalcPoint start, CalcPoint end, Color col)
        {
            ReBridge(start, end);
            textNode.NodeColor = col;
        }
예제 #29
0
 public KeyObject(Key pressedKey, CalcPoint currentMousePos)
 {
     this.thisKey         = pressedKey;
     this.currentMousePos = currentMousePos;
 }
예제 #30
0
        public void updateRepresentation()
        {
            if (represent != null)
            {
                represent.Dispose();
            }

            CreateBoundBox();

            try
            {
                if (boundbox.Height > 0 && boundbox.Width > 0)
                {
                    represent = new CanvasRenderTarget(device, (int)this.boundbox.Width, (int)this.boundbox.Height, 96);

                    using (CanvasDrawingSession g2d = represent.CreateDrawingSession())
                    {
                        g2d.Clear(Colors.Transparent);

                        g2d.Antialiasing = CanvasAntialiasing.Antialiased;

                        Color bordercolor = Colors.Black;
                        int   linesize    = 2;


                        CalcPoint        second = new CalcPoint();
                        CalcPoint        arrowleft;
                        CalcPoint        arrowright;
                        CalcPoint        direction;
                        List <CalcPoint> pointslist;

                        int xoffset = -(int)(boundbox.X);
                        int yoffset = -(int)(boundbox.Y);

                        pointslist = this.nodes;

                        direction = new CalcPoint(this.PointDirection());

                        /*for (int i = 0; i < pointslist.Count - 1; i++)
                         * {
                         *  second = pointslist.ElementAt(i + 1);
                         *  g2d.DrawLine(pointslist[i].X, second.X, pointslist[i].Y, second.Y, bordercolor, linesize);
                         *
                         * }*/
                        second = pointslist.Last();

                        core.DrawBezier(g2d, pointslist, xoffset, yoffset, bordercolor, linesize);

                        arrowleft  = new CalcPoint(second.X + xoffset, second.Y + yoffset);
                        arrowright = new CalcPoint(second.X + xoffset, second.Y + yoffset);

                        if (direction.X != 0)
                        {
                            arrowleft  = new CalcPoint(second.X + xoffset - 10 * direction.X, second.Y + yoffset - 10);
                            arrowright = new CalcPoint(second.X + xoffset - 10 * direction.X, second.Y + yoffset + 10);
                        }
                        if (direction.Y != 0)
                        {
                            arrowleft  = new CalcPoint(second.X + xoffset - 10, second.Y + yoffset - 10 * direction.Y);
                            arrowright = new CalcPoint(second.X + xoffset + 10, second.Y + yoffset - 10 * direction.Y);
                        }

                        //g2d.DrawLine(new Vector2(second), new Vector2(arrowleft), bordercolor, linesize);
                        core.DrawLine(g2d, second.X + xoffset, second.Y + yoffset, arrowleft.X, arrowleft.Y, bordercolor, linesize);
                        core.DrawLine(g2d, second.X + xoffset, second.Y + yoffset, arrowright.X, arrowright.Y, bordercolor, linesize);
                    }
                }
            }
            catch (Exception e)
            {
            }
        }