public static void ShowNotification(NotificationForm f, string command, string screenshot_path = "") { if (f == null) { return; } if (screenshot_path == "") { TibialyzerCommand cmd = new TibialyzerCommand(command); command_stack.Push(cmd); f.command = cmd; } f.Visible = false; int richX = -1; int richY = -1; int anchor = 0; int duration = 5; int group = 0; for (int it = 0; it < Constants.NotificationTypeObjects.Count; it++) { if (f.FormName() == Constants.NotificationTypeObjects[it]) { string settingObject = Constants.NotificationTypes[it].Replace(" ", ""); richX = SettingsManager.getSettingInt(settingObject + "XOffset"); richY = SettingsManager.getSettingInt(settingObject + "YOffset"); anchor = SettingsManager.getSettingInt(settingObject + "Anchor"); duration = SettingsManager.getSettingInt(settingObject + "Duration"); group = Math.Min(Math.Max(SettingsManager.getSettingInt(settingObject + "Group"), 0), 9); break; } } f.notificationDuration = duration; f.LoadForm(); if (screenshot_path != "") { Bitmap bitmap = new Bitmap(f.Width, f.Height); f.DrawToBitmap(bitmap, new Rectangle(0, 0, f.Width, f.Height)); foreach (Control c in f.Controls) { c.DrawToBitmap(bitmap, new Rectangle(new Point(Math.Min(Math.Max(c.Location.X, 0), f.Width), Math.Min(Math.Max(c.Location.Y, 0), f.Height)), c.Size)); } bitmap.Save(screenshot_path); bitmap.Dispose(); f.Dispose(); return; } if (NotificationFormGroups[group] != null) { NotificationFormGroups[group].close(); } int position_x = 0, position_y = 0; Screen screen = ProcessManager.GetScreen(); int xOffset = richX == -1 ? 30 : richX; int yOffset = richY == -1 ? 30 : richY; switch (anchor) { case 3: position_x = screen.WorkingArea.Right - xOffset - f.Width; position_y = screen.WorkingArea.Bottom - yOffset - f.Height; break; case 2: position_x = screen.WorkingArea.Left + xOffset; position_y = screen.WorkingArea.Bottom - yOffset - f.Height; break; case 1: position_x = screen.WorkingArea.Right - xOffset - f.Width; position_y = screen.WorkingArea.Top + yOffset; break; default: position_x = screen.WorkingArea.Left + xOffset; position_y = screen.WorkingArea.Top + yOffset; break; } f.StartPosition = FormStartPosition.Manual; f.SetDesktopLocation(position_x, position_y); f.TopMost = true; f.Show(); NotificationFormGroups[group] = f; }
public static void ShowNotification(NotificationForm f, string command, string screenshot_path = "") { if (f == null) return; if (screenshot_path == "") { TibialyzerCommand cmd = new TibialyzerCommand(command); command_stack.Push(cmd); f.command = cmd; } f.Visible = false; int richX = -1; int richY = -1; int anchor = 0; int duration = 5; int group = 0; for (int it = 0; it < Constants.NotificationTypeObjects.Count; it++) { if (f.FormName() == Constants.NotificationTypeObjects[it]) { string settingObject = Constants.NotificationTypes[it].Replace(" ", ""); richX = SettingsManager.getSettingInt(settingObject + "XOffset"); richY = SettingsManager.getSettingInt(settingObject + "YOffset"); anchor = SettingsManager.getSettingInt(settingObject + "Anchor"); duration = SettingsManager.getSettingInt(settingObject + "Duration"); group = Math.Min(Math.Max(SettingsManager.getSettingInt(settingObject + "Group"), 0), 9); break; } } f.notificationDuration = duration; f.LoadForm(); if (screenshot_path != "") { Bitmap bitmap = new Bitmap(f.Width, f.Height); f.DrawToBitmap(bitmap, new Rectangle(0, 0, f.Width, f.Height)); foreach (Control c in f.Controls) { c.DrawToBitmap(bitmap, new Rectangle(new Point(Math.Min(Math.Max(c.Location.X, 0), f.Width), Math.Min(Math.Max(c.Location.Y, 0), f.Height)), c.Size)); } bitmap.Save(screenshot_path); bitmap.Dispose(); f.Dispose(); return; } if (NotificationFormGroups[group] != null) { NotificationFormGroups[group].close(); } int position_x = 0, position_y = 0; Screen screen = ProcessManager.GetScreen(); int xOffset = richX == -1 ? 30 : richX; int yOffset = richY == -1 ? 30 : richY; switch (anchor) { case 3: position_x = screen.WorkingArea.Right - xOffset - f.Width; position_y = screen.WorkingArea.Bottom - yOffset - f.Height; break; case 2: position_x = screen.WorkingArea.Left + xOffset; position_y = screen.WorkingArea.Bottom - yOffset - f.Height; break; case 1: position_x = screen.WorkingArea.Right - xOffset - f.Width; position_y = screen.WorkingArea.Top + yOffset; break; default: position_x = screen.WorkingArea.Left + xOffset; position_y = screen.WorkingArea.Top + yOffset; break; } f.StartPosition = FormStartPosition.Manual; f.SetDesktopLocation(position_x, position_y); f.TopMost = true; f.Show(); NotificationFormGroups[group] = f; }