private void Window_Loaded(object sender, RoutedEventArgs e) { // Abort if some of the required dependencies are missing if (Dependencies.AreRequiredBinariesPresent(Constant.VersionUpdates.ApplicationName, Assembly.GetExecutingAssembly()) == false) { Dialogs.DependencyFilesMissingDialog(Constant.VersionUpdates.ApplicationName); Application.Current.Shutdown(); } // Check for updates at least once a day if (DateTime.Now.Year != this.State.MostRecentCheckForUpdates.Year || DateTime.Now.Month != this.State.MostRecentCheckForUpdates.Month || DateTime.Now.Day != this.State.MostRecentCheckForUpdates.Day) { VersionChecks updater = new VersionChecks(this, Constant.VersionUpdates.ApplicationName, Constant.VersionUpdates.LatestVersionFileNameXML); updater.TryCheckForNewVersionAndDisplayResultsAsNeeded(false); this.State.MostRecentCheckForUpdates = DateTime.UtcNow; } if (this.State.FirstTimeFileLoading) { // Load the previously saved layout. If there is none, TryLoad will default to a reasonable layout and window size/position. this.AvalonLayout_TryLoad(Constant.AvalonLayoutTags.LastUsed); this.State.FirstTimeFileLoading = false; } if (!SystemStatus.CheckAndGetLangaugeAndCulture(out _, out _, out string displayname)) { this.HelpDocument.WarningRegionLanguage = displayname; } // Add a context menu to the data controls that allows a user to restore default values to the current or selected file // I originally had this in the XAML, but for some reason it complains if put there. ContextMenu menuRestoreDefaults = new ContextMenu(); //{ // Name = "MenuRestoreDefaults" //}; MenuItem menuItemRestoreDefaults = new MenuItem(); //{ // Header = "Restore default values for this file", // ToolTip = "Restores the default values for all fields for this file excepting file paths and date/times" //}; menuItemRestoreDefaults.Click += MenuItemRestoreDefaultValues_Click; menuRestoreDefaults.Opened += this.MenuRestoreDefaults_Opened; menuRestoreDefaults.Items.Add(menuItemRestoreDefaults); this.DataEntryControls.ContextMenu = menuRestoreDefaults; this.DataEntryControlPanel.IsVisible = false; this.InstructionPane.IsActive = true; }
private async void Window_Loaded(object sender, RoutedEventArgs e) { // Abort if some of the required dependencies are missing if (Dependencies.AreRequiredBinariesPresent(Constant.VersionUpdates.ApplicationName, Assembly.GetExecutingAssembly()) == false) { Dialogs.DependencyFilesMissingDialog(Constant.VersionUpdates.ApplicationName); Application.Current.Shutdown(); } // Check for updates at least once a day if (DateTime.Now.Year != this.State.MostRecentCheckForUpdates.Year || DateTime.Now.Month != this.State.MostRecentCheckForUpdates.Month || DateTime.Now.Day != this.State.MostRecentCheckForUpdates.Day) { VersionChecks updater = new VersionChecks(this, Constant.VersionUpdates.ApplicationName, Constant.VersionUpdates.LatestVersionFileNameXML); updater.TryCheckForNewVersionAndDisplayResultsAsNeeded(false); this.State.MostRecentCheckForUpdates = DateTime.Now; } if (this.State.FirstTimeFileLoading) { // Load the previously saved layout. If there is none, TryLoad will default to a reasonable layout and window size/position. this.AvalonLayout_TryLoad(Constant.AvalonLayoutTags.LastUsed); this.State.FirstTimeFileLoading = false; } if (!SystemStatus.CheckAndGetLangaugeAndCulture(out _, out _, out string displayname)) { this.HelpDocument.WarningRegionLanguage = displayname; } // Add a context menu to the data controls that allows a user to restore default values to the current or selected file // I originally had this in the XAML, but for some reason it complains if put there. ContextMenu menuRestoreDefaults = new ContextMenu(); //{ // Name = "MenuRestoreDefaults" //}; MenuItem menuItemRestoreDefaults = new MenuItem(); //{ // Header = "Restore default values for this file", // ToolTip = "Restores the default values for all fields for this file excepting file paths and date/times" //}; menuItemRestoreDefaults.Click += MenuItemRestoreDefaultValues_Click; menuRestoreDefaults.Opened += this.MenuRestoreDefaults_Opened; menuRestoreDefaults.Items.Add(menuItemRestoreDefaults); this.DataEntryControls.ContextMenu = menuRestoreDefaults; if (this.Arguments.IsViewOnly) { this.State.IsViewOnly = true; // Because its readonly, disable the data entry panel, the copy previous values button, the data entry panels' context menu etc. // Individual controls are disabled in the DataEntryX panel this.DataEntryControls.ContextMenu = null; this.CopyPreviousValuesButton.Visibility = Visibility.Collapsed; this.EnableOrDisableMenusAndControls(); } this.DataEntryControlPanel.IsVisible = false; this.InstructionPane.IsActive = true; if (false == String.IsNullOrEmpty(this.Arguments.Template)) { if (File.Exists(this.Arguments.Template)) { Mouse.OverrideCursor = Cursors.Wait; this.StatusBar.SetMessage("Loading images, please wait..."); await this.TryOpenTemplateAndBeginLoadFoldersAsync(this.Arguments.Template).ConfigureAwait(true); if (false == String.IsNullOrEmpty(this.Arguments.RelativePath)) { // Set and only use the relative path as a search term this.DataHandler.FileDatabase.CustomSelection.ClearCustomSearchUses(); this.DataHandler.FileDatabase.CustomSelection.SetAndUseRelativePathSearchTerm(this.Arguments.RelativePath); if (null == this.DataHandler?.ImageCache?.Current) { await this.FilesSelectAndShowAsync(FileSelectionEnum.Folders).ConfigureAwait(true); // Go to the first result (i.e., index 0) in the given selection set } else { await this.FilesSelectAndShowAsync(this.DataHandler.ImageCache.Current.ID, FileSelectionEnum.Folders).ConfigureAwait(true); // Go to the first result (i.e., index 0) in the given selection set } } this.StatusBar.SetMessage("Image set is now loaded."); Mouse.OverrideCursor = null; if (this.Arguments.ConstrainToRelativePath) { // Tell user that its a constrained relative path, // Also, set the File menus so that users cannot close and reopen a new image set // This is to avoid confusion as to how the user may mis-interpret the argument state given another image set Dialogs.ArgumentRelativePathDialog(this, this.Arguments.RelativePath); this.MenuItemExit.Header = "Close image set and exit Timelapse"; this.MenuFileCloseImageSet.Visibility = Visibility.Collapsed; } } else { // We can't open the template. Show a message and ignore the arguments (by clearing them) Dialogs.ArgumentTemplatePathDialog(this, this.Arguments.Template, this.Arguments.RelativePath); this.Arguments = new DataStructures.Arguments(null); } } if (this.State.IsViewOnly) { Dialog.Dialogs.OpeningMessageReadOnly(this); } if (this.State.SuppressOpeningMessageDialog == false) { Dialogs.OpeningMessage(this); } }