// <summary> // Gets the underlying ModelItemCollection // </summary> // <returns>The underlying ModelItemCollection</returns> internal ModelItemCollection GetRawCollection() { ModelPropertyEntry parentAsEntry = ParentValue.ParentProperty as ModelPropertyEntry; if (parentAsEntry != null) { return(parentAsEntry.FirstModelProperty.Collection); } ModelPropertyIndexer parentAsIndexer = ParentValue.ParentProperty as ModelPropertyIndexer; if (parentAsIndexer != null) { ModelItemCollection modelItemCollection = parentAsIndexer.ModelItem as ModelItemCollection; // If the parent is an indexer, that means we are a collection within another collection // and the ModelItem of the indexer is really a ModelItemCollection. Fx.Assert(modelItemCollection != null, "modelItemCollection should not be null"); return(modelItemCollection); } Debug.Fail("A new class was introduced that derives from PropertyEntry. Need to update ModelPropertyValueCollection code as well."); return(null); }
private void ExportBySelSets(SavedItem item, Document doc) { if (item is FolderItem) { //рекурсивный вызов для каждого вложенного FolderItem folder = item as FolderItem; foreach (SavedItem nestedItem in folder.Children) { ExportBySelSets(nestedItem, doc); } } else if (item is SelectionSet) { SelectionSet selectionSet = item as SelectionSet; ModelItemCollection itemsToExport = selectionSet.GetSelectedItems(); if (itemsToExport.DescendantsAndSelf.Count() > 0) { ModelItemCollection itemsToHide = new ModelItemCollection(itemsToExport); itemsToHide.Invert(doc); doc.Models.SetHidden(itemsToHide, true); doc.Models.SetHidden(itemsToExport, false); FBXExport.FBXFileName = selectionSet.DisplayName + ".fbx"; S1NF0_RibbonPanel.ExecuteAddInPlugin("FBXExport." + DEVELOPER_ID); doc.Models.SetHidden(itemsToHide, false); } } }
// <summary> // Basic ctor // </summary> // <param name="parentValue">Parent PropertyValue</param> public ModelPropertyValueCollection(ModelPropertyValue parentValue) : base(parentValue) { if (parentValue == null) { throw FxTrace.Exception.ArgumentNull("parentValue"); } // Wrap each existing item in the collection in ModelPropertyEntryIndexer ModelItemCollection collection = this.GetRawCollection(); if (collection != null && collection.Count > 0) { _values = new List <ModelPropertyIndexer>(); int i = 0; foreach (ModelItem item in collection) { _values.Add(CreateModelPropertyIndexer(item, i++)); } } // Hook into the collection changed events if (collection != null) { collection.CollectionChanged += new NotifyCollectionChangedEventHandler(OnUnderlyingCollectionChanged); } }
public static SearchAndItems SAIsearch(SavedItem item) { ModelItemCollection mod_col = ((SelectionSet)item).GetSelectedItems(); SearchAndItems SAI = new SearchAndItems(); List <Guid> output_guids = new List <Guid>(); HashSet <string> unic_cats = new HashSet <string>(); string cat = null; if (mod_col != null) { foreach (ModelItem mditem in mod_col) { Guid item_guid = FindGuid(mditem); if (item_guid.ToString() != "00000000-0000-0000-0000-000000000000") { PropertyCategoryCollection mitem_property = mditem.GetUserFilteredPropertyCategories(); //свойства объекта для получения его категории, и поиска в категории окон и дверей, следующий номер за количеством папок в Q DataProperty mitem_dataprop = mitem_property.FindPropertyByName("LcRevitData_Element", "LcRevitPropertyElementCategory"); // if (mitem_dataprop != null) { unic_cats.Add(mitem_dataprop.Value.ToDisplayString()); } } output_guids.Add(item_guid); } if (unic_cats.Count == 1 && (unic_cats.Contains("Окна") || unic_cats.Contains("Двери"))) { cat = "ОкнаДвери"; } //#endregion SAI.WriteData(item.DisplayName, output_guids, cat); } return(SAI); }
public void RowToIndexConverter_Convert_DoesntFindValue_ReturnsMinusOne() { var converter = new RowToIndexConverter(); var activityDtos = new List <ActivityDTO> { new ActivityDTO("name", "value", 0), new ActivityDTO("name1", "value1", 1), new ActivityDTO("name2", "value2", 2) }; DsfMultiAssignActivity multiAssign = new DsfMultiAssignActivity(); multiAssign.FieldsCollection = activityDtos; ModelItem modelItemThatdoesntExist = ModelItemUtils.CreateModelItem(new ActivityDTO("thing", "stuff", 8)); dynamic modelItem = ModelItemUtils.CreateModelItem(multiAssign); ModelItemCollection collection = modelItem.FieldsCollection as ModelItemCollection; //------------Execute Test--------------------------- if (collection != null) { var result = converter.Convert(modelItemThatdoesntExist, typeof(int), null, CultureInfo.CurrentCulture); //------------Assert Results------------------------- Assert.AreEqual(-1, result); } else { Assert.Fail(); } }
/// <summary> /// Only one TabItem should have DesignTimeIsSelectedProperty set to true at a time. /// DesignTimeSelectedIndexProperty of TabControl should match with that of active tab. /// </summary> /// <param name="item">The ModelItem representing a TabItem.</param> private static void UpdateIsSelectedForOtherTabs(ModelItem item) { // item.Parent is Tabcontrol if (item.Parent != null && item.Parent.IsItemOfType(MyPlatformTypes.TabControl.TypeId)) { if (item.Parent.Content != null) { ModelItemCollection tabItemCollection = item.Parent.Content.Collection; if (tabItemCollection != null && tabItemCollection.Count > 0) { foreach (ModelItem tabItem in tabItemCollection) { if (tabItem != item) { // set designer property for other tabItem in TabControl to false. tabItem.SetDesignerProperty(DesignTimeIsSelectedProperty, false); } else { // This tabItem has been activated, update selectedIndex for Tabcontrol tabItem.Parent.SetDesignerProperty( TabControlDesignModeValueProvider.DesignTimeSelectedIndexProperty, tabItemCollection.IndexOf(tabItem)); } } } } } }
private void ButFocus_Click(object sender, EventArgs e)//在NW中选择当前选择记录的 { Document Doc = Autodesk.Navisworks.Api.Application.ActiveDocument; TabPage curTabPage = this.TCL1OfQF.SelectedTab;//获取当前选择的tab页面 string strId = ""; foreach (Control control in curTabPage.Controls) //遍历控件 { if (control is DataGridView) //如果是datagridview,则在视图中选择元素 { DataGridView dgv = (DataGridView)control; if (dgv.SelectedRows.Count == 0) { MessageBox.Show("未选中行!"); return; } for (int i = 0; i < dgv.SelectedRows.Count; i++) { strId = dgv.SelectedRows[i].Cells[0].Value.ToString(); } Search search = new Search(); search.Selection.SelectAll(); //元素ID是int32类型,所以Displaystring找不到 search.SearchConditions.Add(SearchCondition.HasPropertyByDisplayName("元素", "Id").EqualValue(VariantData.FromInt32(Int32.Parse(strId)))); ModelItemCollection items = search.FindAll(Doc, true); Doc.CurrentSelection.Clear(); Doc.CurrentSelection.CopyFrom(items); if (items.Count > 0) { MessageBox.Show("已在视图中选中该元素!", "提示"); } } } }
private void InsertToCollection(IEnumerable <string> listToAdd, ModelItem modelItem) { var modelProperty = modelItem.Properties["SystemInformationCollection"]; if (modelProperty != null) { ModelItemCollection mic = modelProperty.Collection; if (mic != null) { List <GatherSystemInformationTO> listOfValidRows = SystemInformationCollection.Where(c => !c.CanRemove()).ToList(); if (listOfValidRows.Count > 0) { GatherSystemInformationTO gatherSystemInformationTo = SystemInformationCollection.Last(c => !c.CanRemove()); int startIndex = SystemInformationCollection.IndexOf(gatherSystemInformationTo) + 1; foreach (string s in listToAdd) { mic.Insert(startIndex, new GatherSystemInformationTO(SystemInformationCollection[startIndex - 1].EnTypeOfSystemInformation, s, startIndex + 1)); startIndex++; } CleanUpCollection(mic, modelItem, startIndex); } else { AddToCollection(listToAdd, modelItem); } } } }
private void listView1_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { ListViewItem item = listView1.GetItemAt(e.X, e.Y); if (item != null) { if (e.Location.X >= item.Bounds.X - (item.ListView.SmallImageList.ImageSize.Width + 5) && e.Location.X <= item.Bounds.Right + 1) { ((mainForm)this.DockPanel.Parent).timeSlider1_Scroll(sender, e); SavedItemCollection si = doc.SelectionSets.Value; SelectionSource ss = doc.SelectionSets.CreateSelectionSource(si[item.Index]); Search s = new Search(); s.Selection.SelectionSources.Add(ss); modelSelection = new ModelItemCollection(s.Selection.GetSelectedItems(doc)); System.Drawing.Color c = System.Drawing.Color.Blue; doc.Models.OverridePermanentColor(modelSelection, new Autodesk.Navisworks.Api.Color(c.R / 255, c.G / 255, c.B / 255)); i = modelSelection[0].PropertyCategories.ElementAt(modelSelection[0].PropertyCategories.Count() - 1).Properties[4].Value.ToInt32(); j = -1; contextMenuStrip1.Items.Clear(); contextMenuStrip1.Items.Add(changePropertiesToolStripMenuItem); contextMenuStrip1.Size = new Size(164, 26); contextMenuStrip1.Show(msTreeView1, e.Location); } } } }
private object createSearchSet(object name, object category, object property, object value) { //https://adndevblog.typepad.com/aec/2012/08/add-search-selectionset-in-net.html Document doc = Autodesk.Navisworks.Api.Application.ActiveDocument; //Create a new search object Search s = new Search(); SearchCondition sc = SearchCondition.HasPropertyByDisplayName(category.ToString(), property.ToString()); s.SearchConditions.Add(sc.EqualValue(VariantData.FromDisplayString(value.ToString()))); //Set the selection which we wish to search s.Selection.SelectAll(); s.Locations = SearchLocations.DescendantsAndSelf; //halt searching below ModelItems which match this s.PruneBelowMatch = true; //get the resulting collection by applying this search ModelItemCollection searchResults = s.FindAll(Autodesk.Navisworks.Api.Application.ActiveDocument, false); SelectionSet selectionSet = new SelectionSet(); selectionSet.DisplayName = name.ToString(); selectionSet.CopyFrom(s); Autodesk.Navisworks.Api.Application.ActiveDocument.SelectionSets.InsertCopy(0, selectionSet); var ss = Autodesk.Navisworks.Api.Application.ActiveDocument.SelectionSets.ToSavedItemCollection(); return(ss); }
protected void RemoveAt(int indexNumber, INotifyPropertyChanged notify) { notify.PropertyChanged -= OnDtoPropertyChanged; var idx = indexNumber - 1; ModelItemCollection.RemoveAt(idx); }
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(); }); }
private void InsertToCollection(IEnumerable <string> listToAdd, ModelItem modelItem) { var modelProperty = modelItem.Properties["ConvertCollection"]; if (modelProperty != null) { ModelItemCollection mic = modelProperty.Collection; if (mic != null) { List <ICaseConvertTO> listOfValidRows = ConvertCollection.Where(c => !c.CanRemove()).ToList(); if (listOfValidRows.Count > 0) { int startIndex = ConvertCollection.IndexOf(listOfValidRows.Last()) + 1; foreach (string s in listToAdd) { mic.Insert(startIndex, new CaseConvertTO(s, ConvertCollection[startIndex - 1].ConvertType, s, startIndex + 1)); startIndex++; } CleanUpCollection(mic, modelItem, startIndex); } else { AddToCollection(listToAdd, modelItem); } } } }
public void RowToIndexConverter_Convert_FindsValue_ReturnsIndex() { //------------Setup for test-------------------------- var converter = new RowToIndexConverter(); var activityDtos = new List <ActivityDTO> { new ActivityDTO("name", "value", 0), new ActivityDTO("name1", "value1", 1), new ActivityDTO("name2", "value2", 2) }; DsfMultiAssignActivity multiAssign = new DsfMultiAssignActivity(); multiAssign.FieldsCollection = activityDtos; dynamic modelItem = ModelItemUtils.CreateModelItem(multiAssign); ModelItemCollection collection = modelItem.FieldsCollection as ModelItemCollection; //------------Execute Test--------------------------- if (collection != null) { var result = converter.Convert(collection[1], typeof(int), null, CultureInfo.CurrentCulture); //------------Assert Results------------------------- Assert.AreEqual(2, result); } else { Assert.Fail(); } }
void OnContextChanged() { this.targetFramework = WorkflowDesigner.GetTargetFramework(this.Context); AttachedPropertiesService attachedPropertyService = this.Context.Services.GetService <AttachedPropertiesService>(); Fx.Assert(attachedPropertyService != null, "AttachedPropertiesService shouldn't be null in EditingContext."); attachedPropertyService.AddProperty(CreateAttachedPropertyForNamespace <string>(ErrorMessagePropertyName)); attachedPropertyService.AddProperty(CreateAttachedPropertyForNamespace <bool>(IsInvalidPropertyName)); //clear any defaults because it's meant to be set by host and not serialized to XAML VisualBasicSettings.Default.ImportReferences.Clear(); ModelService modelService = this.Context.Services.GetService <ModelService>(); Fx.Assert(modelService != null, "ModelService shouldn't be null in EditingContext."); Fx.Assert(modelService.Root != null, "model must have a root"); this.importsModelItem = modelService.Root.Properties[NamespaceListPropertyDescriptor.ImportCollectionPropertyName].Collection; Fx.Assert(this.importsModelItem != null, "root must have imports"); this.importsModelItem.CollectionChanged += this.OnImportsModelItemCollectionChanged; this.importedNamespacesItem = this.Context.Items.GetValue <ImportedNamespaceContextItem>(); this.importedNamespacesItem.EnsureInitialized(this.Context); if (this.availableNamespaces == null) { //change to available namespace should not be a model change so we access the dictionary directly this.availableNamespaces = this.importsModelItem.Properties[NamespaceListPropertyDescriptor.AvailableNamespacesPropertyName].ComputedValue as Dictionary <string, List <string> >; Fx.Assert(this.availableNamespaces != null, "Available namespace dictionary is not in right format"); } RefreshNamespaces(); }
//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); } }
public bool DoDrop(IDataObject dataObject) { var formats = dataObject.GetFormats(); if (!formats.Any()) { return(false); } dynamic mi = ModelItem; ModelItemCollection activitiesCollection = mi.Activities; var modelItemString = formats.FirstOrDefault(s => s.IndexOf("ModelItemsFormat", StringComparison.Ordinal) >= 0); if (!String.IsNullOrEmpty(modelItemString)) { var objectData = dataObject.GetData(modelItemString); var data = objectData as List <ModelItem>; if (data != null && data.Count >= 1) { foreach (var item in data) { activitiesCollection.Insert(activitiesCollection.Count, item); } _addedFromDesignSurface = true; return(true); } } return(SetModelItemForServiceTypes(dataObject)); }
internal override void LoadChildren() { if (this.PerfEventProvider != null) { this.PerfEventProvider.DesignerTreeViewLoadChildrenStart(); } base.LoadChildren(); if (this.Value.IsCollection) { ModelItemCollection mc = this.Value.Value as ModelItemCollection; TreeViewItemViewModel.AddModelItemCollection(this, mc, this.Value); } else if (this.Value.IsDictionary) { ModelItemDictionary dictionary = this.Value.Dictionary; TreeViewItemViewModel.AddModelItemDictionary(this, dictionary, this.Value); } else if (this.Value.Value != null) { TreeViewItemViewModel.AddChild(this, this.Value.Value, this.Value.Value, this.DuplicatedNodeVisible, string.Empty, this.Value); } if (this.PerfEventProvider != null) { this.PerfEventProvider.DesignerTreeViewLoadChildrenEnd(); } }
private void InsertToCollection(IEnumerable <string> listToAdd, ModelItem modelItem) { var modelProperty = modelItem.Properties["ResultsCollection"]; if (modelProperty != null) { ModelItemCollection mic = modelProperty.Collection; if (mic != null) { List <DataSplitDTO> listOfValidRows = ResultsCollection.Where(c => !c.CanRemove()).ToList(); if (listOfValidRows.Count > 0) { DataSplitDTO dataSplitDto = ResultsCollection.Last(c => !c.CanRemove()); int startIndex = ResultsCollection.IndexOf(dataSplitDto) + 1; foreach (string s in listToAdd) { mic.Insert(startIndex, new DataSplitDTO(s, ResultsCollection[startIndex - 1].SplitType, ResultsCollection[startIndex - 1].At, startIndex + 1)); startIndex++; } CleanUpCollection(mic, modelItem, startIndex); } else { AddToCollection(listToAdd, modelItem); } } } }
private void StructureFilling(XML.St.Object parent, SavedItem item, StructureDataStorage dataStorage, Document doc) { if (item is FolderItem) { FolderItem folder = item as FolderItem; XML.St.Object container = dataStorage.CreateNewContainerObject(parent, folder.DisplayName); foreach (SavedItem nestedItem in folder.Children) { StructureFilling(container, nestedItem, dataStorage, doc); } } else if (item is SelectionSet) { SelectionSet selectionSet = item as SelectionSet; XML.St.Object container = dataStorage.CreateNewContainerObject(parent, selectionSet.DisplayName); ModelItemCollection itemsInSelection = selectionSet.GetSelectedItems(); Search searchForAllIDs = new Search(); searchForAllIDs.Selection.CopyFrom(itemsInSelection); searchForAllIDs.Locations = SearchLocations.DescendantsAndSelf; StructureDataStorage.ConfigureSearchForAllGeometryItemsWithIds(searchForAllIDs, false); ModelItemCollection selectedGeometry = searchForAllIDs.FindAll(doc, false); foreach (ModelItem modelItem in selectedGeometry) { dataStorage.CreateNewModelObject(container, modelItem); } } }
private void clearAppearance() //清除所有表达 { Search search = new Search(); search.Selection.SelectAll(); //oDoc.Models.ResetAllPermanentMaterials(); VariantData oData = VariantData.FromDisplayString("门"); SearchCondition oSearchCondition = SearchCondition.HasPropertyByDisplayName("项目", "类型"); oSearchCondition = oSearchCondition.EqualValue(oData); search.SearchConditions.Add(oSearchCondition); ModelItemCollection items = search.FindAll(oDoc, false); oDoc.Models.OverridePermanentColor(items, Autodesk.Navisworks.Api.Color.Blue); oDoc.Models.OverridePermanentTransparency(items, 0.5); Search search1 = new Search(); search1.Selection.SelectAll(); oData = VariantData.FromDisplayString("房间"); oSearchCondition = SearchCondition.HasPropertyByDisplayName("项目", "类型"); oSearchCondition = oSearchCondition.EqualValue(oData); search1.SearchConditions.Add(oSearchCondition); items = search1.FindAll(oDoc, false); oDoc.Models.OverridePermanentColor(items, Autodesk.Navisworks.Api.Color.White); oDoc.Models.OverridePermanentTransparency(items, 1); //oDoc.CurrentSelection.CopyFrom(items); }
bool ExceptionTypeFilter(Type type) { if (type == null) { return(false); } if (type != typeof(Exception) && !type.IsSubclassOf(typeof(Exception))) { return(false); } ModelProperty catchesProperty = this.ModelItem.Properties[CatchesPropertyName]; Fx.Assert(catchesProperty != null, "TryCatch.Catches could not be null"); ModelItemCollection catches = catchesProperty.Collection; Fx.Assert(catches != null, "Catches.Collection could not be null"); foreach (ModelItem catchItem in catches) { ModelProperty exceptionTypeProperty = catchItem.Properties[ExceptionTypePropertyName]; Fx.Assert(exceptionTypeProperty != null, "Catch.ExceptionType could not be null"); Type exceptionType = exceptionTypeProperty.ComputedValue as Type; Fx.Assert(exceptionType != null, "Catch.ExceptionType.Value could not be null"); if (exceptionType == type) { return(false); } } return(true); }
private void ButQueryModelRecord_Click(object sender, EventArgs e)//查询模型记录 { Document Doc = Autodesk.Navisworks.Api.Application.ActiveDocument; ModelItemCollection modelItems = Doc.CurrentSelection.SelectedItems; if (modelItems.Count != 1) { MessageBox.Show("请选择一个构件查询", "提示"); return; } ModelItem modelItem = modelItems.First; int nId = -1; try { nId = modelItem.PropertyCategories.FindPropertyByDisplayName("元素", "Id").Value.ToInt32(); } catch (Exception ex) { MessageBox.Show("查询错误" + ex.Message); return; } string strId = nId.ToString(); if (!HasRecordInSqlTable(strId))//查询并聚焦 { MessageBox.Show("该构件未查询到信息!", "信息"); } }
protected override void AddToCollection(IEnumerable <string> sources, bool overwrite) { if (GetType() == typeof(DataMergeDesignerViewModel)) { var lastPopulated = ModelItemCollection?.LastOrDefault(p => !string.IsNullOrWhiteSpace(p.GetProperty("At").ToString())); if (lastPopulated != null) { _initialDto = (TDev2TOFn)lastPopulated.GetCurrentValue(); } } var indexNumber = GetIndexForAdd(overwrite); // Always insert items before blank row foreach (var s in sources.Where(s => !string.IsNullOrWhiteSpace(s))) { AddDto(indexNumber, s); indexNumber++; } AddBlankRow(overwrite); var lastModelItem = GetModelItem(ItemCount); SetIndexNumber(lastModelItem, indexNumber); UpdateDisplayName(); // Restore _initialDto = new TDev2TOFn(); }
/// <summary> /// Gets the insert index for <see cref="AddToCollection"/>. /// Returns the index of the last blank row. /// </summary> int GetIndexForAdd(bool overwrite) { var indexNumber = 1; if (overwrite) { ModelItemCollection.Clear(); // Add blank row AddDto(indexNumber); } else { var lastDto = GetLastDto(); indexNumber = ModelItemCollection.IndexOf(GetModelItem(ItemCount)) + 1; if (ModelItemCollection.Count == 2) { // Check whether we have 2 blank rows var firstDto = GetDto(1); if (firstDto.CanRemove() && lastDto.CanRemove()) { RemoveAt(indexNumber, lastDto); indexNumber = indexNumber - 1; } } } return(indexNumber); }
public override int Execute(params string[] parameters) { // current document Document doc = Application.ActiveDocument; // COM state object InwOpState10 cdoc = ComApiBridge.State; // current selected items ModelItemCollection items = doc.CurrentSelection.SelectedItems; // convert ModelItem to COM Path InwOaPath citem = ComApiBridge.ToInwOaPath(items[0]); // Get item's PropertyCategoryCollection object InwGUIPropertyNode2 cpropcates = (InwGUIPropertyNode2)cdoc.GetGUIPropertyNode(citem, true); // Get PropertyCategoryCollection data InwGUIAttributesColl propCol = cpropcates.GUIAttributes(); // loop propertycategory foreach (InwGUIAttribute2 i in propCol) { // if category's name match if (i.UserDefined && i.ClassUserName == "Premier League") { // overwritten the existing propertycategory with // newly created propertycategory(existing + new) cpropcates.SetUserDefined(1, "Premier League", "PremierLeague_InternalName", AddNewPropertyToExtgCategory(i)); } } return(0); }
protected override void AddToCollection(IEnumerable <string> source, bool overwrite) { var firstModelItem = ModelItemCollection.FirstOrDefault(); if (firstModelItem != null) { _initialDto = (TDev2TOFn)firstModelItem.GetCurrentValue(); } var indexNumber = GetIndexForAdd(overwrite); // Always insert items before blank row foreach (var s in source.Where(s => !string.IsNullOrWhiteSpace(s))) { AddDto(indexNumber, s); indexNumber++; } var lastModelItem = GetModelItem(ItemCount); SetIndexNumber(lastModelItem, indexNumber); UpdateDisplayName(); // Restore _initialDto = new TDev2TOFn(); }
protected void InitializeItems(ModelItemCollection modelItemCollection) { ModelItemCollection = modelItemCollection; BindingOperations.EnableCollectionSynchronization(ModelItemCollection, _syncLock); // Do this before, because AddDTO() also attaches events AttachEvents(0); if (modelItemCollection.Count == 1) { AddDto(2); } if (modelItemCollection.Count == 0) { AddDto(1); AddDto(2); } AddBlankRow(); UpdateDisplayName(); if (ModelItemCollection != null) { ModelItemCollection.CollectionChanged += ModelItemCollectionOnCollectionChanged; } }
public static void addChilds() { ModelItemCollection selectionModelItems = new ModelItemCollection(); if (!navisApp.Application.ActiveDocument.CurrentSelection.SelectedItems.IsEmpty) { //Copy the selection into a new ModelItemCollection navisApp.Application.ActiveDocument.CurrentSelection.SelectedItems.CopyTo(selectionModelItems); //Clear the current selection Autodesk.Navisworks.Api.Application.ActiveDocument.CurrentSelection.Clear(); //iterate through the ModelItem's in the selection foreach (ModelItem modelItem in selectionModelItems) { navisApp.Application.ActiveDocument.CurrentSelection.Add(modelItem); //Add the ModelItem to the current selection foreach (ModelItem childModelItem in modelItem.Children) { //Add the ModelItem to the current selection Autodesk.Navisworks.Api.Application.ActiveDocument.CurrentSelection.Add(childModelItem); } } } }
void OnCreateSendReplyExecute(object sender, ExecutedRoutedEventArgs e) { ModelItem container; ModelItem flowStepContainer; using (ModelEditingScope scope = this.ModelItem.BeginEdit((string)this.FindResource("createSendReplyDescription"))) { //special case handling for Sequence if (this.ModelItem.IsItemInSequence(out container)) { //get activities collection ModelItemCollection activities = container.Properties["Activities"].Collection; //get index of Send within collection and increment by one int index = activities.IndexOf(this.ModelItem) + 1; //insert created reply just after the Receive activities.Insert(index, ReceiveDesigner.CreateSendReply(container, this.ModelItem)); } //special case handling for Flowchart else if (this.ModelItem.IsItemInFlowchart(out container, out flowStepContainer)) { Activity replyActivity = ReceiveDesigner.CreateSendReply(container, this.ModelItem); FlowchartDesigner.DropActivityBelow(this.ViewStateService, this.ModelItem, replyActivity, 30); } else { ErrorReporting.ShowAlertMessage(string.Format(CultureInfo.CurrentUICulture, System.Activities.Core.Presentation.SR.CannotPasteSendReplyOrReceiveReply, typeof(SendReply).Name)); } scope.Complete(); } //always copy reply to clipboard Func <ModelItem, object, object> callback = CreateSendReply; CutCopyPasteHelper.PutCallbackOnClipBoard(callback, typeof(SendReply), this.ModelItem); e.Handled = true; }
private void InitializeDesigning() { dynamic item = ModelItem; WIP.AllowedItemType = (Type)((ModelItem)item.BranchType).GetCurrentValue(); branchesColl = ((ModelItemCollection)item.Branches); branchesColl.CollectionChanged += OnBranchesCollectionChanged; foreach (var branchModelItem in branchesColl) InitializeBranchModelItem(branchModelItem); }
public static DynamicActivityProperty Find(ModelItemCollection properties, string propertyName) { foreach (ModelItem entry in properties) { DynamicActivityProperty property = (DynamicActivityProperty)entry.GetCurrentValue(); if (StringComparer.Ordinal.Equals(property.Name, propertyName)) { return property; } } return null; }
private static void SwapItems(ModelItemCollection collection, ModelItem modelItem1, ModelItem modelItem2) { int index1 = collection.IndexOf(modelItem1); int index2 = collection.IndexOf(modelItem2); collection.Remove(modelItem1); collection.Insert(index2, modelItem1); collection.Remove(modelItem2); collection.Insert(index1, modelItem2); }
private ModelItem GetTopmostSelectedArgument(Selection selection, ModelItemCollection arguments) { foreach (ModelItem argument in arguments) { foreach (ModelItem candidateArgument in selection.SelectedObjects) { if (candidateArgument.ItemType == typeof(DesignTimeArgument)) { // since for arguments, the selection is not the modelitem, it is the fakemodelitem, we cannot do a // simple reference comparing to find the selected argument. DesignTimeArgument designTimeArgument = candidateArgument.GetCurrentValue() as DesignTimeArgument; if (designTimeArgument.ReflectedObject == argument) { return argument; } } } } return null; }
internal static void AddModelItemCollection(TreeViewItemViewModel parent, ModelItemCollection collection, ModelProperty trackingProperty) { parent.GetTracker(trackingProperty).AddCollection(collection); bool duplicatedNodeVisible = true; string childNodePrefix = string.Empty; ShowPropertyInOutlineViewAttribute viewChild = ExtensibilityAccessor.GetAttribute<ShowPropertyInOutlineViewAttribute>(trackingProperty); if (viewChild != null) { duplicatedNodeVisible = viewChild.DuplicatedChildNodesVisible; childNodePrefix = viewChild.ChildNodePrefix; } foreach (ModelItem item in collection) { AddChild(parent, item, item, duplicatedNodeVisible, childNodePrefix, trackingProperty); } }
void OnItemsChanged(ModelItemCollection oldItemsCollection, ModelItemCollection newItemsCollection) { if (oldItemsCollection != null) { oldItemsCollection.CollectionChanged -= this.OnCollectionChanged; } if (newItemsCollection != null) { newItemsCollection.CollectionChanged += this.OnCollectionChanged; } if (!isRegisteredWithParent) { CutCopyPasteHelper.RegisterWithParentViewElement(this); isRegisteredWithParent = true; } populateOnLoad = false; PopulateContent(); }