Last active
November 17, 2020 21:10
-
-
Save mrlacey/06e037831e69238ffc5dcc44066de699 to your computer and use it in GitHub Desktop.
FestiveEditor - 12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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