示例#1
0
 private void CenterImage(int width, int height)
 {
     if (width == 0 || height == 0) return;
     float ZeroFactor = 0;
     double relativeBorder = SettingStorage.ImageBoxBorder;
     if (width / height > ImageDisplay.ActualWidth / ImageDisplay.ActualHeight)
     {
         ZeroFactor = (float)(ImageDisplay.ActualWidth / (width * (1 + relativeBorder)));
     }
     else
     {
         ZeroFactor = (float)(ImageDisplay.ActualHeight / (height * (1 + relativeBorder)));
     }
     if (ZeroFactor < 0.1) ZeroFactor = 0.1f;
     else if (ZeroFactor > 1) ZeroFactor = (float)(1 - relativeBorder);
     ImageDisplay.MinZoomFactor = 0.1f;
     ImageDisplay.MaxZoomFactor = 10;
     ZoomSlider.Value = ZeroFactor;
     ImageDisplay.ChangeView(0, 0, ZeroFactor);
 }
示例#2
0
 private void Slider_ValueChanged(object sender, RangeBaseValueChangedEventArgs e)
 {
     ImageDisplay.ChangeView(null, null, (float)e.NewValue);
 }