private void lvLayouts_SelectedIndexChanged(object sender, EventArgs e) { masterlayout = new LayoutFile(); foreach (int item in lvLayouts.SelectedIndices) { string FileName = lvLayouts.Items[item].Text; if (!masterlayout.FileLoaded) { masterlayout.FileName = FileName; } else { masterlayout.MergeFile(FileName); } } Summary.Clear(); foreach (DataRow dtarw in masterlayout.HouseItems.Rows) { Int64 itmid = (Int64)dtarw["ItemID"]; string itmnm = dtarw["ItemName"].ToString(); bool crated = (bool)dtarw["InCrate"]; AddSummaryItem(itmnm, itmid, crated); } lvItems.Items.Clear(); foreach (LayoutSummary item in Summary) { ListViewItem itm = new ListViewItem(item.ItemID.ToString()); itm.SubItems.Add(item.ItemName); itm.SubItems.Add(item.ItemCount.ToString("#,###")); itm.SubItems.Add(item.CratedCount.ToString("#,###")); lvItems.Items.Add(itm); } }
private void saveChangesOnlyAsToolStripMenuItem_Click(object sender, EventArgs e) { if (!layout.FileLoaded) { return; } LayoutFile original = new LayoutFile(); LayoutFile changes = new LayoutFile(); changes.FileName = layout.FileName; // Load File Properties changes.HouseItems.Clear(); original.FileName = layout.FileName; var Compare = from nrow in layout.HouseItems.AsEnumerable() join orow in original.HouseItems.AsEnumerable() on nrow.Field <Int32>("DatabaseID") equals orow.Field <Int32>("DatabaseID") where !(nrow.Field <decimal>("x") == orow.Field <decimal>("x") && nrow.Field <decimal>("y") == orow.Field <decimal>("y") && nrow.Field <decimal>("z") == orow.Field <decimal>("z") && nrow.Field <decimal>("Rotation") == orow.Field <decimal>("Rotation") && nrow.Field <decimal>("Pitch") == orow.Field <decimal>("Pitch") && nrow.Field <decimal>("Roll") == orow.Field <decimal>("Roll") && nrow.Field <decimal>("Scale") == orow.Field <decimal>("Scale") && nrow.Field <bool>("InCrate") == orow.Field <bool>("InCrate")) select nrow; Compare.CopyToDataTable(changes.HouseItems, LoadOption.PreserveChanges); if (changes.HouseItems.Rows.Count == 0) { MessageBox.Show("No Changes Detected"); return; } if (sd.ShowDialog(this) == DialogResult.Cancel) { return; } changes.SaveFile(sd.FileName); }
private void ScanFolders() { layoutfiles.Clear(); foreach (string folder in lstDirectories.Items) { foreach (string file in Directory.GetFiles(folder, "*.")) { using (StreamReader sr = new StreamReader(file)) { string firstline = sr.ReadLine(); sr.Close(); if (firstline == "6,Version Number") { LayoutFile LF = new LayoutFile(); LF.FileName = file; layoutfiles.Add(LF); } } } } FillList(); }
private void btnMirror_Click(object sender, EventArgs e) { if (cboMirrorPlane.SelectedIndex == 0 || cboMirrorPlane.SelectedIndex == 3 || cboMirrorPlane.SelectedIndex == 6) { MessageBox.Show("Please select a mirror direction"); return; } decimal PlaneThickness = Decimal.Parse(txtPlaneThick.Text); Placement.HouseItem[] Items = SelectedGridToItems(); List <Placement.HouseItem> MissingCrate = new List <Placement.HouseItem>(); decimal anchorpoint = 0; bool anchorset = false, rotate = chkMirrorRotate.Checked; decimal modifier = 1; // Find the anchor point that will be the "Mirror" plane. foreach (Placement.HouseItem Item in Items) { switch (cboMirrorPlane.SelectedIndex) { case 1: //- Mirror Items Upwards if (anchorset && anchorpoint < Item.z) { anchorpoint = Item.z; } if (!anchorset) { anchorpoint = Item.z; anchorset = true; } break; case 2: //- Mirror Items Downwards if (anchorset && anchorpoint > Item.z) { anchorpoint = Item.z; } if (!anchorset) { anchorpoint = Item.z; anchorset = true; } modifier = -1; break; case 4: //- Mirror Items to East if (anchorset && anchorpoint > Item.x) { anchorpoint = Item.x; } if (!anchorset) { anchorpoint = Item.x; anchorset = true; } modifier = -1; break; case 5: //- Mirror Items to West if (anchorset && anchorpoint < Item.x) { anchorpoint = Item.x; } if (!anchorset) { anchorpoint = Item.x; anchorset = true; } break; case 7: //- Mirror Items North if (anchorset && anchorpoint > Item.y) { anchorpoint = Item.y; } if (!anchorset) { anchorpoint = Item.y; anchorset = true; } modifier = -1; break; case 8: //- Mirror Items South if (anchorset && anchorpoint < Item.y) { anchorpoint = Item.y; } if (!anchorset) { anchorpoint = Item.y; anchorset = true; } break; } } // Mirror the items on the anchor for (int ItemNbr = 0; ItemNbr < Items.Length; ItemNbr++) { // Kick the item out of the crate if it's in crate. if (Items[ItemNbr].InCrate) { Items[ItemNbr].InCrate = false; } bool UseExistingRow = false; DataRow DR = null; if (chkMirrorCrate.Checked && layout.FindCrateItem(Items[ItemNbr].ItemID) != null) { // Use Existing Item DR = layout.FindCrateItem(Items[ItemNbr].ItemID); UseExistingRow = true; } else { // Clone the item MissingCrate.Add(Items[ItemNbr]); DR = layout.HouseItems.NewRow(); } DR["InCrate"] = Items[ItemNbr].InCrate; DR["ItemID"] = Items[ItemNbr].ItemID; DR["ItemName"] = Items[ItemNbr].ItemName; DR["Pitch"] = Items[ItemNbr].Pitch; DR["Roll"] = Items[ItemNbr].Roll; DR["Rotation"] = Items[ItemNbr].Rotation; DR["Scale"] = Items[ItemNbr].Scale; DR["x"] = Items[ItemNbr].x; DR["y"] = Items[ItemNbr].y; DR["z"] = Items[ItemNbr].z; switch (cboMirrorPlane.SelectedIndex) { case 1: //- Mirror Items Upwards // X/Y remains case 2: //- Mirror Items Downwards // X/Y remains DR["z"] = Items[ItemNbr].z + 2 * (Math.Abs(Items[ItemNbr].z - anchorpoint) + PlaneThickness) * modifier; if (rotate) { DR["Rotation"] = Items[ItemNbr].Rotation - 180; } if (rotate) { DR["Pitch"] = Items[ItemNbr].Pitch - 180; } if (rotate && Items[ItemNbr].Rotation == 0) { DR["Rotation"] = 180; } break; case 4: //- Mirror Items to East // Z/Y remains case 5: //- Mirror Items to West // Z/Y remains DR["x"] = Items[ItemNbr].x + 2 * (Math.Abs(Items[ItemNbr].x - anchorpoint) + PlaneThickness) * modifier; if (rotate) { DR["Rotation"] = 360 - Items[ItemNbr].Rotation; } if (rotate && Items[ItemNbr].Rotation == 0) { DR["Rotation"] = 180; } break; case 7: //- Mirror Items North // X/Z remains case 8: //- Mirror Items South // X/Z remains DR["y"] = Items[ItemNbr].y + 2 * (Math.Abs(Items[ItemNbr].y - anchorpoint) + PlaneThickness) * modifier; if (rotate) { DR["Rotation"] = 180 - Items[ItemNbr].Rotation; } if (rotate && Items[ItemNbr].Rotation == 0) { DR["Rotation"] = 180; } break; } mirrorPreAdd: if (!UseExistingRow) { DR["DatabaseID"] = ClonedHouseItemDBId; ClonedHouseItemDBId--; try { layout.HouseItems.Rows.Add(DR); } catch { goto mirrorPreAdd; } } else { DR["InCrate"] = false; } } if (chkMirrorCrate.Checked && MissingCrate.Count > 0) { DialogResult pr_missing = MessageBox.Show(this, "You had checked that you wanted to use items from the crate vs cloning. " + MissingCrate.Count.ToString() + " item(s) were not found in the crate.\r\n\r\nWould you like to see these items?", "Missing Items", MessageBoxButtons.YesNo); if (DialogResult.Yes == pr_missing) { LayoutFile LayoutMissing = new LayoutFile(); LayoutMissing.FileName = layout.FileName; LayoutMissing.HouseItems.Clear(); LayoutMissing.ItemstoDB(MissingCrate.ToArray()); LayoutMissing.SaveFile(layout.FileName + "_mirrored_items_missing_" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString("00") + DateTime.Now.Day.ToString("00") + DateTime.Now.Hour.ToString("00") + DateTime.Now.Minute.ToString("00") + DateTime.Now.Second.ToString("00")); LayoutMissing.ManifestGenerate(false, true); string HTMLOutPath = LayoutMissing.FileName + ".html"; pr_missing = MessageBox.Show(this, "An HTML manifest generated of the missing items. This will be opened after this dialog.\r\n\r\nLayout editor has also created a layout file of just what couldn't be replicated. Do you want to keep this new layout file for reference?", "Missing Items", MessageBoxButtons.YesNo); if (pr_missing == DialogResult.No) { File.Delete(LayoutMissing.FileName); } System.Diagnostics.Process.Start(HTMLOutPath); } } if (Chart.Visible) { Chart.Redraw(); } }