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 { AddSystems(systems); } f.DialogResult = DialogResult.OK; f.Close(); }; f.Add(new ExtendedControls.ConfigurableForm.Entry("UC", null, "", new Point(5, 30), new Size(740, 200), null) { control = usc }); f.Add(new ExtendedControls.ConfigurableForm.Entry("Cancel", typeof(ExtendedControls.ExtButton), "Cancel".Tx(), new Point(650, 230), 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, 280), new Point(-999, -999), "Add Systems".Tx(this, "AddSys"), callback: () => { usc.Font = EDDTheme.Instance.GetFontStandardFontSize(); usc.Init(0, "ExplorationFindSys", false, discoveryform); }); usc.Closing(); }
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:".Tx(this, "FW"), 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%)".Tx(this, "TTF")) { numberboxdoubleminimum = 0, numberboxdoublemaximum = 100, numberboxformat = "0.##" }); f.Add(new ExtendedControls.ConfigurableForm.Entry("OK", typeof(ExtendedControls.ExtButton), "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.ExtButton), "Cancel".Tx(), new Point(width - 200, 70), new Size(80, 24), "Press to Cancel".Tx(this))); 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".Tx(this, "NValid"), "Warning".Tx(), MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (controlname == "Cancel") { f.DialogResult = DialogResult.Cancel; f.Close(); } }; DialogResult res = f.ShowDialogCentred(this.FindForm(), this.FindForm().Icon, "Ship Configure".Tx(this, "SC")); if (res == DialogResult.OK) { last_si.FuelWarningPercent = f.GetDouble("FuelWarning").Value; Display(); } }
// Present a menu to ask how much data to download.. public static Tuple <string, string> SelectGalaxyMenu(Form parent) { ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm(); 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".T(EDTx.GalaxySectorSelect_GALSELEX), new Point(10, 30), new Size(width - 50, 70), "")); f.Add(new ExtendedControls.ConfigurableForm.Entry("L", typeof(Label), "Select:".T(EDTx.GalaxySectorSelect_Select), 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".T(EDTx.GalaxySectorSelect_GALSELEN), list)); f.Add(new ExtendedControls.ConfigurableForm.Entry("OK", typeof(ExtendedControls.ExtButton), "OK".T(EDTx.OK), new Point(width - 40 - 80, 150), new Size(80, 24), "Press to Accept".T(EDTx.GalaxySectorSelect_PresstoAccept))); f.Trigger += (dialogname, controlname, tag) => { if (controlname == "OK") { f.DialogResult = DialogResult.OK; f.Close(); } }; DialogResult res = f.ShowDialogCentred(parent, parent.Icon, "Select EDSM Galaxy Data".T(EDTx.GalaxySectorSelect_GALSELTitle)); string sel = f.Get("Entry"); int index = DefaultGalaxyOptions.FindIndex((x) => { return(x.Item1 == sel); }); return(DefaultGalaxyOptions[index]); }
private void setRouteToolStripMenuItem_Click(object sender, EventArgs e) { ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm(); var routes = SavedRouteClass.GetAllSavedRoutes(); var routenames = (from x in routes select x.Name).ToList(); f.Add(new ExtendedControls.ConfigurableForm.Entry("Route", "", new Point(10, 40), new Size(400, 24), "Select route", routenames, new Size(400, 400))); f.Add(new ExtendedControls.ConfigurableForm.Entry("Cancel", typeof(ExtendedControls.ButtonExt), "Cancel", new Point(410 - 100, 80), new Size(100, 24), "Press to Cancel")); f.Trigger += (dialogname, controlname, tag) => { if (controlname != "Route") { f.DialogResult = DialogResult.Cancel; } else { f.DialogResult = DialogResult.OK; } f.Close(); }; if (f.ShowDialog(this.FindForm(), this.FindForm().Icon, new Size(430, 120), new Point(-999, -999), "Enter route") == DialogResult.OK) { string routename = f.Get("Route"); currentRoute = routes.Find(x => x.Name.Equals(routename)); // not going to be null, but consider the upset. // currentRoute.TestHarness(); // enable for debug if (currentRoute != null) { SQLiteDBClass.PutSettingString(DbSave + "SelectedRoute", currentRoute.Id.ToStringInvariant()); // write ID back } Display(); } }
public static void ShowScanOrMarketForm(Form parent, Object tag, bool checkedsm, HistoryList hl) // tag can be a Isystem or an He.. output depends on it. { Type ty = typeof(ScanDisplayForm); if (tag == null) { return; } ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm(); int width = Math.Max(250, parent.Width * 4 / 5); int height = 800; HistoryEntry he = tag as HistoryEntry; // is tag HE? ISystem sys = he != null ? he.System : tag as ISystem; // if so, sys is he.system, else its a direct sys ScanDisplayControl sd = null; string title = "System".Tx(ty, "Sys") + ": " + sys.Name; if (he != null && (he.EntryType == JournalTypeEnum.Market || he.EntryType == JournalTypeEnum.EDDCommodityPrices)) // station data.. { JournalCommodityPricesBase jm = he.journalEntry as JournalCommodityPricesBase; jm.FillInformation(out string info, out string detailed, 1); f.Add(new ExtendedControls.ConfigurableForm.Entry("RTB", typeof(ExtendedControls.ExtRichTextBox), detailed, new Point(0, 40), new Size(width - 20, height - 85), null)); title += ", " + "Station".Tx(ty) + ": " + jm.Station; } else { sd = new ScanDisplayControl(); sd.CheckEDSM = checkedsm; sd.ShowMoons = sd.ShowMaterials = sd.ShowOverlays = true; sd.SetSize(48); sd.Size = new Size(width - 20, 1024); sd.DrawSystem(sys, null, hl); height = Math.Min(800, Math.Max(400, sd.DisplayAreaUsed.Y)) + 100; f.Add(new ExtendedControls.ConfigurableForm.Entry("Sys", null, null, new Point(0, 40), new Size(width - 20, height - 85), null) { control = sd }); } f.Add(new ExtendedControls.ConfigurableForm.Entry("OK", typeof(ExtendedControls.ExtButton), "OK".Tx(), new Point(width - 20 - 80, height - 40), new Size(80, 24), "")); f.Trigger += (dialogname, controlname, ttag) => { if (controlname == "OK" || controlname == "Cancel") { f.Close(); } }; f.Init(parent.Icon, new Size(width, height), new Point(-999, -999), title, null, null); f.Show(parent); }
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:".T(EDTx.SurfaceBookmarkUserControl_PL), new Point(10, 40), new Size(140, 24), "")); f.Add(new ExtendedControls.ConfigurableForm.Entry("Planet", typeof(ExtendedControls.ExtTextBox), "", new Point(ctrlleft, 40), new Size(width - ctrlleft - 20, 24), "Enter planet name".T(EDTx.SurfaceBookmarkUserControl_EPN))); f.Add(new ExtendedControls.ConfigurableForm.Entry("OK", typeof(ExtendedControls.ExtButton), "OK".T(EDTx.OK), new Point(width - 100, 70), new Size(80, 24), "Press to Accept".T(EDTx.SurfaceBookmarkUserControl_PresstoAccept))); f.Add(new ExtendedControls.ConfigurableForm.Entry("Cancel", typeof(ExtendedControls.ExtButton), "Cancel".T(EDTx.Cancel), new Point(width - 200, 70), new Size(80, 24), "Press to Cancel".T(EDTx.SurfaceBookmarkUserControl_PresstoCancel))); 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.ShowDialogCentred(this.FindForm(), this.FindForm().Icon, "Manually Add Planet".T(EDTx.SurfaceBookmarkUserControl_MAP)); string pname = f.Get("Planet"); if (res == DialogResult.OK && pname.HasChars()) { if (!BodyName.Items.Contains(pname)) { BodyName.Items.Add(pname); } } }
// 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 - 30, 60), "")); 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 - 20, 24), "Enter number to jump to or near to".Tx(t, "GALSELEN"), list)); f.Add(new ExtendedControls.ConfigurableForm.Entry("OK", typeof(ExtendedControls.ButtonExt), "OK".Tx(), new Point(width - 20 - 80, 140), 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]); }
public static void ShowScanOrMarketForm(Form parent, Object tag, bool checkedsm, HistoryList hl) // tag can be a Isystem or an He.. output depends on it. { if (tag == null) { return; } ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm(); Size infosize = parent.SizeWithinScreen(new Size(parent.Width * 2 / 4, parent.Height * 2 / 4), 128, 128 + 100); // go for this, but allow this around window int topmargin = 40; HistoryEntry he = tag as HistoryEntry; // is tag HE? ISystem sys = he != null ? he.System : tag as ISystem; // if so, sys is he.system, else its a direct sys ScanDisplayUserControl sd = null; string title = "System".T(EDTx.ScanDisplayForm_Sys) + ": " + sys.Name; AutoScaleMode asm = AutoScaleMode.Font; if (he != null && (he.EntryType == JournalTypeEnum.Market || he.EntryType == JournalTypeEnum.EDDCommodityPrices)) // station data.. { JournalCommodityPricesBase jm = he.journalEntry as JournalCommodityPricesBase; jm.FillInformation(out string info, out string detailed, 1); f.Add(new ExtendedControls.ConfigurableForm.Entry("RTB", typeof(ExtendedControls.ExtRichTextBox), detailed, new Point(0, topmargin), infosize, null)); title += ", " + "Station".T(EDTx.ScanDisplayForm_Station) + ": " + jm.Station; } else { sd = new ScanDisplayUserControl(); sd.CheckEDSM = checkedsm; sd.ShowMoons = sd.ShowMaterials = sd.ShowOverlays = true; int selsize = (int)(EDDTheme.Instance.GetFont.Height / 16.0f * 48.0f); sd.SetSize(selsize); sd.Size = infosize; StarScan.SystemNode data = sd.FindSystem(sys, hl); if (data != null) { long value = data.ScanValue(sd.CheckEDSM); title += " ~ " + value.ToString("N0") + " cr"; } sd.BackColor = EDDTheme.Instance.Form; sd.DrawSystem(data, null, hl); infosize = new Size(Math.Max(400, sd.DisplayAreaUsed.X), Math.Max(200, sd.DisplayAreaUsed.Y)); asm = AutoScaleMode.None; // because we are using a picture box, it does not autoscale, so we can't use that logic on it. f.Add(new ExtendedControls.ConfigurableForm.Entry("Sys", null, null, new Point(0, topmargin), infosize, null) { control = sd }); } f.Add(new ExtendedControls.ConfigurableForm.Entry("OK", typeof(ExtendedControls.ExtButton), "OK".T(EDTx.OK), new Point(infosize.Width - 120, topmargin + infosize.Height + 10), new Size(100, 24), "")); f.Trigger += (dialogname, controlname, ttag) => { if (controlname == "OK" || controlname == "Cancel") { f.Close(); } }; f.InitCentred(parent, parent.Icon, title, null, null, asm); f.Show(parent); }
public override bool ExecuteAction(ActionProgramRun ap) { string exp; if (ap.functions.ExpandString(UserData, out exp) != ConditionFunctions.ExpandResult.Failed) { StringParser sp = new StringParser(exp); string handle = sp.NextWordComma(); if (handle != null) { bool infile = ap.actionfile.dialogs.ContainsKey(handle); bool inlocal = ap.dialogs.ContainsKey(handle); ExtendedControls.ConfigurableForm f = infile ? ap.actionfile.dialogs[handle] : (inlocal ? ap.dialogs[handle] : null); string cmd = sp.NextWord(lowercase: true); if (cmd == null) { ap.ReportError("Missing command in DialogControl"); } else if (cmd.Equals("exists")) { ap["Exists"] = (f != null) ? "1" : "0"; } else if (f == null) { ap.ReportError("No such dialog exists in DialogControl"); } else if (cmd.Equals("continue")) { return((inlocal) ? false : true); // if local, pause. else just ignore } else if (cmd.Equals("position")) { ap["X"] = f.Location.X.ToStringInvariant(); ap["Y"] = f.Location.Y.ToStringInvariant(); } else if (cmd.Equals("get")) { string control = sp.NextWord(); string r; if (control != null && (r = f.Get(control)) != null) { ap["DialogResult"] = r; } else { ap.ReportError("Missing or invalid dialog name in DialogControl get"); } } else if (cmd.Equals("set")) { string control = sp.NextWord(" ="); string value = sp.IsCharMoveOn('=') ? sp.NextQuotedWord() : null; if (control != null && value != null) { if (!f.Set(control, value)) { ap.ReportError("Cannot set control " + control + " in DialogControl set"); } } else { ap.ReportError("Missing or invalid dialog name and/or value in DialogControl set"); } } else if (cmd.Equals("close")) { f.Close(); if (inlocal) { ap.dialogs.Remove(handle); } else { ap.actionfile.dialogs.Remove(handle); } } else { ap.ReportError("Unknown command in DialogControl"); } } else { ap.ReportError("Missing handle in DialogControl"); } } else { ap.ReportError(exp); } return(true); }
void ShowScanPopOut(Object tag) // tag can be a Isystem or an He.. output depends on it. { if (tag == null) { return; } ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm(); int width = Math.Max(250, this.FindForm().Width * 4 / 5); int height = 800; HistoryEntry he = tag as HistoryEntry; ISystem sys = SysFrom(tag); ScanDisplay sd = null; string title = "System".Tx(this, "Sys") + ": " + sys.Name; if (he != null && (he.EntryType == JournalTypeEnum.Market || he.EntryType == JournalTypeEnum.EDDCommodityPrices)) // station data.. { JournalCommodityPricesBase jm = he.journalEntry as JournalCommodityPricesBase; jm.FillInformation(out string info, out string detailed, 1); f.Add(new ExtendedControls.ConfigurableForm.Entry("RTB", typeof(ExtendedControls.RichTextBoxScroll), detailed, new Point(0, 40), new Size(width - 20, height - 85), null)); title += ", " + "Station".Tx(this) + ": " + jm.Station; } else { // default is the scan display output sd = new ScanDisplay(); sd.CheckEDSM = CheckEDSM; sd.ShowMoons = sd.ShowMaterials = sd.ShowOverlays = true; sd.SetSize(48); sd.Size = new Size(width - 20, 1024); sd.DrawSystem(sys, null, discoveryform.history); height = Math.Min(800, Math.Max(400, sd.DisplayAreaUsed.Y)) + 100; f.Add(new ExtendedControls.ConfigurableForm.Entry("Sys", null, null, new Point(0, 40), new Size(width - 20, height - 85), null) { control = sd }); } f.Add(new ExtendedControls.ConfigurableForm.Entry("OK", typeof(ExtendedControls.ButtonExt), "OK".Tx(), new Point(width - 20 - 80, height - 40), new Size(80, 24), "")); f.Trigger += (dialogname, controlname, ttag) => { if (controlname == "OK" || controlname == "Cancel") { f.Close(); } }; f.Init(this.FindForm().Icon, new Size(width, height), new Point(-999, -999), title, null, null); if (sd != null) { sd.DrawSystem(sys, null, discoveryform.history); } f.Show(this.FindForm()); }