private void SuggestionsList_SelectionChanged(object sender, SelectionChangedEventArgs e) { ListView listview = (ListView)sender; _viewModel.Results.SelectedItem = (ResultViewModel)listview.SelectedItem; if (e.AddedItems.Count > 0 && e.AddedItems[0] != null) { try { listview.ScrollIntoView(e.AddedItems[0]); } catch (ArgumentOutOfRangeException ex) { // Due to virtualization being enabled for the listview, the layout system updates elements in a deferred manner using an algorithm that balances performance and concurrency. // Hence, there can be a situation where the element index that we want to scroll into view is out of range for it's parent control. // To mitigate this we use the UpdateLayout function, which forces layout update to ensure that the parent element contains the latest properties. // However, it has a performance impact and is therefore not called each time. Log.Exception("The parent element layout is not updated yet", ex, GetType()); listview.UpdateLayout(); listview.ScrollIntoView(e.AddedItems[0]); } } // To populate the AutoCompleteTextBox as soon as the selection is changed or set. // Setting it here instead of when the text is changed as there is a delay in executing the query and populating the result if (_viewModel.Results != null) { SearchBox.AutoCompleteTextBlock.Text = MainViewModel.GetAutoCompleteText( _viewModel.Results.SelectedIndex, _viewModel.Results.SelectedItem?.SearchBoxDisplayText(), _viewModel.QueryText); } }
private void SendSettingsTelemetry() { Log.Info("Send Run settings telemetry", this.GetType()); var plugins = PluginManager.AllPlugins.ToDictionary(x => x.Metadata.Name, x => new PluginModel() { Disabled = x.Metadata.Disabled, ActionKeyword = x.Metadata.ActionKeyword, IsGlobal = x.Metadata.IsGlobal, }); var telemetryEvent = new RunPluginsSettingsEvent(plugins); PowerToysTelemetry.Log.WriteEvent(telemetryEvent); }
private void SendSettingsTelemetry() { try { Log.Info("Send Run settings telemetry", this.GetType()); var plugins = PluginManager.AllPlugins.ToDictionary(x => x.Metadata.Name + " " + x.Metadata.ID, x => new PluginModel() { ID = x.Metadata.ID, Name = x.Metadata.Name, Disabled = x.Metadata.Disabled, ActionKeyword = x.Metadata.ActionKeyword, IsGlobal = x.Metadata.IsGlobal, }); var telemetryEvent = new RunPluginsSettingsEvent(plugins); PowerToysTelemetry.Log.WriteEvent(telemetryEvent); } catch (Exception ex) { Log.Exception("Unhandled exception when trying to send PowerToys Run settings telemetry.", ex, GetType()); } }
#pragma warning disable CA1801 // Review unused parameters public IntPtr ProcessWindowMessages(IntPtr hwnd, int msg, IntPtr wparam, IntPtr lparam, ref bool handled) #pragma warning restore CA1801 // Review unused parameters { switch ((WM)msg) { case WM.SETTINGCHANGE: string changeType = Marshal.PtrToStringUni(lparam); if (changeType == EnvironmentChangeType) { Log.Info("Reload environment: Updating environment variables for PT Run's process", typeof(EnvironmentHelper)); EnvironmentHelper.UpdateEnvironment(); handled = true; } break; case WM.HOTKEY: handled = _viewModel.ProcessHotKeyMessages(wparam, lparam); break; } return(IntPtr.Zero); }