public void AddToGroup(string path, BaseTaskbarButton button) { path = path.ToLower().Trim(); // get or create new group for this application ProcessGroup group; if (!_groups.TryGetValue(path, out group)) { group = new ProcessGroup(); _groups.Add(path, group); } if (group.Count == 0) { // if only item in this group, add it to the end of the taskbar group.Add(button); _flow.Controls.SetChildIndex(button, _flow.Controls.Count); } else { int index = group.GetFirstIndex(_flow.Controls); group.Add(button); group.Arrange(_flow.Controls, index); TaskbarPinnedButton pinnedButton = group.GetPinnedButton(); if (pinnedButton != null) { pinnedButton.Visible = false; } } }
private void processMenu_Opening(object sender, CancelEventArgs e) { if (tooltipManager.ToolTipWindow.Visible) { tooltipManager.ToolTipWindow.ForceHide(); } ContextMenuStrip menu = sender as ContextMenuStrip; BaseTaskbarButton baseButton = menu.SourceControl as BaseTaskbarButton; baseButton.Hover = true; if (menu.SourceControl is TaskbarButton) { TaskbarButton button = menu.SourceControl as TaskbarButton; SecondDisplayProcess proc = button.Tag as SecondDisplayProcess; tsmiLaunch.Image = proc.SmallIcon.ConvertToBitmap(false); Process p = ProcessUtil.GetProcessByWindowHandle(proc.Handle); ProcessModule module = p.MainModule; if (module != null) { string fileDescription = System.Diagnostics.FileVersionInfo.GetVersionInfo(module.FileName).FileDescription; tsmiLaunch.Text = string.IsNullOrEmpty(fileDescription) ? (module.FileName ?? p.MainWindowTitle) : fileDescription.Clamp(Constants.MaxProgramNameLength); tsmiLaunch.Tag = new ProcessFullPath { FileName = module.FileName, Arguments = ProcessUtil.GetCommandLineArguments(module.ModuleName) }; tsmiLaunch.Visible = true; if (PinnedManager.Instance.IsPinned(p)) { tsmiPin.Visible = false; tsmiUnpin.Visible = true; } else { tsmiPin.Visible = true; tsmiUnpin.Visible = false; } } else { tsmiLaunch.Visible = false; tsmiPin.Visible = false; tsmiUnpin.Visible = false; } tsmiCloseWindow.Visible = true; } else { TaskbarPinnedButton pinnedButton = menu.SourceControl as TaskbarPinnedButton; PinnedApp app = pinnedButton.Tag as PinnedApp; tsmiCloseWindow.Visible = false; tsmiLaunch.Image = app.Icon.ResizeBitmap(ButtonConstants.SmallIconSize, ButtonConstants.SmallIconSize); tsmiLaunch.Text = string.IsNullOrEmpty(app.Name) ? "Unknown application" : app.Name.Clamp(Constants.MaxProgramNameLength); tsmiLaunch.Tag = new ProcessFullPath { FileName = app.Path, Arguments = app.Arguments }; tsmiLaunch.Visible = !string.IsNullOrEmpty(app.Path); if (PinnedManager.Instance.IsPinned(app)) { tsmiPin.Visible = false; tsmiUnpin.Visible = true; } else { tsmiPin.Visible = true; tsmiUnpin.Visible = false; } } }