ExtendedControls.ExtPictureBox.ImageElement AddColText(int coli, int nextcol, int rowpos, string text, Color textcolour, Color backcolour, string tooltip, Image opt = null, string imagetooltip = null) { if (text.Length > 0) // don't place empty text, do not want image handling to work on blank screen { int endpos = (nextcol == 0) ? 1920 : (columnpos[nextcol] - columnpos[coli] - 4); int colpos = scanpostextoffset.X + columnpos[coli]; if (opt != null) { pictureBox.AddImage(new Rectangle(colpos, rowpos, 24, 24), Icons.Controls.firstdiscover, null, imagetooltip, false); colpos += 24; } ExtendedControls.ExtPictureBox.ImageElement e = pictureBox.AddTextAutoSize(new Point(colpos, rowpos), new Size(endpos, 200), text, displayfont, textcolour, backcolour, 1.0F, null, tooltip); return(e); } else { return(null); } }
private void Timetimer_Tick(object sender, EventArgs e) { Font displayfont = discoveryform.theme.GetFont; Color textcolour = IsTransparent ? discoveryform.theme.SPanelColor : discoveryform.theme.LabelColor; Color backcolour = IsTransparent ? Color.Transparent : this.BackColor; using (StringFormat frmt = new StringFormat()) { var lab = new ExtendedControls.ExtPictureBox.ImageElement(); lab.TextAutosize(timeie.Position, timeie.Size, TimeText(false), displayfont, textcolour, backcolour, 1.0F, frmt: frmt); pictureBox.RemoveItem(timeie, backcolour); pictureBox.AddItem(lab); timeie = lab; } }
private void pictureBox_ClickElement(object sender, MouseEventArgs e, ExtendedControls.ExtPictureBox.ImageElement i, object tag) { if (i != null) { string stag = tag as string; HistoryEntry he = tag as HistoryEntry; if (stag != null) // its SCAN for now { HideScanData(null, null); } else if (he != null) { EliteDangerousCore.EDSM.EDSMClass edsm = new EliteDangerousCore.EDSM.EDSMClass(); if (!edsm.ShowSystemInEDSM(he.System.Name)) { ExtendedControls.MessageBoxTheme.Show(FindForm(), "System " + he.System.Name + " unknown to EDSM"); } } } }
private void Display() { timetimer.Stop(); // redisplay, stop the time timer and lose the timeie. timeie = null; pictureBox.ClearImageList(); Controls.RemoveByKey("chart"); if (curlist != null) { var found = ReadHistory(out int prospectorsused, out int collectorsused, out int asteroidscracked, out int prospected, out int[] content); Font displayfont = discoveryform.theme.GetFont; Color textcolour = IsTransparent ? discoveryform.theme.SPanelColor : discoveryform.theme.LabelColor; Color backcolour = IsTransparent ? Color.Transparent : this.BackColor; Color GridC = discoveryform.theme.GridBorderLines; Color TextC = discoveryform.theme.GridCellText; Color BackC = discoveryform.theme.GridCellBack; Color[] LineC = new Color[] { discoveryform.theme.KnownSystemColor, discoveryform.theme.TextBlockHighlightColor, Color.Blue, Color.Yellow, Color.Green, Color.Gray, Color.HotPink, Color.Teal }; using (StringFormat frmt = new StringFormat()) { frmt.FormatFlags = StringFormatFlags.NoWrap; int vpos = 5; int colwidth = (int)BaseUtils.BitMapHelpers.MeasureStringInBitmap("0000", displayfont, frmt).Width; int percentwidth = (int)BaseUtils.BitMapHelpers.MeasureStringInBitmap("00000.0", displayfont, frmt).Width; int hmlwidth = percentwidth * 2; int[] colsw = new int[] { colwidth * 4, colwidth, colwidth, colwidth, percentwidth, percentwidth, percentwidth, percentwidth, percentwidth, percentwidth, hmlwidth, colwidth }; int[] hpos = new int[colsw.Length]; hpos[0] = 4; for (int i = 1; i < hpos.Length; i++) { hpos[i] = hpos[i - 1] + colsw[i - 1]; } int limpetscolpos = 0; if (curlist.Count() > 0) { lastrefined = found.Sum(x => x.amountrefined); // for use by timer string timetext = TimeText(true); if (timetext.HasChars()) { timeie = pictureBox.AddTextAutoSize(new Point(hpos[0], vpos), new Size(colsw[0], this.Height), timetext, displayfont, textcolour, backcolour, 1.0F, frmt: frmt); limpetscolpos = 1; } } else { lastrefined = 0; } { string text = string.Format("Limpets left {0}, Cargo left {1}".T(EDTx.UserControlMiningOverlay_Limcargo), limpetsleftdisplay, cargoleftdisplay); if (collectorsused > 0 || prospectorsused > 0 || asteroidscracked > 0) { text += string.Format(", Prospectors Fired {0}, Collectors Deployed {1}, Cracked {2}".T(EDTx.UserControlMiningOverlay_Proscoll), prospectorsused, collectorsused, asteroidscracked); } var ieprosp = pictureBox.AddTextAutoSize(new Point(hpos[limpetscolpos], vpos), new Size(this.Width - hpos[limpetscolpos] - 20, this.Height), text, displayfont, textcolour, backcolour, 1.0F, frmt: frmt); vpos = ieprosp.Location.Bottom + displayfont.ScalePixels(2); } bool displaytable = found.Count > 0 && (extCheckBoxZeroRefined.Checked ? lastrefined > 0 : true); if (displaytable) { var ieheader = pictureBox.AddTextAutoSize(new Point(hpos[1], vpos), new Size(colsw[1], this.Height), "Ref.".T(EDTx.UserControlMiningOverlay_ref), displayfont, textcolour, backcolour, 1.0F, frmt: frmt); pictureBox.AddTextAutoSize(new Point(hpos[2], vpos), new Size(colsw[2], this.Height), "Coll.".T(EDTx.UserControlMiningOverlay_coll), displayfont, textcolour, backcolour, 1.0F, frmt: frmt); pictureBox.AddTextAutoSize(new Point(hpos[3], vpos), new Size(colsw[3], this.Height), "Prosp.".T(EDTx.UserControlMiningOverlay_pros), displayfont, textcolour, backcolour, 1.0F, frmt: frmt); pictureBox.AddTextAutoSize(new Point(hpos[4], vpos), new Size(colsw[4], this.Height), "Ratio%".T(EDTx.UserControlMiningOverlay_ratio), displayfont, textcolour, backcolour, 1.0F, frmt: frmt); pictureBox.AddTextAutoSize(new Point(hpos[5], vpos), new Size(colsw[5], this.Height), "Avg%".T(EDTx.UserControlMiningOverlay_avg), displayfont, textcolour, backcolour, 1.0F, frmt: frmt); pictureBox.AddTextAutoSize(new Point(hpos[6], vpos), new Size(colsw[6], this.Height), "Min%".T(EDTx.UserControlMiningOverlay_min), displayfont, textcolour, backcolour, 1.0F, frmt: frmt); pictureBox.AddTextAutoSize(new Point(hpos[7], vpos), new Size(colsw[7], this.Height), "Max%".T(EDTx.UserControlMiningOverlay_max), displayfont, textcolour, backcolour, 1.0F, frmt: frmt); pictureBox.AddTextAutoSize(new Point(hpos[8], vpos), new Size(colsw[8], this.Height), "M.Lode".T(EDTx.UserControlMiningOverlay_mload), displayfont, textcolour, backcolour, 1.0F, frmt: frmt); pictureBox.AddTextAutoSize(new Point(hpos[9], vpos), new Size(colsw[9], this.Height), "HML Ct.".T(EDTx.UserControlMiningOverlay_hml), displayfont, textcolour, backcolour, 1.0F, frmt: frmt); pictureBox.AddTextAutoSize(new Point(hpos[10], vpos), new Size(colsw[10], this.Height), "Discv".T(EDTx.UserControlMiningOverlay_discv), displayfont, textcolour, backcolour, 1.0F, frmt: frmt); vpos = ieheader.Location.Bottom + displayfont.ScalePixels(2); if (prospected > 0) { var ie = pictureBox.AddTextAutoSize(new Point(hpos[0], vpos), new Size(colsw[0], this.Height), "Asteroids Pros.".T(EDTx.UserControlMiningOverlay_astpros), displayfont, textcolour, backcolour, 1.0F, frmt: frmt); pictureBox.AddTextAutoSize(new Point(hpos[3], vpos), new Size(colsw[3], this.Height), prospected.ToString("N0"), displayfont, textcolour, backcolour, 1.0F, frmt: frmt); pictureBox.AddTextAutoSize(new Point(hpos[9], vpos), new Size(colsw[9], this.Height), content[0].ToString("N0") + "/" + content[1].ToString("N0") + "/" + content[2].ToString("N0"), displayfont, textcolour, backcolour, 1.0F, frmt: frmt); vpos = ie.Location.Bottom + displayfont.ScalePixels(2); } foreach (var m in found) { if (!extCheckBoxZeroRefined.Checked || m.amountrefined > 0) { var ie1 = pictureBox.AddTextAutoSize(new Point(hpos[0], vpos), new Size(colsw[0], this.Height), m.friendlyname, displayfont, textcolour, backcolour, 1.0F, frmt: frmt); pictureBox.AddTextAutoSize(new Point(hpos[1], vpos), new Size(colsw[1], this.Height), m.amountrefined.ToString("N0"), displayfont, textcolour, backcolour, 1.0F, frmt: frmt); pictureBox.AddTextAutoSize(new Point(hpos[2], vpos), new Size(colsw[2], this.Height), (m.amountcollected - m.amountdiscarded).ToString("N0"), displayfont, textcolour, backcolour, 1.0F, frmt: frmt); if (m.prospectednoasteroids > 0) { pictureBox.AddTextAutoSize(new Point(hpos[3], vpos), new Size(colsw[3], this.Height), m.prospectednoasteroids.ToString("N0"), displayfont, textcolour, backcolour, 1.0F, frmt: frmt); pictureBox.AddTextAutoSize(new Point(hpos[4], vpos), new Size(colsw[4], this.Height), (100.0 * (double)m.prospectednoasteroids / prospected).ToString("N1"), displayfont, textcolour, backcolour, 1.0F, frmt: frmt); pictureBox.AddTextAutoSize(new Point(hpos[5], vpos), new Size(colsw[5], this.Height), m.prospectedamounts.Average().ToString("N1"), displayfont, textcolour, backcolour, 1.0F, frmt: frmt); pictureBox.AddTextAutoSize(new Point(hpos[6], vpos), new Size(colsw[6], this.Height), m.prospectedamounts.Min().ToString("N1"), displayfont, textcolour, backcolour, 1.0F, frmt: frmt); pictureBox.AddTextAutoSize(new Point(hpos[7], vpos), new Size(colsw[7], this.Height), m.prospectedamounts.Max().ToString("N1"), displayfont, textcolour, backcolour, 1.0F, frmt: frmt); pictureBox.AddTextAutoSize(new Point(hpos[9], vpos), new Size(colsw[9], this.Height), m.content[0].ToString("N0") + "/" + m.content[1].ToString("N0") + "/" + m.content[2].ToString("N0"), displayfont, textcolour, backcolour, 1.0F, frmt: frmt); } if (m.motherloadasteroids > 0) { pictureBox.AddTextAutoSize(new Point(hpos[8], vpos), new Size(colsw[8], this.Height), m.motherloadasteroids.ToString("N0"), displayfont, textcolour, backcolour, 1.0F, frmt: frmt); } if (m.discovered) { pictureBox.AddTextAutoSize(new Point(hpos[10], vpos), new Size(colsw[10], this.Height), " *", displayfont, textcolour, backcolour, 1.0F, frmt: frmt); } vpos = ie1.Location.Bottom + displayfont.ScalePixels(2); } } } pictureBox.Render(true, new Size(0, vpos + displayfont.ScalePixels(8))); // control is resized with a min height var prospectedlist = found.Where(m => m.prospectednoasteroids > 0).ToList(); UpdateComboBox(prospectedlist.Select(m => m.friendlyname).ToList()); int?seli = selectedchart as int?; int?selm = selectedchart is string?prospectedlist.FindIndex(x => x.friendlyname == selectedchart as string) : default(int?); if (prospectedlist.Count > 0 && ((seli.HasValue && seli > 0) || selm.HasValue)) { List <MaterialsFound> matdata = new List <MaterialsFound>(); if (seli.HasValue) { if (seli == chartfixeditems.Length - 1) { seli = LineC.Length; } for (int i = 0; i < seli.Value && i < prospectedlist.Count; i++) { matdata.Add(prospectedlist[i]); } } else { matdata.Add(prospectedlist[selm.Value]); } try { Chart chart = new Chart(); chart.Name = "chart"; // important for remove by key above chart.Dock = DockStyle.Fill; chart.BorderlineColor = GridC; // around the whole thing. chart.BackColor = backcolour; // the whole chart background chart.BeginInit(); chart.BorderlineDashStyle = ChartDashStyle.Solid; ChartArea chartarea = new ChartArea(); chartarea.BorderColor = GridC; // gives the top/right colours for this type of chart chartarea.BorderDashStyle = ChartDashStyle.Solid; chartarea.BorderWidth = 1; chartarea.BackColor = BackC; // chart area is coloured slightly chartarea.AxisX.LabelStyle.ForeColor = TextC; // label on axis colour chartarea.AxisX.LabelStyle.Font = displayfont; chartarea.AxisX.MajorGrid.LineColor = GridC; // major grid colour chartarea.AxisX.LineColor = GridC; // axis (0 value) colour chartarea.AxisX.Title = "Content %".T(EDTx.UserControlMiningOverlay_content); chartarea.AxisX.TitleFont = displayfont; chartarea.AxisX.TitleForeColor = TextC; chartarea.AxisX.Interval = 10; chartarea.AxisX.Minimum = 0; chartarea.AxisY.LabelStyle.ForeColor = TextC; chartarea.AxisY.LabelStyle.Font = displayfont; chartarea.AxisY.MajorGrid.LineColor = GridC; chartarea.AxisY.LineColor = GridC; // axis (0 value) colour chartarea.AxisY.Title = "% Above".T(EDTx.UserControlMiningOverlay_above); chartarea.AxisY.TitleFont = displayfont; chartarea.AxisY.TitleForeColor = TextC; chartarea.AxisY.Interval = 10; chartarea.AxisY.Maximum = 101; chart.ChartAreas.Add(chartarea); chart.Titles.Clear(); var title = new Title((matdata.Count == 1 ? (matdata[0].friendlyname + " ") : "") + "Distribution".T(EDTx.UserControlMiningOverlay_dist), Docking.Top, displayfont, TextC); chart.Titles.Add(title); Legend legend = null; if (matdata.Count > 1) // one legend, series are attached to it via name field { legend = new Legend(); legend.Name = "Legend1"; legend.LegendStyle = LegendStyle.Column; legend.Docking = Docking.Right; legend.BackColor = backcolour; legend.ForeColor = TextC; chart.Legends.Add(legend); } int mi = 0; foreach (var m in matdata) { Series series = new Series(); series.Name = m.friendlyname; series.ChartArea = "ChartArea1"; series.ChartType = SeriesChartType.Line; series.Color = LineC[mi]; series.Legend = "Legend1"; int i = 0; for (i = 0; i < CFDbMax; i++) // 0 - fixed { int numberabove = m.prospectedamounts.Count(x => x >= i); series.Points.Add(new DataPoint(i, (double)numberabove / m.prospectednoasteroids * 100.0)); series.Points[i].AxisLabel = i.ToString(); } chart.Series.Add(series); mi++; } chart.EndInit(); Controls.Add(chart); Controls.SetChildIndex(chart, 0); } catch (NotImplementedException) { // Charting not implemented in mono System.Windows.Forms } } } buttonExtExcel.Enabled = found.Count != 0; } else { pictureBox.Render(); buttonExtExcel.Enabled = false; } Update(); }
private void pictureBox_ClickElement(object sender, MouseEventArgs eventargs, ExtendedControls.ExtPictureBox.ImageElement i, object tag) { if (i != null) { HistoryEntry he = tag as HistoryEntry; if (he != null) { EliteDangerousCore.EDSM.EDSMClass edsm = new EliteDangerousCore.EDSM.EDSMClass(); string url = edsm.GetUrlToEDSMSystem(he.System.Name, he.System.EDSMID); if (url.Length > 0) // may pass back empty string if not known, this solves another exception { System.Diagnostics.Process.Start(url); } else { ExtendedControls.MessageBoxTheme.Show(FindForm(), string.Format("System {0} unknown to EDSM".T(EDTx.UserControlTrippanel_UKN), he.System.Name)); } } else { var list = discoveryform.history.Where(p => p.IsFSDJump).OrderByDescending(p => p.EventTimeUTC).Take(2); if (list.Count() == 0) { return; } he = list.ToArray()[0]; if (he.StartMarker) { return; } he.journalEntry.SetStartFlag(); if (list.Count() > 1 && he.isTravelling) { he = list.ToArray()[1]; he.journalEntry.SetEndFlag(); } discoveryform.RefreshHistoryAsync(); } } }
void DisplayState(HistoryEntry he, HistoryEntry lastfsd) { pictureBox.ClearImageList(); lastHE = he; lastFSD = lastfsd; if (he != null) { Color textcolour = IsTransparent ? discoveryform.theme.SPanelColor : discoveryform.theme.LabelColor; Color backcolour = IsTransparent ? Color.Black : this.BackColor; int leftstart = 5; int topstart = 5; int coltext = leftstart; ExtendedControls.ExtPictureBox.ImageElement iedsm = null; if (showEDSMStartButtonsToolStripMenuItem.Checked) { iedsm = pictureBox.AddTextAutoSize(new Point(leftstart, topstart), new Size(1000, 1000), "EDSM", displayfont, backcolour, textcolour, 0.5F, he, "View system on EDSM"); iedsm.SetAlternateImage(BaseUtils.BitMapHelpers.DrawTextIntoAutoSizedBitmap("EDSM", iedsm.img.Size, displayfont, backcolour, textcolour.Multiply(1.2F), 0.5F), iedsm.pos, true); coltext = iedsm.pos.Right + displayfont.ScalePixels(8); } backcolour = IsTransparent ? Color.Transparent : this.BackColor; EliteDangerousCalculations.FSDSpec.JumpInfo ji = he.GetJumpInfo(); // may be null string line = String.Format("{0} [{1}]", he.System.Name, discoveryform.history.GetVisitsCount(he.System.Name)); if (showTargetToolStripMenuItem.Checked) { if (TargetClass.GetTargetPosition(out string name, out Point3D tpos)) { double dist = he.System.Distance(tpos.X, tpos.Y, tpos.Z); string mesg = "Left".T(EDTx.UserControlTrippanel_Left); if (ji != null) { int jumps = (int)Math.Ceiling(dist / ji.avgsinglejump); if (jumps > 0) { mesg = jumps.ToString() + " " + ((jumps == 1) ? "jump".T(EDTx.UserControlTrippanel_jump) : "jumps".T(EDTx.UserControlTrippanel_jumps)); } } line += String.Format("-> {0} {1:N1}ly {2}", name, dist, mesg); } else { line += " -> Target not set".T(EDTx.UserControlTrippanel_NoT); } } bool firstdiscovery = (lastfsd != null && (lastfsd.journalEntry as EliteDangerousCore.JournalEvents.JournalFSDJump).EDSMFirstDiscover); int line1hpos = coltext; if (firstdiscovery) { var i1 = pictureBox.AddImage(new Rectangle(line1hpos, 5, 24, 24), Icons.Controls.firstdiscover, null, "Shows if EDSM indicates your it's first discoverer".T(EDTx.UserControlTrippanel_FDEDSM), false); line1hpos = i1.pos.Right + Font.ScalePixels(8); } var eline1 = pictureBox.AddTextAutoSize(new Point(line1hpos, topstart), new Size(1000, 1000), line, displayfont, textcolour, backcolour, 1.0F); int line2vpos = eline1.pos.Bottom + displayfont.ScalePixels(8); line = ""; if (showTravelledDistanceToolStripMenuItem.Checked) { line = String.Format("{0:N1}{1},{2} " + "jumps".T(EDTx.UserControlTrippanel_jumps) + ", {3}", he.TravelledDistance, ((he.TravelledMissingjump > 0) ? "ly*" : "ly"), he.Travelledjumps, he.TravelledSeconds); } ShipInformation si = he.ShipInformation; if (si != null) { string addtext = ""; if (showFuelLevelToolStripMenuItem.Checked) { double fuel = si.FuelLevel; double tanksize = si.FuelCapacity; double warninglevelpercent = si.FuelWarningPercent; addtext = String.Format("{0}/{1}t", fuel.ToString("N1"), tanksize.ToString("N1")); if (warninglevelpercent > 0 && fuel < tanksize * warninglevelpercent / 100.0) { textcolour = discoveryform.theme.TextBlockHighlightColor; addtext += String.Format(" < {0}%", warninglevelpercent.ToString("N1")); } } if (ji != null) { HistoryEntry lastJet = discoveryform.history.GetLastHistoryEntry(x => x.journalEntry.EventTypeID == JournalTypeEnum.JetConeBoost); double boostval = 1; if (lastJet != null && lastfsd != null && lastJet.EventTimeLocal > lastfsd.EventTimeLocal) { boostval = (lastJet.journalEntry as EliteDangerousCore.JournalEvents.JournalJetConeBoost).BoostValue; } string range = ""; if (showCurrentFSDRangeToolStripMenuItem.Checked) { range += String.Format("cur {0:N1}ly{1}", ji.cursinglejump * boostval, boostval > 1 ? " Boost" : ""); } if (showAvgFSDRangeToolStripMenuItem.Checked) { range = range.AppendPrePad(String.Format("avg {0:N1}ly{1}", ji.avgsinglejump * boostval, boostval > 1 ? " Boost" : ""), ", "); } if (showMaxFSDRangeToolStripMenuItem.Checked) { range = range.AppendPrePad(String.Format("max {0:N1}ly{1}", ji.curfumessinglejump * boostval, boostval > 1 ? " Boost" : ""), ", "); } if (showFSDRangeToolStripMenuItem.Checked) { range = range.AppendPrePad(String.Format("{0:N1}ly/{1:N0}", ji.maxjumprange, ji.maxjumps), ", "); } if (range.HasChars()) { addtext = addtext.AppendPrePad(range, " | "); } } if (addtext.HasChars()) { line = line.AppendPrePad(addtext, " | "); } } if (showEDSMStartButtonsToolStripMenuItem.Checked) { ExtendedControls.ExtPictureBox.ImageElement start = pictureBox.AddTextFixedSizeC(new Point(leftstart, line2vpos), iedsm.img.Size, "Start", displayfont, backcolour, textcolour, 0.5F, true, "Start", "Set a journey start point"); start.SetAlternateImage(BaseUtils.BitMapHelpers.DrawTextIntoFixedSizeBitmapC("Start", start.img.Size, displayfont, backcolour, textcolour.Multiply(1.2F), 0.5F, true), start.pos, true); } if (line.HasChars()) { pictureBox.AddTextAutoSize(new Point(coltext, line2vpos), new Size(1000, 40), line, displayfont, textcolour, backcolour, 1.0F); } pictureBox.Render(); } }
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(); } }
int DrawHistoryEntry(HistoryEntry he, int rowpos, Point3D tpos, Color textcolour, Color backcolour) { List <string> coldata = new List <string>(); // First we accumulate the strings List <int> tooltipattach = new List <int>(); int initialrowpos = rowpos; int maxrowpos = rowpos; if (Config(Configuration.showTime)) { coldata.Add(EDDiscoveryForm.EDDConfig.ConvertTimeToSelectedFromUTC(he.EventTimeUTC).ToString("HH:mm.ss")); } if (Config(Configuration.showIcon)) { coldata.Add("`!!ICON!!"); // dummy place holder.. } he.FillInformation(out string EventDescription, out string EventDetailedInfo); if (Config(Configuration.showDescription)) { tooltipattach.Add(coldata.Count); coldata.Add(he.EventSummary.Replace("\r\n", " ")); } if (Config(Configuration.showInformation)) { tooltipattach.Add(coldata.Count); coldata.Add(EventDescription.Replace("\r\n", " ")); } if (layoutorder == 0 && Config(Configuration.showNotes)) { coldata.Add((he.SNC != null) ? he.SNC.Note.Replace("\r\n", " ") : ""); } bool showdistance = !Config(Configuration.showDistancesOnFSDJumpsOnly) || he.IsFSDCarrierJump; if (layoutorder == 2 && Config(Configuration.showDistancePerStar)) { coldata.Add(showdistance ? DistToStar(he, tpos) : ""); } if (Config(Configuration.showXYZ)) { coldata.Add((he.System.HasCoordinate && showdistance) ? he.System.X.ToString("0.00") : ""); coldata.Add((he.System.HasCoordinate && showdistance) ? he.System.Y.ToString("0.00") : ""); coldata.Add((he.System.HasCoordinate && showdistance) ? he.System.Z.ToString("0.00") : ""); } if (layoutorder > 0 && Config(Configuration.showNotes)) { coldata.Add((he.SNC != null) ? he.SNC.Note.Replace("\r\n", " ") : ""); } if (layoutorder < 2 && Config(Configuration.showDistancePerStar)) { coldata.Add(showdistance ? DistToStar(he, tpos) : ""); } int colnum = 0; ExtendedControls.ExtPictureBox.ImageElement edsm = null; if (Config(Configuration.showEDSMButton)) { Color backtext = (backcolour.IsFullyTransparent()) ? Color.Black : backcolour; edsm = pictureBox.AddTextAutoSize(new Point(scanpostextoffset.X + columnpos[colnum++], rowpos), new Size(200, 200), "EDSM", displayfont, backtext, textcolour, 0.5F, he, "View system on EDSM".T(EDTx.UserControlSpanel_TVE)); edsm.SetAlternateImage(BaseUtils.BitMapHelpers.DrawTextIntoAutoSizedBitmap("EDSM", new Size(200, 200), displayfont, backtext, textcolour.Multiply(1.2F), 0.5F), edsm.Location, true); } string tooltip = he.EventSummary + Environment.NewLine + EventDescription + Environment.NewLine + EventDetailedInfo; List <ExtendedControls.ExtPictureBox.ImageElement> items = new List <ExtPictureBox.ImageElement>(); for (int i = 0; i < coldata.Count; i++) // then we draw them, allowing them to overfill columns if required { int nextfull = i + 1; for (; nextfull < coldata.Count && Config(Configuration.showExpandOverColumns) && coldata[nextfull].Length == 0; nextfull++) { } if (coldata[i].Equals("`!!ICON!!")) // marker for ICON.. { Image img = he.journalEntry.Icon; var e = pictureBox.AddImage(new Rectangle(scanpostextoffset.X + columnpos[colnum + i], rowpos, img.Width, img.Height), img, null, null, false); maxrowpos = Math.Max(maxrowpos, e.Location.Bottom); items.Add(e); } else { var e = AddColText(colnum + i, colnum + nextfull, rowpos, coldata[i], textcolour, backcolour, tooltipattach.Contains(i) ? tooltip : null); if (e != null) { maxrowpos = Math.Max(maxrowpos, e.Location.Bottom); items.Add(e); } } } if (edsm != null) { edsm.Translate(0, (maxrowpos - initialrowpos - edsm.Image.Height) / 2); // align to centre of rowh.. } foreach (var e in items) { e.Translate(0, (maxrowpos - initialrowpos - e.Image.Height) / 2); // align to centre of rowh.. } return(maxrowpos); }
private void pictureBox_ClickElement(object sender, MouseEventArgs eventargs, ExtendedControls.ExtPictureBox.ImageElement i, object tag) { if (i != null) { HistoryEntry he = tag as HistoryEntry; if (he != null) { EliteDangerousCore.EDSM.EDSMClass edsm = new EliteDangerousCore.EDSM.EDSMClass(); if (!edsm.ShowSystemInEDSM(he.System.Name)) { ExtendedControls.MessageBoxTheme.Show(FindForm(), string.Format("System {0} unknown to EDSM".T(EDTx.UserControlTrippanel_UKN), he.System.Name)); } } else { // TBD horrible fix as its too slow. var list = discoveryform.history.FilterByFSDOnly().OrderByDescending(p => p.EventTimeUTC).Take(2); if (list.Count() == 0) { return; } he = list.ToArray()[0]; if (he.StartMarker) { return; } he.journalEntry.SetStartFlag(); if (list.Count() > 1 && he.isTravelling) { he = list.ToArray()[1]; he.journalEntry.SetEndFlag(); } discoveryform.RefreshHistoryAsync(); } } }
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(); } }