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;

                DGVLoadColumnLayout(dgvpanel.DataGrid, "ShowBonds");

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

                DGVSaveColumnLayout(dgvpanel.DataGrid, "ShowBonds");
            }
        }
Beispiel #2
0
        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.AddOK(new Point(width - 100, 70), "Press to Accept".T(EDTx.SurfaceBookmarkUserControl_PresstoAccept));
            f.AddCancel(new Point(width - 200, 70), "Press to Cancel".T(EDTx.SurfaceBookmarkUserControl_PresstoCancel));

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

            DialogResult res = f.ShowDialogCentred(this.FindForm(), this.FindForm().Icon, "Manually Add Planet".T(EDTx.SurfaceBookmarkUserControl_MAP), closeicon: true);

            string pname = f.Get("Planet");

            if (res == DialogResult.OK && pname.HasChars())
            {
                if (!BodyName.Items.Contains(pname))
                {
                    BodyName.Items.Add(pname);
                }
            }
        }
Beispiel #3
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 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
                }
            }
        }
        public static async void ShowScanOrMarketForm(Form parent, Object tag, bool checkedsm, HistoryList hl)     // tag can be a Isystem or an He.. output depends on it.
        {
            if (tag == null)
            {
                return;
            }

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

            Size infosize  = parent.SizeWithinScreen(new Size(parent.Width * 6 / 8, parent.Height * 6 / 8), 128, 128 + 100);       // go for this, but allow this around window
            int  topmargin = 40;

            HistoryEntry           he  = tag as HistoryEntry;                     // is tag HE?
            ISystem                sys = he != null ? he.System : tag as ISystem; // if so, sys is he.system, else its a direct sys
            ScanDisplayUserControl sd  = null;
            string title = "System".T(EDTx.ScanDisplayForm_Sys) + ": " + sys.Name;

            AutoScaleMode asm = AutoScaleMode.Font;

            if (he != null && (he.EntryType == JournalTypeEnum.Market || he.EntryType == JournalTypeEnum.EDDCommodityPrices))  // station data..
            {
                he.FillInformation(out string info, out string detailed);

                f.Add(new ExtendedControls.ConfigurableForm.Entry("RTB", typeof(ExtendedControls.ExtRichTextBox), detailed, new Point(0, topmargin), infosize, null));

                JournalCommodityPricesBase jm = he.journalEntry as JournalCommodityPricesBase;
                title += ", " + "Station".T(EDTx.ScanDisplayForm_Station) + ": " + jm.Station;
            }
            else
            {
                sd           = new ScanDisplayUserControl();
                sd.CheckEDSM = checkedsm;
                int selsize = (int)(EDDTheme.Instance.GetFont.Height / 16.0f * 48.0f);
                sd.SetSize(selsize);
                sd.Size = infosize;

                StarScan.SystemNode data = await hl.StarScan.FindSystemAsync(sys, sd.CheckEDSM);    // look up system async

                if (data != null)
                {
                    long value = data.ScanValue(sd.CheckEDSM);
                    title += " ~ " + value.ToString("N0") + " cr";
                }

                sd.BackColor = EDDTheme.Instance.Form;
                sd.DrawSystem(data, null, hl);

                int wastedh = infosize.Height - sd.DisplayAreaUsed.Y - 10 - 40;
                if (wastedh > 0)
                {
                    infosize.Height -= wastedh;
                }

                asm = AutoScaleMode.None;   // because we are using a picture box, it does not autoscale, so we can't use that logic on it.

                f.Add(new ExtendedControls.ConfigurableForm.Entry("Sys", null, null, new Point(0, topmargin), infosize, null)
                {
                    control = sd
                });
            }

            f.AddOK(new Point(infosize.Width - 120, topmargin + infosize.Height + 10));

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

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

            f.Show(parent);
        }
        private void 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");
            }
        }
        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");
            }
        }
Beispiel #8
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();
            }
        }
Beispiel #10
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();
            }
        }
Beispiel #11
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");
            }
        }