void parametersGrid_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            string errorString = string.Empty;
            bool   valid       = true;

            if (e.ColumnIndex == this.nameColumn.Index)
            {
                valid = ValidateParamaterName((string)e.FormattedValue, e, out errorString);
            }
            // void is not valid for parameters other than returnvalue
            if (e.ColumnIndex == this.typeColumn.Index)
            {
                if (typeof(void).ToString().Equals(e.FormattedValue) && !(this.parametersGrid.Rows[e.RowIndex].Cells[this.nameColumn.Index].Value.Equals(SR2.GetString(SR2.ReturnValueString))))
                {
                    valid       = false;
                    errorString = SR2.GetString(SR2.VoidIsNotAValidParameterType);
                }
            }
            if (!valid)
            {
                e.Cancel = true;
                DesignerHelpers.ShowMessage(this.ServiceProvider, errorString, DR.GetString(DR.WorkflowDesignerTitle), MessageBoxButtons.OK,
                                            MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
        }
Ejemplo n.º 2
0
        protected override void OnSelectedIndexChanged(EventArgs e)
        {
            try
            {
                if (this.SelectedIndex < 0)
                {
                    return;
                }
                object selectedItem = Items[this.SelectedIndex];
                if (selectedItem == null)
                {
                    return;
                }
                SelectedItemViewControl = Activator.CreateInstance(GetDetailViewType(selectedItem.GetType())) as ListItemViewControl;
                SelectedItemViewControl.ServiceProvider = this.serviceProvider;
                SelectedItemViewControl.Item            = selectedItem;
                SelectedItemViewControl.DrawItemState   = DrawItemState.Selected;
                SelectedItemViewControl.ItemChanged    += new EventHandler(SelectedItemDetailViewControlItemChanged);
                SelectedItemViewControl.UpdateView();
                if (Editable)
                {
                    if (activeItemViewControl != null)
                    {
                        this.Controls.Remove(activeItemViewControl);
                    }
                    if (selectedItem != null)
                    {
                        activeItemViewControl = Activator.CreateInstance(GetItemViewType(selectedItem.GetType())) as ListItemViewControl;
                        if (itemLocations.ContainsKey(selectedItem))
                        {
                            activeItemDetailViewControl.Location = itemLocations[selectedItem];
                        }
                        activeItemViewControl.DrawItemState = DrawItemState.Selected;
                        activeItemViewControl.UpdateView();
                        activeItemViewControl.Item = selectedItem;

                        this.Controls.Add(activeItemViewControl);
                    }
                }
            }
            catch (Exception exception)
            {
                DesignerHelpers.ShowMessage(serviceProvider, exception.Message, DR.GetString(DR.WorkflowDesignerTitle), MessageBoxButtons.OK,
                                            MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                throw;
            }
            base.OnSelectedIndexChanged(e);
        }
        bool TrySelectType(TypeBrowserDialog typeBrowserDialog, DataGridViewCell cell)
        {
            typeBrowserDialog.ShowDialog();
            if (typeBrowserDialog.SelectedType != null)
            {
                if (!ParameterTypeFilterProvider.IsValidType(typeBrowserDialog.SelectedType))
                {
                    DesignerHelpers.ShowMessage(this.ServiceProvider, SR2.GetString(SR2.InvalidParameterType,
                                                                                    typeBrowserDialog.SelectedType), DR.GetString(DR.WorkflowDesignerTitle), MessageBoxButtons.OK,
                                                MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                    return(false);
                }
                AddToTypeList(typeBrowserDialog.SelectedType);
            }
            typeChooserCellItem.ChosenType = typeBrowserDialog.SelectedType;
            cell.Value = typeBrowserDialog.SelectedType;

            return(true);
        }
Ejemplo n.º 4
0
        void ServiceOperationValidating(object sender, CancelEventArgs e)
        {
            ServiceOperationListItem serviceOperationListItem = (ServiceOperationListItem)sender;
            string newOperationName = serviceOperationListItem.Name;
            string contractName     = serviceOperationListItem.ContractName;

            if (string.IsNullOrEmpty(newOperationName))
            {
                e.Cancel = true;
                string errorString = SR2.GetString(SR2.OperationNameCannotBeEmpty);
                DesignerHelpers.ShowMessage(this.serviceProvider, errorString, System.Workflow.ComponentModel.Design.DR.GetString(System.Workflow.ComponentModel.Design.DR.WorkflowDesignerTitle), MessageBoxButtons.OK,
                                            MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }

            Fx.Assert(!string.IsNullOrEmpty(contractName), "contract name should be valid to run this check");
            ServiceContractListItem contractListItem = serviceContracts.Find(contractName);

            Fx.Assert(contractListItem != null, "contract should be present in the list to run this check");

            // operation names must be unique inside a contract
            bool duplicatesFound = false;

            foreach (ServiceOperationListItem foundOperation in contractListItem.Operations)
            {
                if (foundOperation == serviceOperationListItem)
                {
                    continue;
                }
                if (foundOperation.Name.Equals(newOperationName))
                {
                    duplicatesFound = true;
                    break;
                }
            }
            if (duplicatesFound)
            {
                e.Cancel = true;
                string errorString = SR2.GetString(SR2.OperationNameMustBeUnique);
                DesignerHelpers.ShowMessage(this.serviceProvider, errorString, System.Workflow.ComponentModel.Design.DR.GetString(System.Workflow.ComponentModel.Design.DR.WorkflowDesignerTitle), MessageBoxButtons.OK,
                                            MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
        }
Ejemplo n.º 5
0
        void ServiceContractValidating(object sender, CancelEventArgs e)
        {
            ServiceContractListItem serviceContractListItem = (ServiceContractListItem)sender;

            if (string.IsNullOrEmpty(serviceContractListItem.Name))
            {
                e.Cancel = true;
                string errorString = SR2.GetString(SR2.ContractNameCannotBeEmpty);
                DesignerHelpers.ShowMessage(this.serviceProvider, errorString, System.Workflow.ComponentModel.Design.DR.GetString(System.Workflow.ComponentModel.Design.DR.WorkflowDesignerTitle), MessageBoxButtons.OK,
                                            MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
            bool duplicatesFound = false;

            foreach (ServiceContractListItem foundContract in serviceContracts)
            {
                if (foundContract == serviceContractListItem)
                {
                    continue;
                }

                // allow reimport of existing imported contracts
                if (!serviceContractListItem.IsCustomContract && serviceContractListItem.ContractType.Equals(foundContract.ContractType))
                {
                    continue;
                }

                if (foundContract.Name.Equals(serviceContractListItem.Name))
                {
                    duplicatesFound = true;
                    break;
                }
            }
            // contract names must be unique
            if (duplicatesFound)
            {
                e.Cancel = true;
                string errorString = SR2.GetString(SR2.ContractNameMustBeUnique);
                DesignerHelpers.ShowMessage(this.serviceProvider, errorString, System.Workflow.ComponentModel.Design.DR.GetString(System.Workflow.ComponentModel.Design.DR.WorkflowDesignerTitle), MessageBoxButtons.OK,
                                            MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
        }
Ejemplo n.º 6
0
        public static bool TryPickOperation(IServiceProvider serviceProvider, Activity activity, OperationInfoBase currentOperation, out OperationInfoBase selectedOperation)
        {
            selectedOperation = null;
            bool isReceiveActivity = activity is ReceiveActivity;

            try
            {
                using (OperationPickerDialog operationPicker = new OperationPickerDialog(serviceProvider, isReceiveActivity))
                {
                    Walker activityTreeWalker  = new Walker();
                    Type   allowedActivityType = null;

                    if (isReceiveActivity)
                    {
                        allowedActivityType = typeof(ReceiveActivity);
                    }
                    else
                    {
                        allowedActivityType = typeof(SendActivity);
                    }

                    activityTreeWalker.FoundActivity += delegate(Walker walker, WalkerEventArgs eventArgs)
                    {
                        Activity foundActivity = eventArgs.CurrentActivity;
                        if (!(allowedActivityType.IsAssignableFrom(foundActivity.GetType())))
                        {
                            return;
                        }

                        if (!foundActivity.Enabled)
                        {
                            return;
                        }

                        if (foundActivity is ReceiveActivity)
                        {
                            ReceiveActivity reciveActivity = foundActivity as ReceiveActivity;
                            if (reciveActivity.ServiceOperationInfo != null)
                            {
                                operationPicker.AddServiceOperation(reciveActivity.ServiceOperationInfo, reciveActivity);
                            }
                        }
                        if (foundActivity is SendActivity)
                        {
                            SendActivity sendActivity = foundActivity as SendActivity;
                            if (sendActivity.ServiceOperationInfo != null)
                            {
                                operationPicker.AddServiceOperation(sendActivity.ServiceOperationInfo, sendActivity);
                            }
                        }
                    };
                    activityTreeWalker.Walk(activity.RootActivity);
                    OperationInfoBase currentServiceOperationInfo = currentOperation as OperationInfoBase;
                    if (currentServiceOperationInfo != null)
                    {
                        operationPicker.SelectedOperation = currentServiceOperationInfo;
                    }
                    DialogResult dialogResult = operationPicker.ShowDialog();
                    if ((operationPicker.SelectedOperation != null) && (dialogResult == DialogResult.OK) && !operationPicker.SelectedOperation.Equals(currentServiceOperationInfo))
                    {
                        selectedOperation = operationPicker.SelectedOperation.Clone();
                        return(true);
                    }
                }
            }
            catch (Exception e)
            {
                DesignerHelpers.ShowMessage(serviceProvider, e.Message, DR.GetString(DR.WorkflowDesignerTitle), MessageBoxButtons.OK,
                                            MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                throw;
            }

            return(false);
        }