public override void Export(DesignData design) { string filename = GetExportFileName(design.Name); if (filename.Length > 0) { if (!design.IsLoaded) { design.Load(); } using (StreamWriter sw = new StreamWriter(filename, false)) { sw.WriteLine("6 version"); sw.WriteLine("1 template id"); sw.WriteLine("-1 item version"); sw.WriteLine("{0} num components", design.Items.Count); for (int i = 0; i < design.Items.Count; ++i) { DesignItem item = design.Items[i]; sw.WriteLine("{0} {1} {2} {3} 1", item.ItemID, item.X, item.Y, item.Z); } } } }
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(); } }
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)); } }
private void OpenDesignPreview(DesignData design) { Cursor.Current = Cursors.WaitCursor; if (!design.IsLoaded) { design.Load(); } Cursor.Current = Cursors.Default; new DesignPreview().LoadForm(new HouseDesign(design)); }
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(); } }
public HouseDesign(DesignData fileHeader) { m_FileHeader = fileHeader; m_Name = fileHeader.Name; m_Category = fileHeader.Category; m_SubSection = fileHeader.Subsection; m_Width = fileHeader.Width; m_Height = fileHeader.Height; m_UserWidth = fileHeader.UserWidth; m_UserHeight = fileHeader.UserHeight; m_Components = null; Clear(); if (fileHeader == null) { return; } if (!m_FileHeader.IsLoaded) { m_FileHeader.Load(); } for (int i = 0; i < fileHeader.Items.Count; ++i) { DesignItem item = fileHeader.Items[i]; HouseComponent hc = new HouseComponent(item.ItemID, item.Z); hc.Hue = item.Hue; m_Components[item.X][item.Y][GetZLevel(item.Z)].Add(hc); } Sort(); // unload design items to conserve memory m_FileHeader.Unload(); }
private void btnBuild_Click(object sender, System.EventArgs e) { if (!_design.IsLoaded) { _design.Load(); } DesignItemCol items = GetFilteredItems(_design.Items, _foundation, !_defaultHues); BuildResponse response = Connection.BuildDesign(items); _design.Unload(); if (response == null || response.Count == 0) { moveItemControl1.Enabled = false; } else { _serials = response.ItemSerials; moveItemControl1.Enabled = true; } }