diff --git a/Paint_2/Form1.Designer.cs b/Paint_2/Form1.Designer.cs index 2be897e..7732235 100644 --- a/Paint_2/Form1.Designer.cs +++ b/Paint_2/Form1.Designer.cs @@ -303,7 +303,7 @@ this.nupPencilWidth.BorderStyle = System.Windows.Forms.BorderStyle.None; this.nupPencilWidth.Font = new System.Drawing.Font("Cascadia Code", 15F); this.nupPencilWidth.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247))))); - this.nupPencilWidth.Location = new System.Drawing.Point(128, 198); + this.nupPencilWidth.Location = new System.Drawing.Point(126, 166); this.nupPencilWidth.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.nupPencilWidth.Maximum = new decimal(new int[] { 255, diff --git a/Paint_2/Form1.cs b/Paint_2/Form1.cs index aa15a75..3cfd00e 100644 --- a/Paint_2/Form1.cs +++ b/Paint_2/Form1.cs @@ -21,20 +21,11 @@ namespace Paint_2 public partial class PaintForm : Form { const int WINDOW_OFFSET = 15; - //const string DEFAULT_FILEPATH = "C:/Paint2/Drawings/"; + //readonly Font FONT = new Font("Arial", fontSize); readonly Color FLAT_RED = Color.FromArgb(0xC6, 0x28, 0x28); readonly Color FLAT_GREEN = Color.FromArgb(0x00, 0x89, 0x7B); + readonly Color FLAT_GREY1 = Color.FromArgb(0x59, 0x59, 0x59); - //public Sketch sketch; - - - //List toolList; - - //bool drawing = false; - //bool randomColor = false; - //bool eyeDropping = false; - - //Random _random; private Color _hoveringColor; private Project _project; private int _selectedLayer; @@ -270,22 +261,22 @@ namespace Paint_2 private void BtnAddLayer_Click(object sender, EventArgs e) { - Project.AddLayer(); + SelectedLayers.Add(Project.AddLayer()); DisplayLayers(); RefreshUi(); } private void DisplayLayers() { - //I know I know this is not really MVC yet but I will address that - int Yoffset = 25; + int Yoffset = 10; int Xoffset = 10; - - int blocsCount = 1; - int btnWidth = 75; - int labelWidth = 70; + float fontSize = 10; + Size blocSize = new Size(pnlLayers.Width,pnlLayers.Height/6); + int blocsCount = 0; + int btnWidth = (int)(blocSize.Width / 2.7); + int labelWidth = (int)(blocSize.Width / 3.0); int BtnXoffset = labelWidth; - int ChkXOffset = BtnXoffset + btnWidth + Xoffset / 2; - int ChkWidth = 20; + int ChkXOffset = BtnXoffset + btnWidth /*+ Xoffset*/; + int ChkWidth = (int)(blocSize.Width / 6.0); pnlLayers.Controls.Clear(); @@ -293,32 +284,54 @@ namespace Paint_2 foreach (Sketch layer in layers) { - Label name = new Label(); - name.AutoSize = false; - name.Width = labelWidth; - name.Text = layer.Name; - name.BackColor = Color.Transparent; - pnlLayers.Controls.Add(name); - name.Location = new Point(0, blocsCount * Yoffset); + //LABEL LAYER NAME + Label lblName = new Label(); + //Style + lblName.Name = "lblLayer"+layer.Id; + lblName.Font = new Font("Arial",fontSize); + lblName.AutoSize = false; + lblName.Width = labelWidth; + lblName.Text = layer.Name; + lblName.BackColor = Color.Transparent; + lblName.Location = new Point(0,blocsCount * blocSize.Height + Yoffset); + //Style + //Behaviour + pnlLayers.Controls.Add(lblName); + //Behaviour - Button btn = new Button(); - btn.Name = "ChkLayerVisible:" + layer.Id; - btn.Click += LayerSelection; + //BUTTON VISIBILITY + Button BtnVisbility = new Button(); + //Style + BtnVisbility.FlatStyle = FlatStyle.Popup; + BtnVisbility.BackColor = FLAT_GREY1; + BtnVisbility.Location = new Point(BtnXoffset, blocsCount * blocSize.Height + Yoffset / 2); + BtnVisbility.Width = btnWidth; + //Style + //Behaviour if (Project.LayersToPrint.Contains(layer.Id)) { - btn.Text = "Visible"; + BtnVisbility.Text = "Visible"; } else { - btn.Text = "Invisible"; + BtnVisbility.Text = "Invisible"; } - pnlLayers.Controls.Add(btn); - btn.BackColor = Color.FromArgb(59, 59, 59); - btn.Location = new Point(BtnXoffset, blocsCount * Yoffset); - btn.Width = btnWidth; - btn.FlatStyle = FlatStyle.Popup; + BtnVisbility.Name = "ChkLayerVisible:" + layer.Id; + BtnVisbility.Click += LayerSelection; + pnlLayers.Controls.Add(BtnVisbility); + //Behaviour + //BUTTON LAYER SELECTION Button chk = new Button(); + //Style + chk.Location = new Point(ChkXOffset, blocsCount * blocSize.Height + Yoffset / 2); + chk.AutoSize = false; + chk.Text = ""; + chk.FlatStyle = FlatStyle.Popup; + chk.Width = ChkWidth; + chk.Name = "ChkLayerSelected:" + layer.Id; + //Style + //Behaviour chk.Click += LayerCheck; if (SelectedLayers.Contains(layer.Id)) { @@ -329,19 +342,14 @@ namespace Paint_2 chk.BackColor = Color.Red; } pnlLayers.Controls.Add(chk); - chk.Location = new Point(ChkXOffset, blocsCount * Yoffset); - chk.AutoSize = false; - chk.Text = ""; - chk.FlatStyle = FlatStyle.Popup; - chk.Width = ChkWidth; - chk.Name = "ChkLayerSelected:" + layer.Id; + //Behaviour blocsCount++; } } private void LayerSelection(object sender, EventArgs e) { - //We assume that the id of the layer is the name of the button + //We know that the button's name is ChkLayerVisible:... ... being the GUID of the layer Button btn = sender as Button; string rawId = btn.Name; string id = rawId.Replace("ChkLayerVisible:", String.Empty); @@ -350,7 +358,7 @@ namespace Paint_2 } private void LayerCheck(object sender, EventArgs e) { - // We should receive "CheckBox:937r9837r893" + //We know that the button's name is ChkLayerSelected:... ... being the GUID of the layer Button btn = sender as Button; //MessageBox.Show("Btn " + btn.Name + " pressed"); string rawId = btn.Name; diff --git a/Paint_2/Project.cs b/Paint_2/Project.cs index 5c152cb..c623f74 100644 --- a/Paint_2/Project.cs +++ b/Paint_2/Project.cs @@ -54,7 +54,7 @@ namespace Paint_2 AddLayer(); LayersToPrint.Add(Layers[0].Id); } - public void AddLayer() + public string AddLayer() { List newTools = new List(); foreach (PaintTool tool in AvaibleTools) @@ -63,7 +63,22 @@ namespace Paint_2 } uniqIdGenerator = Guid.NewGuid(); string test = uniqIdGenerator.ToString(); - Layers.Add(new Sketch(String.Concat("Layer", Layers.Count + 1), CanvasSize, newTools, uniqIdGenerator.ToString())); + Sketch newSketch = new Sketch(String.Concat("Layer_", Layers.Count + 1), CanvasSize, newTools, uniqIdGenerator.ToString()); + Layers.Add(newSketch); + LayersToPrint.Add(newSketch.Id); + + RestoreLayerNames(); + + return (newSketch.Id); + } + private void RestoreLayerNames() + { + //resets all the names to not have multiple layer 3 for example + + for (int i = 0; i < Layers.Count; i++) + { + Layers[i].Name = "Layer_" + (i + 1); + } } public bool RemoveLayer(string layerId) { @@ -71,6 +86,7 @@ namespace Paint_2 if (layer != null) { Layers.Remove(layer); + RestoreLayerNames(); return true; } else