public CremaAppHostViewModel(ICremaHost cremaHost, IAppConfiguration configs, ICompositionService compositionService) { this.cremaHost = cremaHost; this.cremaHost.Opened += CremaHost_Opened; this.configs = configs; this.compositionService = compositionService; this.theme = Themes.Keys.FirstOrDefault(); this.themeColor = FirstFloor.ModernUI.Presentation.AppearanceManager.Current.AccentColor; this.loginCommand = new DelegateCommand((p) => this.Login(), (p) => this.CanLogin); this.connectionItems = ConnectionItemCollection.Read(AppUtility.GetDocumentFilename("ConnectionList.xml")); this.compositionService.SatisfyImportsOnce(this.connectionItems); this.ConnectionItem = this.connectionItems.FirstOrDefault(item => item.IsDefault); this.authenticator = this.cremaHost.GetService(typeof(Authenticator)) as Authenticator; this.configs.Update(this); this.PropertyChanged += (s, e) => { if (e.PropertyName == nameof(this.IsProgressing)) { this.Shell.IsProgressing = this.IsProgressing; } else if (e.PropertyName == nameof(this.ProgressMessage)) { this.Shell.ProgressMessage = this.ProgressMessage; } }; }
public static ConnectionItemCollection Read(string filename) { try { using (var stream = new FileStream(filename, FileMode.Open)) { var items = serializer.Deserialize(stream) as ConnectionItemInfo[]; var collection = new ConnectionItemCollection(filename, items); return(collection); } } catch { return(new ConnectionItemCollection(filename)); } }