private void buttonExtConfigure_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Debug.Assert(last_si != null);           // must be set for this configure button to be visible

            ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm();

            int width    = 430;
            int ctrlleft = 150;

            f.Add(new ExtendedControls.ConfigurableForm.Entry("L", typeof(Label), "Fuel Warning:", new Point(10, 40), new Size(140, 24), ""));
            f.Add(new ExtendedControls.ConfigurableForm.Entry("FuelWarning", typeof(ExtendedControls.NumberBoxDouble), last_si.FuelWarningPercent.ToStringInvariant(), new Point(ctrlleft, 40), new Size(width - ctrlleft - 20, 24), "Enter fuel warning level in % (0 = off, 1-100%)")
            {
                numberboxdoubleminimum = 0, numberboxdoublemaximum = 100, numberboxformat = "0.##"
            });

            f.Add(new ExtendedControls.ConfigurableForm.Entry("OK", typeof(ExtendedControls.ButtonExt), "OK", new Point(width - 100, 70), new Size(80, 24), "Press to Accept"));
            f.Add(new ExtendedControls.ConfigurableForm.Entry("Cancel", typeof(ExtendedControls.ButtonExt), "Cancel", new Point(width - 200, 70), new Size(80, 24), "Press to Cancel"));

            f.Trigger += (dialogname, controlname, tag) =>
            {
                if (controlname == "OK")
                {
                    double?v3 = f.GetDouble("FuelWarning");
                    if (v3.HasValue)
                    {
                        f.DialogResult = DialogResult.OK;
                        f.Close();
                    }
                    else
                    {
                        ExtendedControls.MessageBoxTheme.Show(this.FindForm(), "A Value is not valid", "Warning - Value", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else if (controlname == "Cancel")
                {
                    f.DialogResult = DialogResult.Cancel;
                    f.Close();
                }
            };

            DialogResult res = f.ShowDialog(this.FindForm(), this.FindForm().Icon, new Size(width, 110), new Point(-999, -999), "Ship Configure");

            if (res == DialogResult.OK)
            {
                last_si.FuelWarningPercent = f.GetDouble("FuelWarning").Value;
                Display();
            }
        }
示例#2
0
        private void addPlanetManuallyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm();

            int width    = 430;
            int ctrlleft = 150;

            f.Add(new ExtendedControls.ConfigurableForm.Entry("L", typeof(Label), "Planet:".Tx(this, "PL"), new Point(10, 40), new Size(140, 24), ""));
            f.Add(new ExtendedControls.ConfigurableForm.Entry("Planet", typeof(ExtendedControls.TextBoxBorder),
                                                              "", new Point(ctrlleft, 40), new Size(width - ctrlleft - 20, 24), "Enter planet name".Tx(this, "EPN")));

            f.Add(new ExtendedControls.ConfigurableForm.Entry("OK", typeof(ExtendedControls.ButtonExt), "OK".Tx(), new Point(width - 100, 70), new Size(80, 24), "Press to Accept".Tx(this)));
            f.Add(new ExtendedControls.ConfigurableForm.Entry("Cancel", typeof(ExtendedControls.ButtonExt), "Cancel".Tx(), new Point(width - 200, 70), new Size(80, 24), "Press to Cancel".Tx(this)));

            f.Trigger += (dialogname, controlname, tag) =>
            {
                if (controlname == "OK")
                {
                    f.DialogResult = DialogResult.OK;
                    f.Close();
                }
                else if (controlname == "Cancel")
                {
                    f.DialogResult = DialogResult.Cancel;
                    f.Close();
                }
            };

            DialogResult res = f.ShowDialog(this.FindForm(), this.FindForm().Icon, new Size(width, 110), new Point(-999, -999), "Manually Add Planet".Tx(this, "MAP"));

            string pname = f.Get("Planet");

            if (res == DialogResult.OK && pname.HasChars())
            {
                if (!BodyName.Items.Contains(pname))
                {
                    BodyName.Items.Add(pname);
                }
            }
        }
示例#3
0
        // Present a menu to ask how much data to download..

        public static Tuple <string, string> SelectGalaxyMenu(Form parent)
        {
            ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm();
            Type t = typeof(GalaxySectorSelect);

            var list = DefaultGalaxyOptions.Where(x => x.Item1 != "Custom" && x.Item1 != "Reset").Select(x => x.Item1).ToList();

            int width = 700;

            f.Add(new ExtendedControls.ConfigurableForm.Entry("L", typeof(Label), "ED Discovery downloads star data from EDSM/EDDB which is used to give you additional data.  Select how much data you want to store.  The more of the galaxy you select, the bigger the storage needed".Tx(t, "GALSELEX"),
                                                              new Point(10, 30), new Size(width - 50, 70), ""));
            f.Add(new ExtendedControls.ConfigurableForm.Entry("L", typeof(Label), "Select:".Tx(t), new Point(10, 100), new Size(160, 24), ""));
            f.Add(new ExtendedControls.ConfigurableForm.Entry("Entry", "All",
                                                              new Point(180, 100), new Size(width - 180 - 100, 24),
                                                              "Select the data set".Tx(t, "GALSELEN"), list));

            f.Add(new ExtendedControls.ConfigurableForm.Entry("OK", typeof(ExtendedControls.ExtButton), "OK".Tx(), new Point(width - 40 - 80, 150), new Size(80, 24), "Press to Accept".Tx(t)));

            //f.Add(new ExtendedControls.ConfigurableForm.Entry("Cancel", typeof(ExtendedControls.ButtonExt), "Cancel".Tx(), new Point(width - 200, 70), new Size(80, 24), "Press to Cancel".Tx(t)));

            f.Trigger += (dialogname, controlname, tag) =>
            {
                if (controlname == "OK")
                {
                    f.DialogResult = DialogResult.OK;
                    f.Close();
                }
            };

            DialogResult res = f.ShowDialog(parent, parent.Icon, new Size(width, 200), new Point(-999, -999), "Select EDSM Galaxy Data".Tx(t, "GALSELTitle"));

            string sel   = f.Get("Entry");
            int    index = DefaultGalaxyOptions.FindIndex((x) => { return(x.Item1 == sel); });

            return(DefaultGalaxyOptions[index]);
        }
        private void extPictureTrades_ClickElement(object sender, MouseEventArgs eventargs, ExtendedControls.ExtPictureBox.ImageElement i, object tag)
        {
            if (i != null && tag is ElementTrade && last_mcl != null)  // must be an element, with a tag, must have a current mcl
            {
                ElementTrade current = (ElementTrade)tag;
                System.Diagnostics.Debug.WriteLine("Clicked on " + current.type + " " + current.element.Name);

                if (selected != null)
                {
                    List <MaterialCommodityMicroResource> mcl = discoveryform.history.MaterialCommoditiesMicroResources.Get(last_mcl.Value);
                    int currenttotal = mcl.Find(x => x.Details == current.element)?.Count ?? 0;   // current mat total. If not there, its zero
                    foreach (var trade in tradelist)
                    {
                        if (trade.fromelement.FDName == current.element.FDName)
                        {
                            currenttotal -= trade.offer;                              // may go negative if over offered
                        }
                        if (trade.element.FDName == current.element.FDName)
                        {
                            currenttotal += trade.receive;
                        }
                    }

                    if (selected.element.FDName == current.element.FDName)        // clicked on same.. deselect
                    {
                        selected = null;
                    }
                    else if (currenttotal >= current.offer)                         // if we have enough for at least 1 trade
                    {
                        DisplayTradeSelection(current.element);

                        ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm();

                        int width  = 250;
                        int margin = 20;

                        var butl = new ExtendedControls.ExtButton();
                        butl.Image = BaseUtils.Icons.IconSet.GetIcon("Controls.MaterialTrader.LeftArrow");
                        f.Add(new ExtendedControls.ConfigurableForm.Entry(butl, "less", "", new Point(margin, 64), new Size(32, 32), null));
                        var butr = new ExtendedControls.ExtButton();
                        butr.Image = BaseUtils.Icons.IconSet.GetIcon("Controls.MaterialTrader.RightArrow");
                        f.Add(new ExtendedControls.ConfigurableForm.Entry(butr, "more", "", new Point(width - margin - 32, 64), new Size(32, 32), null));

                        f.Add(new ExtendedControls.ConfigurableForm.Entry("olabel", typeof(Label), "Offer".T(EDTx.UserControlMaterialTrader_Offer), new Point(margin, 30), new Size(width - margin * 2, 20), null, 1.5f, ContentAlignment.MiddleCenter));

                        f.Add(new ExtendedControls.ConfigurableForm.Entry("offer", typeof(Label), "0/" + currenttotal.ToStringInvariant(), new Point(width / 2 - 12, 50), new Size(width / 2 - 20, 20), null, 1.2f, ContentAlignment.MiddleLeft));

                        var bar = new PictureBox();
                        bar.SizeMode = PictureBoxSizeMode.StretchImage;
                        bar.Image    = BaseUtils.Icons.IconSet.GetIcon("Controls.MaterialTrader.TraderBar");
                        f.Add(new ExtendedControls.ConfigurableForm.Entry(bar, "bar", "", new Point(width / 2 - 32, 70), new Size(64, 16), null));

                        f.Add(new ExtendedControls.ConfigurableForm.Entry("receive", typeof(Label), "0", new Point(width / 2 - 12, 90), new Size(width / 2 - 20, 20), null, 1.2f, ContentAlignment.MiddleLeft));

                        f.Add(new ExtendedControls.ConfigurableForm.Entry("rlabel", typeof(Label), "Receive".T(EDTx.UserControlMaterialTrader_Receive), new Point(margin, 110), new Size(width - margin * 2, 20), null, 1.5f, ContentAlignment.MiddleCenter));

                        f.AddOK(new Point(width - margin - 80, 150), "Press to Accept".T(EDTx.UserControlModules_PresstoAccept));
                        f.AddCancel(new Point(margin, 150), "Press to Cancel".T(EDTx.UserControlModules_PresstoCancel));

                        int currentoffer   = 0;
                        int currentreceive = 0;

                        f.Trigger += (dialogname, controlname, xtag) =>
                        {
                            if (controlname == "OK")
                            {
                                f.ReturnResult(DialogResult.OK);
                            }
                            else if (controlname == "Cancel" || controlname == "Close")
                            {
                                f.ReturnResult(DialogResult.Cancel);
                            }
                            else if (controlname == "less" || controlname == "more")
                            {
                                if (controlname == "less")
                                {
                                    if (currentoffer > 0)
                                    {
                                        currentoffer   -= current.offer;
                                        currentreceive -= current.receive;
                                    }
                                }
                                else
                                {
                                    int newoffer = currentoffer + current.offer;
                                    if (newoffer <= currenttotal)
                                    {
                                        currentoffer    = newoffer;
                                        currentreceive += current.receive;
                                    }
                                }

                                f.GetControl <Label>("offer").Text   = currentoffer.ToStringInvariant() + "/" + currenttotal.ToStringInvariant();
                                f.GetControl <Label>("receive").Text = currentreceive.ToStringInvariant();
                            }
                        };

                        f.RightMargin = margin;

                        f.InitCentred(this.FindForm(), this.FindForm().Icon, " ", closeicon: true);

                        DialogResult res = f.ShowDialog();

                        if (res == DialogResult.OK)
                        {
                            ElementTrade t = new ElementTrade()
                            {
                                element = selected.element, fromelement = current.element, offer = currentoffer, receive = currentreceive
                            };
                            tradelist.Add(t);
                            selected = null;

                            StoreTrades();

                            DisplayTradeList();
                        }

                        DisplayTradeSelection();
                    }
                }
                else
                {
                    selected = current;
                }

                DisplayTradeSelection();
            }
        }
示例#5
0
        private void tsbAddSystems_Click(object sender, EventArgs e)
        {
            ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm();

            FindSystemsUserControl usc = new FindSystemsUserControl();

            usc.ReturnSystems = (List <Tuple <ISystem, double> > syslist) =>
            {
                List <String> systems      = new List <String>();
                int           countunknown = 0;
                foreach (Tuple <ISystem, double> ret in syslist)
                {
                    string name = ret.Item1.Name;

                    ISystem sc = SystemCache.FindSystem(name.Trim());
                    if (sc == null)
                    {
                        sc = new SystemClass(name.Trim());
                        countunknown++;
                    }
                    systems.Add(sc.Name);
                }

                if (systems.Count == 0)
                {
                    ExtendedControls.MessageBoxTheme.Show(FindForm(), "The imported file contains no known system names".Tx(this, "NoSys"),
                                                          "Warning".Tx(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    foreach (var sysname in systems)
                    {
                        dataGridViewExplore.Rows.Add(sysname, "", "");
                    }

                    UpdateSystemRows();
                }

                f.DialogResult = DialogResult.OK;
                f.Close();
            };

            f.Add(new ExtendedControls.ConfigurableForm.Entry("UC", null, "", new Point(5, 30), new Size(740, 150), null)
            {
                control = usc
            });
            f.Add(new ExtendedControls.ConfigurableForm.Entry("Cancel", typeof(ExtendedControls.ButtonExt), "Cancel".Tx(), new Point(650, 190), new Size(80, 24), ""));

            f.Trigger += (dialogname, controlname, tag) =>
            {
                if (controlname == "Cancel")
                {
                    f.DialogResult = DialogResult.Cancel;
                    f.Close();
                }
            };

            f.ShowDialog(this.FindForm(), this.FindForm().Icon, new Size(750, 240), new Point(-999, -999), "Add Systems".Tx(this, "AddSys"),
                         callback: () => { usc.Font = EDDTheme.Instance.GetFontStandardFontSize(); usc.Init(0, false, discoveryform); });
            usc.Closing();
        }
        private void extPictureTrades_ClickElement(object sender, MouseEventArgs eventargs, ExtendedControls.ExtPictureBox.ImageElement i, object tag)
        {
            if (i != null)
            {
                ElementTag e = (ElementTag)tag;
                System.Diagnostics.Debug.WriteLine("Clicked on " + e.type + " " + e.element.Name);

                if (selected != null)
                {
                    if (selected.element.FDName == e.element.FDName)        // clicked on same.. deselect
                    {
                        selected = null;
                    }
                    else
                    {
                        ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm();

                        int width  = 250;
                        int margin = 20;

                        var butl = new ExtendedControls.ExtButton();
                        butl.Image = EDDiscovery.Icons.IconSet.GetIcon("Controls.MaterialTrader.LeftArrow");
                        f.Add(new ExtendedControls.ConfigurableForm.Entry(butl, "left", "", new Point(margin, 64), new Size(32, 32), null));
                        var butr = new ExtendedControls.ExtButton();
                        butr.Image = EDDiscovery.Icons.IconSet.GetIcon("Controls.MaterialTrader.RightArrow");
                        f.Add(new ExtendedControls.ConfigurableForm.Entry(butr, "right", "", new Point(width - margin - 32, 64), new Size(32, 32), null));

                        f.Add(new ExtendedControls.ConfigurableForm.Entry("olabel", typeof(Label), "Offer".Tx(EDTx.UserControlMaterialTrader_Offer), new Point(margin, 30), new Size(width - margin * 2, 20), null, 1.5f, ContentAlignment.MiddleCenter));

                        f.Add(new ExtendedControls.ConfigurableForm.Entry("offer", typeof(Label), "0/0", new Point(width / 2 - 12, 50), new Size(width / 2 - 20, 20), null, 1.2f, ContentAlignment.MiddleLeft));

                        var bar = new PictureBox();
                        bar.SizeMode = PictureBoxSizeMode.StretchImage;
                        bar.Image    = EDDiscovery.Icons.IconSet.GetIcon("Controls.MaterialTrader.TraderBar");
                        f.Add(new ExtendedControls.ConfigurableForm.Entry(bar, "bar", "", new Point(width / 2 - 32, 70), new Size(64, 16), null));

                        f.Add(new ExtendedControls.ConfigurableForm.Entry("receive", typeof(Label), "0", new Point(width / 2 - 12, 90), new Size(width / 2 - 20, 20), null, 1.2f, ContentAlignment.MiddleLeft));

                        f.Add(new ExtendedControls.ConfigurableForm.Entry("rlabel", typeof(Label), "Receive".Tx(EDTx.UserControlMaterialTrader_Receive), new Point(margin, 110), new Size(width - margin * 2, 20), null, 1.5f, ContentAlignment.MiddleCenter));

                        f.Add(new ExtendedControls.ConfigurableForm.Entry("OK", typeof(ExtendedControls.ExtButton), "OK".T(EDTx.OK), new Point(width - margin - 80, 150), new Size(80, 24), "Press to Accept".T(EDTx.UserControlModules_PresstoAccept)));
                        f.Add(new ExtendedControls.ConfigurableForm.Entry("Cancel", typeof(ExtendedControls.ExtButton), "Cancel".T(EDTx.Cancel), new Point(margin, 150), new Size(80, 24), "Press to Cancel".T(EDTx.UserControlModules_PresstoCancel)));

                        f.Trigger += (dialogname, controlname, xtag) =>
                        {
                            if (controlname == "OK")
                            {
                                f.ReturnResult(DialogResult.OK);
                            }
                            else if (controlname == "Cancel")
                            {
                                f.ReturnResult(DialogResult.Cancel);
                            }
                            else if (controlname == "Less")
                            {
                            }
                            else if (controlname == "More")
                            {
                            }
                        };

                        f.RightMargin = margin;

                        f.InitCentred(this.FindForm(), this.FindForm().Icon, "Trade".T(EDTx.UserControlMaterialTrader_Trade));
                        //f.GetControl<Label>("offer").Font = new Font()

                        DialogResult res = f.ShowDialog();

                        if (res == DialogResult.OK)
                        {
                            Display();
                        }
                    }
                }
                else
                {
                    selected = e;
                }
                Display();
            }
        }