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;
                        }

                        System.Drawing.Point pos = new System.Drawing.Point(-999, -999);
                        if (x != null && y != null)
                        {
                            pos = new System.Drawing.Point(x.Value, y.Value);
                        }

                        cd.Trigger += Cd_Trigger;

                        cd.Show(ap.actioncontroller.Form, ap.actioncontroller.Icon,
                                new System.Drawing.Size(dw.Value, dh.Value), pos,
                                exp[1],
                                exp[0], new List <Object>()
                        {
                            ap, IsModalDialog()
                        }                                                                       // logical name and tag
                                );

                        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();
            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);

                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);

                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);
        }
        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);
        }
        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..
            {
                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;
                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) =>
            {
                f.ReturnResult(DialogResult.OK);
            };

            f.InitCentred(parent, parent.Icon, title, null, null, asm, closeicon: true);

            f.Show(parent);
        }
Exemple #5
0
        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());
        }