PowerSwitcher | Power plan switcher for Windows

 by   petrroll C# Version: Current License: MIT

kandi X-RAY | PowerSwitcher Summary

kandi X-RAY | PowerSwitcher Summary

PowerSwitcher is a C# library. PowerSwitcher has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can download it from GitHub.

Power plan switcher for Windows 10. Heavily inspired by EarTrumpet.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              PowerSwitcher has a low active ecosystem.
              It has 232 star(s) with 44 fork(s). There are 12 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 21 open issues and 13 have been closed. On average issues are closed in 69 days. There are 2 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of PowerSwitcher is current.

            kandi-Quality Quality

              PowerSwitcher has 0 bugs and 0 code smells.

            kandi-Security Security

              PowerSwitcher has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              PowerSwitcher code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              PowerSwitcher is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              PowerSwitcher releases are not available. You will need to build from source code and install.
              PowerSwitcher saves you 14 person hours of effort in developing the same functionality from scratch.
              It has 41 lines of code, 0 functions and 31 files.
              It has low code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of PowerSwitcher
            Get all kandi verified functions for this library.

            PowerSwitcher Key Features

            No Key Features are available at this moment for PowerSwitcher.

            PowerSwitcher Examples and Code Snippets

            No Code Snippets are available at this moment for PowerSwitcher.

            Community Discussions

            QUESTION

            Remove selection when selected item gets deleted from ListBox
            Asked 2017-Mar-19 at 11:49

            I have a ListBox that has its ItemsSource bound to a custom class that (properly) implements an INotifyCollectionChanged and a SelectedItem bound to a field in a ViewModel.

            The problem is that when I remove a currently SelectedItem from the ItemsSource collection it immediately changes the selection to an neighboring item. I would very much prefer if it just removed selection.

            The reason why it's such a problem for me is following. The ItemsSource class contains elements from some other collection that either satisfy some (during runtime constant) Predicate or are Active. Being Active is "synchronized" with being SelectedItem (there're reasons for that). So it's very much possible for an item be allowed in the ListBox only if it's selected which means it might be supposed to vanish when user selects some other one.

            My function (deep in "model") that gets called when SelectedItem gets changed:

            ...

            ANSWER

            Answered 2017-Mar-19 at 11:49
            Diagnosis

            The key to your problems is that you set IsSynchronizedWithCurrentItem="True" on your ListBox. What it does is it keeps the ListBox.SelectedItem and ListBox.Items.CurrentItem in sync. Also, ListBox.Items.CurrentItem is synchronized with the ICollectionView.CurrentItem property of the default collection view for the source collection (this view is returned by CollectionViewSource.GetDefaultView(Schemas) in your case). Now when you remove an item from the Schemas collection which also happens to be the CurrentItem of the corresponding collection view, the view by default updates its CurrentItem to the next item (or the previous one if the removed item was the last one, or to null if the removed item was the only item in the collection).

            The second part of the problem is that when the ListBox.SelectedItem is changed causing an update to your view-model property, your RaisePropertyChangedEvent(nameof(ActiveSchema)) is processed after the update process is finished, in particular after the control is returned from the ActiveSchema setter. You can observe that the getter is not hit immediately, but only after the setter is done. What's important, the CurrentItem of the Schemas view is also not updated immediately to reflect the newly selected item. On the other hand, when you set IsActive = false on the previously selected item, it causes immediate "removal" of this item from the Schemas collection, which in turn causes an update of the CurrentItem of the collection view, and the chain immediately continues to update the ListBox.SelectedItem. You can observe that at this point the ActiveSchema setter will be hit again. So your ActiveSchema will be changed again (to the item next to the previously selected one) even before you've finished processing the previous change (to the item selected by the user).

            Solution

            There are several ways to address this issue:

            #1

            Set the IsSynchronizedWithCurrentItem="False" on your ListBox (or leave it untouched). This will make your problem go away with no effort. If however for some reason it is required, use any of the other solutions.

            #2

            Prevent reentrant attempts to set the ActiveSchema by using a guard flag:

            Source https://stackoverflow.com/questions/42703092

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install PowerSwitcher

            You can download it from GitHub.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/petrroll/PowerSwitcher.git

          • CLI

            gh repo clone petrroll/PowerSwitcher

          • sshUrl

            git@github.com:petrroll/PowerSwitcher.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link