private void saveBtn_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in dgvDialogs.Rows)
            {
                // Check Name
                if (!NamingGuidance.CheckDialogName((string)row.Cells[1].Value, true))
                {
                    // Start editing the faulty name cell
                    dgvDialogs.CurrentCell = row.Cells[1];
                    dgvDialogs.BeginEdit(false);
                    return;
                }

                // Check title
                if (!NamingGuidance.CheckCaption((string)row.Cells[2].Value, "Dialog Title", true))
                {
                    // Start editing the faulty name cell
                    dgvDialogs.CurrentCell = row.Cells[2];
                    dgvDialogs.BeginEdit(false);
                    return;
                }
            }

            SelectedDialogs.Clear();

            foreach (LocalDialog d in localDialogs)
            {
                if (d.Selected)
                {
                    // Now set the new Name and Title from the grid.
                    d.Dialog.Name  = d.Name;
                    d.Dialog.Title = d.Title;

                    // Add the dialog to the selected ones.
                    SelectedDialogs.Add(d.Dialog);
                }
            }

            if (SelectedDialogs.Count > 0)
            {
                DialogResult = DialogResult.OK;
            }
            else
            {
                cancelBtn_Click(sender, e);
            }
        }
 private void dgvDialogs_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
 {
     // Check if edited cell is Name or Title
     if (e.ColumnIndex == 1) // Name
     {
         if (!NamingGuidance.CheckDialogName(e.FormattedValue.ToString(), true))
         {
             e.Cancel = true;
         }
     }
     else if (e.ColumnIndex == 2) // Title
     {
         if (!NamingGuidance.CheckCaption(e.FormattedValue.ToString(), "Dialog Title", true))
         {
             e.Cancel = true;
         }
     }
 }
Exemplo n.º 3
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            // Check Action Name
            if (UXAction.MappedToObject != null)
            {
                // Check if mapped to Dialog
                if (UXAction.MappedToObject.ActionType == UXActionType.Dialog)
                {
                    if (!NamingGuidance.CheckUXActionDialogName(UXAction.Name, true))
                    {
                        return;
                    }

                    if (!string.IsNullOrEmpty(UXAction.AlarmId) && (UXAction.Dialog.InterfaceView.ServiceMethod != null))
                    {
                        MessageBox.Show("AlarmId can only be used if the target Dialog has a Service Method defined.", "Action", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }
                // Check if mapped to Service
                else if (UXAction.MappedToObject.ActionType == UXActionType.ServiceMethod)
                {
                    if (!NamingGuidance.CheckUXActionServiceName(UXAction.Name, true))
                    {
                        return;
                    }
                }
            }
            else
            {
                // Check if not mapped
                if (!NamingGuidance.CheckName(UXAction.Name, "UXAction Name", true))
                {
                    return;
                }

                if (!string.IsNullOrEmpty(UXAction.AlarmId))
                {
                    MessageBox.Show("AlarmId can only be used when the Action points to a Dialog or Service Method.", "Action", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }

            if (!NamingGuidance.CheckCaption(UXAction.Caption, "UXAction Caption", true))
            {
                return;
            }

            if (UXAction.MappedToObject == null)
            {
                if (MessageBox.Show("You haven't mapped the Action to any object. Do you want to save the Action anyway?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1) == DialogResult.No)
                {
                    return;
                }
            }

            if (UXAction.OriginalDialog == null)
            {
                UXAction.OriginalDialog = string.Empty;
            }

            Cursor = Cursors.WaitCursor;

            // Save
            try
            {
                if (addedMappedPropertiesInRequestMap.Count > 0 || deletedMappedPropertiesInRequestMap.Count > 0)
                {
                    modelService.StartSynchronizePropertyMapsInObjects(UXAction, new List <IDomainObject>(), deletedMappedPropertiesInRequestMap.Cast <IDomainObject>().ToList());
                }

                UXAction = (UXAction)modelService.SaveDomainObject(UXAction);

                ContaindDomainObjectIdAndType = new KeyValuePair <Guid, Type>(UXAction.Id, typeof(UXAction));

                DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            Cursor = Cursors.Default;
        }