Exemplo n.º 1
0
 private void PreloadDisabledImages()
 {
     foreach (object obj in Resources.Values)
     {
         ImageSource imageSource = (obj as ImageSource);
         if (null != imageSource)
         {
             AutoDisableImage.LoadImage(imageSource);
         }
     }
 }
Exemplo n.º 2
0
        protected static void OnAutoDisableImageIsEnabledPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs args)
        {
            AutoDisableImage image = GetImageWithSource(source);

            if (null != image)
            {
                bool isEnabled = Convert.ToBoolean(args.NewValue);

                image.Source      = isEnabled ? image.OriginalImageSource : image.DisabledImageSource;
                image.Opacity     = isEnabled ? 1.0 : 0.5;
                image.OpacityMask = isEnabled ? null : new ImageBrush(image.OriginalImageSource);
            }
        }
Exemplo n.º 3
0
        protected static AutoDisableImage GetImageWithSource(DependencyObject source)
        {
            AutoDisableImage image = source as AutoDisableImage;

            if (null == image)
            {
                return(null);
            }

            if (null == image.Source)
            {
                return(null);
            }

            return(image);
        }