Example #1
0
 private void SystemEvents_UserPreferenceChanging(object sender, UserPreferenceChangingEventArgs e)
 {
     if (e.Category == UserPreferenceCategory.General)
     {
         EnableOrDisableBasedOnState();
     }
 }
Example #2
0
 public static void SystemEvents_UserPreferenceChanging(object sender, UserPreferenceChangingEventArgs e)
 {
     if (Settings.autodark)
     {
         RefreshColorSceme();
     }
 }
Example #3
0
 public void PreferenceChangedHandler(object sender, UserPreferenceChangingEventArgs e)
 {
     if (e.Category.ToString() == dsk || e.Category.ToString() == colour)
     {
         Restart();
     }
 }
Example #4
0
 private static void OnUserPreferenceChanging(object sender, UserPreferenceChangingEventArgs e)
 {
     if (e.Category == UserPreferenceCategory.Color && colorTable != null)
     {
         UpdateSystemColors(colorTable);
     }
 }
Example #5
0
 private static void OnUserPreferenceChanging(object sender, UserPreferenceChangingEventArgs ea)
 {
     if (ea.Category == UserPreferenceCategory.VisualStyle)
     {
         globalCacheVersion += 1L;
     }
 }
Example #6
0
 static void SystemEvents_UserPreferenceChanging(object sender, UserPreferenceChangingEventArgs e)
 {
     if (e.Category == UserPreferenceCategory.General || e.Category == UserPreferenceCategory.Color)
     {
         Refresh();
     }
 }
Example #7
0
 private static void OnUserPreferenceChanging(object sender, UserPreferenceChangingEventArgs e)
 {
     if (e.Category != UserPreferenceCategory.Color || KnownColorTable.colorTable == null)
     {
         return;
     }
     KnownColorTable.UpdateSystemColors(KnownColorTable.colorTable);
 }
 private void OnUserPreferenceChanging(object sender, UserPreferenceChangingEventArgs e)
 {
     if (e.Category == UserPreferenceCategory.Color ||
         e.Category == UserPreferenceCategory.VisualStyle)
     {
         SetTheme();
     }
 }
Example #9
0
        private void userPreferenceChanging(object sender, UserPreferenceChangingEventArgs e)
        {
            if (e.Category != UserPreferenceCategory.Color)
            {
                return;
            }

            _colorTable = readColorTable();
            fireColorsChangedEvents();
        }
        public void SignalsUserPreferenceEventsAsynchronouslyOnThemeChanged()
        {
            var changing = new AutoResetEvent(false);
            var changed  = new AutoResetEvent(false);

            UserPreferenceChangingEventArgs    changingArgs    = null;
            UserPreferenceChangingEventHandler changingHandler = (o, e) =>
            {
                changingArgs = e;
                changing.Set();
            };

            List <UserPreferenceChangedEventArgs> changedArgs           = new List <UserPreferenceChangedEventArgs>();
            UserPreferenceChangingEventArgs       changingDuringChanged = null;
            UserPreferenceChangedEventHandler     changedHandler        = (o, e) =>
            {
                changedArgs.Add(e);
                changingDuringChanged = changingArgs;
                // signal test to continue after two events were recieved
                if (changedArgs.Count > 1)
                {
                    changed.Set();
                }
            };

            SystemEvents.UserPreferenceChanging += changingHandler;
            SystemEvents.UserPreferenceChanged  += changedHandler;

            try
            {
                SendMessage(User32.WM_THEMECHANGED, 0, null);
                Assert.True(changing.WaitOne(PostMessageWait));
                Assert.NotNull(changingArgs);
                Assert.Equal(UserPreferenceCategory.VisualStyle, changingArgs.Category);

                Assert.True(changed.WaitOne(PostMessageWait));
                Assert.Equal(2, changedArgs.Count);
                Assert.NotNull(changedArgs[0]);
                Assert.Equal(UserPreferenceCategory.Window, changedArgs[0].Category);
                Assert.NotNull(changedArgs[1]);
                Assert.Equal(UserPreferenceCategory.VisualStyle, changedArgs[1].Category);

                // changed must follow changing for VisualStyle
                Assert.NotNull(changingDuringChanged);
                Assert.Equal(UserPreferenceCategory.VisualStyle, changingDuringChanged.Category);
            }
            finally
            {
                SystemEvents.UserPreferenceChanging -= changingHandler;
                SystemEvents.UserPreferenceChanged  -= changedHandler;
                changing.Dispose();
                changed.Dispose();
            }
        }
Example #11
0
 private void SystemEvents_UserPreferenceChanging(object sender, UserPreferenceChangingEventArgs e)
 {
     Graphix.UpdatePanelColor(panel8, Graphix.GetAccentColor());
     foreach (Control item in panel6.Controls)
     {
         if (item is Panel)
         {
             Panel p = (Panel)item;
             Graphix.UpdateColor(p, Graphix.GetAccentColor());
         }
     }
 }
        private static void UserPreferenceChanging(object obj, UserPreferenceChangingEventArgs e)
        {
            s_highContrastSettingValid = false;
            s_lowResSettingValid       = false;
            s_dropShadowSettingValid   = false;
            s_bitsPerPixel             = 0;

            if (e.Category == UserPreferenceCategory.General)
            {
                s_menuAccessKeysUnderlinedValid = false;
            }
        }
Example #13
0
        /// <summary>
        ///  Handles the ThemeChanged event. Basically, we need to ensure all per-thread theme handle
        ///  caches are refreshed.
        /// </summary>
        private static void OnUserPreferenceChanging(object sender, UserPreferenceChangingEventArgs ea)
        {
            if (ea.Category == UserPreferenceCategory.VisualStyle)
            {
                // Let all threads know their cached handles are no longer valid;
                // cache refresh will happen at next handle access.
                // Note that if the theme changes 2^sizeof(long) times before a thread uses
                // its handle, this whole version check won't work, but it is unlikely to happen.

                // this is not ideal.
                globalCacheVersion++;
            }
        }
        public void SignalsUserPreferenceEventsSynchronouslyOnReflectedThemeChanged()
        {
            bool changing = false, changed = false;

            UserPreferenceChangingEventArgs    changingArgs = null;
            UserPreferenceChangingEventHandler changingHandler = (o, e) =>
            {
                changingArgs = e;
                changing     = true;
            };

            List <UserPreferenceChangedEventArgs> changedArgs = new List <UserPreferenceChangedEventArgs>();
            UserPreferenceChangingEventArgs       changingDuringChanged = null;
            UserPreferenceChangedEventHandler     changedHandler = (o, e) =>
            {
                changedArgs.Add(e);
                changingDuringChanged = changingArgs;
                changed = true;
            };

            SystemEvents.UserPreferenceChanging += changingHandler;
            SystemEvents.UserPreferenceChanged  += changedHandler;

            try
            {
                SendReflectedMessage(User32.WM_THEMECHANGED, 0, null);
                Assert.True(changing);
                Assert.NotNull(changingArgs);
                Assert.Equal(UserPreferenceCategory.VisualStyle, changingArgs.Category);

                Assert.True(changed);
                Assert.Equal(2, changedArgs.Count);
                Assert.NotNull(changedArgs[0]);
                Assert.Equal(UserPreferenceCategory.Window, changedArgs[0].Category);
                Assert.NotNull(changedArgs[1]);
                Assert.Equal(UserPreferenceCategory.VisualStyle, changedArgs[1].Category);

                // changed must follow changing for VisualStyle
                Assert.NotNull(changingDuringChanged);
                Assert.Equal(UserPreferenceCategory.VisualStyle, changingDuringChanged.Category);
            }
            finally
            {
                SystemEvents.UserPreferenceChanging -= changingHandler;
                SystemEvents.UserPreferenceChanged  -= changedHandler;
            }
        }
        public void SignalsUserPreferenceEventsAsynchronously(int message, int uiAction, string area, UserPreferenceCategory expectedCategory)
        {
            var changing = new AutoResetEvent(false);
            var changed  = new AutoResetEvent(false);

            UserPreferenceChangingEventArgs    changingArgs    = null;
            UserPreferenceChangingEventHandler changingHandler = (o, e) =>
            {
                changingArgs = e;
                changing.Set();
            };

            UserPreferenceChangedEventArgs    changedArgs           = null;
            UserPreferenceChangingEventArgs   changingDuringChanged = null;
            UserPreferenceChangedEventHandler changedHandler        = (o, e) =>
            {
                changedArgs           = e;
                changingDuringChanged = changingArgs;
                changed.Set();
            };

            SystemEvents.UserPreferenceChanging += changingHandler;
            SystemEvents.UserPreferenceChanged  += changedHandler;

            try
            {
                SendMessage(message, uiAction, area);
                Assert.True(changing.WaitOne(PostMessageWait));
                Assert.NotNull(changingArgs);
                Assert.Equal(expectedCategory, changingArgs.Category);

                Assert.True(changed.WaitOne(PostMessageWait));
                Assert.NotNull(changedArgs);
                Assert.Equal(expectedCategory, changedArgs.Category);

                // changed must follow changing for the same category
                Assert.NotNull(changingDuringChanged);
                Assert.Equal(expectedCategory, changingDuringChanged.Category);
            }
            finally
            {
                SystemEvents.UserPreferenceChanging -= changingHandler;
                SystemEvents.UserPreferenceChanged  -= changedHandler;
                changing.Dispose();
                changed.Dispose();
            }
        }
        public void SignalsUserPreferenceEventsSynchronously(int message, int uiAction, string area, UserPreferenceCategory expectedCategory)
        {
            bool changing = false, changed = false;

            UserPreferenceChangingEventArgs    changingArgs = null;
            UserPreferenceChangingEventHandler changingHandler = (o, e) =>
            {
                changingArgs = e;
                changing     = true;
            };

            UserPreferenceChangedEventArgs    changedArgs = null;
            UserPreferenceChangingEventArgs   changingDuringChanged = null;
            UserPreferenceChangedEventHandler changedHandler = (o, e) =>
            {
                changedArgs           = e;
                changingDuringChanged = changingArgs;
                changed = true;
            };

            SystemEvents.UserPreferenceChanging += changingHandler;
            SystemEvents.UserPreferenceChanged  += changedHandler;


            try
            {
                SendReflectedMessage(message, uiAction, area);
                Assert.True(changing);
                Assert.NotNull(changingArgs);
                Assert.Equal(expectedCategory, changingArgs.Category);

                Assert.True(changed);
                Assert.NotNull(changedArgs);
                Assert.Equal(expectedCategory, changedArgs.Category);

                // changed must follow changing for the same category
                Assert.NotNull(changingDuringChanged);
                Assert.Equal(expectedCategory, changingDuringChanged.Category);
            }
            finally
            {
                SystemEvents.UserPreferenceChanging -= changingHandler;
                SystemEvents.UserPreferenceChanged  -= changedHandler;
            }
        }
        private void SystemEventsOnUserPreferenceChanging(object sender, UserPreferenceChangingEventArgs userPreferenceChangingEventArgs)
        {
            switch (userPreferenceChangingEventArgs.Category)
            {
            case UserPreferenceCategory.Policy:
                this._groupPolicyRefreshDetectedLogMessage(_logger, null);

                try
                {
                    _onUserPreferenceChangingGroupPolicy?.Invoke();
                }
#pragma warning disable CA1031 // Do not catch general exception types
                catch
#pragma warning restore CA1031 // Do not catch general exception types
                {
                    // ignored
                }

                break;
            }
        }
Example #18
0
 static void SystemEvents_UserPreferenceChanging(object sender, UserPreferenceChangingEventArgs e)
 {
 }
 private void UserPreferenceChangingCallback(object o, UserPreferenceChangingEventArgs args)
 {
 }
Example #20
0
 internal void SystemEvents_UserPreferenceChanging(object sender, UserPreferenceChangingEventArgs e)
 {
     OnUserPreferenceChanging?.Invoke(sender, e);
 }
Example #21
0
        /// <summary>
        /// Extends BeginInvoke so that when a state object is not needed, null does not need to be passed.
        /// <example>
        /// userpreferencechangingeventhandler.BeginInvoke(sender, e, callback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginInvoke(this UserPreferenceChangingEventHandler userpreferencechangingeventhandler, Object sender, UserPreferenceChangingEventArgs e, AsyncCallback callback)
        {
            if (userpreferencechangingeventhandler == null)
            {
                throw new ArgumentNullException("userpreferencechangingeventhandler");
            }

            return(userpreferencechangingeventhandler.BeginInvoke(sender, e, callback, null));
        }
        public void Deny_Unrestricted()
        {
            UserPreferenceChangingEventArgs upcea = new UserPreferenceChangingEventArgs(UserPreferenceCategory.Color);

            Assert.AreEqual(UserPreferenceCategory.Color, upcea.Category, "Category");
        }
Example #23
0
    //</snippet2>

    // This method is called when a user preference changes.
    static void SystemEvents_UserPreferenceChanging(object sender, UserPreferenceChangingEventArgs e)
    {
        Console.WriteLine("The user preference is changing. Category={0}", e.Category);
    }
Example #24
0
 private void SystemEvents_UserPreferenceChanging(object sender, UserPreferenceChangingEventArgs e)
 {
     _temperatureService.ChangeScreenColorFromConfig(SelectedConfig);
 }