Example #1
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); }
        }
Example #2
0
 public NewPaintForm(MainForm MF)
 {
     this.MF = MF;
     PHF = new PaintHandlerForm(MF);
     InitializeComponent();
 }
Example #3
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); }
        }
Example #4
0
 public IFormBuilder FormCreator(FormStyle FS, int Left, int Top, int Width, int Height, Color BackColor, string Title)
 {
     IFormBuilder IFB = null;
     switch (FS)
     {
         case FormStyle.StartPage:
             IFB = StartPageForm.Instance;
             ((StartPageForm)IFB).SetMainForm(this);
             if (!EnableActivatedEventDictionary.ContainsKey(FormStyle.StartPage))
                 EnableActivatedEventDictionary.Add(FormStyle.StartPage, 0);
             EnableActivatedEventDictionary[FormStyle.StartPage]++;
             break;
         case FormStyle.Histogram:
             IFB = HistogramForm.Instance;
             if (!EnableActivatedEventDictionary.ContainsKey(FormStyle.Histogram))
                 EnableActivatedEventDictionary.Add(FormStyle.Histogram, 0);
             EnableActivatedEventDictionary[FormStyle.Histogram]++;
             break;
         case FormStyle.Details:
             IFB = DetailsForm.Instance;
             if (!EnableActivatedEventDictionary.ContainsKey(FormStyle.Details))
                 EnableActivatedEventDictionary.Add(FormStyle.Details, 0);
             EnableActivatedEventDictionary[FormStyle.Details]++;
             break;
         case FormStyle.ToolBox:
             IFB = ToolBoxForm.Instance;
             break;
         case FormStyle.PaintHandleForm:
             IFB = new PaintHandlerForm(this);
             if (!EnableActivatedEventDictionary.ContainsKey(FormStyle.PaintHandleForm))
                 EnableActivatedEventDictionary.Add(FormStyle.PaintHandleForm, 0);
             EnableActivatedEventDictionary[FormStyle.PaintHandleForm]++;
             break;
         case FormStyle.ImageHandleForm:
             //IFB = new ImageHandlerForm(this);
             //if (!EnableActivatedEventDictionary.ContainsKey(FormStyle.ImageHandleForm))
             //    EnableActivatedEventDictionary.Add(FormStyle.ImageHandleForm, 0);
             //EnableActivatedEventDictionary[FormStyle.ImageHandleForm]++;
             break;
         default:
             break;
     }
     IFB.Bounds = new Rectangle(Left, Top, Width, Height);
     IFB.FormBorderStyled = FormBorderStyle.SizableToolWindow;
     IFB.BackColor = BackColor;
     IFB.Text = Title;
     IFB.TopLevel = true;
     return IFB;
 }
Example #5
0
        public IFormBuilder FormCreator(FormStyle FS, int Left, int Top, int Width, int Height, Color BackColor, string Title)
        {
            IFormBuilder IFB = null;

            switch (FS)
            {
            case FormStyle.StartPage:
                IFB = StartPageForm.Instance;
                ((StartPageForm)IFB).SetMainForm(this);
                if (!EnableActivatedEventDictionary.ContainsKey(FormStyle.StartPage))
                {
                    EnableActivatedEventDictionary.Add(FormStyle.StartPage, 0);
                }
                EnableActivatedEventDictionary[FormStyle.StartPage]++;
                break;

            case FormStyle.Histogram:
                IFB = HistogramForm.Instance;
                if (!EnableActivatedEventDictionary.ContainsKey(FormStyle.Histogram))
                {
                    EnableActivatedEventDictionary.Add(FormStyle.Histogram, 0);
                }
                EnableActivatedEventDictionary[FormStyle.Histogram]++;
                break;

            case FormStyle.Details:
                IFB = DetailsForm.Instance;
                if (!EnableActivatedEventDictionary.ContainsKey(FormStyle.Details))
                {
                    EnableActivatedEventDictionary.Add(FormStyle.Details, 0);
                }
                EnableActivatedEventDictionary[FormStyle.Details]++;
                break;

            case FormStyle.ToolBox:
                IFB = ToolBoxForm.Instance;
                break;

            case FormStyle.PaintHandleForm:
                IFB = new PaintHandlerForm(this);
                if (!EnableActivatedEventDictionary.ContainsKey(FormStyle.PaintHandleForm))
                {
                    EnableActivatedEventDictionary.Add(FormStyle.PaintHandleForm, 0);
                }
                EnableActivatedEventDictionary[FormStyle.PaintHandleForm]++;
                break;

            case FormStyle.ImageHandleForm:
                //IFB = new ImageHandlerForm(this);
                //if (!EnableActivatedEventDictionary.ContainsKey(FormStyle.ImageHandleForm))
                //    EnableActivatedEventDictionary.Add(FormStyle.ImageHandleForm, 0);
                //EnableActivatedEventDictionary[FormStyle.ImageHandleForm]++;
                break;

            default:
                break;
            }
            IFB.Bounds           = new Rectangle(Left, Top, Width, Height);
            IFB.FormBorderStyled = FormBorderStyle.SizableToolWindow;
            IFB.BackColor        = BackColor;
            IFB.Text             = Title;
            IFB.TopLevel         = true;
            return(IFB);
        }
Example #6
0
 public NewPaintForm(MainForm MF)
 {
     this.MF = MF;
     PHF     = new PaintHandlerForm(MF);
     InitializeComponent();
 }