Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        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());
            }
        }