Skip to content

Instantly share code, notes, and snippets.

@mrlacey
Last active November 17, 2020 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrlacey/06e037831e69238ffc5dcc44066de699 to your computer and use it in GitHub Desktop.
Save mrlacey/06e037831e69238ffc5dcc44066de699 to your computer and use it in GitHub Desktop.
FestiveEditor - 12
internal sealed class FestiveImageAdornment : System.Windows.Controls.Image
{
internal FestiveImageAdornment(FestiveImageTag tag)
{
this.FestiveImageTag = tag;
this.SetSource(this.FestiveImageTag.Term);
this.Height = 20;
this.Width = 20;
}
public FestiveImageTag FestiveImageTag { get; private set; }
internal void Update(FestiveImageTag dataTag)
{
this.FestiveImageTag = dataTag;
this.SetSource(this.FestiveImageTag.Term);
}
internal void SetSource(string term)
{
switch (term.Trim().Length)
{
case 3:
this.Source = GetImagePath("present.png");
break;
case 4:
this.Source = GetImagePath("tree.png");
break;
case 5:
this.Source = GetImagePath("snowflake.png");
break;
case 6:
this.Source = GetImagePath("snowman.png");
break;
case 7:
default:
this.Source = GetImagePath("santa.png");
break;
}
}
private BitmapImage GetImagePath(string imageFileName)
{
return new BitmapImage(
new Uri(
Path.Combine(
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
"Images",
imageFileName)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment