public void AddZone(Zone zone) { Zones.Add(zone); }
public Image ProfileImage(bool screenNames, bool zoneNames, bool highLight = false) { UpdateDisplays(); foreach (Zone zone in Zones) { if (zone.Area.X < TotalArea.X) { TotalArea.Width += TotalArea.X - zone.Area.X; TotalArea.X = zone.Area.X; } if (zone.Area.Y < TotalArea.Y) { TotalArea.Height += TotalArea.Y - zone.Area.Y; TotalArea.Y = zone.Area.Y; } if (zone.Area.Right() > TotalArea.Right()) { TotalArea.Width += zone.Area.Right() - TotalArea.Right(); } if (zone.Area.Bottom() > TotalArea.Bottom()) { TotalArea.Height += zone.Area.Bottom() - TotalArea.Bottom(); } } Image img = (Image)(new Bitmap(TotalArea.Width, TotalArea.Height)); using (Graphics g = Graphics.FromImage(img)) { StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Center; foreach (Display display in Displays) { Area taskbar = Difference(display.Bounds, display.WorkingArea); if (taskbar.Width > 0 && taskbar.Height > 0) { g.FillRectangle(new LinearGradientBrush( new Point(taskbar.X - TotalArea.X, taskbar.Y - TotalArea.Y), new Point(taskbar.Right() - TotalArea.X, taskbar.Bottom() - TotalArea.Y), Settings.TaskBarColor1, Settings.TaskBarColor2), new Rectangle( taskbar.X - TotalArea.X, taskbar.Y - TotalArea.Y, taskbar.Width, taskbar.Height)); } g.FillRectangle(new LinearGradientBrush( new Point(display.WorkingArea.X - TotalArea.X, display.WorkingArea.Y - TotalArea.Y), new Point(display.WorkingArea.Right() - TotalArea.X, display.WorkingArea.Bottom() - TotalArea.Y), Settings.ScreenColor1, Settings.ScreenColor2), new Rectangle( display.WorkingArea.X - TotalArea.X, display.WorkingArea.Y - TotalArea.Y, display.WorkingArea.Width, display.WorkingArea.Height)); } for (int i = 0; i < Zones.Count; i++) { Zone zone = Zones[i]; if (i == Zones.Count - 1 && highLight) { g.FillRectangle(new LinearGradientBrush( new Point(zone.Area.X - TotalArea.X, zone.Area.Y - TotalArea.Y), new Point(zone.Area.Right() - TotalArea.X, zone.Area.Bottom() - TotalArea.Y), Settings.SelectedZoneColor1, Settings.SelectedZoneColor2), new Rectangle( zone.Area.X - TotalArea.X, zone.Area.Y - TotalArea.Y, zone.Area.Width, zone.Area.Height)); DrawBorder(zone.Area, g, TotalArea.X, TotalArea.Y); } else { g.FillRectangle(new LinearGradientBrush( new Point(zone.Area.X - TotalArea.X, zone.Area.Y - TotalArea.Y), new Point(zone.Area.Right() - TotalArea.X, zone.Area.Bottom() - TotalArea.Y), Settings.ZoneColor1, Settings.ZoneColor2), new Rectangle( zone.Area.X - TotalArea.X, zone.Area.Y - TotalArea.Y, zone.Area.Width, zone.Area.Height)); DrawBorder(zone.Area, g, TotalArea.X, TotalArea.Y); } if (zoneNames) { var stringSize1 = g.MeasureString(zone.Name, new Font("Segoe UI", Settings.ProfileImageZoneTextSize)); var stringSize2 = g.MeasureString(zone.Hotkey.ToString(), new Font("Segoe UI", Settings.ProfileImageZoneTextSize)); var totalSize = new Size((int)Math.Max(stringSize1.Width, stringSize2.Width), (int)(stringSize1.Height + stringSize2.Height)); if (zone.Hotkey.ToString() == "(none)" || stringSize2.Width > zone.Area.Width - 10 || totalSize.Height > zone.Area.Height - 10) { if (stringSize1.Width < zone.Area.Width - 10 && stringSize1.Height < zone.Area.Height - 10) { sf.LineAlignment = StringAlignment.Center; g.DrawString(zone.Name, new Font("Segoe UI", Settings.ProfileImageZoneTextSize), new SolidBrush(Color.Black), new PointF( zone.Area.X - TotalArea.X + (zone.Area.Width / 2), zone.Area.Y - TotalArea.Y + (zone.Area.Height / 2)), sf); } } else { if (totalSize.Width < zone.Area.Width - 10 && totalSize.Height < zone.Area.Height - 10) { sf.LineAlignment = StringAlignment.Far; g.DrawString(zone.Name, new Font("Segoe UI", Settings.ProfileImageZoneTextSize), new SolidBrush(Color.Black), new PointF( zone.Area.X - TotalArea.X + (zone.Area.Width / 2), zone.Area.Y - TotalArea.Y + (zone.Area.Height / 2)), sf); sf.LineAlignment = StringAlignment.Near; g.DrawString(zone.Hotkey.ToString(), new Font("Segoe UI", Settings.ProfileImageZoneTextSize), new SolidBrush(Color.Black), new PointF( zone.Area.X - TotalArea.X + (zone.Area.Width / 2), zone.Area.Y - TotalArea.Y + (zone.Area.Height / 2)), sf); } } } } if (screenNames) { sf.LineAlignment = StringAlignment.Center; foreach (Display display in Displays) { var stringSize = g.MeasureString(display.Name, new Font("Segoe UI", Settings.ProfileImageScreenTextSize)); if (stringSize.Width < display.Bounds.Width - 10 && stringSize.Height < display.Bounds.Height - 10) { g.DrawString(display.Name, new Font("Segoe UI", Settings.ProfileImageScreenTextSize), new SolidBrush(Color.FromArgb(128, 0, 0, 0)), new PointF( display.Bounds.X - TotalArea.X + (display.Bounds.Width / 2), display.Bounds.Y - TotalArea.Y + (display.Bounds.Height / 2)), sf); } } } } return(img); }