static void Main() { IdleTimer.Enabled = false; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Telemetry.Init(); Application.ApplicationExit += (s, e) => Telemetry.Default.Flush(); Application.ApplicationExit += (s, e) => DeleteTokenCacheOnApplicationExit(); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.ThreadException += (s, e) => TrackExceptionAndShowError(e.Exception); AppDomain.CurrentDomain.UnhandledException += (s, e) => TrackExceptionAndShowError(e.ExceptionObject as Exception); AppDomain.CurrentDomain.AssemblyResolve += (s, args) => ResolveMissingAssembly(args); // First run install steps Utils.ClickOnce_SetAddRemoveProgramsIcon(); ActivationUri.RegisterVaultProtocol(); // In case ActivationUri was passed perform the action and exit //Add a message filter to check if application is idle LeaveIdleMessageFilter limf = new LeaveIdleMessageFilter(IdleTimer); Application.AddMessageFilter(limf); Application.Idle += new EventHandler(ApplicationIdle); IdleTimer.Interval = TimeIntervalForApplicationIdle; IdleTimer.Tick += TimeDone; var form = new MainForm(ActivationUri.Parse()); if (!form.IsDisposed) { Application.Run(form); } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Telemetry.Init(); Application.ApplicationExit += (s, e) => Telemetry.Default.Flush(); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.ThreadException += (s, e) => TrackExceptionAndShowError(e.Exception); AppDomain.CurrentDomain.UnhandledException += (s, e) => TrackExceptionAndShowError(e.ExceptionObject as Exception); AppDomain.CurrentDomain.AssemblyResolve += (s, args) => ResolveMissingAssembly(args); // First run install steps Utils.ClickOnce_SetAddRemoveProgramsIcon(); ActivationUri.RegisterVaultProtocol(); // In case ActivationUri was passed perform the action and exit var form = new MainForm(ActivationUri.Parse()); if (!form.IsDisposed) { Application.Run(form); } }
public MainForm(ActivationUri activationUri) : this() { Guard.ArgumentNotNull(activationUri, nameof(activationUri)); _activationUri = activationUri; // ActivaionUri is Empty, nothing special to do if (_activationUri == ActivationUri.Empty) { return; } // Activation by vault://name uxComboBoxVaultAlias_DropDown(this, EventArgs.Empty); uxComboBoxVaultAlias.SelectedIndex = 0; SetCurrentVaultAlias(); if (!string.IsNullOrEmpty(_activationUri.VaultName) && string.IsNullOrEmpty(_activationUri.ItemName)) { uxMenuItemRefresh.PerformClick(); // Refresh list return; } // Activation by vault://name/collection/itemName SetCurrentVault(); _activationUri.PerformAction(CurrentVault); Close(); }