private void handleLayerItemClick(object obj, System.EventArgs args) { if (obj is LayerItem) { LayerItem layer = ((LayerItem)obj); if (!layer.isLayerActive()) { SharedSettings.flattenSelection(); foreach (LayerItem l in Layers) { l.setActive(false); } layer.setActive(true); ss.setBitmapCurrentLayer(layer.getBitmap()); } layer.Refresh(); } else if (obj is PictureBox) { LayerItem layer = (LayerItem)((PictureBox)obj).Parent; if (!layer.isLayerActive()) { SharedSettings.flattenSelection(); foreach (LayerItem l in Layers) { l.setActive(false); l.Refresh(); } layer.setActive(true); } layer.Refresh(); } redrawLayerItems(); }
private void removeLayer() { SharedSettings.flattenSelection(); //Foreach loop to iterate through all layers try { for (int t = Layers.Count - 1; t >= 0; t--) { //If there's only one layer, don't remove it if (Layers.Count <= 1) { break; } if (Layers[t].isLayerActive()) { //removes the LayerItem from the Display pLayerDisplay.Controls.Remove(Layers[t]); //Removes selected layer from the List Layers.Remove(Layers[t]); } } } catch (Exception err) { Console.WriteLine(err.InnerException); } redrawLayerItems(); //Disable the Relevant Buttons if only one layer Exists bRemoveLayer.Enabled = (Layers.Count > 1); bMoveDown.Enabled = (Layers.Count > 1); bMoveUp.Enabled = (Layers.Count > 1); }
private void addLayer(Bitmap b, String name) { SharedSettings.flattenSelection(); foreach (LayerItem layer in Layers) { layer.setActive(false); } LayerItem temp = new LayerItem(width, height, pf, name, ss); temp.Location = new Point(0, yLayerLocation); yLayerLocation += temp.Height + 5; temp.setActive(true); temp.setOnClick(handleLayerItemClick); temp.setBitmap(b); Layers.Add(temp); pLayerDisplay.Controls.Add(Layers[Layers.Count - 1]); if (Layers.Count > 1) { bRemoveLayer.Enabled = true; bMoveDown.Enabled = true; bMoveUp.Enabled = true; } ss.setBitmapCurrentLayer(Layers[Layers.Count - 1].getBitmap()); }
public void addImportImage(Bitmap b) { SharedSettings.flattenSelection(); foreach (LayerItem layer in Layers) { layer.setActive(false); } Bitmap bit = new Bitmap(SharedSettings.iCanvasWidth, SharedSettings.iCanvasHeight, PixelFormat.Format32bppArgb); Graphics.FromImage(bit).DrawImage(b, 0, 0); LayerItem temp = new LayerItem(width, height, pf, Layers.Count.ToString(), ss); temp.Location = new Point(0, yLayerLocation); yLayerLocation += temp.Height + 5; temp.setActive(true); temp.setOnClick(handleLayerItemClick); temp.setBitmap((Bitmap)bit.Clone()); Layers.Add(temp); pLayerDisplay.Controls.Add(Layers[Layers.Count - 1]); if (Layers.Count > 1) { bRemoveLayer.Enabled = true; bMoveDown.Enabled = true; bMoveUp.Enabled = true; } b.Dispose(); bit.Dispose(); redrawLayerItems(); }
public void onMouseUp(object sender, MouseEventArgs e) { pOld.X = 0; pOld.Y = 0; pNew.X = 0; pNew.Y = 0; p2 = new Point(e.X, e.Y); if (p1.X == p2.X || p1.Y == p2.Y) { SharedSettings.flattenSelection(); } else { if (!ss.getActiveSelection()) { int tlX = p1.X, tlY = p1.Y; int width = Math.Abs(p1.X - p2.X); int height = Math.Abs(p1.Y - p2.Y); if (p2.X < p1.X) { tlX = p2.X; } if (p2.Y < p1.Y) { tlY = p2.Y; } tlX = tlX < 0 ? 0 : tlX; tlY = tlY < 0 ? 0 : tlY; width = width + tlX <= SharedSettings.iCanvasWidth ? width : SharedSettings.iCanvasWidth - tlX; height = height + tlY <= SharedSettings.iCanvasHeight ? height : SharedSettings.iCanvasHeight - tlY; Point loc = new Point(tlX, tlY); Size sze = new Size(width, height); ss.setSelectionPoint(loc); ss.setSelectionSize(sze); updateInterfaceLayer(); //Get selected area data bEdit = ss.getBitmapCurrentLayer(true).Clone(new Rectangle(loc, sze), ss.getBitmapCurrentLayer(true).PixelFormat); //clear data below selection ss.getActiveGraphics().CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy; ss.getActiveGraphics().FillRectangle(new SolidBrush(Color.Transparent), new Rectangle(loc, sze)); ss.getActiveGraphics().CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver; SharedSettings.setSelection(bEdit, loc); } } }
private void Form1_KeyDown(object sender, KeyEventArgs e) { //CTRL + N for New Project if (e.Control && e.KeyCode == Keys.N) { tsmiFile_New_Click(this, null); } //CTRL + S for Save Project if (e.Control && e.KeyCode == Keys.S) { tsmiFile_Save_Click(this, null); } //CTRL + O for open Project if (e.Control && e.KeyCode == Keys.O) { tsmiFile_Load_Click(this, null); } //CTRL + I for Import Image if (e.Control && e.KeyCode == Keys.I) { tsmiFile_Import_Click(this, null); } //CTRL + E for Export Image if (e.Control && e.KeyCode == Keys.E) { tsmiFile_Export_Click(this, null); } //CTRL + G for Export to Google Drive if (e.Control && e.KeyCode == Keys.G) { tsmiFile_SaveGoogleDrive_Click(this, null); } //CTRL + C for Copy Selection if (e.Control && e.KeyCode == Keys.C) { if (SharedSettings.bitmapSelectionArea != null) { copySelectionToClipboard(); } } //CTRL + X for Cut Selection if (e.Control && e.KeyCode == Keys.X) { if (SharedSettings.bitmapSelectionArea != null) { copySelectionToClipboard(); SharedSettings.bitmapSelectionArea = null; SharedSettings.bRenderBitmapInterface = false; SharedSettings.bActiveSelection = false; SharedSettings.bFlattenSelection = true; SharedSettings.gActiveGraphics = SharedSettings.gActiveLayerGraphics; } } //CTRL + V for Paste Clipboard if (e.Control && e.KeyCode == Keys.V) { if (Clipboard.GetImage() != null) { SharedSettings.flattenSelection(); Bitmap temp = (Bitmap)GetClipboardImage(); Bitmap temp2 = new Bitmap(temp.Width, temp.Height, PixelFormat.Format32bppArgb); Graphics.FromImage(temp2).DrawImage(temp, 0, 0); temp.Dispose(); SharedSettings.setSelection((Bitmap)temp2.Clone(), new Point(0, 0)); temp.Dispose(); } } //CTRL + + for zoom in if (e.Control && e.KeyCode == Keys.Oemplus) { if (c != null) { c.zoomIn(); } } //CTRL + - for zoom out if (e.Control && e.KeyCode == Keys.OemMinus) { if (c != null) { c.zoomOut(); } } }