예제 #1
0
        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;
                }
            }
        }
예제 #2
0
        public void RemoveFromGroup(string path, BaseTaskbarButton button)
        {
            path = path.ToLower().Trim();

            List <BaseTaskbarButton> list = GetButtonsByPath(path);

            list.Remove(button);

            if (list.Count == 1)
            {
                if (list[0] is TaskbarPinnedButton)
                {
                    list[0].Visible = true;
                }
            }
        }
예제 #3
0
        void processMenu_Opened(object sender, System.EventArgs e)
        {
            ContextMenuStrip  menu   = sender as ContextMenuStrip;
            BaseTaskbarButton button = menu.SourceControl as BaseTaskbarButton;

            if (button == null)
            {
                return;
            }

            var taskbarLocation = this.TaskbarLocation;

            if (taskbarLocation == Native.ABEdge.Top ||
                taskbarLocation == Native.ABEdge.Bottom)
            {
                menu.Left = flowPanel.PointToScreen(new Point(button.Left + (button.Width - menu.Width) / 2, 0)).X;
                if (taskbarLocation == Native.ABEdge.Bottom)
                {
                    menu.Top = this.Location.Y - menu.Height;
                }
                else
                {
                    menu.Top = this.Bounds.Bottom;
                }
            }
            else
            {
                menu.Top = Math.Max(CurrentScreen.Bounds.Top, flowPanel.PointToScreen(new Point(0, button.Bottom)).Y - menu.Height);

                if (taskbarLocation == Native.ABEdge.Left)
                {
                    menu.Left = this.Bounds.Right;
                }
                else
                {
                    menu.Left = this.Bounds.Left - menu.Width;
                }
            }
        }
예제 #4
0
        private void processMenu_Closed(object sender, ToolStripDropDownClosedEventArgs e)
        {
            BaseTaskbarButton button = (sender as ContextMenuStrip).SourceControl as BaseTaskbarButton;

            button.Hover = false;
        }
예제 #5
0
        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;
                }
            }
        }
예제 #6
0
        public bool MoveButtonToPoint(Point clientCoords, BaseTaskbarButton button)
        {
            var moved        = false;
            var draggedGroup = _groups.Values.FirstOrDefault(item => item.Contains(button));

            if (draggedGroup == null)
            {
                return(false);
            }

            foreach (var path in _groups.Keys)
            {
                var group = _groups[path];

                if (group == draggedGroup || group.Count == 0)
                {
                    continue;
                }

                var bounds = group.GetBounds();
                var index  = -1;

                var taskbarLocation = _flow.MainForm.TaskbarLocation;

                if (taskbarLocation == Win32.Native.ABEdge.Top ||
                    taskbarLocation == Win32.Native.ABEdge.Bottom)
                {
                    int middle = bounds.Left + bounds.Width / 2;

                    if (clientCoords.X <= middle - 10 && clientCoords.X >= bounds.Left)
                    {
                        index = group.GetFirstIndex(_flow.Controls);
                    }
                    else if (clientCoords.X >= middle + 10 && clientCoords.X <= bounds.Right)
                    {
                        index = group.GetLastIndex(_flow.Controls) + 1;
                    }
                    else
                    {
                        continue;
                    }
                }
                else
                {
                    int middle = bounds.Top + bounds.Height / 2;

                    if (clientCoords.Y <= middle - 10 && clientCoords.Y >= bounds.Top)
                    {
                        index = group.GetFirstIndex(_flow.Controls);
                    }
                    else if (clientCoords.Y >= middle + 10 && clientCoords.Y <= bounds.Bottom)
                    {
                        index = group.GetLastIndex(_flow.Controls) + 1;
                    }
                    else
                    {
                        continue;
                    }
                }

                draggedGroup.Arrange(_flow.Controls, index);

                moved = true;
            }

            return(moved);
        }