private void OnWindowContentRendered(object sender, EventArgs e) { if (_options == null || !_options.IsValid) { return; } MainApplication theApp = (MainApplication)Application.Current; Debug.Assert(theApp != null); if (theApp == null) { return; } ConverterCommandLines commandLines = theApp.CommandLines; Debug.Assert(commandLines != null); if (commandLines == null || commandLines.IsEmpty) { return; } IList <string> sourceFiles = commandLines.SourceFiles; if (sourceFiles == null || sourceFiles.Count == 0) { string sourceFile = commandLines.SourceFile; if (String.IsNullOrEmpty(sourceFile) || !File.Exists(sourceFile)) { return; } sourceFiles = new List <string>(); sourceFiles.Add(sourceFile); } _isConverting = true; if (_converterOutput == null) { _converterOutput = new FileListConverterOutput(); } _options.Update(commandLines); _converterOutput.Options = _options; _converterOutput.Subscribe(this); _converterOutput.ContinueOnError = commandLines.ContinueOnError; _converterOutput.SourceFiles = sourceFiles; _converterOutput.OutputDir = commandLines.OutputDir; frameConverter.Content = _converterOutput; //_converterOutput.Convert(); this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new ConvertHandler(_converterOutput.Convert)); }
static int RunWindows(ConverterCommandLines commandLines, bool isMainWindow) { MainApplication theApp = new MainApplication(); theApp.CommandLines = commandLines; theApp.InitializeComponent(isMainWindow); return(theApp.Run()); }
public override void Cancel() { if (_worker != null) { if (_worker.IsBusy) { _worker.CancelAsync(); // Wait for the ConsoleWorker to finish the download. while (_worker.IsBusy) { // Keep UI messages moving, so the form remains // responsive during the asynchronous operation. MainApplication.DoEvents(); } } } }
public void Cancel() { btnCancel.IsEnabled = false; if (_worker != null) { if (_worker.IsBusy) { _worker.CancelAsync(); // Wait for the BackgroundWorker to finish the download. while (_worker.IsBusy) { // Keep UI messages moving, so the form remains // responsive during the asynchronous operation. MainApplication.DoEvents(); } } } }
static int RunWindows(ConverterCommandLines commandLines, bool isMainWindow) { MainApplication theApp = new MainApplication(); theApp.CommandLines = commandLines; theApp.InitializeComponent(isMainWindow); return theApp.Run(); }
public MainWindow() { InitializeComponent(); this.MinWidth = 640; this.MinHeight = 700; this.Width = 720; this.Height = 700; _startTabIndex = 0; _options = new ConverterOptions(); MainApplication theApp = (MainApplication)Application.Current; Debug.Assert(theApp != null); if (theApp != null) { ConverterCommandLines commandLines = theApp.CommandLines; if (commandLines != null) { if (commandLines.IsEmpty) { IList <string> sources = commandLines.Arguments; _displayHelp = commandLines.ShowHelp || (sources != null && sources.Count != 0); } else { _options.Update(commandLines); } } else { _displayHelp = true; } if (!_displayHelp) { string sourceFile = commandLines.SourceFile; if (!String.IsNullOrEmpty(sourceFile) && File.Exists(sourceFile)) { _startTabIndex = 1; } else { string sourceDir = commandLines.SourceDir; if (!String.IsNullOrEmpty(sourceDir) && Directory.Exists(sourceDir)) { _startTabIndex = 3; } else { IList <string> sourceFiles = commandLines.SourceFiles; if (sourceFiles != null && sourceFiles.Count != 0) { _startTabIndex = 2; } } } } } _filesPage = new FileConverterPage(); _filesPage.Options = _options; _filesPage.ParentFrame = filesFrame; _filesPage.Subscribe(this); filesFrame.Content = _filesPage; _filesListPage = new FileListConverterPage(); _filesListPage.Options = _options; _filesListPage.ParentFrame = filesListFrame; _filesListPage.Subscribe(this); filesListFrame.Content = _filesListPage; _directoriesPage = new DirectoryConverterPage(); _directoriesPage.Options = _options; _directoriesPage.ParentFrame = directoriesFrame; _directoriesPage.Subscribe(this); directoriesFrame.Content = _directoriesPage; _optionsPage = new OptionsPage(); _optionsPage.Options = _options; optionsFrame.Content = _optionsPage; this.Loaded += new RoutedEventHandler(OnWindowLoaded); this.Unloaded += new RoutedEventHandler(OnWindowUnloaded); this.Closing += new CancelEventHandler(OnWindowClosing); }