public void Initialise() { for (int z = 0; z < GridId.GridZRange; z++) { for (int x = 0; x < GridId.GridXRange; x++) { int id = GridId.IdFromComponents(x, z); float xp = 0, zp = 0; bool ok = GridId.XZ(id, out xp, out zp); Debug.Assert(ok); StarGrid grd = new StarGrid(id, xp, zp, Color.Transparent, 1.0F); //A=0 means use default colour array if (xp == 0 && zp == 0) // sol grid, unpopulated stars please { grd.dBAsk = SystemsDB.SystemAskType.UnpopulatedStars; } grids.Add(grd); } } systemlistgrid = new StarGrid(-1, 0, 0, Color.Orange, 1.0F); // grid ID -1 means it won't be filled by the Update task grids.Add(systemlistgrid); int solid = GridId.Id(0, 0); populatedgrid = new StarGrid(solid, 0, 0, Color.Transparent, 1.0F); // Duplicate grid id but asking for populated stars populatedgrid.dBAsk = SystemsDB.SystemAskType.PopulatedStars; grids.Add(populatedgrid); // add last so shown last Console.WriteLine("Grids " + grids.Count + " mid " + midpercentage + " far " + farpercentage); }
public void Initialise() { for (int z = 0; z < GridId.gridzrange; z++) { for (int x = 0; x < GridId.gridxrange; x++) { int id = GridId.IdFromComponents(x, z); double xp = 0, zp = 0; bool ok = GridId.XZ(id, out xp, out zp); Debug.Assert(ok); StarGrid grd = new StarGrid(id, xp, zp, Color.Transparent, 1.0F); //A=0 means use default colour array if (xp == 0 && zp == 0) // sol grid, unpopulated stars please { grd.dBAsk = SystemClass.SystemAskType.UnPopulatedStars; } grids.Add(grd); } } visitedsystemsgrid = new StarGrid(-1, 0, 0, Color.Orange, 1.0F); // grid ID -1 means it won't be filled by the Update task grids.Add(visitedsystemsgrid); int solid = GridId.Id(0, 0); populatedgrid = new StarGrid(solid, 0, 0, Color.Transparent, 1.0F); // Duplicate grid id but asking for populated stars populatedgrid.dBAsk = SystemClass.SystemAskType.PopulatedStars; grids.Add(populatedgrid); // add last, so displayed last, so overwrites anything else long total = SystemClass.GetTotalSystems(); total = Math.Min(total, 10000000); // scaling limit at 10mil long offset = (total - 1000000) / 100000; // scale down slowly.. experimental! midpercentage -= (int)(offset / 2); farpercentage -= (int)(offset / 3); //midpercentage = 10; // agressive debugging options //farpercentage = 1; Console.WriteLine("Grids " + grids.Count + "Database Stars " + total + " mid " + midpercentage + " far " + farpercentage); }
public void Initialise() { for (int z = 0; z < GridId.GridZRange; z++) { for (int x = 0; x < GridId.GridXRange; x++) { int id = GridId.IdFromComponents(x, z); float xp = 0, zp = 0; bool ok = GridId.XZ(id, out xp, out zp); Debug.Assert(ok); StarGrid grd = new StarGrid(id, xp, zp, Color.Transparent, 1.0F); //A=0 means use default colour array grids.Add(grd); } } systemlistgrid = new StarGrid(-1, 0, 0, Color.Orange, 1.0F); // grid ID -1 means it won't be filled by the Update task grids.Add(systemlistgrid); Trace.WriteLine("Grids " + grids.Count + " mid " + midpercentage + " far " + farpercentage); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if (galaxy != null) { SolidBrush red = new SolidBrush(Color.Gray); SolidBrush sel = new SolidBrush(Color.FromArgb(128, Color.Red)); Pen pen = new Pen(red); Rectangle imagesourceregion = GetSourceImageRegion(); // This is what we are displaying Point lypostop = galaxy.LYPos(new Point(imagesourceregion.Left, imagesourceregion.Top)); // convert the top of what displayed to lys. int lywidth = imagesourceregion.Width * galaxy.LYWidth / galaxy.PixelWidth; // work out the width of the displayed in ly. int lyheight = imagesourceregion.Height * galaxy.LYHeight / galaxy.PixelHeight; Rectangle imageviewport = GetImageViewPort(); // these are the pixels on the screen in which imagesourceregion is squashed into int[] xpos = new int[xlines.Length]; int[] zpos = new int[zlines.Length]; for (int x = 0; x < xlines.Length; x++) { int xly = xlines[x]; int pos = xly - lypostop.X; // where it is relative to left of image float offset = (float)pos / lywidth; // fraction across the image int px = imageviewport.Left + (int)(imageviewport.Width * offset); // shift to image viewport pixels xpos[x] = px; e.Graphics.DrawLine(pen, new Point(px, imageviewport.Top), new Point(px, imageviewport.Bottom)); } for (int z = 0; z < zlines.Length; z++) // in numberic order, so bottom of map first { int zly = zlines[z]; int pos = lypostop.Y - zly; // where it is relative to top of image, remembering top is highest float offset = (float)pos / lyheight; // fraction across the image int px = imageviewport.Top + (int)(imageviewport.Height * offset); // shift to image viewport pixels zpos[z] = px; e.Graphics.DrawLine(pen, new Point(imageviewport.Left, px), new Point(imageviewport.Right, px)); } //for (int x = -40000; x < 40000; x += 250) System.Diagnostics.Debug.WriteLine("{0} {1}", x, GridId.Id(x, 0)); for (int x = 0; x < xlines.Length - 1; x++) { for (int z = 0; z < zlines.Length - 1; z++) { int id = GridId.IdFromComponents(x, z); if (!includedgridid.Contains(id)) { int width = xpos[x + 1] - xpos[x] - 2; int height = zpos[z] - zpos[z + 1] - 2; // from bottom of map upwards //System.Diagnostics.Debug.WriteLine("{0},{1} => {2} {3} {4} {5}", x, z, xpos[x], zpos[z], width, height); e.Graphics.FillRectangle(sel, xpos[x] + 1, zpos[z + 1] + 1, width, height); } } } sel.Dispose(); pen.Dispose(); red.Dispose(); } }