private void Window_Loaded(object sender, RoutedEventArgs e) { var database = new SystemDatabase(); if (!database.CreateDatabaseIfNeed()) { AppCommon.ShowErrorMsg(string.Format(ErrorMsg.FailToCreate, "system database")); this.Close(); } this._model = new ObservableCollection <ProfileModel>(); using (var table = new ProfilesTable()) { table.OpenDatabase(); table.SelectAll(); while (table.Read()) { this._model.Add(new ProfileModel { Id = table.Id, FilePath = table.FilePath, DisplayName = table.DisplayName, RowOrder = table.RowOrder }); } } this.cProfileList.DataContext = this._model; }
/// <summary> /// window loaded /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MySimpleLauncherMain_Loaded(object sender, RoutedEventArgs e) { this.cCategoryList.DataContext = this._categoryList; this.cItemList.DataContext = this._itemList; this.cDisplayMenuShowStatusBar.IsChecked = this._settings.ShowStatusBar; this.cFileStatus.Visibility = this._settings.ShowStatusBar ? Visibility.Visible : Visibility.Collapsed; this.cCategoryList.ContextMenu = this._categoryMenu; this.cItemList.ContextMenu = this._itemMenu; if (this._settings.CurrentProfileId < 0) { this.ClearScreen(); } else { using (var table = new ProfilesTable()) { table.SelectById(this._settings.CurrentProfileId); if (table.Read()) { this._currentProfile = new ProfileModel(table); if (System.IO.File.Exists(table.FilePath)) { this.cProfileList.Content = this._currentProfile.DisplayName; this._profileDatabase = new ProfileDatabase(table.FilePath); this.ShowCategoryList(); this.cCategoryList.SelectedIndex = this._settings.CategoryListSelectedIndex; } else { AppCommon.ShowErrorMsg(string.Format(ErrorMsg.ProfileNotFound, table.FilePath)); this.ClearScreen(); } } else { this.ClearScreen(); } } } this.SetWindowsState(true); }