private void WindowSnapshotMenuItem_Click(object sender, EventArgs e) { if (this.m_AppWindow != null && !this.m_AppWindow.Minimized) { MemoryStream ms = new MemoryStream(); try { this.m_AppWindow.WindowAsBitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png); } catch { return; } ms.Position = 0; Image image = Image.FromStream(ms); SlideModel slide = null; using (Synchronizer.Lock(this.m_Model.Workspace.CurrentDeckTraversal.SyncRoot)) { if ((~this.m_Model.Workspace.CurrentDeckTraversal) != null) { using (Synchronizer.Lock((~this.m_Model.Workspace.CurrentDeckTraversal).SyncRoot)) { slide = (~this.m_Model.Workspace.CurrentDeckTraversal).Current.Slide; } } } if (slide != null) { InsertMenu.InsertImage(image, slide); } } }
protected override void OnClick(EventArgs e) { base.OnClick(e); IDataObject clipboardDateObject = Clipboard.GetDataObject(); if (clipboardDateObject.GetDataPresent(DataFormats.Bitmap)) { Image image = (Bitmap)clipboardDateObject.GetData(DataFormats.Bitmap); SlideModel slide = null; using (Synchronizer.Lock(this.m_Model.Workspace.CurrentDeckTraversal.SyncRoot)) { if ((~this.m_Model.Workspace.CurrentDeckTraversal) != null) { using (Synchronizer.Lock((~this.m_Model.Workspace.CurrentDeckTraversal).SyncRoot)) { slide = (~this.m_Model.Workspace.CurrentDeckTraversal).Current.Slide; } } } if (slide != null) { InsertMenu.InsertImage(image, slide); } } }
protected override void OnClick(EventArgs e) { base.OnClick(e); //Show up the OpenFileDialog //get the image that the user wants to load OpenFileDialog file_dialog = new OpenFileDialog(); file_dialog.Filter = "JPEG files (*.jpg)|*.jpg|BMP files (*.bmp)|*.bmp|PNG files (*.png)|*.png"; if (file_dialog.ShowDialog() == DialogResult.OK) { Image image = Image.FromFile(file_dialog.FileName); SlideModel slide = null; using (Synchronizer.Lock(this.m_Model.Workspace.CurrentDeckTraversal.SyncRoot)) { if ((~this.m_Model.Workspace.CurrentDeckTraversal) != null) { using (Synchronizer.Lock((~this.m_Model.Workspace.CurrentDeckTraversal).SyncRoot)) { slide = (~this.m_Model.Workspace.CurrentDeckTraversal).Current.Slide; } } } if (slide != null) { InsertMenu.InsertImage(image, slide); } } }