public static List <Model.RevitBase> Execute(Model.SQLDBUtilities SQLDB, FileInfo SelectedDatabase) { List <Model.RevitBase> result = new List <Model.RevitBase>(); try { List <Model.RevitElement> revitElements = SQLDB.readElementsFromDB(SelectedDatabase.FullName, SelectedDatabase.Name); var random = new Random(); var color = String.Format("#{0:X6}", random.Next(0x1000000)); foreach (Model.RevitElement item in revitElements) { item.ColorSet = color; result.Add(item); } } catch (Exception ex) { MessageBox.Show(ex.Message); } return(result); }
public MainViewModel() { if (IsInDesignMode) { ViewTitle = "Design Mode"; FilePath = "Enter the database file path"; } else { ViewTitle = "Metamorphosis Desktop App"; FilePath = @"C:\Users\giovanni.brogiolo\Documents"; DatabaseList = new ObservableCollection <FileInfo>(); SQLDB = new Model.SQLDBUtilities(); CategoriesAndCount = new ObservableCollection <Model.RevitBase>(); revitElements = new ObservableCollection <Model.RevitBase>(); // Display a list of all the databases in the input folder LoadDatabaseCommand = new RelayCommand(() => LoadRevitElements()); // Display all the categories in the project and their element's count LoadCategoriesAndCount = new RelayCommand(() => LoadCategoriesAndCountCommand()); // Display all the elements in the project LoadAllElements = new RelayCommand(() => LoadAllRevitElementsCommand()); // Clean the DataGrid ClearCommand = new RelayCommand(() => ClearDBList()); // Select a row in the datagrid. The command will leave only that category visible FilterCategoryCommand = new RelayCommand(() => FilterCategory()); // Bring back the Database List UndoFilterCommand = new RelayCommand(() => UndoFilter()); // Change the row colors based on the the database name ChangeColorsCommand = new RelayCommand(() => ChangeColors()); } }