private async void FluentDesignMainForm_Load(object sender, EventArgs e) { if (DesignMode) { return; } activeProvider = settings.RememberLastOpenedDataProvider ? settings.LastOpenedDataProvider : UserSettingsManager.UserSettings.InitialSelectedDataProvider; if (settings.AnalogyPosition.RememberLastPosition || settings.AnalogyPosition.WindowState != FormWindowState.Minimized) { WindowState = settings.AnalogyPosition.WindowState; if (WindowState != FormWindowState.Maximized) { if (Screen.AllScreens.Any(s => s.WorkingArea.Contains(settings.AnalogyPosition.Location))) { Location = settings.AnalogyPosition.Location; Size = settings.AnalogyPosition.Size; } else { AnalogyLogger.Instance.LogError("", $"Last location {settings.AnalogyPosition.Location} is not inside any screen"); } } } string framework = UpdateManager.Instance.CurrentFrameworkAttribute.FrameworkName; Text = $"Analogy Log Viewer {UpdateManager.Instance.CurrentVersion} ({framework})"; Icon = settings.GetIcon(); notifyIconAnalogy.Visible = preventExit = settings.MinimizedToTrayBar; await FactoriesManager.Instance.InitializeBuiltInFactories(); string[] arguments = Environment.GetCommandLineArgs(); disableOnlineDueToFileOpen = arguments.Length == 2; SetupEventHandlers(); bbiFileCaching.Caption = "File caching is " + (settings.EnableFileCaching ? "on" : "off"); bbiFileCaching.Appearance.BackColor = settings.EnableFileCaching ? Color.LightGreen : Color.Empty; //todo: //CreateAnalogyBuiltinDataProviders FactoryContainer analogy = FactoriesManager.Instance.GetBuiltInFactoryContainer(AnalogyBuiltInFactory.AnalogyGuid); CreateDataSource(analogy); await FactoriesManager.Instance.AddExternalDataSources(); PopulateGlobalTools(); //LoadStartupExtensions(); //Create all other DataSources foreach (FactoryContainer factory in FactoriesManager.Instance.Factories .Where(factory => !FactoriesManager.Instance.IsBuiltInFactory(factory.Factory))) { CreateDataSource(factory); } if (OnlineSources.Any()) { TmrAutoConnect.Start(); } Initialized = true; //todo: fine handler for file if (arguments.Length == 2) { //todo string[] fileNames = { arguments[1] }; // await OpenOfflineFileWithSpecificDataProvider(fileNames); } else { TmrAutoConnect.Enabled = true; } if (settings.ShowChangeLogAtStartUp) { var change = new ChangeLog(); change.ShowDialog(this); } //todo:fix below if (settings.RememberLastOpenedDataProvider && Mapping.ContainsKey(settings.LastOpenedDataProvider)) { //ribbonControlMain.SelectPage(Mapping[settings.LastOpenedDataProvider]); } if (AnalogyLogManager.Instance.HasErrorMessages || AnalogyLogManager.Instance.HasWarningMessages) { bbtnErrors.Visibility = BarItemVisibility.Always; } if (!AnalogyNonPersistSettings.Instance.UpdateAreDisabled) { var(_, release) = await UpdateManager.Instance.CheckVersion(false); if (release?.TagName != null && UpdateManager.Instance.NewestVersion != null) { bbtnCheckUpdates.Caption = "Latest Version: " + UpdateManager.Instance.NewestVersion.ToString(); if (UpdateManager.Instance.NewVersionExist) { bbtnCheckUpdates.Appearance.BackColor = Color.GreenYellow; bbtnCheckUpdates.Caption = "New Version Available: " + UpdateManager.Instance.NewestVersion.ToString(); } } } else { AnalogyLogManager.Instance.LogWarning("Update is disabled", nameof(MainForm)); } if (settings.ShowWhatIsNewAtStartup) { WhatsNewForm f = new WhatsNewForm(); f.ShowDialog(this); settings.ShowWhatIsNewAtStartup = false; } }
private void AnalogyMainForm_Load(object sender, EventArgs e) { if (DesignMode) { return; } settings = UserSettingsManager.UserSettings; bbtnCloseCurrentTabPage.ItemClick += (object s, ItemClickEventArgs ea) => { CloseCurrentTabPage(); }; bbtnCloseAllTabPage.ItemClick += (object s, ItemClickEventArgs ea) => { var pages = xtcLogs.TabPages.ToList(); foreach (var page in pages) { if (onlineDataSourcesMapping.ContainsKey(page)) { onlineDataSourcesMapping[page].StopReceiving(); onlineDataSourcesMapping.Remove(page); } xtcLogs.TabPages.Remove(page); } }; bbtnCloseOtherTabPages.ItemClick += (object s, ItemClickEventArgs ea) => { var pages = xtcLogs.TabPages.Where(p => p != currentContextPage).ToList(); foreach (var page in pages) { if (onlineDataSourcesMapping.ContainsKey(page)) { onlineDataSourcesMapping[page].StopReceiving(); onlineDataSourcesMapping.Remove(page); } xtcLogs.TabPages.Remove(page); } }; ribbonControlMain.Minimized = UserSettingsManager.UserSettings.StartupRibbonMinimized; string[] arguments = Environment.GetCommandLineArgs(); //todo: fine handler for file if (arguments.Length == 2) { string[] fileNames = { arguments[1] }; OpenOfflineLogs(fileNames); } else { TmrAutoConnect.Enabled = true; } if (UserSettingsManager.UserSettings.ShowChangeLogAtStartUp) { var change = new ChangeLog(); change.ShowDialog(this); } CreateAnalogyDataSource(); CreateEventLogsGroup(); CreateDataSources(); //set Default page: Guid defaultPage = new Guid(UserSettingsManager.UserSettings.InitilaSelectedDataSource); if (Mapping.ContainsKey(defaultPage)) { ribbonControlMain.SelectedPage = Mapping[defaultPage]; } if (OnlineSources.Any()) { TmrAutoConnect.Start(); } }