示例#1
0
        public NodeControl CreateNode(ViewModel.Node viewModelNode, SuperGraphControl parentSurface)
        {
            NodeControl nodeControl = null;

            /// TODO: We will need to consider being able to have the same viewModelNode present here twice.
            if (!Nodes.ContainsKey(viewModelNode.Id))
            {
                nodeControl = new NodeControl();
                Canvas.SetZIndex(nodeControl, 50);
                nodeControl.ParentSurface = parentSurface;
                nodeControl.DataContext   = viewModelNode;
                nodeControl.VideoRemoteControl.DataContext = viewModelNode.VideoInfo;
                //nodeControl.NodeCornerControl.DataContext = viewModelNode;
                NodeControlFactorySet set = new NodeControlFactorySet();
                set.Node    = viewModelNode;
                set.Control = nodeControl;

                Nodes.Add(viewModelNode.Id, set);
            }
            else
            {
                nodeControl = Nodes[viewModelNode.Id].Control;
            }

            return(nodeControl);
        }
示例#2
0
        public NodeControlFactorySet RemoveNode(ViewModel.Node viewModelNode)
        {
            if (Nodes.ContainsKey(viewModelNode.Id))
            {
                NodeControlFactorySet removedSet = Nodes[viewModelNode.Id];
                Nodes.Remove(viewModelNode.Id);

                return(removedSet);
            }

            return(null);
        }
示例#3
0
        public IEnumerable <ArrowControlFactorySet> RemoveArrows(ViewModel.Node node)
        {
            List <ArrowControlFactorySet> irrelevantSets = new List <ArrowControlFactorySet>();

            foreach (ArrowControlFactorySet set in Arrows.Values)
            {
                if (set.Relationship.From == node.Id || set.Relationship.To == node.Id)
                {
                    irrelevantSets.Add(set);
                }
            }

            foreach (ArrowControlFactorySet irreleventSet in irrelevantSets)
            {
                Arrows.Remove(irreleventSet.Relationship.Id);
                irreleventSet.Control.UnlinkRelatedNodeControls();
            }

            return(irrelevantSets);
        }
示例#4
0
        void NodeChanged(ViewModel.Node node)
        {
            if (node == null)
            {
                Mode = NodeMode.None;
            }
            else if (!node.Success)
            {
                Mode = NodeMode.Failure;
            }
            else if (String.IsNullOrEmpty(node.Text))
            {
                Mode = NodeMode.Empty;
            }
            else
            {
                Mode = NodeMode.None;
            }

            UpdateText(node, Aspect);
        }
示例#5
0
        void UpdateText(ViewModel.Node node, NodeAspect aspect)
        {
            switch (aspect)
            {
            case NodeAspect.NodeHeader:
                if (node == null)
                {
                    base.Text = "<<null>>";
                }
                else if (node is ViewModel.CaptureNode cn)
                {
                    base.Text = String.Format("c[{0}]:", cn.Index);
                }
                else if (node is ViewModel.GroupNode gn)
                {
                    base.Text = String.Format("g[{0} or \"{1}\"]:", gn.Number, gn.Name);
                }
                else if (node is ViewModel.MatchNode mn)
                {
                    base.Text = String.Format("m[{0}]:", mn.Index);
                }
                else if (node is ViewModel.LineNode ln)
                {
                    base.Text = String.Format("l[{0}]:", ln.Index);
                }
                break;

            case NodeAspect.NodeText:
                if (node == null)
                {
                    base.Text = "<<null>>";
                }
                else if (!node.Success)
                {
                    base.Text = "--- FAILURE ---";
                }
                else if (String.IsNullOrEmpty(node.Text))
                {
                    base.Text = "--- EMPTY ---";
                }
                else
                {
                    base.Text = PrepareNodeText(node.Text);
                }
                break;

            case NodeAspect.TooltipHeader:
                if (node == null)
                {
                    base.Text = "<<null>>";
                }
                else if (node is ViewModel.CaptureNode cn)
                {
                    base.Text = String.Format("group.Captures[{0}]", cn.Index);
                }
                else if (node is ViewModel.GroupNode gn)
                {
                    base.Text = String.Format("match.Groups[{0}] or match.Groups[\"{1}\"]", gn.Number, gn.Name);
                }
                else if (node is ViewModel.MatchNode mn)
                {
                    base.Text = String.Format("matches[{0}]", mn.Index);
                }
                else if (node is ViewModel.LineNode ln)
                {
                    base.Text = String.Format("lines[{0}]", ln.Index);
                }
                break;

            case NodeAspect.TooltipText:
                if (node == null)
                {
                    base.Text = "<<null>>";
                }
                else if (String.IsNullOrEmpty(node.Text))
                {
                    base.Text = "--- EMPTY ---";
                }
                else
                {
                    base.Text = PrepareTooltipText(node.Text);
                }
                break;
            }
        }