コード例 #1
0
ファイル: Controller.cs プロジェクト: chienpm304/2D-Designer
        public bool Save(string path, ulong offset)
        {
            try
            {
                SerializeProp ser = new SerializeProp();
                IFormatter    objBinaryFormatter = new BinaryFormatter();
                Stream        objStream          = new FileStream(path,
                                                                  FileMode.Create,
                                                                  FileAccess.ReadWrite,
                                                                  FileShare.None);

                ser.shapes             = mShapes;
                ser.groups             = mGroups;
                ser.fillPattern        = fillPattern;
                ser.border             = border;
                ser.bitmap             = bitmap;
                ser.selectedShapeIndex = mSelectedShapeIndex;
                ser.selectedGroupIndex = mSelectedGroupIndex;
                objBinaryFormatter.Serialize(objStream, ser);
                objStream.Close();

                return(true);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return(false);
            }
        }
コード例 #2
0
ファイル: Controller.cs プロジェクト: chienpm304/2D-Designer
        //---------------------------------------------------
        //                IO Implementations
        public bool Load(string path, ulong offset)
        {
            try
            {
                SerializeProp ser = new SerializeProp();
                Stream        objStreamDeSerialize = new FileStream(path,
                                                                    FileMode.Open,
                                                                    FileAccess.Read,
                                                                    FileShare.Read);
                IFormatter objBinaryFormatter = new BinaryFormatter();

                ser                 = (SerializeProp)objBinaryFormatter.Deserialize(objStreamDeSerialize);
                mShapes             = ser.shapes;
                mGroups             = ser.groups;
                fillPattern         = ser.fillPattern;
                border              = ser.border;
                bitmap              = ser.bitmap;
                mSelectedShapeIndex = ser.selectedShapeIndex;
                mSelectedGroupIndex = ser.selectedGroupIndex;
                objStreamDeSerialize.Close();
                return(true);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return(false);
            }
        }