/// <summary> /// Sets the imagae display draw mode. /// </summary> /// <param name="mode"></param> public void SetDrawMode(HelperLibs.Controls.ImageDrawMode mode) { imageDisplay1.DrawMode = mode; if (mode == HelperLibs.Controls.ImageDrawMode.Resizeable) { imageDisplay1.CenterCurrentImage(); } }
/// <summary> /// lifts the image display onto a new form and fullscreens it /// </summary> private void ShowFullScreenImage() { if (this._showingFullscreenImage) { return; } Control ctl = this.imageDisplay1; Point og_loc = ctl.Location; Size og_size = ctl.Size; DockStyle og_dock = ctl.Dock; AnchorStyles og_anch = ctl.Anchor; Control parent = ctl.Parent; HelperLibs.Controls.ImageDrawMode d = imageDisplay1.DrawMode; imageDisplay1.DrawMode = HelperLibs.Controls.ImageDrawMode.Resizeable; _fullscreenImageForm = new Form() { FormBorderStyle = FormBorderStyle.None, WindowState = FormWindowState.Maximized, ShowInTaskbar = false, KeyPreview = true }; _fullscreenImageForm.FormClosing += delegate { ctl.Parent = parent; ctl.Location = og_loc; ctl.Dock = og_dock; ctl.Anchor = og_anch; ctl.Size = og_size; imageDisplay1.DrawMode = d; if (d == HelperLibs.Controls.ImageDrawMode.Resizeable) { imageDisplay1.CenterCurrentImage(); } this._showingFullscreenImage = false; this.Show(); }; _fullscreenImageForm.KeyUp += (KeyEventHandler)((s, e) => { switch (e.KeyData) { case Keys.End: case Keys.Back: case Keys.Control | Keys.W: case Keys.Alt | Keys.F4: case Keys.Escape: _fullscreenImageForm.Close(); break; } }); // Move control to host ctl.Parent = _fullscreenImageForm; ctl.Location = Point.Empty; ctl.Dock = DockStyle.Fill; // And go full screen _fullscreenImageForm.Show(); this._showingFullscreenImage = true; this.Hide(); }