Example #1
0
        public override void ShowDialog(PropertyValue propertyValue, IInputElement commandSource)
        {
            var ownerActivityConverter = new ModelPropertyEntryToOwnerActivityConverter();
            var activityItem           = ownerActivityConverter.Convert(propertyValue.ParentProperty, typeof(ModelItem), false, null) as ModelItem;
            var editingContext         = activityItem.GetEditingContext();
            var parentModelItem        = ownerActivityConverter.Convert(propertyValue.ParentProperty, typeof(ModelItem), true, null) as ModelItem;
            var args = parentModelItem.Properties[propertyValue.ParentProperty.PropertyName].Dictionary;

            var options = new DynamicArgumentDesignerOptions
            {
                Title = $"{activityItem.ItemType.Name}.{propertyValue.ParentProperty.DisplayName}"
            };

            using (var modelEditingScope = args.BeginEdit("Editing"))
            {
                if (DynamicArgumentDialog.ShowDialog(activityItem, args, editingContext, activityItem.View, options))
                {
                    modelEditingScope.Complete();
                }
                else
                {
                    modelEditingScope.Revert();
                }
            }
        }
Example #2
0
        /// <summary>
        /// Handles the Click event of the DefineArgsButton control to launch a DynamicArgumentDialog instance for argument editing.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void DefineArgsButton_Click(object sender, RoutedEventArgs e)
        {
            DynamicArgumentDesignerOptions options = new DynamicArgumentDesignerOptions()
            {
                Title = Bot.Activity.ActivityLibrary.Properties.Resources.DynamicArgumentDialogTitle
            };

            this.InitImportDynamicArgumentDialog();

            this.ModelItem.Properties["ChildArguments"].SetValue(argumentDictionary);
            ModelItem modelItem = this.ModelItem.Properties["ChildArguments"].Dictionary;


            using (ModelEditingScope change = modelItem.BeginEdit("ChildArgumentEditing"))
            {
                ThreadInvoker.Instance.RunByUiThread(() =>
                {
                    if (DynamicArgumentDialog.ShowDialog(this.ModelItem, modelItem, Context, this.ModelItem.View, options))
                    {
                        change.Complete();
                    }
                    else
                    {
                        change.Revert();
                    }
                });
            }
        }
Example #3
0
        public override void ShowDialog(PropertyValue propertyValue, IInputElement commandSource)
        {
            string propertyName = propertyValue.ParentProperty.PropertyName;

            var ownerActivity = (new ModelPropertyEntryToOwnerActivityConverter()).Convert(
                propertyValue.ParentProperty, typeof(ModelItem), false, null) as ModelItem;

            DynamicArgumentDesignerOptions options = new DynamicArgumentDesignerOptions()
            {
                Title = propertyName
            };

            ModelItem modelItem = ownerActivity.Properties[propertyName].Dictionary;

            using (ModelEditingScope change = modelItem.BeginEdit(propertyName + "Editing")) {
                if (DynamicArgumentDialog.ShowDialog(ownerActivity, modelItem, ownerActivity.GetEditingContext(), ownerActivity.View, options))
                {
                    change.Complete();
                }
                else
                {
                    change.Revert();
                }
            }
        }
        private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            var options = new DynamicArgumentDesignerOptions
            {
                Title = string.Format("Параметры")
            };

            // получаем параметры из активити
            var parameters = GetParametersProperty();

            // дополняем параметрами из класса
            foreach (var propertyDescriptor in _eventDetailProperties)
            {
                if (parameters.ContainsKey(propertyDescriptor.Name))
                {
                    continue;
                }
                parameters.Add(propertyDescriptor.Name, ActivityHelpers.CreateDefaultValue(propertyDescriptor.PropertyType, ArgumentDirection.In));
            }

            using (var change = parameters.BeginEdit("ObjectEditing"))
            {
                if (DynamicArgumentDialog.ShowDialog(ModelItem, parameters, Context, ModelItem.View, options))
                {
                    change.Complete();
                }
                else
                {
                    change.Revert();
                }
            }
        }
Example #5
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var options = new DynamicArgumentDesignerOptions
            {
                Title = string.Format("Параметры метода {0}", _methodInfo.Name)
            };

            var modelParameters = GetParametersProperty();

            foreach (var p in _methodParameters)
            {
                if (modelParameters.ContainsKey(p.Name ?? ResultParamName))
                {
                    continue;
                }

                var direction = (p.IsOut || p.IsRetval || string.IsNullOrEmpty(p.Name)) ? ArgumentDirection.Out : ArgumentDirection.In;
                modelParameters.Add(p.Name ?? ResultParamName, ActivityHelpers.CreateDefaultValue(p.ParameterType, direction));
            }

            using (ModelEditingScope change = modelParameters.BeginEdit("ObjectEditing"))
            {
                if (DynamicArgumentDialog.ShowDialog(ModelItem, modelParameters, Context, ModelItem.View, options))
                {
                    change.Complete();
                }
                else
                {
                    change.Revert();
                }
            }
        }
        public override void ShowDialog(PropertyValue propertyValue, IInputElement commandSource)
        {
            ModelPropertyEntryToOwnerActivityConverter ownerActivityConverter = new ModelPropertyEntryToOwnerActivityConverter();
            ModelItem activityItem =
                ownerActivityConverter.Convert(propertyValue.ParentProperty, typeof(ModelItem), false, null) as ModelItem;
            EditingContext context = activityItem.GetEditingContext();

            ModelItem parentModelItem =
                ownerActivityConverter.Convert(propertyValue.ParentProperty, typeof(ModelItem), true, null) as ModelItem;
            ModelItemDictionary arguments = parentModelItem.Properties[propertyValue.ParentProperty.PropertyName].Dictionary;

            DynamicArgumentDesignerOptions options = new DynamicArgumentDesignerOptions
            {
                Title = propertyValue.ParentProperty.DisplayName
            };

            using (ModelEditingScope change = arguments.BeginEdit("PowerShellParameterEditing"))
            {
                if (DynamicArgumentDialog.ShowDialog(activityItem, arguments, context, activityItem.View, options))
                {
                    change.Complete();
                }
                else
                {
                    change.Revert();
                }
            }
        }
        private void ImportArgumentsBtn_Click(object sender, RoutedEventArgs e)
        {
            var workflowFilePathArg = ModelItem.Properties["WorkflowFilePath"].ComputedValue as InArgument <string>;

            var workflowFilePath = "";

            if (workflowFilePathArg != null)
            {
                //TODO WJF 此处该转换不确定是否正确,准确用法需要Get(Context)这种用法
                workflowFilePath = GetInArgumentStringValue(workflowFilePathArg);

                //转成绝对路径
                //如果workflowFilePath不是绝对路径,则转成绝对路径
                if (!System.IO.Path.IsPathRooted(workflowFilePath))
                {
                    workflowFilePath = System.IO.Path.Combine(SharedObject.Instance.ProjectPath, workflowFilePath);
                }
            }

            Dictionary <string, Argument> argDict = new Dictionary <string, Argument>();

            if (!string.IsNullOrEmpty(workflowFilePath))
            {
                var activity = ActivityXamlServices.Load(workflowFilePath) as DynamicActivity;
                foreach (var prop in activity.Properties)
                {
                    if (!argDict.ContainsKey(prop.Name))
                    {
                        if (prop.Value == null)
                        {
                            argDict.Add(prop.Name, (Argument)Activator.CreateInstance(prop.Type));
                        }
                        else
                        {
                            argDict.Add(prop.Name, (Argument)prop.Value);
                        }
                    }
                }
            }

            var options = new DynamicArgumentDesignerOptions()
            {
                Title = "导入工作流参数"
            };

            ModelTreeManager mtm = new ModelTreeManager(new EditingContext());

            mtm.Load(argDict);

            if (DynamicArgumentDialog.ShowDialog(this.ModelItem, mtm.Root, Context, this.ModelItem.View, options))
            {
                var saveArgDict = this.ModelItem.Properties["Arguments"].Dictionary;
                saveArgDict.Clear();
                foreach (var item in argDict)
                {
                    saveArgDict.Add(item.Key, item.Value);
                }
            }
        }
        void OnParametersButtonClicked(object sender, RoutedEventArgs e)
        {
            DynamicArgumentDesignerOptions dadOptions = new DynamicArgumentDesignerOptions
            {
                Title = P.Resources.Parameters
            };

            DynamicArgumentDialog.ShowDialog(ModelItem, ModelItem.Properties["Parameters"].Value, ModelItem.GetEditingContext(), this, dadOptions);
        }
        private void EditArgumentsBtn_Click(object sender, RoutedEventArgs e)
        {
            ModelItem mi      = this.ModelItem.Properties["Arguments"].Dictionary;
            var       options = new DynamicArgumentDesignerOptions()
            {
                Title = "编辑工作流参数"
            };

            DynamicArgumentDialog.ShowDialog(this.ModelItem, mi, Context, this.ModelItem.View, options);
        }
        public override void ShowDialog(PropertyValue propertyValue, Windows.IInputElement commandSource)
        {
            ModelPropertyEntryToOwnerActivityConverter propertyEntryConverter = new ModelPropertyEntryToOwnerActivityConverter();
            ModelItem                      parentModelItem = (ModelItem)propertyEntryConverter.Convert(propertyValue.ParentProperty, typeof(ModelItem), true, null);
            EditingContext                 context         = ((IModelTreeItem)parentModelItem).ModelTreeManager.Context;
            ModelItemDictionary            inputData       = parentModelItem.Properties[propertyValue.ParentProperty.PropertyName].Dictionary;
            DynamicArgumentDesignerOptions options         = new DynamicArgumentDesignerOptions();

            options.Title = propertyValue.ParentProperty.DisplayName;

            DynamicArgumentDialog.ShowDialog(parentModelItem, inputData, context, parentModelItem.View, options);
        }
Example #11
0
        public static void ShowDialog(string propertyName, ModelItem ownerActivity)
        {
            DynamicArgumentDesignerOptions options = new DynamicArgumentDesignerOptions
            {
                Title = propertyName
            };
            ModelItem collection = ownerActivity.Properties[propertyName].Collection;

            using (ModelEditingScope modelEditingScope = collection.BeginEdit(propertyName + "Editing"))
            {
                if (DynamicArgumentDialog.ShowDialog(ownerActivity, collection, ownerActivity.GetEditingContext(), ownerActivity.View, options))
                {
                    modelEditingScope.Complete();
                }
                else
                {
                    modelEditingScope.Revert();
                }
            }
        }
Example #12
0
        public static void ShowDialog(string propertyName, ModelItem ownerActivity)
        {
            DynamicArgumentDesignerOptions options = new DynamicArgumentDesignerOptions()
            {
                Title = propertyName
            };

            ModelItem modelItem = ownerActivity.Properties[propertyName].Value;

            using (ModelEditingScope change = modelItem.BeginEdit(propertyName + "Editing")) {
                if (DynamicArgumentDialog.ShowDialog(ownerActivity, modelItem, ownerActivity.GetEditingContext(), ownerActivity.View, options))
                {
                    change.Complete();
                }
                else
                {
                    change.Revert();
                }
            }
        }
        private void EditArgumentsBtn_Click(object sender, RoutedEventArgs e)
        {
            DynamicArgumentDesignerOptions options = new DynamicArgumentDesignerOptions
            {
                Title = "执行Python脚本文件参数设置"
            };
            ModelItemDictionary dictionary = base.ModelItem.Properties["Arguments"].Dictionary;

            using (ModelEditingScope modelEditingScope = dictionary.BeginEdit("PythonScriptFileArgumentEditing"))
            {
                if (DynamicArgumentDialog.ShowDialog(base.ModelItem, dictionary, base.Context, base.ModelItem.View, options))
                {
                    modelEditingScope.Complete();
                }
                else
                {
                    modelEditingScope.Revert();
                }
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var options = new DynamicArgumentDesignerOptions
            {
                Title = string.Format("Укажите параметры")
            };

            var modelItem = ModelItem.Properties["Parameters"].Dictionary;

            using (ModelEditingScope change = modelItem.BeginEdit("ObjectEditing"))
            {
                if (DynamicArgumentDialog.ShowDialog(ModelItem, modelItem, Context, ModelItem.View, options))
                {
                    //TODO: Удалить свойства, у которых value == null.
                    change.Complete();
                }
                else
                {
                    change.Revert();
                }
            }
        }
Example #15
0
        public override void ShowDialog(PropertyValue propertyValue, System.Windows.IInputElement commandSource)
        {
            // https://stackoverflow.com/questions/8731605/exposing-collection-of-arguments-for-activity-in-property-grid
            var       PropertyName = propertyValue.ParentProperty.PropertyName;
            ModelItem activity     = new ModelPropertyEntryToOwnerActivityConverter().Convert(propertyValue.ParentProperty, typeof(ModelItem), false, null) as ModelItem;

            DynamicArgumentDesignerOptions options1 = new DynamicArgumentDesignerOptions();

            options1.Title = activity.GetValue <string>("DisplayName");
            DynamicArgumentDesignerOptions options = options1;

            if (!activity.Properties[PropertyName].IsSet)
            {
                Log.Output(PropertyName + " is not set");
                return;
            }
            ModelItem collection = activity.Properties[PropertyName].Collection;

            if (collection == null)
            {
                collection = activity.Properties[PropertyName].Dictionary;
            }
            if (collection == null)
            {
                Log.Output(PropertyName + " is not a Collection or Dictionary");
                return;
            }
            using (ModelEditingScope scope = collection.BeginEdit(PropertyName + "Editing"))
            {
                if (DynamicArgumentDialog.ShowDialog(activity, collection, activity.GetEditingContext(), activity.View, options))
                {
                    scope.Complete();
                }
                else
                {
                    scope.Revert();
                }
            }
        }
Example #16
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string PropertyName = "Payload";
            DynamicArgumentDesignerOptions options1 = new DynamicArgumentDesignerOptions();

            options1.Title = ModelItem.GetValue <string>("DisplayName");
            DynamicArgumentDesignerOptions options = options1;

            if (!ModelItem.Properties[PropertyName].IsSet)
            {
                Log.Warning(PropertyName + " is not set");
                return;
            }
            ModelItem collection = ModelItem.Properties[PropertyName].Collection;

            if (collection == null)
            {
                collection = ModelItem.Properties[PropertyName].Dictionary;
            }
            if (collection == null)
            {
                Log.Warning(PropertyName + " is not a Collection or Dictionary");
                return;
            }
            using (ModelEditingScope scope = collection.BeginEdit(PropertyName + "Editing"))
            {
                if (DynamicArgumentDialog.ShowDialog(ModelItem, collection, ModelItem.GetEditingContext(), ModelItem.View, options))
                {
                    scope.Complete();
                }
                else
                {
                    scope.Revert();
                }
            }
        }
Example #17
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            const string propertyFormat = "[{0}]";
            var          cnerror        = string.Format("!{0}. ", wmsMLC.General.Resources.StringResources.Error);
            var          options        = new DynamicArgumentDesignerOptions
            {
                Title = string.Format("Свойства {0}", _objType.Name)
            };

            var modelItem = ModelItem.Properties["Properties"].Dictionary;

            foreach (PropertyDescriptor p in _properties)
            {
                var propertySubkey    = string.Format(propertyFormat, p.Name);
                var displayNameSubkey = p.DisplayName ?? string.Empty;

                var keyVisual = string.Format("{0} {1}", displayNameSubkey, propertySubkey).GetTrim();

                //ToDo: Блок совместимости со старой версией
                //Ищем по старому и новому ключу
                if (!modelItem.ContainsKey(keyVisual) && !modelItem.ContainsKey(propertySubkey))
                {
                    modelItem.Add(propertySubkey, CreateDefaultValue(p.PropertyType));
                }

                //Преобразуем
                if (modelItem.ContainsKey(propertySubkey))
                {
                    modelItem[keyVisual] = modelItem[propertySubkey];
                    modelItem.Remove(propertySubkey);
                }

                var baditems = modelItem.Select(g => new
                {
                    Skey = g.Key.GetCurrentValue().To(string.Empty),
                    Pair = g
                })
                               .Where(g => (g.Skey != keyVisual && g.Skey != propertySubkey) && g.Skey.ToUpper().Contains(propertySubkey.ToUpper())) //Этот кошмар для совместимости
                               .Select(g => g.Pair).ToArray();

                foreach (var baditem in baditems)
                {
                    object currentvalue;
                    if (baditem.Value == null || (currentvalue = baditem.Value.GetCurrentValue()) == null ||
                        (currentvalue as Argument != null && ((Argument)currentvalue).Expression == null))
                    {
                        modelItem.Remove(baditem.Key);
                        continue;
                    }

                    var badkey = baditem.Key.GetCurrentValue().To(string.Empty);
                    if (badkey.StartsWith(cnerror))
                    {
                        continue;
                    }

                    modelItem[string.Format("{0}{1}", cnerror, baditem.Key)] = baditem.Value;
                    modelItem.Remove(baditem.Key);
                }
            }

            //Проверка свойств
            foreach (var p in modelItem.ToArray())
            {
                var propertyname = GetProperty(p.Key.GetCurrentValue().To <string>());

                if (string.IsNullOrEmpty(propertyname))
                {
                    continue;
                }
                if (_properties.Find(propertyname, true) != null)
                {
                    continue;
                }
                modelItem[string.Format("{0}{1}", cnerror, p.Key)] = p.Value;
                modelItem.Remove(p.Key);
            }

            using (var change = modelItem.BeginEdit("ObjectEditing"))
            {
                if (DynamicArgumentDialog.ShowDialog(ModelItem, modelItem, Context, ModelItem.View, options))
                {
                    change.Complete();
                    //ToDo: Узнать как удалять из modelItem внутри ModelEditingScope
                    RemoveDescription(modelItem, propertyFormat);
                }
                else
                {
                    change.Revert();
                    RemoveDescription(modelItem, propertyFormat);
                }
            }
        }