private void buttonApply_Click(object sender, RoutedEventArgs e) { try { if (null != comboBoxTitleblock.SelectedItem) { TitleBlockType typeItem = (TitleBlockType)comboBoxTitleblock.SelectedItem; configuration.TitleblockId = typeItem.TypeId; if ((bool)radioButtonView.IsChecked) { configuration.IsPlaceholder = false; } if ((bool)radioButtonPlaceholder.IsChecked) { configuration.IsPlaceholder = true; } this.DialogResult = true; } } catch (Exception ex) { string message = ex.Message; } }
private void DisplayItems() { try { List <TitleBlockType> titleBlcokTypes = new List <TitleBlockType>(); FilteredElementCollector collector = new FilteredElementCollector(m_doc); List <FamilySymbol> symbols = collector.OfCategory(BuiltInCategory.OST_TitleBlocks).WhereElementIsElementType().ToElements().Cast <FamilySymbol>().ToList(); if (symbols.Count > 0) { foreach (FamilySymbol symbol in symbols) { TitleBlockType typeItem = new TitleBlockType(symbol); titleBlcokTypes.Add(typeItem); } titleBlcokTypes = titleBlcokTypes.OrderBy(o => o.DisplayName).ToList(); comboBoxTitleblock.ItemsSource = null; comboBoxTitleblock.ItemsSource = titleBlcokTypes; comboBoxTitleblock.DisplayMemberPath = "DisplayName"; if (configuration.TitleblockId != ElementId.InvalidElementId) { int index = titleBlcokTypes.FindIndex(o => o.TypeId == configuration.TitleblockId); if (index > -1) { comboBoxTitleblock.SelectedIndex = index; } } else { comboBoxTitleblock.SelectedIndex = 0; } } if (configuration.IsPlaceholder) { radioButtonPlaceholder.IsChecked = true; } else { radioButtonView.IsChecked = true; } } catch (Exception ex) { MessageBox.Show("Failed to display items.\n" + ex.Message, "Display Items", MessageBoxButton.OK, MessageBoxImage.Warning); } }