private void FormDrag_MouseUp(object sender, MouseEventArgs e) { this.timerSet.Enabled = false; if (e.Button == MouseButtons.Left && this.ScreenBox.Visible) { if (this.Selection.Width > 0 && this.Selection.Height > 0) { this.Hide(); Application.DoEvents(); if (DoneDragging != null) { Addon.SetShortcuts(true); DoneDragging(new DragCallback() { Type = DragCallbackType.Image, Image = this.SelectionImage }); } this.Close(); } } }
/// <summary> /// Shows a progressbar window. /// </summary> /// <param name="Filename">The filename</param> /// <param name="Filesize">The filesize</param> /// <param name="DisplaySpeed">Whether or not to display the speed</param> public void Start(string Filename, long Filesize, bool DisplaySpeed) { Addon.SetShortcuts(false); this.reset(); if (Filesize == 0) { return; } if (!appSettings.GetBool("ProgressBar")) { return; } this.Form = new FormProgressBar(appSettings); this.Form.FormClosing += new FormClosingEventHandler(cancelUpload); new Thread(new ThreadStart(delegate { this.filename = Filename; this.filesize = (int)Filesize; //TODO: Handle Filesize > int.MaxValue this.showSpeed = DisplaySpeed; this.updateStatus(0); Application.Run(this.Form); })).Start(); }
public FormDrag(Addon addon) { InitializeComponent(); this.addon = addon; Addon.SetShortcuts(false); this.settings = new Settings("settings.txt"); this.Screens = new Rectangle[Screen.AllScreens.Length]; for (int i = 0; i < this.Screens.Length; i++) { this.Screens[i] = Screen.AllScreens[i].Bounds; } this.Width = this.Screens[0].Width; this.Height = this.Screens[0].Height; // This works because WinForms has an internal way of setting the maximum width/height of a Control (Form) // Check it with ILSpy, System.Windows.Forms.Control.Width (set) for (int i = 0; i < Screen.AllScreens.Length; i++) { if (Screen.AllScreens[i].Bounds.Left < this.Left) { this.Width += this.Left - Screen.AllScreens[i].Bounds.Left; this.Left = Screen.AllScreens[i].Bounds.Left; } else { this.Width += Screen.AllScreens[i].Bounds.Width; } if (Screen.AllScreens[i].Bounds.Top < this.Top) { this.Height += this.Top - Screen.AllScreens[i].Bounds.Top; this.Top = Screen.AllScreens[i].Bounds.Top; } else { this.Height += Screen.AllScreens[i].Bounds.Height; } } this.Opacity = 0.5f; //this.TopMost = true; this.beginImage = new Bitmap(this.Width, this.Height, System.Drawing.Imaging.PixelFormat.Format32bppRgb); Graphics beginGfx = Graphics.FromImage(this.beginImage); beginGfx.CopyFromScreen(this.Location, Point.Empty, this.Size); beginGfx.Dispose(); }
/// <summary> /// Close the progressbar window /// </summary> public void Done() { Addon.SetShortcuts(true); if (!Canceled && this.Form != null) { this.done = true; try { this.Form.Invoke(new Action(delegate { this.Form.Close(); })); } catch { } } }
private void FormDrag_FormClosing(object sender, FormClosingEventArgs e) { Addon.SetShortcuts(true); this.beginImage.Dispose(); this.Dispose(); }
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (keyData == Keys.Escape) { this.Close(); } else if (keyData == Keys.P) { if (this.Selection.Width > 0 && this.Selection.Height > 0) { Bitmap img = null; try { img = this.SelectionImage; } catch { } if (img != null) { if (this.settings.GetInt("DragEditor") == 0) { Addon.SetShortcuts(true); new FormEditor(img, this.DoneDragging).Show(); } else if (this.settings.GetInt("DragEditor") == 1) { string exePath = this.settings.GetString("DragExtraPath"); if (File.Exists(exePath)) { string localTempPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\Temp\\" + Addon.RandomString(16) + ".png"; MemoryStream ms = new MemoryStream(); img.Save(ms, ImageFormat.Png); File.WriteAllBytes(localTempPath, ms.GetBuffer()); Process.Start(exePath, "\"" + localTempPath + "\""); } } this.Close(); if (DoneDragging != null) { //TODO: What do with this? Could return NULL as image, but then every addon must respond // accordingly to that. Can also not be triggered, but could break some addon code // in the progress. Same goes with doing a DragCallback with DragCallbackType.None, // it could potentially break existing addon code. Decisions, decisions... } } } } else if (keyData == Keys.O) { if (this.AnimationAllowed) { this.Close(); Addon.SetShortcuts(true); new FormAnimation(this, this.Selection, this.DoneDragging).Show(); } } return(base.ProcessCmdKey(ref msg, keyData)); }