/// <summary> /// Start snapshot mode with loading data /// </summary> private void StartLoadingSnapshot(string path, int?selectedElementId = null) { DisableElementSelector(); var v = SelectAction.GetDefaultInstance().SelectLoadedData(path, selectedElementId); Logger.PublishTelemetryEvent(TelemetryEventFactory.ForLoadDataFile(v.Item2.Mode.ToString())); if (v.Item2.Mode == A11yFileMode.Test && !selectedElementId.HasValue) { StartTestAutomatedChecksView(); } else if (v.Item2.Mode == A11yFileMode.Contrast) { StartTestAutomatedChecksView(); // we got rid of the CC test tab. } else // A11yFileMode.Inspect { this.ctrlCurMode.HideControl(); this.ctrlCurMode = this.ctrlSnapMode; this.ctrlSnapMode.DataContextMode = GetDataContextModeForTest(); this.CurrentPage = AppPage.Test; this.CurrentView = TestView.ElementDetails; this.ctrlCurMode.ShowControl(); #pragma warning disable CS4014 // NOTE: We aren't awaiting this async call, so if you // touch it, consider if you need to add the await this.ctrlSnapMode.SetElement(v.Item1); #pragma warning restore CS4014 } PageTracker.TrackPage(this.CurrentPage, this.CurrentView.ToString()); }
/// <summary> /// When snapshot is invoked, Request appropriate mode change. /// </summary> /// <param name="method">by which way : Beaker or Hotkey</param> internal void HandleSnapshotRequest(TestRequestSources method) { if (this.CurrentPage == AppPage.Inspect && this.CurrentView == InspectView.Live) { if (ctrlLiveMode.SelectedInHierarchyElement != null) { if (ctrlLiveMode.SelectedInHierarchyElement.Item2 == 0) { SetDataAction.ReleaseDataContext(SelectAction.GetDefaultInstance().GetSelectedElementContextId().Value); } else { var sa = SelectAction.GetDefaultInstance(); sa.SetCandidateElement(ctrlLiveMode.SelectedInHierarchyElement.Item1, ctrlLiveMode.SelectedInHierarchyElement.Item2); sa.Select(); } } // Based on Ux model feedback from PM team, we decided to go to AutomatedTestResults as default page view for snapshot. StartTestMode(TestView.AutomatedTestResults); Logger.PublishTelemetryEvent(TelemetryEventFactory.ForTestRequested( method.ToString(), SelectAction.GetDefaultInstance().Scope.ToString())); } HollowHighlightDriver.GetDefaultInstance().Clear(); UpdateMainWindowUI(); }
private void hlReleaseNotes_Click(object sender, RoutedEventArgs e) { string error = string.Empty; string releaseNotesString = string.Empty; try { releaseNotesString = ReleaseNotesUri.ToString(); if (ReleaseNotesUri.Scheme == Uri.UriSchemeHttp || ReleaseNotesUri.Scheme == Uri.UriSchemeHttps) { Process.Start(releaseNotesString); } else { error = string.Format(CultureInfo.CurrentCulture, Properties.Resources.ReleaseNotes_ClickURLErrorMessage, releaseNotesString); MessageDialog.Show(error); } } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception ex) { ex.ReportException(); error = string.Format(CultureInfo.CurrentCulture, Properties.Resources.ReleaseNotes_ClickLoadErrorMessage, releaseNotesString); MessageDialog.Show(error); } #pragma warning restore CA1031 // Do not catch general exception types Logger.PublishTelemetryEvent(TelemetryEventFactory.ForReleaseNotesClick(error)); }
public void FileBug(HierarchyNodeViewModel vm = null) { vm = vm ?? this.treeviewHierarchy.SelectedItem as HierarchyNodeViewModel; if (vm == null) { MessageDialog.Show(Properties.Resources.HierarchyControl_FileBug_Could_not_find_the_selected_item__the_bug_filing_is_canceled); return; } if (vm.IssueLink != null) { // Bug already filed, open it in a new window try { System.Diagnostics.Process.Start(vm.IssueLink.OriginalString); } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception ex) { ex.ReportException(); // Happens when bug is deleted, message describes that work item doesn't exist / possible permission issue MessageDialog.Show(ex.InnerException?.Message); vm.IssueDisplayText = null; } #pragma warning restore CA1031 // Do not catch general exception types } else { // File a new bug var telemetryEvent = TelemetryEventFactory.ForIssueFilingRequest(FileBugRequestSource.Hierarchy); Logger.PublishTelemetryEvent(telemetryEvent); if (IssueReporter.IsConnected) { IssueInformation issueInformation = this.SelectedElement.GetIssueInformation(IssueType.NoFailure); FileIssueAction.AttachIssueData(issueInformation, this.ElementContext.Id, this.SelectedElement.BoundingRectangle, this.SelectedElement.UniqueId); IIssueResult issueResult = FileIssueAction.FileIssueAsync(issueInformation); if (issueResult != null) { vm.IssueDisplayText = issueResult.DisplayText; vm.IssueLink = issueResult.IssueLink; } File.Delete(issueInformation.TestFileName); } else { bool?accepted = MessageDialog.Show(Properties.Resources.HierarchyControl_FileIssue_Configure); if (accepted.HasValue && accepted.Value) { this.HierarchyActions.SwitchToServerLogin(); } } } }
/// <summary> /// Handles click on file bug button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnFileBug_Click(object sender, RoutedEventArgs e) { var vm = ((Button)sender).Tag as RuleResultViewModel; if (vm.IssueLink != null) { // Bug already filed, open it in a new window try { Process.Start(vm.IssueLink.OriginalString); } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception ex) { ex.ReportException(); // Happens when bug is deleted, message describes that work item doesn't exist / possible permission issue MessageDialog.Show(ex.InnerException?.Message); vm.IssueDisplayText = null; } #pragma warning restore CA1031 // Do not catch general exception types } else { // File a new bug var telemetryEvent = TelemetryEventFactory.ForIssueFilingRequest(FileBugRequestSource.AutomatedChecks); Logger.PublishTelemetryEvent(telemetryEvent); if (IssueReporter.IsConnected) { IssueInformation issueInformation = vm.GetIssueInformation(); FileIssueAction.AttachIssueData(issueInformation, this.ElementContext.Id, vm.Element.BoundingRectangle, vm.Element.UniqueId); IIssueResult issueResult = FileIssueAction.FileIssueAsync(issueInformation); if (issueResult != null) { vm.IssueDisplayText = issueResult.DisplayText; vm.IssueLink = issueResult.IssueLink; } File.Delete(issueInformation.TestFileName); } else { bool?accepted = MessageDialog.Show(Properties.Resources.AutomatedChecksControl_btnFileBug_Click_File_Issue_Configure); if (accepted.HasValue && accepted.Value) { SwitchToServerLogin(); } } } }
/// <summary>Load and register for custom UI Automation properties if a configuration file exists.</summary> private static void InitCustomUIA(string ConfigurationFolderPath, TelemetryBuffer telemetryBuffer) { const string ConfigurationFileName = "CustomUIA.json"; string path = Path.Combine(ConfigurationFolderPath, ConfigurationFileName); if (File.Exists(path)) { Axe.Windows.Core.CustomObjects.Config config = CustomUIAAction.ReadConfigFromFile(path); if (config?.Properties != null) { CustomUIAAction.RegisterCustomProperties(config.Properties); telemetryBuffer.AddEventFactory(() => TelemetryEventFactory.ForCustomUIAPropertyCount(config.Properties.Length)); } } }
private async Task <bool> HandleReleaseSwitch() { if (appSettingsCtrl.SelectedReleaseChannel == Configuration.ReleaseChannel) { return(false); } Logger.PublishTelemetryEvent(TelemetryEventFactory.ForReleaseChannelChangeConsidered( Configuration.ReleaseChannel, appSettingsCtrl.SelectedReleaseChannel)); var channelDialog = new ChangeChannelContainedDialog(appSettingsCtrl.SelectedReleaseChannel); if (!await MainWin.ctrlDialogContainer.ShowDialog(channelDialog).ConfigureAwait(false)) { return(false); } // If the window is topmost, the UAC prompt from the version switcher will appear behind the main window. // To prevent this, save the previous topmost state, ensure that the main window is not topmost when the // UAC prompt will display, then restore the previous topmost state. bool previousTopmostSetting = Configuration.AlwaysOnTop; try { Dispatcher.Invoke(() => { previousTopmostSetting = MainWin.Topmost; MainWin.Topmost = false; }); VersionSwitcherWrapper.ChangeChannel(appSettingsCtrl.SelectedReleaseChannel); Dispatcher.Invoke(() => MainWin.Close()); return(true); } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception ex) { ex.ReportException(); Dispatcher.Invoke(() => { MainWin.Topmost = previousTopmostSetting; MessageDialog.Show(Properties.Resources.ConfigurationModeControl_VersionSwitcherException); }); return(false); } #pragma warning restore CA1031 // Do not catch general exception types }
/// <summary> /// Download the upgrade installer and close the app depending on if it is successful or not /// </summary> private async void DownLoadInstaller(IAutoUpdate autoUpdate) { UpdateResult updateResult = UpdateResult.Unknown; // If the window is topmost, the UAC prompt from the version switcher will appear behind the main window. // To prevent this, save the previous topmost state, ensure that the main window is not topmost when the // UAC prompt will display, then restore the previous topmost state. bool previousTopmostSetting = Topmost; try { ctrlProgressRing.Activate(); Topmost = false; updateResult = await autoUpdate.UpdateAsync().ConfigureAwait(true); Logger.PublishTelemetryEvent(TelemetryEventFactory.ForUpgradeDoInstallation( autoUpdate.GetUpdateTime(), updateResult.ToString())); if (updateResult == UpdateResult.Success) { this.Close(); return; } } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception e) { e.ReportException(); }; #pragma warning restore CA1031 // Do not catch general exception types Topmost = previousTopmostSetting; ctrlProgressRing.Deactivate(); Logger.PublishTelemetryEvent(TelemetryEventFactory.ForUpgradeInstallationError(updateResult.ToString())); string message = _updateOption == AutoUpdateOption.RequiredUpgrade ? GetMessageForRequiredUpdateFailure() : GetMessageForOptionalUpdateFailure(); MessageDialog.Show(message); if (_updateOption == AutoUpdateOption.RequiredUpgrade) { this.Close(); return; } }
private void ShowUpgradeDialog() { // Make the upgrade decision var autoUpdate = Container.GetDefaultInstance().AutoUpdate; if (!ShouldUserUpgrade(autoUpdate, out _updateOption)) { return; } // Create the upgrade dialog UpdateDialog dialog = CreateUpgradeDialog(autoUpdate.ReleaseNotesUri, _updateOption); bool?dialogResult = dialog.ShowDialog(); // user clicked update now (true) if (dialogResult.HasValue && dialogResult.Value) { try { DownLoadInstaller(autoUpdate); } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception e) { e.ReportException(); } #pragma warning restore CA1031 // Do not catch general exception types } else { // user clicked later (false) Logger.PublishTelemetryEvent(TelemetryEventFactory.ForUpgradeDismissed(autoUpdate.InstalledVersion)); } this.modeGrid.Opacity = 1; this.AllowFurtherAction = true; }
private static void PublishTelemetryEventAsync(IAutoUpdate autoUpdate, Stopwatch updateOptionStopwatch, bool timeOutOccurred) { Task.Run(() => { try { var updateOption = autoUpdate.UpdateOptionAsync.Result; if (timeOutOccurred) { updateOptionStopwatch.Stop(); } Logger.PublishTelemetryEvent(TelemetryEventFactory.ForGetUpgradeOption(autoUpdate.GetInitializationTime(), updateOptionStopwatch.Elapsed, updateOption.ToString(), timeOutOccurred)); } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception e) { e.ReportException(); System.Diagnostics.Trace.WriteLine($"Unable to send telemetry at {e.Message}"); } #pragma warning restore CA1031 // Do not catch general exception types }); }
/// <summary> /// Handles control-related issue filing /// </summary> internal static void FileIssueFromControl(FileIssueWrapperInput input) { IIssueFilingSource vm = input.VM; if (vm.IssueLink != null) { // Bug already filed, open it in a new window try { System.Diagnostics.Process.Start(vm.IssueLink.OriginalString); } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception ex) { ex.ReportException(); // Happens when bug is deleted, message describes that work item doesn't exist / possible permission issue MessageDialog.Show(ex.InnerException?.Message); vm.IssueDisplayText = null; } #pragma warning restore CA1031 // Do not catch general exception types } else { // File a new bug var telemetryEvent = TelemetryEventFactory.ForIssueFilingRequest(input.RequestSource); Logger.PublishTelemetryEvent(telemetryEvent); if (IssueReporter.IsConnected) { IssueInformation issueInformation = null; try { issueInformation = input.IssueInformationProvider(); FileIssueAction.AttachIssueData(issueInformation, input.EcId, vm.Element.BoundingRectangle, vm.Element.UniqueId); IIssueResult issueResult = FileIssueAction.FileIssueAsync(issueInformation); if (issueResult != null) { vm.IssueDisplayText = issueResult.DisplayText; vm.IssueLink = issueResult.IssueLink; } } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception ex) { ex.ReportException(); } #pragma warning restore CA1031 // Do not catch general exception types finally { if (issueInformation != null && File.Exists(issueInformation.TestFileName)) { File.Delete(issueInformation.TestFileName); } } } else { bool?accepted = MessageDialog.Show(Properties.Resources.FileIssuesChooseLocation); if (accepted.HasValue && accepted.Value) { input.SwitchToServerLogin(); } } } }
/// <summary> /// Handles click on file bug button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnFileBug_Click(object sender, RoutedEventArgs e) { var vm = ((Button)sender).Tag as ScanListViewItemViewModel; if (vm.IssueLink != null) { // Bug already filed, open it in a new window try { System.Diagnostics.Process.Start(vm.IssueLink.OriginalString); } catch (Exception ex) { ex.ReportException(); // Happens when bug is deleted, message describes that work item doesn't exist / possible permission issue MessageDialog.Show(ex.InnerException?.Message); vm.IssueDisplayText = null; } } else { // File a new bug var telemetryEvent = TelemetryEventFactory.ForIssueFilingRequest(FileBugRequestSource.HowtoFix); Logger.PublishTelemetryEvent(telemetryEvent); if (IssueReporter.IsConnected) { IssueInformation issueInformation = null; try { issueInformation = vm.GetIssueInformation(); FileIssueAction.AttachIssueData(issueInformation, this.EcId, vm.Element.BoundingRectangle, vm.Element.UniqueId); IIssueResult issueResult = FileIssueAction.FileIssueAsync(issueInformation); if (issueResult != null) { vm.IssueDisplayText = issueResult.DisplayText; vm.IssueLink = issueResult.IssueLink; } } catch (Exception ex) { ex.ReportException(); } finally { if (issueInformation != null && File.Exists(issueInformation.TestFileName)) { File.Delete(issueInformation.TestFileName); } } } else { bool?accepted = MessageDialog.Show(Properties.Resources.ScannerResultControl_btnFileBug_Click_File_Issue_Configure); if (accepted.HasValue && accepted.Value) { SwitchToServerLogin(); } } } }