private void AddSource_Click(object sender, RoutedEventArgs e) { if (IODialogs.TrySelectFile(out string path, "Select Excel Source", ".xlsx")) { void UpdateSources() { string bookName = Path.GetFileNameWithoutExtension(path); userInput.AddSource(new UserInputSource() { Alias = (userInput.ExcelSources.Count + 1).ToString(), Name = bookName, Path = path }); ExcelSources.Items.Refresh(); } void Update() { ExcelSources.Dispatcher.Invoke(UpdateSources); } void PostUpdate() { ExcelDialogs.CheckCommonWorksheets(userInput.ExcelSources.Select(x => x.Path)); } /* This is ultimately too slow to be practical * * void UpdateOnCheck() * { * bool passed = IODialogs.ExcelCheck.Predicate(path); * * if (passed) * { * ExcelSources.Dispatcher.Invoke(Update); * Script.Log.Debug("Document check passed"); * } * else * { * Script.Log.Warning("Document check failed"); * Script.Log.Aside("Is the document you provided accessible, and a word document?"); * } * } */ WindowHelper.RunWithCancel("Check source", Update, "Cancelled checking excel source", PostUpdate); } }
private void CheckWorksheets() { ExcelDialogs.CheckSheets(userInput.FilePath); // Only the status of the buttons is updated here, in contrast to other scripts. // I'm not sure what kind of autofill behaviour would be suitable here. Dispatcher.Invoke(UpdateButtons); void UpdateButtons() { SelectTemplates.IsEnabled = ExcelDialogs.SheetRangeDialogAvailable; SelectSources.IsEnabled = SelectTemplates.IsEnabled; } }
private void RemoveSource_Click(object sender, RoutedEventArgs e) { var selectedIndex = ExcelSources.SelectedIndex; var source = ExcelSources.SelectedItem as UserInputSource; if (source != null) { userInput.RemoveSource(source); } ExcelSources.Items.Refresh(); if (selectedIndex >= ExcelSources.Items.Count) { selectedIndex--; } ExcelSources.SelectedIndex = selectedIndex; ExcelDialogs.CheckCommonWorksheets(userInput.ExcelSources.Select(x => x.Path)); }
private void CheckWorksheets() { ExcelDialogs.CheckSheets(userInput.FilePath); ExcelDialogs.UpdateWorksheetSelector(SelectWorksheet, TemplateName); ExcelDialogs.UpdateWorksheetRangeSelector(SelectRange, SheetRange); }
private void SelectRange_Click(object sender, RoutedEventArgs e) { ExcelDialogs.SelectWorksheetRange(SheetRange, WorkbookPath.Text); }
private void SelectWorksheet_Click(object sender, RoutedEventArgs e) { ExcelDialogs.SelectWorksheet(TemplateName, WorkbookPath.Text); }
private void SelectSheets_Click(object sender, RoutedEventArgs e) { ExcelDialogs.SelectSharedWorksheets(SheetNames); }