Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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;
            }
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
 private void CheckWorksheets()
 {
     ExcelDialogs.CheckSheets(userInput.FilePath);
     ExcelDialogs.UpdateWorksheetSelector(SelectWorksheet, TemplateName);
     ExcelDialogs.UpdateWorksheetRangeSelector(SelectRange, SheetRange);
 }
Exemplo n.º 5
0
 private void SelectRange_Click(object sender, RoutedEventArgs e)
 {
     ExcelDialogs.SelectWorksheetRange(SheetRange, WorkbookPath.Text);
 }
Exemplo n.º 6
0
 private void SelectWorksheet_Click(object sender, RoutedEventArgs e)
 {
     ExcelDialogs.SelectWorksheet(TemplateName, WorkbookPath.Text);
 }
Exemplo n.º 7
0
 private void SelectSheets_Click(object sender, RoutedEventArgs e)
 {
     ExcelDialogs.SelectSharedWorksheets(SheetNames);
 }