Esempio n. 1
0
        private void okButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(this.colorNameText.Text))
                {
                    MessageDialog.ShowWarning("Please entry color naqme.");
                    return;
                }

                if (string.IsNullOrEmpty(this.dwgPathText.Text))
                {
                    MessageDialog.ShowWarning("Please entry DWG path.");
                    return;
                }

                foreach (var c in this.colors)
                {
                    if (c.ColorName == this.colorNameText.Text)
                    {
                        MessageDialog.ShowWarning("This color name is already registered.");
                        return;
                    }
                }

                var color = new SocketBoxPatternColor();
                color.PatternId = this.patternId;
                color.ColorName = this.colorNameText.Text;
                color.DwgPath   = this.dwgPathText.Text;
                this.NewColor   = color;

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception exp)
            {
                MessageDialog.ShowError(exp);
            }
        }
        private void dataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.ColumnIndex != this.buttonColumn.Index)
                {
                    return;
                }

                var color = this.dataGridView.Rows[e.RowIndex].DataBoundItem as SocketBoxPatternColor;
                if (color == null)
                {
                    throw new ApplicationException("Invalid color is selected. Please close this form and open again.");
                }

                this.SelectedColor = color;

                this.DialogResult = DialogResult.OK;
            }
            catch (Exception exp)
            {
                MessageDialog.ShowError(exp);
            }
        }