예제 #1
0
        public override void Export(DesignData design)
        {
            string filename = Utility.GetSaveFileName("(*.mlt)|*.mlt", "Multi Data File", "");

            if (filename.Length > 0)
            {
                if (!design.IsLoaded)
                {
                    design.Load();
                }

                int zoffset = CalculateMinZ(design.Items);

                BinaryFileWriter writer = new BinaryFileWriter(File.Open(filename, FileMode.Create, FileAccess.Write, FileShare.None));

                for (int i = 0; i < design.Items.Count; ++i)
                {
                    DesignItem item = design.Items[i];

                    writer.WriteShort(item.ItemID);
                    writer.WriteShort((short)item.X);
                    writer.WriteShort((short)item.Y);
                    writer.WriteShort((short)(item.Z - zoffset));
                    writer.WriteShort(1);
                    writer.WriteShort(item.Hue);
                }

                writer.Close();
            }
        }
예제 #2
0
        public void ExportDesigns(ArrayList designs, string defaultFile)
        {
            if (designs.Count == 0)
            {
                return;
            }

            string filename = GetExportFileName(defaultFile);

            if (filename.Length > 0)
            {
                BinaryFileWriter writer = new BinaryFileWriter(File.Open(filename, FileMode.Create, FileAccess.Write, FileShare.None));

                // write file version
                writer.WriteShort(EXPORT_VERSION);
                // writer design count
                writer.WriteShort((short)designs.Count);

                for (int i = 0; i < designs.Count; ++i)
                {
                    DesignData design = (DesignData)designs[i];

                    if (!design.IsLoaded)
                    {
                        design.Load();
                    }

                    ExportDesign(design, writer);
                    design.Unload();
                }

                writer.Close();
                System.Windows.Forms.MessageBox.Show(string.Format("{0} designs were exported.", designs.Count));
            }
        }
예제 #3
0
        public override void Export(DesignData design)
        {
            string filename = GetExportFileName(design.Name);

            if (filename.Length > 0)
            {
                if (!design.IsLoaded)
                {
                    design.Load();
                }

                BinaryFileWriter writer = new BinaryFileWriter(File.Open(filename, FileMode.Create, FileAccess.Write, FileShare.None));

                writer.WriteShort(EXPORT_VERSION);
                writer.WriteString(design.Name);
                writer.WriteString(design.Category);
                writer.WriteString(design.Subsection);
                writer.WriteInt(design.Width);
                writer.WriteInt(design.Height);
                writer.WriteInt(design.UserWidth);
                writer.WriteInt(design.UserHeight);

                // item count
                writer.WriteInt(design.Items.Count);

                for (int i = 0; i < design.Items.Count; ++i)
                {
                    DesignItem item = design.Items[i];

                    writer.WriteShort(item.ItemID);
                    writer.WriteShort((short)item.X);
                    writer.WriteShort((short)item.Y);
                    writer.WriteShort((short)item.Z);
                    writer.WriteShort(item.Level);
                    writer.WriteShort(item.Hue);
                }

                writer.Close();
            }
        }
예제 #4
0
        private static void WriteHeaderFile()
        {
            BinaryFileWriter writer = new BinaryFileWriter(File.Open(TMP_INDEX_FILE, FileMode.Create, FileAccess.Write, FileShare.None));

            writer.WriteInt(m_DesignHeaders.Count);          // count
            writer.WriteInt(INDEX_FILE_VERSION);             // file version

            for (int i = 0; i < m_DesignHeaders.Count; ++i)
            {
                DesignData header = (DesignData)m_DesignHeaders[i];

                writer.WriteString(header.Name);
                writer.WriteString(header.Category);
                writer.WriteString(header.Subsection);
                writer.WriteInt(header.Width);
                writer.WriteInt(header.Height);
                writer.WriteInt(header.UserWidth);
                writer.WriteInt(header.UserHeight);
                writer.WriteLong(header.FilePosition);
                writer.WriteInt(header.RecordCount);
            }

            writer.Close();
        }
예제 #5
0
        private static void WriteBinFile()
        {
            bool             fileExists = File.Exists(BIN_FILE);
            BinaryFileWriter binWriter  = new BinaryFileWriter(File.Open(TMP_BIN_FILE, FileMode.Create, FileAccess.Write, FileShare.None));

            if (fileExists)
            {
                BinaryFileReader oldBinReader = new BinaryFileReader(File.Open(BIN_FILE, FileMode.Open, FileAccess.Read, FileShare.None));
                WriteSavedComponentData(oldBinReader, binWriter);
                oldBinReader.Close();
            }

            foreach (DesignData unsavedDesign in m_UnsavedDesigns)
            {
                unsavedDesign.FilePosition = binWriter.Position;
                unsavedDesign.RecordCount  = unsavedDesign.Items.Count;
                WriteUpdatedDesignComponentData(unsavedDesign.Items, binWriter);
                m_DesignHeaders.Add(unsavedDesign);
            }

            m_UnsavedDesigns.Clear();

            binWriter.Close();
        }