2010
@@ -246,6 +246,7 @@ | ||
246 | 246 | |
247 | 247 | commandLine = null; |
248 | 248 | CoreConfigs.General.FirstBoot = false; |
249 | + | |
249 | 250 | System.Windows.Forms.Application.Run(); |
250 | 251 | |
251 | 252 | return 0; |
@@ -86,8 +86,9 @@ | ||
86 | 86 | this.Control.BeginInvoke(new Action<object>(this.Start), id); |
87 | 87 | }else{ |
88 | 88 | this.Reports.Add(id, 0); |
89 | - this.Visible = true; | |
90 | - this.Text = "0 %"; | |
89 | + if(!(this.Visible)){ | |
90 | + this.Visible = true; | |
91 | + } | |
91 | 92 | } |
92 | 93 | } |
93 | 94 |
@@ -78,6 +78,7 @@ | ||
78 | 78 | if(this.InvokeRequired){ |
79 | 79 | this.BeginInvoke(new Action<string>(this.WriteLine), str); |
80 | 80 | }else if(!(this.IsDisposed) && (this.IsHandleCreated)){ |
81 | + this.BeginUpdate(); | |
81 | 82 | foreach(string line in str.Split('\n')){ |
82 | 83 | if(this.trimWriteLine && String.IsNullOrEmpty(line.Trim())){ |
83 | 84 | continue; |
@@ -86,6 +87,7 @@ | ||
86 | 87 | this.CutLines(); |
87 | 88 | this.ScrollToBottom(); |
88 | 89 | } |
90 | + this.EndUpdate(); | |
89 | 91 | } |
90 | 92 | } |
91 | 93 |
@@ -97,6 +99,7 @@ | ||
97 | 99 | if(this.InvokeRequired){ |
98 | 100 | this.BeginInvoke(new Action<string, Color>(this.WriteLine), str, color); |
99 | 101 | }else if(!(this.IsDisposed) && (this.IsHandleCreated)){ |
102 | + this.BeginUpdate(); | |
100 | 103 | foreach(string line in str.Split('\n')){ |
101 | 104 | if(this.trimWriteLine && String.IsNullOrEmpty(line.Trim())){ |
102 | 105 | continue; |
@@ -105,6 +108,7 @@ | ||
105 | 108 | this.CutLines(); |
106 | 109 | this.ScrollToBottom(); |
107 | 110 | } |
111 | + this.EndUpdate(); | |
108 | 112 | } |
109 | 113 | } |
110 | 114 |
@@ -112,7 +116,8 @@ | ||
112 | 116 | if(this.InvokeRequired){ |
113 | 117 | this.BeginInvoke(new Action<string>(this.Write), str); |
114 | 118 | }else if(!(this.IsDisposed) && (this.IsHandleCreated)){ |
115 | - int i = 0; | |
119 | + this.BeginUpdate(); | |
120 | + int i = 0; | |
116 | 121 | foreach(string line in str.Split('\n')){ |
117 | 122 | if(this.trimWriteLine && String.IsNullOrEmpty(line.Trim())){ |
118 | 123 | continue; |
@@ -130,6 +135,7 @@ | ||
130 | 135 | } |
131 | 136 | i++; |
132 | 137 | } |
138 | + this.EndUpdate(); | |
133 | 139 | } |
134 | 140 | } |
135 | 141 |
@@ -137,6 +143,7 @@ | ||
137 | 143 | if(this.InvokeRequired){ |
138 | 144 | this.BeginInvoke(new Action<string, Color>(this.Write), str, color); |
139 | 145 | }else if(!(this.IsDisposed) && (this.IsHandleCreated)){ |
146 | + this.BeginUpdate(); | |
140 | 147 | int i = 0; |
141 | 148 | foreach(string line in str.Split('\n')){ |
142 | 149 | if(this.trimWriteLine && String.IsNullOrEmpty(line.Trim())){ |
@@ -155,6 +162,7 @@ | ||
155 | 162 | } |
156 | 163 | i++; |
157 | 164 | } |
165 | + this.EndUpdate(); | |
158 | 166 | } |
159 | 167 | } |
160 | 168 |
@@ -192,6 +192,8 @@ | ||
192 | 192 | return Resource.Path.ScriptDirectory; |
193 | 193 | case "configdir": |
194 | 194 | return Resource.Path.ConfigDirectory; |
195 | + case "resourcedir": | |
196 | + return Resource.Path.ResourceDirectory; | |
195 | 197 | case "defaultconfigdir": |
196 | 198 | return Resource.Path.DefaultConfigDirectory; |
197 | 199 | case "specialfolder": |
@@ -6,6 +6,7 @@ | ||
6 | 6 | using System.Collections.Generic; |
7 | 7 | using System.Collections.ObjectModel; |
8 | 8 | using System.Drawing; |
9 | +using System.IO; | |
9 | 10 | using System.Windows.Forms; |
10 | 11 | using System.Xml; |
11 | 12 | using System.Xml.Schema; |
@@ -38,11 +39,22 @@ | ||
38 | 39 | Image image = null; |
39 | 40 | ToolStripMenuItem menuItem; |
40 | 41 | if(!(String.IsNullOrEmpty(item.ImagePath))){ |
42 | + string path = ReplacementMacro.Expand(item.ImagePath); | |
41 | 43 | try{ |
42 | - image = Image.FromFile(item.ImagePath); | |
44 | + using(FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read)){ | |
45 | + image = Image.FromStream(stream); | |
46 | + stream.Close(); | |
47 | + } | |
43 | 48 | }catch(Exception ex){ |
44 | - MessageBox.Show(ex.Message + "\n" + item.ImagePath, ApplicationInfo.Name, MessageBoxButtons.OK, MessageBoxIcon.Error); | |
49 | + MessageBox.Show(ex.Message + "\n" + path, ApplicationInfo.Name, MessageBoxButtons.OK, MessageBoxIcon.Error); | |
45 | 50 | } |
51 | + }else if(!(String.IsNullOrEmpty(item.IconPath))){ | |
52 | + string path = ReplacementMacro.Expand(item.IconPath); | |
53 | + try{ | |
54 | + image = (new Icon(path, new Size(16, 16))).ToBitmap(); | |
55 | + }catch(Exception ex){ | |
56 | + MessageBox.Show(ex.Message + "\n" + path, ApplicationInfo.Name, MessageBoxButtons.OK, MessageBoxIcon.Error); | |
57 | + } | |
46 | 58 | } |
47 | 59 | if(String.IsNullOrEmpty(item.Action)){ |
48 | 60 | menuItem = new ToolStripMenuItem(item.Text, image); |
@@ -140,6 +152,17 @@ | ||
140 | 152 | } |
141 | 153 | } |
142 | 154 | |
155 | + private string iconPath = null; | |
156 | + [XmlAttribute("icon")] | |
157 | + public string IconPath{ | |
158 | + get{ | |
159 | + return this.iconPath; | |
160 | + } | |
161 | + set{ | |
162 | + this.iconPath = value; | |
163 | + } | |
164 | + } | |
165 | + | |
143 | 166 | private ContentAlignment textAlign = ContentAlignment.MiddleCenter; |
144 | 167 | [XmlAttribute("align")] |
145 | 168 | public ContentAlignment TextAlign{ |
@@ -25,8 +25,8 @@ | ||
25 | 25 | |
26 | 26 | private const string unknownString = "unknown"; |
27 | 27 | private FolderView folderView; |
28 | - private AddressBarControl addressBar = new AddressBarControl(); | |
29 | - private StatusBarControl statusBar = new StatusBarControl(); | |
28 | + private AddressBarControl addressBar; | |
29 | + private StatusBarControl statusBar; | |
30 | 30 | private string volumeLabel = unknownString; |
31 | 31 | private string usingSpaceString = unknownString; |
32 | 32 | private decimal freeSpace = 0; |
@@ -54,8 +54,6 @@ | ||
54 | 54 | } |
55 | 55 | |
56 | 56 | this.SuspendLayout(); |
57 | - this.Dock = DockStyle.Fill; | |
58 | - this.BorderStyle = BorderStyle.FixedSingle; | |
59 | 57 | if(FilerModule.FilerOption.FilerFont != null){ |
60 | 58 | this.Font = FilerModule.FilerOption.FilerFont.GetFont(); |
61 | 59 | }else{ |
@@ -62,10 +60,11 @@ | ||
62 | 60 | this.Font = SystemFonts.MessageBoxFont; |
63 | 61 | } |
64 | 62 | |
65 | - this.statusBar.ShowDiskUsageGraph = FilerModule.FilerOption.ShowDiskUsageGraph; | |
66 | - | |
67 | 63 | this.folderView = new FolderView(path); |
68 | 64 | this.folderView.BorderStyle = BorderStyle.None; |
65 | + this.statusBar = new StatusBarControl(this.folderView); | |
66 | + this.statusBar.ShowDiskUsageGraph = FilerModule.FilerOption.ShowDiskUsageGraph; | |
67 | + this.addressBar = new AddressBarControl(this.folderView); | |
69 | 68 | this.RefreshAddressBar(); |
70 | 69 | this.RefreshDriveInfo(); |
71 | 70 | this.RefreshStatusBar(); |
@@ -193,7 +192,12 @@ | ||
193 | 192 | |
194 | 193 | private void AutoRefreshMessageProcessQueueEventListener(object sender, EventArgs e){ |
195 | 194 | while(this.autoRefreshMessageQueueServer.Queue.Count > 0){ |
196 | - MainForm.Instance.Output.WriteLine(this.autoRefreshMessageQueueServer.Queue.Dequeue()); | |
195 | + List<string> items = new List<string>(); | |
196 | + foreach(string item in this.autoRefreshMessageQueueServer.Queue){ | |
197 | + items.AddRange(item.Split('\n')); | |
198 | + } | |
199 | + MainForm.Instance.Output.Items.AddRange(items.ToArray()); | |
200 | + MainForm.Instance.Output.LimitLines = MainForm.Instance.Output.LimitLines; | |
197 | 201 | } |
198 | 202 | } |
199 | 203 |
@@ -498,6 +502,15 @@ | ||
498 | 502 | this.folderView.CalculateDirectoryFileSize(mode); |
499 | 503 | } |
500 | 504 | |
505 | + public History<string> History{ | |
506 | + get{ | |
507 | + return this.folderView.History; | |
508 | + } | |
509 | + set{ | |
510 | + this.folderView.History = value; | |
511 | + } | |
512 | + } | |
513 | + | |
501 | 514 | protected override void Dispose(bool disposing){ |
502 | 515 | if(!(this.disposed)){ |
503 | 516 | this.container.Dispose(); |
@@ -704,6 +717,9 @@ | ||
704 | 717 | get{ |
705 | 718 | return this.folderView.BackHistory; |
706 | 719 | } |
720 | + set{ | |
721 | + this.folderView.BackHistory = value; | |
722 | + } | |
707 | 723 | } |
708 | 724 | |
709 | 725 | public string[] ForwardHistory{ |
@@ -710,6 +726,9 @@ | ||
710 | 726 | get{ |
711 | 727 | return this.folderView.ForwardHistory; |
712 | 728 | } |
729 | + set{ | |
730 | + this.folderView.ForwardHistory = value; | |
731 | + } | |
713 | 732 | } |
714 | 733 | |
715 | 734 | public bool Activated{ |
@@ -883,7 +902,11 @@ | ||
883 | 902 | #region 内部クラス |
884 | 903 | |
885 | 904 | private class AddressBarControl : TextBox{ |
886 | - public AddressBarControl(){ | |
905 | + private FolderView folderView; | |
906 | + | |
907 | + public AddressBarControl(FolderView folderView){ | |
908 | + this.folderView = folderView; | |
909 | + | |
887 | 910 | this.BackColor = Color.FromKnownColor(KnownColor.Control); |
888 | 911 | this.BorderStyle = BorderStyle.None; |
889 | 912 | this.ReadOnly = true; |
@@ -890,6 +913,11 @@ | ||
890 | 913 | this.Dock = DockStyle.Top; |
891 | 914 | this.Multiline = false; |
892 | 915 | this.TabStop = false; |
916 | + this.Font = SystemFonts.CaptionFont; | |
917 | + | |
918 | + this.Click += delegate{ | |
919 | + this.folderView.Focus(); | |
920 | + }; | |
893 | 921 | } |
894 | 922 | |
895 | 923 | public void Highlight(){ |
@@ -905,15 +933,21 @@ | ||
905 | 933 | |
906 | 934 | private class StatusBarControl : StatusStrip{ |
907 | 935 | private ToolStripStatusLabel label = new ToolStripStatusLabel(); |
908 | - private ToolStripStatusLabel filterIcon = new ToolStripStatusLabel(); | |
909 | - private ToolStripStatusLabel navLockIcon = new ToolStripStatusLabel(); | |
936 | + private ToolStripButton filterIcon = new ToolStripButton(); | |
937 | + private ToolStripButton navLockIcon = new ToolStripButton(); | |
910 | 938 | private ToolStripButton driveNameControl = new ToolStripButton(); |
911 | 939 | private ToolStripStatusLabel driveUsingSpaceLabel = new ToolStripStatusLabel(); |
912 | 940 | private ToolStripStatusLabel driveFreeSpaceLabel = new ToolStripStatusLabel(); |
913 | 941 | //private ToolStripStatusLabel driveTotalSpaceLabel = new ToolStripStatusLabel(); |
914 | 942 | private ToolStripProgressBar driveUsageBar = new ToolStripProgressBar(); |
943 | + private FolderView folderView; | |
915 | 944 | |
916 | - public StatusBarControl(){ | |
945 | + public StatusBarControl(FolderView folderView){ | |
946 | + this.folderView = folderView; | |
947 | + this.Click += delegate{ | |
948 | + this.folderView.Focus(); | |
949 | + }; | |
950 | + | |
917 | 951 | this.GripStyle = ToolStripGripStyle.Hidden; |
918 | 952 | this.SizingGrip = false; |
919 | 953 |
@@ -922,13 +956,17 @@ | ||
922 | 956 | this.Items.Add(this.label); |
923 | 957 | |
924 | 958 | this.filterIcon.Text = ""; |
925 | - this.filterIcon.Visible = false; | |
926 | - this.filterIcon.Image = Shell.GetIconImage(StringEx.JoinPath(Resource.Path.ResourceDirectory, Resource.Path.FilterIcon), IconSize.Small); | |
959 | + this.filterIcon.Image = Shell.GetIconImage(StringEx.JoinPath(Resource.Path.ResourceDirectory, "Unfilter.ico"), IconSize.Small); | |
960 | + this.filterIcon.Click += delegate{ | |
961 | + Kuon.Filer.FilerModule.SetFileFilter(); | |
962 | + }; | |
927 | 963 | this.Items.Add(this.filterIcon); |
928 | 964 | |
929 | 965 | this.navLockIcon.Text = ""; |
930 | - this.navLockIcon.Visible = false; | |
931 | - this.navLockIcon.Image = Shell.GetIconImage(StringEx.JoinPath(Resource.Path.ResourceDirectory, Resource.Path.LockIcon), IconSize.Small); | |
966 | + this.navLockIcon.Image = Shell.GetIconImage(StringEx.JoinPath(Resource.Path.ResourceDirectory, "Unlock.ico"), IconSize.Small); | |
967 | + this.navLockIcon.Click += delegate{ | |
968 | + Kuon.Filer.FilerModule.ToggleNavigation(); | |
969 | + }; | |
932 | 970 | this.Items.Add(this.navLockIcon); |
933 | 971 | |
934 | 972 | this.driveNameControl.Click += delegate{ |
@@ -945,6 +983,7 @@ | ||
945 | 983 | //this.driveTotalSpaceLabel.TextAlign = ContentAlignment.MiddleLeft; |
946 | 984 | //this.Items.Add(this.driveTotalSpaceLabel); |
947 | 985 | |
986 | + this.driveUsageBar.Width = 100; | |
948 | 987 | this.driveUsageBar.Alignment = ToolStripItemAlignment.Right; |
949 | 988 | this.driveUsageBar.Maximum = 100; |
950 | 989 | this.driveUsageBar.Minimum = 0; |
@@ -968,7 +1007,11 @@ | ||
968 | 1007 | return this.filterIcon.Visible; |
969 | 1008 | } |
970 | 1009 | set{ |
971 | - this.filterIcon.Visible = value; | |
1010 | + if(value){ | |
1011 | + this.filterIcon.Image = Shell.GetIconImage(StringEx.JoinPath(Resource.Path.ResourceDirectory, "Filter.ico"), IconSize.Small); | |
1012 | + }else{ | |
1013 | + this.filterIcon.Image = Shell.GetIconImage(StringEx.JoinPath(Resource.Path.ResourceDirectory, "Unfilter.ico"), IconSize.Small); | |
1014 | + } | |
972 | 1015 | } |
973 | 1016 | } |
974 | 1017 |
@@ -978,7 +1021,11 @@ | ||
978 | 1021 | return this.navLockIcon.Visible; |
979 | 1022 | } |
980 | 1023 | set{ |
981 | - this.navLockIcon.Visible = value; | |
1024 | + if(value){ | |
1025 | + this.navLockIcon.Image = Shell.GetIconImage(StringEx.JoinPath(Resource.Path.ResourceDirectory, "Lock.ico"), IconSize.Small); | |
1026 | + }else{ | |
1027 | + this.navLockIcon.Image = Shell.GetIconImage(StringEx.JoinPath(Resource.Path.ResourceDirectory, "Unlock.ico"), IconSize.Small); | |
1028 | + } | |
982 | 1029 | } |
983 | 1030 | } |
984 | 1031 |
@@ -1050,15 +1097,25 @@ | ||
1050 | 1097 | } |
1051 | 1098 | } |
1052 | 1099 | |
1053 | - public class ToolStripGraphBar : ToolStripProgressBar{ | |
1100 | + public class ToolStripGraphBar : ToolStripLabel{ | |
1101 | + private int value; | |
1102 | + | |
1054 | 1103 | public ToolStripGraphBar(){ |
1055 | - | |
1056 | 1104 | } |
1057 | 1105 | |
1106 | + public int Value{ | |
1107 | + get{ | |
1108 | + return this.value; | |
1109 | + } | |
1110 | + set{ | |
1111 | + this.value = value; | |
1112 | + } | |
1113 | + } | |
1114 | + | |
1058 | 1115 | protected override void OnPaint(PaintEventArgs e){ |
1059 | - using(Pen rectPen = new Pen(SystemColors.WindowFrame)) | |
1060 | - using(Pen graphPen = new Pen(SystemColors.MenuHighlight)) | |
1061 | - using(Pen backgroundPen = new Pen(SystemColors.Menu)){ | |
1116 | + using(Pen rectPen = new Pen(SystemColors.Highlight)) | |
1117 | + using(Pen graphPen = new Pen(SystemColors.Highlight)) | |
1118 | + using(Pen backgroundPen = new Pen(SystemColors.Control)){ | |
1062 | 1119 | e.Graphics.DrawRectangle(backgroundPen, e.ClipRectangle); |
1063 | 1120 | e.Graphics.DrawLines(rectPen, new Point[]{ |
1064 | 1121 | new Point(e.ClipRectangle.Left, e.ClipRectangle.Top), |
@@ -1066,6 +1123,12 @@ | ||
1066 | 1123 | new Point(e.ClipRectangle.Right, e.ClipRectangle.Bottom), |
1067 | 1124 | new Point(e.ClipRectangle.Right, e.ClipRectangle.Top), |
1068 | 1125 | new Point(e.ClipRectangle.Left, e.ClipRectangle.Top)}); |
1126 | + e.Graphics.DrawRectangle(graphPen, new Rectangle( | |
1127 | + e.ClipRectangle.Left, | |
1128 | + e.ClipRectangle.Top, | |
1129 | + e.ClipRectangle.Left + (e.ClipRectangle.Width * 100 / this.value), | |
1130 | + e.ClipRectangle.Bottom | |
1131 | + )); | |
1069 | 1132 | } |
1070 | 1133 | } |
1071 | 1134 | } |
@@ -8,6 +8,7 @@ | ||
8 | 8 | using System.Windows.Forms; |
9 | 9 | using Kuon; |
10 | 10 | using Kuon.Forms; |
11 | +using Kuon.Utilities; | |
11 | 12 | |
12 | 13 | namespace Kuon.Filer{ |
13 | 14 | public class DoubleWindowFiler : SplitContainer{ |
@@ -26,7 +27,7 @@ | ||
26 | 27 | #region コンストラクタ |
27 | 28 | |
28 | 29 | public DoubleWindowFiler(ConfigFilerForm data){ |
29 | - this.Initialize(data.LeftFilerPath, data.RightFilerPath, data.LeftNavigationLockPath, data.RightNavigationLockPath); | |
30 | + this.Initialize(data); | |
30 | 31 | } |
31 | 32 | |
32 | 33 | #endregion |
@@ -33,23 +34,42 @@ | ||
33 | 34 | |
34 | 35 | #region 関数 |
35 | 36 | |
36 | - private void Initialize(string leftFilerPath, string rightFilerPath, string leftNavigationLockPath, string rightNavigationLockPath){ | |
37 | - if((leftFilerPath == null) || (rightFilerPath == null)){ | |
38 | - throw new ArgumentNullException(); | |
37 | + private void Initialize(ConfigFilerForm data){ | |
38 | + if(data.LeftFilerPath == null){ | |
39 | + data.LeftFilerPath = Environment.CurrentDirectory; | |
39 | 40 | } |
41 | + if(data.RightFilerPath == null){ | |
42 | + data.RightFilerPath = Environment.CurrentDirectory; | |
43 | + } | |
40 | 44 | |
41 | 45 | this.SuspendLayout(); |
42 | 46 | |
43 | 47 | // Filer |
44 | - this.leftFiler = new FilerControl(leftFilerPath); | |
45 | - this.rightFiler = new FilerControl(rightFilerPath); | |
48 | + this.leftFiler = new FilerControl(data.LeftFilerPath); | |
49 | + this.rightFiler = new FilerControl(data.RightFilerPath); | |
50 | + this.leftFiler.BorderStyle = BorderStyle.FixedSingle; | |
51 | + this.rightFiler.BorderStyle = BorderStyle.FixedSingle; | |
52 | + this.leftFiler.Dock = DockStyle.Fill; | |
53 | + this.rightFiler.Dock = DockStyle.Fill; | |
54 | + if(data.LeftBackHistory != null){ | |
55 | + this.leftFiler.BackHistory = data.LeftBackHistory; | |
56 | + } | |
57 | + if(data.RightBackHistory != null){ | |
58 | + this.rightFiler.BackHistory = data.RightBackHistory; | |
59 | + } | |
60 | + if(data.LeftForwardHistory != null){ | |
61 | + this.leftFiler.ForwardHistory = data.LeftForwardHistory; | |
62 | + } | |
63 | + if(data.RightForwardHistory != null){ | |
64 | + this.rightFiler.ForwardHistory = data.RightForwardHistory; | |
65 | + } | |
46 | 66 | this.container.Add(this.leftFiler); |
47 | 67 | this.container.Add(this.rightFiler); |
48 | - if(!(String.IsNullOrEmpty(leftNavigationLockPath))){ | |
49 | - this.leftFiler.NavigationLockPath = leftNavigationLockPath; | |
68 | + if(!(String.IsNullOrEmpty(data.LeftNavigationLockPath))){ | |
69 | + this.leftFiler.NavigationLockPath = data.LeftNavigationLockPath; | |
50 | 70 | } |
51 | - if(!(String.IsNullOrEmpty(rightNavigationLockPath))){ | |
52 | - this.rightFiler.NavigationLockPath = rightNavigationLockPath; | |
71 | + if(!(String.IsNullOrEmpty(data.RightNavigationLockPath))){ | |
72 | + this.rightFiler.NavigationLockPath = data.RightNavigationLockPath; | |
53 | 73 | } |
54 | 74 | |
55 | 75 | this.Orientation = FilerModule.FilerOption.Orientation; |
@@ -278,6 +278,10 @@ | ||
278 | 278 | this.RightFilerPath = filerForm.DoubleWindowFiler.RightFiler.Path + IO.Path.DirectorySeparatorChar; |
279 | 279 | this.LeftNavigationLockPath = filerForm.DoubleWindowFiler.LeftFiler.NavigationLockPath; |
280 | 280 | this.RightNavigationLockPath = filerForm.DoubleWindowFiler.RightFiler.NavigationLockPath; |
281 | + this.LeftBackHistory = filerForm.DoubleWindowFiler.LeftFiler.History.BackHistory; | |
282 | + this.RightBackHistory = filerForm.DoubleWindowFiler.RightFiler.History.BackHistory; | |
283 | + this.LeftForwardHistory = filerForm.DoubleWindowFiler.LeftFiler.History.ForwardHistory; | |
284 | + this.RightForwardHistory = filerForm.DoubleWindowFiler.RightFiler.History.ForwardHistory; | |
281 | 285 | } |
282 | 286 | |
283 | 287 | public override Form Restore(Form parent, bool isAddWindowBar){ |
@@ -323,5 +327,46 @@ | ||
323 | 327 | this.rightNavigationLockPath = value; |
324 | 328 | } |
325 | 329 | } |
330 | + | |
331 | + private string[] leftBackHistory = null; | |
332 | + public string[] LeftBackHistory{ | |
333 | + get{ | |
334 | + return this.leftBackHistory; | |
335 | + } | |
336 | + set{ | |
337 | + this.leftBackHistory = value; | |
338 | + } | |
339 | + } | |
340 | + | |
341 | + private string[] rightBackHistory = null; | |
342 | + public string[] RightBackHistory{ | |
343 | + get{ | |
344 | + return this.rightBackHistory; | |
345 | + } | |
346 | + set{ | |
347 | + this.rightBackHistory = value; | |
348 | + } | |
349 | + } | |
350 | + | |
351 | + | |
352 | + private string[] leftForwardHistory = null; | |
353 | + public string[] LeftForwardHistory{ | |
354 | + get{ | |
355 | + return this.leftForwardHistory; | |
356 | + } | |
357 | + set{ | |
358 | + this.leftForwardHistory = value; | |
359 | + } | |
360 | + } | |
361 | + | |
362 | + private string[] rightForwardHistory = null; | |
363 | + public string[] RightForwardHistory{ | |
364 | + get{ | |
365 | + return this.rightForwardHistory; | |
366 | + } | |
367 | + set{ | |
368 | + this.rightForwardHistory = value; | |
369 | + } | |
370 | + } | |
326 | 371 | } |
327 | 372 | } |
\ No newline at end of file |
@@ -43,7 +43,7 @@ | ||
43 | 43 | private LogicalOperation fileFilterMode = LogicalOperation.Or; |
44 | 44 | private readonly FileFilterCollection fileFilters = new FileFilterCollection(); |
45 | 45 | private readonly FileInfoProvider directory = new Directory(4096 * FilerModule.FilerOption.WatcherBufferSize); |
46 | - private readonly History<string> history = new History<string>(FilerModule.FilerOption.HistoryCount); | |
46 | + private History<string> history = new History<string>(FilerModule.FilerOption.HistoryCount); | |
47 | 47 | private readonly IContainer container = new Container(); |
48 | 48 | private readonly static object StaticSyncObject = new object(); |
49 | 49 | private string fileMask = "*.*"; |
@@ -53,6 +53,8 @@ | ||
53 | 53 | private BackgroundWorker autoRefreshWorker = new BackgroundWorker(); |
54 | 54 | private Queue<IO.FileSystemEventArgs> autoRefreshQueue = new Queue<IO.FileSystemEventArgs>(); |
55 | 55 | private Queue<IO.FileSystemEventArgs> autoRefreshEvents = new Queue<IO.FileSystemEventArgs>(); |
56 | + private Queue<GetInfoItem> getInfoQueue = new Queue<GetInfoItem>(); | |
57 | + private BackgroundWorker infoWorker = new BackgroundWorker(); | |
56 | 58 | |
57 | 59 | /* |
58 | 60 | ImageList.ImageCollectionのキーについて。 |
@@ -86,8 +88,6 @@ | ||
86 | 88 | //private const int DownImageIndex = 1; |
87 | 89 | private static readonly DelayProcess incrementWatcherBufferSizeDelayProcess = new DelayProcess(); |
88 | 90 | private static readonly ContextMenuStrip contextMenuStrip; |
89 | - private static Queue<GetInfoItem> getInfoQueue = new Queue<GetInfoItem>(); | |
90 | - private static BackgroundWorker infoWorker = new BackgroundWorker(); | |
91 | 91 | |
92 | 92 | #endregion |
93 | 93 |
@@ -138,12 +138,6 @@ | ||
138 | 138 | MessageBox.Show(ex.Message); |
139 | 139 | } |
140 | 140 | |
141 | - infoWorker.WorkerReportsProgress = true; | |
142 | - infoWorker.WorkerSupportsCancellation = true; | |
143 | - infoWorker.DoWork += new DoWorkEventHandler(GetInfo_DoWork); | |
144 | - infoWorker.ProgressChanged += new ProgressChangedEventHandler(GetInfo_ProgressChanged); | |
145 | - infoWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(GetInfo_RunWorkerCompleted); | |
146 | - | |
147 | 141 | AppDomain.CurrentDomain.ProcessExit += ProcessExitEventListener; |
148 | 142 | } |
149 | 143 |
@@ -166,9 +160,10 @@ | ||
166 | 160 | if(!(String.IsNullOrEmpty(FilerModule.FilerOption.BackgroundImage))){ |
167 | 161 | try{ |
168 | 162 | this.BackColor = Color.Empty; |
169 | - IO.FileStream stream = new IO.FileStream(FilerModule.FilerOption.BackgroundImage, IO.FileMode.Open, IO.FileAccess.Read); | |
170 | - this.BackgroundImage = Image.FromStream(stream); | |
171 | - stream.Close(); | |
163 | + using(IO.FileStream stream = new IO.FileStream(FilerModule.FilerOption.BackgroundImage, IO.FileMode.Open, IO.FileAccess.Read)){ | |
164 | + this.BackgroundImage = Image.FromStream(stream); | |
165 | + stream.Close(); | |
166 | + } | |
172 | 167 | this.BackgroundImageTiled = FilerModule.FilerOption.BackgroundImageTiled; |
173 | 168 | }catch(Exception ex){ |
174 | 169 | this.BackgroundImage = null; |
@@ -191,7 +186,8 @@ | ||
191 | 186 | this.LabelEdit = false; |
192 | 187 | this.LabelWrap = true; |
193 | 188 | this.MultiSelect = true; |
194 | - this.ShowItemToolTips = FilerModule.FilerOption.ShowItemToolTips; | |
189 | + base.ShowItemToolTips = true; | |
190 | + this.showItemToolTips = FilerModule.FilerOption.ShowItemToolTips; | |
195 | 191 | //this.OwnerDraw = true; |
196 | 192 | //this.SetStyle(ControlStyles.UserPaint, true); |
197 | 193 | this.View = FilerModule.FilerOption.ViewStyle; |
@@ -230,6 +226,12 @@ | ||
230 | 226 | this.autoRefreshWorker.WorkerSupportsCancellation = true; |
231 | 227 | this.autoRefreshWorker.WorkerReportsProgress = true; |
232 | 228 | |
229 | + this.infoWorker.WorkerReportsProgress = true; | |
230 | + this.infoWorker.WorkerSupportsCancellation = true; | |
231 | + this.infoWorker.DoWork += new DoWorkEventHandler(GetInfo_DoWork); | |
232 | + this.infoWorker.ProgressChanged += new ProgressChangedEventHandler(GetInfo_ProgressChanged); | |
233 | + this.infoWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(GetInfo_RunWorkerCompleted); | |
234 | + | |
233 | 235 | // 自動更新 |
234 | 236 | this.container.Add(this.directory); |
235 | 237 | this.directory.Changed += this.DirectoryChangedEventListener; |
@@ -273,6 +275,7 @@ | ||
273 | 275 | lock(this.autoRefreshQueue){ |
274 | 276 | if(!(this.autoRefreshWorker.IsBusy) && (this.autoRefreshQueue.Count > 0) && (this.directory.EnableRaisingEvents)){ |
275 | 277 | MainForm.Instance.StatusBar.Progress.Start(this.autoRefreshWorker); |
278 | + this.Cursor = Cursors.AppStarting; | |
276 | 279 | this.autoRefreshWorker.RunWorkerAsync(); |
277 | 280 | } |
278 | 281 | } |
@@ -434,7 +437,7 @@ | ||
434 | 437 | List<ListViewItem> items = new List<ListViewItem>(state.FilesToAdd.Count); |
435 | 438 | lock(this.itemDictionary){ |
436 | 439 | foreach(var elm in state.FilesToAdd){ |
437 | - lock(getInfoQueue){ | |
440 | + lock(this.getInfoQueue){ | |
438 | 441 | if(this.fileFilters.Count > 0){ |
439 | 442 | if(!(this.fileFilters.IsMatch(elm.Value.Info, this.fileFilterMode))){ |
440 | 443 | continue; |
@@ -453,7 +456,7 @@ | ||
453 | 456 | var infoItem = new GetInfoItem(item, InfoType.Icon, null); |
454 | 457 | infoItem.UseSimpleIcon = this.useSimpleIcon; |
455 | 458 | infoItem.UseSmallIcon = this.UseSmallIcon; |
456 | - getInfoQueue.Enqueue(infoItem); | |
459 | + this.getInfoQueue.Enqueue(infoItem); | |
457 | 460 | } |
458 | 461 | } |
459 | 462 | if(elm.Value.State != null){ |
@@ -513,6 +516,9 @@ | ||
513 | 516 | |
514 | 517 | private void AutoRefreshWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e){ |
515 | 518 | MainForm.Instance.StatusBar.Progress.Complete(this.autoRefreshWorker); |
519 | + if(!(this.infoWorker.IsBusy || this.listWorker.IsBusy)){ | |
520 | + this.Cursor = Cursors.Default; | |
521 | + } | |
516 | 522 | this.StartAutoRefreshWorker(); |
517 | 523 | } |
518 | 524 |
@@ -707,11 +713,7 @@ | ||
707 | 713 | this.List(0, focusedItemText); |
708 | 714 | } |
709 | 715 | |
710 | - private Stopwatch sw = new Stopwatch(); | |
711 | - | |
712 | 716 | private void List(int focusedItemIndex, string focusedItemText){ |
713 | - this.sw.Reset(); | |
714 | - this.sw.Start(); | |
715 | 717 | lock(this.autoRefreshQueue){ |
716 | 718 | this.autoRefreshQueue.Clear(); |
717 | 719 | this.autoRefreshWorker.CancelAsync(); |
@@ -724,6 +726,7 @@ | ||
724 | 726 | } |
725 | 727 | |
726 | 728 | MainForm.Instance.StatusBar.Progress.Start(this.listWorker); |
729 | + this.Cursor = Cursors.AppStarting; | |
727 | 730 | |
728 | 731 | this.BeginUpdate(); |
729 | 732 |
@@ -742,9 +745,6 @@ | ||
742 | 745 | |
743 | 746 | this.EndUpdate(); |
744 | 747 | |
745 | - this.sw.Stop(); | |
746 | - MainForm.AddOutput(this.path + " : Initializing : " + this.sw.ElapsedMilliseconds); | |
747 | - | |
748 | 748 | if(!(focusedItemText.IsNullOrEmpty())){ |
749 | 749 | focusedItemIndex = -1; |
750 | 750 | } |
@@ -753,18 +753,12 @@ | ||
753 | 753 | |
754 | 754 | private void ListWorker_DoWork(object sender, DoWorkEventArgs e){ |
755 | 755 | try{ |
756 | - this.sw.Reset(); | |
757 | - this.sw.Start(); | |
758 | 756 | ListWorkerArgument arg = (ListWorkerArgument)e.Argument; |
759 | 757 | e.Result = arg; |
760 | 758 | this.directory.Refresh(); |
761 | - this.sw.Stop(); | |
762 | - MainForm.AddOutput(this.path + " : Listing : " + this.sw.ElapsedMilliseconds); | |
763 | 759 | |
764 | 760 | |
765 | 761 | if(!(this.listWorker.CancellationPending)){ |
766 | - this.sw.Reset(); | |
767 | - this.sw.Start(); | |
768 | 762 | List<FileInfo> infos = new List<FileInfo>(); |
769 | 763 | foreach(FileInfo info in this.directory){ |
770 | 764 | if( |
@@ -773,29 +767,19 @@ | ||
773 | 767 | infos.Add(info); |
774 | 768 | } |
775 | 769 | } |
776 | - this.sw.Stop(); | |
777 | - MainForm.AddOutput(this.path + " : Filtering : " + this.sw.ElapsedMilliseconds); | |
778 | 770 | |
779 | 771 | infos.Sort(((ListViewItemComparer)this.ListViewItemSorter).Comparer); |
780 | 772 | |
781 | - this.sw.Reset(); | |
782 | - this.sw.Start(); | |
783 | 773 | arg.Items = new ListViewItem[infos.Count]; |
784 | 774 | arg.ItemList = new List<ListViewItem>(); |
785 | - Stopwatch sw2 = new Stopwatch(); | |
786 | - sw2.Reset(); | |
787 | - sw2.Start(); | |
788 | 775 | for(int i = 0; i < infos.Count; i++){ |
789 | 776 | ListViewItem item = this.BuildItem(infos[i]); |
790 | 777 | arg.Items[i] = item; |
791 | 778 | arg.ItemList.Add(item); |
792 | 779 | } |
793 | - sw2.Stop(); | |
794 | 780 | if(arg.ItemList.Count > 0){ |
795 | 781 | this.listWorker.ReportProgress(100, new ListWorkerProgress(arg.FocusedItemIndex, arg.FocusedItemText, arg.ItemList, arg.Items)); |
796 | 782 | } |
797 | - this.sw.Stop(); | |
798 | - MainForm.AddOutput(this.path + " : Building : " + this.sw.ElapsedMilliseconds); | |
799 | 783 | }else{ |
800 | 784 | e.Cancel = true; |
801 | 785 | } |
@@ -805,8 +789,6 @@ | ||
805 | 789 | } |
806 | 790 | |
807 | 791 | private void ListWorker_ProgressChanged(object sender, ProgressChangedEventArgs e){ |
808 | - this.sw.Reset(); | |
809 | - this.sw.Start(); | |
810 | 792 | ListWorkerProgress arg = (ListWorkerProgress)e.UserState; |
811 | 793 | |
812 | 794 | MainForm.Instance.StatusBar.Progress.Report(this.listWorker, e.ProgressPercentage); |
@@ -814,7 +796,7 @@ | ||
814 | 796 | this.BeginUpdate(); |
815 | 797 | ListViewItem focusedItem = null; |
816 | 798 | lock(this.itemDictionary){ |
817 | - lock(getInfoQueue){ | |
799 | + lock(this.getInfoQueue){ | |
818 | 800 | foreach(ListViewItem item in arg.ItemList){ |
819 | 801 | if(!(String.IsNullOrEmpty(arg.FocusedItemText)) && (StringComparer.OrdinalIgnoreCase.Equals(item.Text, arg.FocusedItemText))){ |
820 | 802 | focusedItem = item; |
@@ -827,7 +809,7 @@ | ||
827 | 809 | var infoItem = new GetInfoItem(item, InfoType.Icon, null); |
828 | 810 | infoItem.UseSimpleIcon = this.useSimpleIcon; |
829 | 811 | infoItem.UseSmallIcon = this.UseSmallIcon; |
830 | - getInfoQueue.Enqueue(infoItem); | |
812 | + this.getInfoQueue.Enqueue(infoItem); | |
831 | 813 | } |
832 | 814 | } |
833 | 815 | this.itemDictionary.Add(item.Name, item); |
@@ -844,8 +826,6 @@ | ||
844 | 826 | } |
845 | 827 | |
846 | 828 | this.EndUpdate(); |
847 | - this.sw.Stop(); | |
848 | - MainForm.AddOutput(this.path + " : Adding : " + this.sw.ElapsedMilliseconds); | |
849 | 829 | |
850 | 830 | StartGetInfoServer(); |
851 | 831 | } |
@@ -852,6 +832,9 @@ | ||
852 | 832 | |
853 | 833 | private void ListWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e){ |
854 | 834 | MainForm.Instance.StatusBar.Progress.Complete(this.listWorker); |
835 | + if(!(this.infoWorker.IsBusy || this.autoRefreshWorker.IsBusy)){ | |
836 | + this.Cursor = Cursors.Default; | |
837 | + } | |
855 | 838 | this.directory.EnableRaisingEvents = true; |
856 | 839 | } |
857 | 840 |
@@ -946,13 +929,13 @@ | ||
946 | 929 | subItem.Tag = column.Tag; |
947 | 930 | switch((FolderViewColumn)column.Tag){ |
948 | 931 | case FolderViewColumn.OwnerName: |
949 | - lock(getInfoQueue){ | |
950 | - getInfoQueue.Enqueue(new GetInfoItem(item, InfoType.OwnerName, subItem)); | |
932 | + lock(this.getInfoQueue){ | |
933 | + this.getInfoQueue.Enqueue(new GetInfoItem(item, InfoType.OwnerName, subItem)); | |
951 | 934 | } |
952 | 935 | break; |
953 | 936 | case FolderViewColumn.FileRights:{ |
954 | - lock(getInfoQueue){ | |
955 | - getInfoQueue.Enqueue(new GetInfoItem(item, InfoType.FileRights, subItem)); | |
937 | + lock(this.getInfoQueue){ | |
938 | + this.getInfoQueue.Enqueue(new GetInfoItem(item, InfoType.FileRights, subItem)); | |
956 | 939 | } |
957 | 940 | break; |
958 | 941 | } |
@@ -963,8 +946,10 @@ | ||
963 | 946 | item.Name = info.Name; |
964 | 947 | item.Tag = info; |
965 | 948 | |
966 | - if(this.ShowItemToolTips){ | |
949 | + if(this.showItemToolTips){ | |
967 | 950 | item.ToolTipText = GetToolTipText(info); |
951 | + }else{ | |
952 | + item.ToolTipText = item.Text; | |
968 | 953 | } |
969 | 954 | |
970 | 955 | // アイコン |
@@ -1189,16 +1174,17 @@ | ||
1189 | 1174 | return sb.ToString(); |
1190 | 1175 | } |
1191 | 1176 | |
1192 | - private static void StartGetInfoServer(){ | |
1193 | - lock(getInfoQueue){ | |
1194 | - if((getInfoQueue.Count > 0) && !(infoWorker.IsBusy)){ | |
1195 | - MainForm.Instance.StatusBar.Progress.Start(infoWorker); | |
1177 | + private void StartGetInfoServer(){ | |
1178 | + lock(this.getInfoQueue){ | |
1179 | + if((this.getInfoQueue.Count > 0) && !(infoWorker.IsBusy)){ | |
1180 | + MainForm.Instance.StatusBar.Progress.Start(this.infoWorker); | |
1181 | + this.Cursor = Cursors.AppStarting; | |
1196 | 1182 | infoWorker.RunWorkerAsync(); |
1197 | 1183 | } |
1198 | 1184 | } |
1199 | 1185 | } |
1200 | 1186 | |
1201 | - private static void GetInfo_DoWork(object sender, DoWorkEventArgs e){ | |
1187 | + private void GetInfo_DoWork(object sender, DoWorkEventArgs e){ | |
1202 | 1188 | try{ |
1203 | 1189 | Stopwatch sw = new Stopwatch(); |
1204 | 1190 | sw.Reset(); |
@@ -1206,9 +1192,9 @@ | ||
1206 | 1192 | List<GetInfoItem> list = new List<GetInfoItem>(); |
1207 | 1193 | do{ |
1208 | 1194 | GetInfoItem item; |
1209 | - lock(getInfoQueue){ | |
1210 | - if(getInfoQueue.Count > 0){ | |
1211 | - item = getInfoQueue.Dequeue(); | |
1195 | + lock(this.getInfoQueue){ | |
1196 | + if(this.getInfoQueue.Count > 0){ | |
1197 | + item = this.getInfoQueue.Dequeue(); | |
1212 | 1198 | }else{ |
1213 | 1199 | break; |
1214 | 1200 | } |
@@ -1258,7 +1244,7 @@ | ||
1258 | 1244 | } |
1259 | 1245 | } |
1260 | 1246 | |
1261 | - private static void GetInfo_ProgressChanged(object sender, ProgressChangedEventArgs e){ | |
1247 | + private void GetInfo_ProgressChanged(object sender, ProgressChangedEventArgs e){ | |
1262 | 1248 | GetInfoItem[] items = (GetInfoItem[])e.UserState; |
1263 | 1249 | |
1264 | 1250 | foreach(GetInfoItem item in items){ |
@@ -1289,8 +1275,11 @@ | ||
1289 | 1275 | MainForm.Instance.StatusBar.Progress.Report(infoWorker, e.ProgressPercentage); |
1290 | 1276 | } |
1291 | 1277 | |
1292 | - private static void GetInfo_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e){ | |
1278 | + private void GetInfo_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e){ | |
1293 | 1279 | MainForm.Instance.StatusBar.Progress.Complete(infoWorker); |
1280 | + if(!(this.autoRefreshWorker.IsBusy || this.listWorker.IsBusy)){ | |
1281 | + this.Cursor = Cursors.Default; | |
1282 | + } | |
1294 | 1283 | StartGetInfoServer(); |
1295 | 1284 | } |
1296 | 1285 |
@@ -1908,7 +1897,7 @@ | ||
1908 | 1897 | |
1909 | 1898 | private bool ReuseHistory(string dir, int reuseHistoryCount, ref string name){ |
1910 | 1899 | int i = 0; |
1911 | - foreach(string history in this.history.BackStack){ | |
1900 | + foreach(string history in this.history.BackHistory){ | |
1912 | 1901 | if(reuseHistoryCount < ++i){ |
1913 | 1902 | break; |
1914 | 1903 | } |
@@ -1917,12 +1906,14 @@ | ||
1917 | 1906 | name = IO.Path.GetFileName(history); |
1918 | 1907 | } |
1919 | 1908 | this.history.Current = this.FocusedFile ?? this.path; |
1920 | - this.history.Back(i); | |
1909 | + for(int j = 0; j < i; j++){ | |
1910 | + this.history.Back(); | |
1911 | + } | |
1921 | 1912 | return true; |
1922 | 1913 | } |
1923 | 1914 | } |
1924 | 1915 | i = 0; |
1925 | - foreach(string history in this.history.ForwardStack){ | |
1916 | + foreach(string history in this.history.ForwardHistory){ | |
1926 | 1917 | if(reuseHistoryCount < ++i){ |
1927 | 1918 | break; |
1928 | 1919 | } |
@@ -1931,7 +1922,9 @@ | ||
1931 | 1922 | name = IO.Path.GetFileName(history); |
1932 | 1923 | } |
1933 | 1924 | this.history.Current = this.FocusedFile ?? this.path; |
1934 | - this.history.Forward(i); | |
1925 | + for(int j = 0; j < i; j++){ | |
1926 | + this.history.Forward(); | |
1927 | + } | |
1935 | 1928 | return true; |
1936 | 1929 | } |
1937 | 1930 | } |
@@ -1948,7 +1941,7 @@ | ||
1948 | 1941 | } |
1949 | 1942 | |
1950 | 1943 | public void GoForwardHistory(){ |
1951 | - if(this.history.Forward()){ | |
1944 | + if(this.history.Forward() != null){ | |
1952 | 1945 | if(this.IsAllowToGo(this.history.Current)){ |
1953 | 1946 | this.ChangeDirectory(this.history.Current, false); |
1954 | 1947 | }else{ |
@@ -1959,12 +1952,16 @@ | ||
1959 | 1952 | } |
1960 | 1953 | |
1961 | 1954 | public void GoForwardHistory(int count){ |
1962 | - this.history.Forward(count); | |
1955 | + for(int i = 0; i < count; i++){ | |
1956 | + this.history.Forward(); | |
1957 | + } | |
1963 | 1958 | if(this.IsAllowToGo(this.history.Current)){ |
1964 | 1959 | this.ChangeDirectory(this.history.Current, false); |
1965 | 1960 | }else{ |
1966 | 1961 | MainForm.Instance.MessageBeep(MessageBeep.Okey); |
1967 | - this.history.Back(count); | |
1962 | + for(int i = 0; i < count; i++){ | |
1963 | + this.history.Back(); | |
1964 | + } | |
1968 | 1965 | } |
1969 | 1966 | } |
1970 | 1967 |
@@ -1977,7 +1974,7 @@ | ||
1977 | 1974 | this.history.Current = focusedFile; |
1978 | 1975 | } |
1979 | 1976 | } |
1980 | - if(this.history.Back()){ | |
1977 | + if(this.history.Back() != null){ | |
1981 | 1978 | if(this.IsAllowToGo(this.history.Current)){ |
1982 | 1979 | this.ChangeDirectory(this.history.Current, false); |
1983 | 1980 | }else{ |
@@ -1996,12 +1993,16 @@ | ||
1996 | 1993 | this.history.Current = focusedFile; |
1997 | 1994 | } |
1998 | 1995 | } |
1999 | - this.history.Back(count); | |
1996 | + for(int i = 0; i < count; i++){ | |
1997 | + this.history.Back(); | |
1998 | + } | |
2000 | 1999 | if(this.IsAllowToGo(this.history.Current)){ |
2001 | 2000 | this.ChangeDirectory(this.history.Current, false); |
2002 | 2001 | }else{ |
2003 | 2002 | MainForm.Instance.MessageBeep(MessageBeep.Okey); |
2004 | - this.history.Forward(count); | |
2003 | + for(int i = 0; i < count; i++){ | |
2004 | + this.history.Forward(); | |
2005 | + } | |
2005 | 2006 | } |
2006 | 2007 | } |
2007 | 2008 |
@@ -2164,13 +2165,12 @@ | ||
2164 | 2165 | public void CheckAndDown(){ |
2165 | 2166 | this.Check(); |
2166 | 2167 | int idx = this.FocusedItemIndex + 1; |
2167 | - this.ClearSelection(false); | |
2168 | 2168 | if(idx < this.Items.Count){ |
2169 | 2169 | this.FocusedItemIndex = idx; |
2170 | 2170 | } |
2171 | - try{ | |
2171 | + this.ClearSelection(false); | |
2172 | + if(this.FocusedItem != null){ | |
2172 | 2173 | this.FocusedItem.Selected = true; |
2173 | - }catch(NullReferenceException){ | |
2174 | 2174 | } |
2175 | 2175 | } |
2176 | 2176 |
@@ -2315,10 +2315,21 @@ | ||
2315 | 2315 | } |
2316 | 2316 | } |
2317 | 2317 | |
2318 | + | |
2318 | 2319 | #endregion |
2319 | 2320 | |
2320 | 2321 | #region プロパティ |
2321 | 2322 | |
2323 | + public History<string> History{ | |
2324 | + get{ | |
2325 | + return this.history; | |
2326 | + } | |
2327 | + set{ | |
2328 | + this.history = value; | |
2329 | + this.history.LimitCount = FilerModule.FilerOption.HistoryCount; | |
2330 | + } | |
2331 | + } | |
2332 | + | |
2322 | 2333 | public string Path{ |
2323 | 2334 | get{ |
2324 | 2335 | return this.path; |
@@ -2536,14 +2547,20 @@ | ||
2536 | 2547 | |
2537 | 2548 | public string[] ForwardHistory{ |
2538 | 2549 | get{ |
2539 | - return this.history.ForwardStack.ToArray(); | |
2550 | + return this.history.ForwardHistory; | |
2540 | 2551 | } |
2552 | + set{ | |
2553 | + this.history.ForwardHistory = value; | |
2554 | + } | |
2541 | 2555 | } |
2542 | 2556 | |
2543 | 2557 | public string[] BackHistory{ |
2544 | 2558 | get{ |
2545 | - return this.history.BackStack.ToArray(); | |
2559 | + return this.history.BackHistory; | |
2546 | 2560 | } |
2561 | + set{ | |
2562 | + this.history.BackHistory = value; | |
2563 | + } | |
2547 | 2564 | } |
2548 | 2565 | |
2549 | 2566 | public int LimitHistoryCount{ |
@@ -2666,6 +2683,16 @@ | ||
2666 | 2683 | } |
2667 | 2684 | } |
2668 | 2685 | |
2686 | + private bool showItemToolTips = true; | |
2687 | + public new bool ShowItemToolTips{ | |
2688 | + get{ | |
2689 | + return this.showItemToolTips; | |
2690 | + } | |
2691 | + set{ | |
2692 | + this.showItemToolTips = value; | |
2693 | + } | |
2694 | + } | |
2695 | + | |
2669 | 2696 | #endregion |
2670 | 2697 | |
2671 | 2698 | #region イベント |
@@ -1490,6 +1490,10 @@ | ||
1490 | 1490 | } |
1491 | 1491 | } |
1492 | 1492 | |
1493 | + public static void ToggleNavigation(){ | |
1494 | + ToggleNavigation(null, null); | |
1495 | + } | |
1496 | + | |
1493 | 1497 | private static void ToggleNavigation(object sender, ActionEventArgs e){ |
1494 | 1498 | FilerControl actFiler = FilerForm.ActiveFiler; |
1495 | 1499 | if(actFiler != null){ |
@@ -1650,6 +1654,10 @@ | ||
1650 | 1654 | } |
1651 | 1655 | } |
1652 | 1656 | |
1657 | + public static void SetFileFilter(){ | |
1658 | + SetFileFilter(null, ActionEventArgs.Empty); | |
1659 | + } | |
1660 | + | |
1653 | 1661 | private static void SetFileFilter(object sender, ActionEventArgs e){ |
1654 | 1662 | FilerControl actFiler = FilerForm.ActiveFiler; |
1655 | 1663 | if(actFiler != null){ |
@@ -2103,6 +2111,21 @@ | ||
2103 | 2111 | } |
2104 | 2112 | |
2105 | 2113 | public override void Apply(){ |
2114 | + { | |
2115 | + int lenWidths = this.ColumnWidths.Length; | |
2116 | + int lenOrder = this.ColumnOrder.Length; | |
2117 | + if(lenOrder > lenWidths){ | |
2118 | + int[] widths = new int[lenOrder]; | |
2119 | + this.ColumnWidths.CopyTo(widths, 0); | |
2120 | + for(int i = lenWidths; i < lenOrder; i++){ | |
2121 | + widths[i] = 100; | |
2122 | + } | |
2123 | + this.ColumnWidths = widths; | |
2124 | + }else if(lenOrder < lenWidths){ | |
2125 | + Array.Resize(ref this.columnWidths, lenOrder); | |
2126 | + } | |
2127 | + } | |
2128 | + | |
2106 | 2129 | if(MainForm.Instance != null){ |
2107 | 2130 | foreach(FilerForm form in FilerForm.FilerForms){ |
2108 | 2131 | form.DoubleWindowFiler.LeftFiler.AutoFitColumn = form.DoubleWindowFiler.RightFiler.AutoFitColumn = this.AutoFitColumn; |
@@ -2130,9 +2153,11 @@ | ||
2130 | 2153 | try{ |
2131 | 2154 | form.DoubleWindowFiler.LeftFiler.BackColor = Color.Empty; |
2132 | 2155 | form.DoubleWindowFiler.RightFiler.BackColor = Color.Empty; |
2133 | - IO.FileStream stream = new IO.FileStream(this.BackgroundImage, IO.FileMode.Open, IO.FileAccess.Read); | |
2134 | - Image image = Image.FromStream(stream); | |
2135 | - stream.Close(); | |
2156 | + Image image = null; | |
2157 | + using(IO.FileStream stream = new IO.FileStream(this.BackgroundImage, IO.FileMode.Open, IO.FileAccess.Read)){ | |
2158 | + image = Image.FromStream(stream); | |
2159 | + stream.Close(); | |
2160 | + } | |
2136 | 2161 | form.DoubleWindowFiler.LeftFiler.BackgroundImage = image; |
2137 | 2162 | form.DoubleWindowFiler.RightFiler.BackgroundImage = image; |
2138 | 2163 | }catch(Exception ex){ |
@@ -2156,18 +2181,6 @@ | ||
2156 | 2181 | |
2157 | 2182 | form.DoubleWindowFiler.LeftFiler.Columns.Clear(); |
2158 | 2183 | form.DoubleWindowFiler.RightFiler.Columns.Clear(); |
2159 | - int lenWidths = this.ColumnWidths.Length; | |
2160 | - int lenOrder = this.ColumnOrder.Length; | |
2161 | - if(lenOrder > lenWidths){ | |
2162 | - int[] widths = new int[lenOrder]; | |
2163 | - this.ColumnWidths.CopyTo(widths, 0); | |
2164 | - for(int i = lenOrder - 1; i < lenWidths; i++){ | |
2165 | - widths[i] = 100; | |
2166 | - } | |
2167 | - this.ColumnWidths = widths; | |
2168 | - }else if(lenOrder < lenWidths){ | |
2169 | - Array.Resize(ref this.columnWidths, lenOrder); | |
2170 | - } | |
2171 | 2184 | for(int i = 0; i < this.ColumnOrder.Length; i++){ |
2172 | 2185 | form.DoubleWindowFiler.LeftFiler.AddColumn(this.ColumnOrder[i], this.ColumnWidths[i]); |
2173 | 2186 | form.DoubleWindowFiler.RightFiler.AddColumn(this.ColumnOrder[i], this.ColumnWidths[i]); |
@@ -2625,7 +2638,7 @@ | ||
2625 | 2638 | } |
2626 | 2639 | } |
2627 | 2640 | |
2628 | - private string[] ignoreCachingIconFileTypes = new string[]{".exe", ".ico", ".lnk", ".icl", ".msc", ".cpl"}; | |
2641 | + private string[] ignoreCachingIconFileTypes = new string[]{".exe", ".ico", ".lnk", ".icl", ".msc", ".cpl", ".cur", ".ani"}; | |
2629 | 2642 | [Category("ViewCategory")] |
2630 | 2643 | [Description("IgnoreCachingIconFileTypesDescription")] |
2631 | 2644 | [DefaultValue(true)] |
@@ -4,8 +4,11 @@ | ||
4 | 4 | |
5 | 5 | using System; |
6 | 6 | using System.ComponentModel; |
7 | +using System.Collections.Generic; | |
8 | +using System.Collections.ObjectModel; | |
7 | 9 | using System.Drawing; |
8 | 10 | using System.Drawing.Drawing2D; |
11 | +using System.Drawing.Imaging; | |
9 | 12 | using System.Threading; |
10 | 13 | using System.Windows.Forms; |
11 | 14 | using Kuon.Utilities; |
@@ -12,18 +15,39 @@ | ||
12 | 15 | |
13 | 16 | namespace Kuon.Viewer{ |
14 | 17 | public class ViewerControl : UserControl{ |
18 | + #region field | |
19 | + | |
15 | 20 | private BackgroundWorker loadingWorker = new BackgroundWorker(); |
16 | 21 | private BackgroundWorker refreshWorker = new BackgroundWorker(); |
17 | 22 | private PictureBox pictureBox = new PictureBox(); |
18 | - private Bitmap originalImage = null; | |
23 | + private GflBitmap originalImage = null; | |
19 | 24 | private double scale = 1.0; |
20 | - private ImageFittingMode fittingMode = ImageFittingMode.Window; | |
25 | + private ImageFittingMode fittingMode = ImageFittingMode.WindowLargeOnly; | |
26 | + private FileList fileList = new FileList(); | |
21 | 27 | |
28 | + #endregion | |
29 | + | |
30 | + #region constructor | |
31 | + | |
22 | 32 | public ViewerControl(){ |
33 | + this.SuspendLayout(); | |
34 | + | |
23 | 35 | this.AutoScroll = true; |
24 | - this.BackColor = Color.Black; | |
36 | + this.BackColor = SystemColors.AppWorkspace; | |
25 | 37 | |
26 | - this.Controls.Add(pictureBox); | |
38 | + Bitmap backgroundTexture = new Bitmap(32, 32); | |
39 | + using(Graphics g = Graphics.FromImage(backgroundTexture)) | |
40 | + using(SolidBrush brush1 = new SolidBrush(SystemColors.Window)) | |
41 | + using(SolidBrush brush2 = new SolidBrush(SystemColors.AppWorkspace)) | |
42 | + { | |
43 | + g.FillRectangle(brush1, 0, 0, 16, 16); | |
44 | + g.FillRectangle(brush1, 16, 16, 16, 16); | |
45 | + g.FillRectangle(brush2, 16, 0, 16, 16); | |
46 | + g.FillRectangle(brush2, 0, 16, 16, 16); | |
47 | + } | |
48 | + this.pictureBox.BackgroundImage = backgroundTexture; | |
49 | + this.pictureBox.BackgroundImageLayout = ImageLayout.Tile; | |
50 | + this.Controls.Add(this.pictureBox); | |
27 | 51 | |
28 | 52 | this.loadingWorker.DoWork += this.LoadImage_DoWork; |
29 | 53 | this.loadingWorker.RunWorkerCompleted += this.LoadImage_RunWorkerCompleted; |
@@ -34,9 +58,21 @@ | ||
34 | 58 | this.refreshWorker.RunWorkerCompleted += this.RefreshImage_RunWorkerCompleted; |
35 | 59 | //this.refreshWorker.WorkerReportsProgress = true; |
36 | 60 | this.refreshWorker.WorkerSupportsCancellation = true; |
61 | + | |
62 | + this.ResumeLayout(); | |
37 | 63 | } |
38 | 64 | |
39 | - public void LoadImage(string path){ | |
65 | + #endregion | |
66 | + | |
67 | + #region Load | |
68 | + | |
69 | + public void OpenImage(string path){ | |
70 | + this.fileList.Clear(); | |
71 | + this.fileList.Add(path); | |
72 | + this.LoadImage(this.fileList.Current); | |
73 | + } | |
74 | + | |
75 | + private void LoadImage(string path){ | |
40 | 76 | if(path == null){ |
41 | 77 | throw new ArgumentNullException(); |
42 | 78 | } |
@@ -52,6 +88,7 @@ | ||
52 | 88 | LoadImageArgument arg = new LoadImageArgument(path); |
53 | 89 | |
54 | 90 | MainForm.Instance.StatusBar.Progress.Start(arg); |
91 | + this.Cursor = Cursors.AppStarting; | |
55 | 92 | this.loadingWorker.RunWorkerAsync(arg); |
56 | 93 | } |
57 | 94 |
@@ -64,23 +101,28 @@ | ||
64 | 101 | return; |
65 | 102 | } |
66 | 103 | |
67 | - using(GflBitmap bmp = GflBitmap.FromFile(arg.Path, new GflProgressCallback(delegate(object sender2, GflProgressEventArgs e2){ | |
104 | + arg.Bitmap = GflBitmap.FromFile(arg.Path, new GflProgressCallback(delegate(object sender2, GflProgressEventArgs e2){ | |
68 | 105 | this.Invoke(new MethodInvoker(delegate{ |
69 | 106 | MainForm.Instance.StatusBar.Progress.Report(arg, e2.ProgressPercentage); |
70 | 107 | })); |
71 | - }))){ | |
72 | - arg.Bitmap = bmp.ToBitmap(); | |
73 | - } | |
108 | + })); | |
74 | 109 | |
75 | 110 | if(this.loadingWorker.CancellationPending){ |
76 | 111 | arg.Cancelled = true; |
77 | 112 | return; |
78 | 113 | } |
114 | + | |
115 | + this.Invoke(new MethodInvoker(delegate{ | |
116 | + this.OnImageLoaded(new ImageLoadedEventArgs(arg.Bitmap)); | |
117 | + })); | |
79 | 118 | } |
80 | 119 | |
81 | 120 | private void LoadImage_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e){ |
82 | 121 | LoadImageArgument arg = (LoadImageArgument)e.Result; |
83 | 122 | MainForm.Instance.StatusBar.Progress.Complete(arg); |
123 | + if(!(this.refreshWorker.IsBusy)){ | |
124 | + this.Cursor = Cursors.Default; | |
125 | + } | |
84 | 126 | |
85 | 127 | if(arg.Cancelled){ |
86 | 128 | this.originalImage = null; |
@@ -92,7 +134,7 @@ | ||
92 | 134 | |
93 | 135 | public class LoadImageArgument{ |
94 | 136 | public string Path{get; private set;} |
95 | - public Bitmap Bitmap{get; set;} | |
137 | + public GflBitmap Bitmap{get; set;} | |
96 | 138 | public bool Cancelled{get; set;} |
97 | 139 | |
98 | 140 | public LoadImageArgument(string path){ |
@@ -101,6 +143,10 @@ | ||
101 | 143 | } |
102 | 144 | } |
103 | 145 | |
146 | + #endregion | |
147 | + | |
148 | + #region refresh | |
149 | + | |
104 | 150 | public void RefreshImage(){ |
105 | 151 | if(this.originalImage == null){ |
106 | 152 | this.ClearImage(); |
@@ -118,6 +164,7 @@ | ||
118 | 164 | RefreshImageArgument arg = new RefreshImageArgument(this.originalImage, this.ClientSize, this.fittingMode, 1.0); |
119 | 165 | |
120 | 166 | MainForm.Instance.StatusBar.Progress.Start(arg); |
167 | + this.Cursor = Cursors.AppStarting; | |
121 | 168 | MainForm.Instance.StatusBar.Progress.Report(arg, 50); |
122 | 169 | this.refreshWorker.RunWorkerAsync(arg); |
123 | 170 | } |
@@ -131,7 +178,7 @@ | ||
131 | 178 | return; |
132 | 179 | } |
133 | 180 | |
134 | - Bitmap bitmap = arg.Bitmap; | |
181 | + Bitmap bitmap = arg.Bitmap.ToBitmap(); | |
135 | 182 | |
136 | 183 | double originalWidth = bitmap.Width; |
137 | 184 | double originalHeight = bitmap.Height; |
@@ -173,13 +220,17 @@ | ||
173 | 220 | if((destWidth == 0) || (destHeight == 0)){ |
174 | 221 | arg.Bitmap = null; |
175 | 222 | }else{ |
176 | - Bitmap destImage = new Bitmap(destWidth, destHeight); | |
223 | + Bitmap destImage = new Bitmap(destWidth, destHeight, PixelFormat.Format32bppArgb); | |
177 | 224 | using(Graphics g = Graphics.FromImage(destImage)){ |
225 | + g.CompositingMode = CompositingMode.SourceOver; | |
178 | 226 | g.CompositingQuality = CompositingQuality.HighQuality; |
179 | 227 | g.InterpolationMode = InterpolationMode.HighQualityBicubic; |
228 | + g.PixelOffsetMode = PixelOffsetMode.HighQuality; | |
229 | + g.SmoothingMode = SmoothingMode.HighQuality; | |
230 | + | |
180 | 231 | g.DrawImage(bitmap, 0, 0, destWidth, destHeight); |
181 | 232 | } |
182 | - arg.Bitmap = destImage; | |
233 | + arg.DestBitmap = destImage; | |
183 | 234 | } |
184 | 235 | |
185 | 236 | if(this.refreshWorker.CancellationPending){ |
@@ -192,11 +243,19 @@ | ||
192 | 243 | RefreshImageArgument arg = (RefreshImageArgument)e.Result; |
193 | 244 | |
194 | 245 | MainForm.Instance.StatusBar.Progress.Complete(arg); |
246 | + if(!(this.loadingWorker.IsBusy)){ | |
247 | + this.Cursor = Cursors.Default; | |
248 | + } | |
195 | 249 | |
196 | 250 | if(!(arg.Cancelled)){ |
197 | - int destWidth = (arg.Bitmap != null) ? arg.Bitmap.Width : 0; | |
198 | - int destHeight = (arg.Bitmap != null) ? arg.Bitmap.Height : 0; | |
199 | - this.pictureBox.Image = arg.Bitmap; | |
251 | + this.SuspendLayout(); | |
252 | + | |
253 | + this.scale = arg.Scale; | |
254 | + this.AutoScrollPosition = new Point(0, 0); | |
255 | + | |
256 | + int destWidth = (arg.Bitmap != null) ? arg.DestBitmap.Width : 0; | |
257 | + int destHeight = (arg.Bitmap != null) ? arg.DestBitmap.Height : 0; | |
258 | + this.pictureBox.Image = arg.DestBitmap; | |
200 | 259 | this.pictureBox.ClientSize = new Size(destWidth, destHeight); |
201 | 260 | |
202 | 261 | if(destWidth < this.ClientSize.Width){ |
@@ -209,17 +268,20 @@ | ||
209 | 268 | }else{ |
210 | 269 | this.pictureBox.Top = 0; |
211 | 270 | } |
271 | + | |
272 | + this.ResumeLayout(); | |
212 | 273 | } |
213 | 274 | } |
214 | 275 | |
215 | 276 | private class RefreshImageArgument{ |
216 | - public Bitmap Bitmap{get; set;} | |
277 | + public GflBitmap Bitmap{get; set;} | |
278 | + public Bitmap DestBitmap{get; set;} | |
217 | 279 | public double Scale{get; set;} |
218 | 280 | public bool Cancelled{get; set;} |
219 | 281 | public Size ClientSize{get; private set;} |
220 | 282 | public ImageFittingMode FittingMode{get; private set;} |
221 | 283 | |
222 | - public RefreshImageArgument(Bitmap bitmap, Size clientSize, ImageFittingMode fittingMode, double scale){ | |
284 | + public RefreshImageArgument(GflBitmap bitmap, Size clientSize, ImageFittingMode fittingMode, double scale){ | |
223 | 285 | this.Bitmap = bitmap; |
224 | 286 | this.ClientSize = clientSize; |
225 | 287 | this.FittingMode = fittingMode; |
@@ -228,6 +290,10 @@ | ||
228 | 290 | } |
229 | 291 | } |
230 | 292 | |
293 | + #endregion | |
294 | + | |
295 | + #region 関数 | |
296 | + | |
231 | 297 | private void ClearImage(){ |
232 | 298 | this.pictureBox.ClientSize = new Size(0, 0); |
233 | 299 | } |
@@ -239,6 +305,10 @@ | ||
239 | 305 | base.OnSizeChanged(e); |
240 | 306 | } |
241 | 307 | |
308 | + #endregion | |
309 | + | |
310 | + #region プロパティ | |
311 | + | |
242 | 312 | public double Scale{ |
243 | 313 | get{ |
244 | 314 | return this.scale; |
@@ -247,8 +317,123 @@ | ||
247 | 317 | this.scale = value; |
248 | 318 | } |
249 | 319 | } |
320 | + | |
321 | + public ImageFittingMode AutoFittingMode{ | |
322 | + get{ | |
323 | + return this.fittingMode; | |
324 | + } | |
325 | + set{ | |
326 | + this.fittingMode = value; | |
327 | + } | |
328 | + } | |
329 | + | |
330 | + #endregion | |
331 | + | |
332 | + #region クラス | |
333 | + | |
334 | + public class FileList : Collection<string>{ | |
335 | + private int currentIndex = -1; | |
336 | + | |
337 | + protected override void ClearItems(){ | |
338 | + base.ClearItems(); | |
339 | + this.currentIndex = -1; | |
340 | + } | |
341 | + | |
342 | + protected override void InsertItem(int index, string item){ | |
343 | + if(index < this.currentIndex){ | |
344 | + this.currentIndex++; | |
345 | + }else if(index == this.currentIndex){ | |
346 | + this.currentIndex = -1; | |
347 | + }else if(this.Count == 0){ | |
348 | + this.currentIndex = 0; | |
349 | + } | |
350 | + base.InsertItem(index, item); | |
351 | + } | |
352 | + | |
353 | + protected override void RemoveItem(int index){ | |
354 | + base.RemoveItem(index); | |
355 | + if(index < this.currentIndex){ | |
356 | + this.currentIndex--; | |
357 | + }else if(index == this.currentIndex){ | |
358 | + this.currentIndex = -1; | |
359 | + }else if(this.Count == 0){ | |
360 | + this.currentIndex = -1; | |
361 | + } | |
362 | + } | |
363 | + | |
364 | + public int CurrentIndex{ | |
365 | + get{ | |
366 | + return this.currentIndex; | |
367 | + } | |
368 | + set{ | |
369 | + if(value > this.Count){ | |
370 | + throw new ArgumentOutOfRangeException(); | |
371 | + } | |
372 | + this.currentIndex = value; | |
373 | + } | |
374 | + } | |
375 | + | |
376 | + public string Current{ | |
377 | + get{ | |
378 | + if(this.currentIndex >= 0){ | |
379 | + return this[this.currentIndex]; | |
380 | + }else{ | |
381 | + return null; | |
382 | + } | |
383 | + } | |
384 | + } | |
385 | + } | |
386 | + | |
387 | + #endregion | |
388 | + | |
389 | + #region イベント | |
390 | + | |
391 | + private static readonly object EventImageLoaded = new object(); | |
392 | + public event ImageLoadedEventHandler ImageLoaded{ | |
393 | + add{ | |
394 | + this.Events.AddHandler(EventImageLoaded, value); | |
395 | + } | |
396 | + remove{ | |
397 | + this.Events.RemoveHandler(EventImageLoaded, value); | |
398 | + } | |
399 | + } | |
400 | + | |
401 | + protected virtual void OnImageLoaded(ImageLoadedEventArgs e){ | |
402 | + ImageLoadedEventHandler handler = this.Events[EventImageLoaded] as ImageLoadedEventHandler; | |
403 | + if(handler != null){ | |
404 | + handler(this, e); | |
405 | + } | |
406 | + } | |
407 | + | |
408 | + #endregion | |
250 | 409 | } |
251 | 410 | |
411 | + public delegate void ImageLoadedEventHandler(object sender, ImageLoadedEventArgs e); | |
412 | + | |
413 | + public class ImageLoadedEventArgs : EventArgs{ | |
414 | + public GflBitmap bitmap; | |
415 | + | |
416 | + public ImageLoadedEventArgs(GflBitmap bitmap){ | |
417 | + this.bitmap = bitmap; | |
418 | + } | |
419 | + | |
420 | + public Bitmap SmallIcon{ | |
421 | + get{ | |
422 | + Bitmap icon = new Bitmap(16, 16, PixelFormat.Format32bppArgb); | |
423 | + using(Graphics g = Graphics.FromImage(icon)){ | |
424 | + g.CompositingMode = CompositingMode.SourceOver; | |
425 | + g.CompositingQuality = CompositingQuality.HighQuality; | |
426 | + g.InterpolationMode = InterpolationMode.HighQualityBicubic; | |
427 | + g.PixelOffsetMode = PixelOffsetMode.HighQuality; | |
428 | + g.SmoothingMode = SmoothingMode.HighQuality; | |
429 | + | |
430 | + g.DrawImage(this.bitmap.ToBitmap(), 0, 0, 16, 16); | |
431 | + } | |
432 | + return icon; | |
433 | + } | |
434 | + } | |
435 | + } | |
436 | + | |
252 | 437 | public enum ImageFittingMode{ |
253 | 438 | None = 0, |
254 | 439 | Window = 1, |
@@ -3,11 +3,18 @@ | ||
3 | 3 | */ |
4 | 4 | |
5 | 5 | using System; |
6 | +using System.Drawing; | |
6 | 7 | using System.Windows.Forms; |
8 | +using Kuon; | |
9 | +using Kuon.Forms; | |
10 | +using Kuon.Utilities; | |
7 | 11 | |
8 | 12 | namespace Kuon.Viewer{ |
13 | + using IO = System.IO; | |
14 | + | |
9 | 15 | public class ViewerForm : ChildForm{ |
10 | 16 | private ViewerControl viewer = new ViewerControl(); |
17 | + private MenuStrip menuStrip = new ClickThroughMenuStrip(); | |
11 | 18 | |
12 | 19 | public ViewerForm(Form parent) : base(parent, true){ |
13 | 20 | this.SuspendLayout(); |
@@ -18,6 +25,31 @@ | ||
18 | 25 | //this.Location = data.Location; |
19 | 26 | this.WindowState = FormWindowState.Normal; |
20 | 27 | |
28 | + { | |
29 | + string path = StringEx.JoinPath(Resource.Path.ResourceDirectory, "Viewer.ico"); | |
30 | + if(System.IO.File.Exists(path)){ | |
31 | + Icon icon = Shell.GetIcon(path, IconSize.Small); | |
32 | + if(icon != null){ | |
33 | + this.Icon = icon; | |
34 | + } | |
35 | + } | |
36 | + } | |
37 | + | |
38 | + try{ | |
39 | + if(IO.File.Exists(Resource.Path.ConfigDirectory + IO.Path.DirectorySeparatorChar + "ViewerMenu.xml")){ | |
40 | + this.menuStrip.Items.AddRange(MenuCreator.Create(Resource.Path.ConfigDirectory + IO.Path.DirectorySeparatorChar + "ViewerMenu.xml", "viewer")); | |
41 | + }else{ | |
42 | + this.menuStrip.Items.AddRange(MenuCreator.Create(Resource.Path.LanguageDirectory + IO.Path.DirectorySeparatorChar + ApplicationConfig.GetConfig<ConfigGeneral>("General").Language + IO.Path.DirectorySeparatorChar + "ViewerMenu.xml", "viewer")); | |
43 | + } | |
44 | + }catch(InvalidOperationException ex){ | |
45 | + MessageBox.Show(ex.Message, ApplicationInfo.Name, MessageBoxButtons.OK, MessageBoxIcon.Error); | |
46 | + } | |
47 | + if(this.menuStrip.Items.Count > 0){ | |
48 | + this.menuStrip.Visible = false; | |
49 | + this.MainMenuStrip = this.menuStrip; | |
50 | + this.Controls.Add(this.menuStrip); | |
51 | + } | |
52 | + | |
21 | 53 | this.viewer.Dock = DockStyle.Fill; |
22 | 54 | this.Controls.Add(this.viewer); |
23 | 55 |
@@ -30,8 +62,27 @@ | ||
30 | 62 | this.WindowState = windowState; |
31 | 63 | } |
32 | 64 | |
33 | - public void LoadImage(string path){ | |
34 | - this.viewer.LoadImage(path); | |
65 | + public void OpenImage(string path){ | |
66 | + this.viewer.OpenImage(path); | |
35 | 67 | } |
68 | + | |
69 | + public void RefreshImage(){ | |
70 | + this.viewer.RefreshImage(); | |
71 | + } | |
72 | + | |
73 | + public ImageFittingMode AutoFittingMode{ | |
74 | + get{ | |
75 | + return this.viewer.AutoFittingMode; | |
76 | + } | |
77 | + set{ | |
78 | + this.viewer.AutoFittingMode = value; | |
79 | + } | |
80 | + } | |
81 | + | |
82 | + public static ViewerForm ActiveViewerForm{ | |
83 | + get{ | |
84 | + return MainForm.Instance.ActiveMdiChild as ViewerForm; | |
85 | + } | |
86 | + } | |
36 | 87 | } |
37 | 88 | } |
\ No newline at end of file |
@@ -7,6 +7,18 @@ | ||
7 | 7 | using System.Windows.Forms; |
8 | 8 | using Kuon; |
9 | 9 | |
10 | +[assembly: AssemblyTitle("Kuon.Viewer")] | |
11 | +[assembly: AssemblyProduct("Kuon.Viewer")] | |
12 | +[assembly: AssemblyVersion("1.0.*")] | |
13 | +[assembly: AssemblyInformationalVersion("0.5.0.0")] | |
14 | +[assembly: AssemblyCopyright("Copyright 2009 Kuon Developer Team. (cat-walk)")] | |
15 | +[assembly: AssemblyDescription("Viewer module.")] | |
16 | +[assembly: AssemblyConfiguration("")] | |
17 | +[assembly: AssemblyCompany("")] | |
18 | +[assembly: AssemblyTrademark("")] | |
19 | +[assembly: AssemblyCulture("")] | |
20 | +[assembly: ModuleEntryPoint("Kuon.Viewer.ViewerModule")] | |
21 | + | |
10 | 22 | namespace Kuon.Viewer{ |
11 | 23 | public class ViewerModule : Module{ |
12 | 24 | public ViewerModule(){ |
@@ -26,10 +38,25 @@ | ||
26 | 38 | |
27 | 39 | public override void LoadActions(){ |
28 | 40 | const string @namespace = "viewer"; |
41 | + if(!(ActionManager.Namespace.ContainsKey(@namespace))){ | |
42 | + ActionManager.Namespace.Add(@namespace, new ActionItemDictionary()); | |
43 | + } | |
29 | 44 | ActionManager.Global.Add("open-viewer-window", new ActionItem(OpenViewerWindow)); |
45 | + ActionManager.Namespace[@namespace].Add("open-file", new ActionItem(OpenFile)); | |
46 | + ActionManager.Namespace[@namespace].Add("auto-fit-none", new ActionItem(AutoFitNone, AutoFitNone)); | |
47 | + ActionManager.Namespace[@namespace].Add("auto-fit-window", new ActionItem(AutoFitWindow, AutoFitWindow)); | |
48 | + ActionManager.Namespace[@namespace].Add("auto-fit-window-largeonly", new ActionItem(AutoFitWindowLargeOnly, AutoFitWindowLargeOnly)); | |
49 | + ActionManager.Namespace[@namespace].Add("auto-fit-window-width", new ActionItem(AutoFitWindowWidth, AutoFitWindowWidth)); | |
50 | + ActionManager.Namespace[@namespace].Add("auto-fit-window-width-largeonly", new ActionItem(AutoFitWindowWidthLargeOnly, AutoFitWindowWidthLargeOnly)); | |
51 | + ActionManager.Namespace[@namespace].Add("auto-fit-window-height", new ActionItem(AutoFitWindowHeight, AutoFitWindowHeight)); | |
52 | + ActionManager.Namespace[@namespace].Add("auto-fit-window-height-largeonly", new ActionItem(AutoFitWindowHeightLargeOnly, AutoFitWindowHeightLargeOnly)); | |
30 | 53 | } |
31 | 54 | |
32 | 55 | private static void OpenViewerWindow(object sender, ActionEventArgs e){ |
56 | + new ViewerForm(MainForm.Instance); | |
57 | + } | |
58 | + | |
59 | + private static void OpenFile(object sender, ActionEventArgs e){ | |
33 | 60 | OpenFileDialog dialog = new OpenFileDialog(); |
34 | 61 | dialog.CheckFileExists = true; |
35 | 62 | dialog.CheckPathExists = true; |
@@ -36,9 +63,159 @@ | ||
36 | 63 | dialog.Multiselect = false; |
37 | 64 | DialogResult result = dialog.ShowDialog(MainForm.Instance); |
38 | 65 | if(result == DialogResult.OK){ |
39 | - ViewerForm form = new ViewerForm(MainForm.Instance); | |
40 | - form.LoadImage(dialog.FileName); | |
66 | + ViewerForm form = ViewerForm.ActiveViewerForm; | |
67 | + if(form == null){ | |
68 | + form = new ViewerForm(MainForm.Instance); | |
69 | + } | |
70 | + form.OpenImage(dialog.FileName); | |
41 | 71 | } |
42 | 72 | } |
73 | + | |
74 | + private static void AutoFitNone(object sender, ActionEventArgs e){ | |
75 | + ViewerForm form = ViewerForm.ActiveViewerForm; | |
76 | + if(form != null){ | |
77 | + form.AutoFittingMode = ImageFittingMode.None; | |
78 | + form.RefreshImage(); | |
79 | + } | |
80 | + } | |
81 | + | |
82 | + private static ToolStripMenuItem AutoFitNone(object sender, CreateMenuItemArgs e){ | |
83 | + ToolStripMenuItem menuItem = new ToolStripMenuItem(e.Text, e.Image, e.ClickedEventHandler); | |
84 | + menuItem.Paint += delegate{ | |
85 | + ViewerForm form = ViewerForm.ActiveViewerForm; | |
86 | + if(form != null){ | |
87 | + menuItem.Checked = (form.AutoFittingMode == ImageFittingMode.None); | |
88 | + }else{ | |
89 | + menuItem.Checked = false; | |
90 | + } | |
91 | + }; | |
92 | + return menuItem; | |
93 | + } | |
94 | + | |
95 | + private static void AutoFitWindow(object sender, ActionEventArgs e){ | |
96 | + ViewerForm form = ViewerForm.ActiveViewerForm; | |
97 | + if(form != null){ | |
98 | + form.AutoFittingMode = ImageFittingMode.Window; | |
99 | + form.RefreshImage(); | |
100 | + } | |
101 | + } | |
102 | + | |
103 | + private static ToolStripMenuItem AutoFitWindow(object sender, CreateMenuItemArgs e){ | |
104 | + ToolStripMenuItem menuItem = new ToolStripMenuItem(e.Text, e.Image, e.ClickedEventHandler); | |
105 | + menuItem.Paint += delegate{ | |
106 | + ViewerForm form = ViewerForm.ActiveViewerForm; | |
107 | + if(form != null){ | |
108 | + menuItem.Checked = (form.AutoFittingMode == ImageFittingMode.Window); | |
109 | + }else{ | |
110 | + menuItem.Checked = false; | |
111 | + } | |
112 | + }; | |
113 | + return menuItem; | |
114 | + } | |
115 | + | |
116 | + private static void AutoFitWindowLargeOnly(object sender, ActionEventArgs e){ | |
117 | + ViewerForm form = ViewerForm.ActiveViewerForm; | |
118 | + if(form != null){ | |
119 | + form.AutoFittingMode = ImageFittingMode.WindowLargeOnly; | |
120 | + form.RefreshImage(); | |
121 | + } | |
122 | + } | |
123 | + | |
124 | + private static ToolStripMenuItem AutoFitWindowLargeOnly(object sender, CreateMenuItemArgs e){ | |
125 | + ToolStripMenuItem menuItem = new ToolStripMenuItem(e.Text, e.Image, e.ClickedEventHandler); | |
126 | + menuItem.Paint += delegate{ | |
127 | + ViewerForm form = ViewerForm.ActiveViewerForm; | |
128 | + if(form != null){ | |
129 | + menuItem.Checked = (form.AutoFittingMode == ImageFittingMode.WindowLargeOnly); | |
130 | + }else{ | |
131 | + menuItem.Checked = false; | |
132 | + } | |
133 | + }; | |
134 | + return menuItem; | |
135 | + } | |
136 | + | |
137 | + private static void AutoFitWindowWidth(object sender, ActionEventArgs e){ | |
138 | + ViewerForm form = ViewerForm.ActiveViewerForm; | |
139 | + if(form != null){ | |
140 | + form.AutoFittingMode = ImageFittingMode.WindowWidth; | |
141 | + form.RefreshImage(); | |
142 | + } | |
143 | + } | |
144 | + | |
145 | + private static ToolStripMenuItem AutoFitWindowWidth(object sender, CreateMenuItemArgs e){ | |
146 | + ToolStripMenuItem menuItem = new ToolStripMenuItem(e.Text, e.Image, e.ClickedEventHandler); | |
147 | + menuItem.Paint += delegate{ | |
148 | + ViewerForm form = ViewerForm.ActiveViewerForm; | |
149 | + if(form != null){ | |
150 | + menuItem.Checked = (form.AutoFittingMode == ImageFittingMode.WindowWidth); | |
151 | + }else{ | |
152 | + menuItem.Checked = false; | |
153 | + } | |
154 | + }; | |
155 | + return menuItem; | |
156 | + } | |
157 | + | |
158 | + private static void AutoFitWindowWidthLargeOnly(object sender, ActionEventArgs e){ | |
159 | + ViewerForm form = ViewerForm.ActiveViewerForm; | |
160 | + if(form != null){ | |
161 | + form.AutoFittingMode = ImageFittingMode.WindowWidthLargeOnly; | |
162 | + form.RefreshImage(); | |
163 | + } | |
164 | + } | |
165 | + | |
166 | + private static ToolStripMenuItem AutoFitWindowWidthLargeOnly(object sender, CreateMenuItemArgs e){ | |
167 | + ToolStripMenuItem menuItem = new ToolStripMenuItem(e.Text, e.Image, e.ClickedEventHandler); | |
168 | + menuItem.Paint += delegate{ | |
169 | + ViewerForm form = ViewerForm.ActiveViewerForm; | |
170 | + if(form != null){ | |
171 | + menuItem.Checked = (form.AutoFittingMode == ImageFittingMode.WindowWidthLargeOnly); | |
172 | + }else{ | |
173 | + menuItem.Checked = false; | |
174 | + } | |
175 | + }; | |
176 | + return menuItem; | |
177 | + } | |
178 | + | |
179 | + private static void AutoFitWindowHeight(object sender, ActionEventArgs e){ | |
180 | + ViewerForm form = ViewerForm.ActiveViewerForm; | |
181 | + if(form != null){ | |
182 | + form.AutoFittingMode = ImageFittingMode.WindowHeight; | |
183 | + form.RefreshImage(); | |
184 | + } | |
185 | + } | |
186 | + | |
187 | + private static ToolStripMenuItem AutoFitWindowHeight(object sender, CreateMenuItemArgs e){ | |
188 | + ToolStripMenuItem menuItem = new ToolStripMenuItem(e.Text, e.Image, e.ClickedEventHandler); | |
189 | + menuItem.Paint += delegate{ | |
190 | + ViewerForm form = ViewerForm.ActiveViewerForm; | |
191 | + if(form != null){ | |
192 | + menuItem.Checked = (form.AutoFittingMode == ImageFittingMode.WindowHeight); | |
193 | + }else{ | |
194 | + menuItem.Checked = false; | |
195 | + } | |
196 | + }; | |
197 | + return menuItem; | |
198 | + } | |
199 | + | |
200 | + private static void AutoFitWindowHeightLargeOnly(object sender, ActionEventArgs e){ | |
201 | + ViewerForm form = ViewerForm.ActiveViewerForm; | |
202 | + if(form != null){ | |
203 | + form.AutoFittingMode = ImageFittingMode.WindowHeightLargeOnly; | |
204 | + form.RefreshImage(); | |
205 | + } | |
206 | + } | |
207 | + | |
208 | + private static ToolStripMenuItem AutoFitWindowHeightLargeOnly(object sender, CreateMenuItemArgs e){ | |
209 | + ToolStripMenuItem menuItem = new ToolStripMenuItem(e.Text, e.Image, e.ClickedEventHandler); | |
210 | + menuItem.Paint += delegate{ | |
211 | + ViewerForm form = ViewerForm.ActiveViewerForm; | |
212 | + if(form != null){ | |
213 | + menuItem.Checked = (form.AutoFittingMode == ImageFittingMode.WindowHeightLargeOnly); | |
214 | + }else{ | |
215 | + menuItem.Checked = false; | |
216 | + } | |
217 | + }; | |
218 | + return menuItem; | |
219 | + } | |
43 | 220 | } |
44 | 221 | } |
\ No newline at end of file |
@@ -4,11 +4,13 @@ | ||
4 | 4 | |
5 | 5 | using System; |
6 | 6 | using System.Collections.Generic; |
7 | +using System.ComponentModel; | |
7 | 8 | using System.Drawing; |
8 | 9 | using System.Linq; |
9 | 10 | using System.Reflection; |
10 | 11 | using System.Text; |
11 | 12 | using System.Text.RegularExpressions; |
13 | +using System.Threading; | |
12 | 14 | using System.Windows.Forms; |
13 | 15 | using Kuon; |
14 | 16 | using Kuon.IO; |
@@ -66,6 +68,7 @@ | ||
66 | 68 | private Button editButton = new Button(); |
67 | 69 | private ListViewEx fileListView = new ListViewEx(); |
68 | 70 | private MenuStrip menuStrip = new ClickThroughMenuStrip(); |
71 | + private BackgroundWorker macroWorker = new BackgroundWorker(); | |
69 | 72 | |
70 | 73 | private static readonly Image UnknownIcon; |
71 | 74 | private static StringTable MacroHelp; |
@@ -125,6 +128,8 @@ | ||
125 | 128 | this.Controls.Add(this.macroBox); |
126 | 129 | |
127 | 130 | this.macroBox.MacroTextBox.TextChanged += delegate{ |
131 | + this.ApplyMacro(); | |
132 | + /* | |
128 | 133 | RenameInfo[] infos = new RenameInfo[this.fileListView.Items.Count]; |
129 | 134 | { |
130 | 135 | int i = 0; |
@@ -134,6 +139,7 @@ | ||
134 | 139 | } |
135 | 140 | RenameMacro.Expand(this.macroBox.MacroTextBox.Text, infos); |
136 | 141 | this.RefreshList(); |
142 | + */ | |
137 | 143 | }; |
138 | 144 | this.macroBox.MacroTextBox.Text = @"<bn><ext>"; |
139 | 145 | /* |
@@ -217,6 +223,12 @@ | ||
217 | 223 | |
218 | 224 | this.MinimumSize = new Size(buttonWidth * 6, this.fileListView.Top + this.Margin.Top * 5 + this.upButton.Height * 5); |
219 | 225 | |
226 | + this.macroWorker.WorkerReportsProgress = true; | |
227 | + this.macroWorker.WorkerSupportsCancellation = true; | |
228 | + this.macroWorker.DoWork += this.ApplyMacro_DoWork; | |
229 | + this.macroWorker.ProgressChanged += this.ApplyMacro_Progress; | |
230 | + this.macroWorker.RunWorkerCompleted += this.ApplyMacro_Completed; | |
231 | + | |
220 | 232 | this.Show(); |
221 | 233 | this.ResumeLayout(); |
222 | 234 |
@@ -300,7 +312,7 @@ | ||
300 | 312 | |
301 | 313 | #endregion |
302 | 314 | |
303 | - #region 関数 | |
315 | + #region List | |
304 | 316 | |
305 | 317 | private void RefreshList(){ |
306 | 318 | this.RefreshList(this.GetRenameInfos()); |
@@ -329,6 +341,71 @@ | ||
329 | 341 | this.fileListView.EndUpdate(); |
330 | 342 | } |
331 | 343 | |
344 | + private void ApplyMacro(){ | |
345 | + if(this.macroWorker.IsBusy){ | |
346 | + this.macroWorker.CancelAsync(); | |
347 | + while(this.macroWorker.IsBusy){ | |
348 | + Thread.Sleep(64); | |
349 | + Application.DoEvents(); | |
350 | + } | |
351 | + } | |
352 | + | |
353 | + ListViewItem[] items = new ListViewItem[this.fileListView.Items.Count]; | |
354 | + { | |
355 | + int i = 0; | |
356 | + foreach(ListViewItem item in this.fileListView.Items){ | |
357 | + items[i++] = item; | |
358 | + } | |
359 | + } | |
360 | + MainForm.Instance.StatusBar.Progress.Start(this.macroWorker); | |
361 | + this.macroWorker.RunWorkerAsync(new ApplyMacroArgument(items, this.macroBox.MacroTextBox.Text)); | |
362 | + } | |
363 | + | |
364 | + private void ApplyMacro_DoWork(object sender, DoWorkEventArgs e){ | |
365 | + ApplyMacroArgument arg = (ApplyMacroArgument)e.Argument; | |
366 | + RenameInfo[] infos = new RenameInfo[arg.Items.Length]; | |
367 | + { | |
368 | + int i = 0; | |
369 | + foreach(ListViewItem item in arg.Items){ | |
370 | + infos[i++] = (RenameInfo)item.Tag; | |
371 | + } | |
372 | + } | |
373 | + RenameMacro.Expand(arg.Text, infos, new ExpandEventHandler(delegate(object sender2, ExpandEventArgs e2){ | |
374 | + if(this.macroWorker.CancellationPending){ | |
375 | + e.Cancel = true; | |
376 | + e2.Cancel = true; | |
377 | + }else{ | |
378 | + this.macroWorker.ReportProgress(e2.ProgressPercentage); | |
379 | + } | |
380 | + })); | |
381 | + } | |
382 | + | |
383 | + private void ApplyMacro_Progress(object sender, ProgressChangedEventArgs e){ | |
384 | + MainForm.Instance.StatusBar.Progress.Report(this.macroWorker, e.ProgressPercentage); | |
385 | + } | |
386 | + | |
387 | + private void ApplyMacro_Completed(object sender, RunWorkerCompletedEventArgs e){ | |
388 | + MainForm.Instance.StatusBar.Progress.Complete(this.macroWorker); | |
389 | + if(!e.Cancelled){ | |
390 | + this.RefreshList(); | |
391 | + this.CheckErrors(); | |
392 | + } | |
393 | + } | |
394 | + | |
395 | + private class ApplyMacroArgument{ | |
396 | + public ListViewItem[] Items{get; private set;} | |
397 | + public string Text{get; private set;} | |
398 | + | |
399 | + public ApplyMacroArgument(ListViewItem[] items, string text){ | |
400 | + this.Items = items; | |
401 | + this.Text = text; | |
402 | + } | |
403 | + } | |
404 | + | |
405 | + #endregion | |
406 | + | |
407 | + #region 関数 | |
408 | + | |
332 | 409 | private void AddFiles(string[] files){ |
333 | 410 | RenameInfo[] infos = this.GetRenameInfos(); |
334 | 411 | RenameInfo[] newInfos = new RenameInfo[infos.Length + files.Length]; |
@@ -5,6 +5,7 @@ | ||
5 | 5 | using System; |
6 | 6 | using System.Collections.Generic; |
7 | 7 | using System.Collections.ObjectModel; |
8 | +using System.ComponentModel; | |
8 | 9 | using System.Linq; |
9 | 10 | using System.Security.Cryptography; |
10 | 11 | using System.Text; |
@@ -86,6 +87,10 @@ | ||
86 | 87 | } |
87 | 88 | |
88 | 89 | public static void Expand(string source, RenameInfo[] infos){ |
90 | + Expand(source, infos, null); | |
91 | + } | |
92 | + | |
93 | + public static void Expand(string source, RenameInfo[] infos, ExpandEventHandler cancel){ | |
89 | 94 | if(source == null){ |
90 | 95 | throw new ArgumentNullException(); |
91 | 96 | } |
@@ -103,6 +108,13 @@ | ||
103 | 108 | root.Items.AddRange(Parse(source)); |
104 | 109 | |
105 | 110 | for(int i = 0; i < files.Length; i++){ |
111 | + if(cancel != null){ | |
112 | + ExpandEventArgs e = new ExpandEventArgs((int)i / files.Length * 100); | |
113 | + cancel(null, e); | |
114 | + if(e.Cancel){ | |
115 | + return; | |
116 | + } | |
117 | + } | |
106 | 118 | infos[i].NewName = root.GetString(files[i], i); |
107 | 119 | } |
108 | 120 | } |
@@ -731,4 +743,14 @@ | ||
731 | 743 | FileNameError = 0x0020, |
732 | 744 | UndoError = 0x0040, |
733 | 745 | } |
746 | + | |
747 | + public delegate void ExpandEventHandler(object sender, ExpandEventArgs e); | |
748 | + | |
749 | + public class ExpandEventArgs : CancelEventArgs{ | |
750 | + public int ProgressPercentage{get; private set;} | |
751 | + | |
752 | + public ExpandEventArgs(int percentage){ | |
753 | + this.ProgressPercentage = percentage; | |
754 | + } | |
755 | + } | |
734 | 756 | } |
\ No newline at end of file |
@@ -6,139 +6,165 @@ | ||
6 | 6 | using System.Collections.Generic; |
7 | 7 | |
8 | 8 | namespace Kuon.Utilities{ |
9 | - public class History<T>{ | |
10 | - private Stack<T> forwardStack = new Stack<T>(); | |
11 | - private Stack<T> backStack = new Stack<T>(); | |
12 | - private T current = default(T); | |
9 | + public interface IHistory<T>{ | |
10 | + void Add(T item); | |
11 | + void Clear(); | |
12 | + T Forward(); | |
13 | + T Back(); | |
14 | + bool CanGoForward{get;} | |
15 | + bool CanGoBack{get;} | |
16 | + T Current{get;} | |
17 | + } | |
18 | + | |
19 | + public class History<T> : IHistory<T>{ | |
20 | + private LinkedList<T> list = new LinkedList<T>(); | |
21 | + private LinkedListNode<T> current = null; | |
13 | 22 | private int limitCount = 0; |
14 | 23 | |
15 | 24 | public History(){ |
16 | 25 | } |
17 | 26 | |
18 | - public History(int limit){ | |
19 | - this.limitCount = limit; | |
27 | + public History(int limitCount){ | |
28 | + this.limitCount = limitCount; | |
20 | 29 | } |
21 | 30 | |
22 | - /// <summary> | |
23 | - /// 履歴を追加する。 | |
24 | - /// </summary> | |
25 | - /// <param name="item">アイテム</param> | |
26 | 31 | public void Add(T item){ |
27 | - if(item == null){ | |
28 | - throw new ArgumentNullException(); | |
29 | - } | |
30 | - this.backStack.Push(item); | |
31 | - if((this.limitCount > 0) && (this.backStack.Count > this.limitCount)){ | |
32 | - Stack<T> stack = new Stack<T>(); | |
33 | - for(int i = 0; i < this.limitCount; i++){ | |
34 | - stack.Push(this.backStack.Pop()); | |
32 | + if(this.list.Count == 0){ | |
33 | + this.list.AddFirst(item); | |
34 | + this.current = this.list.First; | |
35 | + }else{ | |
36 | + if(this.current != null){ | |
37 | + while(this.current.Next != null){ | |
38 | + this.list.Remove(this.current.Next); | |
39 | + } | |
35 | 40 | } |
36 | - this.backStack = stack; | |
41 | + this.list.AddAfter(this.current, item); | |
42 | + this.current = this.current.Next; | |
37 | 43 | } |
38 | - this.forwardStack.Clear(); | |
39 | - this.current = default(T); | |
44 | + if((this.limitCount > 0) && (this.list.Count > this.limitCount)){ | |
45 | + this.list.Remove(this.list.First); | |
46 | + } | |
40 | 47 | } |
41 | 48 | |
42 | - /// <summary> | |
43 | - /// 履歴をクリアする。 | |
44 | - /// </summary> | |
45 | - public void Clear(){ | |
46 | - this.backStack.Clear(); | |
47 | - this.forwardStack.Clear(); | |
48 | - } | |
49 | - | |
50 | - /// <summary> | |
51 | - /// 次の履歴へ移動する。 | |
52 | - /// </summary> | |
53 | - /// <returns>移動出来たかどうか</returns> | |
54 | - public bool Forward(){ | |
55 | - if(this.forwardStack.Count > 0){ | |
56 | - this.backStack.Push(this.current); | |
57 | - this.current = this.forwardStack.Pop(); | |
58 | - return true; | |
49 | + public void Insert(T item){ | |
50 | + if(this.list.Count == 0){ | |
51 | + this.list.AddFirst(item); | |
52 | + this.current = this.list.First; | |
59 | 53 | }else{ |
60 | - return false; | |
54 | + this.list.AddAfter(this.current, item); | |
55 | + this.current = this.current.Next; | |
61 | 56 | } |
57 | + if((this.limitCount > 0) && (this.list.Count > this.limitCount)){ | |
58 | + this.list.Remove(this.list.First); | |
59 | + } | |
62 | 60 | } |
63 | 61 | |
64 | - public bool Forward(int count){ | |
65 | - if(count < 0){ | |
66 | - throw new ArgumentOutOfRangeException(); | |
67 | - } | |
68 | - while(count-- > 0){ | |
69 | - if(!this.Forward()){ | |
70 | - return false; | |
71 | - } | |
72 | - } | |
73 | - return true; | |
62 | + public void Clear(){ | |
63 | + this.list.Clear(); | |
64 | + this.current = null; | |
74 | 65 | } |
75 | 66 | |
76 | - public bool CanGoForward{ | |
77 | - get{ | |
78 | - return (this.forwardStack.Count > 0); | |
67 | + public T Forward(){ | |
68 | + if(this.CanGoForward){ | |
69 | + this.current = this.current.Next; | |
70 | + return this.current.Value; | |
71 | + }else{ | |
72 | + return default(T); | |
79 | 73 | } |
80 | 74 | } |
81 | 75 | |
82 | - /// <summary> | |
83 | - /// 前の履歴へ移動する。 | |
84 | - /// </summary> | |
85 | - /// <returns>移動できたかどうか</returns> | |
86 | - public bool Back(){ | |
87 | - if(this.backStack.Count > 0){ | |
88 | - this.forwardStack.Push(this.current); | |
89 | - this.current = this.backStack.Pop(); | |
90 | - return true; | |
76 | + public T Back(){ | |
77 | + if(this.CanGoBack){ | |
78 | + this.current = this.current.Previous; | |
79 | + return this.current.Value; | |
91 | 80 | }else{ |
92 | - return false; | |
81 | + return default(T); | |
93 | 82 | } |
94 | 83 | } |
95 | 84 | |
96 | - public bool Back(int count){ | |
97 | - while(count-- > 0){ | |
98 | - if(!this.Back()){ | |
99 | - return false; | |
85 | + public T Current{ | |
86 | + get{ | |
87 | + return this.current.Value; | |
88 | + } | |
89 | + set{ | |
90 | + if(this.current == null){ | |
91 | + this.list.AddFirst(value); | |
92 | + this.current = this.list.First; | |
93 | + }else{ | |
94 | + this.current.Value = value; | |
100 | 95 | } |
101 | 96 | } |
102 | - return true; | |
103 | 97 | } |
104 | 98 | |
105 | - public bool CanGoBack{ | |
99 | + public T[] ForwardHistory{ | |
106 | 100 | get{ |
107 | - return (this.backStack.Count > 0); | |
101 | + if(this.current != null){ | |
102 | + List<T> list = new List<T>(); | |
103 | + LinkedListNode<T> node = this.current.Next; | |
104 | + while(node != null){ | |
105 | + list.Add(node.Value); | |
106 | + node = node.Next; | |
107 | + } | |
108 | + return list.ToArray(); | |
109 | + }else{ | |
110 | + return new T[0]; | |
111 | + } | |
108 | 112 | } |
113 | + set{ | |
114 | + if(this.current == null){ | |
115 | + this.list.AddFirst(default(T)); | |
116 | + this.current = this.list.First; | |
117 | + } | |
118 | + LinkedListNode<T> node = this.current; | |
119 | + foreach(T item in value){ | |
120 | + this.list.AddAfter(node, item); | |
121 | + node = node.Next; | |
122 | + if((this.limitCount > 0) && (this.list.Count == this.limitCount)){ | |
123 | + break; | |
124 | + } | |
125 | + } | |
126 | + } | |
109 | 127 | } |
110 | - | |
111 | 128 | |
112 | - /// <summary> | |
113 | - /// 現在の状態。 | |
114 | - /// </summary> | |
115 | - public T Current{ | |
129 | + public T[] BackHistory{ | |
116 | 130 | get{ |
117 | - return this.current; | |
131 | + if(this.current != null){ | |
132 | + List<T> list = new List<T>(); | |
133 | + LinkedListNode<T> node = this.current.Previous; | |
134 | + while(node != null){ | |
135 | + list.Add(node.Value); | |
136 | + node = node.Previous; | |
137 | + } | |
138 | + return list.ToArray(); | |
139 | + }else{ | |
140 | + return new T[0]; | |
141 | + } | |
118 | 142 | } |
119 | 143 | set{ |
120 | - if(value == null){ | |
121 | - throw new ArgumentNullException(); | |
144 | + if(this.current == null){ | |
145 | + this.list.AddFirst(default(T)); | |
146 | + this.current = this.list.First; | |
122 | 147 | } |
123 | - this.current = value; | |
148 | + LinkedListNode<T> node = this.current; | |
149 | + foreach(T item in value){ | |
150 | + this.list.AddBefore(node, item); | |
151 | + node = node.Previous; | |
152 | + if((this.limitCount > 0) && (this.list.Count == this.limitCount)){ | |
153 | + break; | |
154 | + } | |
155 | + } | |
124 | 156 | } |
125 | 157 | } |
126 | 158 | |
127 | - /// <summary> | |
128 | - /// 現在より後ろの履歴のスタック。 | |
129 | - /// </summary> | |
130 | - public Stack<T> BackStack{ | |
159 | + public bool CanGoForward{ | |
131 | 160 | get{ |
132 | - return this.backStack; | |
161 | + return ((this.current != null) || (this.current.Next != null)); | |
133 | 162 | } |
134 | 163 | } |
135 | 164 | |
136 | - /// <summary> | |
137 | - /// 現在より前の履歴のスタック。 | |
138 | - /// </summary> | |
139 | - public Stack<T> ForwardStack{ | |
165 | + public bool CanGoBack{ | |
140 | 166 | get{ |
141 | - return this.forwardStack; | |
167 | + return ((this.current != null) || (this.current.Previous != null)); | |
142 | 168 | } |
143 | 169 | } |
144 | 170 |
@@ -147,41 +173,52 @@ | ||
147 | 173 | return this.limitCount; |
148 | 174 | } |
149 | 175 | set{ |
150 | - if(limitCount < 1){ | |
151 | - throw new ArgumentOutOfRangeException(); | |
152 | - } | |
153 | 176 | this.limitCount = value; |
154 | 177 | } |
155 | 178 | } |
156 | 179 | } |
157 | - | |
158 | 180 | /* |
159 | - public class SizeLimitedStack<T> : Stack<T>{ | |
160 | - private int limit = -1; | |
161 | - public int Limit{ | |
162 | - get{ | |
163 | - return this.limit; | |
164 | - } | |
165 | - set{ | |
166 | - this.limit = value; | |
167 | - } | |
181 | + [Serializable] | |
182 | + public class BranchHistory<T> : IHistory<T>{ | |
183 | + private Node current; | |
184 | + private Node root; | |
185 | + | |
186 | + public BranchHistory(){ | |
187 | + this.root = new RootNode(); | |
188 | + this.current = this.root; | |
168 | 189 | } |
169 | 190 | |
170 | - public SizeLimitedStack() : base(){ | |
191 | + public void Add(T item){ | |
192 | + Node node = new Node(this.current, item); | |
193 | + this.current.Children.Add(node); | |
194 | + this.current = node; | |
171 | 195 | } |
172 | 196 | |
173 | - public SizeLimitedStack(IEnumerable<T> collection) : base(collection){ | |
197 | + public void Clear(){ | |
198 | + this.root.Children.Clear(); | |
199 | + this.current = this.root; | |
174 | 200 | } |
175 | 201 | |
176 | - public SizeLimitedStack(int capacity) : base(capacity){ | |
202 | + public T Forward(){ | |
203 | + | |
177 | 204 | } |
178 | 205 | |
179 | - public SizeLimitedStack(int capacity, int limit) : base(capacity){ | |
180 | - this.limit = limit; | |
206 | + private class Node{ | |
207 | + public Node Parent{get; set;} | |
208 | + public IList<Node> Children{get; set;} | |
209 | + public T Value{get; set;} | |
210 | + | |
211 | + public Node(Node parent, T value){ | |
212 | + this.Parent = parent; | |
213 | + this.Children = new SkipListNode<Node>(); | |
214 | + this.Value = value; | |
215 | + } | |
181 | 216 | } |
182 | 217 | |
183 | - //public override void Push(T item){ | |
184 | - //} | |
218 | + private class RootNode : Node{ | |
219 | + public RootNode() : base(null, default(T)){ | |
220 | + } | |
221 | + } | |
185 | 222 | } |
186 | 223 | */ |
187 | 224 | } |
\ No newline at end of file |
@@ -19,9 +19,15 @@ | ||
19 | 19 | [DllImport("KERNEL32.DLL", EntryPoint = "RtlMoveMemory", CharSet = CharSet.Auto)] |
20 | 20 | public static extern void CopyMemory(IntPtr dst, IntPtr src, int length); |
21 | 21 | |
22 | + [DllImport("USER32.DLL", EntryPoint = "GetActiveWindow", CharSet = CharSet.Auto)] | |
23 | + public static extern IntPtr GetActiveWindow(); | |
24 | + | |
22 | 25 | [DllImport("USER32.DLL", EntryPoint = "SetActiveWindow", CharSet = CharSet.Auto)] |
23 | 26 | public static extern IntPtr SetActiveWindow(IntPtr hwnd); |
24 | 27 | |
28 | + [DllImport("USER32.DLL", EntryPoint = "GetClassLong", CharSet = CharSet.Auto)] | |
29 | + public static extern IntPtr GetClassLong(IntPtr hwnd, GetClassLongOption nIndex); | |
30 | + | |
25 | 31 | /// <summary> |
26 | 32 | /// ウインドウを表示する。 |
27 | 33 | /// </summary> |
@@ -42,15 +48,10 @@ | ||
42 | 48 | [DllImport("USER32.DLL", EntryPoint = "GetForegroundWindow", CharSet = CharSet.Auto)] |
43 | 49 | public static extern IntPtr GetForegroundWindow(); |
44 | 50 | |
45 | - /// <summary> | |
46 | - /// メッセージを発行する。 | |
47 | - /// </summary> | |
48 | - /// <param name="hwnd">メッセージの発行先のウインドウのハンドル</param> | |
49 | - /// <param name="msg">メッセージ番号</param> | |
50 | - /// <param name="wParam">wParam</param> | |
51 | - /// <param name="lParam">lParam</param> | |
52 | - /// <returns>返り値</returns> | |
53 | 51 | [DllImport("USER32.DLL", EntryPoint = "SendMessage", CharSet = CharSet.Auto)] |
52 | + public static extern IntPtr SendMessage(IntPtr hwnd, WindowMessage msg, int wParam, int lParam); | |
53 | + | |
54 | + [DllImport("USER32.DLL", EntryPoint = "SendMessage", CharSet = CharSet.Auto)] | |
54 | 55 | public static extern IntPtr SendMessage(IntPtr hwnd, int msg, int wParam, int lParam); |
55 | 56 | |
56 | 57 | [DllImport("USER32.DLL", EntryPoint = "SendMessage", CharSet = CharSet.Auto)] |
@@ -79,22 +80,46 @@ | ||
79 | 80 | public static extern int EnumWindows(EnumWindowsProc lpEnumFunc, int lParam); |
80 | 81 | |
81 | 82 | [DllImport("user32", EntryPoint = "GetWindowThreadProcessId", CharSet = CharSet.Auto)] |
82 | - public static extern int GetWindowThreadProcessId(IntPtr hWnd, ref int ProcessId); | |
83 | + public static extern int GetWindowThreadProcessId(IntPtr hWnd, out int ProcessId); | |
83 | 84 | |
85 | + [DllImport("user32", EntryPoint = "GetWindow", CharSet = CharSet.Auto)] | |
86 | + public static extern IntPtr GetWindow(IntPtr hWnd, GetWindowOption option); | |
87 | + | |
84 | 88 | [DllImport("user32", EntryPoint = "GetWindowText", CharSet = CharSet.Auto)] |
85 | 89 | public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount); |
86 | 90 | |
91 | + [DllImport("user32", EntryPoint = "SetWindowText", CharSet = CharSet.Auto)] | |
92 | + public static extern bool SetWindowText(IntPtr hWnd, [MarshalAs(UnmanagedType.LPTStr)] string text); | |
93 | + | |
94 | + [DllImport("user32", EntryPoint = "SetWindowPos", CharSet = CharSet.Auto)] | |
95 | + public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hwndAfter, int x, int y, int width, int height, SetWindowPosOptions options); | |
96 | + | |
97 | + [DllImport("user32", EntryPoint = "GetWindowRect", CharSet = CharSet.Auto)] | |
98 | + public static extern int GetWindowRect(IntPtr hWnd, ref Win32.Rectangle rect); | |
99 | + | |
100 | + [DllImport("user32", EntryPoint = "IsWindow", CharSet = CharSet.Auto)] | |
101 | + public static extern bool IsWindow(IntPtr hWnd); | |
102 | + | |
87 | 103 | [DllImport("user32", EntryPoint = "GetWindowPlacement", CharSet = CharSet.Auto)] |
88 | 104 | public static extern bool GetWindowPlacement(IntPtr Handle, ref WindowPlacement placement); |
89 | 105 | |
90 | - [DllImport("user32", EntryPoint = "GetWindowRect", CharSet = CharSet.Auto)] | |
91 | - public static extern bool GetWindowPlacement(IntPtr Handle, ref Rectangle rect); | |
106 | + [DllImport("user32", EntryPoint = "GetWindowLong", CharSet = CharSet.Auto)] | |
107 | + public static extern uint GetWindowLong(IntPtr Handle, GetWindowLongOption option); | |
92 | 108 | |
109 | + [DllImport("user32", EntryPoint = "IsWindowVisible", CharSet = CharSet.Auto)] | |
110 | + public static extern bool IsWindowVisible(IntPtr Handle); | |
111 | + | |
112 | + [DllImport("user32", EntryPoint = "IsWindowEnabled", CharSet = CharSet.Auto)] | |
113 | + public static extern bool IsWindowEnabled(IntPtr Handle); | |
114 | + | |
115 | + [DllImport("user32", EntryPoint = "EnableWindow", CharSet = CharSet.Auto)] | |
116 | + public static extern bool IsWindowEnabled(IntPtr Handle, bool enable); | |
117 | + | |
93 | 118 | [StructLayout(LayoutKind.Sequential)] |
94 | 119 | public struct WindowPlacement{ |
95 | 120 | public long Length; |
96 | 121 | public long Flags; |
97 | - public ShowWindowCommand cmd; | |
122 | + public ShowWindowCommand Command; | |
98 | 123 | public Point MinPosition; |
99 | 124 | public Point MaxPosition; |
100 | 125 | public Rectangle NormalPosition; |
@@ -114,10 +139,10 @@ | ||
114 | 139 | /// </summary> |
115 | 140 | [StructLayout(LayoutKind.Sequential)] |
116 | 141 | public struct Rectangle{ |
117 | - public long Left; | |
118 | - public long Top; | |
119 | - public long Right; | |
120 | - public long Bottom; | |
142 | + public int Left; | |
143 | + public int Top; | |
144 | + public int Right; | |
145 | + public int Bottom; | |
121 | 146 | } |
122 | 147 | |
123 | 148 | [DllImport("user32.dll", EntryPoint = "ToUnicode", CharSet = CharSet.Auto)] |
@@ -352,6 +377,92 @@ | ||
352 | 377 | } |
353 | 378 | } |
354 | 379 | |
380 | + public enum GetWindowOption : uint{ | |
381 | + First = 0, | |
382 | + Last = 1, | |
383 | + Next = 2, | |
384 | + Prev = 3, | |
385 | + Owner = 4, | |
386 | + Child = 5, | |
387 | + EnabledPopup = 6, | |
388 | + } | |
389 | + | |
390 | + public enum GetWindowLongOption : int{ | |
391 | + WndProc = (-4), | |
392 | + HInstance = (-6), | |
393 | + HwndParent = (-8), | |
394 | + Style = (-16), | |
395 | + ExStyle = (-20), | |
396 | + UserData = (-21), | |
397 | + Id = (-12), | |
398 | + } | |
399 | + | |
400 | + public enum GetClassLongOption : int{ | |
401 | + MenuName = (-8), | |
402 | + HbrBackground = (-10), | |
403 | + HCursor = (-12), | |
404 | + HIcon = (-14), | |
405 | + HModule = (-16), | |
406 | + WndProc = (-24), | |
407 | + HIconSmall = (-34), | |
408 | + } | |
409 | + | |
410 | + [Flags] | |
411 | + public enum WindowStyle : uint{ | |
412 | + Overlapped = 0x00000000, | |
413 | + Popup = 0x80000000, | |
414 | + Child = 0x40000000, | |
415 | + Minimize = 0x20000000, | |
416 | + Visible = 0x10000000, | |
417 | + Disabled = 0x08000000, | |
418 | + ClipSiblings = 0x04000000, | |
419 | + ClipChildren = 0x02000000, | |
420 | + Maximize = 0x01000000, | |
421 | + Caption = 0x00C00000, /* WS_BORDER | WS_DLGFRAME */ | |
422 | + Border = 0x00800000, | |
423 | + DialogFrame = 0x00400000, | |
424 | + VScroll = 0x00200000, | |
425 | + HScroll = 0x00100000, | |
426 | + SystemMenu = 0x00080000, | |
427 | + ThickFrame = 0x00040000, | |
428 | + Group = 0x00020000, | |
429 | + TabStop = 0x00010000, | |
430 | + | |
431 | + MinimizeBox = 0x00020000, | |
432 | + MaximizeBox = 0x00010000, | |
433 | + | |
434 | + Tiled = Overlapped, | |
435 | + Iconic = Minimize, | |
436 | + SizeBox = ThickFrame, | |
437 | + TiledWindows = OverlappedWindow, | |
438 | + | |
439 | + /* | |
440 | + * Common Window Styles | |
441 | + */ | |
442 | + OverlappedWindow = (Overlapped | Caption | SystemMenu | ThickFrame | MinimizeBox | MaximizeBox), | |
443 | + PopupWindow = (Popup | Border | SystemMenu), | |
444 | + ChildWindow = (Child), | |
445 | + } | |
446 | + | |
447 | + [Flags] | |
448 | + public enum SetWindowPosOptions : uint{ | |
449 | + NoSize = 0x0001, | |
450 | + NoMove = 0x0002, | |
451 | + NoZOrder = 0x0004, | |
452 | + NoRedraw = 0x0008, | |
453 | + NoActivate = 0x0010, | |
454 | + FrameChanged = 0x0020, /* The frame changed: send WM_NCCALCSIZE */ | |
455 | + ShowWindow = 0x0040, | |
456 | + HideWindow = 0x0080, | |
457 | + NoCopyBits = 0x0100, | |
458 | + NoOwnerZOrder = 0x0200, /* Don't do owner Z ordering */ | |
459 | + NoSendChanging = 0x0400, /* Don't send WM_WINDOWPOSCHANGING */ | |
460 | + DrawFrane = FrameChanged, | |
461 | + NoReposition = NoOwnerZOrder, | |
462 | + Defererase = 0x2000, | |
463 | + AsyncWindowPosition = 0x4000, | |
464 | + } | |
465 | + | |
355 | 466 | public enum WindowMessage : uint{ |
356 | 467 | Null = 0x0000, |
357 | 468 | Create = 0x0001, |
@@ -186,6 +186,60 @@ | ||
186 | 186 | |
187 | 187 | #endregion |
188 | 188 | |
189 | + #region Extended | |
190 | + | |
191 | + const string GfleDllName = "libgfle311.dll"; | |
192 | + | |
193 | + [DllImport(GfleDllName, EntryPoint = "gflNegative", CharSet = CharSet.Auto)] | |
194 | + public static extern Error Negative(ref Bitmap src, ref IntPtr dst); | |
195 | + | |
196 | + [DllImport(GfleDllName, EntryPoint = "gflReduceNoise", CharSet = CharSet.Auto)] | |
197 | + public static extern Error ReduceNoise(ref Bitmap src, ref IntPtr dst); | |
198 | + | |
199 | + [DllImport(GfleDllName, EntryPoint = "gflLogCorrection", CharSet = CharSet.Auto)] | |
200 | + public static extern Error LogCorrection(ref Bitmap src, ref IntPtr dst); | |
201 | + | |
202 | + [DllImport(GfleDllName, EntryPoint = "gflNormalize", CharSet = CharSet.Auto)] | |
203 | + public static extern Error Normalize(ref Bitmap src, ref IntPtr dst); | |
204 | + | |
205 | + [DllImport(GfleDllName, EntryPoint = "gflEqualize", CharSet = CharSet.Auto)] | |
206 | + public static extern Error Equalize(ref Bitmap src, ref IntPtr dst); | |
207 | + | |
208 | + [DllImport(GfleDllName, EntryPoint = "gflEqualizeOnLuminance", CharSet = CharSet.Auto)] | |
209 | + public static extern Error EqualizeOnLuminance(ref Bitmap src, ref IntPtr dst); | |
210 | + | |
211 | + [DllImport(GfleDllName, EntryPoint = "gflAutomaticContrast", CharSet = CharSet.Auto)] | |
212 | + public static extern Error AutomaticContrast(ref Bitmap src, ref IntPtr dst); | |
213 | + | |
214 | + [DllImport(GfleDllName, EntryPoint = "gflAutomaticLevels", CharSet = CharSet.Auto)] | |
215 | + public static extern Error AutomaticLevels(ref Bitmap src, ref IntPtr dst); | |
216 | + | |
217 | + [DllImport(GfleDllName, EntryPoint = "gflEnhanceDetail", CharSet = CharSet.Auto)] | |
218 | + public static extern Error EnhanceDetail(ref Bitmap src, ref IntPtr dst); | |
219 | + | |
220 | + [DllImport(GfleDllName, EntryPoint = "gflEnhanceFocus", CharSet = CharSet.Auto)] | |
221 | + public static extern Error EnhanceFocus(ref Bitmap src, ref IntPtr dst); | |
222 | + | |
223 | + [DllImport(GfleDllName, EntryPoint = "gflFocusRestoration", CharSet = CharSet.Auto)] | |
224 | + public static extern Error FocusRestoration(ref Bitmap src, ref IntPtr dst); | |
225 | + | |
226 | + [DllImport(GfleDllName, EntryPoint = "gflEdgeDetectLight", CharSet = CharSet.Auto)] | |
227 | + public static extern Error EdgeDetectLight(ref Bitmap src, ref IntPtr dst); | |
228 | + | |
229 | + [DllImport(GfleDllName, EntryPoint = "gflEdgeDetectMedium", CharSet = CharSet.Auto)] | |
230 | + public static extern Error EdgeDetectMedium(ref Bitmap src, ref IntPtr dst); | |
231 | + | |
232 | + [DllImport(GfleDllName, EntryPoint = "gflEdgeDetectHeavy", CharSet = CharSet.Auto)] | |
233 | + public static extern Error EdgeDetectHeavy(ref Bitmap src, ref IntPtr dst); | |
234 | + | |
235 | + [DllImport(GfleDllName, EntryPoint = "gflEmboss", CharSet = CharSet.Auto)] | |
236 | + public static extern Error Emboss(ref Bitmap src, ref IntPtr dst); | |
237 | + | |
238 | + [DllImport(GfleDllName, EntryPoint = "gflEmbossMore", CharSet = CharSet.Auto)] | |
239 | + public static extern Error EmbossMore(ref Bitmap src, ref IntPtr dst); | |
240 | + | |
241 | + #endregion | |
242 | + | |
189 | 243 | #region Error |
190 | 244 | |
191 | 245 | [DllImport(GflDllName, EntryPoint = "gflGetErrorString", CharSet = CharSet.Auto)] |
@@ -602,7 +656,7 @@ | ||
602 | 656 | internal static GflBitmap GetGflBitmapFromFile(string path, GflProgressCallback progressCallback){ |
603 | 657 | Gfl.LoadParams prms = new Gfl.LoadParams(); |
604 | 658 | Gfl.GetDefaultLoadParams(ref prms); |
605 | - prms.Options = Gfl.LoadOptions.ForceColorModel; | |
659 | + prms.Options = Gfl.LoadOptions.ForceColorModel | Gfl.LoadOptions.IgnoreReadError | Gfl.LoadOptions.OnlyFirstFrame; | |
606 | 660 | prms.ColorModel = Gfl.BitmapType.Bgra; |
607 | 661 | if(progressCallback != null){ |
608 | 662 | prms.Callbacks.Progress = new Gfl.ProgressCallback(delegate(int percent, IntPtr userParams){ |
@@ -667,9 +721,12 @@ | ||
667 | 721 | private Gfl.Bitmap bitmap; |
668 | 722 | private GflFileInfo info; |
669 | 723 | |
670 | - internal GflBitmap(Gfl.Bitmap bitmap, Gfl.FileInformation info){ | |
724 | + internal GflBitmap(Gfl.Bitmap bitmap, Gfl.FileInformation info) : this(bitmap, new GflFileInfo(info)){ | |
725 | + } | |
726 | + | |
727 | + internal GflBitmap(Gfl.Bitmap bitmap, GflFileInfo info){ | |
671 | 728 | this.bitmap = bitmap; |
672 | - this.info = new GflFileInfo(info); | |
729 | + this.info = info; | |
673 | 730 | } |
674 | 731 | |
675 | 732 | public static GflBitmap FromFile(string path){ |
@@ -680,6 +737,15 @@ | ||
680 | 737 | return GflManager.GetGflBitmapFromFile(path, progressCallback); |
681 | 738 | } |
682 | 739 | |
740 | + public GflBitmap ReduceNoise(){ | |
741 | + IntPtr ptr = IntPtr.Zero; | |
742 | + if(Gfl.ReduceNoise(ref this.bitmap, ref ptr) == Gfl.Error.None){ | |
743 | + return new GflBitmap((Gfl.Bitmap)Marshal.PtrToStructure(ptr, typeof(Gfl.Bitmap)), this.info); | |
744 | + }else{ | |
745 | + throw new InvalidOperationException(); | |
746 | + } | |
747 | + } | |
748 | + | |
683 | 749 | public Drawing.Bitmap ToBitmap(){ |
684 | 750 | int length = (int)this.bitmap.BytesPerLine * this.bitmap.Height; |
685 | 751 |
@@ -704,6 +770,16 @@ | ||
704 | 770 | } |
705 | 771 | } |
706 | 772 | |
773 | + private GflExif exif = null; | |
774 | + public GflExif Exif{ | |
775 | + get{ | |
776 | + if(this.exif == null){ | |
777 | + this.exif = new GflExif(Gfl.GetExif(ref this.bitmap, Gfl.GetExifOptions.None)); | |
778 | + } | |
779 | + return this.exif; | |
780 | + } | |
781 | + } | |
782 | + | |
707 | 783 | private bool disposed = false; |
708 | 784 | protected override void Dispose(bool disposing){ |
709 | 785 | if(disposing){ |
@@ -8,6 +8,9 @@ | ||
8 | 8 | -改善: ファイル一覧表示処理を高速化。 |
9 | 9 | -改善: 起動を高速化。 |
10 | 10 | -改善: 自動更新処理をバックグラウンドで行うように。 |
11 | +-改善: アイコンを描き直し。 | |
12 | +-改善: ファイラの移動履歴を保存するようにした。 | |
13 | +-改善: リネームマクロ展開をバックグラウンドで行うようにした。 | |
11 | 14 | |
12 | 15 | **0.4.0.0β4 (2009-06-18) |
13 | 16 | -改善: セットアップをInnoSetupに変更。 |
@@ -27,6 +27,11 @@ | ||
27 | 27 | このアプリケーションが使用するスクリプトを置くディレクトリに置換します。 |
28 | 28 | 通常は"$(ExeDir)\Script"です。 |
29 | 29 | |
30 | +**$(Global:ResourceDir) | |
31 | + このアプリケーションが使用するリソースを置くディレクトリに置換します。 | |
32 | + 通常は"$(ExeDir)\Resource"です。 | |
33 | + | |
34 | + | |
30 | 35 | **$(Global:SpecialFolder:FolderName) |
31 | 36 | 特殊フォルダのパスを取得します。 |
32 | 37 | FolderNameに以下の特殊フォルダ名を指定します。 |