Example #1
0
 /// <summary>
 /// When overriden in a class, this method provides means to run code whenever a <see cref="DependencyProperty"/> has changed
 /// </summary>
 /// <param name="propertyName">The case sensitive name of the modified property</param>
 /// <param name="originalValue">An object representing the property's value before the suffered change(s)</param>
 /// <param name="value">An object representing the property's actual (new) value</param>
 protected override void OnPropertyChanged(string propertyName, object originalValue, object value)
 {
     base.OnPropertyChanged(propertyName, originalValue, value);
     if (propertyName == ImageBrush.ImageProperty.Name)
     {
         if (this.Texture != null)
         {
             this.Texture.Dispose();
         }
         if (value != null)
         {
             this.Texture = Texture.FromBitmap((Bitmap)value);
         }
         return;
     }
 }
Example #2
0
 /// <summary>
 /// Returns a <see cref="Texture"/> based on the specified <see cref="Bitmap"/>
 /// </summary>
 /// <param name="bitmap">The <see cref="Bitmap"/> to create a <see cref="Texture"/> from</param>
 /// <returns>The loaded <see cref="Texture"/></returns>
 public static Texture FromBitmap(Bitmap bitmap)
 {
     Texture texture;
     texture = new Texture(bitmap);
     return texture;
 }