Exemple #1
0
        Color GetNodeForeColor(VisualNodeInfo nodeInfo)
        {
            switch (nodeInfo.State)
            {
            case VisualNodeInfo.EState.Added:
                return(nodeInfo.IsDummy ? DummyAddedForeColor : NodeAddedForeColor);

            case VisualNodeInfo.EState.Removed:
                return(nodeInfo.IsDummy ? DummyRemovedForeColor : NodeRemovedForeColor);

            case VisualNodeInfo.EState.Downgraded:
                return(NodeDowngradedForeColor);

            case VisualNodeInfo.EState.Upgraded:
                return(DummyUpgradedForeColor);

            case VisualNodeInfo.EState.Saved:
                return(nodeInfo.IsDummy ? DummyDefaultForeColor : NodeDefaultForeColor);
            }
            return(NodeDefaultForeColor);
        }
Exemple #2
0
        private void NodeContextMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            // the targeted node should already exist in our tree and be selected
            if (SelectedNode == null)
            {
                return;
            }

            VisualNode node = SelectedNode;

            switch (e.ClickedItem.Tag.ToString().ToUpperInvariant())
            {
            case "INCLUDE":
                VisualNodeInfo info = (VisualNodeInfo)node.Tag;
                QueueAddNode(info.MaxNode);
                break;

            case "EXCLUDE":
                QueueRemoveNode(node);
                break;
            }
        }
        void SetNodeState_ToAdd(VisualNode visualNode, bool setNonDummy = true)
        {
            VisualNodeInfo nodeInfo = (VisualNodeInfo)visualNode.Tag;

            if (setNonDummy)
            {
                nodeInfo.IsDummy = false;
            }

            if (previousAppliedHandles.TryGetValue(nodeInfo.MaxNode.Handle, out bool wasDummy))
            {
                if (wasDummy)
                {
                    nodeInfo.State = nodeInfo.IsDummy ? VisualNodeInfo.EState.Saved : VisualNodeInfo.EState.Upgraded;
                }
                else
                {
                    nodeInfo.State = nodeInfo.IsDummy ? VisualNodeInfo.EState.Downgraded : VisualNodeInfo.EState.Saved;
                }
            }
            else
            {
                nodeInfo.State = VisualNodeInfo.EState.Added;
            }

            if (!nodeInfo.IsDummy)
            {
                visualNode.EnsureVisible();
            }

            visualNode.ForeColor = GetNodeForeColor(nodeInfo);
            visualNode.BackColor = GetNodeBackColor(nodeInfo);

            // deselect so the user sees something happened to the node
            if (SelectedNode == visualNode)
            {
                SelectedNode = null;
            }
        }
Exemple #4
0
        public bool ApplyQueuedChanges(out List <uint> nodeHandles, bool doBeginUpdate = true)
        {
            nodeHandles = null;

            if (!changed)
            {
                return(false);
            }

            changed = false;

            if (doBeginUpdate)
            {
                BeginUpdate();
            }
            ApplyQueuedChangesRecursively(Nodes);
            if (doBeginUpdate)
            {
                EndUpdate();
            }

            // - get all non-dummy handles to return
            // - save all handles from the 'applied changes'
            previousAppliedHandles.Clear();
            nodeHandles = new List <uint>();
            foreach (KeyValuePair <uint, VisualNode> pair in visualNodeMap)
            {
                VisualNodeInfo info = pair.Value.Tag as VisualNodeInfo;
                previousAppliedHandles.Add(pair.Key, info.IsDummy);

                if (!info.IsDummy)
                {
                    nodeHandles.Add(pair.Key);
                }
            }

            return(true);
        }
Exemple #5
0
        void SetNodeState_ToRemove(VisualNode visualNode, bool keepAsDummy)
        {
            VisualNodeInfo nodeInfo = (VisualNodeInfo)visualNode.Tag;

            if (keepAsDummy)
            {
                nodeInfo.IsDummy = true;
                if (previousAppliedHandles.TryGetValue(nodeInfo.MaxNode.Handle, out bool wasDummy))
                {
                    nodeInfo.State = wasDummy ? VisualNodeInfo.EState.Saved : VisualNodeInfo.EState.Downgraded;
                }
                else
                {
                    nodeInfo.State = VisualNodeInfo.EState.Added;
                }
            }
            else
            {
                nodeInfo.State = VisualNodeInfo.EState.Removed;
            }

            visualNode.ForeColor = GetNodeForeColor(nodeInfo);
            visualNode.BackColor = GetNodeBackColor(nodeInfo);
        }