Exemplo n.º 1
0
 private void SelectTool(ToolboxTool tool)
 {
     if (selectedTab != null)
     {
         selectedTab.SelectTool(tool);
     }
 }
Exemplo n.º 2
0
        public void SetSelectedToolboxItem(ToolboxItem toolboxItem)
        {
            ToolboxTool tool = toolboxItem as ToolboxTool;

            if (tool != null)
            {
                SelectTool(tool);
            }
        }
Exemplo n.º 3
0
        public void SelectTool(ToolboxTool tool)
        {
            if (tool == null)
            {
                return;
            }

            if (tools.ContainsKey(tool))
            {
                ToolboxButton button = tools[tool];
                button.PerformClick();
            }
        }
Exemplo n.º 4
0
        private void OnItemAdded(ToolStripItem item)
        {
            ToolboxButton toolboxButton = null;

            if (!(item is ToolboxButton))
            {
                // We deny addition of non ToolboxButton buttons
                toolStrip.Items.Remove(item);
                return;
            }
            else
            {
                toolboxButton = (ToolboxButton)item;
            }

            ToolboxTool tool = toolboxButton.Tool;

            if (tool == null)
            {
                toolStrip.Items.Remove(item);
            }
            else if (tool is ToolboxPointer)
            {
                // We allow only one pointer per tab
                if (pointersCount > 1)
                {
                    toolStrip.Items.Remove(item);
                }
                else
                {
                    tools.Add(tool, toolboxButton);
                    pointersCount++;
                }
            }
            else if (tool is ToolboxTool)
            {
                if (!tools.ContainsKey(tool))
                {
                    tools.Add(tool, toolboxButton);
                }
            }
            else
            {
                toolStrip.Items.Remove(item);
            }
        }
Exemplo n.º 5
0
        public void AddTool(ToolboxTool tool, bool dragEnabled)
        {
            refreshLayout = false;
            ToolboxButton toolStripButton = new ToolboxButton();

            toolStripButton.Tool               = tool;
            toolStripButton.DragEnabled        = dragEnabled;
            toolStripButton.Text               = tool.DisplayName;
            toolStripButton.Image              = tool.Bitmap;
            toolStripButton.TextAlign          = System.Drawing.ContentAlignment.MiddleLeft;
            toolStripButton.ImageAlign         = System.Drawing.ContentAlignment.MiddleLeft;
            toolStripButton.Alignment          = ToolStripItemAlignment.Left;
            toolStripButton.DoubleClickEnabled = true;
            toolStripButton.Click             += new EventHandler(OnButtonClick);
            toolStripButton.DoubleClick       += new EventHandler(OnButtonDoubleClick);

            toolStrip.Items.Add(toolStripButton);
            refreshLayout = true;
        }
Exemplo n.º 6
0
        private void OnItemRemoved(ToolStripItem item)
        {
            ToolboxButton toolboxButton = null;

            if (!(item is ToolboxButton))
            {
                return;
            }
            else
            {
                toolboxButton = (ToolboxButton)item;
            }

            ToolboxTool tool = toolboxButton.Tool;

            if (tool == null)
            {
            }                     // It's ok, the item is removed
            else if (tool is ToolboxPointer)
            {
                // We don't allow the removal of the pointer tool
                if (pointersCount > 1)
                {
                    toolStrip.Items.Remove(item);
                    pointersCount--;
                }
                else
                {
                    AddPointer();
                }
            }
            else if (tool is ToolboxTool)
            {
                if (tools.ContainsKey(tool))
                {
                    tools.Remove(tool);
                }
            }
            else
            {
            }        // It's ok, the item is removed
        }
Exemplo n.º 7
0
        public ToolboxItem GetSelectedToolboxItem(IDesignerHost host)
        {
            ToolboxButton button = SelectedButton;

            if (button != null)
            {
                ToolboxTool tool = button.Tool;
                if (tool is ToolboxPointer)
                {
                    return(null);
                }
                else
                {
                    return(tool);
                }
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 8
0
        public ToolboxItem DeserializeToolboxItem(object serializedObject, IDesignerHost host)
        {
            DataObject dataObject = serializedObject as DataObject;

            if (dataObject == null)
            {
                return(null);
            }

            ToolboxTool tool = dataObject.GetData(typeof(ToolboxTool)) as ToolboxTool;

            if (tool == null)
            {
                ToolboxItem item = dataObject.GetData(typeof(ToolboxItem)) as ToolboxItem;
                return(item);
            }
            else
            {
                return(tool);
            }
        }
Exemplo n.º 9
0
 public void AddTool(ToolboxTool tool)
 {
     AddTool(tool, true);
 }
Exemplo n.º 10
0
 private void SelectTool(ToolboxTool tool) { if (selectedTab != null) selectedTab.SelectTool(tool); }
Exemplo n.º 11
0
 public void AddTool(ToolboxTool tool, bool dragEnabled)
 {
     refreshLayout = false;
     ToolboxButton toolStripButton = new ToolboxButton();
     toolStripButton.Tool = tool;
     toolStripButton.DragEnabled = dragEnabled;
     toolStripButton.Text = tool.DisplayName;
     toolStripButton.Image = tool.Bitmap;
     toolStripButton.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
     toolStripButton.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
     toolStripButton.Alignment = ToolStripItemAlignment.Left;
     toolStripButton.DoubleClickEnabled = true;
     toolStripButton.Click += new EventHandler(OnButtonClick);
     toolStripButton.DoubleClick += new EventHandler(OnButtonDoubleClick);
     
     toolStrip.Items.Add(toolStripButton);            
     refreshLayout = true;
 }
Exemplo n.º 12
0
 public void AddTool(ToolboxTool tool) { AddTool(tool, true); }
Exemplo n.º 13
0
        public void SelectTool(ToolboxTool tool)
        {
            if (tool == null) return;

            if (tools.ContainsKey(tool))
            {
                ToolboxButton button = tools[tool];
                button.PerformClick();
            }
        }