예제 #1
0
 public CremaAppHostViewModel(ICremaHost cremaHost, IAppConfiguration configs, IBuildUp buildUp, CremaSettings settings,
                              Lazy <DataBaseServiceViewModel> dataBaseService, Lazy <DataBaseListViewModel> dataBaseSelections, Lazy <IShell> shell)
 {
     this.cremaHost          = cremaHost;
     this.cremaHost.Opened  += CremaHost_Opened;
     this.configs            = configs;
     this.buildUp            = buildUp;
     this.settings           = settings;
     this.dataBaseService    = dataBaseService;
     this.dataBaseSelections = dataBaseSelections;
     this.shell           = shell;
     this.theme           = Themes.Keys.FirstOrDefault();
     this.themeColor      = FirstFloor.ModernUI.Presentation.AppearanceManager.Current.AccentColor;
     this.ConnectionItems = ConnectionItemCollection.Read(this, AppUtility.GetDocumentFilename("ConnectionList.xml"));
     this.buildUp.BuildUp(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;
         }
     };
 }
예제 #2
0
 public static ConnectionItemCollection Read(CremaAppHostViewModel cremaAppHost, string filename)
 {
     try
     {
         using var stream = new FileStream(filename, FileMode.Open);
         var items      = serializer.Deserialize(stream) as ConnectionItemInfo[];
         var collection = new ConnectionItemCollection(cremaAppHost, filename, items);
         return(collection);
     }
     catch
     {
         return(new ConnectionItemCollection(cremaAppHost, filename));
     }
 }