Beispiel #1
0
        public bool SaveFile(IFileable f)
        {
            if (f == null)
            {
                return(false);
            }

            ISerializable iser = f as ISerializable;

            if (iser == null)
            {
                return(false);
            }

            object jobj = new JObject();

            if (iser.Serialize(ref jobj) == false)
            {
                return(false);
            }

            var setting = new JsonSerializerSettings();

            setting.Formatting            = Formatting.Indented;          // 들여쓰기, 줄내림(None : 용량 반으로 줄어듬)
            setting.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; // 순환 참조 객체 무시
            string json = JsonConvert.SerializeObject(jobj, setting);

            File.WriteAllText(f.FileInfo.FullFileName, json);

            return(true);
        }
Beispiel #2
0
        public bool LoadFile(IFileable f)
        {
            try
            {
                Bitmap bm = LoadTexture(f);
                if (bm == null)
                {
                    return(false);
                }

                ISerializable iser = f as ISerializable;

                if (iser == null)
                {
                    return(false);
                }

                if (iser.Deserialize(bm) == false)
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                // f.fileinfo.error
                MessageBox.Show(e.ToString());
                return(false);
            }

            return(true);
        }
Beispiel #3
0
        public bool LoadFile(IFileable f)
        {
            try
            {
                StreamReader sr   = new StreamReader(f.FileInfo.FullFileName);
                string       text = sr.ReadToEnd();

                ISerializable iser = f as ISerializable;
                if (iser == null)
                {
                    return(false);
                }

                if (iser.Deserialize(text) == false)
                {
                    MessageBox.Show("파일 deserialize 실패 - " + f.FileInfo.FullFileName);
                    return(false);
                }
            }
            catch (Exception e)
            {
                // error log
                MessageBox.Show(e.ToString());
            }

            return(true);
        }
Beispiel #4
0
        private Bitmap LoadTexture(IFileable f)
        {
            FIBITMAP dib = new FIBITMAP();

            if (dib.IsNull == false)
            {
                FreeImage.Unload(dib);
            }

            FREE_IMAGE_FORMAT fif = FreeImage.GetFIFFromFilename(f.FileInfo.FullFileName);

            dib = FreeImage.Load(fif, f.FileInfo.FullFileName, FREE_IMAGE_LOAD_FLAGS.DEFAULT);

            FreeImage.FlipVertical(dib);

            if (dib.IsNull)
            {
                // f.FileInfo.error
                return(null);
            }

            Bitmap bitmap = FreeImage.GetBitmap(dib);

            FreeImage.Unload(dib);

            return(bitmap);
        }
Beispiel #5
0
        public bool LoadFile(IFileable f)
        {
            try
            {
                if (mConverters.ContainsKey(f.FileInfo.Extension) == false)
                {
                    MessageBox.Show("해당 파일을 지원하는 Converter가 없습니다. - " + f.FileInfo.Extension);
                    return(false);
                }

                IConverter conv   = mConverters[f.FileInfo.Extension];
                JObject    jmodel = conv.Import(f.FileInfo.FullFileName);

                // Deserialize
                ISerializable iser = f as ISerializable;
                if (iser == null)
                {
                    return(false);
                }

                if (iser.Deserialize(jmodel) == false)
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                //f.FileInfo.error
                MessageBox.Show(e.ToString());
                return(false);
            }

            return(true);
        }
Beispiel #6
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            /* << VIEWS >> */
            BaseForm  baseForm = new BaseForm();
            IGameView gameView = new GameFormView(); // injecting new << View >>
            //IGameView_Render gameView = new GameFormView_Render(); // injecting new << View >>
            //IGameView_Manual gameView = new GameFormView_Manual();
            IFilerView    filerView    = new FilerFormView();
            IDesignerView designerView = new DesignerFormView();

            /* << MODELS >> */
            IFiler    filer            = new Filer();
            IDesigner designer         = new Designer();
            IFileable designerFileable = (IFileable)designer;
            IGame     game             = new Game();
            IFileable gameFileable     = (IFileable)game;

            /* << CONTROLLER(S) >> */
            IGameController     gameController     = new GameController(gameView, filerView, filer, game, gameFileable);
            IDesignerController designerController = new DesignerController(filerView, designerView, filer, designer, designerFileable);

            baseForm.SetControllers(gameController, designerController);
            //gameView.SetController(gameController); // Set Controller for injected View
            Application.Run(baseForm);
        }
Beispiel #7
0
        public bool SaveFile(IFileable f)
        {
            if (f == null)
            {
                return(false);
            }

            ISerializable iser = f as ISerializable;

            if (iser == null)
            {
                return(false);
            }

            FileStream fs     = new FileStream(f.FileInfo.FullFileName, FileMode.Create, FileAccess.Write);
            object     writer = new BinaryWriter(fs);

            bool success = iser.Serialize(ref writer);

            BinaryWriter bw = writer as BinaryWriter;

            bw.Close();
            fs.Close();

            return(success);
        }
Beispiel #8
0
        public bool LoadFile(IFileable f)
        {
            try
            {
                string str = File.ReadAllText(f.FileInfo.FullFileName);

                JObject jobj = JObject.Parse(str);

                ISerializable iser = f as ISerializable;
                if (iser == null)
                {
                    return(false);
                }

                if (iser.Deserialize(jobj) == false)
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
            }

            return(true);
        }
Beispiel #9
0
        public void Save(string filename, IFileable callMeBackforDetails)
        {
            // sorry – you gotta do this

            string txt    = "";
            int    column = callMeBackforDetails.GetColumnCount();
            int    row    = callMeBackforDetails.GetRowCount();

            // whatIsAs.WhatsAt(row, column);
            for (int r = 0; r < row; r++)
            {
                for (int c = 0; c < column; c++)
                {
                    //txt += Convert.ToString(callMeBackforDetails.WhatsAt(r, c));
                    txt += callMeBackforDetails.WhatsAt(r, c).ToString();
                    if (c == (column - 1))
                    {
                        txt += "\n";
                    }
                }
            }
            this.Converter.Compress(txt);
            string compressedLevel = this.Converter.Compressed;

            Saver.Save(filename, compressedLevel);
        }
Beispiel #10
0
        public bool LoadFile(IFileable f)
        {
            if (f == null)
            {
                return(false);
            }

            ISerializable iser = f as ISerializable;

            if (iser == null)
            {
                return(false);
            }

            FileStream fs = new FileStream(f.FileInfo.FullFileName, FileMode.Open, FileAccess.Read);

            BinaryReader br = new BinaryReader(fs);

            bool success = iser.Deserialize(br);

            br.Close();
            fs.Close();

            return(success);
        }
Beispiel #11
0
        public bool SaveFile(string filename, IFileable dest)
        {
            dest.FileInfo = CFileInfo.SetFileInfo(filename);

            // todo : 파일 유효성 체크

            return(SaveFile(dest));
        }
Beispiel #12
0
 //public DesignerController(IManualDesignerView designerView, IFilerView filerView, IFiler filer, IDesigner designer, IFileable designerFileable)
 //public DesignerController(IDesignerButtonView designerView, IFilerView filerView, IFiler filer, IDesigner designer, IFileable designerFileable)
 public DesignerController(IDesignerView designerView, IFilerView filerView, IFiler filer, IDesigner designer, IFileable designerFileable)
 {
     FilerView        = filerView;
     DesignerView     = designerView;
     Filer            = filer;
     Designer         = designer;
     DesignerFileable = designerFileable;
 }
 public GameController(IGameView /*IGameView_Render*/ /*IGameView_Manual*/ gameView, IFilerView filerView, IFiler filer, IGame game, IFileable gameFileable)
 {
     GameView     = gameView;
     FilerView    = filerView;
     Filer        = filer;
     Game         = game;
     GameFileable = gameFileable;
 }
Beispiel #14
0
 public GameController(IGameView gameView, IFilerView filerView, IFiler filer, IGame game, IFileable gameFileable)
 {
     GameView     = gameView;
     FilerView    = filerView;
     Filer        = filer;
     Game         = game;
     GameFileable = gameFileable;
 }
        public LockingFileDecoration(IFileable decorated, string filePath)
            : base(decorated)
        {
            Condition.Requires(filePath).IsNotNullOrEmpty();
            this.FilePath = filePath;

            // Create a file using the FileStream class.
            this.Stream = FileUtil.GetLockedStream(this.FilePath);
            this.Stream.Lock(0, this.Stream.Length);
        }
Beispiel #16
0
        public LockingFileDecoration(IFileable decorated, string filePath)
            : base(decorated)
        {
            Condition.Requires(filePath).IsNotNullOrEmpty();
            this.FilePath = filePath;

            // Create a file using the FileStream class.
            this.Stream = FileUtil.GetLockedStream(this.FilePath);
            this.Stream.Lock(0, this.Stream.Length);
        }
Beispiel #17
0
        public void BuilderTemp(string fileName, IFileable callBack)
        {
            string empty   = "";
            int    rows    = callBack.GetRowCount();
            int    columns = callBack.GetColumnCount();

            for (int row = 0; row < rows; row++)
            {
                for (int column = 0; column < columns; column++)
                {
                    char part = (char)callBack.WhatsAt(row, column);
                    empty += part.ToString();
                }
                empty += "\r\n";
            }
            System.IO.File.WriteAllText(fileName, empty);
        }
Beispiel #18
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //<<VIEW>>
            BaseForm   baseFrm   = new BaseForm();
            IGameView  gameView  = new GameFormView();
            IFilerView filerView = new FilerFormView();
            /*MANUAL DESIGNER*/
            //IManualDesignerView manualDesignerView = new ManualDesignerFormView();
            /*DYNAMIC BUTTONS*/
            //IDesignerButtonView designerButtonView = new DesignerButtonFormView();
            /*DYNAMIC DRAWING VIEW*/
            IDesignerView designerView = new DesignerFormView();


            //<<MODELS>>
            IFiler    filer            = new Filer();
            IDesigner designer         = new Designer();
            IGame     game             = new Game();
            IFileable designerFileable = (IFileable)designer;
            IFileable gameFileable     = (IFileable)game;

            baseFrm.StartPosition = FormStartPosition.CenterScreen;

            //<<CONTROLLERS>>
            IGameController gameController = new GameController(gameView, filerView, filer, game, gameFileable);
            /*MANUAL DESIGNER*/
            //IDesignerController designerController = new DesignerController(manualDesignerView, filerView, filer, designer, designerFileable);
            /*DYNAMIC BUTTONS*/
            //IDesignerController designerController = new DesignerController(designerButtonView, filerView, filer, designer, designerFileable);
            /*DYNAMIC DRAWING VIEW*/
            IDesignerController designerController = new DesignerController(designerView, filerView, filer, designer, designerFileable);


            //<<SET CONTROLLERS>>
            baseFrm.SetControllers(gameController, designerController);
            /*MANUAL DESIGNER*/
            //manualDesignerView.SetController(designerController);

            Application.Run(baseFrm);
        }
Beispiel #19
0
        public bool LoadFile(IFileable dest)
        {
            if (dest.FileInfo == null)
            {
                MessageBox.Show("파일 로딩 실패");
                return(false);
            }

            // Formatter 선택
            IFormatter formatter = mFormatters[dest.FileInfo.Extension];

            if (formatter.LoadFile(dest) == false)
            {
                // todo : file error logging
                return(false);
            }

            // todo : file status loaded!!

            return(true);
        }
Beispiel #20
0
        public void Save(string file, IFileable callBack)
        {
            int           rows    = callBack.GetRowCount();
            int           columns = callBack.GetColumnCount();
            StringBuilder level   = new StringBuilder();

            for (int i = 0; i < rows; i++)
            {
                for (int j = 0; j < columns; j++)
                {
                    char part = (char)callBack.WhatsAt(i, j);
                    level.Append(part);
                }
                if (i < (rows - 1))
                {
                    level.AppendLine();
                }
            }
            RawString = level.ToString();
            compress();
            System.IO.File.WriteAllText(file, CompressedString);
        }
Beispiel #21
0
        public void Save(string filename, IFileable callMeBackforDetails)
        {
            StringBuilder builder = new StringBuilder();
            int           rows    = callMeBackforDetails.GetRowCount();
            int           columns = callMeBackforDetails.GetColumnCount();

            for (var i = 0; i < rows; i++)
            {
                for (var j = 0; j < columns; j++)
                {
                    char part = (char)callMeBackforDetails.WhatsAt(i, j);
                    builder.Append(part);
                }
                if (i < (rows - 1))
                {
                    builder.AppendLine();
                }
            }
            RawString = builder.ToString();
            Compress();
            System.IO.File.WriteAllText(filename, CompressedString);
        }
Beispiel #22
0
        private bool SaveFile(IFileable dest)
        {
            if (dest.FileInfo == null)
            {
                MessageBox.Show("저장 실패");
                return(false);
            }


            // Formatter 선택
            IFormatter formatter = mFormatters[dest.FileInfo.Extension];

            if (formatter.SaveFile(dest) == false)
            {
                // todo : file error logging
                return(false);
            }

            // todo : file status 변경 saved!

            return(true);
        }
 public void SaveFile(string fileName, IFileable callMeBackforDetails)
 {
     File = fileName;
     BaseForm.SaveFileEvent();
 }
Beispiel #24
0
 public FileDecoration(IFileable decorated, string filePath)
     : base(decorated)
 {
     Condition.Requires(filePath).IsNotNullOrEmpty();
     this.FilePath = filePath;
 }
Beispiel #25
0
 public override IDecorationOf <IFileable> ApplyThisDecorationTo(IFileable decorated)
 {
     return(new LockingFileDecoration(decorated, this.FilePath));
 }
Beispiel #26
0
 public static LockingFileDecoration LockingFiling(this IFileable decorated, string filePath)
 {
     Condition.Requires(decorated).IsNotNull();
     return(new LockingFileDecoration(decorated, filePath));
 }
Beispiel #27
0
 public bool SaveFile(IFileable f)
 {
     MessageBox.Show("미구현");
     return(false);
 }
Beispiel #28
0
 public FileDecoration(IFileable decorated, string filePath)
     : base(decorated)
 {
     Condition.Requires(filePath).IsNotNullOrEmpty();
     this.FilePath = filePath;
 }
 public override IDecorationOf<IFileable> ApplyThisDecorationTo(IFileable decorated)
 {
     return new LockingFileDecoration(decorated, this.FilePath);
 }
Beispiel #30
0
        //public void SaveGame(string filename, Game, callMeBackforDetails)
        //{
        //    Game.Save(filename, callMeBackforDetails);
        //}
        public void SaveFile(string fileName, IFileable callMeBackforDetails)
        {
            var mockObject = Game;

            Game.Save(fileName, mockObject);
        }