//call this in Form1 if you wish for your tool to appear in taskbar: taskbar.AddTool(Form X, imageList1.Images[Y]); //X is the form you're currently calling, example "px" for property manager //Y is the image to use for taskbar icon. public static void AddTool(Form original, Image symbol, bool startPoppedOut = false, Window wpfWindow = null) { original.MdiParent = mdiParent; original.WindowState = FormWindowState.Maximized; original.Show(); //creating the button TaskbarToolButton tool_button = new TaskbarToolButton(); tool_button.Image = symbol; tool_button.Tag = id_counter.ToString(); tool_button.Click += new EventHandler(tipek_onclick); if (wpfWindow != null) { tool_button.Text = wpfWindow.Title; tool_button.ContextMenu = new ContextMenu(new MenuItem[] { new MenuItem("This tool cannot be docked.") }); tool_button.ContextMenu.MenuItems[0].Enabled = false; } else { tool_button.Text = original.Text; tool_button.ContextMenu = new ContextMenu(new MenuItem[] { new MenuItem("Undock tool"), new MenuItem("Dock tool") }); tool_button.ContextMenu.MenuItems[0].Click += HandleDockEvent; tool_button.ContextMenu.MenuItems[1].Click += HandleDockEvent; tool_button.ContextMenu.MenuItems[1].Enabled = startPoppedOut; tool_button.ContextMenu.MenuItems[0].Enabled = !startPoppedOut; } tool_button.ContextMenu.Tag = tool_button.Tag; strip.ImageScalingSize = new System.Drawing.Size(64, 64); //adding to toolstrip strip.Items.Add(tool_button); //creating new structure entry task_list add = new task_list(); add.icon = tool_button; add.tool = original; add.ID = id_counter; add.poppedOut = startPoppedOut; add.button = tool_button; add.wpfWindow = wpfWindow; tools.Add(add); //counter, you be here here. id_counter++; }
//call this in Form1 if you wish for your tool to appear in taskbar: taskbar.AddTool(Form X, imageList1.Images[Y]); //X is the form you're currently calling, example "px" for property manager //Y is the image to use for taskbar icon. public static void AddTool(Form original, Image symbol, bool startPoppedOut = false, Window wpfWindow = null) { //creating the button TaskbarToolButton tool_button = new TaskbarToolButton(); tool_button.Image = symbol; tool_button.Tag = id_counter.ToString(); tool_button.Click += new EventHandler(tipek_onclick); //I can haz event handler? No? ORLY?! if (wpfWindow != null) { tool_button.Text = wpfWindow.Title; tool_button.ContextMenu = new ContextMenu(new MenuItem[] { new MenuItem("This tool cannot be docked.") }); tool_button.ContextMenu.MenuItems[0].Enabled = false; } else { tool_button.Text = original.Text; tool_button.ContextMenu = new ContextMenu(new MenuItem[] { new MenuItem("Undock tool"), new MenuItem("Dock tool") }); tool_button.ContextMenu.MenuItems[0].Click += HandleDockEvent; tool_button.ContextMenu.MenuItems[1].Click += HandleDockEvent; tool_button.ContextMenu.MenuItems[1].Enabled = startPoppedOut; tool_button.ContextMenu.MenuItems[0].Enabled = !startPoppedOut; } tool_button.ContextMenu.Tag = tool_button.Tag; strip.ImageScalingSize = new System.Drawing.Size(64, 64); //adding to toolstrip strip.Items.Add(tool_button); //creating new structure entry task_list add = new task_list(); add.icon = tool_button; add.tool = original; add.ID = id_counter; add.poppedOut = startPoppedOut; add.button = tool_button; add.wpfWindow = wpfWindow; tools.Add(add); //counter, you be here here. id_counter++; }