void UpdateSettingsVisibility(DrawTool tool) { // Retrieve the proper setting type ToolSettingBase settings = null; if (tool == DrawTool.Selection) { // tool selection use the visible settings of the object selected when there is only one settings = GetSettingsForSelectedDrawable(); } else { settings = toolSettings [tool]; } DrawToolSettings drawingSettings = settings as DrawToolSettings; TextToolSettings textSettings = (drawingSettings != null) ? drawingSettings.TextSettings : settings as TextToolSettings; // updates frames visibility linesframe.Visible = drawingSettings != null; textframe.Visible = textSettings != null; // update drawing settings visibility if (drawingSettings != null) { colorslabel.Visible = drawingSettings.Color; colorbutton.Visible = drawingSettings.Color; label3.Visible = drawingSettings.Size; linesizespinbutton.Visible = drawingSettings.Size; label4.Visible = drawingSettings.Style; stylecombobox.Visible = drawingSettings.Style; label5.Visible = drawingSettings.Type; typecombobox.Visible = drawingSettings.Type; } // update text settings visibility if (textSettings != null) { textcolorslabel2.Visible = textSettings.Color; textcolorbutton.Visible = textSettings.Color; backgroundcolorslabel2.Visible = textSettings.Background; backgroundcolorbutton.Visible = textSettings.Background; backgroundcolorslabel3.Visible = textSettings.Size; textspinbutton.Visible = textSettings.Size; } zoombox.Visible = tool == DrawTool.Zoom; }
void CreateToolSettings() { toolSettings = new Dictionary <DrawTool, ToolSettingBase> (); toolSettings.Add(DrawTool.Selection, null); toolSettings.Add(DrawTool.Eraser, null); toolSettings.Add(DrawTool.Zoom, null); DrawToolSettings complete = new DrawToolSettings { Color = true, Size = true, Style = true, Type = true }; toolSettings.Add(DrawTool.Line, complete); DrawToolSettings drawArea = new DrawToolSettings { Color = true, Size = true, Style = true }; toolSettings.Add(DrawTool.CircleArea, drawArea); toolSettings.Add(DrawTool.RectangleArea, drawArea); toolSettings.Add(DrawTool.Cross, drawArea); toolSettings.Add(DrawTool.Rectangle, drawArea); toolSettings.Add(DrawTool.Ellipse, drawArea); DrawToolSettings counter = new DrawToolSettings { Color = true, Size = true }; counter.TextSettings = new TextToolSettings { Color = true }; toolSettings.Add(DrawTool.Counter, counter); TextToolSettings text = new TextToolSettings { Background = true, Color = true, Size = true }; toolSettings.Add(DrawTool.Player, text); toolSettings.Add(DrawTool.Text, text); DrawToolSettings simple = new DrawToolSettings { Color = true, Size = true }; toolSettings.Add(DrawTool.Pen, simple); }