Exemple #1
0
 private void UpdateStatistics(ImageHandlerForm imgDoc)
 {
     if (DF.Visible)
     {
         DF.GatherStatistics((imgDoc == null) ? null : imgDoc.Image);
     }
 }
Exemple #2
0
 // Update histogram
 private void UpdateHistogram(ImageHandlerForm imgDoc)
 {
     if (HF.Visible)
     {
         HF.GatherStatistics((imgDoc == null) ? null : imgDoc.Image);
     }
 }
Exemple #3
0
 // 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);
 }
Exemple #4
0
        // 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);
        }
Exemple #5
0
        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); }
        }
Exemple #6
0
 // 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;
     }
 }
Exemple #7
0
        // 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);
        }
Exemple #8
0
        // 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;
            }
        }
Exemple #9
0
 // 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;
     }
 }
Exemple #10
0
 private void UpdateStatistics(ImageHandlerForm imgDoc)
 {
     if (DF.Visible)
         DF.GatherStatistics((imgDoc == null) ? null : imgDoc.Image);
 }
Exemple #11
0
        // 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;
            }
        }
Exemple #12
0
 // Update histogram
 private void UpdateHistogram(ImageHandlerForm imgDoc)
 {
     if (HF.Visible)
         HF.GatherStatistics((imgDoc == null) ? null : imgDoc.Image);
 }
Exemple #13
0
 // 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);
 }
Exemple #14
0
        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); }
        }
Exemple #15
0
 // 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;
 }