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 virtual void OnListChanged(ActivityCollectionChangeEventArgs e)
 {
     if (e == null)
     {
         throw new ArgumentNullException("e");
     }
     if (((e.Action == ActivityCollectionChangeAction.Replace) || (e.Action == ActivityCollectionChangeAction.Remove)) && (e.RemovedItems != null))
     {
         foreach (Activity activity in e.RemovedItems)
         {
             activity.SetParent(null);
         }
     }
     if (((e.Action == ActivityCollectionChangeAction.Replace) || (e.Action == ActivityCollectionChangeAction.Add)) && (e.AddedItems != null))
     {
         foreach (Activity activity2 in e.AddedItems)
         {
             activity2.SetParent(this);
         }
         Queue <Activity> queue = new Queue <Activity>(e.AddedItems);
         while (queue.Count > 0)
         {
             Activity activity3 = queue.Dequeue();
             if ((activity3 != null) && (((activity3.Name == null) || (activity3.Name.Length == 0)) || (activity3.Name == activity3.GetType().Name)))
             {
                 Activity rootActivity = Helpers.GetRootActivity(activity3);
                 string   str          = rootActivity.GetValue(WorkflowMarkupSerializer.XClassProperty) as string;
                 if ((rootActivity.Parent == null) || !string.IsNullOrEmpty(str))
                 {
                     ArrayList list = new ArrayList();
                     list.AddRange(Helpers.GetIdentifiersInCompositeActivity(rootActivity as CompositeActivity));
                     activity3.Name = DesignerHelpers.GenerateUniqueIdentifier(this.Site, Helpers.GetBaseIdentifier(activity3), (string[])list.ToArray(typeof(string)));
                 }
             }
             if (activity3 is CompositeActivity)
             {
                 foreach (Activity activity5 in ((CompositeActivity)activity3).Activities)
                 {
                     queue.Enqueue(activity5);
                 }
             }
         }
     }
     if (this.Site != null)
     {
         IComponentChangeService service = this.Site.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
         if (service != null)
         {
             service.OnComponentChanged(this, null, e, null);
         }
     }
 }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        public void LoadLibrary(bool isInDesignMode)
        {
            // Properties.Settings.Default.Reset();
            if (isInDesignMode)
            {
                Scenes.Add(DesignerHelpers.GetScene(5, false, true));
                Scenes.Add(DesignerHelpers.GetScene(5, true, false));
                Scenes.Add(DesignerHelpers.GetScene(5, false, false));

                FavColors.Add(new HSV(1, 1, 1));
                FavColors.Add(new HSV(.3, .8, 1));
            }

            else
            {
                try
                {
                    string scenes = Properties.Settings.Default.Scenes;
                    var    array  = JsonConvert.DeserializeObject <StateSet[]>(scenes);

                    foreach (var s in array ?? Array.Empty <StateSet>())
                    {
                        Scenes.Add(s);
                    }
                }
                catch (Exception)
                {
                }

                var favColors = JsonConvert.DeserializeObject <HSV[]>(Properties.Settings.Default.FavColors);

                foreach (var c in favColors ?? Array.Empty <HSV>())
                {
                    FavColors.Add(c);
                }

                if (FavColors.Count == 0)
                {
                    FavColors.Add(new HSV(1, 1, 1));
                    FavColors.Add(new HSV(.3, .8, 1));

                    SaveLibrary();
                }

                App.Current.Exit += (s, e) => SaveLibrary();
            }
        }
        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.º 6
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.º 7
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.º 8
0
 private void GetHelp()
 {
     DesignerHelpers.ShowHelpFromKeyword(this.serviceProvider, typeof(OperationPickerDialog).FullName + ".UI");
 }
Ejemplo n.º 9
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);
        }