/// <summary> /// Paint the highlight effect on show desktop buttons /// </summary> public static void Paint(Graphics graphics, Native.ABEdge taskbarLocation, Rectangle bounds, bool hover, bool isClicked) { if (!hover) { graphics.FillRectangle(Theme.DarkBackground, bounds); } if (taskbarLocation == Win32.Native.ABEdge.Top || taskbarLocation == Win32.Native.ABEdge.Bottom) { graphics.DrawImage(Properties.Resources.show_desktop_vertical, bounds.Location); graphics.FillGradientRectangle(Theme.ButtonHighlightTransparent, Theme.ButtonHighlight, new Rectangle(bounds.X + 1, bounds.Bottom - 15, bounds.Width, 16), LinearGradientMode.Vertical); } else { graphics.DrawImage(Properties.Resources.show_desktop_horizontal, bounds.Location); graphics.FillGradientRectangle(Theme.ButtonHighlightTransparent, Theme.ButtonHighlight, new Rectangle(bounds.Y - 30, bounds.Top, 31, bounds.Height), LinearGradientMode.Horizontal); } graphics.DrawRectangle(Theme.ButtonOuterBorder, new Rectangle(bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1)); graphics.DrawRectangle(Theme.ButtonInnerBorderLighter, new Rectangle(bounds.X + 1, bounds.Y + 1, bounds.Width - 3, bounds.Height - 3)); if (isClicked) { graphics.FillRectangle(Theme.ButtonBackgroundFocused, 2, 2, bounds.Width - 2, bounds.Height - 2); } }
void HookManager_MouseMove(object sender, MouseEventArgs e) { // resize based on mouse position Native.ABEdge location = this.MainForm.TaskbarLocation; if (location == Native.ABEdge.Top || location == Native.ABEdge.Bottom) { int h = MainForm.Height; int dy = location == Native.ABEdge.Bottom ? (MainForm.CurrentScreen.Bounds.Bottom - e.Y) : (e.Y - MainForm.CurrentScreen.Bounds.Top); int multiplier = (int)(dy / MainForm.BaseSize); int nh = multiplier * MainForm.BaseSize; if (nh > 0 && nh != h && nh <= MainForm.CurrentScreen.Bounds.Height / 2) { TaskbarPropertiesManager.Instance.Properties.HeightMultiplier = multiplier; MainForm.SetPosition(false, this.MainForm.TaskbarLocation); } } else { int dy = location == Native.ABEdge.Left ? (e.X - MainForm.CurrentScreen.Bounds.Left) : (MainForm.CurrentScreen.Bounds.Right - e.X); if (dy < Constants.VerticalTaskbarWidth) { dy = Constants.VerticalTaskbarWidth; } if (dy != TaskbarPropertiesManager.Instance.Properties.Width && dy <= MainForm.CurrentScreen.Bounds.Width / 2) { TaskbarPropertiesManager.Instance.Properties.Width = dy; MainForm.SetPosition(false, this.MainForm.TaskbarLocation); } } }
public void SetTaskbarLocation(string deviceName, Native.ABEdge location) { int index = ScreenLocation.FindIndex(kvp => kvp.DeviceName.Equals(deviceName)); if (index < 0) { ScreenLocation.Add(new TaskbarLocation(deviceName, location)); } else { ScreenLocation[index] = new TaskbarLocation(deviceName, location); } }
private int IndexFromScreenLocation(Native.ABEdge location) { switch (location) { case Native.ABEdge.Left: return(1); case Native.ABEdge.Top: return(3); case Native.ABEdge.Right: return(2); default: return(0); } }
public static int BigIconPosYWithLabel(Native.ABEdge taskbarLocation) { if (Native.IsThemeActive() != 0) { return(4); } else { if (taskbarLocation == Native.ABEdge.Top) { return(5); } else { return(7); } } }
public static int SmallHorizontalHeight(Native.ABEdge taskbarLocation) { if (Native.IsThemeActive() != 0) { return(30); } else { if (taskbarLocation == Native.ABEdge.Top) { return(25); } else { return(28); } } }
public static int BigHorizontalHeight(Native.ABEdge taskbarLocation) { if (Native.IsThemeActive() != 0) { return(40); } else { if (taskbarLocation == Native.ABEdge.Top) { return(41); } else { return(44); } } }
protected virtual bool IsNearEdge(Native.ABEdge edge) { switch (edge) { case Native.ABEdge.Left: return(this.Right == this.Parent.Width); case Native.ABEdge.Top: return(this.Bottom == this.Parent.Height); case Native.ABEdge.Right: return(this.Left == 0); case Native.ABEdge.Bottom: return(this.Top == 0); } return(false); }
public void UpdateIcons() { var icons = NotificationAreaProxy.GetVisibleIcons(); this.Controls.Clear(); this.SuspendLayout(); ShowButton(); // add a button for each icon and calculate its position Native.ABEdge edge = this.MainForm.TaskbarLocation; int index = _buttonVisible && _showButtonOnTheSameLine && edge != Native.ABEdge.Left ? 1 : 0; int top = _buttonVisible && !_showButtonOnTheSameLine ? 30 : (Native.IsThemeActive() == 0 ? 0 : 4); foreach (var icon in icons) { var button = new NotificationIcon(icon); this.Controls.Add(button); button.Init(); button.AutoSize = false; button.Padding = new System.Windows.Forms.Padding(0); button.Margin = new System.Windows.Forms.Padding(0); button.Left = index * button.Width + HMargin; button.Top = top + 1; index++; if ((index + 1) * button.Width + HMargin > this.Width) { index = _buttonVisible && (edge == Native.ABEdge.Bottom || edge == Native.ABEdge.Top) ? 1 : 0; top += button.Height; } } this.ResumeLayout(); CalculateSize(icons.Count); }
/// <summary> /// Move taskbar to specific side and rearrange all controls /// </summary> /// <param name="notify">If TRUE it will broadcast a message, so that all windows can adjust their size based on the new workarea </param> /// <param name="location">Where to move it</param> public void SetPosition(bool notify, Native.ABEdge location) { TaskbarPropertiesManager.Instance.Properties.SetTaskbarLocation(CurrentScreen.DeviceName, location); ABSetPos(notify); DisplayStartMenu(); bool isVisualTheme = Native.IsThemeActive() != 0; btnShowDesktop.CalculateSizeAndPosition(); FlowDirection direction; if (location == Native.ABEdge.Top || location == Native.ABEdge.Bottom) { direction = FlowDirection.LeftToRight; pnlClock.Dock = DockStyle.Right; pnlClock.Width = ClockPanel.PanelWidth; pnlClock.Height = pnlNotificationBorder.Height; if (pnlNotificationArea.Visible) { pnlNotificationArea.CalculateSize(NotificationAreaProxy.GetVisibleIcons().Count); pnlNotificationArea.UpdateIcons(); pnlNotificationArea.Left = 1; pnlNotificationArea.Top = 0; } pnlNotificationBorder.Width = (pnlClock.Visible ? pnlClock.Width : 0) + (pnlNotificationArea.Visible ? pnlNotificationArea.Width + 5 : 0) + btnShowDesktop.Width; pnlProgramsFlow.Width = this.Width - (_startButton != null ? 54 : 0) - pnlNotificationBorder.Width - 10; pnlProgramsFlow.Height = this.Height; pnlProgramsFlow.Left = (_startButton != null ? 54 : 0); pnlProgramsFlow.Top = 0; if (!isVisualTheme) { pnlNotificationBorder.Height = location == Native.ABEdge.Bottom ? this.Height - 6 : this.Height - 9; pnlNotificationBorder.Top = location == Native.ABEdge.Bottom ? 4 : 3; pnlNotificationBorder.Left = pnlProgramsFlow.Right + 8; } else { pnlNotificationBorder.Height = this.Height; pnlNotificationBorder.Top = 0; pnlNotificationBorder.Left = this.Width - pnlNotificationBorder.Width; } if (location == Native.ABEdge.Bottom) { this.pnlResize.Dock = System.Windows.Forms.DockStyle.Top; } else { this.pnlResize.Dock = System.Windows.Forms.DockStyle.Bottom; } this.pnlResize.Height = 4; if (!TaskbarPropertiesManager.Instance.Properties.Locked) { this.pnlResize.Cursor = System.Windows.Forms.Cursors.SizeNS; } else { this.pnlResize.Cursor = System.Windows.Forms.Cursors.Default; } } else { direction = FlowDirection.TopDown; pnlClock.Dock = DockStyle.Bottom; pnlClock.Width = pnlNotificationBorder.Width; pnlClock.Height = 55; if (pnlNotificationArea.Visible) { pnlNotificationArea.CalculateSize(NotificationAreaProxy.GetVisibleIcons().Count); pnlNotificationArea.UpdateIcons(); pnlNotificationArea.Left = 0; pnlNotificationArea.Top = 2; } pnlNotificationBorder.Height = (pnlClock.Visible ? pnlClock.Height : 0) + (pnlNotificationArea.Visible ? pnlNotificationArea.Height : 0) + btnShowDesktop.Height; pnlProgramsFlow.Height = this.Height - (_startButton != null ? 45 : 0) - pnlNotificationBorder.Height - 10; pnlProgramsFlow.Width = this.Width; pnlProgramsFlow.Left = 0; pnlProgramsFlow.Top = (_startButton != null ? 45 : 0); if (!isVisualTheme) { pnlNotificationBorder.Width = this.Width - 6; pnlNotificationBorder.Left = (location == Native.ABEdge.Left ? 2 : 4); pnlNotificationBorder.Top = pnlProgramsFlow.Bottom + 8; } else { pnlNotificationBorder.Width = this.Width; pnlNotificationBorder.Left = 0; pnlNotificationBorder.Top = this.Height - pnlNotificationBorder.Height; } if (location == Native.ABEdge.Left) { this.pnlResize.Dock = System.Windows.Forms.DockStyle.Right; } else { this.pnlResize.Dock = System.Windows.Forms.DockStyle.Left; } this.pnlResize.Width = 4; if (!TaskbarPropertiesManager.Instance.Properties.Locked) { this.pnlResize.Cursor = System.Windows.Forms.Cursors.SizeWE; } else { this.pnlResize.Cursor = System.Windows.Forms.Cursors.Default; } } pnlClock.RefreshProperties(); flowPanel.SuspendLayout(); flowPanel.FlowDirection = direction; flowPanel.RefreshProperties(); if (tooltipManager.ToolTipWindow != null) { tooltipManager.ToolTipWindow.RefreshProperties(); } if ((location == Native.ABEdge.Right || location == Native.ABEdge.Left) && Native.IsThemeActive() == 0) { flowPanel.Padding = new Padding(3, 0, 6, 0); } else { flowPanel.Padding = new Padding(0); } flowPanel.ResumeLayout(); Refresh(); if (notify) { TaskbarPropertiesManager.Instance.Save(); } }
public TaskbarLocation(string deviceName, Native.ABEdge location) { DeviceName = deviceName; Location = location; }
protected override bool IsNearEdge(Native.ABEdge edge) { return(false); }
public static void Draw(Graphics g, Control ctrl, Native.ABEdge taskbarLocation) { if (Native.IsThemeActive() != 0) { var pen1 = Theme.TaskbarTopLine1; var pen2 = Theme.TaskbarTopLine2; switch (taskbarLocation) { case Native.ABEdge.Left: g.DrawLine(pen1, ctrl.Size.Width - 1, 0, ctrl.Size.Width - 1, ctrl.Size.Height); g.DrawLine(pen2, ctrl.Size.Width - 2, 0, ctrl.Size.Width - 2, ctrl.Size.Height); break; case Native.ABEdge.Top: g.DrawLine(pen1, 0, ctrl.Size.Height - 1, ctrl.Size.Width, ctrl.Size.Height - 1); g.DrawLine(pen2, 0, ctrl.Size.Height - 2, ctrl.Size.Width, ctrl.Size.Height - 2); break; case Native.ABEdge.Right: g.DrawLine(pen1, 0, 0, 0, ctrl.Size.Height); g.DrawLine(pen2, 1, 0, 1, ctrl.Size.Height); break; case Native.ABEdge.Bottom: g.DrawLine(pen1, 0, 0, ctrl.Size.Width, 0); g.DrawLine(pen2, 0, 1, ctrl.Size.Width, 1); break; } } else { var darkPen = new Pen(Color.FromKnownColor(KnownColor.ControlDark)); var lighterPen = new Pen(Color.FromKnownColor(KnownColor.ControlLightLight)); var darkerPen = new Pen(Color.FromKnownColor(KnownColor.ControlDarkDark)); var lightPen = new Pen(Color.FromKnownColor(KnownColor.ControlLight)); switch (taskbarLocation) { case Native.ABEdge.Left: g.DrawLine(darkerPen, ctrl.Size.Width - 1, 0, ctrl.Size.Width - 1, ctrl.Size.Height); g.DrawLine(darkPen, ctrl.Size.Width - 2, 0, ctrl.Size.Width - 2, ctrl.Size.Height); break; case Native.ABEdge.Top: g.DrawLine(darkerPen, 0, ctrl.Size.Height - 1, ctrl.Size.Width, ctrl.Size.Height - 1); g.DrawLine(darkPen, 0, ctrl.Size.Height - 2, ctrl.Size.Width, ctrl.Size.Height - 2); break; case Native.ABEdge.Right: g.DrawLine(lightPen, 0, 0, 0, ctrl.Size.Height); g.DrawLine(lighterPen, 1, 0, 1, ctrl.Size.Height); break; case Native.ABEdge.Bottom: g.DrawLine(lightPen, 0, 0, ctrl.Size.Width, 0); g.DrawLine(lighterPen, 0, 1, ctrl.Size.Width, 1); break; } } }