public override void ShowDialog(PropertyValue propertyValue, IInputElement commandSource) { try { ModelItem modelItem = new ModelPropertyEntryToOwnerActivityConverter().Convert(propertyValue.ParentProperty, typeof(ModelItem), false, null) as ModelItem; using (ModelEditingScope modelEditingScope = modelItem.BeginEdit()) { if (new TextEditorDialog(modelItem).ShowOkCancel()) { modelEditingScope.Complete(); } else { modelEditingScope.Revert(); } } } catch { } }
public override void ShowDialog(PropertyValue propertyValue, System.Windows.IInputElement commandSource) { ParamTransferWin wn = new ParamTransferWin(propertyValue.Value as List <paramtransfer_item>); //wn.newValue = propertyValue.Value as List<string>; if (wn.ShowDialog().Equals(true)) { var ownerActivityConverter = new ModelPropertyEntryToOwnerActivityConverter(); ModelItem activityItem = ownerActivityConverter.Convert(propertyValue.ParentProperty, typeof(ModelItem), false, null) as ModelItem; using (ModelEditingScope editingScope = activityItem.BeginEdit()) { propertyValue.Value = wn.params_transfer; editingScope.Complete(); var control = commandSource as Control; var oldData = control.DataContext; control.DataContext = null; control.DataContext = oldData; } } }
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(); } } }
public override void ShowDialog(PropertyValue propertyValue, IInputElement commandSource) { var ownerActivityConverter = new ModelPropertyEntryToOwnerActivityConverter(); var modelItem = ownerActivityConverter.Convert(propertyValue.ParentProperty, typeof(ModelItem), false /*no parent*/, null) as ModelItem; var collection = modelItem.Properties["Fields"].Collection; var actualCollection = collection.GetCurrentValue() as IEnumerable <ValueDataField>; var clonedCollection = new ObservableCollection <ValueDataField>(actualCollection.Select((item) => item.Clone() as ValueDataField)); var dialog = new CustomCollectionEditorDialog(clonedCollection); dialog.ShowDialog(); if (dialog.DialogResult == true) { using (var scope = collection.BeginEdit()) { collection.Clear(); dialog.Collection.ToList().ForEach((item) => collection.Add(item)); scope.Complete(); } } }
public override void ShowDialog(PropertyValue propertyValue, IInputElement commandSource) { ModelPropertyEntryToOwnerActivityConverter propertyEntryConverter = new ModelPropertyEntryToOwnerActivityConverter(); ModelItem activityModelItem = (ModelItem)propertyEntryConverter.Convert(propertyValue.ParentProperty, typeof(ModelItem), false, null); ModelItem parentModelItem = (ModelItem)propertyEntryConverter.Convert(propertyValue.ParentProperty, typeof(ModelItem), true, null); EditingContext context = ((IModelTreeItem)activityModelItem).ModelTreeManager.Context; ModelItemCollection inputData = parentModelItem.Properties[propertyValue.ParentProperty.PropertyName].Collection; IEnumerable <Type> rawInputData = inputData.GetCurrentValue() as IEnumerable <Type>; Fx.Assert(rawInputData != null, "rawInputData is null or is not IEnumerable<Type>."); ModelProperty editingProperty = activityModelItem.Properties[propertyValue.ParentProperty.PropertyName]; bool allowDuplication = GetOptionValueOrUseDefault(editingProperty.Attributes, TypeCollectionPropertyEditor.AllowDuplicate, true); Func <Type, bool> filter = GetOptionValueOrUseDefault <Func <Type, bool> >(editingProperty.Attributes, TypeCollectionPropertyEditor.Filter, null); Type defaultType = GetOptionValueOrUseDefault <Type>(editingProperty.Attributes, TypeCollectionPropertyEditor.DefaultType, typeof(Object)); EditorWindow editorWindow = new EditorWindow(activityModelItem, rawInputData, context, activityModelItem.View, allowDuplication, filter, defaultType); if (editorWindow.ShowOkCancel()) { using (var commitEditingScope = inputData.BeginEdit(System.Activities.Core.Presentation.SR.ChangeTypeCollectionEditingScopeDesc)) { inputData.Clear(); foreach (Type i in ((TypeCollectionDesigner)editorWindow.Content).UpdatedTypeCollection) { inputData.Add(i); } commitEditingScope.Complete(); } } }
public override void ShowDialog(PropertyValue propertyValue, IInputElement commandSource) { ModelPropertyEntryToOwnerActivityConverter ownerActivityConverter = new ModelPropertyEntryToOwnerActivityConverter(); ModelItem activityItem = ownerActivityConverter.Convert(propertyValue.ParentProperty, typeof(ModelItem), false, null) as ModelItem; var av = activityItem.GetCurrentValue() as SendBusinessObjectsReportToEmail; var currReportUn = string.Empty; if (av != null && av.Report_id != null) { var literal = av.Report_id.Expression as Literal <string>; if (literal == null) { return; } currReportUn = literal.Value; } var dialog = new ReportBusinessObjectsIdDialog(activityItem); var lv = dialog.lvReports; lv.ItemsSource = null; List <Info_Report_Stimul> reports = null; try { reports = ServiceFactory.ArmServiceInvokeSync <List <Info_Report_Stimul> >("REP_GetStimulReports"); } catch (Exception ex) { Manager.UI.ShowMessage(ex.Message); return; } if (reports == null) { return; } lv.ItemsSource = reports; if (!string.IsNullOrEmpty(currReportUn)) { var selectedReport = reports.FirstOrDefault(r => r.Report_UN == currReportUn); if (selectedReport != null) { lv.SelectedItem = selectedReport; } } if (dialog.ShowOkCancel()) { var selectedReport = lv.SelectedItem as Info_Report_Stimul; if (selectedReport == null) { return; } if (Equals(selectedReport.Report_UN, currReportUn)) { return; } propertyValue.Value = new InArgument <string>(selectedReport.Report_UN); if (!string.IsNullOrEmpty(currReportUn) && av != null && !string.IsNullOrEmpty(av.Args)) { Manager.UI.ShowMessage("Изменилась бизнес модель. Объекты для построения отчета необходимо выбрать заново!"); av.Args = string.Empty; } } }
public override void ShowDialog(PropertyValue propertyValue, IInputElement commandSource) { ModelPropertyEntryToOwnerActivityConverter ownerActivityConverter = new ModelPropertyEntryToOwnerActivityConverter(); ModelItem activityItem = ownerActivityConverter.Convert(propertyValue.ParentProperty, typeof(ModelItem), false, null) as ModelItem; //var av = activityItem.GetCurrentValue() as SendBusinessObjectsReportToEmail; //if (av == null) return; string reportUn = string.Empty; var av = activityItem.GetCurrentValue(); if (av == null) { return; } var rv = av.GetType().GetProperty("Report_id").GetValue(av, null); if (rv != null) { var rvl = rv as InArgument <string>; if (rvl == null) { return; } var literal = rvl.Expression as Literal <string>; if (literal == null) { return; } reportUn = literal.Value; } //if (av.Report_id != null) //{ // var literal = av.Report_id.Expression as Literal<string>; // if (literal == null) return; // reportUn = literal.Value; //} if (string.IsNullOrEmpty(reportUn)) { Manager.UI.ShowMessage("Сначала необходимо выбрать отчет!"); return; } var fe = commandSource as FrameworkElement; if (fe != null) { _owner = fe.FindParent <IModule>(); } Manager.UI.RunAsync(report => { string businessObjectName = string.Empty; try { businessObjectName = ServiceFactory.StimulReportInvokeSync <string>("GetUsedBusinessObjectsNames", reportUn); } catch (Exception ex) { Manager.UI.ShowMessage(ex.Message); } return(businessObjectName); }, businessObjectName => { if (string.IsNullOrEmpty(businessObjectName)) { //Это отчет без бизнес объекта Manager.UI.RunAsync(args => ServiceFactory.StimulReportInvokeSync <TReportInfo>("LoadReport", reportUn) , response => { if (response == null) { return; } if (response.TreeMode == enumTreeMode.None && !response.IsShowChannelSelector) { //Аргументы не нужны propertyValue.Value = new MultiPsSelectedArgs().SerializeToString <MultiPsSelectedArgs>(); return; } string title; var selector = Manager.Modules.CreateModule(ModuleType.MultiPSSelector, out title, response.DateRangeMode, (enumTreeMode)response.TreeMode, response.IsShowChannelSelector); selector.Width = SystemParameters.PrimaryScreenWidth - 50; selector.Height = SystemParameters.PrimaryScreenHeight - 30; ShowMultiPsSelector(propertyValue, selector, title); }, null); } else { string title; var selector = Manager.Modules.CreateModule(ModuleType.MultiPSSelector, out title, businessObjectName); selector.Width = SystemParameters.PrimaryScreenWidth - 50; selector.Height = SystemParameters.PrimaryScreenHeight - 30; ShowMultiPsSelector(propertyValue, selector, title); } }, reportUn); }