// curmats may be null Point CreateMaterialNodes(List <ExtPictureBox.ImageElement> pc, JournalScan sn, MaterialCommoditiesList curmats, HistoryList hl, Point matpos, Size matsize) { Point startpos = matpos; Point maximum = matpos; int noperline = 0; bool noncommon = ShowMaterialsRare; string matclicktext = sn.DisplayMaterials(2, curmats, hl.GetLast?.MaterialCommodity); foreach (KeyValuePair <string, double> sd in sn.Materials) { string tooltip = sn.DisplayMaterial(sd.Key, sd.Value, curmats, hl.GetLast?.MaterialCommodity); Color fillc = Color.Yellow; string abv = sd.Key.Substring(0, 1); MaterialCommodityData mc = MaterialCommodityData.GetByFDName(sd.Key); if (mc != null) { abv = mc.Shortname; fillc = mc.Colour; if (HideFullMaterials) // check full { int?limit = mc.MaterialLimit(); MaterialCommodities matnow = curmats?.Find(mc); // allow curmats = null // debug if (matnow != null && mc.shortname == "Fe") matnow.count = 10000; if (matnow != null && limit != null && matnow.Count >= limit) // and limit { continue; } } if (noncommon && mc.IsCommonMaterial) { continue; } } CreateMaterialImage(pc, matpos, matsize, abv, tooltip + "\n\n" + "All " + matclicktext, tooltip, fillc, Color.Black); maximum = new Point(Math.Max(maximum.X, matpos.X + matsize.Width), Math.Max(maximum.Y, matpos.Y + matsize.Height)); if (++noperline == 4) { matpos = new Point(startpos.X, matpos.Y + matsize.Height + materiallinespacerxy); noperline = 0; } else { matpos.X += matsize.Width + materiallinespacerxy; } } return(maximum); }
Point CreateMaterialNodes(List <PictureBoxHotspot.ImageElement> pc, JournalScan sn, Point matpos, Size matsize) { Point startpos = matpos; Point maximum = matpos; int noperline = 0; bool noncommon = checkBoxMaterialsRare.Checked; string matclicktext = sn.DisplayMaterials(2); foreach (KeyValuePair <string, double> sd in sn.Materials) { string abv = sd.Key.Substring(0, 1); string tooltip = sd.Key; Color fillc = Color.Yellow; MaterialCommodityDB mc = MaterialCommodityDB.GetCachedMaterial(sd.Key); if (mc != null) { abv = mc.shortname; fillc = mc.colour; tooltip = mc.name + " (" + mc.shortname + ") " + mc.type + " " + sd.Value.ToString("0.0") + "%"; if (noncommon && mc.type.IndexOf("common", StringComparison.InvariantCultureIgnoreCase) >= 0) { continue; } } CreateMaterialImage(pc, matpos, matsize, abv, tooltip + "\n\n" + "All " + matclicktext, tooltip, fillc, Color.Black); maximum = new Point(Math.Max(maximum.X, matpos.X + matsize.Width), Math.Max(maximum.Y, matpos.Y + matsize.Height)); if (++noperline == 4) { matpos = new Point(startpos.X, matpos.Y + matsize.Height + materialspacer); noperline = 0; } else { matpos.X += matsize.Width + materialspacer; } } return(maximum); }
// curmats may be null Point CreateMaterialNodes(List <ExtPictureBox.ImageElement> pc, JournalScan sn, MaterialCommoditiesList curmats, HistoryList hl, Point matpos, Size matsize) { Point startpos = matpos; Point maximum = matpos; int noperline = 0; string matclicktext = sn.DisplayMaterials(2, curmats, hl.GetLast?.MaterialCommodity); foreach (KeyValuePair <string, double> sd in sn.Materials) { string tooltip = sn.DisplayMaterial(sd.Key, sd.Value, curmats, hl.GetLast?.MaterialCommodity); Color fillc = Color.Yellow; string abv = sd.Key.Substring(0, 1); MaterialCommodityData mc = MaterialCommodityData.GetByFDName(sd.Key); if (mc != null) { abv = mc.Shortname; fillc = mc.Colour; if (HideFullMaterials) // check full { int?limit = mc.MaterialLimit(); MaterialCommodities matnow = curmats?.Find(mc); // allow curmats = null // debug if (matnow != null && mc.shortname == "Fe") matnow.count = 10000; if (matnow != null && limit != null && matnow.Count >= limit) // and limit { continue; } } if (ShowOnlyMaterialsRare && mc.IsCommonMaterial) { continue; } } System.Drawing.Imaging.ColorMap colormap = new System.Drawing.Imaging.ColorMap(); colormap.OldColor = Color.White; // this is the marker colour to replace colormap.NewColor = fillc; Bitmap mat = BaseUtils.BitMapHelpers.ReplaceColourInBitmap((Bitmap)Icons.Controls.Scan_Bodies_Material, new System.Drawing.Imaging.ColorMap[] { colormap }); BaseUtils.BitMapHelpers.DrawTextCentreIntoBitmap(ref mat, abv, stdfont, Color.Black); ExtPictureBox.ImageElement ie = new ExtPictureBox.ImageElement( new Rectangle(matpos.X, matpos.Y, matsize.Width, matsize.Height), mat, tooltip + "\n\n" + "All " + matclicktext, tooltip); pc.Add(ie); maximum = new Point(Math.Max(maximum.X, matpos.X + matsize.Width), Math.Max(maximum.Y, matpos.Y + matsize.Height)); if (++noperline == 4) { matpos = new Point(startpos.X, matpos.Y + matsize.Height + materiallinespacerxy); noperline = 0; } else { matpos.X += matsize.Width + materiallinespacerxy; } } return(maximum); }
// curmats may be null Point CreateMaterialNodes(List <ExtPictureBox.ImageElement> pc, JournalScan sn, List <MaterialCommodityMicroResource> historicmats, List <MaterialCommodityMicroResource> curmats, Point matpos, Size matsize) { Point startpos = matpos; Point maximum = matpos; int noperline = 0; string matclicktext = sn.DisplayMaterials(2, historicmats, curmats); foreach (KeyValuePair <string, double> sd in sn.Materials) { string tooltip = sn.DisplayMaterial(sd.Key, sd.Value, historicmats, curmats); Color fillc = Color.Yellow; string abv = sd.Key.Substring(0, 1); MaterialCommodityMicroResourceType mc = MaterialCommodityMicroResourceType.GetByFDName(sd.Key); if (mc != null) { abv = mc.Shortname; fillc = mc.Colour; //System.Diagnostics.Debug.WriteLine("Colour {0} {1}", fillc.ToString(), fillc.GetBrightness()); if (HideFullMaterials) // check full { int?limit = mc.MaterialLimit(); MaterialCommodityMicroResource matnow = curmats?.Find(x => x.Details == mc); // allow curmats = null // debug if (matnow != null && mc.shortname == "Fe") matnow.count = 10000; if (matnow != null && limit != null && matnow.Count >= limit) // and limit { continue; } } if (ShowOnlyMaterialsRare && mc.IsCommonMaterial) { continue; } } System.Drawing.Imaging.ColorMap colormap = new System.Drawing.Imaging.ColorMap(); colormap.OldColor = Color.White; // this is the marker colour to replace colormap.NewColor = fillc; Bitmap mat = BaseUtils.BitMapHelpers.ReplaceColourInBitmap((Bitmap)BaseUtils.Icons.IconSet.GetIcon("Controls.Scan.Bodies.Material"), new System.Drawing.Imaging.ColorMap[] { colormap }); BaseUtils.BitMapHelpers.DrawTextCentreIntoBitmap(ref mat, abv, Font, fillc.GetBrightness() > 0.4f ? Color.Black : Color.White); ExtPictureBox.ImageElement ie = new ExtPictureBox.ImageElement( new Rectangle(matpos.X, matpos.Y, matsize.Width, matsize.Height), mat, tooltip + "\n\n" + "All " + matclicktext, tooltip); pc.Add(ie); maximum = new Point(Math.Max(maximum.X, matpos.X + matsize.Width), Math.Max(maximum.Y, matpos.Y + matsize.Height)); if (++noperline == 4) { matpos = new Point(startpos.X, matpos.Y + matsize.Height + materiallinespacerxy); noperline = 0; } else { matpos.X += matsize.Width + materiallinespacerxy; } } return(maximum); }