Beispiel #1
0
        public void ToolView_Click(object sender, EventArgs e)
        {
            ToolView toolView = (sender as Label).Parent as ToolView;

            if (toolView.Tool != null)
            {
                _tool = toolView.Tool;
                _toolsView.UpdateOptions(_tool);
            }

            else if (toolView.OptionDialog != null)
            {
                DialogResult result = toolView.OptionDialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    SizeDialog  sizeDialog  = toolView.OptionDialog as SizeDialog;
                    ColorDialog colorDialog = toolView.OptionDialog as ColorDialog;

                    if (sizeDialog != null)
                    {
                        _tool.Size          = sizeDialog.Size;
                        toolView.Label.Text = "Str.: " + sizeDialog.Size;
                    }
                    else if (colorDialog != null)
                    {
                        _tool.Color        = colorDialog.Color;
                        toolView.BackColor = colorDialog.Color;
                    }
                }
            }
        }
Beispiel #2
0
        public void UpdateOptions(Tool tool)
        {
            foreach (Control control in Controls)
            {
                ToolView toolView = control as ToolView;
                if (toolView != null)
                {
                    if (toolView.Tool != null)
                    {
                        toolView.Selected = toolView.Tool == tool;
                    }

                    else if (toolView.OptionDialog != null)
                    {
                        SizeDialog  sizeDialog  = toolView.OptionDialog as SizeDialog;
                        ColorDialog colorDialog = toolView.OptionDialog as ColorDialog;

                        if (sizeDialog != null)
                        {
                            if (tool.SizeChangeable)
                            {
                                sizeDialog.Size = tool.Size;

                                toolView.Visible    = true;
                                toolView.Label.Text = "Str.: " + sizeDialog.Size;
                            }
                            else
                            {
                                toolView.Visible = false;
                            }
                        }
                        else if (colorDialog != null)
                        {
                            if (tool.ColorChangeable)
                            {
                                colorDialog.Color  = tool.Color;
                                toolView.Visible   = true;
                                toolView.BackColor = colorDialog.Color;
                            }
                            else
                            {
                                toolView.Visible = false;
                            }
                        }
                    }
                }
            }
        }