private void SwapRow(List <LayerRow> list, int row1, int row2) { LayerRow tmp = list[row1]; list[row1] = list[row2]; list[row2] = tmp; }
public void Duplicate() { LayerRow newRow = new LayerRow(); newRow.Text = layers[current].Text + "(Copy)"; Bitmap bmp; if (!Tool.Select.Selected) { bmp = (Bitmap)layers[current].Layer.Image.Clone(); } else { bmp = new Bitmap(layerSize.Width, layerSize.Height); using (Graphics g = Graphics.FromImage(bmp)) g.DrawImage(layers[current].Layer.Image, Tool.Select.Rect.X, Tool.Select.Rect.Y, Tool.Select.Rect, GraphicsUnit.Pixel); } newRow.Layer = new Layer(bmp, newRow.Text, true); bmp.Dispose(); current++; layers.Insert(current, newRow); panel.Controls.Add(newRow); Allocation(); }
public void RestoreRow() { LayerRow l = layers[current]; layers.Insert(deletedRows.Peek().Key, deletedRows.Peek().Value); panel.Controls.Add(deletedRows.Peek().Value); current = layers.IndexOf(l); deletedRows.Pop(); Allocation(); }
public void Duplicate() { LayerRow newRow = new LayerRow(); newRow.Text = layers[current].Text + "-Copy"; newRow.Layer = new Layer(layers[current].Layer.Image, newRow.Text, true); current++; layers.Insert(current, newRow); panel.Controls.Add(newRow); Allocation(); }
public void DeleteRowAt(LayerRow lr) { int index = layers.IndexOf(lr); layers[index].Dispose(); panel.Controls.Remove(layers[index]); layers.Remove(layers[index]); if (index <= current && current > 0) { current--; } Allocation(); }
public void MoveBack(LayerRow lr, bool up) { int index = layers.IndexOf(lr); if (up) { SwapRow(layers, index, index + 1); } else { SwapRow(layers, index, index - 1); } Allocation(); }
public void AddLayerRow(ref Layer layer) { if (layers.Count == 0) { current = -1; layerSize = layer.Image.Size; } LayerRow row = new LayerRow(layer.Visible); row.Layer = layer; row.Text = layer.Name; current++; layers.Insert(current, row); panel.Controls.Add(row); Allocation(); }
public void AddLayerRow(ref Layer layer) { if (layers.Count == 0) { layerSize = layer.Image.Size; final = new Bitmap(layerSize.Width, layerSize.Height); } LayerRow row = new LayerRow(); row.Layer = layer; row.Text = layer.Name; layers.Add(row); current = layers.Count - 1; panel.Controls.Add(row); Allocation(); }
public void Add(HistoryEvent e, LayerRow l) { events.Push(new KeyValuePair <HistoryEvent, LayerRow>(e, l)); string eventName = l.Layer.Name + ": "; switch (e) { case HistoryEvent.Draw: eventName += "Draw"; break; case HistoryEvent.Erase: eventName += "Erase"; break; case HistoryEvent.DrawFilter: eventName += "Filter"; break; case HistoryEvent.NewL: eventName += "New"; break; case HistoryEvent.DuplicateL: eventName += "Duplicate"; break; case HistoryEvent.DeleteL: eventName += "Delete"; break; case HistoryEvent.MergeL: eventName += "Merge"; break; case HistoryEvent.Lup: eventName += "Move up"; break; case HistoryEvent.Ldown: eventName += "Move down"; break; case HistoryEvent.Opacity: eventName += "Opacity change"; break; case HistoryEvent.Clear: eventName += "Clear"; break; case HistoryEvent.Fill: eventName += "Fill"; break; case HistoryEvent.Transform: eventName += "Transform"; break; case HistoryEvent.Blend: eventName += "Blendmode change"; break; default: break; } listBox1.Items.Insert(0, eventName); }