private void extCheckBoxStar_Click(object sender, EventArgs e) { if (extCheckBoxStar.Checked == true) { ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm(); int width = 500; f.Add(new ExtendedControls.ConfigurableForm.Entry("L", typeof(Label), "System:".T(EDTx.UserControlEDSM_System), new Point(10, 40), new Size(110, 24), null)); f.Add(new ExtendedControls.ConfigurableForm.Entry("Sys", typeof(ExtendedControls.ExtTextBoxAutoComplete), "", new Point(120, 40), new Size(width - 120 - 20, 24), null)); f.AddOK(new Point(width - 20 - 80, 80)); f.AddCancel(new Point(width - 200, 80)); f.Trigger += (dialogname, controlname, tag) => { if (controlname == "OK" || controlname == "Cancel" || controlname == "Close") { f.ReturnResult(controlname == "OK" ? DialogResult.OK : DialogResult.Cancel); } else if (controlname == "Sys:Return") { if (f.Get("Sys").HasChars()) { f.ReturnResult(DialogResult.OK); } f.SwallowReturn = true; } }; f.InitCentred(this.FindForm(), this.FindForm().Icon, "Show System".T(EDTx.UserControlEDSM_EnterSys), null, null, closeicon: true); f.GetControl <ExtendedControls.ExtTextBoxAutoComplete>("Sys").SetAutoCompletor(SystemCache.ReturnSystemAutoCompleteList, true); DialogResult res = f.ShowDialog(this.FindForm()); if (res == DialogResult.OK) { string sname = f.Get("Sys"); if (sname.HasChars()) { override_system = new EliteDangerousCore.SystemClass(sname); PresentSystem(override_system); extCheckBoxStar.Checked = true; } else { extCheckBoxStar.Checked = false; } } else { extCheckBoxStar.Checked = false; } } else { override_system = null; PresentSystem(last_sys); extCheckBoxStar.Checked = false; } }
public static async 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 * 6 / 8, parent.Height * 6 / 8), 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.. { he.FillInformation(out string info, out string detailed); f.Add(new ExtendedControls.ConfigurableForm.Entry("RTB", typeof(ExtendedControls.ExtRichTextBox), detailed, new Point(0, topmargin), infosize, null)); JournalCommodityPricesBase jm = he.journalEntry as JournalCommodityPricesBase; title += ", " + "Station".T(EDTx.ScanDisplayForm_Station) + ": " + jm.Station; } else { sd = new ScanDisplayUserControl(); sd.CheckEDSM = checkedsm; int selsize = (int)(EDDTheme.Instance.GetFont.Height / 16.0f * 48.0f); sd.SetSize(selsize); sd.Size = infosize; StarScan.SystemNode data = await hl.StarScan.FindSystemAsync(sys, sd.CheckEDSM); // look up system async if (data != null) { long value = data.ScanValue(sd.CheckEDSM); title += " ~ " + value.ToString("N0") + " cr"; } sd.BackColor = EDDTheme.Instance.Form; sd.DrawSystem(data, null, hl); int wastedh = infosize.Height - sd.DisplayAreaUsed.Y - 10 - 40; if (wastedh > 0) { infosize.Height -= wastedh; } 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.AddOK(new Point(infosize.Width - 120, topmargin + infosize.Height + 10)); f.Trigger += (dialogname, controlname, ttag) => { if (controlname == "OK") { f.ReturnResult(DialogResult.OK); } else if (controlname == "Close") { f.ReturnResult(DialogResult.Cancel); } }; f.InitCentred(parent, parent.Icon, title, null, null, asm, closeicon: true); f.Show(parent); }
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(); } }
public override bool ExecuteAction(ActionProgramRun ap) { List <string> ctrl = FromString(UserData); if (ctrl != null) { List <string> exp; if (ap.Functions.ExpandStrings(ctrl, out exp) != Functions.ExpandResult.Failed) { Variables cv = ap.variables.FilterVars(exp[3] + "*"); ExtendedControls.ConfigurableForm cd = new ExtendedControls.ConfigurableForm(); foreach (string k in cv.NameList) { string errmsg = cd.Add(cv[k]); if (errmsg != null) { return(ap.ReportError(errmsg + " in " + k + " variable for Dialog")); } } StringParser sp2 = new StringParser(exp[2]); int? dw = sp2.NextWordComma().InvariantParseIntNull(); int? dh = sp2.NextWordComma().InvariantParseIntNull(); int? x = sp2.NextWordComma().InvariantParseIntNull(); int? y = sp2.NextWordComma().InvariantParseIntNull(); int? mw = sp2.NextWordComma().InvariantParseIntNull(); int? mh = sp2.NextWordComma().InvariantParseIntNull(); if (dw != null && dh != null && ((x == null) == (y == null))) // need w/h, must have either no pos or both pos { bool closeicon = true, alwaysontop = false; for (int i = 4; i < exp.Count; i++) { if (exp[i].Equals("AllowResize", StringComparison.InvariantCultureIgnoreCase)) { cd.AllowResize = true; } else if (exp[i].Equals("Transparent", StringComparison.InvariantCultureIgnoreCase)) { cd.Transparent = true; } else if (exp[i].Equals("NoCloseIcon", StringComparison.InvariantCultureIgnoreCase)) { closeicon = false; } else if (exp[i].Equals("AlwaysOnTop", StringComparison.InvariantCultureIgnoreCase)) { alwaysontop = true; } else if (exp[i].Equals("NoWindowsBorder", StringComparison.InvariantCultureIgnoreCase)) { cd.ForceNoWindowsBorder = true; } else if (exp[i].Equals("NoPanelBorder", StringComparison.InvariantCultureIgnoreCase)) { cd.PanelBorderStyle = BorderStyle.None; } else if (exp[i].StartsWith("FontScale:", StringComparison.InvariantCultureIgnoreCase)) { cd.FontScale = exp[i].Substring(10).InvariantParseFloat(1.0f); } else { ap.ReportError("Unknown Dialog option " + exp[i]); return(true); } } if (IsModalDialog()) { ap.Dialogs[exp[0]] = cd; } else { ap.ActionFile.Dialogs[exp[0]] = cd; } cd.Trigger += Cd_Trigger; System.Drawing.Size minsize = new System.Drawing.Size(dw.Value, dh.Value); System.Drawing.Size maxsize = new System.Drawing.Size(mw.HasValue ? mw.Value : 50000, mh.HasValue ? mh.Value : 50000); if (x != null && y != null) { cd.Init(minsize, maxsize, new System.Drawing.Point(x.Value, y.Value), ap.ActionController.Icon, exp[1], exp[0], new List <Object>() { ap, IsModalDialog() }, // logical name and tag closeicon: closeicon ); } else { cd.InitCentred(ap.ActionController.Form, minsize, maxsize, ap.ActionController.Icon, exp[1], exp[0], new List <Object>() { ap, IsModalDialog() }, // logical name and tag closeicon: closeicon ); } cd.TopMost = alwaysontop; cd.Show(ap.ActionController.Form); return(!IsModalDialog()); // modal, return false, STOP. Non modal, continue } else { ap.ReportError("Width/Height and/or X/Y not specified correctly in Dialog"); } } else { ap.ReportError(exp[0]); } } else { ap.ReportError("Dialog command line not in correct format"); } return(true); }
public override bool ExecuteAction(ActionProgramRun ap) { List <string> ctrl = FromString(UserData); if (ctrl != null) { List <string> exp; if (ap.functions.ExpandStrings(ctrl, out exp) != Functions.ExpandResult.Failed) { Variables cv = ap.variables.FilterVars(exp[3] + "*"); ExtendedControls.ConfigurableForm cd = new ExtendedControls.ConfigurableForm(); foreach (string k in cv.NameList) { string errmsg = cd.Add(cv[k]); if (errmsg != null) { return(ap.ReportError(errmsg + " in " + k + " variable for Dialog")); } } StringParser sp2 = new StringParser(exp[2]); int? dw = sp2.NextWordComma().InvariantParseIntNull(); int? dh = sp2.NextWordComma().InvariantParseIntNull(); int? x = sp2.NextWordComma().InvariantParseIntNull(); int? y = sp2.NextWord().InvariantParseIntNull(); if (dw != null && dh != null && ((x == null) == (y == null))) // need w/h, must have either no pos or both pos { if (IsModalDialog()) { ap.dialogs[exp[0]] = cd; } else { ap.actionfile.dialogs[exp[0]] = cd; } cd.Trigger += Cd_Trigger; if (x != null && y != null) { cd.Init(new System.Drawing.Point(x.Value, y.Value), ap.actioncontroller.Icon, exp[1], exp[0], new List <Object>() { ap, IsModalDialog() }, // logical name and tag closeicon: true ); } else { cd.InitCentred(ap.actioncontroller.Form, ap.actioncontroller.Icon, exp[1], exp[0], new List <Object>() { ap, IsModalDialog() }, // logical name and tag closeicon: true ); } cd.Show(ap.actioncontroller.Form); return(!IsModalDialog()); // modal, return false, STOP. Non modal, continue } else { ap.ReportError("Width/Height and/or X/Y not specified correctly in Dialog"); } } else { ap.ReportError(exp[0]); } } else { ap.ReportError("Dialog command line not in correct format"); } return(true); }
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(); 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".Tx(ty, "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".Tx(ty) + ": " + 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".Tx(), 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); }
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(); } }