예제 #1
0
            public void Remove(ToolBase uiElement)
            {
                ToolInstance instance = null;

                if (this.toolInstances.TryGetValue(uiElement.Key, out instance))
                {
                    instance.DecrementCount();

                    if (instance.Count == 0)
                    {
                        this.toolInstances.Remove(uiElement.Key);
                    }
                }
            }
예제 #2
0
            public ToolBase Add(ToolBase uiElement, int newToolIndex)
            {
                ToolInstance instance;

                if (this.toolInstances.TryGetValue(uiElement.Key, out instance))
                {
                    instance.IncrementCount();
                }
                else
                {
                    ToolBase tool;

                    if (this.Manager.Tools.Exists(uiElement.Key) == false)
                    {
                        // create a root tool instance
                        this.Manager.Tools.Add(uiElement);
                    }

                    // see if there is an instance of the tool in the collection
                    int index = this.Tools.IndexOf(uiElement.Key);

                    if (index < 0)
                    {
                        // now create an instance of the tool
                        index = newToolIndex;
                        this.Tools.Insert(index, uiElement);
                    }

                    // get the tool
                    tool = this.Tools[index];

                    // then create a toolinstance to manage the count
                    instance = new ToolInstance(tool);
                    this.toolInstances.Add(uiElement.Key, instance);
                }

                return(instance.Tool);
            }