private void RecompositeCanvasImage() { Bitmap bm = new Bitmap(CANVAS_WIDTH, CANVAS_HEIGHT, System.Drawing.Imaging.PixelFormat.Format32bppArgb); LayerStateManager.Layers fgbg = layerState.Query(LayerStateManager.Layers.Background | LayerStateManager.Layers.Foreground); using (Graphics g = Graphics.FromImage(bm)) { g.Clear(Color.Black); if ((canvasBgImage != null) && ((fgbg & LayerStateManager.Layers.Background) != 0)) { g.Clear(Globals.App.TransparentBackgroundAreasColour); g.DrawImage(canvasBgImage, Point.Empty); } if ((canvasFgImage != null) && ((fgbg & LayerStateManager.Layers.Foreground) != 0)) { g.DrawImage(canvasFgImage, Point.Empty); } } if (DebugLogger.DoDebugActions()) { string compositedName = Globals.MakeDebugSaveName(false, "newcanvas.png"); bm.Save(compositedName, System.Drawing.Imaging.ImageFormat.Png); } Image oldImage = canvas.Image; canvas.Image = bm; if (oldImage != null) { oldImage.Dispose(); } }
private void toggleBoxContentsToolStripMenuItem_Click(object sender, EventArgs e) { ToolStripMenuItem toggle = (ToolStripMenuItem)sender; LayerStateManager.Layers state = layerState.Toggle(LayerStateManager.Layers.BoxContents); Globals.App.ShowInnerContent = ((state & LayerStateManager.Layers.BoxContents) != 0); DebugLogger.Log("Main", "Global inner content toggle to {0}", Globals.App.ShowInnerContent); RedrawCanvas(); }
public void Draw(Graphics g, Rectangle clipRect, Rectangle currentlyDrawing, LayerStateManager.Layers layers) { bool showBoxes = (layers != LayerStateManager.Layers.None); foreach (IBox b in Items) { b.Draw(g, clipRect, showBoxes); } if (currentlyDrawing != Rectangle.Empty) { g.DrawRectangle(Globals.App.DefaultOutlinePen, currentlyDrawing); } }
private void toggleLayerStateMenuClick(object sender, EventArgs e) { ToolStripMenuItem item = (ToolStripMenuItem)sender; LayerStateManager.Layers before = layerState.Query(LayerStateManager.Layers.All); LayerStateManager.Layers after = layerState.Toggle((LayerStateManager.Layers)item.Tag); if ((before & after) != (LayerStateManager.Layers.Background | LayerStateManager.Layers.Foreground)) { RecompositeCanvasImage(); } RedrawCanvas(); }