Exemplo n.º 1
0
        internal bool AddGradientToLibrary(ColorGradient cg, bool edit = true)
        {
            Common.Controls.TextDialog dialog = new Common.Controls.TextDialog("Gradient name?");

            while (dialog.ShowDialog() == DialogResult.OK)
            {
                if (dialog.Response == string.Empty)
                {
                    //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
                    MessageBoxForm.msgIcon = SystemIcons.Error;                     //this is used if you want to add a system icon to the message form.
                    var messageBox = new MessageBoxForm("Please enter a name.", "Warning", false, false);
                    messageBox.ShowDialog();
                    continue;
                }

                if (_colorGradientLibrary.Contains(dialog.Response))
                {
                    //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
                    MessageBoxForm.msgIcon = SystemIcons.Warning;                     //this is used if you want to add a system icon to the message form.
                    var messageBox = new MessageBoxForm("There is already a gradient with that name. Do you want to overwrite it?", "Overwrite gradient?", true, true);
                    messageBox.ShowDialog();
                    if (messageBox.DialogResult == DialogResult.OK)
                    {
                        _colorGradientLibrary.AddColorGradient(dialog.Response, cg);
                        if (edit)
                        {
                            _colorGradientLibrary.EditLibraryItem(dialog.Response);
                        }
                        OnGradientLibraryChanged();
                        return(false);
                    }

                    if (messageBox.DialogResult == DialogResult.Cancel)
                    {
                        return(true);
                    }
                }
                else
                {
                    _colorGradientLibrary.AddColorGradient(dialog.Response, cg);
                    if (edit)
                    {
                        _colorGradientLibrary.EditLibraryItem(dialog.Response);
                    }
                    OnGradientLibraryChanged();
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 2
0
        private void toolStripButtonNewGradient_Click(object sender, EventArgs e)
        {
            Common.Controls.TextDialog dialog = new Common.Controls.TextDialog("Gradient name?");

            while (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (dialog.Response == string.Empty)
                {
                    MessageBox.Show("Please enter a name.");
                    continue;
                }

                if (_colorGradientLibrary.Contains(dialog.Response))
                {
                    DialogResult result = MessageBox.Show("There is already a gradient with that name. Do you want to overwrite it?",
                                                          "Overwrite gradient?", MessageBoxButtons.YesNoCancel);
                    if (result == System.Windows.Forms.DialogResult.Yes)
                    {
                        _colorGradientLibrary.AddColorGradient(dialog.Response, new ColorGradient());
                        _colorGradientLibrary.EditLibraryItem(dialog.Response);
                        Populate_Gradients();
                        break;
                    }
                    else if (result == System.Windows.Forms.DialogResult.Cancel)
                    {
                        break;
                    }
                }
                else
                {
                    _colorGradientLibrary.AddColorGradient(dialog.Response, new ColorGradient());
                    _colorGradientLibrary.EditLibraryItem(dialog.Response);
                    break;
                }
            }
        }