コード例 #1
0
        internal bool AddCurveToLibrary(Curve c, bool edit = true)
        {
            Common.Controls.TextDialog dialog = new Common.Controls.TextDialog("Curve name?");

            while (dialog.ShowDialog() == DialogResult.OK)
            {
                if (dialog.Response == string.Empty)
                {
                    //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
                    var messageBox = new MessageBoxForm("Please enter a name.", "Curve Name", false, false);
                    messageBox.ShowDialog();
                    continue;
                }

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

                    if (messageBox.DialogResult == DialogResult.Cancel)
                    {
                        return(true);
                    }
                }
                else
                {
                    _curveLibrary.AddCurve(dialog.Response, c);
                    if (edit)
                    {
                        _curveLibrary.EditLibraryCurve(dialog.Response);
                    }
                    OnCurveLibraryChanged();
                    return(false);
                }
            }
            return(true);
        }
コード例 #2
0
ファイル: Form_ToolPalette.cs プロジェクト: komby/vixen
        private void toolStripButtonNewCurve_Click(object sender, EventArgs e)
        {
            Common.Controls.TextDialog dialog = new Common.Controls.TextDialog("Curve name?");

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

                if (_curveLibrary.Contains(dialog.Response))
                {
                    DialogResult result = MessageBox.Show("There is already a curve with that name. Do you want to overwrite it?",
                                                          "Overwrite curve?", MessageBoxButtons.YesNoCancel);
                    if (result == DialogResult.Yes)
                    {
                        _curveLibrary.AddCurve(dialog.Response, new Curve());
                        _curveLibrary.EditLibraryCurve(dialog.Response);
                        Populate_Curves();
                        break;
                    }
                    else if (result == DialogResult.Cancel)
                    {
                        break;
                    }
                }
                else
                {
                    _curveLibrary.AddCurve(dialog.Response, new Curve());
                    _curveLibrary.EditLibraryCurve(dialog.Response);
                    break;
                }
            }
        }