示例#1
0
            NodeAttr CreateNodeAttr(string id, bool isSelected)
            {
                NodeTypeEntry nte = Model.GraphEditor.NodeTypes.Last();

                NodeAttr nodeAttr = new NodeAttr();

                nodeAttr.Id    = id;
                nodeAttr.Color = Styles.NODE_LINE_COLOR.ToMsAgl();

                if (Entity.Virtual)
                {
                    nodeAttr.FillColor = Styles.NODE_BGCOLOR_VIRTUAL.ToMsAgl();
                }
                else if (Entity.Abstract)
                {
                    nodeAttr.FillColor = Styles.NODE_BGCOLOR_ABSTRACT.ToMsAgl();
                }
                else
                {
                    nodeAttr.FillColor = Styles.NODE_BGCOLOR_NORMAL.ToMsAgl();
                }

                if (isSelected)
                {
                    nodeAttr.Color = Styles.SELECTED_NODE_LINE_COLOR.ToMsAgl();
                }

                nodeAttr.Shape       = nte.Shape;
                nodeAttr.LabelMargin = 8;
                nodeAttr.LineWidth   = 4;

                return(nodeAttr);
            }
示例#2
0
        /// <summary>
        /// Add a node to the hierarchy.
        /// </summary>
        /// <param name="node">
        /// The node to add to the hierarchy.
        /// </param>
        public void AddNode(ConfigurationNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            if (nodesById.ContainsKey(node.Id))
            {
                return;                                             // we already own this one
            }
            SetUniqueComponentName(node);
            AddSite(node, node.Name);
            node.Hierarchy = this;
            string nodeTypeName = node.GetType().FullName;

            if (!nodesByType.ContainsKey(node.Id))
            {
                nodesByType[node.Id] = new NodeTypeEntryArrayList();
            }
            if (node.Parent != null && nodesByType.ContainsKey(node.Parent.Id))
            {
                NodeTypeEntryArrayList childTypes = nodesByType[node.Parent.Id];
                NodeTypeEntry          entry      = new NodeTypeEntry(node, nodeTypeName);
                if (!childTypes.Contains(entry))
                {
                    childTypes.Add(entry);
                    AddBaseTypes(node, childTypes);
                }
            }
            nodesById[node.Id] = node;
            AddNodeByName(node);
        }
示例#3
0
        /// <summary>
        /// <para>Add a node to the hierarchy.</para>
        /// </summary>
        /// <param name="node">
        /// <para>The node to add to the hierarchy.</para>
        /// </param>
        public void AddNode(ConfigurationNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            node.Hierarchy = this;
            string nodeTypeName = node.GetType().FullName;

            if (!nodesByType.Contains(node.Id))
            {
                nodesByType[node.Id] = new NodeTypeEntryArrayList();
            }
            if (node.Parent != null)
            {
                NodeTypeEntryArrayList childTypes = (NodeTypeEntryArrayList)nodesByType[node.Parent.Id];
                NodeTypeEntry          entry      = new NodeTypeEntry(node, nodeTypeName);
                if (!childTypes.Contains(entry))
                {
                    childTypes.Add(entry);
                    AddBaseTypes(node, childTypes);
                }
            }
            nodesById[node.Id] = node;
            AddToContainer(node);
            SetSiteName(node.Name, node);
            // make sure to add after contanier so the name is set
            AddNodeByName(node);
        }
示例#4
0
        protected override void OnHelpRequested(HelpEventArgs args)
        {
            base.OnHelpRequested(args);
            string keyword;

            if (SelectedPaletteItem != null)
            {
                keyword = SelectedPaletteItem.ClassName;
            }
            else
            {
                if (ActiveControl.Name == "FNodesTree")
                {
                    keyword = FNodesTree.SelectedNode.Node.GetType().Name;
                }
                else
                {
                    keyword = FPropertyGrid.SelectedObject.GetType().Name;
                }
            }
            NodeTypeEntry entry = FrontendSession.NodeTypeTable[keyword];

            if (entry != null)
            {
                keyword = entry.Namespace + "." + keyword;
            }
            Dataphoria.InvokeHelp(keyword);
        }
示例#5
0
        private static void RemoveBaseTypes(ConfigurationNode node, NodeTypeEntryArrayList tableToAddTypes)
        {
            Type searchType = node.GetType().BaseType;

            while (searchType != null)
            {
                NodeTypeEntry entry = new NodeTypeEntry(node, searchType.FullName);
                tableToAddTypes.Remove(entry);
                searchType = searchType.BaseType;
            }
        }
示例#6
0
            public override bool Contains(object item)
            {
                NodeTypeEntry nodeTypeEntry = (NodeTypeEntry)item;

                foreach (NodeTypeEntry entry in this)
                {
                    if (nodeTypeEntry == entry)
                    {
                        return(true);
                    }
                }
                return(false);
            }
示例#7
0
        /// <summary>
        /// Overloaded. Adds a new node type to the list. If the parameter contains an image, a button with that image will be added to the toolbar.
        /// </summary>
        /// <param name="nte">The NodeTypeEntry structure containing the initial aspect of the node, type name, and additional parameters required
        /// for node insertion.</param>
        void AddNodeType(NodeTypeEntry nte)
        {
            m_NodeTypes.Add(nte);

            if (nte.ButtonImage != null)
            {
                ToolBar tb  = ToolBar;
                var     btn = new ToolBarButton();
                tb.ImageList.Images.Add(nte.ButtonImage);
                btn.ImageIndex = tb.ImageList.Images.Count - 1;
                tb.Buttons.Add(btn);
                nte.Button = btn;
            }
        }
示例#8
0
        void InsertNode_Click(object sender, EventArgs e)
        {
            RemoveDraggableEntities();

            NodeTypeEntry selectedNTE = null;

            foreach (NodeTypeEntry nte in NodeTypes)
            {
                if (nte.MenuItem == sender)
                {
                    selectedNTE = nte;
                }
            }

            InsertNode?.Invoke(this, new NodeEventArgs(null, m_MouseRightButtonDownPoint));
        }
示例#9
0
        void insertNode_Click(object sender, EventArgs e)
        {
            NodeTypeEntry selectedNTE = null;

            foreach (NodeTypeEntry nte in m_NodeTypes)
            {
                if (nte.MenuItem == sender)
                {
                    selectedNTE = nte;
                }
            }
            DrawingNode n = InsertNode(m_MouseRightButtonDownPoint, selectedNTE);

            if (NodeInsertedByUser != null)
            {
                NodeInsertedByUser(n);
            }
        }
示例#10
0
        /// <summary>
        /// Inserts a new node at the selected point, with standard attributes, and displays it.
        /// </summary>
        /// <param name="center">The location of the node on the graph</param>
        /// <param name="nte">The NodeTypeEntry structure containing the initial aspect of the node</param>
        /// <param name="id">The id for the node</param>
        /// <returns>The new node</returns>
        internal virtual DrawingNode InsertNode(Point center, NodeTypeEntry nte, string id)
        {
            var node = new DrawingNode(id);

            node.Label.Text      = nte.DefaultLabel;
            node.Attr.FillColor  = nte.FillColor;
            node.Label.FontColor = nte.FontColor;
            node.Label.FontSize  = nte.FontSize;
            node.Attr.Shape      = nte.Shape;
            string s = nte.UserData;

            node.UserData = s;
            IViewerNode dNode = gViewer.CreateIViewerNode(node, center, null);

            gViewer.AddNode(dNode, true);

            return(node);
        }
示例#11
0
        /// <summary>
        /// Remove a node from the hierarchy.
        /// </summary>
        /// <param name="node">
        /// The node to remove.
        /// </param>
        public void RemoveNode(ConfigurationNode node)
        {
            string nodeTypeName = node.GetType().FullName;

            nodesByType.Remove(node.Id);
            if (node.Parent != null)
            {
                NodeTypeEntryArrayList childTypes    = nodesByType[node.Parent.Id];
                NodeTypeEntry          entryToRemove = new NodeTypeEntry(node, nodeTypeName);
                if (childTypes.Contains(entryToRemove))
                {
                    childTypes.Remove(entryToRemove);
                    RemoveBaseTypes(node, childTypes);
                }
            }
            node.Hierarchy = null;
            nodesById.Remove(node.Id);
            RemoveNodeByName(node);
            if (node.Id == rootNode.Id)
            {
                rootNode = null;
            }
        }
示例#12
0
        /// <summary>
        /// <para>Remove a node from the hierarchy.</para>
        /// </summary>
        /// <param name="node">
        /// <para>The node to remove.</para>
        /// </param>
        public void RemoveNode(ConfigurationNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            string nodeTypeName = node.GetType().FullName;

            nodesByType.Remove(node.Id);
            if (node.Parent != null)
            {
                NodeTypeEntryArrayList childTypes    = (NodeTypeEntryArrayList)nodesByType[node.Parent.Id];
                NodeTypeEntry          entryToRemove = new NodeTypeEntry(node, nodeTypeName);
                if (childTypes.Contains(entryToRemove))
                {
                    childTypes.Remove(entryToRemove);
                    RemoveBaseTypes(node, childTypes);
                }
            }
            node.Hierarchy = null;
            nodesById.Remove(node.Id);
            RemoveNodeByName(node);
            RemoveFromContainer(node);
        }
示例#13
0
 /// <summary>
 /// Inserts a new node at the selected point, with standard attributes, and displays it.
 /// </summary>
 /// <param name="center">The location of the node on the graph</param>
 /// <param name="nte">The NodeTypeEntry structure containing the initial aspect of the node</param>
 /// <returns>The new node</returns>
 internal virtual DrawingNode InsertNode(Point center, NodeTypeEntry nte)
 {
     return(InsertNode(center, nte, GetNewId()));
 }
示例#14
0
        /// <summary>
        /// New Filters to offer, based on Results
        /// </summary>
        public JArray FilterOptions(ICswNbtTree Tree)
        {
            JArray FiltersArr = new JArray();

            Tree.goToRoot();
            bool SingleNodeType = IsSingleNodeType();

            if (false == SingleNodeType)
            {
                // Filter on NodeTypes only
                SortedList <string, NodeTypeEntry> NodeTypeOptions = new SortedList <string, NodeTypeEntry>();
                Int32 ChildCnt = Tree.getChildNodeCount();
                for (Int32 n = 0; n < ChildCnt; n++)
                {
                    Tree.goToNthChild(n);
                    CswNbtNodeKey NodeKey = Tree.getNodeKeyForCurrentPosition();
                    if (NodeKey != null)
                    {
                        CswNbtMetaDataNodeType NodeType = _CswNbtResources.MetaData.getNodeType(NodeKey.NodeTypeId);
                        string LatestName = NodeType.getNodeTypeLatestVersion().NodeTypeName;
                        if (false == NodeTypeOptions.ContainsKey(LatestName))
                        {
                            NodeTypeOptions.Add(LatestName, new NodeTypeEntry
                            {
                                NodeType   = NodeType,
                                NodeTypeId = NodeType.NodeTypeId,
                                LatestName = LatestName,
                                Count      = 0
                            });
                        }
                        NodeTypeOptions[LatestName].Count += 1;
                    }
                    Tree.goToParentNode();
                } // for( Int32 n = 0; n < ChildCnt; n++ )

                if (NodeTypeOptions.Keys.Count == 1)
                {
                    if (false == IsSingleNodeType())
                    {
                        // If we have uniform results but no nodetype filter applied
                        // add the filter to the filters list for display
                        NodeTypeEntry      entry          = NodeTypeOptions.Values[0];
                        CswNbtSearchFilter NodeTypeFilter = makeFilter(entry.NodeType, entry.Count, false, CswEnumNbtSearchPropOrderSourceType.Unknown);
                        addFilter(NodeTypeFilter);
                    }
                    SingleNodeType = true;
                }
                else
                {
                    JArray FilterSet = new JArray();
                    FiltersArr.Add(FilterSet);

                    foreach (NodeTypeEntry entry in NodeTypeOptions.Values)
                    {
                        CswNbtSearchFilter NodeTypeFilter = makeFilter(entry.NodeType, entry.Count, true, CswEnumNbtSearchPropOrderSourceType.Unknown);
                        FilterSet.Add(NodeTypeFilter.ToJObject());
                    }
                }
            } // if( false == SingleNodeType )

            if (SingleNodeType)
            {
                // Filter on property values in the results
                Collection <Int32> FilteredPropIds = getFilteredPropIds();
                Dictionary <Int32, Dictionary <string, Int32> > PropCounts = new Dictionary <Int32, Dictionary <string, Int32> >();
                SortedSet <CswNbtSearchPropOrder.SearchOrder>   PropOrder  = new SortedSet <CswNbtSearchPropOrder.SearchOrder>();
                Int32 ChildCnt = Tree.getChildNodeCount();
                for (Int32 n = 0; n < ChildCnt; n++)
                {
                    Tree.goToNthChild(n);

                    if (0 == PropOrder.Count)
                    {
                        PropOrder = _CswNbtSearchPropOrder.getPropOrderDict(Tree.getNodeKeyForCurrentPosition());
                    }
                    Collection <CswNbtTreeNodeProp> Props = Tree.getChildNodePropsOfNode();
                    foreach (CswNbtTreeNodeProp Prop in Props)
                    {
                        CswNbtMetaDataFieldType FieldType = _CswNbtResources.MetaData.getFieldType(Prop.FieldType);
                        if (false == FilteredPropIds.Contains(Prop.NodeTypePropId) && FieldType.Searchable)
                        {
                            string Gestalt = Prop.Gestalt;
                            if (Gestalt.Length > 50)
                            {
                                Gestalt = Gestalt.Substring(0, 50);
                            }

                            if (false == PropCounts.ContainsKey(Prop.NodeTypePropId))
                            {
                                PropCounts[Prop.NodeTypePropId] = new Dictionary <string, Int32>();
                            }
                            if (false == PropCounts[Prop.NodeTypePropId].ContainsKey(Gestalt))
                            {
                                PropCounts[Prop.NodeTypePropId][Gestalt] = 0;
                            }
                            PropCounts[Prop.NodeTypePropId][Gestalt] += 1;
                        }
                    }

                    Tree.goToParentNode();
                } // for( Int32 n = 0; n < ChildCnt; n++ )

                foreach (Int32 NodeTypePropId in PropCounts.Keys.OrderBy(NodeTypePropId => PropOrder.First(Order => Order.NodeTypePropId == NodeTypePropId).Order))
                {
                    CswNbtMetaDataNodeTypeProp NodeTypeProp = _CswNbtResources.MetaData.getNodeTypePropLatestVersion(NodeTypePropId);
                    if (false == NodeTypeProp.IsUnique())    // case 27649
                    {
                        CswNbtSearchPropOrder.SearchOrder order = PropOrder.First(Order => Order.NodeTypePropId == NodeTypePropId);

                        JArray FilterSet = new JArray();
                        FiltersArr.Add(FilterSet);

                        // Sort by count descending, then alphabetically by gestalt
                        Dictionary <string, Int32> sortedDict = (from entry
                                                                 in PropCounts[NodeTypePropId]
                                                                 orderby entry.Value descending, entry.Key ascending
                                                                 select entry
                                                                 ).ToDictionary(pair => pair.Key, pair => pair.Value);
                        foreach (string Value in sortedDict.Keys)
                        {
                            Int32 Count = sortedDict[Value];
                            CswNbtSearchFilter Filter = makeFilter(NodeTypeProp, Value, Count, true, order.Source);
                            FilterSet.Add(Filter.ToJObject());
                        }
                    } // if( false == NodeTypeProp.IsUnique() )
                }     // foreach( Int32 NodeTypePropId in PropCounts.Keys.OrderBy( NodeTypePropId => PropOrder.First( Order => Order.NodeTypePropId == NodeTypePropId ).Order ) )
            }         // if( SingleNodeType )

            return(FiltersArr);
        } // FilterOptions()
示例#15
0
            public override bool Equals(object obj)
            {
                NodeTypeEntry entry = (NodeTypeEntry)obj;

                return(node.Id == entry.node.Id && typeName == entry.typeName);
            }
示例#16
0
 internal void AddNodeType(NodeTypeEntry nte)
 {
     NodeTypes.Add(nte);
 }
示例#17
0
        /// <summary>
        /// Add a node to the hierarchy.
        /// </summary>
        /// <param name="node">
        /// The node to add to the hierarchy.
        /// </param>
        public void AddNode(ConfigurationNode node)
        {
            if (node == null) throw new ArgumentNullException("node");
            if (nodesById.ContainsKey(node.Id)) return; // we already own this one

            SetUniqueComponentName(node);
            AddSite(node, node.Name);
            node.Hierarchy = this;
            string nodeTypeName = node.GetType().FullName;
            if (!nodesByType.ContainsKey(node.Id))
            {
                nodesByType[node.Id] = new NodeTypeEntryArrayList();
            }
            if (node.Parent != null && nodesByType.ContainsKey(node.Parent.Id))
            {
                NodeTypeEntryArrayList childTypes = nodesByType[node.Parent.Id];
                NodeTypeEntry entry = new NodeTypeEntry(node, nodeTypeName);
                if (!childTypes.Contains(entry))
                {
                    childTypes.Add(entry);
                    AddBaseTypes(node, childTypes);
                }
            }
            nodesById[node.Id] = node;
            AddNodeByName(node);
        }
示例#18
0
 /// <summary>
 /// Remove a node from the hierarchy.
 /// </summary>
 /// <param name="node">
 /// The node to remove.
 /// </param>
 public void RemoveNode(ConfigurationNode node)
 {
     string nodeTypeName = node.GetType().FullName;
     nodesByType.Remove(node.Id);
     if (node.Parent != null)
     {
         NodeTypeEntryArrayList childTypes = nodesByType[node.Parent.Id];
         NodeTypeEntry entryToRemove = new NodeTypeEntry(node, nodeTypeName);
         if (childTypes.Contains(entryToRemove))
         {
             childTypes.Remove(entryToRemove);
             RemoveBaseTypes(node, childTypes);
         }
     }
     node.Hierarchy = null;
     nodesById.Remove(node.Id);
     RemoveNodeByName(node);
     if (node.Id == rootNode.Id) rootNode = null;
 }
示例#19
0
 /// <summary>
 /// <para>Remove a node from the hierarchy.</para>
 /// </summary>
 /// <param name="node">
 /// <para>The node to remove.</para>
 /// </param>
 public void RemoveNode(ConfigurationNode node)
 {
     if (node == null)
     {
         throw new ArgumentNullException("node");
     }
     string nodeTypeName = node.GetType().FullName;
     nodesByType.Remove(node.Id);
     if (node.Parent != null)
     {
         NodeTypeEntryArrayList childTypes = (NodeTypeEntryArrayList)nodesByType[node.Parent.Id];
         NodeTypeEntry entryToRemove = new NodeTypeEntry(node, nodeTypeName);
         if (childTypes.Contains(entryToRemove))
         {
             childTypes.Remove(entryToRemove);
             RemoveBaseTypes(node, childTypes);
         }
     }
     node.Hierarchy = null;
     nodesById.Remove(node.Id);
     RemoveNodeByName(node);
     RemoveFromContainer(node);
 }
示例#20
0
 private static void RemoveBaseTypes(ConfigurationNode node, NodeTypeEntryArrayList tableToAddTypes)
 {
     Type searchType = node.GetType().BaseType;
     while (searchType != null)
     {
         NodeTypeEntry entry = new NodeTypeEntry(node, searchType.FullName);
         tableToAddTypes.Remove(entry);
         searchType = searchType.BaseType;
     }
 }
示例#21
0
        /// <summary>
        /// Inserts a new node at the selected point, with standard attributes, and displays it.
        /// </summary>
        /// <param name="center">The location of the node on the graph</param>
        /// <param name="nte">The NodeTypeEntry structure containing the initial aspect of the node</param>
        /// <param name="id">The id for the node</param>
        /// <returns>The new node</returns>
        internal virtual DrawingNode InsertNode(Point center, NodeTypeEntry nte, string id)
        {
            var node = new DrawingNode(id);
            node.Label.Text = nte.DefaultLabel;
            node.Attr.FillColor = nte.FillColor;
            node.Label.FontColor = nte.FontColor;
            node.Label.FontSize = nte.FontSize;
            node.Attr.Shape = nte.Shape;
            string s = nte.UserData;
            node.UserData = s;
            IViewerNode dNode = gViewer.CreateIViewerNode(node,center,null);
            gViewer.AddNode(dNode, true);

            return node;
        }
示例#22
0
 /// <summary>
 /// Inserts a new node at the selected point, with standard attributes, and displays it.
 /// </summary>
 /// <param name="center">The location of the node on the graph</param>
 /// <param name="nte">The NodeTypeEntry structure containing the initial aspect of the node</param>
 /// <returns>The new node</returns>
 internal virtual DrawingNode InsertNode(Point center, NodeTypeEntry nte)
 {
     return InsertNode(center, nte, GetNewId());
 }
示例#23
0
        /// <summary>
        /// Overloaded. Adds a new node type to the list. If the parameter contains an image, a button with that image will be added to the toolbar.
        /// </summary>
        /// <param name="nte">The NodeTypeEntry structure containing the initial aspect of the node, type name, and additional parameters required
        /// for node insertion.</param>
        void AddNodeType(NodeTypeEntry nte) {
            m_NodeTypes.Add(nte);

            if (nte.ButtonImage != null) {
                ToolBar tb = ToolBar;
                var btn = new ToolBarButton();
                tb.ImageList.Images.Add(nte.ButtonImage);
                btn.ImageIndex = tb.ImageList.Images.Count - 1;
                tb.Buttons.Add(btn);
                nte.Button = btn;
            }
        }
示例#24
0
 /// <summary>
 /// <para>Add a node to the hierarchy.</para>
 /// </summary>
 /// <param name="node">
 /// <para>The node to add to the hierarchy.</para>
 /// </param>
 public void AddNode(ConfigurationNode node)
 {
     if (node == null)
     {
         throw new ArgumentNullException("node");
     }
     node.Hierarchy = this;
     string nodeTypeName = node.GetType().FullName;
     if (!nodesByType.Contains(node.Id))
     {
         nodesByType[node.Id] = new NodeTypeEntryArrayList();
     }
     if (node.Parent != null)
     {
         NodeTypeEntryArrayList childTypes = (NodeTypeEntryArrayList)nodesByType[node.Parent.Id];
         NodeTypeEntry entry = new NodeTypeEntry(node, nodeTypeName);
         if (!childTypes.Contains(entry))
         {
             childTypes.Add(entry);
             AddBaseTypes(node, childTypes);
         }
     }
     nodesById[node.Id] = node;
     AddToContainer(node);
     SetSiteName(node.Name, node);
     // make sure to add after contanier so the name is set
     AddNodeByName(node);
 }