diff --git a/GUI/App.config b/GUI/App.config
index ed196aa8..cf87cecf 100644
--- a/GUI/App.config
+++ b/GUI/App.config
@@ -91,6 +91,9 @@
+
+ False
+
diff --git a/GUI/ImagePreview.cs b/GUI/ImagePreview.cs
index 2cb797dd..df722758 100644
--- a/GUI/ImagePreview.cs
+++ b/GUI/ImagePreview.cs
@@ -2,7 +2,7 @@
//! \date Sun Jul 06 06:34:56 2014
//! \brief preview images.
//
-// Copyright (C) 2014-2015 by morkt
+// Copyright (C) 2014-2018 by morkt
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
@@ -259,6 +259,7 @@ namespace GARbro.GUI
{
ActiveViewer = ImageView;
ImageCanvas.Source = bitmap;
+ ApplyDownScaleSetting();
SetStatusText (string.Format (guiStrings.MsgImageSize, bitmap.PixelWidth,
bitmap.PixelHeight, bitmap.Format.BitsPerPixel));
}
@@ -289,5 +290,42 @@ namespace GARbro.GUI
}, DispatcherPriority.ContextIdle);
}
}
+
+ private void SetImageScaleMode (bool scale)
+ {
+ if (scale)
+ {
+ ImageCanvas.Stretch = Stretch.Uniform;
+ RenderOptions.SetBitmapScalingMode (ImageCanvas, BitmapScalingMode.HighQuality);
+ ImageView.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled;
+ ImageView.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
+ }
+ else
+ {
+ ImageCanvas.Stretch = Stretch.None;
+ RenderOptions.SetBitmapScalingMode (ImageCanvas, BitmapScalingMode.NearestNeighbor);
+ ImageView.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
+ ImageView.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
+ }
+ }
+
+ private void ApplyDownScaleSetting ()
+ {
+ bool image_need_scale = DownScaleImage.Get();
+ if (image_need_scale && ImageCanvas.Source != null)
+ {
+ var image = ImageCanvas.Source;
+ image_need_scale = image.Width > ImageView.ActualWidth || image.Height > ImageView.ActualHeight;
+ }
+ SetImageScaleMode (image_need_scale);
+ }
+
+ private void PreviewSizeChanged (object sender, SizeChangedEventArgs e)
+ {
+ var image = ImageCanvas.Source;
+ if (null == image || !DownScaleImage.Get())
+ return;
+ SetImageScaleMode (image.Width > e.NewSize.Width || image.Height > e.NewSize.Height);
+ }
}
}
diff --git a/GUI/MainWindow.xaml b/GUI/MainWindow.xaml
index b3b24bff..68824a02 100644
--- a/GUI/MainWindow.xaml
+++ b/GUI/MainWindow.xaml
@@ -360,7 +360,8 @@
-
+
diff --git a/GUI/MainWindow.xaml.cs b/GUI/MainWindow.xaml.cs
index 868e7050..3c164448 100644
--- a/GUI/MainWindow.xaml.cs
+++ b/GUI/MainWindow.xaml.cs
@@ -56,6 +56,8 @@ namespace GARbro.GUI
public App App { get { return m_app; } }
+ internal static readonly GuiResourceSetting DownScaleImage = new GuiResourceSetting ("winDownScaleImage");
+
const StringComparison StringIgnoreCase = StringComparison.CurrentCultureIgnoreCase;
public MainWindow()
@@ -82,6 +84,7 @@ namespace GARbro.GUI
this.MinWidth = e.NewSize.Width+79;
}
};
+ DownScaleImage.PropertyChanged += (s, e) => ApplyDownScaleSetting();
pathLine.EnterKeyDown += acb_OnKeyDown;
}
diff --git a/GUI/Properties/Settings.Designer.cs b/GUI/Properties/Settings.Designer.cs
index cad07ed5..6f9fc681 100644
--- a/GUI/Properties/Settings.Designer.cs
+++ b/GUI/Properties/Settings.Designer.cs
@@ -357,5 +357,17 @@ namespace GARbro.GUI.Properties {
this["appLastDestination"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("False")]
+ public bool winDownScaleImage {
+ get {
+ return ((bool)(this["winDownScaleImage"]));
+ }
+ set {
+ this["winDownScaleImage"] = value;
+ }
+ }
}
}
diff --git a/GUI/Properties/Settings.settings b/GUI/Properties/Settings.settings
index 0a8838d0..0ce873c8 100644
--- a/GUI/Properties/Settings.settings
+++ b/GUI/Properties/Settings.settings
@@ -86,5 +86,8 @@
+
+ False
+
\ No newline at end of file
diff --git a/GUI/SettingsWindow.xaml.cs b/GUI/SettingsWindow.xaml.cs
index 5ef445eb..e7e1ca98 100644
--- a/GUI/SettingsWindow.xaml.cs
+++ b/GUI/SettingsWindow.xaml.cs
@@ -33,6 +33,7 @@ using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using GameRes;
+using GARbro.GUI.Properties;
using GARbro.GUI.Strings;
namespace GARbro.GUI
@@ -54,6 +55,10 @@ namespace GARbro.GUI
};
}
+ static readonly IEnumerable ViewerSettings = new [] {
+ MainWindow.DownScaleImage,
+ };
+
SettingsViewModel ViewModel;
static string LastSelectedSection = null;
@@ -82,17 +87,20 @@ namespace GARbro.GUI
if (!ViewModel.HasChanges)
return;
if (OnApplyChanges != null)
- OnApplyChanges (this, new EventArgs());
+ OnApplyChanges (this, EventArgs.Empty);
ViewModel.HasChanges = false;
}
private SettingsViewModel CreateSettingsTree ()
{
SettingsSectionView[] list = {
+ new SettingsSectionView {
+ Label = guiStrings.TextViewer,
+ Panel = CreateSectionPanel (ViewerSettings)
+ },
new SettingsSectionView {
Label = guiStrings.TextFormats,
Children = EnumerateFormatsSettings(),
- Panel = (UIElement)this.Resources["FormatsPanel"]
},
};
SettingsSectionView selected_section = null;
@@ -110,13 +118,7 @@ namespace GARbro.GUI
var formats = FormatCatalog.Instance.Formats.Where (f => f.Settings != null && f.Settings.Any());
foreach (var format in formats.OrderBy (f => f.Tag))
{
- var pane = new WrapPanel();
- foreach (var setting in format.Settings)
- {
- var widget = CreateSettingWidget (setting, setting.Value as dynamic);
- if (widget != null)
- pane.Children.Add (widget);
- }
+ var pane = CreateSectionPanel (format.Settings);
if (pane.Children.Count > 0)
{
var section = new SettingsSectionView {
@@ -130,7 +132,19 @@ namespace GARbro.GUI
return list;
}
- UIElement CreateSettingWidget (IResourceSetting setting, bool value)
+ Panel CreateSectionPanel (IEnumerable settings)
+ {
+ var pane = new WrapPanel();
+ foreach (var setting in settings)
+ {
+ var widget = CreateSettingWidget (setting, setting.Value);
+ if (widget != null)
+ pane.Children.Add (widget);
+ }
+ return pane;
+ }
+
+ UIElement CreateCheckBoxWidget (IResourceSetting setting)
{
return new CheckBox {
Template = (ControlTemplate)this.Resources["BoundCheckBox"],
@@ -138,7 +152,7 @@ namespace GARbro.GUI
};
}
- UIElement CreateSettingWidget (IResourceSetting setting, Encoding value)
+ UIElement CreateEncodingWidget (IResourceSetting setting)
{
var view = CreateSettingView (setting);
// XXX make a control template in XAML instead
@@ -169,6 +183,10 @@ namespace GARbro.GUI
UIElement CreateSettingWidget (IResourceSetting setting, TUnknown value)
{
+ if (value is bool)
+ return CreateCheckBoxWidget (setting);
+ if (value is Encoding)
+ return CreateEncodingWidget (setting);
Trace.WriteLine (string.Format ("Unknown setting type {0}", value.GetType()), "[GUI]");
return null;
}
@@ -348,4 +366,36 @@ namespace GARbro.GUI
throw new System.NotImplementedException();
}
}
+
+ internal class GuiResourceSetting : ResourceSettingBase, INotifyPropertyChanged
+ {
+ public override object Value {
+ get { return Settings.Default[Name]; }
+ set {
+ if (!Settings.Default[Name].Equals (value))
+ {
+ Settings.Default[Name] = value;
+ OnPropertyChanged();
+ }
+ }
+ }
+
+ public GuiResourceSetting () { }
+
+ public GuiResourceSetting (string name)
+ {
+ Name = name;
+ Text = guiStrings.ResourceManager.GetString (name, guiStrings.Culture) ?? name;
+ }
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ void OnPropertyChanged ([CallerMemberName] string propertyName = "")
+ {
+ if (PropertyChanged != null)
+ {
+ PropertyChanged (this, new PropertyChangedEventArgs (propertyName));
+ }
+ }
+ }
}
diff --git a/GUI/Strings/guiStrings.Designer.cs b/GUI/Strings/guiStrings.Designer.cs
index 4e6eec1a..00d6f2fa 100644
--- a/GUI/Strings/guiStrings.Designer.cs
+++ b/GUI/Strings/guiStrings.Designer.cs
@@ -1273,6 +1273,15 @@ namespace GARbro.GUI.Strings {
}
}
+ ///
+ /// Looks up a localized string similar to Image viewer.
+ ///
+ public static string TextViewer {
+ get {
+ return ResourceManager.GetString("TextViewer", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Visit download page.
///
@@ -1326,5 +1335,14 @@ namespace GARbro.GUI.Strings {
return ResourceManager.GetString("Type_NONE", resourceCulture);
}
}
+
+ ///
+ /// Looks up a localized string similar to Scale large images to fit window.
+ ///
+ public static string winDownScaleImage {
+ get {
+ return ResourceManager.GetString("winDownScaleImage", resourceCulture);
+ }
+ }
}
}
diff --git a/GUI/Strings/guiStrings.ja-JP.resx b/GUI/Strings/guiStrings.ja-JP.resx
index 34d395e3..83838d49 100644
--- a/GUI/Strings/guiStrings.ja-JP.resx
+++ b/GUI/Strings/guiStrings.ja-JP.resx
@@ -691,4 +691,10 @@ Overwrite?
環境設定
Preferences
+
+ Image viewer
+
+
+ Scale large images to fit window
+
\ No newline at end of file
diff --git a/GUI/Strings/guiStrings.ko-KR.resx b/GUI/Strings/guiStrings.ko-KR.resx
index 981880dd..e68f1af0 100644
--- a/GUI/Strings/guiStrings.ko-KR.resx
+++ b/GUI/Strings/guiStrings.ko-KR.resx
@@ -561,4 +561,12 @@
script
translation pending
+
+ Image viewer
+ translation pending
+
+
+ Scale large images to fit window
+ translation pending
+
\ No newline at end of file
diff --git a/GUI/Strings/guiStrings.resx b/GUI/Strings/guiStrings.resx
index 8ac0b4ad..2ae74247 100644
--- a/GUI/Strings/guiStrings.resx
+++ b/GUI/Strings/guiStrings.resx
@@ -545,4 +545,10 @@ Overwrite?
Preferences
+
+ Image viewer
+
+
+ Scale large images to fit window
+
\ No newline at end of file
diff --git a/GUI/Strings/guiStrings.ru-RU.resx b/GUI/Strings/guiStrings.ru-RU.resx
index 5a29f3ac..f029b16c 100644
--- a/GUI/Strings/guiStrings.ru-RU.resx
+++ b/GUI/Strings/guiStrings.ru-RU.resx
@@ -566,4 +566,10 @@
Настройки
+
+ Просмотр
+
+
+ Масштабировать большие изображения
+
\ No newline at end of file
diff --git a/GUI/Strings/guiStrings.zh-Hans.resx b/GUI/Strings/guiStrings.zh-Hans.resx
index 93b24d3e..e5242e31 100644
--- a/GUI/Strings/guiStrings.zh-Hans.resx
+++ b/GUI/Strings/guiStrings.zh-Hans.resx
@@ -562,4 +562,12 @@
script
translation pending
+
+ Image viewer
+ translation pending
+
+
+ Scale large images to fit window
+ translation pending
+
\ No newline at end of file