• R/O
  • SSH
  • HTTPS

scfiler: Commit


Commit MetaInfo

Revisão91 (tree)
Hora2009-05-21 15:15:05
Autoryuki_sc

Mensagem de Log

サムネイルモードの矢印の動作を修正

Mudança Sumário

Diff

--- SCFiler2/Folder.cs (revision 90)
+++ SCFiler2/Folder.cs (revision 91)
@@ -3,6 +3,7 @@
33 using System.Text;
44 using System.Drawing;
55 using SCFiler2.ItemInterface;
6+using SCFiler2.Util;
67
78 namespace SCFiler2.FileSystem {
89 public class Folder : FilerItem, IFolder {
@@ -86,7 +87,7 @@
8687 }
8788
8889 public override Icon Icon {
89- get { return Icons.Folder; }
90+ get { return Images.Folder; }
9091 }
9192
9293 public List<IFolder> GetFolders() {
@@ -104,5 +105,24 @@
104105 }
105106 return files;
106107 }
108+
109+ Image image = null;
110+ public override Image ThumnailImage {
111+ get {
112+ return Images.FolderThumbnail;
113+ }
114+ }
115+
116+ public override bool Equals(object obj) {
117+ if (obj == null || this.GetType() != obj.GetType()) {
118+ return false;
119+ } else {
120+ return this.FullName == ((Folder)obj).FullName;
121+ }
122+ }
123+
124+ public override int GetHashCode() {
125+ return this.FullName.GetHashCode();
126+ }
107127 }
108128 }
--- SCFiler2/FileView.cs (revision 90)
+++ SCFiler2/FileView.cs (revision 91)
@@ -185,30 +185,30 @@
185185 }
186186 }
187187
188- private Image getSizeTransformedImage(Image source, int width, int height, bool IsDoNothingWhenSmall) {
189- //サイズを合わせる
190- if (IsDoNothingWhenSmall && source.Width < width && source.Height < height) {
191- return source;
192- } else {
193- Image output = new Bitmap(width, height);
194- //うまく収まるサイズの計算
195- float rateX = (float)width / (float)source.Width;
196- float rateY = (float)height / (float)source.Height;
197- int newWidth, newHeight;
198- if (rateX < rateY) { //より小さくなる方にあわせないといけない
199- newWidth = (int)(source.Width * rateX);
200- newHeight = (int)(source.Height * rateX);
201- } else {
202- newWidth = (int)(source.Width * rateY);
203- newHeight = (int)(source.Height * rateY);
204- }
205- Graphics g = Graphics.FromImage(output);
206- g.FillRectangle( new SolidBrush(Color.White) , 0, 0, width, height);
207- g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Bilinear;
208- g.DrawImage(source, 0, 0, newWidth, newHeight);
209- return output;
210- }
211- }
188+ //private Image getSizeTransformedImage(Image source, int width, int height, bool IsDoNothingWhenSmall) {
189+ // //サイズを合わせる
190+ // if (IsDoNothingWhenSmall && source.Width < width && source.Height < height) {
191+ // return source;
192+ // } else {
193+ // Image output = new Bitmap(width, height);
194+ // //うまく収まるサイズの計算
195+ // float rateX = (float)width / (float)source.Width;
196+ // float rateY = (float)height / (float)source.Height;
197+ // int newWidth, newHeight;
198+ // if (rateX < rateY) { //より小さくなる方にあわせないといけない
199+ // newWidth = (int)(source.Width * rateX);
200+ // newHeight = (int)(source.Height * rateX);
201+ // } else {
202+ // newWidth = (int)(source.Width * rateY);
203+ // newHeight = (int)(source.Height * rateY);
204+ // }
205+ // Graphics g = Graphics.FromImage(output);
206+ // g.FillRectangle(new SolidBrush(Color.White), 0, 0, width, height);
207+ // g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Bilinear;
208+ // g.DrawImage(source, 0, 0, newWidth, newHeight);
209+ // return output;
210+ // }
211+ //}
212212
213213 #region プレビュー関係
214214
@@ -303,35 +303,12 @@
303303
304304 this.listView.LargeImageList.ImageSize = new Size(thumbnailWidth, thumbnailHeight);
305305
306- Bitmap folderIcon = Icons.Folder.ToBitmap();
307- Image folderThumbnail = getSizeTransformedImage(folderIcon, thumbnailWidth, thumbnailHeight, false);
308306 foreach (VirtualListViewItem item in this.virtualListView.Items) {
309- switch (item.FilerItem.Type) {
310- case ItemType.Folder:
311- this.listView.LargeImageList.Images.Add(folderThumbnail);
312- item.Item.ImageIndex = this.listView.LargeImageList.Images.Count - 1;
313- break;
314- case ItemType.File:
315- Bitmap image = null;
316- try {
317- image = (Bitmap)ImageUtil.getImage(item.FilerItem);
318- } catch (OutOfMemoryException) {
319- SCFiler2System.ShowHistoryMessage(item.FilerItem.Name + "は読み込めません");
320- }
321- if (image != null) {
322- this.listView.LargeImageList.Images.Add(getSizeTransformedImage(image, thumbnailWidth, thumbnailHeight, false));
323- item.Item.ImageIndex = this.listView.LargeImageList.Images.Count - 1;
324- image.Dispose();
325- break;
326- } else {
327- item.Item.ImageIndex = -1;
328- break;
329- }
330- default:
331- item.Item.ImageIndex = -1;
332- break;
307+ Image image = item.FilerItem.ThumnailImage;
308+ if (image != null) {
309+ this.listView.LargeImageList.Images.Add(image);
310+ item.Item.ImageIndex = this.listView.LargeImageList.Images.Count - 1;
333311 }
334-
335312 }
336313 }
337314
@@ -401,7 +378,6 @@
401378 setViewMode(ViewMode.Normal);
402379 }
403380
404- previousPath = currentPath;
405381 currentPath = fullName;
406382 NarrowDownTextBox.Text = "";
407383 try {
@@ -433,6 +409,7 @@
433409 this.NarrowDownTextBox.Clear();
434410 this.isNeedToUpdateView = false;
435411 EventInterfacesImpl.Instance.CauseFileViewPathChangedEvent(this, this.currentPath);
412+ previousPath = currentPath;
436413 }
437414
438415 /// <summary>
@@ -527,7 +504,6 @@
527504 newPath = System.IO.Directory.GetDirectoryRoot(Application.ExecutablePath);
528505 }
529506 this.currentPath = newPath;
530- this.previousPath = newPath;
531507 folders = System.IO.Directory.GetDirectories(currentPath);
532508 }
533509 String[] files = System.IO.Directory.GetFiles(currentPath);
@@ -681,12 +657,8 @@
681657 /// <param name="sender"></param>
682658 /// <param name="e"></param>
683659 private void fileListView_KeyDown(object sender, KeyEventArgs e) {
684- //if (this.listView.View == View.LargeIcon && (e.KeyCode == Keys.Left || e.KeyCode == Keys.Right) &&
685- // !e.Shift && !e.Control && !e.Alt) {
686- // return;
687- //}
688660
689- //ListViewコントローラの優先処理
661+ //ListViewコントローラの優先処理
690662 ListViewController.Result result = currentListViewController.KeyProcessingBeforeKeyCommand(e);
691663 switch (result) {
692664 case ListViewController.Result.EventHandled:
--- SCFiler2/NormalListViewController.cs (revision 90)
+++ SCFiler2/NormalListViewController.cs (revision 91)
@@ -49,6 +49,11 @@
4949 return Result.EventNotHandled;
5050 }
5151
52+ if (this.parentView.ViewMode == ViewMode.ThumbnailMode && (keyEvent.KeyCode == Keys.Left || keyEvent.KeyCode == Keys.Right)
53+ && !keyEvent.Shift && !keyEvent.Control && !keyEvent.Alt) {
54+ return Result.DelegateToOriginalControl;
55+ }
56+
5257 //incremental search, Migemo
5358 ItemSearcher searcher = null;
5459 if (allItemSearcher.ContainsKey(ItemSearcher.SearchType.Incremental)) {
--- SCFiler2/Drive.cs (revision 90)
+++ SCFiler2/Drive.cs (revision 91)
@@ -4,6 +4,7 @@
44 using SCFiler2;
55 using SCFiler2.Util;
66 using SCFiler2.ItemInterface;
7+using System.Drawing;
78
89 namespace SCFiler2.FileSystem {
910 public class Drive : FilerItem {
@@ -69,21 +70,47 @@
6970 get {
7071 switch (this.info.DriveType) {
7172 case System.IO.DriveType.Fixed:
72- return Icons.Hdd;
73+ return Images.Hdd;
7374 case System.IO.DriveType.CDRom:
74- return Icons.CDROM;
75+ return Images.CDROM;
7576 case System.IO.DriveType.Removable:
76- return Icons.RemovableDrive;
77+ return Images.RemovableDrive;
7778 case System.IO.DriveType.Network:
78- return Icons.NetworkDrive;
79+ return Images.NetworkDrive;
7980 default:
80- return Icons.Hdd;
81+ return Images.Hdd;
8182 }
8283 }
8384 }
8485
86+ Image image = null;
87+ public override System.Drawing.Image ThumnailImage {
88+ get {
89+ if (this.image != null) {
90+ return this.image;
91+ }
92+ this.image = ImageUtil.GetSizeTransformedImage(this.Icon.ToBitmap(),
93+ SCFiler2System.Instance.Option.FileView.ThumbnailWidth,
94+ SCFiler2System.Instance.Option.FileView.ThumbnailHeight,
95+ false);
96+ return this.image;
97+ }
98+ }
99+
85100 public override void Refresh() {
86101 //何もしない
87102 }
103+
104+ public override bool Equals(object obj) {
105+ if (obj == null || this.GetType() != obj.GetType()) {
106+ return false;
107+ } else {
108+ return this.FullName == ((Drive)obj).FullName;
109+ }
110+ }
111+
112+ public override int GetHashCode() {
113+ return this.info.Name.GetHashCode();
114+ }
88115 }
89116 }
--- SCFiler2/File.cs (revision 90)
+++ SCFiler2/File.cs (revision 91)
@@ -4,6 +4,7 @@
44 using SCFiler2.Util;
55 using System.Diagnostics;
66 using SCFiler2.ItemInterface;
7+using System.Drawing;
78
89 namespace SCFiler2.FileSystem {
910 public class File : FilerItem , IFile {
@@ -102,5 +103,36 @@
102103 public void Execute() {
103104 ExtensionRelationCustomize.Instance.Execute(this);
104105 }
106+
107+ Image image = null;
108+ public override System.Drawing.Image ThumnailImage {
109+ get {
110+ if (image != null) {
111+ return image;
112+ }
113+ Image originalImage = ImageUtil.GetImage(this);
114+ if (originalImage == null) {
115+ return Images.DefaultThumbnail;
116+ }
117+ this.image = ImageUtil.GetSizeTransformedImage(originalImage,
118+ SCFiler2System.Instance.Option.FileView.ThumbnailWidth,
119+ SCFiler2System.Instance.Option.FileView.ThumbnailHeight,
120+ false);
121+ originalImage.Dispose();
122+ return this.image;
123+ }
124+ }
125+
126+ public override bool Equals(object obj) {
127+ if (obj == null || this.GetType() != obj.GetType()) {
128+ return false;
129+ } else {
130+ return this.FullName == ((File)obj).FullName;
131+ }
132+ }
133+
134+ public override int GetHashCode() {
135+ return this.FullName.GetHashCode();
136+ }
105137 }
106138 }
--- SCFiler2/Icons.cs (revision 90)
+++ SCFiler2/Icons.cs (revision 91)
@@ -2,9 +2,10 @@
22 using System.Collections.Generic;
33 using System.Text;
44 using System.Drawing;
5+using SCFiler2.Util;
56
67 namespace SCFiler2 {
7- public class Icons {
8+ public class Images {
89 static public Icon Folder = SCFiler2.Properties.Resources.folderIcon;
910 static public Icon Default = SCFiler2.Properties.Resources.defaultIcon;
1011 static public Icon Hdd = SCFiler2.Properties.Resources.HddIcon;
@@ -12,7 +13,27 @@
1213 static public Icon RemovableDrive = SCFiler2.Properties.Resources.RemovableDiskIcon;
1314 static public Icon NetworkDrive = SCFiler2.Properties.Resources.NetworkDiskIcon;
1415
15- private Icons() {
16+ static public Image FolderThumbnail = null;
17+ static public Image DefaultThumbnail = null;
18+
19+ private Images() {
1620 }
21+
22+ static Images() {
23+ ThumnailSizeReCalc();
24+ }
25+
26+ static public void ThumnailSizeReCalc() {
27+ FolderThumbnail = ImageUtil.GetSizeTransformedImage(
28+ SCFiler2.Properties.Resources.folderIcon.ToBitmap(),
29+ SCFiler2System.Instance.Option.FileView.ThumbnailWidth,
30+ SCFiler2System.Instance.Option.FileView.ThumbnailHeight,
31+ false);
32+ DefaultThumbnail = ImageUtil.GetSizeTransformedImage(
33+ SCFiler2.Properties.Resources.defaultIcon.ToBitmap(),
34+ SCFiler2System.Instance.Option.FileView.ThumbnailWidth,
35+ SCFiler2System.Instance.Option.FileView.ThumbnailHeight,
36+ false);
37+ }
1738 }
1839 }
--- SCFiler2/VirtualListView.cs (revision 90)
+++ SCFiler2/VirtualListView.cs (revision 91)
@@ -80,12 +80,6 @@
8080 } else {
8181 return this.itemList[this.targetView.FocusedItem.Index];
8282 }
83- //foreach (VirtualListViewItem item in this.Items) {
84- // if (item.Focused) {
85- // return item;
86- // }
87- //}
88- //return null;
8983 }
9084 set {
9185 if (value == null) {
@@ -93,10 +87,6 @@
9387 } else {
9488 this.targetView.FocusedItem = value.Item;
9589 }
96- //if (this.focusedItem != null && this.focusedItem == value) {
97- // this.focusedItem.Focused = false;
98- //}
99- //this.focusedItem = value;
10090 }
10191 }
10292
@@ -203,11 +193,11 @@
203193
204194 internal void InitializeImageList() {
205195 this.targetView.SmallImageList.Images.Clear();
206- this.targetView.SmallImageList.Images.Add(Icons.Folder);
207- this.targetView.SmallImageList.Images.Add(Icons.Hdd);
208- this.targetView.SmallImageList.Images.Add(Icons.CDROM);
209- this.targetView.SmallImageList.Images.Add(Icons.RemovableDrive);
210- this.targetView.SmallImageList.Images.Add(Icons.NetworkDrive);
196+ this.targetView.SmallImageList.Images.Add(Images.Folder);
197+ this.targetView.SmallImageList.Images.Add(Images.Hdd);
198+ this.targetView.SmallImageList.Images.Add(Images.CDROM);
199+ this.targetView.SmallImageList.Images.Add(Images.RemovableDrive);
200+ this.targetView.SmallImageList.Images.Add(Images.NetworkDrive);
211201 }
212202
213203
--- SCFiler2/CustomToolbarItem.cs (revision 90)
+++ SCFiler2/CustomToolbarItem.cs (revision 91)
@@ -49,7 +49,7 @@
4949 try {
5050 icon = new Icon(@"icons\" + iconFile);
5151 } catch (FileNotFoundException) {
52- icon = Icons.Default;
52+ icon = Images.Default;
5353 SCFiler2System.ShowHistoryMessage("[error]カスタムツールバーに割り当てられたアイコンが見つかりません");
5454 }
5555 this.iconFilename = iconFile;
@@ -81,14 +81,14 @@
8181 this.icon = System.Drawing.Icon.ExtractAssociatedIcon(
8282 ExternalToolManager.Instance.GetItem(exeExtTool.Index).Path);
8383 } else {
84- this.icon = Icons.Default;
84+ this.icon = Images.Default;
8585 SCFiler2System.ShowHistoryMessage("[error]外部ツール"+exeExtTool.Index+"が見つかりません");
8686 }
8787 } catch (ArgumentException) {
88- this.icon = Icons.Default;
88+ this.icon = Images.Default;
8989 SCFiler2System.ShowHistoryMessage("[error]外部ツール" + exeExtTool.Index + "が見つかりません");
9090 } catch (FileNotFoundException) {
91- this.icon = Icons.Default;
91+ this.icon = Images.Default;
9292 SCFiler2System.ShowHistoryMessage("[error]外部ツール" + exeExtTool.Index + "が見つかりません");
9393 }
9494 } else {
--- SCFiler2/ImageUtil.cs (revision 90)
+++ SCFiler2/ImageUtil.cs (revision 91)
@@ -17,7 +17,7 @@
1717 /// <param name="extension">調べる拡張子</param>
1818 /// <returns>対応しているならtrue</returns>
1919 static private bool isSupportedByOS(string extension) {
20- return supportExtensions.Contains(extension);
20+ return supportExtensions.Contains(extension.ToUpper());
2121 }
2222
2323 //スタティックイニシャライザ
@@ -24,8 +24,10 @@
2424 static ImageUtil() {
2525 ImageCodecInfo[] codecs = ImageCodecInfo.GetImageDecoders();
2626 foreach (ImageCodecInfo info in codecs) {
27- string[] ext = info.FilenameExtension.Split(';');
28- supportExtensions.AddRange(ext);
27+ string[] ext = info.FilenameExtension.ToUpper().Split(';');
28+ foreach (string item in ext) {
29+ supportExtensions.Add(item.TrimStart('*').ToUpper());
30+ }
2931 }
3032 }
3133
@@ -35,9 +37,16 @@
3537 /// </summary>
3638 /// <param name="item"></param>
3739 /// <returns>Imageインスタンス。読み込めない場合はnull</returns>
38- static public Image getImage(IFilerItem item) {
40+ static public Image GetImage(IFilerItem item) {
3941 Bitmap image = susie.GetPicture(item.FullName);
42+ if (image != null) {
43+ return image;
44+ }
4045
46+ if (!isSupportedByOS(item.Extension)) {
47+ return null;
48+ }
49+
4150 //Susieで表示できないときはWindowsの標準デコーダで表示を試みる
4251 if (image == null) {
4352 image = (Bitmap)Bitmap.FromFile(item.FullName);
@@ -44,5 +53,34 @@
4453 }
4554 return image;
4655 }
56+
57+ static public Image GetSizeTransformedImage(Image source, int width, int height, bool IsDoNothingWhenSmall) {
58+ if (source == null) {
59+ return null;
60+ }
61+
62+ //サイズを合わせる
63+ if (IsDoNothingWhenSmall && source.Width < width && source.Height < height) {
64+ return source;
65+ } else {
66+ Image output = new Bitmap(width, height);
67+ //うまく収まるサイズの計算
68+ float rateX = (float)width / (float)source.Width;
69+ float rateY = (float)height / (float)source.Height;
70+ int newWidth, newHeight;
71+ if (rateX < rateY) { //より小さくなる方にあわせないといけない
72+ newWidth = (int)(source.Width * rateX);
73+ newHeight = (int)(source.Height * rateX);
74+ } else {
75+ newWidth = (int)(source.Width * rateY);
76+ newHeight = (int)(source.Height * rateY);
77+ }
78+ Graphics g = Graphics.FromImage(output);
79+ g.FillRectangle(new SolidBrush(Color.White), 0, 0, width, height);
80+ g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Bilinear;
81+ g.DrawImage(source, 0, 0, newWidth, newHeight);
82+ return output;
83+ }
84+ }
4785 }
4886 }
--- SCFiler2/FilerItem.cs (revision 90)
+++ SCFiler2/FilerItem.cs (revision 91)
@@ -53,6 +53,11 @@
5353 /// </summary>
5454 abstract public bool Exists { get;}
5555
56+ /// <summary>
57+ /// アイテムのサムネイルイメージを取得する(サイズはオプションで設定した値)
58+ /// </summary>
59+ abstract public Image ThumnailImage { get;}
60+
5661 abstract public Icon Icon { get;}
5762
5863 /// <summary>
--- SCFiler2/Properties/Resources.Designer.cs (revision 90)
+++ SCFiler2/Properties/Resources.Designer.cs (revision 91)
@@ -1,7 +1,7 @@
11 //------------------------------------------------------------------------------
22 // <auto-generated>
33 // このコードはツールによって生成されました。
4-// ランタイム バージョン:2.0.50727.1433
4+// ランタイム バージョン:2.0.50727.3082
55 //
66 // このファイルへの変更は、以下の状況下で不正な動作の原因になったり、
77 // コードが再生成されるときに損失したりします。
--- SCFiler2/FileSearchForm.cs (revision 90)
+++ SCFiler2/FileSearchForm.cs (revision 91)
@@ -53,7 +53,7 @@
5353 this.baseFolder = baseFolderForSearch;
5454 this.searchPathLabel.Text = "検索対象: " + baseFolderForSearch;
5555 this.foundItemList.SmallImageList = new ImageList();
56- this.foundItemList.SmallImageList.Images.Add(Icons.Folder);
56+ this.foundItemList.SmallImageList.Images.Add(Images.Folder);
5757 }
5858
5959 /// <summary>
Show on old repository browser