private void btn_Screen_Click(object sender, EventArgs e) { if (fs != null && !fs.IsDisposed) { fs.WindowState = FormWindowState.Normal; fs.BringToFront(); fs.Focus(); } else { fs = new f_Screen(); fs.parent = this; } fs.Show(); if (Properties.Settings.Default.s_ToolbarPanel == 0) { if (tools == null || tools.IsDisposed) { tools = new f_SettingPanel(); } fs.child = tools; tools.parent = fs; tools.Show(); } }
public void handleCutouts(int mode) { Bitmap bmp = doCutting(mode); int i = 0; var x = Application.OpenForms; foreach (Form f in x) { if (f is f_Screen) { i++; break; } } if (i == 0) { fs = new f_Screen(); fs.parent = this; fs.Show(); if (Properties.Settings.Default.s_ToolbarPanel == 0) { tools = new f_SettingPanel(); tools.parent = fs; fs.child = tools; tools.Show(); } } if (fs != null) { fs.addImage(bmp); } }
public static Dictionary <int, uc_CutoutHolder> returnCutouts(f_Screen fs) { Dictionary <int, uc_CutoutHolder> c = new Dictionary <int, uc_CutoutHolder>(); foreach (var v in fs.Controls) { if (v != null && v is uc_CutoutHolder) { int i = fs.Controls.GetChildIndex(((uc_CutoutHolder)v)); if (!c.ContainsKey(i)) { c.Add(i, ((uc_CutoutHolder)v)); } } } return(c); }
public static void fillDict(f_Screen fs, out Dictionary <int, uc_CutoutHolder> cutouts) { cutouts = new Dictionary <int, uc_CutoutHolder>(); foreach (var v in fs.Controls) { if (v != null && v is uc_CutoutHolder) { int i = fs.Controls.GetChildIndex(((uc_CutoutHolder)v)); if (!cutouts.ContainsKey(i)) { cutouts.Add(i, ((uc_CutoutHolder)v)); } } } //TODO:This SORTS cutouts cutouts = cutouts.OrderByDescending(r => r.Key).ToDictionary(r => r.Key, r => r.Value); }
public static Bitmap createPng(f_Screen fs, List <c_ImageHolder> cutouts, Object[] drawings, bool drawTBG) { if (fs != null) { int left = int.MaxValue; int top = int.MaxValue; int right = 0; int bottom = 0; foreach (var v in cutouts) { //var k = v.Value; if (v.Left < left) { left = v.Left; } if (v.Top < top) { top = v.Top; } if (v.Left + v.Width > right) { right = v.Left + v.Width; } if (v.Top + v.Height > bottom) { bottom = v.Top + v.Height; } } int height = bottom - top; int width = right - left; var picrec = new System.Drawing.Rectangle(left, top, width, height); Bitmap _b = createImage(picrec, cutouts, drawTBG); //TODO: Redo this. drawnpoints instead of lines //TODO: New object type instead of Bitmaps if (drawings != null && drawings.Length == 2) { List <c_DrawnPoints> lines = drawings[0] as List <c_DrawnPoints>; //List<Bitmap> shapes = drawings[1] as List<Bitmap>; if (lines.Count > 0) { try { using (Graphics g = Graphics.FromImage(_b)) { for (int i = 0; i < lines.Count - 2; i++) { c_DrawnPoints l = lines[i]; c_DrawnPoints l2 = lines[i + 1]; Point p1 = new Point(l.X, l.Y); Point p2 = new Point(l2.X, l2.Y); g.DrawLine(Pens.Black, p1, p2); } /* * foreach (Bitmap b in shapes) * { * g.DrawImage(b, new PointF(0, 0)); * } */ } } catch { } } } return(_b); } else { return(null); } }
public static Bitmap createPng(f_Screen fs, List <c_ImageHolder> cutouts, Object[] drawings) { return(createPng(fs, cutouts, drawings, false)); }
public void refreshImage(f_Screen fs) { pb_PreviewPicture.Image = c_ImgGen.createPng(fs, fs.Limages, new object[] { fs.getDrawnPoints(), null }); GC.Collect(1); }