Ejemplo n.º 1
0
        //public bool Open()
        //{
        //    bool blnSuccess = false;
        //    using (OpenFileDialog OFD = new OpenFileDialog())
        //    {
        //        try
        //        {
        //            OFD.Filter = "Photo Brush Project File (*.pbp)|*.pbp";
        //            OFD.DefaultExt = ".pbp";
        //            OFD.Title = "Open Photo Brush Project File";
        //            OFD.ShowDialog();

        //            if (OFD.FileName != "")
        //            {
        //                shapeManager.FileName = OFD.FileName;
        //                using (FileStream FS = new FileStream(shapeManager.FileName, FileMode.Open, FileAccess.Read, FileShare.Read))
        //                {
        //                    BinaryFormatter BF = new BinaryFormatter();
        //                    ShapeManager TMP = (ShapeManager)BF.Deserialize(FS);
        //                    TMP.RestoreNonSerializable(this);
        //                    shapeManager.Dispose();
        //                    shapeManager = null;
        //                    shapeManager = TMP;
        //                }
        //                blnSuccess = true;
        //                this.Invalidate();
        //            }
        //        }
        //        catch (Exception E) { MessageBox.Show(E.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
        //    }
        //    return blnSuccess;
        //}

        public bool Open()
        {
            bool blnSuccess = false;

            try
            {
                if (shapeManager.FileName != "")
                {
                    //shapeManager.FileName = FilePath;
                    using (FileStream FS = new FileStream(shapeManager.FileName, FileMode.OpenOrCreate))//new FileStream(shapeManager.FileName, FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                        BinaryFormatter BF  = new BinaryFormatter();
                        ShapeManager    TMP = (ShapeManager)BF.Deserialize(FS);
                        TMP.RestoreNonSerializable(this);
                        shapeManager.Dispose();
                        shapeManager = null;
                        shapeManager = TMP;
                    }
                    blnSuccess = true;
                    this.Invalidate();
                }
            }
            catch (Exception E) { MessageBox.Show(E.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
            return(blnSuccess);
        }