Beispiel #1
0
 public void SetEfaMode(FrmModel model)
 {
     FrameListView.Clear();
     ImportImage = null;
     Model       = model;
     importSettingsControl1.SetOriginalImage(null);
 }
Beispiel #2
0
        private void MnAdd_Click(object sender, System.EventArgs e)
        {
            FrmModel win = new FrmModel(false, new Framework.Entity.Model());

            win.RefreshIntance += new Framework.Interface.Content.FrmModel.RefreshHandle(RefreshList);
            win.ShowDialog();
        }
Beispiel #3
0
 public void SaveToEfa(string fileName, FrmModel model)
 {
     using (var stream = File.OpenWrite(fileName))
     {
         SaveToEfa(stream, model, true);
     }
 }
        public static FrmModel ConvertToModel(FrmFileData info, Palette palette)
        {
            var result = new FrmModel
            {
                Version     = (int)info.Version,
                ActionFrame = info.ActionFrame,
                Fps         = info.Fps,
                FrameCountInEachDirection = info.FrameCountInEachDirection,
            };

            var frameDirs = GetFrames(info, palette).Batch(result.FrameCountInEachDirection).ToList();

            for (int i = 0; i < frameDirs.Count; i++)
            {
                var direction = (FrmDirectionType)i;
                var frameDir  = new FrmDirectionModel
                {
                    Shift            = new RVector2(info.XShiftPerDirection[i], info.YShiftPerDirection[i]),
                    FirtsFrameOffset = (int)info.FirstFrameOffsetPerDirection[i],
                    Frames           = frameDirs[i].ToList()
                };

                result.Directions.Add(direction, frameDir);
            }

            return(result);
        }
Beispiel #5
0
 private void MnModify_Click(object sender, System.EventArgs e)
 {
     Framework.Entity.Model model = (Framework.Entity.Model)AdvTree.SelectedNode.Tag;
     FrmModel win = new FrmModel(true, model);
     win.RefreshIntance += new Framework.Interface.Content.FrmModel.RefreshHandle(RefreshList);
     win.ShowDialog();
 }
Beispiel #6
0
 public void SaveToFrm(string fileName, FrmModel model)
 {
     using (var stream = File.Open(fileName, FileMode.Create))
     {
         SaveToFrm(stream, model);
     }
 }
Beispiel #7
0
        private void MnModify_Click(object sender, System.EventArgs e)
        {
            Framework.Entity.Model model = (Framework.Entity.Model)AdvTree.SelectedNode.Tag;
            FrmModel win = new FrmModel(true, model);

            win.RefreshIntance += new Framework.Interface.Content.FrmModel.RefreshHandle(RefreshList);
            win.ShowDialog();
        }
Beispiel #8
0
 public void SaveToFrm(Stream stream, FrmModel model)
 {
     try
     {
         var data = FrmConverter.ConvertToData(model);
         FrmParser.SaveTo(stream, data);
     }
     catch (Exception e)
     {
         throw new Exception("Exception occured when saving model as FRM.", e);
     }
 }
        public static FrmFileData ConvertToData(FrmModel model)
        {
            var result = new FrmFileData
            {
                Version     = (uint)model.Version,
                ActionFrame = (ushort)model.ActionFrame,
                Fps         = (ushort)model.Fps,
                FrameCountInEachDirection    = (ushort)model.FrameCountInEachDirection,
                XShiftPerDirection           = new ushort[FrmParser.DirCount],
                YShiftPerDirection           = new ushort[FrmParser.DirCount],
                FirstFrameOffsetPerDirection = new uint[FrmParser.DirCount]
            };

            foreach (var dir in model.Directions)
            {
                var dirIdx = (int)dir.Key;
                result.XShiftPerDirection[dirIdx]           = (ushort)dir.Value.Shift.x;
                result.YShiftPerDirection[dirIdx]           = (ushort)dir.Value.Shift.y;
                result.FirstFrameOffsetPerDirection[dirIdx] = (uint)dir.Value.FirtsFrameOffset;
            }

            var frames = model.Directions.OrderBy(x => x.Key).SelectMany(x => x.Value.Frames);

            foreach (var frame in frames)
            {
                var rframe = new FrameData
                {
                    FrameWidth       = (ushort)frame.Width,
                    FrameHeight      = (ushort)frame.Height,
                    FrameSize        = (uint)(frame.Width * frame.Height),
                    XOffset          = (short)frame.Offset.x,
                    YOffset          = (short)frame.Offset.y,
                    PixelIndexFrames = ImageHelper.GetPaletteIndexes(frame.Bitmap)
                };

                result.Frames.Add(rframe);
            }
            return(result);
        }
Beispiel #10
0
        public FrmModel ImportFrom(Bitmap img)
        {
            var model = new FrmModel
            {
                Fps = 1,
                FrameCountInEachDirection = 1,
                Version = 1
            };

            model.Directions.Add(FrmDirectionType.A, new FrmDirectionModel
            {
                Frames = new List <FrameModel>
                {
                    new FrameModel
                    {
                        Bitmap = img,
                        Id     = 1
                    }
                }
            });
            return(model);
        }
Beispiel #11
0
        public void SaveToEfa(Stream stream, FrmModel model, bool leaveOpen)
        {
            try
            {
                using (var archive = new ZipArchive(stream, ZipArchiveMode.Create, true))
                {
                    foreach (var dir in model.Directions)
                    {
                        foreach (var frame in dir.Value.Frames)
                        {
                            var name = string.Format(@"{0}/{1}.bmp", dir.Key, frame.Id);
                            var file = archive.CreateEntry(name);
                            using (var entryStream = file.Open())
                            {
                                frame.Bitmap.Save(entryStream, ImageFormat.Bmp);
                            }
                        }
                    }

                    using (var entryStream = archive.CreateEntry(ManifestName).Open())
                    {
                        using (var writer = new StreamWriter(entryStream))
                        {
                            using (var jsonWriter = new JsonTextWriter(writer))
                            {
                                var ser = GetSerializer();
                                ser.Serialize(jsonWriter, model);
                                jsonWriter.Flush();
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw new Exception("Exception occured when saving model as EFA.", e);
            }
        }
Beispiel #12
0
 private void MnAdd_Click(object sender, System.EventArgs e)
 {
     FrmModel win = new FrmModel(false, new Framework.Entity.Model());
     win.RefreshIntance += new Framework.Interface.Content.FrmModel.RefreshHandle(RefreshList);
     win.ShowDialog();
 }