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); }
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(); } } }
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(); } } }
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(); } } }
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(); } } }
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(); } } }
/// <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 EditArgsButton_Click(object sender, RoutedEventArgs e) { DynamicArgumentDesignerOptions options = new DynamicArgumentDesignerOptions() { Title = Bot.Activity.ActivityLibrary.Properties.Resources.DynamicArgumentDialogTitle }; 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(); } }); } }
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); } } }