public void RemoveLayer(ColorLayer layer) { if (layer != null) { this.Controls.Remove(layer); this.AligmentContorls(); } }
public ColorLayer AddLayer(ColorLayer layer) { this.Controls.Add(layer); int y = layer.Height * this.LayerCount; layer.Location = new Point(0, y); layer.Width = this.Width; layer.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)))); this.AligmentContorls(); return(layer); }
private void SelectLayer(ColorLayer layer) { foreach (Control ctrl in this.Controls) { ColorLayer ctrlLayer = ctrl as ColorLayer; if (ctrlLayer != null) { ctrlLayer.BackColor = Color.FromKnownColor(KnownColor.Control); ctrlLayer.Selected = false; } } layer.Selected = true; layer.BackColor = Color.OrangeRed; }
private void Displayer1_ImageMouseUp(object arg1, MouseEventArgs arg2, Point arg3) { if (arg2.Button == MouseButtons.Right) { ColorLayer layer = this.layersPannel1.SelectedLayer; if (layer != null && layer.Tag != null) { Bitmap img = layer.Tag as Bitmap; this._reverse_data.Add(new ReverseStruct(REVERSE_TYPE.DRAWING, layer, img.Clone(new Rectangle(0, 0, img.Width, img.Height), img.PixelFormat))); if (this._reverse_data.Count > 10) { this._reverse_data[0].Image.Dispose(); this._reverse_data.RemoveAt(0); } } } }
private void Displayer1_LabelOnPaint(PaintEventArgs obj) { lock (this) { Graphics g = obj.Graphics; g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality; g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None; foreach (Control ctrl in this.layersPannel1.Controls) { ColorLayer layer = ctrl as ColorLayer; if (layer != null && layer.DrawEnable && layer.Tag != null) { Bitmap image = layer.Tag as Bitmap; Color color = layer.SelectColor; float[][] matrixItems = { new float[] { color.R, 0, 0, 0, 0 }, new float[] { 0, color.G, 0, 0, 0 }, new float[] { 0, 0, color.B, 0, 0 }, new float[] { 0, 0, 0, 0.5f, 0 }, new float[] { 0, 0, 0, 0, 1 } }; ColorMatrix colorMatrix = new ColorMatrix(matrixItems); ImageAttributes attributes = new ImageAttributes(); attributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); g.DrawImage( image, new Rectangle(new Point(0, 0), new Size(image.Width, image.Height)), 0.0f, 0.0f, image.Width, image.Height, GraphicsUnit.Pixel, attributes); } } } }
private void DrawOnMouseMove(object arg1, MouseEventArgs arg2, Point arg3) { if (arg2.Button == MouseButtons.Right) { float brushSize = (float)this.numericUpDown1.Value; ColorLayer layer = this.layersPannel1.SelectedLayer; if (layer != null) { using (Graphics g = Graphics.FromImage(layer.Tag as Bitmap)) { g.FillEllipse(red, arg3.X - brushSize / 2, arg3.Y - brushSize / 2, brushSize, brushSize); } } float scale = this.displayer1.ImageScale; float min_width = Math.Max(3, (brushSize + 2) * scale); RectangleF rect_new = new RectangleF(arg2.X - scale - brushSize * scale / 2, arg2.Y - scale - brushSize * scale / 2, min_width, min_width); Region r = new Region(rect_new); this.displayer1.InvalidPannelRegion(r); } Console.WriteLine(arg2.Location.ToString()); }
public ColorLayer AddLayer() { this.SuspendLayout(); ColorLayer layer = new ColorLayer(); layer.DrawCheckChanged += Layer_DrawCheckChanged; layer.ColorChanged += Layer_ColorChanged; layer.MouseDown += Layer_MouseDown; int y = layer.Height * this.LayerCount; this.Controls.Add(layer); layer.Location = new Point(0, y); layer.Width = this.Width; layer.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)))); if (this.SelectedChaged != null) { this.SelectedChaged(layer, null); } this.AligmentContorls(); this.ResumeLayout(); return(layer); }
private void button1_Click(object sender, EventArgs e) { Bitmap emptyImg = new Bitmap(this.displayer1.Image.Width, this.displayer1.Image.Height, PixelFormat.Format32bppArgb); using (Graphics g = Graphics.FromImage(emptyImg)) { using (Brush brush = new SolidBrush(Color.FromArgb(0, 0, 0, 0))) { g.FillRectangle(brush, new Rectangle(0, 0, emptyImg.Width, emptyImg.Height)); } } lock (this) { ColorLayer layer = this.layersPannel1.AddLayer(); /*List<Bitmap> historys = new List<Bitmap>(); * for (int i = 0; i < this._label_images.Count; ++i) * historys.Add(null); * historys.Add(emptyImg.Clone(new Rectangle(0,0,emptyImg.Width, emptyImg.Height), emptyImg.PixelFormat)); * this._reverse_list.Add(historys);*/ layer.Tag = emptyImg; this._reverse_data.Add(new ReverseStruct(REVERSE_TYPE.ADD_LAYER, layer, emptyImg.Clone(new Rectangle(0, 0, emptyImg.Width, emptyImg.Height), emptyImg.PixelFormat))); } }
public ReverseStruct(REVERSE_TYPE type, ColorLayer layer, Bitmap image) { ReverseType = type; Layer = layer; Image = image; }