private void GetCurrentDocLayouts() { try { Document mdiActiveDocument = AcApp.DocumentManager.MdiActiveDocument; Database database; if (mdiActiveDocument != null) { database = mdiActiveDocument.Database; } else { database = null; } Database database1 = database; if (!((database1 == null) | (mdiActiveDocument == null))) { _currentDocLayouts = new ObservableCollection <LayoutForBinding>(); using (Transaction transaction = database1.TransactionManager.StartTransaction()) { LayoutManager current = LayoutManager.Current; DBDictionary obj = transaction.GetObject(database1.LayoutDictionaryId, OpenMode.ForRead, false) as DBDictionary; if (obj != null) { foreach (DBDictionaryEntry dBDictionaryEntry in obj) { Layout layout = transaction.GetObject(dBDictionaryEntry.Value, OpenMode.ForRead) as Layout; if (layout != null) { LayoutForBinding layoutForBinding = new LayoutForBinding() { LayoutName = layout.LayoutName, ModelType = layout.ModelType, TabOrder = layout.TabOrder == -1 ? current.LayoutCount : layout.TabOrder, TabSelected = layout.TabSelected }; if (_showModel) { _currentDocLayouts.Add(layoutForBinding); } else if (!layout.ModelType) { _currentDocLayouts.Add(layoutForBinding); } } } } transaction.Commit(); } _currentDocLayouts = new ObservableCollection <LayoutForBinding>( from x in _currentDocLayouts orderby x.TabOrder select x); } else { LvLayouts.ItemsSource = null; return; } } catch (Exception exception) { ExceptionBox.Show(exception); } BindingLayoutsToListView(); }
private string GetCopyLayoutName(LayoutForBinding selectedLayout, int copyCount) { int num = 1 + _currentDocLayouts.Count(currentDocLayout => currentDocLayout.LayoutName.Contains(selectedLayout.LayoutName)) + copyCount; return(string.Concat(selectedLayout.LayoutName, " (", num, ")")); }