Exemple #1
0
        private void mnuShopping_ItemClick(object sender, EventArgs e)
        {
            ToolStripMenuItem Clicked     = (ToolStripMenuItem)sender;
            string            CSVOutPath  = layout.FileName + "_manifest.csv";
            string            HTMLOutPath = layout.FileName + ".html";

            switch (Clicked.Name)
            {
            case "mnuShopCSV":
                layout.ManifestGenerate(true, false);
                if (MessageBox.Show("CSV file created as" + Environment.NewLine + CSVOutPath + Environment.NewLine + Environment.NewLine + "Open Now?", "File Created", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    System.Diagnostics.Process.Start(CSVOutPath);
                }
                break;

            case "mnuShopHTML":
                layout.ManifestGenerate(false, true);
                if (MessageBox.Show("HTML file created as" + Environment.NewLine + HTMLOutPath + Environment.NewLine + Environment.NewLine + "Open Now?", "File Created", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    System.Diagnostics.Process.Start(HTMLOutPath);
                }
                break;

            case "mnuShopBoth":
                layout.ManifestGenerate(true, true);
                if (MessageBox.Show("CSV file created as" + Environment.NewLine + CSVOutPath + Environment.NewLine + Environment.NewLine + "Open Now?", "File Created", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    System.Diagnostics.Process.Start(CSVOutPath);
                }
                if (MessageBox.Show("HTML file created as" + Environment.NewLine + HTMLOutPath + Environment.NewLine + Environment.NewLine + "Open Now?", "File Created", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    System.Diagnostics.Process.Start(HTMLOutPath);
                }
                break;

            default:
                break;
            }
        }
Exemple #2
0
        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();
            }
        }