private void buttonDiagram_Click(object sender, EventArgs e) { if (wybrany == null || kopiaZebowWybranego == null) { return; } FormDiagram fK = new FormDiagram(wybrany, kopiaZebowWybranego, this, editMode); }
internal void generujIZapiszObraz(string nazwa_folderu) { int x = 1; int y = 350; FormDiagram formularzZebowy = new FormDiagram(this); Bitmap bmpTrzonowe = new Bitmap(formularzZebowy.canvas.Width, formularzZebowy.canvas.Height + 100); formularzZebowy.canvas.DrawToBitmap(bmpTrzonowe, new Rectangle(0, 0, formularzZebowy.canvas.Width, formularzZebowy.canvas.Height + 100)); Graphics graphics1 = Graphics.FromImage(bmpTrzonowe); Font arialFont = new Font("Arial", 15, GraphicsUnit.Pixel); List <int> unikalneTrzonowe = new List <int>(); for (int i = 0; i < 2; i++) { for (int j = 0; j < 16; j++) { for (int k = 0; k < 8; k++) { if (!unikalneTrzonowe.Contains(tabTrzonowe[i, j, k]) && tabTrzonowe[i, j, k] != 0) { unikalneTrzonowe.Add(tabTrzonowe[i, j, k]); } } } } graphics1.DrawString("Legenda: ", arialFont, Brushes.White, x, y); y = y + 15; for (int v = 0; v < unikalneTrzonowe.Count; v++) { string text = OpisStanu(unikalneTrzonowe[v]); if (unikalneTrzonowe[v] == 1) { var size = graphics1.MeasureString(text, arialFont); var rect = new RectangleF(x, y, size.Width, size.Height); graphics1.FillRectangle(Brushes.White, rect); } graphics1.DrawString(text, arialFont, formularzZebowy.StanZeba(unikalneTrzonowe[v]), x, y); x = x + text.Length * 10; if (x > 1050) { y = y + 15; x = 1; } } bmpTrzonowe.Save(nazwa_folderu + @"\diagramTrzonowe.Bmp", System.Drawing.Imaging.ImageFormat.Bmp); Bitmap bmpMleczne = new Bitmap(formularzZebowy.canvas.Width, formularzZebowy.canvas.Height + 100); formularzZebowy.czyMleczne = true; formularzZebowy.canvas.Invalidate(); formularzZebowy.canvas.DrawToBitmap(bmpMleczne, new Rectangle(0, 0, formularzZebowy.canvas.Width, formularzZebowy.canvas.Height)); x = 1; y = 350; Graphics graphics2 = Graphics.FromImage(bmpMleczne); List <int> unikalneMleczne = new List <int>(); for (int i = 0; i < 2; i++) { for (int j = 0; j < 16; j++) { for (int k = 0; k < 8; k++) { if (!unikalneMleczne.Contains(tabMleczne[i, j, k]) && tabMleczne[i, j, k] != 0) { unikalneMleczne.Add(tabMleczne[i, j, k]); } } } } graphics2.DrawString("Legenda: ", arialFont, Brushes.White, x, y); y = y + 15; for (int v = 0; v < unikalneMleczne.Count; v++) { string text = OpisStanu(unikalneMleczne[v]); if (unikalneMleczne[v] == 1) { var size = graphics2.MeasureString(text, arialFont); var rect = new RectangleF(x, y, size.Width, size.Height); graphics2.FillRectangle(Brushes.White, rect); } graphics2.DrawString(text, arialFont, formularzZebowy.StanZeba(unikalneMleczne[v]), x, y); x = x + text.Length * 10; if (x > 1050) { y = y + 15; x = 1; } } bmpMleczne.Save(nazwa_folderu + @"\diagramMleczne.Bmp", System.Drawing.Imaging.ImageFormat.Bmp); formularzZebowy.Close(); }