Exemple #1
0
        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;
            }
        }
Exemple #2
0
        // icon list box

        private void extButton1_Click(object sender, EventArgs e)
        {
            ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm();

            int width = 400;

            var butl = new ExtendedControls.ExtButton();

            butl.Image = Properties.Resources.LeftArrow;
            f.Add(new ExtendedControls.ConfigurableForm.Entry(butl, "left", "", new Point(20, 64), new Size(32, 32), null));
            var butr = new ExtendedControls.ExtButton();

            butr.Image = Properties.Resources.RightArrow;
            f.Add(new ExtendedControls.ConfigurableForm.Entry(butr, "right", "", new Point(width - 20 - 32, 64), new Size(32, 32), null));

            f.Add(new ExtendedControls.ConfigurableForm.Entry("olabel", typeof(Label), "Offer", new Point(20, 30), new Size(width - 40, 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    = Properties.Resources.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", new Point(20, 110), new Size(width - 40, 20), null, 1.5f, ContentAlignment.MiddleCenter));

            var panelbox = new GroupBox()
            {
                ForeColor = Color.Red
            };

            f.Add(new ExtendedControls.ConfigurableForm.Entry(panelbox, "panel", "g1", new Point(10, 150), new Size(width - 10, 100), "")
            {
                anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Left
            });

            f.AddOK(new Point(width - 100, 270), anchor: AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom);
            f.AddCancel(new Point(20, 270), anchor: AnchorStyles.Right | AnchorStyles.Bottom);

            f.Trigger += (a, b, c) => { System.Diagnostics.Debug.WriteLine("Ret " + b); if (b == "OK" || b == "Close")
                                        {
                                            f.ReturnResult(DialogResult.OK);
                                        }
            };

            f.RightMargin = 20;
            f.AllowResize = true;

            Theme.Current.FontSize = 12;

            f.ShowDialogCentred(this, this.Icon, "Trader", closeicon: true, minsize: new Size(800, 500), maxsize: new Size(1000, 600));
        }
        void CF(float s, bool wf)
        {
            theme.FontSize     = s;
            theme.WindowsFrame = wf;

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

            int width    = 430;
            int ctrlleft = 150;

            Type t = typeof(DataGridViewDialogs);

            int  initialvalue = 200;
            Form parent       = this;

            f.Add(new ExtendedControls.ConfigurableForm.Entry("L", typeof(Label), "Jump to:".Tx(t), new Point(10, 40), new Size(140, 24), ""));
            f.Add(new ExtendedControls.ConfigurableForm.Entry("Entry", typeof(ExtendedControls.NumberBoxLong), initialvalue.ToString(), new Point(ctrlleft, 40), new Size(width - ctrlleft - 20, 24), "Enter number to jump to or near to".Tx(t, "EN"))
            {
                numberboxdoubleminimum = 0, 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(t)));
            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(t)));

            f.Trigger += (dialogname, controlname, tag) =>
            {
                if (controlname == "OK" || controlname == "Entry:Return")
                {
                    long?v3 = f.GetLong("Entry");
                    if (v3.HasValue)
                    {
                        f.DialogResult = DialogResult.OK;
                        f.Close();
                    }
                    else
                    {
                        ExtendedControls.MessageBoxTheme.Show(parent, "Value is not valid".Tx(t, "VNV"), "Warning".Tx(), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else if (controlname == "Cancel")
                {
                    f.DialogResult = DialogResult.Cancel;
                    f.Close();
                }
            };


            DialogResult res = f.ShowDialogCentred(parent, parent.Icon, "Jump to Entry".Tx(t, "Title"));

            if (res == DialogResult.OK)
            {
                int target = (int)f.GetLong("Entry").Value;
            }
        }
Exemple #4
0
        private void extCheckBoxStar_Click(object sender, EventArgs e)
        {
            if (extCheckBoxStar.Checked == true)
            {
                ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm();
                int width = 700;
                f.Add(new ExtendedControls.ConfigurableForm.Entry("L", typeof(Label), "System:".Tx(this), new Point(10, 40), new Size(160, 24), null));
                f.Add(new ExtendedControls.ConfigurableForm.Entry("Sys", typeof(ExtendedControls.ExtTextBoxAutoComplete), "", new Point(180, 40), new Size(width - 180 - 20, 24), null));

                f.Add(new ExtendedControls.ConfigurableForm.Entry("OK", typeof(ExtendedControls.ExtButton), "OK".Tx(), new Point(width - 20 - 80, 80), new Size(80, 24), ""));
                f.Add(new ExtendedControls.ConfigurableForm.Entry("Cancel", typeof(ExtendedControls.ExtButton), "Cancel".Tx(), new Point(width - 200, 80), new Size(80, 24), ""));

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

                f.Init(this.FindForm().Icon, new Size(width, 120), new Point(-999, -999), "Show System".Tx(this, "EnterSys"), null, null);
                f.GetControl <ExtendedControls.ExtTextBoxAutoComplete>("Sys").SetAutoCompletor(SystemClassDB.ReturnOnlySystemsListForAutoComplete);
                DialogResult res = f.ShowDialog(this.FindForm());

                if (res == DialogResult.OK)
                {
                    string sname = f.Get("Sys");
                    if (sname.HasChars())
                    {
                        showing_matcomds = null;
                        showing_system   = new EliteDangerousCore.SystemClass(sname);
                        override_system  = true;
                        DrawSystem();
                        extCheckBoxStar.Checked = true;
                    }
                    else
                    {
                        extCheckBoxStar.Checked = false;
                    }
                }
                else
                {
                    extCheckBoxStar.Checked = false;
                }
            }
            else
            {
                override_system = false;
                DrawSystem(last_he);
                extCheckBoxStar.Checked = false;
            }
        }
Exemple #5
0
        private void extButton21_Click(object sender, EventArgs e)
        {
            ConfigurableForm cfg = new ExtendedControls.ConfigurableForm();

            cfg.AllowSpaceForScrollBar   = false;
            cfg.RightMargin              = cfg.BottomMargin = 0;
            cfg.ForceNoWindowsBorder     = true;
            cfg.AllowSpaceForCloseButton = true;
            cfg.BorderMargin             = 0;

            ExtButton wikibutton = new ExtButton();

            wikibutton.Image = Properties.Resources.CursorToTop;
            cfg.Add(new ConfigurableForm.Entry(wikibutton, "Wiki", null, new Point(0, 0), new Size(24, 24), null));

            ExtButton videobutton = new ExtButton();

            videobutton.Image = Properties.Resources.CursorToTop;
            cfg.Add(new ConfigurableForm.Entry(videobutton, "Video", null, new Point(24, 0), new Size(24, 24), null));

            cfg.Trigger += (string logicalname, string ctrlname, object callertag) =>
            {
                if (ctrlname == "Close")
                {
                    cfg.ReturnResult(DialogResult.Cancel);
                }
                else if (ctrlname == "Wiki")
                {
                    cfg.ReturnResult(DialogResult.OK);
                }
                else if (ctrlname == "Video")
                {
                    cfg.ReturnResult(DialogResult.Yes);
                }
            };

            Theme.Current.WindowsFrame = false;
            Theme.Current.FontSize     = sender is float?(float)sender : 8.5f;

            DialogResult res = cfg.ShowDialog(this, new Point(500, 500), this.Icon, "", closeicon: true);
        }
        // icon list box

        private void extButton1_Click(object sender, EventArgs e)
        {
            ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm();

            int width = 400;

            var butl = new ExtendedControls.ExtButton();

            butl.Image = Properties.Resources.LeftArrow;
            f.Add(new ExtendedControls.ConfigurableForm.Entry(butl, "left", "", new Point(20, 64), new Size(32, 32), null));
            var butr = new ExtendedControls.ExtButton();

            butr.Image = Properties.Resources.RightArrow;
            f.Add(new ExtendedControls.ConfigurableForm.Entry(butr, "right", "", new Point(width - 20 - 32, 64), new Size(32, 32), null));

            f.Add(new ExtendedControls.ConfigurableForm.Entry("olabel", typeof(Label), "Offer", new Point(20, 30), new Size(width - 40, 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    = Properties.Resources.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", new Point(20, 110), new Size(width - 40, 20), null, 1.5f, ContentAlignment.MiddleCenter));

            f.AddOK(new Point(width - 100, 150));
            f.AddCancel(new Point(20, 150));

            f.Trigger += (a, b, c) => { System.Diagnostics.Debug.WriteLine("Ret " + b); f.ReturnResult(DialogResult.OK); };

            f.RightMargin = 20;

            f.ShowDialogCentred(this, this.Icon, "Trader", closeicon: true);
        }
        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:".T(EDTx.UserControlModules_FW), new Point(10, 40), new Size(140, 24), ""));
            f.Add(new ExtendedControls.ConfigurableForm.Entry("FuelWarning", typeof(ExtendedControls.NumberBoxDouble),
                                                              last_si.FuelWarningPercent.ToString(), new Point(ctrlleft, 40), new Size(width - ctrlleft - 20, 24), "Enter fuel warning level in % (0 = off, 1-100%)".T(EDTx.UserControlModules_TTF))
            {
                numberboxdoubleminimum = 0, numberboxdoublemaximum = 100, numberboxformat = "0.##"
            });

            f.Add(new ExtendedControls.ConfigurableForm.Entry("Sell", typeof(ExtendedControls.ExtButton), "Force Sell".T(EDTx.UserControlModules_ForceSell), new Point(10, 80), new Size(80, 24), null));

            f.AddOK(new Point(width - 100, 110), "Press to Accept".T(EDTx.UserControlModules_PresstoAccept));
            f.AddCancel(new Point(width - 200, 110), "Press to Cancel".T(EDTx.UserControlModules_PresstoCancel));

            f.Trigger += (dialogname, controlname, tag) =>
            {
                if (controlname == "OK")
                {
                    double?v3 = f.GetDouble("FuelWarning");
                    if (v3.HasValue)
                    {
                        f.ReturnResult(DialogResult.OK);
                    }
                    else
                    {
                        ExtendedControls.MessageBoxTheme.Show(this.FindForm(), "A Value is not valid".T(EDTx.UserControlModules_NValid), "Warning".T(EDTx.Warning), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else if (controlname == "Cancel" || controlname == "Close")
                {
                    f.ReturnResult(DialogResult.Cancel);
                }
                else if (controlname == "Sell")
                {
                    if (ExtendedControls.MessageBoxTheme.Show(FindForm(), "Confirm sell of ship:".TxID(EDTx.UserControlModules_ConfirmForceSell) + Environment.NewLine + last_si.ShipNameIdentType, "Warning".T(EDTx.Warning), MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                    {
                        var je = new EliteDangerousCore.JournalEvents.JournalShipyardSell(DateTime.UtcNow, last_si.ShipFD, last_si.ID, 0, EDCommander.CurrentCmdrID);
                        var jo = je.Json();
                        je.Add(jo);
                        discoveryform.NewEntry(je);
                    }

                    f.ReturnResult(DialogResult.Cancel);
                }
            };

            DialogResult res = f.ShowDialogCentred(this.FindForm(), this.FindForm().Icon, "Ship Configure".T(EDTx.UserControlModules_SC), closeicon: true);

            if (res == DialogResult.OK)
            {
                last_si.FuelWarningPercent = f.GetDouble("FuelWarning").Value;
                Display();
            }
        }
Exemple #8
0
        // do videos
        // use file in folder if present, download folder..

        public static void Help(Form parent, Point pos, string name)
        {
            JToken helptouse = defaulthelp;

            string helpfile = Path.Combine(EDDOptions.Instance.HelpDirectory(), "help.json");

            if (File.Exists(helpfile))
            {
                string t        = BaseUtils.FileHelpers.TryReadAllTextFromFile(helpfile);
                JToken filejson = t != null?JToken.Parse(t) : null;

                if (filejson != null)
                {
                    Version intv  = new Version(helptouse["Version"].Str("0.0.0.0"));
                    Version filev = new Version(filejson["Version"].Str("0.0.0.0"));

                    if (filev >= intv)
                    {
                        helptouse = filejson;
                    }
                }
            }

            //System.IO.File.WriteAllText(@"c:\code\help.json",helptouse.ToString(true));
            //System.Diagnostics.Debug.WriteLine("Help on " + name);

            string wiki  = Properties.Resources.URLProjectWiki;     // default..
            string video = Properties.Resources.URLProjectVideos;

            JArray panels = helptouse["Panels"].Array();                                                                    // may be null if there is trouble

            JToken obj = panels?.Where(x => x.Object()["panel"].ValueEquals(name)).Select(x => x).FirstOrDefault() ?? null; // allow for panels to be null

            if (obj != null)
            {
                wiki  = obj["wiki"].StrNull();
                video = obj["video"].StrNull();

                if (wiki != null && wiki.StartsWith("/"))
                {
                    wiki = Properties.Resources.URLProjectWiki + wiki;
                }

                if (video != null && video.StartsWith("/"))
                {
                    video = Properties.Resources.URLProjectVideosRoot + video;
                }

                //System.Diagnostics.Debug.WriteLine("For {0} {1} {2}", name, wiki, video);
            }

            if (wiki.HasChars() && video.HasChars())
            {
                ConfigurableForm cfg = new ExtendedControls.ConfigurableForm();
                cfg.AllowSpaceForScrollBar   = false;
                cfg.RightMargin              = cfg.BottomMargin = 0;
                cfg.ForceNoWindowsBorder     = true;
                cfg.AllowSpaceForCloseButton = true;
                cfg.BorderMargin             = 0;
                cfg.ExtraMarginRightBottom   = new Size(0, 0);

                ExtButton wikibutton = new ExtButton();
                wikibutton.Image = global::EDDiscovery.Icons.Controls.Help_Wiki;
                cfg.Add(new ConfigurableForm.Entry(wikibutton, "Wiki", null, new Point(0, 0), new Size(24, 24), null));
                ExtButton videobutton = new ExtButton();
                videobutton.Image = global::EDDiscovery.Icons.Controls.Help_Video;
                cfg.Add(new ConfigurableForm.Entry(videobutton, "Video", null, new Point(26, 0), new Size(24, 24), null));

                cfg.Trigger += (string logicalname, string ctrlname, object callertag) =>
                {
                    if (ctrlname == "Close")
                    {
                        cfg.ReturnResult(DialogResult.Cancel);
                    }
                    else if (ctrlname == "Wiki")
                    {
                        cfg.ReturnResult(DialogResult.OK);
                    }
                    else if (ctrlname == "Video")
                    {
                        cfg.ReturnResult(DialogResult.Yes);
                    }
                };

                DialogResult res = cfg.ShowDialog(parent, pos, parent.Icon, "", closeicon: true);
                if (res == DialogResult.OK)
                {
                    BaseUtils.BrowserInfo.LaunchBrowser(wiki);
                }
                else if (res == DialogResult.Yes)
                {
                    BaseUtils.BrowserInfo.LaunchBrowser(video);
                }
            }
            else if (wiki.HasChars())
            {
                BaseUtils.BrowserInfo.LaunchBrowser(wiki);
            }
            else if (video.HasChars())
            {
                BaseUtils.BrowserInfo.LaunchBrowser(video);
            }
            else
            {
                MessageBox.Show("No help for " + name);
            }
        }
Exemple #9
0
    public static int JumpToDialog(this DataGridView grid, Form parent, int initialvalue, Func <DataGridViewRow, int> getindex)
    {
        ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm();

        int width    = 430;
        int ctrlleft = 150;

        Type t = typeof(DataGridViewDialogs);

        f.Add(new ExtendedControls.ConfigurableForm.Entry("L", typeof(Label), "Jump to:".TxID(EDTx.DataGridViewDialogs_Jumpto), new Point(10, 40), new Size(140, 24), ""));
        f.Add(new ExtendedControls.ConfigurableForm.Entry("Entry", typeof(ExtendedControls.NumberBoxLong), initialvalue.ToString(), new Point(ctrlleft, 40), new Size(width - ctrlleft - 20, 24), "Enter number to jump to or near to".TxID(EDTx.DataGridViewDialogs_EN))
        {
            numberboxdoubleminimum = 0, numberboxformat = "0"
        });

        f.AddOK(new Point(width - 100, 70), "Press to Accept".TxID(EDTx.DataGridViewDialogs_PresstoAccept));
        f.AddCancel(new Point(width - 200, 70), "Press to Cancel".TxID(EDTx.DataGridViewDialogs_PresstoCancel));

        f.Trigger += (dialogname, controlname, tag) =>
        {
            if (controlname == "OK" || controlname == "Entry:Return")
            {
                long?v3 = f.GetLong("Entry");
                if (v3.HasValue)
                {
                    f.ReturnResult(DialogResult.OK);
                }
                else
                {
                    ExtendedControls.MessageBoxTheme.Show(parent, "Value is not valid".TxID(EDTx.DataGridViewDialogs_VNV), "Warning".TxID(EDTx.Warning), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else if (controlname == "Cancel" || controlname == "Close")
            {
                f.ReturnResult(DialogResult.Cancel);
            }
        };

        DialogResult res = f.ShowDialogCentred(parent, parent.Icon, "Jump to Entry".TxID(EDTx.DataGridViewDialogs_Jumpto), closeicon: true);

        if (res == DialogResult.OK)
        {
            int target = (int)f.GetLong("Entry").Value;

            int rowclosest = 0;
            int rowdist    = int.MaxValue;

            foreach (DataGridViewRow r in grid.Rows)
            {
                if (r.Visible)
                {
                    int index = getindex(r);
                    int delta = Math.Abs(target - index);
                    if (delta < rowdist)
                    {
                        rowdist    = delta;
                        rowclosest = r.Index;
                    }
                }
            }

            grid.DisplayRow(rowclosest, true);

            return(rowclosest);
        }
        else
        {
            return(-1);
        }
    }