private void FrmDraggable_FormClosing(object sender, FormClosingEventArgs e) { Properties.Settings.Default.DraggableFormStartPostion = new Point(frmDraggable.Bounds.Location.X, frmDraggable.Bounds.Location.Y); Properties.Settings.Default.Save(); frmDraggable = null; this.WindowState = FormWindowState.Normal; this.Show(); }
private void lunchWpfFormToolStripMenuItem_Click(object sender, EventArgs e) { if (frmDraggable == null) { frmDraggable = new DraggableForm.FormBase(); frmDraggable.WindowState = FormWindowState.Normal; frmDraggable.FormBorderStyle = FormBorderStyle.None; frmDraggable.MouseDoubleClick += FrmDraggable_MouseDoubleClick; //events frmDraggable.FormClosing += FrmDraggable_FormClosing; frmDraggable.OnCaptureRequest += FrmDraggable_OnCaptureRequest; frmDraggable.OnShowMainFormRequest += FrmDraggable_OnShowMainFormRequest; frmDraggable.Shown += FrmDraggable_Shown; frmDraggable.Load += FrmDraggable_Load; frmDraggable.OnShift += FrmDraggable_OnShift; frmDraggable.Draggable = true; frmDraggable.TopMost = true; //frmDraggable.Cursor=Cursor. //add controls PictureBox pb1 = new PictureBox(); pb1.Tag = "pb1"; pb1.Name = "pb1"; pb1.Dock = DockStyle.Fill; pb1.BackColor = Color.DarkGray; pb1.MouseDoubleClick += FrmDraggable_MouseDoubleClick; //now, we need some staff to resize image by mouse pb1.Paint += Pb1_Paint; pb1.MouseDown += Pb1_MouseDown; pb1.MouseMove += Pb1_MouseMove; pb1.MouseUp += Pb1_MouseUp; frmDraggable.ControlAdded += FrmDraggable_ControlAdded; frmDraggable.Controls.Add(pb1); if (pdCapture.Image != null) { SetStandaloneFormImage((Bitmap)pdCapture.Image.Clone()); } frmDraggable.Show(); } }