Permalink
Browse files

Issue #71 Zoom enhancement

  • Loading branch information...
1 parent 723221f commit 665c6f14b9220fc85c87e2eb594db53cc9e94d9d @d2phap committed May 2, 2016
View
@@ -156,3 +156,5 @@ $RECYCLE.BIN/
.DS_Store
*.cache
*.cache
+*.cache
+Source/ImageGlass/obj/Debug/DesignTimeResolveAssemblyReferences.cache
@@ -402,11 +402,11 @@ private void InitDefaultLanguageDictionary()
this.Items.Add("frmSetting.chkLoopSlideshow", "Loop back slideshow to the first image when reaching the end of the list"); //v2.0 final
this.Items.Add("frmSetting.chkImageBoosterBack", "Turn on Image Booster when navigate back (need more ~20% RAM)"); //v2.0 final
this.Items.Add("frmSetting.chkESCToQuit", "Allow to press ESC to quit application"); //v2.0 final
- //this.Items.Add("frmSetting.lblGeneral_ZoomOptimization", "Zoom optimization:"); //removed 3.0
+ this.Items.Add("frmSetting.lblGeneral_ZoomOptimization", "Zoom optimization:"); //-3.0, +3.3
this.Items.Add("frmSetting.chkAllowMultiInstances", "Allow multiple instances of the program"); //v3.0
- //this.Items.Add("frmSetting.cmbZoomOptimization._Auto", "Auto"); //removed 3.2
- //this.Items.Add("frmSetting.cmbZoomOptimization._SmoothPixels", "Smooth pixels"); //removed 3.2
- //this.Items.Add("frmSetting.cmbZoomOptimization._ClearPixels", "Clear pixels"); //removed 3.2
+ this.Items.Add("frmSetting.cmbZoomOptimization._Auto", "Auto"); //-3.2, +3.3
+ this.Items.Add("frmSetting.cmbZoomOptimization._SmoothPixels", "Smooth pixels"); //-3.2, +3.3
+ this.Items.Add("frmSetting.cmbZoomOptimization._ClearPixels", "Clear pixels"); //-3.2, +3.3
this.Items.Add("frmSetting.lblSlideshowInterval", "Slide show interval: {0} seconds");
this.Items.Add("frmSetting.lblGeneral_MaxFileSize", "Maximum thumbnail file size (MB):");
this.Items.Add("frmSetting.lblGeneral_ThumbnailSize", "Thumbnail dimension (pixel):"); // v3.0
@@ -327,15 +327,15 @@ public static ZoomOptimizationValue ZoomOptimizationMethod
if (value == ZoomOptimizationValue.SmoothPixels)
{
- GlobalSetting.SetConfig("ZoomOptimize", "1");
+ GlobalSetting.SetConfig("ZoomOptimization", "1");
}
else if (value == ZoomOptimizationValue.ClearPixels)
{
- GlobalSetting.SetConfig("ZoomOptimize", "2");
+ GlobalSetting.SetConfig("ZoomOptimization", "2");
}
else
{
- GlobalSetting.SetConfig("ZoomOptimize", "0");
+ GlobalSetting.SetConfig("ZoomOptimization", "0");
}
}
}
@@ -624,7 +624,33 @@ private void frmMain_KeyDown(object sender, KeyEventArgs e)
#region Private functions
-
+
+ /// <summary>
+ /// Start Zoom optimization
+ /// </summary>
+ private void ZoomOptimization()
+ {
+ if (GlobalSetting.ZoomOptimizationMethod == ZoomOptimizationValue.Auto)
+ {
+ if (picMain.Zoom > 100)
+ {
+ picMain.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
+ }
+ else if (picMain.Zoom < 100)
+ {
+ picMain.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Low;
+ }
+ }
+ else if (GlobalSetting.ZoomOptimizationMethod == ZoomOptimizationValue.ClearPixels)
+ {
+ picMain.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
+ }
+ else if (GlobalSetting.ZoomOptimizationMethod == ZoomOptimizationValue.SmoothPixels)
+ {
+ picMain.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Low;
+ }
+ }
+
/// <summary>
/// Rename image
/// </summary>
@@ -1119,6 +1145,21 @@ private void LoadConfig()
GlobalSetting.IsZoomToFit = bool.Parse(GlobalSetting.GetConfig("IsZoomToFit", "False"));
mnuMainZoomToFit.Checked = GlobalSetting.IsZoomToFit;
+ //Zoom optimization method-------------------------------------------------------
+ string z = GlobalSetting.GetConfig("ZoomOptimization", "0");
+ if (z == "1")
+ {
+ GlobalSetting.ZoomOptimizationMethod = ZoomOptimizationValue.SmoothPixels;
+ }
+ else if (z == "2")
+ {
+ GlobalSetting.ZoomOptimizationMethod = ZoomOptimizationValue.ClearPixels;
+ }
+ else //auto
+ {
+ GlobalSetting.ZoomOptimizationMethod = ZoomOptimizationValue.Auto;
+ }
+
//Load theme--------------------------------------------------------------------
thumbnailBar.SetRenderer(new ImageListView.ImageListViewRenderers.ThemeRenderer()); //ThumbnailBar Renderer must be done BEFORE loading theme
LoadTheme();
@@ -1157,7 +1198,7 @@ private void LoadConfig()
mnuMainThumbnailBar_Click(null, EventArgs.Empty);
//Load background---------------------------------------------------------------
- string z = GlobalSetting.GetConfig("BackgroundColor", "-1");
+ z = GlobalSetting.GetConfig("BackgroundColor", "-1");
GlobalSetting.BackgroundColor = Color.FromArgb(int.Parse(z));
picMain.BackColor = GlobalSetting.BackgroundColor;
@@ -1191,7 +1232,7 @@ private void SaveConfig()
//Window always on top
GlobalSetting.SetConfig("IsWindowAlwaysOnTop", GlobalSetting.IsWindowAlwaysOnTop.ToString());
-
+
//Zoom to fit
GlobalSetting.SetConfig("IsZoomToFit", GlobalSetting.IsZoomToFit.ToString());
@@ -1509,6 +1550,10 @@ private void sysWatch_Changed(object sender, FileSystemEventArgs e)
private void picMain_Zoomed(object sender, ImageBoxZoomEventArgs e)
{
this._isZoomed = true;
+
+ //Zoom optimization
+ ZoomOptimization();
+
this.UpdateStatusBar(true);
}
@@ -76,6 +76,8 @@ private void InitializeComponent()
this.tab1 = new System.Windows.Forms.TabControl();
this.imglOpenWith = new System.Windows.Forms.ImageList(this.components);
this.sp0 = new System.Windows.Forms.SplitContainer();
+ this.lblGeneral_ZoomOptimization = new System.Windows.Forms.Label();
+ this.cmbZoomOptimization = new System.Windows.Forms.ComboBox();
((System.ComponentModel.ISupportInitialize)(this.picBackgroundColor)).BeginInit();
this.tabLanguage.SuspendLayout();
this.tabFileAssociation.SuspendLayout();
@@ -167,7 +169,7 @@ private void InitializeComponent()
this.picBackgroundColor.BackColor = System.Drawing.Color.White;
this.picBackgroundColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.picBackgroundColor.Cursor = System.Windows.Forms.Cursors.Hand;
- this.picBackgroundColor.Location = new System.Drawing.Point(20, 505);
+ this.picBackgroundColor.Location = new System.Drawing.Point(20, 539);
this.picBackgroundColor.Name = "picBackgroundColor";
this.picBackgroundColor.Size = new System.Drawing.Size(100, 19);
this.picBackgroundColor.TabIndex = 12;
@@ -188,7 +190,7 @@ private void InitializeComponent()
this.tabLanguage.Location = new System.Drawing.Point(4, 4);
this.tabLanguage.Name = "tabLanguage";
this.tabLanguage.Padding = new System.Windows.Forms.Padding(3);
- this.tabLanguage.Size = new System.Drawing.Size(551, 511);
+ this.tabLanguage.Size = new System.Drawing.Size(528, 597);
this.tabLanguage.TabIndex = 2;
this.tabLanguage.Text = "language";
this.tabLanguage.UseVisualStyleBackColor = true;
@@ -302,7 +304,7 @@ private void InitializeComponent()
this.tabFileAssociation.Location = new System.Drawing.Point(4, 4);
this.tabFileAssociation.Name = "tabFileAssociation";
this.tabFileAssociation.Padding = new System.Windows.Forms.Padding(3);
- this.tabFileAssociation.Size = new System.Drawing.Size(551, 511);
+ this.tabFileAssociation.Size = new System.Drawing.Size(528, 597);
this.tabFileAssociation.TabIndex = 1;
this.tabFileAssociation.Text = "file association";
this.tabFileAssociation.UseVisualStyleBackColor = true;
@@ -374,7 +376,7 @@ private void InitializeComponent()
this.txtSupportedExtensionDefault.Multiline = true;
this.txtSupportedExtensionDefault.Name = "txtSupportedExtensionDefault";
this.txtSupportedExtensionDefault.ReadOnly = true;
- this.txtSupportedExtensionDefault.Size = new System.Drawing.Size(502, 38);
+ this.txtSupportedExtensionDefault.Size = new System.Drawing.Size(479, 38);
this.txtSupportedExtensionDefault.TabIndex = 22;
this.txtSupportedExtensionDefault.Text = "jpg\r\npng\r\n";
//
@@ -399,6 +401,9 @@ private void InitializeComponent()
//
// tabGeneral
//
+ this.tabGeneral.AutoScroll = true;
+ this.tabGeneral.Controls.Add(this.lblGeneral_ZoomOptimization);
+ this.tabGeneral.Controls.Add(this.cmbZoomOptimization);
this.tabGeneral.Controls.Add(this.chkThumbnailVertical);
this.tabGeneral.Controls.Add(this.chkAllowMultiInstances);
this.tabGeneral.Controls.Add(this.lblGeneral_ThumbnailSize);
@@ -421,7 +426,7 @@ private void InitializeComponent()
this.tabGeneral.Location = new System.Drawing.Point(4, 4);
this.tabGeneral.Name = "tabGeneral";
this.tabGeneral.Padding = new System.Windows.Forms.Padding(3);
- this.tabGeneral.Size = new System.Drawing.Size(551, 554);
+ this.tabGeneral.Size = new System.Drawing.Size(550, 574);
this.tabGeneral.TabIndex = 0;
this.tabGeneral.Text = "general";
this.tabGeneral.UseVisualStyleBackColor = true;
@@ -553,7 +558,7 @@ private void InitializeComponent()
// lblBackGroundColor
//
this.lblBackGroundColor.AutoSize = true;
- this.lblBackGroundColor.Location = new System.Drawing.Point(17, 484);
+ this.lblBackGroundColor.Location = new System.Drawing.Point(17, 518);
this.lblBackGroundColor.Name = "lblBackGroundColor";
this.lblBackGroundColor.Size = new System.Drawing.Size(104, 15);
this.lblBackGroundColor.TabIndex = 11;
@@ -573,7 +578,7 @@ private void InitializeComponent()
// lblImageLoadingOrder
//
this.lblImageLoadingOrder.AutoSize = true;
- this.lblImageLoadingOrder.Location = new System.Drawing.Point(17, 428);
+ this.lblImageLoadingOrder.Location = new System.Drawing.Point(17, 468);
this.lblImageLoadingOrder.Name = "lblImageLoadingOrder";
this.lblImageLoadingOrder.Size = new System.Drawing.Size(117, 15);
this.lblImageLoadingOrder.TabIndex = 10;
@@ -591,7 +596,7 @@ private void InitializeComponent()
"Last write time",
"Extension",
"Random"});
- this.cmbImageOrder.Location = new System.Drawing.Point(20, 446);
+ this.cmbImageOrder.Location = new System.Drawing.Point(20, 486);
this.cmbImageOrder.Name = "cmbImageOrder";
this.cmbImageOrder.Size = new System.Drawing.Size(279, 23);
this.cmbImageOrder.TabIndex = 14;
@@ -643,7 +648,7 @@ private void InitializeComponent()
//
// tab1
//
- this.tab1.Alignment = System.Windows.Forms.TabAlignment.Bottom;
+ this.tab1.Alignment = System.Windows.Forms.TabAlignment.Right;
this.tab1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
@@ -654,7 +659,7 @@ private void InitializeComponent()
this.tab1.Multiline = true;
this.tab1.Name = "tab1";
this.tab1.SelectedIndex = 0;
- this.tab1.Size = new System.Drawing.Size(559, 582);
+ this.tab1.Size = new System.Drawing.Size(581, 582);
this.tab1.TabIndex = 0;
this.tab1.SelectedIndexChanged += new System.EventHandler(this.tab1_SelectedIndexChanged);
//
@@ -680,22 +685,43 @@ private void InitializeComponent()
// sp0.Panel2
//
this.sp0.Panel2.Controls.Add(this.tab1);
- this.sp0.Size = new System.Drawing.Size(704, 541);
+ this.sp0.Size = new System.Drawing.Size(704, 571);
this.sp0.SplitterDistance = 155;
this.sp0.TabIndex = 17;
this.sp0.TabStop = false;
//
+ // lblGeneral_ZoomOptimization
+ //
+ this.lblGeneral_ZoomOptimization.AutoSize = true;
+ this.lblGeneral_ZoomOptimization.Location = new System.Drawing.Point(17, 420);
+ this.lblGeneral_ZoomOptimization.Name = "lblGeneral_ZoomOptimization";
+ this.lblGeneral_ZoomOptimization.Size = new System.Drawing.Size(109, 15);
+ this.lblGeneral_ZoomOptimization.TabIndex = 19;
+ this.lblGeneral_ZoomOptimization.Text = "Zoom optimization";
+ //
+ // cmbZoomOptimization
+ //
+ this.cmbZoomOptimization.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.cmbZoomOptimization.FormattingEnabled = true;
+ this.cmbZoomOptimization.Items.AddRange(new object[] {
+ "(loaded from code)"});
+ this.cmbZoomOptimization.Location = new System.Drawing.Point(20, 438);
+ this.cmbZoomOptimization.Name = "cmbZoomOptimization";
+ this.cmbZoomOptimization.Size = new System.Drawing.Size(279, 23);
+ this.cmbZoomOptimization.TabIndex = 20;
+ this.cmbZoomOptimization.SelectedIndexChanged += new System.EventHandler(this.cmbZoomOptimization_SelectedIndexChanged);
+ //
// frmSetting
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.White;
- this.ClientSize = new System.Drawing.Size(704, 541);
+ this.ClientSize = new System.Drawing.Size(704, 571);
this.Controls.Add(this.sp0);
this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.KeyPreview = true;
- this.MinimumSize = new System.Drawing.Size(720, 580);
+ this.MinimumSize = new System.Drawing.Size(720, 610);
this.Name = "frmSetting";
this.RightToLeftLayout = true;
this.Text = "Settings";
@@ -771,5 +797,7 @@ private void InitializeComponent()
private System.Windows.Forms.Panel panExtraExts;
private System.Windows.Forms.Label lblLanguageWarning;
private System.Windows.Forms.CheckBox chkThumbnailVertical;
+ private System.Windows.Forms.Label lblGeneral_ZoomOptimization;
+ private System.Windows.Forms.ComboBox cmbZoomOptimization;
}
}
@@ -330,8 +330,28 @@ private void LoadTabGeneralConfig()
//Get value of IsPressESCToQuit
chkAllowMultiInstances.Checked = bool.Parse(GlobalSetting.GetConfig("IsAllowMultiInstances", "true"));
+ //Load items of cmbZoomOptimization
+ cmbZoomOptimization.Items.Clear();
+ cmbZoomOptimization.Items.Add(GlobalSetting.LangPack.Items["frmSetting.cmbZoomOptimization._Auto"]);
+ cmbZoomOptimization.Items.Add(GlobalSetting.LangPack.Items["frmSetting.cmbZoomOptimization._SmoothPixels"]);
+ cmbZoomOptimization.Items.Add(GlobalSetting.LangPack.Items["frmSetting.cmbZoomOptimization._ClearPixels"]);
+
+ //Get value of cmbZoomOptimization
+ s = GlobalSetting.GetConfig("ZoomOptimization", "0");
+ int i = 0;
+ if (int.TryParse(s, out i))
+ {
+ if (-1 < i && i < cmbZoomOptimization.Items.Count)
+ { }
+ else
+ {
+ i = 0;
+ }
+ }
+ cmbZoomOptimization.SelectedIndex = i;
+
//Get value of barInterval
- int i = int.Parse(GlobalSetting.GetConfig("Interval", "5"));
+ i = int.Parse(GlobalSetting.GetConfig("Interval", "5"));
if (0 < i && i < 61)
{
barInterval.Value = i;
@@ -341,8 +361,7 @@ private void LoadTabGeneralConfig()
barInterval.Value = 5;
}
- lblSlideshowInterval.Text = string.Format(GlobalSetting.LangPack.Items["frmSetting.lblSlideshowInterval"],
- barInterval.Value);
+ lblSlideshowInterval.Text = string.Format(GlobalSetting.LangPack.Items["frmSetting.lblSlideshowInterval"], barInterval.Value);
//load thumbnail dimension
i = int.Parse(GlobalSetting.GetConfig("ThumbnailDimension", "48"));
@@ -438,6 +457,22 @@ private void barInterval_Scroll(object sender, EventArgs e)
barInterval.Value);
}
+ private void cmbZoomOptimization_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ if (cmbZoomOptimization.SelectedIndex == 1)
+ {
+ GlobalSetting.ZoomOptimizationMethod = ZoomOptimizationValue.SmoothPixels;
+ }
+ else if (cmbZoomOptimization.SelectedIndex == 2)
+ {
+ GlobalSetting.ZoomOptimizationMethod = ZoomOptimizationValue.ClearPixels;
+ }
+ else
+ {
+ GlobalSetting.ZoomOptimizationMethod = ZoomOptimizationValue.Auto;
+ }
+ }
+
private void numMaxThumbSize_ValueChanged(object sender, EventArgs e)
{
GlobalSetting.SetConfig("MaxThumbnailFileSize", numMaxThumbSize.Value.ToString());

0 comments on commit 665c6f1

Please sign in to comment.