private void UpdateStatistics(ImageHandlerForm imgDoc) { if (DF.Visible) { DF.GatherStatistics((imgDoc == null) ? null : imgDoc.Image); } }
// Update histogram private void UpdateHistogram(ImageHandlerForm imgDoc) { if (HF.Visible) { HF.GatherStatistics((imgDoc == null) ? null : imgDoc.Image); } }
// Setup events private void SetupDocumentEvents(ImageHandlerForm ActivatedIHF) { ActivatedIHF.DocumentChanged += new System.EventHandler(this.document_DocumentChanged); ActivatedIHF.ZoomChanged += new System.EventHandler(this.document_ZoomChanged); ActivatedIHF.MouseImagePosition += new ImageHandlerForm.SelectionEventHandler(this.document_MouseImagePosition); ActivatedIHF.SelectionChanged += new ImageHandlerForm.SelectionEventHandler(this.document_SelectionChanged); ActivatedIHF.MouseHover += new EventHandler(this.dockManager_ActiveDocumentChanged); }
// active document changed private void dockManager_ActiveDocumentChanged(object sender, System.EventArgs e) { ImageHandlerForm doc = ActiveIHF; ImageHandlerForm imgDoc = (doc is ImageHandlerForm) ? (ImageHandlerForm)doc : null; UpdateHistogram(imgDoc); UpdateStatistics(imgDoc); UpdateZoomStatus(imgDoc); UpdateSizeStatus(doc); }
public void OpenFile_Click(object sender, EventArgs e) { try { OpenFileDialog OFD = new OpenFileDialog(); OFD.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); OFD.Filter = "Photo Brush Project File (*.pbp)|*.pbp|Image File (*.png;*.jpg;*.tif;*.bmp;*.gif)|*.png;*.jpg;*.tif;*.bmp;*.gif|Adobe Photoshop Image (*.psd)|*.psd|All Files (*.*)|*.*"; if (OFD.ShowDialog() == DialogResult.OK) { switch (OFD.SafeFileName.Substring(OFD.SafeFileName.IndexOf('.'))) { case ".png": case ".jpg": case ".tif": case ".bmp": case ".gif": ImageHandlerForm IHF = new ImageHandlerForm(OFD.FileName, this); IHF.Text = OFD.SafeFileName;//OFD.FileName.Remove(0, OFD.InitialDirectory.Length + 1); //IHF.pictureBox1.Image = Image.FromFile(OFD.FileName); Initialize(IHF, FormStyle.ImageHandleForm); SetupDocumentEvents(IHF); break; case ".pbp": PaintHandlerForm PHF = new PaintHandlerForm(this); PHF.Text = OFD.SafeFileName;//OFD.FileName.Remove(0, OFD.InitialDirectory.Length + 1); PHF.drawingCanvas1.shapeManager.FileName = OFD.FileName; using (FileStream FS = new FileStream(OFD.FileName, FileMode.Open, FileAccess.Read, FileShare.Read)) { BinaryFormatter BF = new BinaryFormatter(); ShapeManager SM = (ShapeManager)BF.Deserialize(FS); SM.RestoreNonSerializable(PHF.drawingCanvas1); PHF.drawingCanvas1.shapeManager = SM; } PHF.drawingCanvas1.Invalidate(); Initialize(PHF, FormStyle.PaintHandleForm); break; case ".psd": PsdHandlerForm PsdHF = new PsdHandlerForm(); PsdHF.Text = OFD.SafeFileName; PsdHF.OpenPsdFile(OFD.FileName); Initialize(PsdHF, FormStyle.PsdHandlerForm); break; default: ReadyToolStripStatusLabel.Text = "Sorry cannot open this file !"; break; } } } catch (Exception E) { MessageBox.Show(E.Message, "Error File", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
// Update zoom status private void UpdateZoomStatus(ImageHandlerForm imgDoc) { if (imgDoc != null) { int zoom = (int)(imgDoc.Zoom * 100); zoomPanel.Text = "ZOOM " + zoom.ToString() + "%"; } else { zoomPanel.Text = String.Empty; } }
// Create new document public bool NewDocument(Bitmap image) { unnamedNumber++; ImageHandlerForm IHF2 = new ImageHandlerForm(image, (IDocumentsHost)this); //IHF2.Image = image; IHF2.Text = ActiveIHF.Text + " " + unnamedNumber.ToString(); IHF2.SafeFileName = ActiveIHF.SafeFileName; Initialize(IHF2, FormStyle.ImageHandleForm); //SetupDocumentEvents(IHF2); return(true); }
// Update size status private void UpdateSizeStatus(ImageHandlerForm doc) { if (doc != null) { int w = 0, h = 0; if (doc is ImageHandlerForm) { w = ((ImageHandlerForm)doc).ImageWidth; h = ((ImageHandlerForm)doc).ImageHeight; } //else if (doc is FourierDoc) //{ // w = ((FourierDoc)doc).ImageWidth; // h = ((FourierDoc)doc).ImageHeight; //} sizePanel.Text = "SIZE " + w.ToString() + " x " + h.ToString(); } else { sizePanel.Text = String.Empty; } }
// Update zoom status private void UpdateZoomStatus(ImageHandlerForm imgDoc) { if (imgDoc != null) { int zoom = (int)(imgDoc.Zoom * 100); zoomPanel.Text = "ZOOM "+ zoom.ToString() + "%"; } else { zoomPanel.Text = String.Empty; } }
private void UpdateStatistics(ImageHandlerForm imgDoc) { if (DF.Visible) DF.GatherStatistics((imgDoc == null) ? null : imgDoc.Image); }
// Update size status private void UpdateSizeStatus(ImageHandlerForm doc) { if (doc != null) { int w = 0, h = 0; if (doc is ImageHandlerForm) { w = ((ImageHandlerForm)doc).ImageWidth; h = ((ImageHandlerForm)doc).ImageHeight; } //else if (doc is FourierDoc) //{ // w = ((FourierDoc)doc).ImageWidth; // h = ((FourierDoc)doc).ImageHeight; //} sizePanel.Text = "SIZE " + w.ToString() + " x " + h.ToString(); } else { sizePanel.Text = String.Empty; } }
// Update histogram private void UpdateHistogram(ImageHandlerForm imgDoc) { if (HF.Visible) HF.GatherStatistics((imgDoc == null) ? null : imgDoc.Image); }
// Setup events private void SetupDocumentEvents(ImageHandlerForm ActivatedIHF) { ActivatedIHF.DocumentChanged += new System.EventHandler(this.document_DocumentChanged); ActivatedIHF.ZoomChanged += new System.EventHandler(this.document_ZoomChanged); ActivatedIHF.MouseImagePosition += new ImageHandlerForm.SelectionEventHandler(this.document_MouseImagePosition); ActivatedIHF.SelectionChanged += new ImageHandlerForm.SelectionEventHandler(this.document_SelectionChanged); ActivatedIHF.MouseHover += new EventHandler(this.dockManager_ActiveDocumentChanged); }
public void OpenFile_Click(object sender, EventArgs e) { try { OpenFileDialog OFD = new OpenFileDialog(); OFD.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); OFD.Filter = "Photo Brush Project File (*.pbp)|*.pbp|Image File (*.png;*.jpg;*.tif;*.bmp;*.gif)|*.png;*.jpg;*.tif;*.bmp;*.gif|Adobe Photoshop Image (*.psd)|*.psd|All Files (*.*)|*.*"; if (OFD.ShowDialog() == DialogResult.OK) { switch(OFD.SafeFileName.Substring(OFD.SafeFileName.IndexOf('.'))) { case ".png": case ".jpg": case ".tif": case ".bmp": case ".gif": ImageHandlerForm IHF = new ImageHandlerForm(OFD.FileName, this); IHF.Text = OFD.SafeFileName;//OFD.FileName.Remove(0, OFD.InitialDirectory.Length + 1); //IHF.pictureBox1.Image = Image.FromFile(OFD.FileName); Initialize(IHF, FormStyle.ImageHandleForm); SetupDocumentEvents(IHF); break; case ".pbp": PaintHandlerForm PHF = new PaintHandlerForm(this); PHF.Text = OFD.SafeFileName;//OFD.FileName.Remove(0, OFD.InitialDirectory.Length + 1); PHF.drawingCanvas1.shapeManager.FileName = OFD.FileName; using (FileStream FS = new FileStream(OFD.FileName, FileMode.Open, FileAccess.Read, FileShare.Read)) { BinaryFormatter BF = new BinaryFormatter(); ShapeManager SM = (ShapeManager)BF.Deserialize(FS); SM.RestoreNonSerializable(PHF.drawingCanvas1); PHF.drawingCanvas1.shapeManager = SM; } PHF.drawingCanvas1.Invalidate(); Initialize(PHF, FormStyle.PaintHandleForm); break; case ".psd": PsdHandlerForm PsdHF = new PsdHandlerForm(); PsdHF.Text = OFD.SafeFileName; PsdHF.OpenPsdFile(OFD.FileName); Initialize(PsdHF, FormStyle.PsdHandlerForm); break; default: ReadyToolStripStatusLabel.Text = "Sorry cannot open this file !"; break; } } } catch (Exception E) { MessageBox.Show(E.Message, "Error File", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
// Create new document public bool NewDocument(Bitmap image) { unnamedNumber++; ImageHandlerForm IHF2 = new ImageHandlerForm(image, (IDocumentsHost)this); //IHF2.Image = image; IHF2.Text = ActiveIHF.Text +" "+ unnamedNumber.ToString(); IHF2.SafeFileName = ActiveIHF.SafeFileName; Initialize(IHF2, FormStyle.ImageHandleForm); //SetupDocumentEvents(IHF2); return true; }