Beispiel #1
0
        //-------------------------------------------------------------------------------
        //
        // Internal Methods
        //
        //-------------------------------------------------------------------------------

        #region Internal Methods

        /// <summary>
        /// Register the weak references for HighContrastCallback
        /// </summary>
        /// <param name="highContrastCallback"></param>
        internal static void RegisterHighContrastCallback(HighContrastCallback highContrastCallback)
        {
            lock ( __lock )
            {
                int count = __highContrastCallbackList.Count;
                int i     = 0;
                int j     = 0;

                // Every 100 items, We go through the list to remove the references
                // which have been collected by GC.
                if (__increaseCount > CleanTolerance)
                {
                    while (i < count)
                    {
                        WeakReference weakRef = __highContrastCallbackList[j];
                        if (weakRef.IsAlive)
                        {
                            j++;
                        }
                        else
                        {
                            // Remove the unavaliable reference from the list
                            __highContrastCallbackList.RemoveAt(j);
                        }
                        i++;
                    }

                    // Reset the count
                    __increaseCount = 0;
                }

                __highContrastCallbackList.Add(new WeakReference(highContrastCallback));
                __increaseCount++;
            }
        }
Beispiel #2
0
        // Token: 0x06006D74 RID: 28020 RVA: 0x001F6C54 File Offset: 0x001F4E54
        private static void UpdateHighContrast()
        {
            object _lock = HighContrastHelper.__lock;

            lock (_lock)
            {
                int count = HighContrastHelper.__highContrastCallbackList.Count;
                int i     = 0;
                int num   = 0;
                while (i < count)
                {
                    WeakReference weakReference = HighContrastHelper.__highContrastCallbackList[num];
                    if (weakReference.IsAlive)
                    {
                        HighContrastCallback highContrastCallback = weakReference.Target as HighContrastCallback;
                        if (highContrastCallback.Dispatcher != null)
                        {
                            highContrastCallback.Dispatcher.BeginInvoke(DispatcherPriority.Background, new HighContrastHelper.UpdateHighContrastCallback(HighContrastHelper.OnUpdateHighContrast), highContrastCallback);
                        }
                        else
                        {
                            HighContrastHelper.OnUpdateHighContrast(highContrastCallback);
                        }
                        num++;
                    }
                    else
                    {
                        HighContrastHelper.__highContrastCallbackList.RemoveAt(num);
                    }
                    i++;
                }
                HighContrastHelper.__increaseCount = 0;
            }
        }
Beispiel #3
0
        // Token: 0x06006D72 RID: 28018 RVA: 0x001F6BA0 File Offset: 0x001F4DA0
        internal static void RegisterHighContrastCallback(HighContrastCallback highContrastCallback)
        {
            object _lock = HighContrastHelper.__lock;

            lock (_lock)
            {
                int count = HighContrastHelper.__highContrastCallbackList.Count;
                int i     = 0;
                int num   = 0;
                if (HighContrastHelper.__increaseCount > 100)
                {
                    while (i < count)
                    {
                        WeakReference weakReference = HighContrastHelper.__highContrastCallbackList[num];
                        if (weakReference.IsAlive)
                        {
                            num++;
                        }
                        else
                        {
                            HighContrastHelper.__highContrastCallbackList.RemoveAt(num);
                        }
                        i++;
                    }
                    HighContrastHelper.__increaseCount = 0;
                }
                HighContrastHelper.__highContrastCallbackList.Add(new WeakReference(highContrastCallback));
                HighContrastHelper.__increaseCount++;
            }
        }
Beispiel #4
0
        // Token: 0x06006D75 RID: 28021 RVA: 0x001F6D14 File Offset: 0x001F4F14
        private static void OnUpdateHighContrast(HighContrastCallback highContrastCallback)
        {
            bool  highContrast    = SystemParameters.HighContrast;
            Color windowTextColor = SystemColors.WindowTextColor;

            if (highContrast)
            {
                highContrastCallback.TurnHighContrastOn(windowTextColor);
                return;
            }
            highContrastCallback.TurnHighContrastOff();
        }
Beispiel #5
0
        /// <summary>
        /// Invoke the callback
        /// </summary>
        /// <param name="highContrastCallback"></param>
        private static void OnUpdateHighContrast(HighContrastCallback highContrastCallback)
        {
            // Get the current setting.
            bool  isHighContrast  = SystemParameters.HighContrast;
            Color windowTextColor = SystemColors.WindowTextColor;

            if (isHighContrast)
            {
                highContrastCallback.TurnHighContrastOn(windowTextColor);
            }
            else
            {
                highContrastCallback.TurnHighContrastOff();
            }
        }
Beispiel #6
0
        //-------------------------------------------------------------------------------
        //
        // Private Methods
        //
        //-------------------------------------------------------------------------------

        #region Private Methods

        /// <summary>
        /// UpdateHighContrast which calls out all the registered callbacks.
        /// </summary>
        private static void UpdateHighContrast()
        {
            lock ( __lock )
            {
                int count = __highContrastCallbackList.Count;
                int i     = 0;
                int j     = 0;

                // Now go through the list,
                // And we will notify the alive callbacks
                // or remove the references which have been collected by GC.
                while (i < count)
                {
                    WeakReference weakRef = __highContrastCallbackList[j];
                    if (weakRef.IsAlive)
                    {
                        HighContrastCallback highContrastCallback = weakRef.Target as HighContrastCallback;

                        if (highContrastCallback.Dispatcher != null)
                        {
                            highContrastCallback.Dispatcher.BeginInvoke(DispatcherPriority.Background,
                                                                        new UpdateHighContrastCallback(OnUpdateHighContrast),
                                                                        highContrastCallback);
                        }
                        else
                        {
                            OnUpdateHighContrast(highContrastCallback);
                        }

                        j++;
                    }
                    else
                    {
                        // Remove the dead ones
                        __highContrastCallbackList.RemoveAt(j);
                    }
                    i++;
                }

                // Reset the count
                __increaseCount = 0;
            }
        }
        //--------------------------------------------------------------------------------
        // 
        // Internal Methods 
        //
        //------------------------------------------------------------------------------- 

        #region Internal Methods

        /// <summary> 
        /// Register the weak references for HighContrastCallback
        /// </summary> 
        /// <param name="highContrastCallback"></param> 
        internal static void RegisterHighContrastCallback(HighContrastCallback highContrastCallback)
        { 
            lock ( __lock )
            {
                int count = __highContrastCallbackList.Count;
                int i = 0; 
                int j = 0;
 
                // Every 100 items, We go through the list to remove the references 
                // which have been collected by GC.
                if ( __increaseCount > CleanTolerance ) 
                {
                    while ( i < count )
                    {
                        WeakReference weakRef = __highContrastCallbackList[j]; 
                        if ( weakRef.IsAlive )
                        { 
                            j++; 
                        }
                        else 
                        {
                            // Remove the unavaliable reference from the list
                            __highContrastCallbackList.RemoveAt(j);
                        } 
                        i++;
                    } 
 
                    // Reset the count
                    __increaseCount = 0; 
                }

                __highContrastCallbackList.Add(new WeakReference(highContrastCallback));
                __increaseCount++; 
            }
        } 
        /// <summary> 
        /// Invoke the callback
        /// </summary> 
        /// <param name="highContrastCallback"></param> 
        private static void OnUpdateHighContrast(HighContrastCallback highContrastCallback)
        { 
            // Get the current setting.
            bool isHighContrast = SystemParameters.HighContrast;
            Color windowTextColor = SystemColors.WindowTextColor;
 
            if ( isHighContrast )
            { 
                highContrastCallback.TurnHighContrastOn(windowTextColor); 
            }
            else 
            {
                highContrastCallback.TurnHighContrastOff();
            }
        }