internal void OnDataChanged() { var c = (MessagePiece)DataContext; var isDg = MapDatabase.GetDungeon(c.Location); if (mapImg.Source == null) { return; } var ratio = mapImg.Source.Width / mapImg.Source.Height; if (isDg && ratio != 1) { mapImg.Height = mapImg.ActualWidth / ratio; if (mapImg.Height == 0) { mapImg.Height = (double)App.Current.FindResource("MapWidth") / ratio; } mapImg.Stretch = Stretch.Uniform; } else if (ratio == 1 && !isDg) { mapImg.Height = (double)App.Current.FindResource("MapHeight"); mapImg.Stretch = Stretch.UniformToFill; } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var loc = (Location)value; if (MapDatabase.GetDungeon(loc)) { return(Stretch.Uniform); } else { return(Stretch.UniformToFill); } }