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);
                sd.DrawSystem(sys, 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);
        }
Exemple #2
0
        private void FillComboBoxes(HistoryList hl)
        {
            string selfrom = comboBoxCustomFrom.Text;
            string selto   = comboBoxCustomTo.Text;

            comboBoxCustomFrom.Items.Clear();
            comboBoxCustomTo.Items.Clear();

            comboBoxCustomFrom.Items.Add("Travel History Entry Last".T(EDTx.UserControlMarketData_LEntry));
            comboBoxCustomTo.Items.Add("None".T(EDTx.None));

            comboboxentries.Clear();

            List <HistoryEntry>        hlcpb = HistoryList.FilterByCommodityPricesBackwards(hl.EntryOrder());
            JournalCommodityPricesBase last  = null;

            foreach (HistoryEntry h in hlcpb)
            {
                var j = (JournalCommodityPricesBase)h.journalEntry;
                if (last == null || !j.Station.Equals(last.Station) || last.EventTimeUTC - j.EventTimeUTC >= new TimeSpan(0, 15, 0))
                {
                    comboboxentries.Add(h);
                    string v = h.System.Name + ":" + h.WhereAmI + " " + "on".T(EDTx.on) + " " + EDDConfig.Instance.ConvertTimeToSelectedFromUTC(h.EventTimeUTC).ToString();
                    if (h.journalEntry is JournalEDDCommodityPrices)
                    {
                        v += " (CAPI)";
                    }
                    comboBoxCustomFrom.Items.Add(v);
                    comboBoxCustomTo.Items.Add(v);
                    last = j;
                }
            }

            comboBoxCustomFrom.Enabled = comboBoxCustomTo.Enabled = false;

            if (comboBoxCustomFrom.Items.Contains(selfrom))
            {
                comboBoxCustomFrom.SelectedItem = selfrom;
            }
            else
            {
                comboBoxCustomFrom.SelectedIndex = 0;
            }

            if (comboBoxCustomTo.Items.Contains(selto))
            {
                comboBoxCustomTo.SelectedItem = selto;
            }
            else
            {
                comboBoxCustomTo.SelectedIndex = 0;
            }

            comboBoxCustomFrom.Enabled = comboBoxCustomTo.Enabled = true;
        }
Exemple #3
0
        private void Display()
        {
            //Stopwatch swp = new Stopwatch(); swp.Start();

            System.Diagnostics.Trace.WriteLine(BaseUtils.AppTicks.TickCountLap(this, true) + " MK " + displaynumber + " Begin Display");

            DataGridViewColumn sortcol   = dataGridViewMarketData.SortedColumn != null ? dataGridViewMarketData.SortedColumn : dataGridViewMarketData.Columns[0];
            SortOrder          sortorder = dataGridViewMarketData.SortOrder;

            int    firstdisplayed = dataGridViewMarketData.FirstDisplayedScrollingRowIndex;
            string commodity      = (dataGridViewMarketData.CurrentRow != null) ? (string)dataGridViewMarketData.CurrentRow.Cells[1].Value : null;
            int    currentoffset  = (dataGridViewMarketData.CurrentRow != null) ? Math.Max(0, dataGridViewMarketData.CurrentRow.Index - firstdisplayed) : 0;

            dataGridViewMarketData.Rows.Clear();
            labelLocation.Text = "No Data".Tx();
            toolTip.SetToolTip(labelLocation, null);

            HistoryEntry left  = (eddmd_left != null) ? eddmd_left : last_eddmd; // if we have a selected left, use it, else use the last eddmd
            HistoryEntry cargo = (eddmd_left != null) ? eddmd_left : last_he;    // if we have a selected left, use it, else use the last he

            if (left != null)                                                    // we know it has a journal entry of EDD commodity..
            {
                //System.Diagnostics.Debug.WriteLine(Environment.NewLine + "From " + current_displayed?.WhereAmI + " to " + left.WhereAmI);

                JournalCommodityPricesBase ecp  = left.journalEntry as JournalCommodityPricesBase;
                List <CCommodities>        list = ecp.Commodities;

                //System.Diagnostics.Debug.WriteLine("Test Right " + eddmd_right?.WhereAmI + " vs " + left.WhereAmI);
                if (eddmd_right != null && !Object.ReferenceEquals(eddmd_right, left))   // if got a comparision, and not the same data..
                {
                    if (checkBoxAutoSwap.Checked &&
                        left.System.Name.Equals(eddmd_right.System.Name) &&     // if left system being displayed is same as right system
                        left.WhereAmI.Equals(eddmd_right.WhereAmI))             // that means we can autoswap comparisions around
                    {
                        //System.Diagnostics.Debug.WriteLine("Arrived at last left station, repick " + current_displayed.WhereAmI + " as comparision");

                        int index = comboboxentries.FindIndex(x => x.System.Name.Equals(current_displayed.System.Name) && x.WhereAmI.Equals(current_displayed.WhereAmI));
                        if (index >= 0)         // if found it, swap to last instance of system
                        {
                            comboBoxCustomTo.Enabled       = false;
                            comboBoxCustomTo.SelectedIndex = index + 1;
                            comboBoxCustomTo.Enabled       = true;
                            eddmd_right = comboboxentries[index];
                            //System.Diagnostics.Debug.WriteLine("Right is now " + eddmd_right.WhereAmI);
                        }
                    }

                    //System.Diagnostics.Debug.WriteLine("Right " + eddmd_right.System.Name + " " + eddmd_right.WhereAmI);
                    list = CCommodities.Merge(list, ((JournalCommodityPricesBase)eddmd_right.journalEntry).Commodities, eddmd_right.WhereAmI);
                }

                List <MaterialCommodities> mclist   = cargo.MaterialCommodity.Sort(true);   // stuff we have..  commodities only
                List <MaterialCommodities> notfound = new List <MaterialCommodities>();
                foreach (MaterialCommodities m in mclist)
                {
                    int index = list.FindIndex(x => x.fdname.EqualsAlphaNumOnlyNoCase(m.Details.Name));   // try and match, remove any spaces/_ and lower case it for matching
                    if (index >= 0)
                    {
                        list[index].CargoCarried = m.Count; // found it, set cargo count..
                    }
                    else
                    {
                        notfound.Add(m);        // not found, add to list for bottom
                    }
                }

                FontFamily ff      = new FontFamily(this.Font.Name);
                bool       buyonly = checkBoxBuyOnly.Checked;

                foreach (CCommodities c in list)
                {
                    if (!buyonly || (c.buyPrice > 0 || c.ComparisionBuy))
                    {
                        MaterialCommodityData mc = MaterialCommodityData.GetByFDName(c.fdname);

                        object[] rowobj = { mc?.TranslatedType ?? c.loccategory.Alt(c.category),
                                            mc?.Name ?? c.locName,
                                            c.sellPrice > 0 ? c.sellPrice.ToString() : "",
                                            c.buyPrice > 0 ? c.buyPrice.ToString() : "",
                                            c.CargoCarried,
                                            c.demand > 1 ? c.demand.ToString() : "",
                                            c.stock > 0 ? c.stock.ToString() : "",
                                            c.meanPrice > 0 ? c.meanPrice.ToString() : "",
                                            c.ComparisionLR,
                                            c.ComparisionRL };

                        int rowno = dataGridViewMarketData.Rows.Add(rowobj);

                        if (c.ComparisionRightOnly && ff != null && ff.IsStyleAvailable(FontStyle.Italic))
                        {
                            for (int i = 1; i < dataGridViewMarketData.Columns.Count; i++)
                            {
                                dataGridViewMarketData.Rows[rowno].Cells[i].Style.Font = new Font(this.Font, FontStyle.Italic);
                            }
                        }

                        dataGridViewMarketData.Rows[rowno].Cells[0].ToolTipText     =
                            dataGridViewMarketData.Rows[rowno].Cells[1].ToolTipText = c.ToString();
                    }
                }

                foreach (MaterialCommodities m in notfound)
                {
                    if (m.Count > 0)
                    {
                        object[] rowobj = { m.Details.TranslatedType,
                                            m.Details.Name,
                                            "",
                                            "",
                                            m.Count,
                                            "",
                                            "",
                                            "",
                                            "",
                                            "" };

                        int rowno = dataGridViewMarketData.Rows.Add(rowobj);
                        dataGridViewMarketData.Rows[rowno].Cells[0].ToolTipText     =
                            dataGridViewMarketData.Rows[rowno].Cells[1].ToolTipText = "Cargo only, no market data on this item".Tx(this, "Conly");
                    }
                }

                current_displayed  = left;
                labelLocation.Text = left.System.Name + ":" + left.WhereAmI;
                string r = "Recorded at " + ((EDDiscoveryForm.EDDConfig.DisplayUTC) ? left.EventTimeUTC.ToString() : left.EventTimeLocal.ToString());
                toolTip.SetToolTip(labelLocation, r);

                System.Diagnostics.Trace.WriteLine(BaseUtils.AppTicks.TickCountLap(this) + " MK " + displaynumber + " Load Finished");
            }

            dataGridViewMarketData.Sort(sortcol, (sortorder == SortOrder.Descending) ? ListSortDirection.Descending : ListSortDirection.Ascending);
            dataGridViewMarketData.Columns[sortcol.Index].HeaderCell.SortGlyphDirection = sortorder;

            if (commodity != null)
            {
                foreach (DataGridViewRow rw in dataGridViewMarketData.Rows)
                {
                    string v = (string)rw.Cells[1].Value;
                    if (v.Equals(commodity))            // Find the commodity, and set it to the same relative position as before.
                    {
                        dataGridViewMarketData.CurrentCell = dataGridViewMarketData.Rows[rw.Index].Cells[1];
                        dataGridViewMarketData.FirstDisplayedScrollingRowIndex = Math.Max(rw.Index - currentoffset, 0);
                        break;
                    }
                }
            }

            //System.Diagnostics.Debug.WriteLine("Stop watch" + swp.ElapsedMilliseconds);
        }
        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 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);
        }
Exemple #6
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());
        }