private void showMissionsForFactionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int row = dataGridViewFactions.RightClickRow;

            if (row >= 0)
            {
                FactionStatistics fs = dataGridViewFactions.Rows[row].Tag as FactionStatistics;

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

                mluc.Clear();
                List <MissionState> ml = discoveryform.history.MissionListAccumulator.GetMissionList(last_he?.MissionList ?? 0);

                DateTime startdateutc = startDateTime.Checked ? EDDConfig.Instance.ConvertTimeToUTCFromSelected(startDateTime.Value) : new DateTime(1980, 1, 1);
                DateTime enddateutc   = endDateTime.Checked ? EDDConfig.Instance.ConvertTimeToUTCFromSelected(endDateTime.Value) : new DateTime(8999, 1, 1);

                if (ml != null)
                {
                    foreach (MissionState ms in ml)
                    {
                        if (ms.State == MissionState.StateTypes.Completed && ms.Completed != null)
                        {
                            if (DateTime.Compare(ms.Completed.EventTimeUTC, startdateutc) >= 0 &&
                                DateTime.Compare(ms.Completed.EventTimeUTC, enddateutc) <= 0)
                            {
                                var faction = ms.Mission.Faction;
                                if (faction == fs.Name)
                                {
                                    mluc.Add(ms, true);
                                }
                            }
                        }
                    }

                    mluc.Finish();
                }

                DGVLoadColumnLayout(mluc.dataGridView, "ShowMission");

                f.Add(new ExtendedControls.ConfigurableForm.Entry(mluc, "Grid", "", new System.Drawing.Point(3, 30), new System.Drawing.Size(800, 400), null)
                {
                    anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom
                });

                f.AddOK(new Point(800 - 100, 460), "OK", anchor: AnchorStyles.Right | AnchorStyles.Bottom);
                f.InstallStandardTriggers();

                f.AllowResize = true;

                f.ShowDialogCentred(FindForm(), FindForm().Icon, "Missions for ".T(EDTx.UserControlFactions_MissionsFor) + fs.Name, closeicon: true);

                DGVSaveColumnLayout(mluc.dataGridView, "ShowMission");
            }
        }
Example #2
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".T(EDTx.UserControlExploration_NoSys),
                                                          "Warning".T(EDTx.Warning), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    AddSystems(systems);
                }

                f.ReturnResult(DialogResult.OK);
            };

            f.Add(new ExtendedControls.ConfigurableForm.Entry("UC", null, "", new Point(5, 30), usc.Size, null)
            {
                control = usc
            });
            f.AddCancel(new Point(4 + usc.Width - 80, usc.Height + 50));

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

            // usc.Font = EDDTheme.Instance.GetScaledFont(0.8f)
            f.ShowDialogCentred(this.FindForm(), this.FindForm().Icon, "Add Systems".T(EDTx.UserControlExploration_AddSys),
                                callback: () => {; usc.Init(0, "ExplorationFindSys", false, discoveryform); }, closeicon: true);
            usc.Closing();
        }
Example #3
0
        // present and allow alloweddisallowed string to be edited. null if cancel

        public static string DLLPermissionManager(Form form, Icon icon, string alloweddisallowed)
        {
            string[] allowedfiles = alloweddisallowed.Split(',');

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

            int width  = 400;
            int margin = 20;
            int vpos   = 30;

            foreach (string setting in allowedfiles)
            {
                if (setting.Length >= 2)    // double check
                {
                    string name = setting.Substring(1);
                    f.Add(new ExtendedControls.ConfigurableForm.Entry(name, typeof(ExtendedControls.ExtCheckBox), name, new Point(margin, vpos), new Size(width - margin - 20, 20), null)
                    {
                        checkboxchecked = setting[0] == '+'
                    });
                    vpos += 30;
                }
            }

            f.AddOK(new Point(width - margin - 100, vpos), "OK".Tx());
            f.AddCancel(new Point(width - margin - 200, vpos), "Cancel".Tx());

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

            if (f.ShowDialogCentred(form, icon, "DLL - applies at next restart", closeicon: true) == DialogResult.OK)
            {
                alloweddisallowed = "";
                foreach (var e in f.Entries.Where(x => x.controltype == typeof(ExtendedControls.ExtCheckBox)))
                {
                    alloweddisallowed = alloweddisallowed.AppendPrePad((f.Get(e.controlname) == "1" ? "+" : "-") + e.controlname, ",");
                }

                return(alloweddisallowed);
            }
            else
            {
                return(null);
            }
        }
Example #4
0
        private void showBountiesAndBondsForFactionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (dataGridViewFactions.RightClickRow >= 0)
            {
                FactionStatistics fs = dataGridViewFactions.Rows[dataGridViewFactions.RightClickRow].Tag as FactionStatistics;

                var dgvpanel = new ExtendedControls.ExtPanelDataGridViewScrollWithDGV <BaseUtils.DataGridViewColumnHider>();
                dgvpanel.DataGrid.CreateTextColumns("Date".T(EDTx.UserControlOutfitting_Date), 100, 5,
                                                    "Bounty/Bond".T(EDTx.UserControlFactions_BountyBond), 80, 5,
                                                    "Target".T(EDTx.UserControlFactions_Target), 150, 5,
                                                    "Target Faction".T(EDTx.UserControlFactions_TargetFaction), 150, 5,
                                                    "Reward".T(EDTx.UserControlFactions_Reward), 60, 5);
                dgvpanel.DataGrid.SortCompare += (s, ev) => { if (ev.Column.Index >= 4)
                                                              {
                                                                  ev.SortDataGridViewColumnNumeric();
                                                              }
                };
                dgvpanel.DataGrid.RowHeadersVisible = false;
                dgvpanel.DataGrid.Columns[4].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;

                string keyname = "UserControlFactionsShowBonds";
                dgvpanel.DataGrid.LoadColumnSettings(keyname, (a) => EliteDangerousCore.DB.UserDatabase.Instance.GetSettingInt(a, int.MinValue),
                                                     (b) => EliteDangerousCore.DB.UserDatabase.Instance.GetSettingDouble(b, double.MinValue));


                foreach (var he in FilterHistory((x) => x.journalEntry is IStatsJournalEntryBountyOrBond &&
                                                 (x.journalEntry as IStatsJournalEntryBountyOrBond).HasFaction(fs.Name)))
                {
                    var      bb     = he.journalEntry as IStatsJournalEntryBountyOrBond;
                    object[] rowobj = { EDDiscoveryForm.EDDConfig.ConvertTimeToSelectedFromUTC(he.EventTimeUTC),
                                        bb.Type,                                                                bb.Target,bb.TargetFaction, bb.FactionReward(fs.Name).ToString("N0") };
                    var      row = dgvpanel.DataGrid.RowTemplate.Clone() as DataGridViewRow;
                    row.CreateCells(dgvpanel.DataGrid, rowobj);
                    dgvpanel.DataGrid.Rows.Add(row);
                }

                ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm();
                f.Add(new ExtendedControls.ConfigurableForm.Entry(dgvpanel, "Grid", "", new System.Drawing.Point(3, 30), new System.Drawing.Size(800, 400), null)
                {
                    anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom
                });
                f.AddOK(new Point(800 - 100, 460), "OK", anchor: AnchorStyles.Right | AnchorStyles.Bottom);
                f.InstallStandardTriggers();
                f.AllowResize = true;

                f.ShowDialogCentred(FindForm(), FindForm().Icon, "Bounties/Bonds for ".T(EDTx.UserControlFactions_BountiesBondsFor) + fs.Name, closeicon: true);

                dgvpanel.DataGrid.SaveColumnSettings(keyname, (a, b) => EliteDangerousCore.DB.UserDatabase.Instance.PutSettingInt(a, b),
                                                     (c, d) => EliteDangerousCore.DB.UserDatabase.Instance.PutSettingDouble(c, d));
            }
        }
Example #5
0
        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();
            }
        }
Example #6
0
        void ShowMissions(int row)
        {
            if (row >= 0)
            {
                FactionStatistics fs = dataGridViewFactions.Rows[row].Tag as FactionStatistics;

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

                mluc.Clear();
                MissionList ml = last_he?.MissionList;
                if (ml != null)
                {
                    foreach (MissionState ms in ml.Missions.Values)
                    {
                        if (ms.State == MissionState.StateTypes.Completed && ms.Completed != null)
                        {
                            var faction = ms.Mission.Faction;
                            if (faction == fs.Name)
                            {
                                mluc.Add(ms, true);
                            }
                        }
                    }

                    mluc.Finish();
                }

                f.Add(new ExtendedControls.ConfigurableForm.Entry(mluc, "Grid", "", new System.Drawing.Point(3, 30), new System.Drawing.Size(800, 400), null)
                {
                    anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom
                });

                f.AddOK(new Point(800 - 100, 460), "OK", anchor: AnchorStyles.Right | AnchorStyles.Bottom);

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

                f.AllowResize = true;

                f.ShowDialogCentred(this.FindForm(), this.FindForm().Icon, "Missions for ".Tx(EDTx.UserControlMissionAccounting_MissionsFor) + fs.Name, closeicon: true);
            }
        }
        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);
                }
            }
        }
Example #8
0
        private void extCheckBoxAllowedList_Click(object sender, EventArgs e)
        {
            ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm();

            int width = 430;

            string deflist = GetSetting("Allowed", "");

            f.Add(new ExtendedControls.ConfigurableForm.Entry("Text", typeof(ExtendedControls.ExtTextBox), deflist, new Point(10, 40), new Size(width - 10 - 20, 110), "URLs")
            {
                textboxmultiline = true
            });

            f.AddOK(new Point(width - 100, 180));
            f.AddCancel(new Point(width - 200, 180));

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

            DialogResult res = f.ShowDialogCentred(this.FindForm(), this.FindForm().Icon, "URLs", closeicon: true);

            if (res == DialogResult.OK)
            {
                string userurllist = f.Get("Text");
                wbb.userurllist = userurllist;
                PutSetting("Allowed", userurllist);
                PresentSystem(last_sys_tracked);
            }
        }
        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".T(EDTx.UserControlRouteTracker_Selectroute), routenames));
            f.AddCancel(new Point(410 - 80, 80), "Press to Cancel".T(EDTx.UserControlRouteTracker_PresstoCancel));

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

            if (f.ShowDialogCentred(this.FindForm(), this.FindForm().Icon, "Enter route".T(EDTx.UserControlRouteTracker_Enterroute), closeicon: true) == 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 testing of route finding

                if (currentRoute != null)
                {
                    PutSetting("SelectedRoute", currentRoute.Id.ToStringInvariant());        // write ID back
                }
                Display();
            }
        }
        private void extButtonHeader_Click(object sender, EventArgs e)
        {
            ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm();

            int width  = 800;
            int okline = 600;

            var istr = curprog.HeaderText ?? "";                                                                                           // may be null

            string conv = string.Join(Environment.NewLine, istr.Split(Environment.NewLine).Select(x => x.ReplaceIfStartsWith("// ", ""))); // split, remove any // space prefixes

            f.Add(new ExtendedControls.ConfigurableForm.Entry("text", typeof(ExtendedControls.ExtTextBox), conv,
                                                              new Point(8, 30), new Size(width - 20, okline - 10 - 30), null)
            {
                textboxmultiline = true
            });

            f.AddOK(new Point(width - 100, okline));
            f.AddCancel(new Point(width - 200, okline));
            f.InstallStandardTriggers();

            DialogResult res = f.ShowDialogCentred(this.FindForm(), this.FindForm().Icon, "Header", closeicon: true);

            if (res == DialogResult.OK)
            {
                var str = f.Get("text");
                if (str.HasChars())     // if anything there, put back the custom header, with // any lines which do not start with it
                {
                    curprog.HeaderText = string.Join(Environment.NewLine, str.Split(Environment.NewLine).Select(x => x.StartsWith("//") ? x : "// " + x));
                }
                else
                {
                    curprog.HeaderText = null;  // else cancel the custom header
                }
            }
        }
Example #11
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 showCommoditymaterialTradesForFactionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (dataGridViewFactions.RightClickRow >= 0)
            {
                FactionStatistics fs = dataGridViewFactions.Rows[dataGridViewFactions.RightClickRow].Tag as FactionStatistics;

                var dgvpanel = new ExtendedControls.ExtPanelDataGridViewScrollWithDGV <BaseUtils.DataGridViewColumnHider>();
                dgvpanel.DataGrid.CreateTextColumns("Date".T(EDTx.UserControlOutfitting_Date), 100, 5,
                                                    "Item".T(EDTx.UserControlFactions_Item), 150, 5,
                                                    "Bought".T(EDTx.UserControlStats_GoodsBought), 50, 5,
                                                    "Sold".T(EDTx.UserControlStats_GoodsSold), 50, 5,
                                                    "Profit".T(EDTx.UserControlStats_GoodsProfit), 50, 5);

                dgvpanel.DataGrid.SortCompare += (s, ev) => { if (ev.Column.Index >= 2)
                                                              {
                                                                  ev.SortDataGridViewColumnNumeric();
                                                              }
                };
                dgvpanel.DataGrid.RowHeadersVisible = false;
                dgvpanel.DataGrid.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                dgvpanel.DataGrid.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                dgvpanel.DataGrid.Columns[4].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;

                DGVLoadColumnLayout(dgvpanel.DataGrid, "ShowCommdsMats");

                long profit = 0;

                foreach (var he in FilterHistory((x) => x.journalEntry is IStatsJournalEntryMatCommod && x.StationFaction == fs.Name))
                {
                    var items = (he.journalEntry as IStatsJournalEntryMatCommod).ItemsList;
                    foreach (var i in items)
                    {
                        var    m    = EliteDangerousCore.MaterialCommodityMicroResourceType.GetByFDName(i.FDName); // and we see if we actually have some at this time
                        string name = m?.Name ?? i.FDName;

                        int bought = i.Count > 0 ? i.Count : 0;
                        int sold   = i.Count < 0 ? -i.Count : 0;

                        object[] rowobj = { EDDiscoveryForm.EDDConfig.ConvertTimeToSelectedFromUTC(he.EventTimeUTC),
                                            name,
                                            bought.ToString("N0"),
                                            sold.ToString("N0"),
                                            i.Profit.ToString("N0") };
                        var      row = dgvpanel.DataGrid.RowTemplate.Clone() as DataGridViewRow;
                        row.CreateCells(dgvpanel.DataGrid, rowobj);
                        dgvpanel.DataGrid.Rows.Add(row);

                        profit += i.Profit;
                    }
                }

                ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm();
                f.Add(new ExtendedControls.ConfigurableForm.Entry(dgvpanel, "Grid", "", new System.Drawing.Point(3, 30), new System.Drawing.Size(800, 400), null)
                {
                    anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom
                });
                f.AddOK(new Point(800 - 100, 460), "OK", anchor: AnchorStyles.Right | AnchorStyles.Bottom);
                f.InstallStandardTriggers();
                f.AllowResize = true;

                string title = "Materials/Commodities for ".T(EDTx.UserControlFactions_MaterialCommodsFor) + fs.Name;
                if (profit != 0)
                {
                    title += " (" + profit.ToString("N0") + "cr)";
                }
                f.ShowDialogCentred(FindForm(), FindForm().Icon, title, closeicon: true);

                DGVSaveColumnLayout(dgvpanel.DataGrid, "ShowCommdsMats");
            }
        }
Example #13
0
        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);
        }
Example #14
0
        DialogResult EditEntry(FilterEntry entry, bool newentry, bool allowdel)
        {
            ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm();

            DateTime starttime = EDDConfig.Instance.ConvertTimeToSelectedFromUTC(entry.StartTimeUTC);
            DateTime endtime   = EDDConfig.Instance.ConvertTimeToSelectedFromUTC(entry.EndTimeUTC);

            int width = 430;

            f.Add(new ExtendedControls.ConfigurableForm.Entry("L", typeof(Label), "Name:".T(EDTx.UserControlCombatPanel_Name), new Point(10, 40), new Size(80, 24), ""));
            f.Add(new ExtendedControls.ConfigurableForm.Entry("Name", typeof(ExtendedControls.ExtTextBox), entry.Name, new Point(100, 40), new Size(width - 100 - 20, 24), "Give name to campaign".T(EDTx.UserControlCombatPanel_C1))
            {
                clearonfirstchar = newentry
            });

            f.Add(new ExtendedControls.ConfigurableForm.Entry("L", typeof(Label), "Faction:".T(EDTx.UserControlCombatPanel_Faction), new Point(10, 70), new Size(80, 24), ""));
            f.Add(new ExtendedControls.ConfigurableForm.Entry("Faction", typeof(ExtendedControls.ExtTextBox), entry.TargetFaction, new Point(100, 70), new Size(width - 100 - 20, 24), "Optional faction to target".T(EDTx.UserControlCombatPanel_C2)));

            f.Add(new ExtendedControls.ConfigurableForm.Entry("L", typeof(Label), "Start:".T(EDTx.UserControlCombatPanel_Start), new Point(10, 100), new Size(80, 24), ""));
            f.Add(new ExtendedControls.ConfigurableForm.Entry("DTS", typeof(ExtendedControls.ExtDateTimePicker), starttime.ToStringZulu(), new Point(100, 100), new Size(width - 100 - 20, 24), "Select Start time".T(EDTx.UserControlCombatPanel_C3))
            {
                customdateformat = "yyyy-MM-dd HH:mm:ss"
            });

            f.Add(new ExtendedControls.ConfigurableForm.Entry("L", typeof(Label), "End:".T(EDTx.UserControlCombatPanel_End), new Point(10, 130), new Size(80, 24), ""));
            f.Add(new ExtendedControls.ConfigurableForm.Entry("DTE", typeof(ExtendedControls.ExtDateTimePicker), endtime.ToStringZulu(), new Point(100, 130), new Size(width - 100 - 20, 24), "Select Start time".T(EDTx.UserControlCombatPanel_C4))
            {
                customdateformat = "yyyy-MM-dd HH:mm:ss"
            });

            f.AddOK(new Point(width - 100, 180), "Press to Accept".T(EDTx.UserControlCombatPanel_C5));
            f.AddCancel(new Point(width - 200, 180), "Press to Cancel".T(EDTx.UserControlCombatPanel_C6));

            if (allowdel)
            {
                f.Add(new ExtendedControls.ConfigurableForm.Entry("Delete", typeof(ExtendedControls.ExtButton), "Delete".T(EDTx.Delete), new Point(10, 180), new Size(80, 24), "Press to Delete".T(EDTx.UserControlCombatPanel_C7)));
            }

            f.Trigger += (dialogname, controlname, tag) =>
            {
                if (controlname == "OK")
                {
                    FilterEntry fe = displayedfilterentries.Find(x => x.UniqueID.Equals(f.Get("Name")));

                    if (fe != null && fe != entry)
                    {
                        ExtendedControls.MessageBoxTheme.Show(this.FindForm(), "Name of campaign already in use, cannot overwrite".T(EDTx.UserControlCombatPanel_NoOverwrite), "Warning".T(EDTx.Warning), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        f.ReturnResult(DialogResult.OK);
                    }
                }
                else if (controlname == "Delete")
                {
                    if (f.Get("Name").Equals(entry.Name))
                    {
                        if (ExtendedControls.MessageBoxTheme.Show(this.FindForm(), string.Format("Confirm deletion of {0}".T(EDTx.UserControlCombatPanel_Condel), entry.Name), "Warning".T(EDTx.Warning), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                        {
                            f.ReturnResult(DialogResult.Abort);
                        }
                    }
                    else
                    {
                        ExtendedControls.MessageBoxTheme.Show(this.FindForm(), "Name changed - can't delete".T(EDTx.UserControlCombatPanel_NC), "Warning".T(EDTx.Warning), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else if (controlname == "Cancel" || controlname == "Close")
                {
                    f.ReturnResult(DialogResult.Cancel);
                }
            };

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

            if (res == DialogResult.OK)
            {
                entry.Reset(f.Get("Name"), f.Get("Faction"),
                            EDDConfig.Instance.ConvertTimeToUTCFromSelected(f.GetDateTime("DTS").Value),
                            EDDConfig.Instance.ConvertTimeToUTCFromSelected(f.GetDateTime("DTE").Value));
            }

            return(res);
        }
        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) != ConditionFunctions.ExpandResult.Failed)
                {
                    ConditionVariables 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);
        }
Example #17
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();
        }
Example #18
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());
        }
        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);
        }
        public override bool ExecuteAction(ActionProgramRun ap)
        {
            string exp;

            if (ap.Functions.ExpandString(UserData, out exp) != Functions.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.NextWordLCInvariant();

                    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"))      // verified 10/1/21
                    {
                        int?x = sp.NextIntComma(",");
                        int?y = sp.NextInt();

                        if (x != null)
                        {
                            if (y != null)
                            {
                                f.Location = new System.Drawing.Point(x.Value, y.Value);
                            }
                            else
                            {
                                ap.ReportError("Missing position in DialogControl position");
                            }
                        }
                        else if (sp.IsEOL)
                        {
                            ap["X"] = f.Location.X.ToStringInvariant();
                            ap["Y"] = f.Location.Y.ToStringInvariant();
                        }
                        else
                        {
                            ap.ReportError("Missing position in DialogControl position");
                        }
                    }
                    else if (cmd.Equals("size"))    // verified 10/1/21
                    {
                        int?w = sp.NextIntComma(",");
                        int?h = sp.NextInt();

                        if (w != null)
                        {
                            if (h != null)
                            {
                                f.Size = new System.Drawing.Size(w.Value, h.Value);
                            }
                            else
                            {
                                ap.ReportError("Missing size in DialogControl size");
                            }
                        }
                        else if (sp.IsEOL)
                        {
                            ap["W"] = f.Size.Width.ToStringInvariant();
                            ap["H"] = f.Size.Height.ToStringInvariant();
                        }
                        else
                        {
                            ap.ReportError("Missing size in DialogControl size");
                        }
                    }
                    else if (cmd.Equals("get"))
                    {
                        string control = sp.NextQuotedWord();
                        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.NextQuotedWord(" =");
                        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("enable") || cmd.Equals("visible"))     // verified 10/1/21
                    {
                        string  control = sp.NextQuotedWord();
                        Control c;

                        if (control != null && (c = f.GetControl(control)) != null)
                        {
                            bool?r = sp.NextBoolComma();

                            if (r != null)
                            {
                                if (cmd.Equals("enable"))
                                {
                                    c.Enabled = r.Value;
                                }
                                else
                                {
                                    c.Visible = r.Value;
                                }
                            }
                            else if (sp.IsEOL)
                            {
                                if (cmd.Equals("enable"))
                                {
                                    ap["Enabled"] = c.Enabled.ToStringIntValue();
                                }
                                else
                                {
                                    ap["Visible"] = c.Visible.ToStringIntValue();
                                }
                            }
                            else
                            {
                                ap.ReportError("Missing or invalid " + cmd + "value in DialogControl " + cmd);
                            }
                        }
                        else
                        {
                            ap.ReportError("Missing or invalid dialog control name in DialogControl " + cmd);
                        }
                    }
                    else if (cmd.Equals("controlbounds"))       // verified 10/1/21
                    {
                        string  control = sp.NextQuotedWord();
                        Control c;

                        if (control != null && (c = f.GetControl(control)) != null)
                        {
                            int?x = sp.NextIntComma(",");
                            int?y = sp.NextIntComma(",");
                            int?w = sp.NextIntComma(",");
                            int?h = sp.NextInt();

                            if (x != null && y != null && w != null && h != null)
                            {
                                c.Bounds = new System.Drawing.Rectangle(x.Value, y.Value, w.Value, h.Value);
                            }
                            else if (sp.IsEOL)
                            {
                                ap["X"] = c.Left.ToStringInvariant();
                                ap["Y"] = c.Top.ToStringInvariant();
                                ap["W"] = c.Width.ToStringInvariant();
                                ap["H"] = c.Height.ToStringInvariant();
                            }
                            else
                            {
                                ap.ReportError("Missing or invalid bounds values in DialogControl controlbounds");
                            }
                        }
                        else
                        {
                            ap.ReportError("Missing or invalid dialog control name in DialogControl controlbounds");
                        }
                    }
                    else if (cmd.Equals("close"))
                    {
                        f.ReturnResult(f.DialogResult);
                        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);
        }
        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);
        }
Example #22
0
        private void showFactionSystemDetailToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (dataGridViewFactions.RightClickRow >= 0)
            {
                FactionStatistics fs = dataGridViewFactions.Rows[dataGridViewFactions.RightClickRow].Tag as FactionStatistics;

                var dgvpanel = new ExtendedControls.ExtPanelDataGridViewScrollWithDGV <BaseUtils.DataGridViewColumnControl>();
                dgvpanel.DataGrid.CreateTextColumns("System".T(EDTx.UserControlModules_System), 100, 5,
                                                    "System Address".T(EDTx.UserControlFactions_SystemAddress), 60, 5,
                                                    "Missions".T(EDTx.UserControlMissions_MPlural), 50, 5,
                                                    "+Influence".T(EDTx.UserControlFactions_colInfluence), 50, 5,       // these align with columns of main view, with same names
                                                    "Commds +".T(EDTx.UserControlFactions_CBought), 50, 5,
                                                    "Commds -".T(EDTx.UserControlFactions_CSold), 50, 5,
                                                    "Mats +".T(EDTx.UserControlFactions_MBought), 50, 5,
                                                    "Mats -".T(EDTx.UserControlFactions_MSold), 50, 5,
                                                    "Bounties".T(EDTx.UserControlFactions_BountiesPlural), 50, 5,
                                                    "Rewards".T(EDTx.UserControlFactions_RewardsPlural), 60, 5,
                                                    "Bonds".T(EDTx.UserControlFactions_BondsPlural), 50, 5,
                                                    "Rewards".T(EDTx.UserControlFactions_RewardsPlural), 60, 5,
                                                    "Cartographic Value".T(EDTx.UserControlFactions_CartoValue), 60, 5);
                dgvpanel.DataGrid.SortCompare += (s, ev) => { if (ev.Column.Index >= 1)
                                                              {
                                                                  ev.SortDataGridViewColumnNumeric();
                                                              }
                };
                dgvpanel.DataGrid.RowHeadersVisible           = false;
                dgvpanel.DataGrid.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
                for (int col = 1; col < dgvpanel.DataGrid.ColumnCount - 1; col++)
                {
                    dgvpanel.DataGrid.Columns[col].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                }

                DGVLoadColumnLayout(dgvpanel.DataGrid, "ShowSystemDetail");

                // systems to present
                var systems = new List <SystemInfo>();

                // look thru the influence systems and add it to the list of systems

                foreach (var si in fs.SystemsWithInfluence.Values)
                {
                    string systemName = null;
                    if (last_he != null)
                    {
                        foreach (var he in HistoryList.FilterBefore(discoveryform.history.EntryOrder(), last_he,
                                                                    (x) => x.System.SystemAddress == si.SystemAddress))
                        {
                            systemName = he.System.Name;
                            break;
                        }
                    }
                    systems.Add(new SystemInfo {
                        Name = systemName, Address = si.SystemAddress, Missions = si.Missions, Influence = si.Influence
                    });
                }

                // find all the history entries with faction, taking into account start/end date, and last_he position

                var list = FilterHistory((x) =>
                                         (x.journalEntry is IStatsJournalEntryMatCommod && x.StationFaction == fs.Name) ||                                                                                              // he's with changes in stats due to MatCommod trading
                                         (x.journalEntry is IStatsJournalEntryBountyOrBond && (x.journalEntry as IStatsJournalEntryBountyOrBond).HasFaction(fs.Name)) ||                                                // he's with Bountry/bond
                                         ((x.journalEntry.EventTypeID == JournalTypeEnum.SellExplorationData || x.journalEntry.EventTypeID == JournalTypeEnum.MultiSellExplorationData) && x.StationFaction == fs.Name) // he's for exploration
                                         );

                foreach (var he in list)
                {
                    SystemInfo si = systems.Find(x =>           // do we have this previous entry?
                                                 (he.System.SystemAddress != null && x.Address == he.System.SystemAddress) ||
                                                 (he.System.Name != null && x.Name == he.System.Name));

                    if (si == null)     // no, add it to the system list
                    {
                        si = new SystemInfo {
                            Name = he.System.Name, Address = he.System.SystemAddress
                        };
                        systems.Add(si);
                    }

                    if (he.journalEntry is IStatsJournalEntryMatCommod)         // is this a material or commodity trade?
                    {
                        var items = (he.journalEntry as IStatsJournalEntryMatCommod).ItemsList;
                        foreach (var i in items)
                        {
                            if (he.journalEntry.EventTypeID == JournalTypeEnum.MaterialTrade)       // material trade is only counter for mats
                            {
                                if (i.Count > 0)
                                {
                                    si.AddMaterialsBought(i.Count);
                                }
                                else if (i.Count < 0)
                                {
                                    si.AddMaterialsSold(-i.Count);
                                }
                            }
                            else
                            {                                               // all others are commds
                                if (i.Count > 0)
                                {
                                    si.AddCommoditiesBought(i.Count);
                                }
                                else
                                {
                                    si.AddCommoditiesSold(-i.Count);        // value is negative, invert
                                }
                            }
                        }
                    }
                    else
                    {
                        //  System.Diagnostics.Debug.WriteLine($"Faction {fs.Name} Journal entry {he.journalEntry.EventTypeStr} {he.System.Name}");

                        if (he.journalEntry.EventTypeID == JournalTypeEnum.Bounty)
                        {
                            si.AddBounties(1);
                            si.AddBountyRewardsValue((he.journalEntry as IStatsJournalEntryBountyOrBond).FactionReward(fs.Name));
                        }
                        else if (he.journalEntry.EventTypeID == JournalTypeEnum.FactionKillBond)
                        {
                            si.AddKillBonds(1);
                            si.AddBondsRewardsValue((he.journalEntry as IStatsJournalEntryBountyOrBond).FactionReward(fs.Name));
                        }
                        else if (he.journalEntry.EventTypeID == JournalTypeEnum.SellExplorationData)
                        {
                            si.AddCartographicValue((he.journalEntry as EliteDangerousCore.JournalEvents.JournalSellExplorationData).TotalEarnings);
                        }
                        else if (he.journalEntry.EventTypeID == JournalTypeEnum.MultiSellExplorationData)
                        {
                            si.AddCartographicValue((he.journalEntry as EliteDangerousCore.JournalEvents.JournalMultiSellExplorationData).TotalEarnings);
                        }
                    }
                }

                foreach (var system in systems)
                {
                    object[] rowobj = { system.Name,
                                        system.Address,
                                        system.Missions?.ToString("N0"),
                                        system.Influence?.ToString("N0"),
                                        system.CommoditiesBought?.ToString("N0"),
                                        system.CommoditiesSold?.ToString("N0"),
                                        system.MaterialsBought?.ToString("N0"),
                                        system.MaterialsSold?.ToString("N0"),
                                        system.Bounties?.ToString("N0"),
                                        system.BountyRewardsValue?.ToString("N0"),
                                        system.KillBonds?.ToString("N0"),
                                        system.BondsRewardsValue?.ToString("N0"),
                                        system.CartographicValue?.ToString("N0"), };
                    var      row = dgvpanel.DataGrid.RowTemplate.Clone() as DataGridViewRow;
                    row.CreateCells(dgvpanel.DataGrid, rowobj);
                    dgvpanel.DataGrid.Rows.Add(row);
                }

                ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm();
                f.Add(new ExtendedControls.ConfigurableForm.Entry(dgvpanel, "Grid", "", new System.Drawing.Point(3, 30), new System.Drawing.Size(960, 400), null)
                {
                    anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom
                });
                f.AddOK(new Point(960 - 100, 460), "OK", anchor: AnchorStyles.Right | AnchorStyles.Bottom);
                f.InstallStandardTriggers();
                f.AllowResize = true;

                f.ShowDialogCentred(FindForm(), FindForm().Icon, "Systems Detail for ".T(EDTx.UserControlFactions_SystemsDetailFor) + fs.Name, closeicon: true);

                DGVSaveColumnLayout(dgvpanel.DataGrid, "ShowSystemDetail");
            }
        }
        private void showFactionSystemDetailToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (dataGridViewFactions.RightClickRow >= 0)
            {
                FactionStatistics fs = dataGridViewFactions.Rows[dataGridViewFactions.RightClickRow].Tag as FactionStatistics;

                var dgvpanel = new ExtendedControls.ExtPanelDataGridViewScrollWithDGV <BaseUtils.DataGridViewColumnHider>();
                dgvpanel.DataGrid.CreateTextColumns("System".T(EDTx.UserControlModules_System), 100, 5,
                                                    "System Address".T(EDTx.UserControlFactions_SystemAddress), 60, 5,
                                                    "Missions".T(EDTx.UserControlMissions_MPlural), 50, 5,
                                                    "+Influence".T(EDTx.UserControlFactions_colInfluence), 50, 5,       // these align with columns of main view, with same names
                                                    "Commds +".T(EDTx.UserControlFactions_CBought), 50, 5,
                                                    "Commds -".T(EDTx.UserControlFactions_CSold), 50, 5,
                                                    "Mats +".T(EDTx.UserControlFactions_MBought), 50, 5,
                                                    "Mats -".T(EDTx.UserControlFactions_MSold), 50, 5,
                                                    "Bounties".T(EDTx.UserControlFactions_BountiesPlural), 50, 5,
                                                    "Rewards".T(EDTx.UserControlFactions_RewardsPlural), 60, 5,
                                                    "Bonds".T(EDTx.UserControlFactions_BondsPlural), 50, 5,
                                                    "Rewards".T(EDTx.UserControlFactions_RewardsPlural), 60, 5);
                dgvpanel.DataGrid.SortCompare += (s, ev) => { if (ev.Column.Index >= 1)
                                                              {
                                                                  ev.SortDataGridViewColumnNumeric();
                                                              }
                };
                dgvpanel.DataGrid.RowHeadersVisible           = false;
                dgvpanel.DataGrid.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
                for (int col = 1; col < dgvpanel.DataGrid.ColumnCount - 1; col++)
                {
                    dgvpanel.DataGrid.Columns[col].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                }

                DGVLoadColumnLayout(dgvpanel.DataGrid, "ShowSystemDetail");

                var systems = new List <SystemInfo>();
                foreach (var si in fs.Systems.Values)
                {
                    string systemName = null;
                    if (last_he != null)
                    {
                        foreach (var he in HistoryList.FilterBefore(discoveryform.history.EntryOrder(), last_he,
                                                                    (x) => x.System.SystemAddress == si.SystemAddress))
                        {
                            systemName = he.System.Name;
                            break;
                        }
                    }
                    systems.Add(new SystemInfo {
                        Name = systemName, Address = si.SystemAddress, Missions = si.Missions, Influence = si.Influence
                    });
                }

                var list = FilterHistory((x) => (x.journalEntry is IStatsJournalEntryMatCommod && x.StationFaction == fs.Name) ||
                                         (x.journalEntry is IStatsJournalEntryBountyOrBond &&
                                          (x.journalEntry as IStatsJournalEntryBountyOrBond).HasFaction(fs.Name)));
                foreach (var he in list)
                {
                    SystemInfo si = systems.Find(x =>
                                                 (he.System.SystemAddress != null && x.Address == he.System.SystemAddress) ||
                                                 (he.System.Name != null && x.Name == he.System.Name));
                    if (si == null)
                    {
                        si = new SystemInfo {
                            Name = he.System.Name, Address = he.System.SystemAddress
                        };
                        systems.Add(si);
                    }
                    if (he.journalEntry is IStatsJournalEntryMatCommod)
                    {
                        var items = (he.journalEntry as IStatsJournalEntryMatCommod).ItemsList;
                        foreach (var i in items)
                        {
                            if (he.journalEntry.EventTypeID == JournalTypeEnum.MaterialTrade)
                            {
                                if (i.Count > 0)
                                {
                                    si.AddMaterialsBought(i.Count);
                                }
                                else if (i.Count < 0)
                                {
                                    si.AddMaterialsSold(i.Count);
                                }
                            }
                            else
                            {
                                if (i.Count > 0)
                                {
                                    si.AddCommoditiesBought(i.Count);
                                }
                                else if (i.Count < 0)
                                {
                                    si.AddCommoditiesSold(i.Count);
                                }
                            }
                        }
                    }
                    else
                    {
                        if (he.journalEntry.EventTypeID == JournalTypeEnum.Bounty)
                        {
                            si.AddBounties(1);
                            si.AddBountyRewardsValue((he.journalEntry as IStatsJournalEntryBountyOrBond).FactionReward(fs.Name));
                        }
                        else if (he.journalEntry.EventTypeID == JournalTypeEnum.FactionKillBond)
                        {
                            si.AddKillBonds(1);
                            si.AddBondsRewardsValue((he.journalEntry as IStatsJournalEntryBountyOrBond).FactionReward(fs.Name));
                        }
                    }
                }

                foreach (var system in systems)
                {
                    object[] rowobj = { system.Name,
                                        system.Address,
                                        system.Missions?.ToString("N0"),
                                        system.Influence?.ToString("N0"),
                                        system.CommoditiesBought?.ToString("N0"),
                                        system.CommoditiesSold?.ToString("N0"),
                                        system.MaterialsBought?.ToString("N0"),
                                        system.MaterialsSold?.ToString("N0"),
                                        system.Bounties?.ToString("N0"),
                                        system.BountyRewardsValue?.ToString("N0"),
                                        system.KillBonds?.ToString("N0"),
                                        system.BondsRewardsValue?.ToString("N0") };
                    var      row = dgvpanel.DataGrid.RowTemplate.Clone() as DataGridViewRow;
                    row.CreateCells(dgvpanel.DataGrid, rowobj);
                    dgvpanel.DataGrid.Rows.Add(row);
                }

                ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm();
                f.Add(new ExtendedControls.ConfigurableForm.Entry(dgvpanel, "Grid", "", new System.Drawing.Point(3, 30), new System.Drawing.Size(960, 400), null)
                {
                    anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom
                });
                f.AddOK(new Point(960 - 100, 460), "OK", anchor: AnchorStyles.Right | AnchorStyles.Bottom);
                f.InstallStandardTriggers();
                f.AllowResize = true;

                f.ShowDialogCentred(FindForm(), FindForm().Icon, "Systems Detail for ".T(EDTx.UserControlFactions_SystemsDetailFor) + fs.Name, closeicon: true);

                DGVSaveColumnLayout(dgvpanel.DataGrid, "ShowSystemDetail");
            }
        }
Example #24
0
        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:".Tx(EDTx.EDDiscoveryForm_ConfirmSyncToEDSM) + Environment.NewLine + last_si.ShipNameIdentType, "Warning".T(EDTx.Warning), MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                    {
                        var je = new EliteDangerousCore.JournalEvents.JournalShipyardSell(DateTime.UtcNow);
                        je.ShipTypeFD = last_si.ShipFD;
                        je.SellShipId = last_si.ID;
                        je.ShipPrice  = 0;
                        je.SetCommander(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();
            }
        }
        public void EDSMSend()
        {
            var helist = EDSMJournalSync.GetListToSend(history.EntryOrder());               // find out what to send..

            if (helist.Count >= 500)
            {
                ExtendedControls.ConfigurableForm cf = new ExtendedControls.ConfigurableForm();

                int width = 400;

                DateTime lasthe = helist.Last().EventTimeUTC;

                cf.Add(new ExtendedControls.ConfigurableForm.Entry("UC", typeof(Label),
                                                                   string.Format("There are {0} EDSM reports to send, this will take time and bandwidth, choose from the following what to do. Entries before this will be marked as sent.".T(EDTx.EDDiscoveryForm_SendEDSMCaption), helist.Count),
                                                                   new Point(5, 30), new Size(width - 5 - 20, 100), null)
                {
                    textboxmultiline = true
                });

                cf.Add(new ExtendedControls.ConfigurableForm.Entry("All", typeof(ExtendedControls.ExtButton),
                                                                   "Send All to EDSM".T(EDTx.EDDiscoveryForm_SendEDSMAll),
                                                                   new Point(5, 130), new Size(width - 5 - 20, 24), null));

                cf.Add(new ExtendedControls.ConfigurableForm.Entry("Today", typeof(ExtendedControls.ExtButton),
                                                                   "Send Last 24 Hours of entries to EDSM".T(EDTx.EDDiscoveryForm_SendEDSM24),
                                                                   new Point(5, 180), new Size(width - 5 - 20, 24), null));

                cf.Add(new ExtendedControls.ConfigurableForm.Entry("Custom", typeof(ExtendedControls.ExtButton),
                                                                   "Send From".T(EDTx.EDDiscoveryForm_SendEDSMFrom),
                                                                   new Point(5, 230), new Size(80, 24), null));

                cf.Add(new ExtendedControls.ConfigurableForm.Entry("Date", typeof(ExtendedControls.ExtDateTimePicker),
                                                                   lasthe.AddDays(-28).ToStringZulu(),
                                                                   new Point(100, 230), new Size(width - 100 - 20, 24), null));

                cf.Add(new ExtendedControls.ConfigurableForm.Entry("None", typeof(ExtendedControls.ExtButton),
                                                                   "EDSM is up to date - send Nothing more".T(EDTx.EDDiscoveryForm_SendEDSMNone),
                                                                   new Point(5, 280), new Size(width - 5 - 20, 24), null));

                cf.Add(new ExtendedControls.ConfigurableForm.Entry("Cancel", typeof(ExtendedControls.ExtButton),
                                                                   "I'll decide later, do nothing".T(EDTx.EDDiscoveryForm_SendEDSMCancel),
                                                                   new Point(5, 330), new Size(width - 5 - 20, 24), null));

                DateTime date = DateTime.UtcNow;

                cf.Trigger += (dialogname, controlname, tag) =>
                {
                    if (controlname.Contains("All"))
                    {
                        date = new DateTime(1900, 1, 1);
                        cf.ReturnResult(DialogResult.OK);
                    }
                    else if (controlname.Contains("Today"))
                    {
                        date = lasthe.AddDays(-1);
                        cf.ReturnResult(DialogResult.OK);
                    }
                    else if (controlname.Contains("Custom"))
                    {
                        date = cf.GetDateTime("Date").Value.ToUniversalTime();
                        cf.ReturnResult(DialogResult.OK);
                    }
                    else if (controlname.Contains("None"))
                    {
                        cf.ReturnResult(DialogResult.OK);
                    }
                    else if (controlname.Contains("Cancel"))
                    {
                        cf.ReturnResult(DialogResult.Cancel);
                    }
                };

                if (cf.ShowDialogCentred(this.FindForm(), this.FindForm().Icon, "Sending a large number of EDSM Entries".T(EDTx.EDDiscoveryForm_SendEDSMTitle)) == DialogResult.Cancel)
                {
                    return;
                }

                var jes = helist.Where(x => x.EventTimeUTC < date).Select(x => x.journalEntry).ToList();
                JournalEntry.SetEdsmSyncList(jes);

                helist = EDSMJournalSync.GetListToSend(history.EntryOrder());               // find out what to send..
            }

            if (helist.Count > 0)
            {
                EDSMJournalSync.SendEDSMEvents(l => LogLine(l), helist);
            }
        }
        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);
        }
        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();
            }
        }
Example #28
0
        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);
        }