Пример #1
0
        private void Parse(XmlTextReader xml)
        {
            Name = xml.MoveToAttribute("name") ? xml.Value : "empty";

            if (xml.IsEmptyElement)
            {
                Children = new IGoNode[0];
            }
            else
            {
                List <IGoNode> children = new List <IGoNode>();

                while (xml.Read() && (xml.NodeType == XmlNodeType.Element || xml.NodeType == XmlNodeType.Comment))
                {
                    if (xml.NodeType == XmlNodeType.Comment)
                    {
                        continue;
                    }

                    if (xml.Name == "child")
                    {
                        children.Add(new ChildNode(xml, this));
                    }
                    else
                    {
                        children.Add(new ParentNode(xml, this));
                    }
                }

                Children = children.ToArray();
            }
        }
Пример #2
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;

            switch (info.ButtonID)
            {
            case 1:
            {
                if (m_Node.Parent != null)
                {
                    from.SendGump(new GoGump(0, from, m_Tree, m_Node.Parent));
                }

                break;
            }

            case 2:
            {
                if (m_Page > 0)
                {
                    from.SendGump(new GoGump(m_Page - 1, from, m_Tree, m_Node));
                }

                break;
            }

            case 3:
            {
                if ((m_Page + 1) * EntryCount < m_Node.Children.Length)
                {
                    from.SendGump(new GoGump(m_Page + 1, from, m_Tree, m_Node));
                }

                break;
            }

            default:
            {
                int index = info.ButtonID - 4;

                if (index >= 0 && index < m_Node.Children.Length)
                {
                    IGoNode o = m_Node.Children[index];

                    if (o is ParentNode node)
                    {
                        from.SendGump(new GoGump(0, from, m_Tree, node));
                    }
                    else
                    {
                        from.MoveToWorld(((ChildNode)o).Location, m_Tree.Map);
                    }
                }

                break;
            }
            }
        }
Пример #3
0
 protected void NodeGotSelection(Object sender, GoSelectionEventArgs evt)
 {
     if (evt.GoObject == this.View.Selection.Primary)
     {
         IGoNode n = evt.GoObject as IGoNode;
         if (n != null && n.UserObject != null)
         {
             this.NodeInfo = (n.UserObject as ToolBase).Settings;
         }
         else
         {
             this.NodeInfo = null;
         }
     }
 }
Пример #4
0
 protected override void OnBackgroundHover(GoInputEventArgs e)
 {
     foreach (GoObject obj in this.Document)
     {
         IGoNode n = obj as IGoNode;
         if (n != null)
         {
             foreach (GoPort p in n.Ports)
             {
                 p.SkipsUndoManager = true;
                 p.Style = GoPortStyle.None;
                 p.SkipsUndoManager = false;
             }
         }
     }
     base.OnBackgroundHover(e);
 }
Пример #5
0
        /// <summary>
        /// Make sure each link, either directly in the given collection, or connected to the nodes in
        /// the given collection, belong to the appropriate <see cref="T:Northwoods.Go.GoSubGraphBase" />.
        /// </summary>
        /// <param name="coll"></param>
        /// <param name="behind">whether to add the <paramref name="coll" /> at the beginning of the list
        /// of the subgraph's children (thus behind all other subgraph children), or at the end of the list
        /// (thus appearing in front of all the other subgraph children)</param>
        /// <param name="layer">the <see cref="T:Northwoods.Go.GoLayer" /> for links whose ports do not both belong to a <see cref="T:Northwoods.Go.GoSubGraphBase" /></param>
        /// <remarks>
        /// This calls <see cref="M:Northwoods.Go.GoSubGraphBase.ReparentToCommonSubGraph(Northwoods.Go.GoObject,Northwoods.Go.GoObject,Northwoods.Go.GoObject,System.Boolean,Northwoods.Go.GoLayer)" /> for each <see cref="T:Northwoods.Go.IGoLink" /> in the
        /// <paramref name="coll" /> collection, or for each <see cref="T:Northwoods.Go.IGoLink" /> connected to each <see cref="T:Northwoods.Go.IGoNode" />
        /// in the <paramref name="coll" /> collection.
        /// </remarks>
        public static void ReparentAllLinksToSubGraphs(IGoCollection coll, bool behind, GoLayer layer)
        {
            GoCollection goCollection = new GoCollection();

            foreach (GoObject item in coll)
            {
                goCollection.Add(item);
            }
            foreach (GoObject item2 in goCollection)
            {
                IGoNode goNode = item2 as IGoNode;
                if (goNode != null)
                {
                    foreach (IGoLink link in goNode.Links)
                    {
                        if (link != null && link.FromPort != null && link.ToPort != null)
                        {
                            ReparentToCommonSubGraph(link.GoObject, link.FromPort.GoObject, link.ToPort.GoObject, behind, layer);
                        }
                    }
                }
                else
                {
                    IGoPort goPort = item2 as IGoPort;
                    if (goPort != null)
                    {
                        foreach (IGoLink link2 in goPort.Links)
                        {
                            if (link2 != null && link2.FromPort != null && link2.ToPort != null)
                            {
                                ReparentToCommonSubGraph(link2.GoObject, link2.FromPort.GoObject, link2.ToPort.GoObject, behind, layer);
                            }
                        }
                    }
                    else
                    {
                        IGoLink goLink = item2 as IGoLink;
                        if (goLink != null && goLink.FromPort != null && goLink.ToPort != null)
                        {
                            ReparentToCommonSubGraph(goLink.GoObject, goLink.FromPort.GoObject, goLink.ToPort.GoObject, behind, layer);
                        }
                    }
                }
            }
        }
Пример #6
0
        public void RefreshUI()
        {
            if (myView == null)
            {
                this.NodeInfo = null;
                return;
            }
            IGoNode nn = (myView.Selection != null ? myView.Selection.Primary as IGoNode : null);

            if (nn != null && nn.UserObject != null)
            {
                this.NodeInfo = (nn.UserObject as ToolBase).Settings;
            }
            else
            {
                this.NodeInfo = null;
            }
        }
Пример #7
0
        private static void addReachable(Hashtable collection, IGoNode node)
        {
            if (node == null)
            {
                return;
            }
            var goObject = node.GoObject;

            if (collection.ContainsKey(goObject))
            {
                return;
            }
            collection.Add(goObject, goObject);
            foreach (var goLink in node.DestinationLinks.OfType <RelatedItemLink>())
            {
                var link = goLink.GoObject;
                if (!collection.ContainsKey(link))
                {
                    collection.Add(link, link);
                }
                addReachable(collection, goLink.ToNode);
            }
        }
Пример #8
0
        /// <summary>
        /// Produce a new <see cref="T:Northwoods.Go.GoSelection" /> that is the real set of objects
        /// to be moved by <see cref="M:Northwoods.Go.GoView.MoveSelection(Northwoods.Go.GoSelection,System.Drawing.SizeF,System.Boolean)" /> or copied by
        /// <see cref="M:Northwoods.Go.GoView.CopySelection(Northwoods.Go.GoSelection,System.Drawing.SizeF,System.Boolean)" />.
        /// </summary>
        /// <param name="coll"></param>
        /// <param name="move">true for moving, false for copying</param>
        /// <returns>a <see cref="T:Northwoods.Go.GoSelection" /> that is cached as <see cref="P:Northwoods.Go.GoToolDragging.EffectiveSelection" /></returns>
        /// <remarks>
        /// This method is used to try to avoid problems with double-moving
        /// due to duplicate entries or both a parent and its child being in
        /// the argument collection.
        /// This also removes objects whose <see cref="P:Northwoods.Go.GoObject.DraggingObject" />
        /// is null or has a false value for <see cref="M:Northwoods.Go.GoObject.CanMove" /> (if
        /// <paramref name="move" /> is true) or a false value for <see cref="M:Northwoods.Go.GoObject.CanCopy" />
        /// (if <paramref name="move" /> is false).
        /// Furthermore this adds to the collection all links that have both
        /// ports in the selection.
        /// </remarks>
        public virtual GoSelection ComputeEffectiveSelection(IGoCollection coll, bool move)
        {
            Dictionary <GoObject, bool> dictionary = new Dictionary <GoObject, bool>();
            GoCollection goCollection = null;
            GoSelection  goSelection  = new GoSelection(null);

            foreach (GoObject item in coll)
            {
                GoObject draggingObject = item.DraggingObject;
                if (draggingObject != null && !(move ? (!draggingObject.CanMove()) : (!draggingObject.CanCopy())) && !alreadyDragged(dictionary, draggingObject))
                {
                    dictionary[draggingObject] = true;
                    if (!draggingObject.IsTopLevel)
                    {
                        if (goCollection == null)
                        {
                            goCollection = new GoCollection();
                        }
                        goCollection.Add(draggingObject);
                    }
                    goSelection.Add(draggingObject);
                }
            }
            if (EffectiveSelectionIncludesLinks)
            {
                GoObject[] array = goSelection.CopyArray();
                for (int i = 0; i < array.Length; i++)
                {
                    IGoNode goNode = array[i] as IGoNode;
                    if (goNode != null)
                    {
                        foreach (IGoLink destinationLink in goNode.DestinationLinks)
                        {
                            if (!alreadyDragged(dictionary, destinationLink.GoObject) && (destinationLink.ToPort == null || alreadyDragged(dictionary, destinationLink.ToPort.GoObject)))
                            {
                                dictionary[destinationLink.GoObject] = true;
                                goSelection.Add(destinationLink.GoObject);
                            }
                        }
                        foreach (IGoLink sourceLink in goNode.SourceLinks)
                        {
                            if (!alreadyDragged(dictionary, sourceLink.GoObject) && (sourceLink.FromPort == null || alreadyDragged(dictionary, sourceLink.FromPort.GoObject)))
                            {
                                dictionary[sourceLink.GoObject] = true;
                                goSelection.Add(sourceLink.GoObject);
                            }
                        }
                    }
                }
            }
            if (goCollection != null)
            {
                GoCollection goCollection2 = null;
                foreach (GoObject item2 in goSelection)
                {
                    GoObject draggingObject2 = item2.DraggingObject;
                    if (draggingObject2 is GoGroup)
                    {
                        foreach (GoObject item3 in goCollection)
                        {
                            if (item3.IsChildOf(draggingObject2))
                            {
                                if (goCollection2 == null)
                                {
                                    goCollection2 = new GoCollection();
                                }
                                goCollection2.Add(item3);
                            }
                        }
                    }
                }
                if (goCollection2 != null)
                {
                    foreach (GoObject item4 in goCollection2)
                    {
                        goSelection.Remove(item4);
                    }
                    return(goSelection);
                }
            }
            return(goSelection);
        }
Пример #9
0
        private GoGump(int page, Mobile from, LocationTree tree, ParentNode node) : base(50, 50)
        {
            from.CloseGump <GoGump>();

            tree.LastBranch[from] = node;

            m_Page = page;
            m_Tree = tree;
            m_Node = node;

            int x = BorderSize + OffsetSize;
            int y = BorderSize + OffsetSize;

            int count = node.Children.Length - page * EntryCount;

            if (count < 0)
            {
                count = 0;
            }
            else if (count > EntryCount)
            {
                count = EntryCount;
            }

            int totalHeight = OffsetSize + (EntryHeight + OffsetSize) * (count + 1);

            AddPage(0);

            AddBackground(0, 0, BackWidth, BorderSize + totalHeight + BorderSize, BackGumpID);
            AddImageTiled(BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), totalHeight,
                          OffsetGumpID);

            if (OldStyle)
            {
                AddImageTiled(x, y, TotalWidth - OffsetSize * 3 - SetWidth, EntryHeight, HeaderGumpID);
            }
            else
            {
                AddImageTiled(x, y, PrevWidth, EntryHeight, HeaderGumpID);
            }

            if (node.Parent != null)
            {
                AddButton(x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 1);

                if (PrevLabel)
                {
                    AddLabel(x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous");
                }
            }

            x += PrevWidth + OffsetSize;

            int emptyWidth = TotalWidth - PrevWidth * 2 - NextWidth - OffsetSize * 5 -
                             (OldStyle ? SetWidth + OffsetSize : 0);

            if (!OldStyle)
            {
                AddImageTiled(x - (OldStyle ? OffsetSize : 0), y, emptyWidth + (OldStyle ? OffsetSize * 2 : 0), EntryHeight,
                              EntryGumpID);
            }

            AddHtml(x + TextOffsetX, y, emptyWidth - TextOffsetX, EntryHeight, $"<center>{node.Name}</center>");

            x += emptyWidth + OffsetSize;

            if (OldStyle)
            {
                AddImageTiled(x, y, TotalWidth - OffsetSize * 3 - SetWidth, EntryHeight, HeaderGumpID);
            }
            else
            {
                AddImageTiled(x, y, PrevWidth, EntryHeight, HeaderGumpID);
            }

            if (page > 0)
            {
                AddButton(x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 2);

                if (PrevLabel)
                {
                    AddLabel(x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous");
                }
            }

            x += PrevWidth + OffsetSize;

            if (!OldStyle)
            {
                AddImageTiled(x, y, NextWidth, EntryHeight, HeaderGumpID);
            }

            if ((page + 1) * EntryCount < node.Children.Length)
            {
                AddButton(x + NextOffsetX, y + NextOffsetY, NextButtonID1, NextButtonID2, 3, GumpButtonType.Reply, 1);

                if (NextLabel)
                {
                    AddLabel(x + NextLabelOffsetX, y + NextLabelOffsetY, TextHue, "Next");
                }
            }

            for (int i = 0, index = page * EntryCount; i < EntryCount && index < node.Children.Length; ++i, ++index)
            {
                x  = BorderSize + OffsetSize;
                y += EntryHeight + OffsetSize;

                IGoNode child = node.Children[index];
                string  name  = child.Name;

                AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
                AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, name);

                x += EntryWidth + OffsetSize;

                if (SetGumpID != 0)
                {
                    AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
                }

                AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, index + 4);
            }
        }
Пример #10
0
        protected void DocumentChanged(Object sender, GoChangedEventArgs evt)
        {
            switch (evt.Hint)
            {
            case GoLayer.InsertedObject:
            {
                // added a node to the document--gotta add it to the combobox's list of nodes
                IGoNode n = evt.Object as IGoNode;
                if (n != null && n.UserObject != null)
                {
                    this.NodeCombo.Items.Add(n.UserObject);        //((n.UserObject as ToolBase).ID);
                }
                break;
            }

            case GoLayer.RemovedObject:
            {
                // removed a node from the document--gotta remove from the combobox's list of nodes
                IGoNode n = evt.GoObject as IGoNode;
                if (n != null && this.Grid.SelectedObject == n.UserObject)
                {
                    this.Grid.SelectedObject = null;
                    int i = this.NodeCombo.Items.IndexOf(n.UserObject);
                    if (i >= 0)
                    {
                        this.NodeCombo.Items.RemoveAt(i);
                    }
                }
                break;
            }

            case GoLayer.ChangedObject:
            {
                switch (evt.SubHint)
                {
                case GoObject.ChangedBounds:
                {
                    // because we're displaying the GraphNode's size and position,
                    // we need to update the grid when the bounds change
                    IGoNode n = evt.GoObject as IGoNode;
                    if (n != null && n.UserObject != null &&
                        this.Grid.SelectedObject == n.UserObject)
                    {
                        RedisplayInfo();
                    }
                    break;
                }

                case GoText.ChangedText:
                {
                    // need to update combobox's list of node names
                    IGoNode n = evt.GoObject.ParentNode as IGoNode;
                    if (n != null && n.UserObject != null)
                    {
                        int i = this.NodeCombo.Items.IndexOf(n.UserObject);
                        if (i >= 0)
                        {
                            this.NodeCombo.Items[i] = n.UserObject;                  // reset to update displayed string
                        }
                        RedisplayInfo();
                    }
                    break;
                }
                }
                break;
            }

            case GoDocument.ChangedName:
            {
                // because we're displaying the document name in the grid,
                // we need to keep it up-to-date too
                RedisplayInfo();
                break;
            }
            }
        }