Пример #1
0
        public Bar(Monitor monitor, IEnumerable<IFixedWidthWidget> leftAlignedWidgets, IEnumerable<IFixedWidthWidget> rightAlignedWidgets,
			IEnumerable<ISpanWidget> middleAlignedWidgets, int barHeight = 20, Font font = null, Color? backgroundColor = null)
        {
            this.monitor = monitor;
            this.leftAlignedWidgets = leftAlignedWidgets.ToArray();
            this.rightAlignedWidgets = rightAlignedWidgets.ToArray();
            this.middleAlignedWidgets = middleAlignedWidgets.ToArray();
            this.barHeight = barHeight;
            this.font = font ?? new Font("Lucida Console", 8);

            this.form = CreateForm();
            if (backgroundColor != null)
            {
                this.form.BackColor = backgroundColor.Value;
            }
        }
Пример #2
0
        public Workspace(Monitor monitor, ILayout layout, IEnumerable<IBar> barsAtTop = null, IEnumerable<IBar> barsAtBottom = null,
			string name = null, bool showWindowsTaskbar = false, bool repositionOnSwitchedTo = false)
        {
            windows = new LinkedList<Window>();

            this.id = ++count;
            this.Monitor = monitor;
            this.Layout = layout;
            this.barsAtTop = Screen.AllScreens.Select(_ => new LinkedList<IBar>()).ToArray();
            this.barsAtBottom = Screen.AllScreens.Select(_ => new LinkedList<IBar>()).ToArray();
            if (barsAtTop != null)
            {
                barsAtTop.ForEach(bar => this.barsAtTop[bar.Monitor.monitorIndex].AddLast(bar));
            }
            if (barsAtBottom != null)
            {
                barsAtBottom.ForEach(bar => this.barsAtBottom[bar.Monitor.monitorIndex].AddLast(bar));
            }
            this.name = name;
            this.ShowWindowsTaskbar = showWindowsTaskbar;
            this.repositionOnSwitchedTo = repositionOnSwitchedTo;
            layout.Initialize(this);
        }
Пример #3
0
 internal static void DoWorkspaceMonitorChanged(Workspace workspace, Monitor oldMonitor, Monitor newMonitor)
 {
     if (WorkspaceMonitorChanged != null)
     {
         WorkspaceMonitorChanged(workspace, oldMonitor, newMonitor);
     }
 }
Пример #4
0
        public void MoveWorkspaceToMonitor(Workspace workspace, Monitor newMonitor, bool showOnNewMonitor = true,
			bool switchTo = true)
        {
            var oldMonitor = workspace.Monitor;
            if (oldMonitor != newMonitor && oldMonitor.Workspaces.Count() > 1)
            {
                // unswitch the current workspace
                if (CurrentWorkspace != workspace && switchTo)
                {
                    CurrentWorkspace.IsCurrentWorkspace = false;

                    // remove windows from ALT-TAB menu and Taskbar
                    if (CurrentWorkspace.hideFromAltTabWhenOnInactiveWorkspaceCount > 0)
                    {
                        CurrentWorkspace.GetWindows().Where(w => w.hideFromAltTabAndTaskbarWhenOnInactiveWorkspace).ForEach(w => w.ShowInAltTabAndTaskbar(false));
                    }
                }

                // if the workspace to be moved is visible on the old monitor, switch to another one
                if (oldMonitor.CurrentVisibleWorkspace == workspace)
                {
                    var oldMonitorNewWorkspace = oldMonitor.Workspaces.First(ws => !ws.IsWorkspaceVisible);
                    ShowHideWindows(workspace, oldMonitorNewWorkspace, false);
                    oldMonitor.SwitchToWorkspace(oldMonitorNewWorkspace);
                }

                // remove from old/add to new monitor
                oldMonitor.RemoveWorkspace(workspace);
                workspace.Monitor = newMonitor;
                newMonitor.AddWorkspace(workspace);

                if (switchTo || showOnNewMonitor) // if the workspace must be switched to, it must be shown too
                {
                    // switch to the workspace now on the new monitor
                    ShowHideWindows(newMonitor.CurrentVisibleWorkspace, workspace, true);
                    newMonitor.SwitchToWorkspace(workspace);
                }

                // switch to the moved workspace
                if (CurrentWorkspace != workspace && switchTo)
                {
                    workspace.IsCurrentWorkspace = true;

                    // add windows to ALT-TAB menu and Taskbar
                    if (workspace.hideFromAltTabWhenOnInactiveWorkspaceCount > 0)
                    {
                        workspace.GetWindows().Where(w => w.hideFromAltTabAndTaskbarWhenOnInactiveWorkspace).ForEach(w => w.ShowInAltTabAndTaskbar(true));
                    }

                    CurrentWorkspace = workspace;
                }

                if (CurrentWorkspace == workspace && config.MoveMouseOverMonitorsOnSwitch)
                {
                    Utilities.MoveMouseToMiddleOf(workspace.Monitor.Bounds);
                }

                // reposition the windows on the workspace
                workspace.Reposition();

                Workspace.DoWorkspaceMonitorChanged(workspace, oldMonitor, newMonitor);
            }
        }
Пример #5
0
            public bool SetPosition(Monitor monitor)
            {
                this.monitor = monitor;

                var appBarData = new NativeMethods.APPBARDATA(this.Handle, uEdge: edge, rc: new NativeMethods.RECT { left = monitor.Bounds.Left, right = monitor.Bounds.Right });

                if (edge == NativeMethods.ABE.ABE_TOP)
                {
                    appBarData.rc.top = monitor.Bounds.Top;
                    appBarData.rc.bottom = appBarData.rc.top + this.height;
                }
                else
                {
                    appBarData.rc.bottom = monitor.Bounds.Bottom;
                    appBarData.rc.top = appBarData.rc.bottom - this.height;
                }

                NativeMethods.SHAppBarMessage(NativeMethods.ABM.ABM_QUERYPOS, ref appBarData);

                if (edge == NativeMethods.ABE.ABE_TOP)
                {
                    appBarData.rc.bottom = appBarData.rc.top + this.height;
                }
                else
                {
                    appBarData.rc.top = appBarData.rc.bottom - this.height;
                }

                NativeMethods.SHAppBarMessage(NativeMethods.ABM.ABM_SETPOS, ref appBarData);

                var changedPosition = appBarData.rc.bottom != rect.bottom || appBarData.rc.top != rect.top ||
                    appBarData.rc.left != rect.left || appBarData.rc.right != rect.right;

                this.rect = appBarData.rc;

                this.visible = true;

                return changedPosition;
            }
Пример #6
0
        private void OnWorkspaceMonitorChanged(Workspace workspace, Monitor oldMonitor, Monitor newMonitor)
        {
            if (bar.Monitor == oldMonitor || bar.Monitor == newMonitor)
            {
                applicationPanels.ForEach(p => p.ForEach(t => t.Item2.Hide()));

                if (mustResize[bar.Monitor.CurrentVisibleWorkspace.id - 1])
                {
                    ResizeApplicationPanels(left, right, bar.Monitor.CurrentVisibleWorkspace.id - 1);
                }
                if (!showSingleApplicationTab)
                {
                    applicationPanels[bar.Monitor.CurrentVisibleWorkspace.id - 1].ForEach(t => t.Item2.Show());
                }
            }
        }