public void UpdateFrom(MainWindow window) { Left = window.Left; Top = window.Top; Width = window.Width; Height = window.Height; State = window.WindowState; }
public static int Start(string[] args) { InstallExceptionHandlers(); Log.InfoFormat("Starting tailviewer..."); Log.InfoFormat("Commandline arguments: {0}", string.Join(" ", args)); LogEnvironment(); ApplicationSettings settings = ApplicationSettings.Create(); bool neededPatching; settings.Restore(out neededPatching); if (neededPatching) { // TODO: Save settings right again to complete the upgrade // (maybe we should preserve an old version) } var actionCenter = new ActionCenter(); using (var taskScheduler = new DefaultTaskScheduler()) using (var dataSources = new DataSources(taskScheduler, settings.DataSources)) using (var updater = new AutoUpdater(actionCenter, settings.AutoUpdate)) { if (args.Length > 0) { var filePath = args[0]; if (File.Exists(filePath)) { // Not only do we want to add this file to the list of data sources, // but we also want to select it so the user can view it immediately, regardless // of what was selected previously. var dataSource = dataSources.AddDataSource(filePath); settings.DataSources.SelectedItem = dataSource.Id; } else { Log.ErrorFormat("File '{0}' does not exist, won't open it!", filePath); } } if (settings.AutoUpdate.CheckForUpdates) { // Our initial check for updates is not due to a user action // and therefore we don't need to show a notification when the // application is up-to-date. updater.CheckForUpdates(addNotificationWhenUpToDate: false); } var quickFilters = new QuickFilters(settings.QuickFilters); actionCenter.Add(Changelog.MostRecent); var application = new App(); Dispatcher dispatcher = Dispatcher.CurrentDispatcher; var uiDispatcher = new UiDispatcher(dispatcher); dispatcher.UnhandledException += actionCenter.ReportUnhandledException; TaskScheduler.UnobservedTaskException += actionCenter.ReportUnhandledException; var window = new MainWindow(settings) { DataContext = new MainWindowViewModel(settings, dataSources, quickFilters, actionCenter, updater, uiDispatcher) }; settings.MainWindow.RestoreTo(window); window.Show(); return application.Run(); } }