/// <summary> /// Set the current item /// </summary> /// <param name="guid">The guid of the item</param> /// <returns>true if the new item is set, false otherwise</returns> public bool SetCurrentDB(Guid guid) { var db = DBs.Where(x => x.Guid == guid); if (db.Any()) { IDB newDB = db.First(); CurrentDB = newDB; //ResourceDictionary theme = Application.Current.MainWindow.Resources.MergedDictionaries[0]; //ResourceDictionary appTheme = Application.Current.Resources.MergedDictionaries.Count > 0 // ? Application.Current.Resources.MergedDictionaries[0] // : null; //theme.BeginInit(); //theme.MergedDictionaries.Clear(); //if (appTheme != null) //{ // appTheme.BeginInit(); // appTheme.MergedDictionaries.Clear(); //} //else //{ // appTheme = new ResourceDictionary(); // appTheme.BeginInit(); // Application.Current.Resources.MergedDictionaries.Add(appTheme); //} //foreach (Uri uri in newTheme.UriList) //{ // ResourceDictionary newDict = new ResourceDictionary {Source = uri}; // /*AvalonDock and menu style needs to move to the application // * 1. AvalonDock needs global styles as floatable windows can be created // * 2. Menu's need global style as context menu can be created // */ // if (uri.ToString().Contains("AvalonDock") || // uri.ToString().Contains("Wide;component/Interfaces/Styles/VS2012/Menu.xaml")) // { // appTheme.MergedDictionaries.Add(newDict); // } // else // { // theme.MergedDictionaries.Add(newDict); // } //} //appTheme.EndInit(); //theme.EndInit(); _logger.Log("Database item set to " + newDB.DBOptions.Name, LogCategory.Info, LogPriority.None); VEFModule.EventAggregator.GetEvent <DALChangeEvent>().Publish(newDB); } return(false); }
private void AddDB(string name, string path) { if (name == null || path == null) { return; } int count = DBs.Where(db => { return(db.DBPath == path); }).Count(); if (count != 0) { return; } DBViewModel newDB = new DBViewModel(name, path); DBs.Add(newDB); ActiveDB = newDB; }