private void Tray_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { GC.Collect(); ContextMenuStrip cms = new ContextMenuStrip(); ToolStripMenuItem tsi; foreach (Addon addon in Addons) { int MenuItemsAdded = 0; Hashtable[] MenuItems = addon.CallHook2 <Hashtable[]>("Menu", new Hashtable[0]); for (int i = 0; i < MenuItems.Length; i++) { if ((bool)MenuItems[i]["Visible"]) { tsi = (ToolStripMenuItem)cms.Items.Add((string)MenuItems[i]["Text"]); tsi.Image = (Image)MenuItems[i]["Image"]; Action temp = (MenuItems[i]["Action"] as Action); tsi.Click += new EventHandler(delegate { temp.Invoke(); }); if (MenuItems[i].ContainsKey("ShortcutModifiers") && MenuItems[i].Contains("ShortcutKey")) { tsi.ShortcutKeyDisplayString = ((string)MenuItems[i]["ShortcutModifiers"] + "+" + (string)MenuItems[i]["ShortcutKey"]).Trim('+'); } MenuItemsAdded++; } } if (MenuItemsAdded > 0) { cms.Items.Add(new ToolStripSeparator()); } } tsi = (ToolStripMenuItem)cms.Items.Add("Settings"); tsi.Image = this.iconList.Images[0]; tsi.Click += new EventHandler(delegate { Show(); }); tsi = (ToolStripMenuItem)cms.Items.Add("Upload Log"); tsi.Image = this.iconList.Images[1]; tsi.Click += new EventHandler(delegate { button7_Click(null, null); }); if (settings.GetBool("BackupsEnabled")) { tsi = (ToolStripMenuItem)cms.Items.Add("Backups"); tsi.Image = this.iconList.Images[4]; tsi.Click += new EventHandler(delegate { Process.Start("explorer", "\"" + Path.GetFullPath(settings.GetString("BackupsPath")) + "\""); }); } if (this.canUpdate != "") { tsi = (ToolStripMenuItem)cms.Items.Add("Update to " + this.canUpdate); tsi.Image = this.iconList.Images[5]; tsi.Click += new EventHandler(delegate { if (File.Exists("Updater.exe")) { Process.Start("Updater.exe"); this.KillMe(); } }); } tsi = (ToolStripMenuItem)cms.Items.Add("Exit"); tsi.Click += new EventHandler(delegate { KillMe(); }); Tray.ContextMenuStrip = cms; } }
private void Tray_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { GC.Collect(); ContextMenuStrip cms = new ContextMenuStrip(); ToolStripMenuItem tsi; foreach (Addon addon in Addons) { int MenuItemsAdded = 0; Hashtable[] MenuItems = addon.CallHook2 <Hashtable[]>("Menu", new Hashtable[0]); for (int i = 0; i < MenuItems.Length; i++) { if ((bool)MenuItems[i]["Visible"]) { tsi = (ToolStripMenuItem)cms.Items.Add((string)MenuItems[i]["Text"]); tsi.Image = (Image)MenuItems[i]["Image"]; Action temp = (MenuItems[i]["Action"] as Action); tsi.Click += new EventHandler(delegate { temp.Invoke(); }); if (MenuItems[i].ContainsKey("ShortcutModifiers") && MenuItems[i].Contains("ShortcutKey")) { tsi.ShortcutKeyDisplayString = ((string)MenuItems[i]["ShortcutModifiers"] + "+" + (string)MenuItems[i]["ShortcutKey"]).Trim('+'); } MenuItemsAdded++; } } if (MenuItemsAdded > 0) { cms.Items.Add(new ToolStripSeparator()); } } if (LogInfos.Count > 0) { foreach (LogInfo logInfo in LogInfos.Reverse <LogInfo>()) { LogInfo temp = logInfo; string filename = ""; try { filename = Path.GetFileName(temp.URL); } catch { } tsi = (ToolStripMenuItem)cms.Items.Add(filename + " - " + temp.Info); tsi.Click += new EventHandler(delegate { SetClipboardText(temp.URL); }); } cms.Items.Add(new ToolStripSeparator()); } tsi = (ToolStripMenuItem)cms.Items.Add("Settings"); tsi.Image = this.iconList.Images[0]; tsi.Click += new EventHandler(delegate { Show(); }); tsi = (ToolStripMenuItem)cms.Items.Add("Upload Log"); tsi.Image = this.iconList.Images[1]; tsi.Click += new EventHandler(delegate { button7_Click(null, null); }); if (settings.GetBool("BackupsEnabled")) { tsi = (ToolStripMenuItem)cms.Items.Add("Backups"); tsi.Image = this.iconList.Images[4]; tsi.Click += new EventHandler(delegate { Process.Start("explorer", "\"" + Path.GetFullPath(settings.GetString("BackupsPath")) + "\""); }); } if (this.canUpdate != "") { tsi = (ToolStripMenuItem)cms.Items.Add("Update to " + this.canUpdate); tsi.Image = this.iconList.Images[5]; tsi.Click += new EventHandler(delegate { if (File.Exists("Update.exe")) { Process.Start("Update.exe"); this.KillMe(); } }); } tsi = (ToolStripMenuItem)cms.Items.Add("Exit"); tsi.Click += new EventHandler(delegate { KillMe(); }); // 2nd anniversary if (!this.settings.Contains("Cats")) { DateTime now = DateTime.Now; if (now.Day == 14 && now.Month == 7 && now.Year == 2012) { cms.Items.Add(new ToolStripSeparator()); tsi = (ToolStripMenuItem)cms.Items.Add("Happy 2nd Anniversary, ClipUpload!"); tsi.Image = this.iconList.Images[6]; tsi.Click += new EventHandler(delegate { this.settings.SetBool("Cats", true); this.settings.Save(); MessageBox.Show("You may now upload cat watermarks. Enjoy.", "ClipUpload 2nd Anniversary", MessageBoxButtons.OK, MessageBoxIcon.Information); }); } } else { cms.Items.Add(new ToolStripSeparator()); tsi = (ToolStripMenuItem)cms.Items.Add("Disable anniversary cats"); tsi.Image = this.iconList.Images[6]; tsi.Click += new EventHandler(delegate { this.settings.Delete("Cats"); this.settings.Save(); MessageBox.Show("And the cat watermarks are now gone.", "ClipUpload 2nd Anniversary", MessageBoxButtons.OK, MessageBoxIcon.Information); }); } Tray.ContextMenuStrip = cms; } }