예제 #1
0
        private static void Restore(Dictionary <Part, bool> parts)
        {
            foreach (KeyValuePair <Part, bool> entry in parts)
            {
                Part part      = entry.Key;
                bool recursive = entry.Value;

                HighlightTracker2.Restore(part, recursive);
            }
        }
예제 #2
0
        /// <summary>
        /// Cancels the current tracking operation. The current set and previous set are cleared and all parts are restored to their original states.
        /// </summary>
        public void CancelTracking()
        {
            this.tracking = false;

            // Eliminate duplicates held in previousParts.
            foreach (Part part in this.Parts.Keys)
            {
                this.PreviousParts.Remove(part);
            }

            // Now previousParts and parts have all the parts we need to restore.
            HighlightTracker2.Restore(this.Parts);
            HighlightTracker2.Restore(this.PreviousParts);

            this.Parts.Clear();
            this.PreviousParts.Clear();
        }
예제 #3
0
        /// <summary>
        /// Finalizes the tracking actions. All parts in the current set are activated for highlighting. All parts in the previous set are restored to their original
        /// state. The current set becomes the previous set and the previous set is emptied and recycled to become the next current set.
        /// </summary>
        public void EndTracking()
        {
            if (!tracking)
            {
                throw new GUIControlsException("Highlight tracking must be started before tracking can be completed.");
            }

            if (Event.current.type == EventType.Repaint)
            {
                HighlightTracker2.Restore(this.PreviousParts);

                this.PreviousParts.Clear();

                this.Swap();
            }

            this.tracking = false;
        }
예제 #4
0
        public void Add(Part part, Color color, bool recursive)
        {
            bool tracked = false;

            if (!tracking)
            {
                throw new HighlightTrackerException("Highlight tracking must be started before adding parts to track.");
            }

            if (part == null)
            {
                throw new ArgumentNullException("part");
            }

            if (recursive)
            {
                foreach (Part childPart in part.children)
                {
                    this.Add(childPart, color, recursive);
                }
            }

            if (!this.Parts.ContainsKey(part) && this.PreviousParts.ContainsKey(part))
            {
                tracked = true;
                // This part was previously tracked, so move it to the current set.
                HighlightTracker2.Transfer(part, this.PreviousParts, this.Parts);
            }

            if (!this.Parts.ContainsKey(part) && !this.PreviousParts.ContainsKey(part))
            {
                // This part wasn't previously tracked by this instance. Look for it in the master set and move it to the current set if found.

                bool found = false;

                foreach (var globalParts in HighlightTracker2.instanceParts)
                {
                    if (globalParts.Key != this.instance)
                    {
                        if (globalParts.Value.Left.ContainsKey(part))
                        {
                            HighlightTracker2.Transfer(part, globalParts.Value.Left, this.Parts);

                            found = true;

                            break;
                        }
                        else if (globalParts.Value.Right.ContainsKey(part))
                        {
                            HighlightTracker2.Transfer(part, globalParts.Value.Right, this.Parts);

                            found = true;

                            break;
                        }
                    }
                }

                // The part wasn't found, add it to the current set.
                if (!found)
                {
                    this.Parts.Add(part, recursive);
                }
            }

            // The part should be in the current set by this point.
            Log.Assert(this.Parts.ContainsKey(part));
            if (!tracked)
            {
                HighlightTracker2.Modify(part, color, recursive);
            }
        }