private async void bSelectBar2_Click(object sender, RoutedEventArgs e) { mainMenu.IsEnabled = false; SpinnerFile1.Visibility = Visibility.Visible; tbFile.Text = "Opening"; OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = Settings.Default.lastOpenedPath; openFileDialog.Filter = "Age of Empires 3 .BAR files (*.bar)|*.bar"; string filePath; if (openFileDialog.ShowDialog() == true) { filePath = openFileDialog.FileName; Settings.Default.lastOpenedPath = Path.GetDirectoryName(filePath); Settings.Default.Save(); tbBar2Name.ToolTip = filePath; } else { SpinnerFile1.Visibility = Visibility.Collapsed; tbFile.Text = "Open"; mainMenu.IsEnabled = true; return; } try { barComparer = null; NotifyPropertyChanged("barComparer"); Bar2 = null; NewOpen.IsChecked = false; NotifyPropertyChanged("Bar2"); Bar2 = await BarViewModel.Load(filePath, true); NotifyPropertyChanged("Bar2"); NewOpen.IsChecked = true; if (Bar2.barFile.barFileHeader.Version > 5) { gvcEntryNewlastModifiedDate.Width = 0; gvcEntryNewFileName.Width = 345; } else { gvcEntryNewlastModifiedDate.Width = 160; gvcEntryNewFileName.Width = 185; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } SpinnerFile1.Visibility = Visibility.Collapsed; tbFile.Text = "Open"; mainMenu.IsEnabled = true; }
private async void openFile(string path = null) { mainMenu.IsEnabled = false; SpinnerFile.Visibility = Visibility.Visible; tbFile.Text = "Opening"; var filePath = path; if (string.IsNullOrEmpty(path)) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Age of Empires 3 .BAR files (*.bar)|*.bar"; if (openFileDialog.ShowDialog() == true) { filePath = openFileDialog.FileName; } else { SpinnerFile.Visibility = Visibility.Collapsed; tbFile.Text = "File"; mainMenu.IsEnabled = true; return; } } try { file = null; NotifyPropertyChanged("recentFiles"); NotifyPropertyChanged("file"); file = await BarViewModel.Load(filePath, DoCRC32); if (Settings.Default.RecentFiles.Contains(filePath)) { Settings.Default.RecentFiles.Remove(filePath); recentFiles.Remove(recentFiles.SingleOrDefault(x => x.FileName == filePath)); } recentFiles.Insert(0, new RecentFile() { FileName = filePath, Title = Path.GetFileName(filePath), OnClickCommand = new RelayCommand <string>(openFile) }); Settings.Default.RecentFiles.Insert(0, filePath); Settings.Default.Save(); NotifyPropertyChanged("recentFiles"); NotifyPropertyChanged("file"); } catch (Exception e) { MessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } SpinnerFile.Visibility = Visibility.Collapsed; tbFile.Text = "File"; mainMenu.IsEnabled = true; }
private async void bSelectBar2_Click(object sender, RoutedEventArgs e) { mainMenu.IsEnabled = false; SpinnerFile1.Visibility = Visibility.Visible; tbFile.Text = "Opening"; OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Age of Empires 3 .BAR files (*.bar)|*.bar"; string filePath; if (openFileDialog.ShowDialog() == true) { filePath = openFileDialog.FileName; tbBar2Name.ToolTip = filePath; } else { SpinnerFile1.Visibility = Visibility.Collapsed; tbFile.Text = "Open"; mainMenu.IsEnabled = true; return; } try { barComparer = null; NotifyPropertyChanged("barComparer"); Bar2 = null; NewOpen.IsChecked = false; NotifyPropertyChanged("Bar2"); Bar2 = await BarViewModel.Load(filePath, true); NotifyPropertyChanged("Bar2"); NewOpen.IsChecked = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } SpinnerFile1.Visibility = Visibility.Collapsed; tbFile.Text = "Open"; mainMenu.IsEnabled = true; }