void LoadTableColumns(System.Action continueWith = null) { if (!IsTableSelected || _isInitializing) { if (!_isInitializing) { ModelItemCollection.Clear(); } continueWith?.Invoke(); return; } var oldColumns = GetInputMappings().ToList(); ModelItemCollection.Clear(); var selectedDatabase = SelectedDatabase; var selectedTable = SelectedTable; // ReSharper disable ImplicitlyCapturedClosure _asyncWorker.Start(() => GetDatabaseTableColumns(selectedDatabase, selectedTable), columnList => // ReSharper restore ImplicitlyCapturedClosure { if (columnList.HasErrors) { Errors = new List <IActionableErrorInfo> { new ActionableErrorInfo(() => IsSelectedTableFocused = true) { ErrorType = ErrorType.Critical, Message = columnList.Errors } }; } else { Errors = null; } foreach (var mapping in columnList.Items.Select(column => new DataColumnMapping { OutputColumn = column })) { var mapping1 = mapping; var oldColumn = oldColumns.FirstOrDefault(c => c.OutputColumn.ColumnName == mapping1.OutputColumn.ColumnName); if (oldColumn?.InputColumn != null) { var inputcolumn = oldColumn.InputColumn; inputcolumn = inputcolumn.Replace("[", ""); inputcolumn = inputcolumn.Replace("]", ""); inputcolumn = inputcolumn.Replace(" ", ""); mapping.InputColumn = string.Format("[[{0}]]", inputcolumn); } if (string.IsNullOrEmpty(mapping.InputColumn)) { mapping.InputColumn = string.Format("[[{0}(*).{1}]]", selectedTable.TableName.Replace("[", "").Replace("]", "").Replace(" ", ""), mapping.OutputColumn.ColumnName.Replace("[", "").Replace("]", "").Replace(" ", "")); } ModelItemCollection.Add(mapping); } continueWith?.Invoke(); }); }
//Helper function used by other components if need to update import context item public static void AddImport(string importedNamespace, EditingContext editingContext) { //For types defined without any namespace, Type.Namespace is null instead of empty. We don't need to add any namespace to Import list in this case if (string.IsNullOrEmpty(importedNamespace)) { return; } Fx.Assert(editingContext != null, "EditingContext shouldn't be null."); ModelService modelService = editingContext.Services.GetService <ModelService>(); Fx.Assert(modelService != null, "EditingContext should contains ModelService."); ModelItemCollection importsCollection = modelService.Root.Properties[NamespaceListPropertyDescriptor.ImportCollectionPropertyName].Collection; NamespaceList namespaceList = importsCollection.GetCurrentValue() as NamespaceList; if (namespaceList.Lookup(importedNamespace) == -1) { importsCollection.Add(new NamespaceData { Namespace = importedNamespace }); } else { namespaceList.UpdateAssemblyInfo(importedNamespace); } }
private void AddDefaultArguments() { ModelTreeManager mtm = _workflowDesigner.Context.Services.GetService <ModelTreeManager>(); ModelItem ab = mtm.Root; ModelItemCollection argsAndProperties = ab.Properties["Properties"].Collection; argsAndProperties.Add(new DynamicActivityProperty { Name = "ArgFileSystemItemId", Type = typeof(InArgument <int>), }); argsAndProperties.Add(new DynamicActivityProperty { Name = "ArgSessionId", Type = typeof(InArgument <string>), }); }
//添加活动 public static ModelItem AddActivity(this ModelItem modelItem, object item, int index = -1) { if (!modelItem.CanAddItem(item)) { return(null); } ModelItem result = null; Activity value; if (modelItem.IsSequence() && (value = (item as Activity)) != null) { ModelItemCollection collection = modelItem.Properties["Activities"].Collection; result = ((index == -1) ? collection.Add(value) : collection.Insert(index, value)); } else if (modelItem.IsFlowchart()) { FlowNode flowNode = null; if (item != null) { FlowNode flowNode2; if ((flowNode2 = (item as FlowNode)) == null) { Activity activity; if ((activity = (item as Activity)) != null) { Activity action = activity; flowNode = new FlowStep { Action = action }; } } else { FlowNode flowNode3 = flowNode2; flowNode = flowNode3; } } if (flowNode != null) { ModelItemCollection collection2 = modelItem.Properties["Nodes"].Collection; result = ((index == -1) ? collection2.Add(flowNode) : collection2.Insert(index, flowNode)); } } else if (modelItem.IsStateMachine() && (item is State || item is FinalState)) { State state = (item as State) ?? new State { IsFinal = true, }; ModelItemCollection collection3 = modelItem.Properties["States"].Collection; result = ((index == -1) ? collection3.Add(state) : collection3.Insert(index, state)); } return(result); }
public static void AddCase(ModelProperty casesPropperties, object newKey, object newCase) { Type propertyType = casesPropperties.PropertyType; Fx.Assert(propertyType.IsGenericType && propertyType.GetGenericTypeDefinition() == typeof(IDictionary <,>), "Property type should be IDictonary<T, FlowNode>"); Type keyType = propertyType.GetGenericArguments()[0]; ModelItemCollection itemsCollection = casesPropperties.Value.Properties["ItemsCollection"].Collection; Type caseType = typeof(ModelItemKeyValuePair <,>).MakeGenericType(new Type[] { keyType, typeof(FlowNode) }); object mutableKVPair = Activator.CreateInstance(caseType, new object[] { newKey, newCase }); itemsCollection.Add(mutableKVPair); }
internal static void WrapperCollectionToModelItem(ObservableCollection <DynamicArgumentWrapperObject> wrappers, ModelItem data, bool isDictionary, Type underlyingArgumentType) { ModelItemCollection collection = GetArgumentCollection(data); using (ModelEditingScope change = collection.BeginEdit(SR.UpdateDynamicArgumentsDescription)) { if (isDictionary) { collection.Clear(); Type dictionaryEntryType = typeof(ModelItemKeyValuePair <,>).MakeGenericType(new Type[] { typeof(string), underlyingArgumentType }); foreach (DynamicArgumentWrapperObject wrapper in wrappers) { Argument argument = Argument.Create(wrapper.Type, wrapper.Direction); object mutableKVPair = Activator.CreateInstance(dictionaryEntryType, new object[] { wrapper.Name, argument }); ModelItem argumentKVPair = collection.Add(mutableKVPair); if (wrapper.Expression != null) { argumentKVPair.Properties["Value"].Value.Properties["Expression"].SetValue(wrapper.Expression.GetCurrentValue()); } } } else { collection.Clear(); foreach (DynamicArgumentWrapperObject wrapper in wrappers) { Argument argument = Argument.Create(wrapper.Type, wrapper.Direction); ModelItem argumentItem = collection.Add(argument); if (wrapper.Expression != null) { argumentItem.Properties["Expression"].SetValue(wrapper.Expression.GetCurrentValue()); } } } change.Complete(); } }
void CleanUpCollection(ModelItemCollection mic, ModelItem modelItem, int startIndex) { if (startIndex < mic.Count) { mic.RemoveAt(startIndex); } mic.Add(new DataMergeDTO(string.Empty, "None", string.Empty, startIndex + 1, " ", "Left To Right")); var modelProperty = modelItem.Properties["DisplayName"]; if (modelProperty != null) { modelProperty.SetValue(CreateDisplayName(modelItem, startIndex + 1)); } }
void CleanUpCollection(ModelItemCollection mic, ModelItem modelItem, int startIndex) { if (startIndex < mic.Count) { mic.RemoveAt(startIndex); } mic.Add(new BaseConvertTO(string.Empty, "Text", "Base 64", string.Empty, startIndex + 1)); var modelProperty = modelItem.Properties["DisplayName"]; if (modelProperty != null) { modelProperty.SetValue(CreateDisplayName(modelItem, startIndex + 1)); } }
// implement execute method public override int Execute(params string[] parameters) { // current document Document doc = Application.ActiveDocument; // model items collection-1 ModelItemCollection itemCollection = new ModelItemCollection(); // get current selected items ModelItemCollection selectionItems = doc.CurrentSelection.SelectedItems; // get appended models DocumentModels models = doc.Models; // display message //string message = ""; // each model foreach (Model model in models) { // collect all items from the mode1 // add to model item collection-1 itemCollection.AddRange(ItemsFromRoot(model)); } // model item collection-2 ModelItemCollection itemsToColor = new ModelItemCollection(); // each item from model item collection-1 foreach (ModelItem item1 in itemCollection) { // get item1 bounding box BoundingBox3D box1 = item1.BoundingBox(true); // each item from the current selected items foreach (ModelItem item2 in selectionItems) { // get item2 bounding box BoundingBox3D box2 = item2.BoundingBox(true); // check intersection of box1 vs box2 if (box1.Intersects(box2)) { //message += item1.DisplayName + "Intersects " + item2.DisplayName + "\n"; // item add to model item collection-2 itemsToColor.Add(item1); } } } // change the color of model item collection-2 items doc.Models.OverridePermanentColor(itemsToColor, Color.Green); //wf.MessageBox.Show(message); return(0); }
private void CleanUpCollection(ModelItemCollection mic, ModelItem modelItem, int startIndex) { if (startIndex < mic.Count) { mic.RemoveAt(startIndex); } mic.Add(new DataSplitDTO(string.Empty, "Chars", string.Empty, startIndex + 1)); var modelProperty = modelItem.Properties["DisplayName"]; if (modelProperty != null) { modelProperty.SetValue(CreateDisplayName(modelItem, startIndex + 1)); } }
private void CleanUpCollection(ModelItemCollection mic, ModelItem modelItem, int startIndex) { if (startIndex < mic.Count) { mic.RemoveAt(startIndex); } mic.Add(new GatherSystemInformationTO(enTypeOfSystemInformationToGather.FullDateTime, string.Empty, startIndex + 1)); var modelProperty = modelItem.Properties["DisplayName"]; if (modelProperty != null) { modelProperty.SetValue(CreateDisplayName(modelItem, startIndex + 1)); } }
void getParts() { Document doc = Autodesk.Navisworks.Api.Application.ActiveDocument; parts = new ModelItemCollection(); foreach (ModelItem item in doc.Models.RootItemDescendants) { textBox1.Update(); if (item.Children.Count() == 0 && item.Parent != null && !parts.Contains(item)) { parts.Add(item.Parent); } } button2.Text = "Upload " + parts.Count.ToString() + " Parts to Database"; }
private void CicleThroughChildren(ModelItem modelItem) { Autodesk.Navisworks.Api.Application.ActiveDocument.Models.SetHidden(modelItem.Children, true); foreach (ModelItem modelItemChild in modelItem.Children) { //SelectionSet oSet = modelItemChild as SelectionSet; //LcOpSelectionSetsElement.MakeVisible(oDoc.State, oSet); ModelItemCollection hidden = new ModelItemCollection(); hidden.Add(modelItemChild); oDoc.Models.SetHidden(hidden, false); ExportFbx(modelItemChild.DisplayName); oDoc.Models.SetHidden(hidden, true); } }
private void FillArguments() { string propertyName = PropertyReferenceUtilities.GetPropertyReference(this.ModelItem.GetCurrentValue(), DelegatePropertyName); if (string.IsNullOrEmpty(propertyName)) { return; } ModelTreeManager manager = this.Context.Services.GetService <ModelTreeManager>(); DynamicActivityProperty property = DynamicActivityPropertyUtilities.Find(manager.Root.Properties["Properties"].Collection, propertyName); if (property == null || !property.Type.IsSubclassOf(typeof(ActivityDelegate))) { return; } ActivityDelegateMetadata metadata = ActivityDelegateUtilities.GetMetadata(property.Type); ModelItemCollection collection = this.ModelItem.Properties[DelegateArgumentsPropertyName].Value.Properties["ItemsCollection"].Collection; Type underlyingArgumentType = this.ModelItem.Properties[DelegateArgumentsPropertyName].Value.GetCurrentValue().GetType().GetGenericArguments()[1]; if (!typeof(Argument).IsAssignableFrom(underlyingArgumentType)) { return; } if (collection.Count == 0) { using (ModelEditingScope change = collection.BeginEdit(SR.FillDelegateArguments)) { Type dictionaryEntryType = typeof(ModelItemKeyValuePair <,>).MakeGenericType(new Type[] { typeof(string), underlyingArgumentType }); foreach (ActivityDelegateArgumentMetadata arg in metadata) { Argument argument = Argument.Create(arg.Type, arg.Direction == ActivityDelegateArgumentDirection.In ? ArgumentDirection.In : ArgumentDirection.Out); object mutableKVPair = Activator.CreateInstance(dictionaryEntryType, new object[] { arg.Name, argument }); ModelItem argumentKVPair = collection.Add(mutableKVPair); } change.Complete(); } } }
private void AddURL(ModelItem modelItem, string[] urls, string[] titleUrls) { ComApi.InwOpState10 state; state = ComApiBridge.ComApiBridge.State; // create the hyperlink collection ComApi.InwURLOverride oMyURLOoverride = (ComApi.InwURLOverride)state.ObjectFactory(ComApi.nwEObjectType.eObjectType_nwURLOverride, null, null); // get current selected items ModelItemCollection modelItemCollectionIn = new ModelItemCollection(); modelItemCollectionIn.Add(modelItem); // add the new hyperlink to the hyperlink collection ComApi.InwURLColl oURLColl = oMyURLOoverride.URLs(); for (int i = 0; i < urls.Count(); i++) { // create one hyperlink ComApi.InwURL2 oMyURL = (ComApi.InwURL2)state.ObjectFactory(ComApi.nwEObjectType.eObjectType_nwURL, null, null); // create Hyperlink oMyURL.SetCategory("Hyperlink", "LcOaURLCategoryHyperlink"); // Attachment Point of the hyperlink ComApi.InwLPos3f oNewP = (ComApi.InwLPos3f)state.ObjectFactory(ComApi.nwEObjectType.eObjectType_nwLPos3f, null, null); oNewP.data1 = modelItemCollectionIn.BoundingBox().Center.X; oNewP.data2 = modelItemCollectionIn.BoundingBox().Center.Y; oNewP.data3 = modelItemCollectionIn.BoundingBox().Center.Z; oMyURL.AttachmentPoints().Add(oNewP); // name of the hyperlink oMyURL.name = titleUrls[i]; // site of the hyperlink oMyURL.URL = urls[i]; oURLColl.Add(oMyURL); } //convert to InwOpSelection of COM API ComApi.InwOpSelection comSelectionOut = ComApiBridge.ComApiBridge.ToInwOpSelection(modelItemCollectionIn); // set the hyplerlink of the model items state.SetOverrideURL(comSelectionOut, oMyURLOoverride); // enable to the hyperlinks visible state.URLsEnabled = true; modelItemCollectionIn.Remove(modelItem); }
void AddNewCase(object newKey) { Type caseType = typeof(ModelItemKeyValuePair <,>).MakeGenericType(new Type[] { this.CaseType, typeof(Activity) }); object mutableKVPair = Activator.CreateInstance(caseType, new object[] { newKey, null }); ModelProperty casesProp = this.ModelItem.Properties["Cases"]; Fx.Assert(casesProp != null, "Property Cases is not available"); ModelItem cases = casesProp.Value; Fx.Assert(cases != null, "Cannot get ModelItem from property Cases"); ModelProperty itemsCollectionProp = cases.Properties["ItemsCollection"]; Fx.Assert(itemsCollectionProp != null, "Cannot get property ItemsCollection from Cases"); ModelItemCollection itemsCollection = itemsCollectionProp.Collection; Fx.Assert(itemsCollection != null, "Cannot get ModelItemCollection from property ItemsCollection"); itemsCollection.Add(mutableKVPair); this.caseKeyBox.ResetText(); }
protected Variable <T> AddVariable <T>(ModelItemCollection variables, Variable <T> variable) { // Get variable. ModelItem modelItem = variables.FirstOrDefault( m => ((Variable)m.GetCurrentValue()).Name == variable.Name); // Add into variables collection if it does not exist. if (modelItem == null) { variables.Add(variable); } // Assign it if it was found. else { variable = modelItem.GetCurrentValue() as Variable <T>; } return(variable); }
/// <summary> /// ВЫЗЫВАЕТСЯ НАЖАТИЕМ КНОПКИ В ОКНЕ /// Выбрать в документе все объекты геометрии, которые уже добавлены в структуру /// </summary> public void SelectAdded() { //ModelItemCollection toSelect = new ModelItemCollection(); //foreach (KeyValuePair<string, ModelItem> kvp in allItemsLookup) //{ // if (!AddedGeometryItemsLookUp.ContainsKey(kvp.Key)) // { // toSelect.Add(kvp.Value); // } //} //doc.CurrentSelection.CopyFrom(toSelect); ModelItemCollection toSelect = new ModelItemCollection(); foreach (XML.St.Object obj in AddedGeometryItemsLookUp.Values) { toSelect.Add(obj.NavisItem); } doc.CurrentSelection.CopyFrom(toSelect); }
void AddDto(int indexNumber, string initializeWith = "") { // // DO NOT invoke Renumber() from here - this method is called MANY times when invoking AddToCollection()!! // var dto = CreateDto(indexNumber, initializeWith); AttachEvents(dto); var idx = indexNumber - 1; if (idx >= ModelItemCollection.Count) { ModelItem modelItem = ModelItemUtils.CreateModelItem(dto); ModelItemCollection.Add(modelItem); } else { ModelItemCollection.Insert(idx, dto); } }
public Argument GetArgument(string Name, bool add, Type type) { ModelService modelService = wfDesigner.Context.Services.GetService <ModelService>(); ModelItemCollection args = modelService.Root.Properties["Properties"].Collection; foreach (var _v in args) { var nameprop = (string)_v.Properties["Name"].ComputedValue; if (Name == nameprop) { return(_v.GetCurrentValue() as Argument); } } if (add) { Argument myArg = Argument.Create(type, ArgumentDirection.InOut); args.Add(myArg); return(myArg); } return(null); }
internal void CommitEdit() { if ((this.Activity != null) && (this.Activity.ItemType == typeof(InitializeCorrelation))) { using (ModelEditingScope scope = this.Activity.BeginEdit((string)this.FindResource("editCorrelationDataDescription"))) { this.Activity.Properties[InitializeCorrelationDesigner.CorrelationPropertyName].SetValue(this.CorrelationHandle); ModelItemCollection correlationDataCollection = this.Activity.Properties[InitializeCorrelationDesigner.CorrelationDataPropertyName].Dictionary.Properties["ItemsCollection"].Collection; correlationDataCollection.Clear(); foreach (CorrelationDataWrapper wrapper in this.CorrelationInitializeData) { correlationDataCollection.Add(new ModelItemKeyValuePair <string, InArgument <string> > { Key = wrapper.Key, Value = wrapper.Value != null ? wrapper.Value.GetCurrentValue() as InArgument <string> : null }); } scope.Complete(); } } }
private void AddToCollection(IEnumerable <string> listToAdd, ModelItem modelItem) { var modelProperty = modelItem.Properties["SystemInformationCollection"]; if (modelProperty != null) { ModelItemCollection mic = modelProperty.Collection; if (mic != null) { int startIndex = 0; const enTypeOfSystemInformationToGather EnTypeOfSystemInformation = enTypeOfSystemInformationToGather.FullDateTime; mic.Clear(); foreach (string s in listToAdd) { mic.Add(new GatherSystemInformationTO(EnTypeOfSystemInformation, s, startIndex + 1)); startIndex++; } CleanUpCollection(mic, modelItem, startIndex); } } }
private void AddToCollection(IEnumerable <string> listToAdd, ModelItem modelItem) { var modelProperty = modelItem.Properties["ConvertCollection"]; if (modelProperty != null) { ModelItemCollection mic = modelProperty.Collection; if (mic != null) { int startIndex = 0; string firstRowConvertType = ConvertCollection[0].ConvertType; mic.Clear(); foreach (string s in listToAdd) { mic.Add(new CaseConvertTO(s, firstRowConvertType, s, startIndex + 1)); startIndex++; } CleanUpCollection(mic, modelItem, startIndex); } } }
private void BUTFocus_Click(object sender, EventArgs e) { Document Doc = Autodesk.Navisworks.Api.Application.ActiveDocument; List <string> listId = new List <string>(); if (DGVTotal.SelectedRows.Count == 0) { MessageBox.Show("未选中行!"); return; } for (int i = 0; i < DGVTotal.SelectedRows.Count; i++) { listId.Add(DGVTotal.SelectedRows[i].Cells[0].Value.ToString()); } ModelItemCollection itemsCol = new ModelItemCollection(); //元素ID是int32类型,所以Displaystring找不到 for (int i = 0; i < DGVTotal.SelectedRows.Count; i++) { Search search = new Search(); search.Selection.SelectAll(); search.SearchConditions.Add(SearchCondition.HasPropertyByDisplayName("元素", "Id").EqualValue(VariantData.FromInt32(Int32.Parse(listId[i])))); ModelItemCollection items = search.FindAll(Doc, true); if (items.First != null)//不为空才添加 { itemsCol.Add(items.First); } } Doc.CurrentSelection.Clear(); Doc.CurrentSelection.CopyFrom(itemsCol); if (itemsCol.Count > 0) { MessageBox.Show("已在视图中选中该元素!", "提示"); } }
void pinAdorner_MouseUp(object sender, MouseButtonEventArgs e) { var pinAdorner = sender as PinAdorner; if (pinAdorner.HitPin != null) { LinkableControl targetObject = pinAdorner.HitLinkableControl; LinkPin lp1 = pinAdorner.SourcePin; LinkPin lp2 = pinAdorner.HitPin; ConnectInfo info1 = lp1.GetInfo(); ConnectInfo info2 = lp2.GetInfo(); LinkLine line = new LinkLine(info1, info2); //Panel.SetZIndex(line, designCanvas.Children.Count); Binding bi1 = new Binding(omap[info1.Orient]); bi1.ElementName = designObject.Name; line.SetBinding(LinkLine.OriginInfoProperty, bi1); Binding bi2 = new Binding(omap[info2.Orient]); bi2.ElementName = targetObject.Name; line.SetBinding(LinkLine.TargetInfoProperty, bi2); var CanvasModelItem = AdornerProperties.GetModel(adorner).Parent; ModelItemCollection myControls = CanvasModelItem.Properties["Children"].Collection; ModelItem myLinkLine = myControls.Add(line); } if (pinAdorner.HitLinkableControl != null) { pinAdorner.HitLinkableControl.IsLinkDragOver = false; } hitPin = null; if (adorner.IsMouseCaptured) { adorner.ReleaseMouseCapture(); } _panel.Children.Remove(pinAdorner); }
private void AddToCollection(IEnumerable <string> listToAdd, ModelItem modelItem) { var modelProperty = modelItem.Properties["ResultsCollection"]; if (modelProperty != null) { ModelItemCollection mic = modelProperty.Collection; if (mic != null) { int startIndex = 0; string firstRowSplitType = ResultsCollection[0].SplitType; string firstRowAt = ResultsCollection[0].At; mic.Clear(); foreach (string s in listToAdd) { mic.Add(new DataSplitDTO(s, firstRowSplitType, firstRowAt, startIndex + 1)); startIndex++; } CleanUpCollection(mic, modelItem, startIndex); } } }
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 DynamicActivityProperty GetArgumentOf <T>(string Name, bool add) { ModelService modelService = wfDesigner.Context.Services.GetService <ModelService>(); ModelItemCollection args = modelService.Root.Properties["Properties"].Collection; foreach (var _v in args) { var nameprop = (string)_v.Properties["Name"].ComputedValue; if (Name == nameprop) { return(_v.GetCurrentValue() as DynamicActivityProperty); } } if (add) { args.Add(new DynamicActivityProperty { Name = Name, Type = typeof(OutArgument <T>), Value = new OutArgument <T>() // new OutArgument<T>(myPara) // uses myPara.ToString() for default expression }); } return(null); }
private void AddToCollection(IEnumerable <string> listToAdd, ModelItem modelItem) { var modelProperty = modelItem.Properties["MergeCollection"]; if (modelProperty != null) { ModelItemCollection mic = modelProperty.Collection; if (mic != null) { int startIndex = 0; string firstRowMergeType = MergeCollection[0].MergeType; string firstRowPadding = MergeCollection[0].Padding; string firstRowAlignment = MergeCollection[0].Alignment; mic.Clear(); foreach (string s in listToAdd) { mic.Add(new DataMergeDTO(s, firstRowMergeType, string.Empty, startIndex + 1, firstRowPadding, firstRowAlignment)); startIndex++; } CleanUpCollection(mic, modelItem, startIndex); } } }
static SendReply CreateSendReply(ModelItem target, object context) { SendReply reply = null; ModelItem receive = (ModelItem)context; if (null != receive) { Receive receiveInstance = (Receive)receive.GetCurrentValue(); string name = null; //if no correlation is set - create one if (null == receiveInstance.CorrelatesWith) { Variable handleVariable = null; //first, look for nearest variable scope ModelItemCollection variableScope = VariableHelper.FindRootVariableScope(receive).GetVariableCollection(); if (null != variableScope) { ModelItemCollection correlations = receive.Properties["CorrelationInitializers"].Collection; bool hasRequestReplyHandle = false; foreach (ModelItem item in correlations) { if (item.ItemType.IsAssignableFrom(typeof(RequestReplyCorrelationInitializer))) { hasRequestReplyHandle = true; break; } } if (!hasRequestReplyHandle) { //create unique variable name name = variableScope.CreateUniqueVariableName("__handle", 1); //create variable handleVariable = Variable.Create(name, typeof(CorrelationHandle), VariableModifiers.None); //add it to the scope variableScope.Add(handleVariable); //setup correlation ImportDesigner.AddImport(CorrelationHandleTypeNamespace, receive.GetEditingContext()); VariableValue <CorrelationHandle> expression = new VariableValue <CorrelationHandle> { Variable = handleVariable }; InArgument <CorrelationHandle> handle = new InArgument <CorrelationHandle>(expression); correlations.Add(new RequestReplyCorrelationInitializer { CorrelationHandle = handle }); } } } reply = new SendReply() { DisplayName = string.Format(CultureInfo.CurrentUICulture, "SendReplyTo{0}", receive.Properties["DisplayName"].ComputedValue), Request = (Receive)receive.GetCurrentValue(), }; } else { MessageBox.Show( (string)StringResourceDictionary.Instance["receiveActivityCreateReplyErrorLabel"] ?? "Source 'Reply' element not found!", (string)StringResourceDictionary.Instance["MessagingActivityTitle"] ?? "Send", MessageBoxButton.OK, MessageBoxImage.Error); } return(reply); }