From ed66e5c0334d0cb6254fa4d31c5b03154aafd401 Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Mon, 9 May 2016 17:15:42 +0300 Subject: [PATCH 01/17] Extended git ignore list --- .gitignore | 3 ++- preview toy.csproj.user | 16 ---------------- preview toy.suo | Bin 36864 -> 0 bytes preview toy.v11.suo | Bin 95232 -> 0 bytes 4 files changed, 2 insertions(+), 17 deletions(-) delete mode 100644 preview toy.csproj.user delete mode 100644 preview toy.suo delete mode 100644 preview toy.v11.suo diff --git a/.gitignore b/.gitignore index fbad72c..db5c47d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ bin/* obj/* -*.suo +*.suo +*.user diff --git a/preview toy.csproj.user b/preview toy.csproj.user deleted file mode 100644 index 9c62ad0..0000000 --- a/preview toy.csproj.user +++ /dev/null @@ -1,16 +0,0 @@ - - - - publish\ - - - - - - en-US - false - - - false - - \ No newline at end of file diff --git a/preview toy.suo b/preview toy.suo deleted file mode 100644 index 477401b4b921a970ccb3555ec002a7ea5351076d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 36864 zcmeHQ3wT_`b-u!Hn>UmY0%if@*x+5X(rUHx1K5XTD@a(jG*X@VL~ zR+QtAAbfQA@L_RNQIPy3OrRF{5VTH4=gk330kFTP0j2|H0MO0KOu#I_@qiNmCjw3a zoB}u%a2ntY!0CWL0GtPK0L}z_8t@swIe@bP=K^K}E&|L2TmU#9a3SC<0D0+Ch(8OM z2bd4I7_b1~1hfKNfJ*?(>qguFXaslwO#m;T8Q=r702Trk0hoUY;!6RS0WJsl0Rcb| z5CSkyn-(K^%!idq3V&JjSF4gloK|+A_V&XW;2POTj&iTvck?gWe|oTP67pTXSY+-3 z#+0&IX$SUxq*|5jdpo(xJo=XO&g>je#b4KO?f4 z{?1X3t0TX1yx7HGr{!m%vi>n83hW`^&VZ5uv<9gt9~@QGpFA#0W?BN}fL;dl;+oIa zXmRoQXB+Be0P}ME%kt#-=eVW};P|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asi?M}oX3@4EU|kY_gI?g(a&i-7u1h}{OMz!L>4EI z@!}`psJ6gNJ}r^?zZ^nSOY$ifys?jTv#; z7XmBTI;?J@+&^XnR?&JYh4+jZgKj3!nzJJWflVhZcHrzYrL{`#-V>w2|$4Bj- z3>Z7^lie#@&fgdeHG diff --git a/preview toy.v11.suo b/preview toy.v11.suo deleted file mode 100644 index 3278dbcc68236354329e7f242a9fc0fd0d7420d9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 95232 zcmeHQ2VhiH*1i)!P*hMX*dQuWgv9g&1SH8M)CiJLlu#y@g1pNHVFTe1X4KNXa(;cCkw7^W^ z!(UKjiVEQc_KP;YO3Ps%(JS=6rzLypsd2rh-TJ(30^&_rBqPs2jy|zOOh)bvII0jU zZRON54q3|kd$_5xVV z|53#4qbI29?-EYrZb#k$l%x@@!BQj-neC|mBS>}+J?Z^{e~Rd<9LpTj>e4Pa-Um|!vJj8-vf3930!0!5ae;w}$ zJOHp4U~j-afPDc20s8^=2OI!65O5HH=?@0Z)Q@?7D2|8d=R<*q>Bl304+o3{i~?i< zvH?c`asau2JU~9608j`h0u%#E0HXn807nAG0>%Nx1C9bP-%{W*z!ZR8zlO_kVJhxT z15^Qy222N31C9aA1Td`{;8}p#fH{D1n>Zw0bYO)&;nQr@B;#XAfOen46q!q0?-Cn2{<0G3a}b*0^mfz8o)`Q zdustF16YSsfqw&72RIFI7T^rPnSk2?X9I2ooC9F|^MKFSkJkfVs2`IT`JH}zsg5t# z@s&EhTF2Mu_&VTk0XG2d1Kb3-8SsCATL8BLHUXILZNPT`HtXlSb{CHC*3Zd<-Wzf6 zejGm#asCjFAC5TZ^9pbn6`n!7KkISJ(Pmq4`~u)Dz)Ju=_lk~R)A1WR{)>(e#&h4` z_#OTHJ>V|^?*sk@_yF)B;O~Hc06qeI4EO}F74T2Mr-07@{{nmt_yWMZzXJYRKmNCl zdA%R<{149m3-|%>qq+zD3qauhY*8*UMf56!x2y)NzidcGTO+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=X1mYVkcoc~QKzdVXzX6XoI^#jNy@(_t>Ztsi%6>V z!^u)*QY z>=73l)k)Tk!(!Hjt@o}QSlf5ko)5gx@Ji1cjbfLTmEmhY*m@SzCl+*Y{D;PC?D&;0 z=b^JteeB8UZ6EHoe#}e7mkD|sh xO+e%6-=fZ|zjULT4_1m!`jlhf^GAHT_QJo+e<=UikF(xvskxQ~R^1Z#{{a@hj*S2S From 2d6e98892aa09ca0cf01a57b1d2158c823c06f7b Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Mon, 9 May 2016 17:17:08 +0300 Subject: [PATCH 02/17] Moved the EOP project into separate folder --- .../AboutBox.Designer.cs | 0 AboutBox.cs => Eve-O-Preview/AboutBox.cs | 0 AboutBox.resx => Eve-O-Preview/AboutBox.resx | 0 Hotkey.cs => Eve-O-Preview/Hotkey.cs | 0 .../Preview.Designer.cs | 0 Preview.cs => Eve-O-Preview/Preview.cs | 0 Preview.resx => Eve-O-Preview/Preview.resx | 0 .../PreviewHandler.Designer.cs | 0 .../PreviewHandler.cs | 0 .../PreviewHandler.resx | 0 .../PreviewOverlay.Designer.cs | 0 .../PreviewOverlay.cs | 0 .../PreviewOverlay.resx | 0 Program.cs => Eve-O-Preview/Program.cs | 0 .../Properties}/AssemblyInfo.cs | 0 .../DataSources/PreviewToyMain.datasource | 0 .../Properties}/Resources.Designer.cs | 0 .../Properties}/Resources.resx | 0 .../Properties}/Settings.Designer.cs | 0 .../Properties}/Settings.settings | 0 {Resources => Eve-O-Preview/Resources}/icon.ico | Bin {Resources => Eve-O-Preview/Resources}/icon.png | Bin Win32api.cs => Eve-O-Preview/Win32api.cs | 0 app.config => Eve-O-Preview/app.config | 0 icon.ico => Eve-O-Preview/icon.ico | Bin .../preview toy.csproj | 0 .../preview toy_TemporaryKey.pfx | Bin 27 files changed, 0 insertions(+), 0 deletions(-) rename AboutBox.Designer.cs => Eve-O-Preview/AboutBox.Designer.cs (100%) rename AboutBox.cs => Eve-O-Preview/AboutBox.cs (100%) rename AboutBox.resx => Eve-O-Preview/AboutBox.resx (100%) rename Hotkey.cs => Eve-O-Preview/Hotkey.cs (100%) rename Preview.Designer.cs => Eve-O-Preview/Preview.Designer.cs (100%) rename Preview.cs => Eve-O-Preview/Preview.cs (100%) rename Preview.resx => Eve-O-Preview/Preview.resx (100%) rename PreviewHandler.Designer.cs => Eve-O-Preview/PreviewHandler.Designer.cs (100%) rename PreviewHandler.cs => Eve-O-Preview/PreviewHandler.cs (100%) rename PreviewHandler.resx => Eve-O-Preview/PreviewHandler.resx (100%) rename PreviewOverlay.Designer.cs => Eve-O-Preview/PreviewOverlay.Designer.cs (100%) rename PreviewOverlay.cs => Eve-O-Preview/PreviewOverlay.cs (100%) rename PreviewOverlay.resx => Eve-O-Preview/PreviewOverlay.resx (100%) rename Program.cs => Eve-O-Preview/Program.cs (100%) rename {Properties => Eve-O-Preview/Properties}/AssemblyInfo.cs (100%) rename {Properties => Eve-O-Preview/Properties}/DataSources/PreviewToyMain.datasource (100%) rename {Properties => Eve-O-Preview/Properties}/Resources.Designer.cs (100%) rename {Properties => Eve-O-Preview/Properties}/Resources.resx (100%) rename {Properties => Eve-O-Preview/Properties}/Settings.Designer.cs (100%) rename {Properties => Eve-O-Preview/Properties}/Settings.settings (100%) rename {Resources => Eve-O-Preview/Resources}/icon.ico (100%) rename {Resources => Eve-O-Preview/Resources}/icon.png (100%) rename Win32api.cs => Eve-O-Preview/Win32api.cs (100%) rename app.config => Eve-O-Preview/app.config (100%) rename icon.ico => Eve-O-Preview/icon.ico (100%) rename preview toy.csproj => Eve-O-Preview/preview toy.csproj (100%) rename preview toy_TemporaryKey.pfx => Eve-O-Preview/preview toy_TemporaryKey.pfx (100%) diff --git a/AboutBox.Designer.cs b/Eve-O-Preview/AboutBox.Designer.cs similarity index 100% rename from AboutBox.Designer.cs rename to Eve-O-Preview/AboutBox.Designer.cs diff --git a/AboutBox.cs b/Eve-O-Preview/AboutBox.cs similarity index 100% rename from AboutBox.cs rename to Eve-O-Preview/AboutBox.cs diff --git a/AboutBox.resx b/Eve-O-Preview/AboutBox.resx similarity index 100% rename from AboutBox.resx rename to Eve-O-Preview/AboutBox.resx diff --git a/Hotkey.cs b/Eve-O-Preview/Hotkey.cs similarity index 100% rename from Hotkey.cs rename to Eve-O-Preview/Hotkey.cs diff --git a/Preview.Designer.cs b/Eve-O-Preview/Preview.Designer.cs similarity index 100% rename from Preview.Designer.cs rename to Eve-O-Preview/Preview.Designer.cs diff --git a/Preview.cs b/Eve-O-Preview/Preview.cs similarity index 100% rename from Preview.cs rename to Eve-O-Preview/Preview.cs diff --git a/Preview.resx b/Eve-O-Preview/Preview.resx similarity index 100% rename from Preview.resx rename to Eve-O-Preview/Preview.resx diff --git a/PreviewHandler.Designer.cs b/Eve-O-Preview/PreviewHandler.Designer.cs similarity index 100% rename from PreviewHandler.Designer.cs rename to Eve-O-Preview/PreviewHandler.Designer.cs diff --git a/PreviewHandler.cs b/Eve-O-Preview/PreviewHandler.cs similarity index 100% rename from PreviewHandler.cs rename to Eve-O-Preview/PreviewHandler.cs diff --git a/PreviewHandler.resx b/Eve-O-Preview/PreviewHandler.resx similarity index 100% rename from PreviewHandler.resx rename to Eve-O-Preview/PreviewHandler.resx diff --git a/PreviewOverlay.Designer.cs b/Eve-O-Preview/PreviewOverlay.Designer.cs similarity index 100% rename from PreviewOverlay.Designer.cs rename to Eve-O-Preview/PreviewOverlay.Designer.cs diff --git a/PreviewOverlay.cs b/Eve-O-Preview/PreviewOverlay.cs similarity index 100% rename from PreviewOverlay.cs rename to Eve-O-Preview/PreviewOverlay.cs diff --git a/PreviewOverlay.resx b/Eve-O-Preview/PreviewOverlay.resx similarity index 100% rename from PreviewOverlay.resx rename to Eve-O-Preview/PreviewOverlay.resx diff --git a/Program.cs b/Eve-O-Preview/Program.cs similarity index 100% rename from Program.cs rename to Eve-O-Preview/Program.cs diff --git a/Properties/AssemblyInfo.cs b/Eve-O-Preview/Properties/AssemblyInfo.cs similarity index 100% rename from Properties/AssemblyInfo.cs rename to Eve-O-Preview/Properties/AssemblyInfo.cs diff --git a/Properties/DataSources/PreviewToyMain.datasource b/Eve-O-Preview/Properties/DataSources/PreviewToyMain.datasource similarity index 100% rename from Properties/DataSources/PreviewToyMain.datasource rename to Eve-O-Preview/Properties/DataSources/PreviewToyMain.datasource diff --git a/Properties/Resources.Designer.cs b/Eve-O-Preview/Properties/Resources.Designer.cs similarity index 100% rename from Properties/Resources.Designer.cs rename to Eve-O-Preview/Properties/Resources.Designer.cs diff --git a/Properties/Resources.resx b/Eve-O-Preview/Properties/Resources.resx similarity index 100% rename from Properties/Resources.resx rename to Eve-O-Preview/Properties/Resources.resx diff --git a/Properties/Settings.Designer.cs b/Eve-O-Preview/Properties/Settings.Designer.cs similarity index 100% rename from Properties/Settings.Designer.cs rename to Eve-O-Preview/Properties/Settings.Designer.cs diff --git a/Properties/Settings.settings b/Eve-O-Preview/Properties/Settings.settings similarity index 100% rename from Properties/Settings.settings rename to Eve-O-Preview/Properties/Settings.settings diff --git a/Resources/icon.ico b/Eve-O-Preview/Resources/icon.ico similarity index 100% rename from Resources/icon.ico rename to Eve-O-Preview/Resources/icon.ico diff --git a/Resources/icon.png b/Eve-O-Preview/Resources/icon.png similarity index 100% rename from Resources/icon.png rename to Eve-O-Preview/Resources/icon.png diff --git a/Win32api.cs b/Eve-O-Preview/Win32api.cs similarity index 100% rename from Win32api.cs rename to Eve-O-Preview/Win32api.cs diff --git a/app.config b/Eve-O-Preview/app.config similarity index 100% rename from app.config rename to Eve-O-Preview/app.config diff --git a/icon.ico b/Eve-O-Preview/icon.ico similarity index 100% rename from icon.ico rename to Eve-O-Preview/icon.ico diff --git a/preview toy.csproj b/Eve-O-Preview/preview toy.csproj similarity index 100% rename from preview toy.csproj rename to Eve-O-Preview/preview toy.csproj diff --git a/preview toy_TemporaryKey.pfx b/Eve-O-Preview/preview toy_TemporaryKey.pfx similarity index 100% rename from preview toy_TemporaryKey.pfx rename to Eve-O-Preview/preview toy_TemporaryKey.pfx From 063b747c631381ef21c636f65e7c28c315832077 Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Mon, 9 May 2016 17:24:56 +0300 Subject: [PATCH 03/17] Give proper name to the mock project --- {ExeFile => Eve-O-Mock}/App.config | 0 {ExeFile => Eve-O-Mock}/App.xaml | 0 {ExeFile => Eve-O-Mock}/App.xaml.cs | 0 ExeFile/ExeFile.csproj => Eve-O-Mock/Eve-O-Mock.csproj | 0 {ExeFile => Eve-O-Mock}/MainWindow.xaml | 0 {ExeFile => Eve-O-Mock}/MainWindow.xaml.cs | 0 {ExeFile => Eve-O-Mock}/Properties/AssemblyInfo.cs | 0 {ExeFile => Eve-O-Mock}/Properties/Resources.Designer.cs | 0 {ExeFile => Eve-O-Mock}/Properties/Resources.resx | 0 {ExeFile => Eve-O-Mock}/Properties/Settings.Designer.cs | 0 {ExeFile => Eve-O-Mock}/Properties/Settings.settings | 0 ExeFile/.gitignore | 3 --- ExeFile/.hgignore | 3 --- 13 files changed, 6 deletions(-) rename {ExeFile => Eve-O-Mock}/App.config (100%) rename {ExeFile => Eve-O-Mock}/App.xaml (100%) rename {ExeFile => Eve-O-Mock}/App.xaml.cs (100%) rename ExeFile/ExeFile.csproj => Eve-O-Mock/Eve-O-Mock.csproj (100%) rename {ExeFile => Eve-O-Mock}/MainWindow.xaml (100%) rename {ExeFile => Eve-O-Mock}/MainWindow.xaml.cs (100%) rename {ExeFile => Eve-O-Mock}/Properties/AssemblyInfo.cs (100%) rename {ExeFile => Eve-O-Mock}/Properties/Resources.Designer.cs (100%) rename {ExeFile => Eve-O-Mock}/Properties/Resources.resx (100%) rename {ExeFile => Eve-O-Mock}/Properties/Settings.Designer.cs (100%) rename {ExeFile => Eve-O-Mock}/Properties/Settings.settings (100%) delete mode 100644 ExeFile/.gitignore delete mode 100644 ExeFile/.hgignore diff --git a/ExeFile/App.config b/Eve-O-Mock/App.config similarity index 100% rename from ExeFile/App.config rename to Eve-O-Mock/App.config diff --git a/ExeFile/App.xaml b/Eve-O-Mock/App.xaml similarity index 100% rename from ExeFile/App.xaml rename to Eve-O-Mock/App.xaml diff --git a/ExeFile/App.xaml.cs b/Eve-O-Mock/App.xaml.cs similarity index 100% rename from ExeFile/App.xaml.cs rename to Eve-O-Mock/App.xaml.cs diff --git a/ExeFile/ExeFile.csproj b/Eve-O-Mock/Eve-O-Mock.csproj similarity index 100% rename from ExeFile/ExeFile.csproj rename to Eve-O-Mock/Eve-O-Mock.csproj diff --git a/ExeFile/MainWindow.xaml b/Eve-O-Mock/MainWindow.xaml similarity index 100% rename from ExeFile/MainWindow.xaml rename to Eve-O-Mock/MainWindow.xaml diff --git a/ExeFile/MainWindow.xaml.cs b/Eve-O-Mock/MainWindow.xaml.cs similarity index 100% rename from ExeFile/MainWindow.xaml.cs rename to Eve-O-Mock/MainWindow.xaml.cs diff --git a/ExeFile/Properties/AssemblyInfo.cs b/Eve-O-Mock/Properties/AssemblyInfo.cs similarity index 100% rename from ExeFile/Properties/AssemblyInfo.cs rename to Eve-O-Mock/Properties/AssemblyInfo.cs diff --git a/ExeFile/Properties/Resources.Designer.cs b/Eve-O-Mock/Properties/Resources.Designer.cs similarity index 100% rename from ExeFile/Properties/Resources.Designer.cs rename to Eve-O-Mock/Properties/Resources.Designer.cs diff --git a/ExeFile/Properties/Resources.resx b/Eve-O-Mock/Properties/Resources.resx similarity index 100% rename from ExeFile/Properties/Resources.resx rename to Eve-O-Mock/Properties/Resources.resx diff --git a/ExeFile/Properties/Settings.Designer.cs b/Eve-O-Mock/Properties/Settings.Designer.cs similarity index 100% rename from ExeFile/Properties/Settings.Designer.cs rename to Eve-O-Mock/Properties/Settings.Designer.cs diff --git a/ExeFile/Properties/Settings.settings b/Eve-O-Mock/Properties/Settings.settings similarity index 100% rename from ExeFile/Properties/Settings.settings rename to Eve-O-Mock/Properties/Settings.settings diff --git a/ExeFile/.gitignore b/ExeFile/.gitignore deleted file mode 100644 index a6ff838..0000000 --- a/ExeFile/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -bin/* -obj/* -*.suo diff --git a/ExeFile/.hgignore b/ExeFile/.hgignore deleted file mode 100644 index 59bc062..0000000 --- a/ExeFile/.hgignore +++ /dev/null @@ -1,3 +0,0 @@ -syntax: glob -bin/* -obj/* From 789dd5b24896b06a76f614b22f5fd612584636fe Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Mon, 9 May 2016 17:25:37 +0300 Subject: [PATCH 04/17] Give proper names to the solution and project files --- preview toy.sln => EVE-O-Preview.sln | 10 ++++------ .../{preview toy.csproj => Eve-O-Preview.csproj} | 0 2 files changed, 4 insertions(+), 6 deletions(-) rename preview toy.sln => EVE-O-Preview.sln (69%) rename Eve-O-Preview/{preview toy.csproj => Eve-O-Preview.csproj} (100%) diff --git a/preview toy.sln b/EVE-O-Preview.sln similarity index 69% rename from preview toy.sln rename to EVE-O-Preview.sln index 007fa50..c5d80f3 100644 --- a/preview toy.sln +++ b/EVE-O-Preview.sln @@ -1,11 +1,9 @@  -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.31101.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "preview toy", "preview toy.csproj", "{6CA62DF3-8589-484C-8BC8-F763CA66BBB1}" +Microsoft Visual Studio Solution File, Format Version 14.00 +# Visual Studio 2015 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Eve-O-Preview", "Eve-O-Preview\Eve-O-Preview.csproj", "{6CA62DF3-8589-484C-8BC8-F763CA66BBB1}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExeFile", "ExeFile\ExeFile.csproj", "{BE2C3A13-CC19-4525-895F-381DD71C5833}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Eve-O-Mock", "Eve-O-Mock\Eve-O-Mock.csproj", "{BE2C3A13-CC19-4525-895F-381DD71C5833}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/Eve-O-Preview/preview toy.csproj b/Eve-O-Preview/Eve-O-Preview.csproj similarity index 100% rename from Eve-O-Preview/preview toy.csproj rename to Eve-O-Preview/Eve-O-Preview.csproj From 14630f4ea0c7951188f82a51fc374a9e17b0940a Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Mon, 9 May 2016 17:31:50 +0300 Subject: [PATCH 05/17] .gitignore update --- .gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index db5c47d..7b25809 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -bin/* -obj/* +bin/ +obj/ *.suo *.user From d84201f5295fc4c30b27785887c7de32664ca201 Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Mon, 9 May 2016 17:53:03 +0300 Subject: [PATCH 06/17] Set proper namespace in the Mock project --- Eve-O-Mock/App.xaml | 16 +- Eve-O-Mock/App.xaml.cs | 25 +-- Eve-O-Mock/Eve-O-Mock.csproj | 194 ++++++++++---------- Eve-O-Mock/MainWindow.xaml | 20 +- Eve-O-Mock/MainWindow.xaml.cs | 54 ++---- Eve-O-Mock/Properties/AssemblyInfo.cs | 80 +++----- Eve-O-Mock/Properties/Resources.Designer.cs | 134 +++++++------- Eve-O-Mock/Properties/Settings.Designer.cs | 56 +++--- 8 files changed, 254 insertions(+), 325 deletions(-) diff --git a/Eve-O-Mock/App.xaml b/Eve-O-Mock/App.xaml index d27e1f5..c963d94 100644 --- a/Eve-O-Mock/App.xaml +++ b/Eve-O-Mock/App.xaml @@ -1,8 +1,8 @@ - - - - - + + + + + diff --git a/Eve-O-Mock/App.xaml.cs b/Eve-O-Mock/App.xaml.cs index d0cd6a4..b19c434 100644 --- a/Eve-O-Mock/App.xaml.cs +++ b/Eve-O-Mock/App.xaml.cs @@ -1,17 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Data; -using System.Linq; -using System.Threading.Tasks; -using System.Windows; - -namespace ExeFile -{ - /// - /// Interaction logic for App.xaml - /// - public partial class App : Application - { - } -} +using System.Windows; + +namespace EveOMock +{ + public partial class App : Application + { + } +} diff --git a/Eve-O-Mock/Eve-O-Mock.csproj b/Eve-O-Mock/Eve-O-Mock.csproj index 241071d..1b48ffa 100644 --- a/Eve-O-Mock/Eve-O-Mock.csproj +++ b/Eve-O-Mock/Eve-O-Mock.csproj @@ -1,104 +1,104 @@ - - - - - Debug - AnyCPU - {BE2C3A13-CC19-4525-895F-381DD71C5833} - WinExe - Properties - ExeFile - ExeFile - v4.5 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - 4.0 - - - - - - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - App.xaml - Code - - - MainWindow.xaml - Code - - - - - Code - - - True - True - Resources.resx - - - True - Settings.settings - True - - - ResXFileCodeGenerator - Resources.Designer.cs - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - - - + + + + + Debug + AnyCPU + {BE2C3A13-CC19-4525-895F-381DD71C5833} + WinExe + Properties + EveOMock + exefile + v4.5 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + MainWindow.xaml + Code + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + --> \ No newline at end of file diff --git a/Eve-O-Mock/MainWindow.xaml b/Eve-O-Mock/MainWindow.xaml index 10a1f9b..252faa9 100644 --- a/Eve-O-Mock/MainWindow.xaml +++ b/Eve-O-Mock/MainWindow.xaml @@ -1,10 +1,10 @@ - - - - - - - + + + + + + + diff --git a/Eve-O-Mock/MainWindow.xaml.cs b/Eve-O-Mock/MainWindow.xaml.cs index aff17db..1b9018c 100644 --- a/Eve-O-Mock/MainWindow.xaml.cs +++ b/Eve-O-Mock/MainWindow.xaml.cs @@ -1,37 +1,17 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -namespace ExeFile -{ - /// - /// Interaction logic for MainWindow.xaml - /// - public partial class MainWindow : Window - { - public MainWindow() - { - InitializeComponent(); - Random random = new Random(); - this.Title += random.Next().ToString("X"); - this.grid.Background = new SolidColorBrush( - Color.FromArgb((byte)255, - (byte)random.Next(0, 255), - (byte)random.Next(0, 255), - (byte)random.Next(0, 255) - ) - ); - } - } -} +using System; +using System.Windows; +using System.Windows.Media; + +namespace EveOMock +{ + public partial class MainWindow : Window + { + public MainWindow() + { + InitializeComponent(); + Random random = new Random(); + this.Title += random.Next().ToString("X"); + this.grid.Background = new SolidColorBrush(Color.FromArgb(255, (byte)random.Next(0, 255), (byte)random.Next(0, 255), (byte)random.Next(0, 255))); + } + } +} diff --git a/Eve-O-Mock/Properties/AssemblyInfo.cs b/Eve-O-Mock/Properties/AssemblyInfo.cs index 9ffcdf9..6be2b76 100644 --- a/Eve-O-Mock/Properties/AssemblyInfo.cs +++ b/Eve-O-Mock/Properties/AssemblyInfo.cs @@ -1,55 +1,25 @@ -using System.Reflection; -using System.Resources; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Windows; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("ExeFile")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("ExeFile")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -//In order to begin building localizable applications, set -//CultureYouAreCodingWith in your .csproj file -//inside a . For example, if you are using US english -//in your source files, set the to en-US. Then uncomment -//the NeutralResourceLanguage attribute below. Update the "en-US" in -//the line below to match the UICulture setting in the project file. - -//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] - - -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) -)] - - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +using System.Reflection; +using System.Runtime.InteropServices; +using System.Windows; + +[assembly: AssemblyTitle("EVE Online mock executable for the EVE-O Preview project")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("EVE-O Mock")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(false)] + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Eve-O-Mock/Properties/Resources.Designer.cs b/Eve-O-Mock/Properties/Resources.Designer.cs index 7453b44..154cb18 100644 --- a/Eve-O-Mock/Properties/Resources.Designer.cs +++ b/Eve-O-Mock/Properties/Resources.Designer.cs @@ -1,71 +1,63 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.18444 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace ExeFile.Properties -{ - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ExeFile.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { - return resourceCulture; - } - set - { - resourceCulture = value; - } - } - } -} +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace EveOMock.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("EveOMock.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/Eve-O-Mock/Properties/Settings.Designer.cs b/Eve-O-Mock/Properties/Settings.Designer.cs index fbbc5ec..74657f2 100644 --- a/Eve-O-Mock/Properties/Settings.Designer.cs +++ b/Eve-O-Mock/Properties/Settings.Designer.cs @@ -1,30 +1,26 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.18444 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace ExeFile.Properties -{ - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { - return defaultInstance; - } - } - } -} +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace EveOMock.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} From 46fc80714f3d128aac583de35957079b305f61e0 Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Mon, 9 May 2016 19:26:58 +0300 Subject: [PATCH 07/17] Default namespace changed to EveOPreview --- Eve-O-Preview/Preview.Designer.cs | 2 +- Eve-O-Preview/Preview.cs | 8 +----- Eve-O-Preview/PreviewHandler.Designer.cs | 2 +- Eve-O-Preview/PreviewHandler.cs | 2 +- Eve-O-Preview/PreviewOverlay.Designer.cs | 2 +- Eve-O-Preview/PreviewOverlay.cs | 2 +- Eve-O-Preview/Program.cs | 25 +++++++++---------- .../Properties/Resources.Designer.cs | 6 ++--- Eve-O-Preview/Properties/Settings.Designer.cs | 6 ++--- Eve-O-Preview/Win32api.cs | 2 +- 10 files changed, 25 insertions(+), 32 deletions(-) diff --git a/Eve-O-Preview/Preview.Designer.cs b/Eve-O-Preview/Preview.Designer.cs index 96889e3..c6d52dc 100644 --- a/Eve-O-Preview/Preview.Designer.cs +++ b/Eve-O-Preview/Preview.Designer.cs @@ -1,4 +1,4 @@ -namespace PreviewToy +namespace EveOPreview { partial class Preview { diff --git a/Eve-O-Preview/Preview.cs b/Eve-O-Preview/Preview.cs index ce25712..693563d 100644 --- a/Eve-O-Preview/Preview.cs +++ b/Eve-O-Preview/Preview.cs @@ -1,14 +1,8 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; using System.Drawing; -using System.Text; using System.Windows.Forms; -using System.Runtime.InteropServices; -using System.Diagnostics; -using MovablePython; -namespace PreviewToy +namespace EveOPreview { public partial class Preview : Form { diff --git a/Eve-O-Preview/PreviewHandler.Designer.cs b/Eve-O-Preview/PreviewHandler.Designer.cs index 88dd593..5201d99 100644 --- a/Eve-O-Preview/PreviewHandler.Designer.cs +++ b/Eve-O-Preview/PreviewHandler.Designer.cs @@ -6,7 +6,7 @@ using System; using System.Windows.Forms; using System.Diagnostics; -namespace PreviewToy +namespace EveOPreview { partial class PreviewToyHandler { diff --git a/Eve-O-Preview/PreviewHandler.cs b/Eve-O-Preview/PreviewHandler.cs index 7c46fec..6d7c6d6 100644 --- a/Eve-O-Preview/PreviewHandler.cs +++ b/Eve-O-Preview/PreviewHandler.cs @@ -14,7 +14,7 @@ using System.Linq; using System.IO; -namespace PreviewToy +namespace EveOPreview { public partial class PreviewToyHandler : Form diff --git a/Eve-O-Preview/PreviewOverlay.Designer.cs b/Eve-O-Preview/PreviewOverlay.Designer.cs index 038e7c2..c02c9a0 100644 --- a/Eve-O-Preview/PreviewOverlay.Designer.cs +++ b/Eve-O-Preview/PreviewOverlay.Designer.cs @@ -1,4 +1,4 @@ -namespace PreviewToy +namespace EveOPreview { partial class PreviewOverlay { diff --git a/Eve-O-Preview/PreviewOverlay.cs b/Eve-O-Preview/PreviewOverlay.cs index b2cd701..b1f0aab 100644 --- a/Eve-O-Preview/PreviewOverlay.cs +++ b/Eve-O-Preview/PreviewOverlay.cs @@ -8,7 +8,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -namespace PreviewToy +namespace EveOPreview { public partial class PreviewOverlay : Form { diff --git a/Eve-O-Preview/Program.cs b/Eve-O-Preview/Program.cs index 6604c0b..0a6d7ee 100644 --- a/Eve-O-Preview/Program.cs +++ b/Eve-O-Preview/Program.cs @@ -1,18 +1,17 @@ using System; -using System.Collections.Generic; using System.Windows.Forms; -namespace PreviewToy +namespace EveOPreview { - static class Program - { - /// The main entry point for the application. - [STAThread] - static void Main() - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(true); - Application.Run(new PreviewToyHandler()); - } - } + static class Program + { + /// The main entry point for the application. + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(true); + Application.Run(new PreviewToyHandler()); + } + } } \ No newline at end of file diff --git a/Eve-O-Preview/Properties/Resources.Designer.cs b/Eve-O-Preview/Properties/Resources.Designer.cs index bc8c639..2490aeb 100644 --- a/Eve-O-Preview/Properties/Resources.Designer.cs +++ b/Eve-O-Preview/Properties/Resources.Designer.cs @@ -1,14 +1,14 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.34014 +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // //------------------------------------------------------------------------------ -namespace PreviewToy.Properties { +namespace EveOPreview.Properties { using System; @@ -39,7 +39,7 @@ namespace PreviewToy.Properties { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PreviewToy.Properties.Resources", typeof(Resources).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("EveOPreview.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; diff --git a/Eve-O-Preview/Properties/Settings.Designer.cs b/Eve-O-Preview/Properties/Settings.Designer.cs index ad54533..7effa90 100644 --- a/Eve-O-Preview/Properties/Settings.Designer.cs +++ b/Eve-O-Preview/Properties/Settings.Designer.cs @@ -1,18 +1,18 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.34014 +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // //------------------------------------------------------------------------------ -namespace PreviewToy.Properties { +namespace EveOPreview.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); diff --git a/Eve-O-Preview/Win32api.cs b/Eve-O-Preview/Win32api.cs index 4dd3ab8..84a55a2 100644 --- a/Eve-O-Preview/Win32api.cs +++ b/Eve-O-Preview/Win32api.cs @@ -3,7 +3,7 @@ using System.Runtime.InteropServices; using System.Drawing; using System.Text; -namespace PreviewToy +namespace EveOPreview { // Desktop Windows Manager APIs internal class DwmApi From 09405ac43a833094a6d1d3ce4fb61590cb5b383b Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Mon, 9 May 2016 19:27:24 +0300 Subject: [PATCH 08/17] Hotkeys management code moved into a folder --- Eve-O-Preview/Eve-O-Preview.csproj | 10 +- Eve-O-Preview/Hotkey.cs | 302 ----------------- Eve-O-Preview/Hotkeys/Hotkey.cs | 332 +++++++++++++++++++ Eve-O-Preview/Hotkeys/HotkeyNativeMethods.cs | 24 ++ 4 files changed, 362 insertions(+), 306 deletions(-) delete mode 100644 Eve-O-Preview/Hotkey.cs create mode 100644 Eve-O-Preview/Hotkeys/Hotkey.cs create mode 100644 Eve-O-Preview/Hotkeys/HotkeyNativeMethods.cs diff --git a/Eve-O-Preview/Eve-O-Preview.csproj b/Eve-O-Preview/Eve-O-Preview.csproj index c03ed96..4cbd220 100644 --- a/Eve-O-Preview/Eve-O-Preview.csproj +++ b/Eve-O-Preview/Eve-O-Preview.csproj @@ -8,8 +8,8 @@ {6CA62DF3-8589-484C-8BC8-F763CA66BBB1} WinExe Properties - PreviewToy - eve-o preview + EveOPreview + Eve-O Preview v4.5 @@ -42,6 +42,7 @@ prompt 4 false + false pdbonly @@ -57,7 +58,7 @@ icon.ico - PreviewToy.Program + EveOPreview.Program 4B29FD125BFAD24FF900FC81CCE0B0AD37464FDB @@ -95,7 +96,8 @@ - + + Form diff --git a/Eve-O-Preview/Hotkey.cs b/Eve-O-Preview/Hotkey.cs deleted file mode 100644 index 96d3853..0000000 --- a/Eve-O-Preview/Hotkey.cs +++ /dev/null @@ -1,302 +0,0 @@ -using System; -using System.Windows.Forms; -using System.ComponentModel; -using System.Xml.Serialization; -using System.Runtime.InteropServices; - -namespace MovablePython -{ - public class Hotkey : IMessageFilter - { - #region Interop - - [DllImport("user32.dll", SetLastError = true)] - private static extern int RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, Keys vk); - - [DllImport("user32.dll", SetLastError=true)] - private static extern int UnregisterHotKey(IntPtr hWnd, int id); - - private const uint WM_HOTKEY = 0x312; - - private const uint MOD_ALT = 0x1; - private const uint MOD_CONTROL = 0x2; - private const uint MOD_SHIFT = 0x4; - private const uint MOD_WIN = 0x8; - - private const uint ERROR_HOTKEY_ALREADY_REGISTERED = 1409; - - #endregion - - private static int currentID; - private const int maximumID = 0xBFFF; - - private Keys keyCode; - private bool shift; - private bool control; - private bool alt; - private bool windows; - - [XmlIgnore] - private int id; - [XmlIgnore] - private bool registered; - [XmlIgnore] - private Control windowControl; - - public event HandledEventHandler Pressed; - - public Hotkey() : this(Keys.None, false, false, false, false) - { - // No work done here! - } - - public Hotkey(Keys keyCode, bool shift, bool control, bool alt, bool windows) - { - // Assign properties - this.KeyCode = keyCode; - this.Shift = shift; - this.Control = control; - this.Alt = alt; - this.Windows = windows; - - // Register us as a message filter - Application.AddMessageFilter(this); - } - - ~Hotkey() - { - // Unregister the hotkey if necessary - if (this.Registered) - { this.Unregister(); } - } - - public Hotkey Clone() - { - // Clone the whole object - return new Hotkey(this.keyCode, this.shift, this.control, this.alt, this.windows); - } - - public bool GetCanRegister(Control windowControl) - { - // Handle any exceptions: they mean "no, you can't register" :) - try - { - // Attempt to register - if (!this.Register(windowControl)) - { return false; } - - // Unregister and say we managed it - this.Unregister(); - return true; - } - catch (Win32Exception) - { return false; } - catch (NotSupportedException) - { return false; } - } - - public bool Register(Control windowControl) - { - // Check that we have not registered - if (this.registered) - { throw new NotSupportedException("You cannot register a hotkey that is already registered"); } - - // We can't register an empty hotkey - if (this.Empty) - { throw new NotSupportedException("You cannot register an empty hotkey"); } - - // Get an ID for the hotkey and increase current ID - this.id = Hotkey.currentID; - Hotkey.currentID = Hotkey.currentID + 1 % Hotkey.maximumID; - - // Translate modifier keys into unmanaged version - uint modifiers = (this.Alt ? Hotkey.MOD_ALT : 0) | (this.Control ? Hotkey.MOD_CONTROL : 0) | - (this.Shift ? Hotkey.MOD_SHIFT : 0) | (this.Windows ? Hotkey.MOD_WIN : 0); - - // Register the hotkey - if (Hotkey.RegisterHotKey(windowControl.Handle, this.id, modifiers, keyCode) == 0) - { - // Is the error that the hotkey is registered? - if (Marshal.GetLastWin32Error() == ERROR_HOTKEY_ALREADY_REGISTERED) - { return false; } - else - { throw new Win32Exception(); } - } - - // Save the control reference and register state - this.registered = true; - this.windowControl = windowControl; - - // We successfully registered - return true; - } - - public void Unregister() - { - // Check that we have registered - if (!this.registered) - { throw new NotSupportedException("You cannot unregister a hotkey that is not registered"); } - - // It's possible that the control itself has died: in that case, no need to unregister! - if (!this.windowControl.IsDisposed) - { - // Clean up after ourselves - if (Hotkey.UnregisterHotKey(this.windowControl.Handle, this.id) == 0) - { throw new Win32Exception(); } - } - - // Clear the control reference and register state - this.registered = false; - this.windowControl = null; - } - - private void Reregister() - { - // Only do something if the key is already registered - if (!this.registered) - { return; } - - // Save control reference - Control windowControl = this.windowControl; - - // Unregister and then reregister again - this.Unregister(); - this.Register(windowControl); - } - - public bool PreFilterMessage(ref Message message) - { - // Only process WM_HOTKEY messages - if (message.Msg != Hotkey.WM_HOTKEY) - { return false; } - - // Check that the ID is our key and we are registerd - if (this.registered && (message.WParam.ToInt32() == this.id)) - { - // Fire the event and pass on the event if our handlers didn't handle it - return this.OnPressed(); - } - else - { return false; } - } - - private bool OnPressed() - { - // Fire the event if we can - HandledEventArgs handledEventArgs = new HandledEventArgs(false); - if (this.Pressed != null) - { this.Pressed(this, handledEventArgs); } - - // Return whether we handled the event or not - return handledEventArgs.Handled; - } - - public override string ToString() - { - // We can be empty - if (this.Empty) - { return "(none)"; } - - // Build key name - string keyName = Enum.GetName(typeof(Keys), this.keyCode);; - switch (this.keyCode) - { - case Keys.D0: - case Keys.D1: - case Keys.D2: - case Keys.D3: - case Keys.D4: - case Keys.D5: - case Keys.D6: - case Keys.D7: - case Keys.D8: - case Keys.D9: - // Strip the first character - keyName = keyName.Substring(1); - break; - default: - // Leave everything alone - break; - } - - // Build modifiers - string modifiers = ""; - if (this.shift) - { modifiers += "Shift+"; } - if (this.control) - { modifiers += "Control+"; } - if (this.alt) - { modifiers += "Alt+"; } - if (this.windows) - { modifiers += "Windows+"; } - - // Return result - return modifiers + keyName; - } - - public bool Empty - { - get { return this.keyCode == Keys.None; } - } - - public bool Registered - { - get { return this.registered; } - } - - public Keys KeyCode - { - get { return this.keyCode; } - set - { - // Save and reregister - this.keyCode = value; - this.Reregister(); - } - } - - public bool Shift - { - get { return this.shift; } - set - { - // Save and reregister - this.shift = value; - this.Reregister(); - } - } - - public bool Control - { - get { return this.control; } - set - { - // Save and reregister - this.control = value; - this.Reregister(); - } - } - - public bool Alt - { - get { return this.alt; } - set - { - // Save and reregister - this.alt = value; - this.Reregister(); - } - } - - public bool Windows - { - get { return this.windows; } - set - { - // Save and reregister - this.windows = value; - this.Reregister(); - } - } - } -} diff --git a/Eve-O-Preview/Hotkeys/Hotkey.cs b/Eve-O-Preview/Hotkeys/Hotkey.cs new file mode 100644 index 0000000..5fc8132 --- /dev/null +++ b/Eve-O-Preview/Hotkeys/Hotkey.cs @@ -0,0 +1,332 @@ +using System; +using System.Windows.Forms; +using System.ComponentModel; +using System.Xml.Serialization; +using System.Runtime.InteropServices; + +namespace EveOPreview +{ + public class Hotkey : IMessageFilter + { + private static int _currentId; + private const int MaxId = 0xBFFF; + + [XmlElement("keyCode")] + private Keys _keyCode; + [XmlElement("shift")] + private bool _shift; + [XmlElement("control")] + private bool _control; + [XmlElement("alt")] + private bool _alt; + [XmlElement("windows")] + private bool _windows; + + [XmlIgnore] + private int _id; + [XmlIgnore] + private bool _isRegistered; + [XmlIgnore] + private Control _windowControl; + + public event HandledEventHandler Pressed; + + public Hotkey() + : this(Keys.None, false, false, false, false) + { + } + + public Hotkey(Keys keyCode, bool shift, bool control, bool alt, bool windows) + { + // Assign properties + this.KeyCode = keyCode; + this.Shift = shift; + this.Control = control; + this.Alt = alt; + this.Windows = windows; + + // Register us as a message filter + Application.AddMessageFilter(this); + } + + ~Hotkey() + { + // Unregister the hotkey if necessary + if (this.IsRegistered) + { + this.Unregister(); + } + } + + public Hotkey Clone() + { + // Clone the whole object + return new Hotkey(this._keyCode, this._shift, this._control, this._alt, this._windows); + } + + public bool GetCanRegister(Control windowControl) + { + // Handle any exceptions: they mean "no, you can't register" :) + try + { + // Attempt to register + if (this.Register(windowControl)) + { + // Unregister and say we managed it + this.Unregister(); + return true; + } + } + catch (Win32Exception) + { + } + catch (NotSupportedException) + { + } + + return false; + } + + public bool Register(Control windowControl) + { + // Check that we have not registered + if (this._isRegistered) + { + throw new NotSupportedException("You cannot register a hotkey that is already registered"); + } + + // We can't register an empty hotkey + if (this.IsEmpty) + { + throw new NotSupportedException("You cannot register an empty hotkey"); + } + + // Get an ID for the hotkey and increase current ID + this._id = Hotkey._currentId; + Hotkey._currentId = Hotkey._currentId + 1 % Hotkey.MaxId; + + // Translate modifier keys into unmanaged version + uint modifiers = (this.Alt ? HotkeyNativeMethods.MOD_ALT : 0) | (this.Control ? HotkeyNativeMethods.MOD_CONTROL : 0) | + (this.Shift ? HotkeyNativeMethods.MOD_SHIFT : 0) | (this.Windows ? HotkeyNativeMethods.MOD_WIN : 0); + + // Register the hotkey + if (HotkeyNativeMethods.RegisterHotKey(windowControl.Handle, this._id, modifiers, _keyCode) == 0) + { + // Is the error that the hotkey is registered? + if (Marshal.GetLastWin32Error() != HotkeyNativeMethods.ERROR_HOTKEY_ALREADY_REGISTERED) + { + throw new Win32Exception(); + } + + return false; + } + + // Save the control reference and register state + this._isRegistered = true; + this._windowControl = windowControl; + + // We successfully registered + return true; + } + + public void Unregister() + { + // Check that we have registered + if (!this._isRegistered) + { + throw new NotSupportedException("You cannot unregister a hotkey that is not registered"); + } + + // It's possible that the control itself has died: in that case, no need to unregister! + if (!this._windowControl.IsDisposed) + { + // Clean up after ourselves + if (HotkeyNativeMethods.UnregisterHotKey(this._windowControl.Handle, this._id) == 0) + { + throw new Win32Exception(); + } + } + + // Clear the control reference and register state + this._isRegistered = false; + this._windowControl = null; + } + + private void Reregister() + { + // Only do something if the key is already registered + if (!this._isRegistered) + { + return; + } + + // Save control reference + Control windowControl = this._windowControl; + + // Unregister and then reregister again + this.Unregister(); + this.Register(windowControl); + } + + public bool PreFilterMessage(ref Message message) + { + // Only process WM_HOTKEY messages + if (message.Msg != HotkeyNativeMethods.WM_HOTKEY) + { + return false; + } + + // Check that the ID is our key and we are registerd + return this._isRegistered && (message.WParam.ToInt32() == this._id) && this.OnPressed(); + } + + private bool OnPressed() + { + // Fire the event if we can + HandledEventArgs handledEventArgs = new HandledEventArgs(false); + this.Pressed?.Invoke(this, handledEventArgs); + + // Return whether we handled the event or not + return handledEventArgs.Handled; + } + + public override string ToString() + { + // We can be empty + if (this.IsEmpty) + { + return "(none)"; + } + + // Build key name + string keyName = Enum.GetName(typeof(Keys), this._keyCode) ?? " "; + switch (this._keyCode) + { + case Keys.D0: + case Keys.D1: + case Keys.D2: + case Keys.D3: + case Keys.D4: + case Keys.D5: + case Keys.D6: + case Keys.D7: + case Keys.D8: + case Keys.D9: + // Strip the first character + keyName = keyName.Substring(1); + break; + } + + // Build modifiers + string modifiers = ""; + if (this._shift) + { + modifiers += "Shift+"; + } + + if (this._control) + { + modifiers += "Control+"; + } + + if (this._alt) + { + modifiers += "Alt+"; + } + + if (this._windows) + { + modifiers += "Windows+"; + } + + // Return result + return modifiers + keyName; + } + + public bool IsEmpty + { + get + { + return this._keyCode == Keys.None; + } + } + + public bool IsRegistered + { + get + { + return this._isRegistered; + } + } + + public Keys KeyCode + { + get + { + return this._keyCode; + } + set + { + // Save and reregister + this._keyCode = value; + this.Reregister(); + } + } + + public bool Shift + { + get + { + return this._shift; + } + set + { + // Save and reregister + this._shift = value; + this.Reregister(); + } + } + + public bool Control + { + get + { + return this._control; + } + set + { + // Save and reregister + this._control = value; + this.Reregister(); + } + } + + public bool Alt + { + get + { + return this._alt; + } + set + { + // Save and reregister + this._alt = value; + this.Reregister(); + } + } + + public bool Windows + { + get + { + return this._windows; + } + set + { + // Save and reregister + this._windows = value; + this.Reregister(); + } + } + } +} \ No newline at end of file diff --git a/Eve-O-Preview/Hotkeys/HotkeyNativeMethods.cs b/Eve-O-Preview/Hotkeys/HotkeyNativeMethods.cs new file mode 100644 index 0000000..8823fee --- /dev/null +++ b/Eve-O-Preview/Hotkeys/HotkeyNativeMethods.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; +using System.Windows.Forms; + +namespace EveOPreview +{ + static class HotkeyNativeMethods + { + [DllImport("user32.dll", SetLastError = true)] + public static extern int RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, Keys vk); + + [DllImport("user32.dll", SetLastError = true)] + public static extern int UnregisterHotKey(IntPtr hWnd, int id); + + public const uint WM_HOTKEY = 0x312; + + public const uint MOD_ALT = 0x1; + public const uint MOD_CONTROL = 0x2; + public const uint MOD_SHIFT = 0x4; + public const uint MOD_WIN = 0x8; + + public const uint ERROR_HOTKEY_ALREADY_REGISTERED = 1409; + } +} \ No newline at end of file From 793fc8cd0634e665b587c34a197b975ee080232c Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Mon, 9 May 2016 19:56:16 +0300 Subject: [PATCH 09/17] DWM API moved into a folder --- Eve-O-Preview/DwmAPI/DWM_BLURBEHIND.cs | 20 ++++++ .../DwmAPI/DWM_THUMBNAIL_PROPERTIES.cs | 23 +++++++ .../DwmApiNativeMethods.cs} | 64 +------------------ Eve-O-Preview/DwmAPI/MARGINS.cs | 21 ++++++ Eve-O-Preview/DwmAPI/RECT.cs | 21 ++++++ Eve-O-Preview/Eve-O-Preview.csproj | 6 +- Eve-O-Preview/Preview.cs | 36 +++++------ Eve-O-Preview/PreviewHandler.cs | 10 +-- 8 files changed, 115 insertions(+), 86 deletions(-) create mode 100644 Eve-O-Preview/DwmAPI/DWM_BLURBEHIND.cs create mode 100644 Eve-O-Preview/DwmAPI/DWM_THUMBNAIL_PROPERTIES.cs rename Eve-O-Preview/{Win32api.cs => DwmAPI/DwmApiNativeMethods.cs} (70%) create mode 100644 Eve-O-Preview/DwmAPI/MARGINS.cs create mode 100644 Eve-O-Preview/DwmAPI/RECT.cs diff --git a/Eve-O-Preview/DwmAPI/DWM_BLURBEHIND.cs b/Eve-O-Preview/DwmAPI/DWM_BLURBEHIND.cs new file mode 100644 index 0000000..14ebd8e --- /dev/null +++ b/Eve-O-Preview/DwmAPI/DWM_BLURBEHIND.cs @@ -0,0 +1,20 @@ +using System; +using System.Runtime.InteropServices; + +namespace EveOPreview +{ + [StructLayout(LayoutKind.Sequential)] + class DWM_BLURBEHIND + { + public uint dwFlags; + [MarshalAs(UnmanagedType.Bool)] + public bool fEnable; + public IntPtr hRegionBlur; + [MarshalAs(UnmanagedType.Bool)] + public bool fTransitionOnMaximized; + + public const uint DWM_BB_ENABLE = 0x00000001; + public const uint DWM_BB_BLURREGION = 0x00000002; + public const uint DWM_BB_TRANSITIONONMAXIMIZED = 0x00000004; + } +} \ No newline at end of file diff --git a/Eve-O-Preview/DwmAPI/DWM_THUMBNAIL_PROPERTIES.cs b/Eve-O-Preview/DwmAPI/DWM_THUMBNAIL_PROPERTIES.cs new file mode 100644 index 0000000..b5d270a --- /dev/null +++ b/Eve-O-Preview/DwmAPI/DWM_THUMBNAIL_PROPERTIES.cs @@ -0,0 +1,23 @@ +using System.Runtime.InteropServices; + +namespace EveOPreview +{ + [StructLayout(LayoutKind.Sequential)] + internal class DWM_THUMBNAIL_PROPERTIES + { + public uint dwFlags; + public RECT rcDestination; + public RECT rcSource; + public byte opacity; + [MarshalAs(UnmanagedType.Bool)] + public bool fVisible; + [MarshalAs(UnmanagedType.Bool)] + public bool fSourceClientAreaOnly; + + public const uint DWM_TNP_RECTDESTINATION = 0x00000001; + public const uint DWM_TNP_RECTSOURCE = 0x00000002; + public const uint DWM_TNP_OPACITY = 0x00000004; + public const uint DWM_TNP_VISIBLE = 0x00000008; + public const uint DWM_TNP_SOURCECLIENTAREAONLY = 0x00000010; + } +} \ No newline at end of file diff --git a/Eve-O-Preview/Win32api.cs b/Eve-O-Preview/DwmAPI/DwmApiNativeMethods.cs similarity index 70% rename from Eve-O-Preview/Win32api.cs rename to Eve-O-Preview/DwmAPI/DwmApiNativeMethods.cs index 84a55a2..027f6ac 100644 --- a/Eve-O-Preview/Win32api.cs +++ b/Eve-O-Preview/DwmAPI/DwmApiNativeMethods.cs @@ -1,14 +1,12 @@ using System; using System.Runtime.InteropServices; using System.Drawing; -using System.Text; namespace EveOPreview { // Desktop Windows Manager APIs - internal class DwmApi + static class DwmApiNativeMethods { - [DllImport("user32.dll")] public static extern IntPtr GetForegroundWindow(); @@ -43,65 +41,8 @@ namespace EveOPreview [DllImport("dwmapi.dll", PreserveSig = false)] public static extern void DwmQueryThumbnailSourceSize(IntPtr hThumbnail, out Size size); - - [StructLayout(LayoutKind.Sequential)] - public class DWM_THUMBNAIL_PROPERTIES - { - public uint dwFlags; - public RECT rcDestination; - public RECT rcSource; - public byte opacity; - [MarshalAs(UnmanagedType.Bool)] - public bool fVisible; - [MarshalAs(UnmanagedType.Bool)] - public bool fSourceClientAreaOnly; - public const uint DWM_TNP_RECTDESTINATION = 0x00000001; - public const uint DWM_TNP_RECTSOURCE = 0x00000002; - public const uint DWM_TNP_OPACITY = 0x00000004; - public const uint DWM_TNP_VISIBLE = 0x00000008; - public const uint DWM_TNP_SOURCECLIENTAREAONLY = 0x00000010; - } - - [StructLayout(LayoutKind.Sequential)] - public class MARGINS - { - public int cxLeftWidth, cxRightWidth, cyTopHeight, cyBottomHeight; - - public MARGINS(int left, int top, int right, int bottom) - { - cxLeftWidth = left; cyTopHeight = top; - cxRightWidth = right; cyBottomHeight = bottom; - } - } - - [StructLayout(LayoutKind.Sequential)] - public class DWM_BLURBEHIND - { - public uint dwFlags; - [MarshalAs(UnmanagedType.Bool)] - public bool fEnable; - public IntPtr hRegionBlur; - [MarshalAs(UnmanagedType.Bool)] - public bool fTransitionOnMaximized; - - public const uint DWM_BB_ENABLE = 0x00000001; - public const uint DWM_BB_BLURREGION = 0x00000002; - public const uint DWM_BB_TRANSITIONONMAXIMIZED = 0x00000004; - } - - [StructLayout(LayoutKind.Sequential)] - public struct RECT - { - public int left, top, right, bottom; - - public RECT(int left, int top, int right, int bottom) - { - this.left = left; this.top = top; this.right = right; this.bottom = bottom; - } - } - - public const int SW_SHOWNORMAL = 1; + public const int SW_SHOWNORMAL = 1; public const int SW_SHOWMINIMIZED = 2; public const int SW_SHOWMAXIMIZED = 3; @@ -174,6 +115,5 @@ namespace EveOPreview public const UInt32 WS_EX_LAYOUTRTL = 0x00400000; // Right to left mirroring public const UInt32 WS_EX_COMPOSITED = 0x02000000; public const UInt32 WS_EX_NOACTIVATE = 0x08000000; - } } \ No newline at end of file diff --git a/Eve-O-Preview/DwmAPI/MARGINS.cs b/Eve-O-Preview/DwmAPI/MARGINS.cs new file mode 100644 index 0000000..58ad6fc --- /dev/null +++ b/Eve-O-Preview/DwmAPI/MARGINS.cs @@ -0,0 +1,21 @@ +using System.Runtime.InteropServices; + +namespace EveOPreview +{ + [StructLayout(LayoutKind.Sequential)] + class MARGINS + { + public int cxLeftWidth; + public int cxRightWidth; + public int cyTopHeight; + public int cyBottomHeight; + + public MARGINS(int left, int top, int right, int bottom) + { + cxLeftWidth = left; + cyTopHeight = top; + cxRightWidth = right; + cyBottomHeight = bottom; + } + } +} \ No newline at end of file diff --git a/Eve-O-Preview/DwmAPI/RECT.cs b/Eve-O-Preview/DwmAPI/RECT.cs new file mode 100644 index 0000000..68eee6a --- /dev/null +++ b/Eve-O-Preview/DwmAPI/RECT.cs @@ -0,0 +1,21 @@ +using System.Runtime.InteropServices; + +namespace EveOPreview +{ + [StructLayout(LayoutKind.Sequential)] + struct RECT + { + public int left; + public int top; + public int right; + public int bottom; + + public RECT(int left, int top, int right, int bottom) + { + this.left = left; + this.top = top; + this.right = right; + this.bottom = bottom; + } + } +} \ No newline at end of file diff --git a/Eve-O-Preview/Eve-O-Preview.csproj b/Eve-O-Preview/Eve-O-Preview.csproj index 4cbd220..2f6ff94 100644 --- a/Eve-O-Preview/Eve-O-Preview.csproj +++ b/Eve-O-Preview/Eve-O-Preview.csproj @@ -96,6 +96,10 @@ + + + + @@ -153,7 +157,7 @@ Preview.cs - + diff --git a/Eve-O-Preview/Preview.cs b/Eve-O-Preview/Preview.cs index 693563d..91d0556 100644 --- a/Eve-O-Preview/Preview.cs +++ b/Eve-O-Preview/Preview.cs @@ -17,7 +17,7 @@ namespace EveOPreview private IntPtr m_hThumbnail; public IntPtr sourceWindow; - private DwmApi.DWM_THUMBNAIL_PROPERTIES m_ThumbnailProperties; + private DWM_THUMBNAIL_PROPERTIES m_ThumbnailProperties; private bool has_been_set_up = false; private bool thumbnail_has_been_set_up = false; private PreviewToyHandler spawner; @@ -231,14 +231,14 @@ namespace EveOPreview { if (has_been_set_up) { - if (DwmApi.DwmIsCompositionEnabled()) + if (DwmApiNativeMethods.DwmIsCompositionEnabled()) { if (thumbnail_has_been_set_up == false) { this.SetUpThumbnail(); } - m_ThumbnailProperties.rcDestination = new DwmApi.RECT(0, 0, ClientRectangle.Right, ClientRectangle.Bottom); - DwmApi.DwmUpdateThumbnailProperties(m_hThumbnail, m_ThumbnailProperties); + m_ThumbnailProperties.rcDestination = new RECT(0, 0, ClientRectangle.Right, ClientRectangle.Bottom); + DwmApiNativeMethods.DwmUpdateThumbnailProperties(m_hThumbnail, m_ThumbnailProperties); } else { @@ -284,21 +284,21 @@ namespace EveOPreview private void SetUpThumbnail() { - if (DwmApi.DwmIsCompositionEnabled() && !thumbnail_has_been_set_up) + if (DwmApiNativeMethods.DwmIsCompositionEnabled() && !thumbnail_has_been_set_up) { - m_hThumbnail = DwmApi.DwmRegisterThumbnail(this.Handle, sourceWindow); + m_hThumbnail = DwmApiNativeMethods.DwmRegisterThumbnail(this.Handle, sourceWindow); - m_ThumbnailProperties = new DwmApi.DWM_THUMBNAIL_PROPERTIES(); - m_ThumbnailProperties.dwFlags = DwmApi.DWM_THUMBNAIL_PROPERTIES.DWM_TNP_VISIBLE - + DwmApi.DWM_THUMBNAIL_PROPERTIES.DWM_TNP_OPACITY - + DwmApi.DWM_THUMBNAIL_PROPERTIES.DWM_TNP_RECTDESTINATION - + DwmApi.DWM_THUMBNAIL_PROPERTIES.DWM_TNP_SOURCECLIENTAREAONLY; + m_ThumbnailProperties = new DWM_THUMBNAIL_PROPERTIES(); + m_ThumbnailProperties.dwFlags = DWM_THUMBNAIL_PROPERTIES.DWM_TNP_VISIBLE + + DWM_THUMBNAIL_PROPERTIES.DWM_TNP_OPACITY + + DWM_THUMBNAIL_PROPERTIES.DWM_TNP_RECTDESTINATION + + DWM_THUMBNAIL_PROPERTIES.DWM_TNP_SOURCECLIENTAREAONLY; m_ThumbnailProperties.opacity = 255; m_ThumbnailProperties.fVisible = true; m_ThumbnailProperties.fSourceClientAreaOnly = true; - m_ThumbnailProperties.rcDestination = new DwmApi.RECT(0, 0, ClientRectangle.Right, ClientRectangle.Bottom); + m_ThumbnailProperties.rcDestination = new RECT(0, 0, ClientRectangle.Right, ClientRectangle.Bottom); - DwmApi.DwmUpdateThumbnailProperties(m_hThumbnail, m_ThumbnailProperties); + DwmApiNativeMethods.DwmUpdateThumbnailProperties(m_hThumbnail, m_ThumbnailProperties); thumbnail_has_been_set_up = true; } @@ -311,15 +311,15 @@ namespace EveOPreview public void bring_client_to_foreground() { - DwmApi.SetForegroundWindow(sourceWindow); - int style = DwmApi.GetWindowLong(sourceWindow, DwmApi.GWL_STYLE); - if ((style & DwmApi.WS_MAXIMIZE) == DwmApi.WS_MAXIMIZE) + DwmApiNativeMethods.SetForegroundWindow(sourceWindow); + int style = DwmApiNativeMethods.GetWindowLong(sourceWindow, DwmApiNativeMethods.GWL_STYLE); + if ((style & DwmApiNativeMethods.WS_MAXIMIZE) == DwmApiNativeMethods.WS_MAXIMIZE) { //It's maximized } - else if ((style & DwmApi.WS_MINIMIZE) == DwmApi.WS_MINIMIZE) + else if ((style & DwmApiNativeMethods.WS_MINIMIZE) == DwmApiNativeMethods.WS_MINIMIZE) { - DwmApi.ShowWindowAsync(sourceWindow, DwmApi.SW_SHOWNORMAL); + DwmApiNativeMethods.ShowWindowAsync(sourceWindow, DwmApiNativeMethods.SW_SHOWNORMAL); } } diff --git a/Eve-O-Preview/PreviewHandler.cs b/Eve-O-Preview/PreviewHandler.cs index 6d7c6d6..ce325e0 100644 --- a/Eve-O-Preview/PreviewHandler.cs +++ b/Eve-O-Preview/PreviewHandler.cs @@ -224,7 +224,7 @@ namespace EveOPreview refresh_client_window_locations(process); } - if (process.MainWindowHandle == DwmApi.GetForegroundWindow()) + if (process.MainWindowHandle == DwmApiNativeMethods.GetForegroundWindow()) { active_client_handle = process.MainWindowHandle; active_client_title = process.MainWindowTitle; @@ -512,7 +512,7 @@ namespace EveOPreview private void refresh_thumbnails() { - IntPtr active_window = DwmApi.GetForegroundWindow(); + IntPtr active_window = DwmApiNativeMethods.GetForegroundWindow(); // hide, show, resize and move foreach (KeyValuePair entry in previews) @@ -547,7 +547,7 @@ namespace EveOPreview } } - DwmApi.DwmIsCompositionEnabled(); + DwmApiNativeMethods.DwmIsCompositionEnabled(); } @@ -566,7 +566,7 @@ namespace EveOPreview foreach (KeyValuePair entry in previews) { - if (entry.Value.Handle != DwmApi.GetForegroundWindow()) + if (entry.Value.Handle != DwmApiNativeMethods.GetForegroundWindow()) { entry.Value.set_render_area_size(sync_size); } @@ -607,7 +607,7 @@ namespace EveOPreview refresh_thumbnails(); if (ignoring_size_sync.ElapsedMilliseconds > 500) { ignoring_size_sync.Stop(); }; - if (DwmApi.DwmIsCompositionEnabled()) + if (DwmApiNativeMethods.DwmIsCompositionEnabled()) { aero_status_label.Text = "AERO is ON"; aero_status_label.ForeColor = Color.Black; From 95b10a352ca467a830d469598a4cd7c66a966026 Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Mon, 9 May 2016 20:50:31 +0300 Subject: [PATCH 10/17] GUI cleanup --- Eve-O-Preview/Eve-O-Preview.csproj | 22 ++--- .../MainForm.Designer.cs} | 6 +- .../{PreviewHandler.cs => GUI/MainForm.cs} | 88 +++++++++---------- .../MainForm.resx} | 0 .../{ => Preview}/Preview.Designer.cs | 0 Eve-O-Preview/{ => Preview}/Preview.cs | 24 ++--- Eve-O-Preview/{ => Preview}/Preview.resx | 0 .../{ => Preview}/PreviewOverlay.Designer.cs | 0 Eve-O-Preview/{ => Preview}/PreviewOverlay.cs | 0 .../{ => Preview}/PreviewOverlay.resx | 0 Eve-O-Preview/Program.cs | 2 +- 11 files changed, 69 insertions(+), 73 deletions(-) rename Eve-O-Preview/{PreviewHandler.Designer.cs => GUI/MainForm.Designer.cs} (97%) rename Eve-O-Preview/{PreviewHandler.cs => GUI/MainForm.cs} (88%) rename Eve-O-Preview/{PreviewHandler.resx => GUI/MainForm.resx} (100%) rename Eve-O-Preview/{ => Preview}/Preview.Designer.cs (100%) rename Eve-O-Preview/{ => Preview}/Preview.cs (90%) rename Eve-O-Preview/{ => Preview}/Preview.resx (100%) rename Eve-O-Preview/{ => Preview}/PreviewOverlay.Designer.cs (100%) rename Eve-O-Preview/{ => Preview}/PreviewOverlay.cs (100%) rename Eve-O-Preview/{ => Preview}/PreviewOverlay.resx (100%) diff --git a/Eve-O-Preview/Eve-O-Preview.csproj b/Eve-O-Preview/Eve-O-Preview.csproj index 2f6ff94..71ecbe9 100644 --- a/Eve-O-Preview/Eve-O-Preview.csproj +++ b/Eve-O-Preview/Eve-O-Preview.csproj @@ -102,25 +102,25 @@ - + Form - - PreviewHandler.cs + + MainForm.cs - + Form - + PreviewOverlay.cs - + Designer - PreviewHandler.cs + MainForm.cs - + PreviewOverlay.cs @@ -128,7 +128,7 @@ Resources.Designer.cs Designer - + Designer Preview.cs @@ -151,10 +151,10 @@ Settings.settings True - + Form - + Preview.cs diff --git a/Eve-O-Preview/PreviewHandler.Designer.cs b/Eve-O-Preview/GUI/MainForm.Designer.cs similarity index 97% rename from Eve-O-Preview/PreviewHandler.Designer.cs rename to Eve-O-Preview/GUI/MainForm.Designer.cs index 5201d99..802defc 100644 --- a/Eve-O-Preview/PreviewHandler.Designer.cs +++ b/Eve-O-Preview/GUI/MainForm.Designer.cs @@ -8,7 +8,7 @@ using System.Diagnostics; namespace EveOPreview { - partial class PreviewToyHandler + partial class MainForm { /// /// Required designer variable. @@ -37,7 +37,7 @@ namespace EveOPreview private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PreviewToyHandler)); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); this.option_hide_active = new System.Windows.Forms.CheckBox(); this.option_hide_all_if_not_right_type = new System.Windows.Forms.CheckBox(); this.option_unique_layout = new System.Windows.Forms.CheckBox(); @@ -566,7 +566,7 @@ namespace EveOPreview this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Margin = new System.Windows.Forms.Padding(0); this.MaximizeBox = false; - this.Name = "PreviewToyHandler"; + this.Name = "MainForm"; this.Text = "EVE Online previewer"; this.TopMost = true; this.WindowState = System.Windows.Forms.FormWindowState.Minimized; diff --git a/Eve-O-Preview/PreviewHandler.cs b/Eve-O-Preview/GUI/MainForm.cs similarity index 88% rename from Eve-O-Preview/PreviewHandler.cs rename to Eve-O-Preview/GUI/MainForm.cs index ce325e0..21af088 100644 --- a/Eve-O-Preview/PreviewHandler.cs +++ b/Eve-O-Preview/GUI/MainForm.cs @@ -1,23 +1,16 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using System.Drawing; -using System.Drawing.Drawing2D; -using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; using System.Diagnostics; -using System.Drawing.Text; using System.Windows.Threading; using System.Xml.Linq; -using System.Linq; - using System.IO; namespace EveOPreview { - - public partial class PreviewToyHandler : Form + public partial class MainForm : Form { private const int WM_SIZE = 5; private const int SIZE_RESTORED = 0; @@ -31,11 +24,11 @@ namespace EveOPreview public event EventHandler Restored; - private Dictionary previews; - private DispatcherTimer dispatcherTimer; + private readonly Dictionary _previews; + private DispatcherTimer _dispatcherTimer; - private IntPtr active_client_handle = (IntPtr)0; - private String active_client_title = ""; + private IntPtr _activeClientHandle; + private String _activeClientTitle; private Dictionary> unique_layouts; private Dictionary flat_layout; @@ -85,11 +78,14 @@ namespace EveOPreview private Dictionary zoom_anchor_button_map; - public PreviewToyHandler() + public MainForm() { is_initialized = false; - previews = new Dictionary(); + this._activeClientHandle = (IntPtr)0; + this._activeClientTitle = ""; + + _previews = new Dictionary(); xml_bad_to_ok_chars = new Dictionary(); xml_bad_to_ok_chars["<"] = "---lt---"; @@ -112,10 +108,10 @@ namespace EveOPreview init_options(); // DispatcherTimer setup - dispatcherTimer = new DispatcherTimer(); - dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick); - dispatcherTimer.Interval = new TimeSpan(0, 0, 1); - dispatcherTimer.Start(); + _dispatcherTimer = new DispatcherTimer(); + _dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick); + _dispatcherTimer.Interval = new TimeSpan(0, 0, 1); + _dispatcherTimer.Start(); is_initialized = true; @@ -195,46 +191,46 @@ namespace EveOPreview sync_size.Width = (int)Properties.Settings.Default.sync_resize_x; sync_size.Height = (int)Properties.Settings.Default.sync_resize_y; - if (!previews.ContainsKey(process.MainWindowHandle) && process.MainWindowTitle != "") + if (!_previews.ContainsKey(process.MainWindowHandle) && process.MainWindowTitle != "") { - previews[process.MainWindowHandle] = new Preview(process.MainWindowHandle, "...", this, sync_size); - previews[process.MainWindowHandle].set_render_area_size(sync_size); + _previews[process.MainWindowHandle] = new Preview(process.MainWindowHandle, "...", this, sync_size); + _previews[process.MainWindowHandle].set_render_area_size(sync_size); // apply more thumbnail specific options - previews[process.MainWindowHandle].MakeTopMost(Properties.Settings.Default.always_on_top); - set_thumbnail_frame_style(previews[process.MainWindowHandle], Properties.Settings.Default.show_thumb_frames); + _previews[process.MainWindowHandle].MakeTopMost(Properties.Settings.Default.always_on_top); + set_thumbnail_frame_style(_previews[process.MainWindowHandle], Properties.Settings.Default.show_thumb_frames); // add a preview also previews_check_listbox.BeginUpdate(); - previews_check_listbox.Items.Add(previews[process.MainWindowHandle]); + previews_check_listbox.Items.Add(_previews[process.MainWindowHandle]); previews_check_listbox.EndUpdate(); refresh_client_window_locations(process); } - else if (previews.ContainsKey(process.MainWindowHandle) && process.MainWindowTitle != previews[process.MainWindowHandle].Text) //or update the preview titles + else if (_previews.ContainsKey(process.MainWindowHandle) && process.MainWindowTitle != _previews[process.MainWindowHandle].Text) //or update the preview titles { - previews[process.MainWindowHandle].SetLabel(process.MainWindowTitle); - string key = previews[process.MainWindowHandle].Text; + _previews[process.MainWindowHandle].SetLabel(process.MainWindowTitle); + string key = _previews[process.MainWindowHandle].Text; string value; if (flat_layout_shortcuts.TryGetValue(key, out value)) { - previews[process.MainWindowHandle].registerShortcut(value); + _previews[process.MainWindowHandle].registerShortcut(value); } refresh_client_window_locations(process); } if (process.MainWindowHandle == DwmApiNativeMethods.GetForegroundWindow()) { - active_client_handle = process.MainWindowHandle; - active_client_title = process.MainWindowTitle; + _activeClientHandle = process.MainWindowHandle; + _activeClientTitle = process.MainWindowTitle; } } // clean up old previews List to_be_pruned = new List(); - foreach (IntPtr processHandle in previews.Keys) + foreach (IntPtr processHandle in _previews.Keys) { if (!(processHandles.Contains(processHandle))) { @@ -245,12 +241,12 @@ namespace EveOPreview foreach (IntPtr processHandle in to_be_pruned) { previews_check_listbox.BeginUpdate(); - previews_check_listbox.Items.Remove(previews[processHandle]); + previews_check_listbox.Items.Remove(_previews[processHandle]); previews_check_listbox.EndUpdate(); - previews[processHandle].overlay.Close(); - previews[processHandle].Close(); - previews.Remove(processHandle); + _previews[processHandle].overlay.Close(); + _previews[processHandle].Close(); + _previews.Remove(processHandle); } previews_check_listbox.Update(); @@ -473,7 +469,7 @@ namespace EveOPreview { update_client_locations(); store_layout(); //todo: check if it actually changed ... - foreach (KeyValuePair entry in previews) + foreach (KeyValuePair entry in _previews) { entry.Value.MakeTopMost(Properties.Settings.Default.always_on_top); //makes the PreviewOverlay topmost @@ -498,7 +494,7 @@ namespace EveOPreview private bool window_is_preview_or_client(IntPtr window) { bool active_window_is_right_type = false; - foreach (KeyValuePair entry in previews) + foreach (KeyValuePair entry in _previews) { if (entry.Key == window || entry.Value.Handle == window || this.Handle == window || entry.Value.overlay.Handle == window) { @@ -515,13 +511,13 @@ namespace EveOPreview IntPtr active_window = DwmApiNativeMethods.GetForegroundWindow(); // hide, show, resize and move - foreach (KeyValuePair entry in previews) + foreach (KeyValuePair entry in _previews) { if (!window_is_preview_or_client(active_window) && Properties.Settings.Default.hide_all) { entry.Value.Hide(); } - else if (entry.Key == active_client_handle && Properties.Settings.Default.hide_active) + else if (entry.Key == _activeClientHandle && Properties.Settings.Default.hide_active) { entry.Value.Hide(); } @@ -530,7 +526,7 @@ namespace EveOPreview entry.Value.Show(); if (Properties.Settings.Default.unique_layout) { - handle_unique_layout(entry.Value, active_client_title); + handle_unique_layout(entry.Value, _activeClientTitle); } else { @@ -564,7 +560,7 @@ namespace EveOPreview option_sync_size_x.Text = sync_size.Width.ToString(); option_sync_size_y.Text = sync_size.Height.ToString(); - foreach (KeyValuePair entry in previews) + foreach (KeyValuePair entry in _previews) { if (entry.Value.Handle != DwmApiNativeMethods.GetForegroundWindow()) { @@ -583,14 +579,14 @@ namespace EveOPreview if (Properties.Settings.Default.unique_layout) { Dictionary layout; - if (unique_layouts.TryGetValue(active_client_title, out layout)) + if (unique_layouts.TryGetValue(_activeClientTitle, out layout)) { layout[preview_title] = position; } - else if (active_client_title == "") + else if (_activeClientTitle == "") { - unique_layouts[active_client_title] = new Dictionary(); - unique_layouts[active_client_title][preview_title] = position; + unique_layouts[_activeClientTitle] = new Dictionary(); + unique_layouts[_activeClientTitle][preview_title] = position; } } else @@ -726,7 +722,7 @@ namespace EveOPreview ignoring_size_sync.Start(); } - foreach (var thumbnail in previews) + foreach (var thumbnail in _previews) { set_thumbnail_frame_style(thumbnail.Value, Properties.Settings.Default.show_thumb_frames); } diff --git a/Eve-O-Preview/PreviewHandler.resx b/Eve-O-Preview/GUI/MainForm.resx similarity index 100% rename from Eve-O-Preview/PreviewHandler.resx rename to Eve-O-Preview/GUI/MainForm.resx diff --git a/Eve-O-Preview/Preview.Designer.cs b/Eve-O-Preview/Preview/Preview.Designer.cs similarity index 100% rename from Eve-O-Preview/Preview.Designer.cs rename to Eve-O-Preview/Preview/Preview.Designer.cs diff --git a/Eve-O-Preview/Preview.cs b/Eve-O-Preview/Preview/Preview.cs similarity index 90% rename from Eve-O-Preview/Preview.cs rename to Eve-O-Preview/Preview/Preview.cs index 91d0556..53823b7 100644 --- a/Eve-O-Preview/Preview.cs +++ b/Eve-O-Preview/Preview/Preview.cs @@ -20,7 +20,7 @@ namespace EveOPreview private DWM_THUMBNAIL_PROPERTIES m_ThumbnailProperties; private bool has_been_set_up = false; private bool thumbnail_has_been_set_up = false; - private PreviewToyHandler spawner; + private MainForm spawner; private Hotkey hotkey; private bool hide = false; @@ -44,7 +44,7 @@ namespace EveOPreview this.TopMost = topmost && !(this.hide); } - public Preview(IntPtr sourceWindow, String title, PreviewToyHandler spawner, Size size) + public Preview(IntPtr sourceWindow, String title, MainForm spawner, Size size) { has_been_set_up = false; @@ -138,34 +138,34 @@ namespace EveOPreview Size = new Size((int)(hover_zoom_factor * (float)Size.Width), (int)(hover_zoom_factor * (float)Size.Height)); - switch ((PreviewToyHandler.zoom_anchor_t)Properties.Settings.Default.zoom_anchor) + switch ((MainForm.zoom_anchor_t)Properties.Settings.Default.zoom_anchor) { - case (PreviewToyHandler.zoom_anchor_t.NW): + case (MainForm.zoom_anchor_t.NW): break; - case (PreviewToyHandler.zoom_anchor_t.N): + case (MainForm.zoom_anchor_t.N): Location = new Point(Location.X - Size.Width / 2 + old_size.Width / 2, Location.Y); break; - case (PreviewToyHandler.zoom_anchor_t.NE): + case (MainForm.zoom_anchor_t.NE): Location = new Point(Location.X - Size.Width + old_size.Width, Location.Y); break; - case (PreviewToyHandler.zoom_anchor_t.W): + case (MainForm.zoom_anchor_t.W): Location = new Point(Location.X, Location.Y - Size.Height / 2 + old_size.Height / 2); break; - case (PreviewToyHandler.zoom_anchor_t.C): + case (MainForm.zoom_anchor_t.C): Location = new Point(Location.X - Size.Width / 2 + old_size.Width / 2, Location.Y - Size.Height / 2 + old_size.Height / 2); break; - case (PreviewToyHandler.zoom_anchor_t.E): + case (MainForm.zoom_anchor_t.E): Location = new Point(Location.X - Size.Width + old_size.Width, Location.Y - Size.Height / 2 + old_size.Height / 2); break; - case (PreviewToyHandler.zoom_anchor_t.SW): + case (MainForm.zoom_anchor_t.SW): Location = new Point(Location.X, Location.Y - Size.Height + old_size.Height); break; - case (PreviewToyHandler.zoom_anchor_t.S): + case (MainForm.zoom_anchor_t.S): Location = new Point(Location.X - Size.Width / 2 + old_size.Width / 2, Location.Y - Size.Height + old_size.Height); break; - case (PreviewToyHandler.zoom_anchor_t.SE): + case (MainForm.zoom_anchor_t.SE): Location = new Point(Location.X - Size.Width + old_size.Width, Location.Y - Size.Height + old_size.Height); break; } diff --git a/Eve-O-Preview/Preview.resx b/Eve-O-Preview/Preview/Preview.resx similarity index 100% rename from Eve-O-Preview/Preview.resx rename to Eve-O-Preview/Preview/Preview.resx diff --git a/Eve-O-Preview/PreviewOverlay.Designer.cs b/Eve-O-Preview/Preview/PreviewOverlay.Designer.cs similarity index 100% rename from Eve-O-Preview/PreviewOverlay.Designer.cs rename to Eve-O-Preview/Preview/PreviewOverlay.Designer.cs diff --git a/Eve-O-Preview/PreviewOverlay.cs b/Eve-O-Preview/Preview/PreviewOverlay.cs similarity index 100% rename from Eve-O-Preview/PreviewOverlay.cs rename to Eve-O-Preview/Preview/PreviewOverlay.cs diff --git a/Eve-O-Preview/PreviewOverlay.resx b/Eve-O-Preview/Preview/PreviewOverlay.resx similarity index 100% rename from Eve-O-Preview/PreviewOverlay.resx rename to Eve-O-Preview/Preview/PreviewOverlay.resx diff --git a/Eve-O-Preview/Program.cs b/Eve-O-Preview/Program.cs index 0a6d7ee..4373bcc 100644 --- a/Eve-O-Preview/Program.cs +++ b/Eve-O-Preview/Program.cs @@ -11,7 +11,7 @@ namespace EveOPreview { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(true); - Application.Run(new PreviewToyHandler()); + Application.Run(new MainForm()); } } } \ No newline at end of file From b3c4536407de1718a2f9f3a058bf3ddb3cc0272f Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Fri, 13 May 2016 23:27:46 +0300 Subject: [PATCH 11/17] Initial Code Cleanup - 1st phase completed --- Eve-O-Mock/Eve-O-Mock.csproj | 3 +- Eve-O-Preview/DwmAPI/DwmApiNativeMethods.cs | 2 + Eve-O-Preview/DwmAPI/RECT.cs | 16 +- Eve-O-Preview/Eve-O-Preview.csproj | 11 +- Eve-O-Preview/GUI/ClientLocation.cs | 10 + Eve-O-Preview/GUI/GuiNativeMethods.cs | 22 + Eve-O-Preview/GUI/MainForm.cs | 1766 ++++++++--------- Eve-O-Preview/GUI/ZoomAnchor.cs | 15 + Eve-O-Preview/Preview/Preview.Designer.cs | 84 +- Eve-O-Preview/Preview/Preview.cs | 566 +++--- .../Preview/PreviewOverlay.Designer.cs | 113 +- Eve-O-Preview/Preview/PreviewOverlay.cs | 77 +- Eve-O-Preview/Preview/PreviewOverlay.resx | 3 + Eve-O-Preview/Properties/AssemblyInfo.cs | 14 +- Eve-O-Preview/preview toy_TemporaryKey.pfx | Bin 1652 -> 0 bytes 15 files changed, 1347 insertions(+), 1355 deletions(-) create mode 100644 Eve-O-Preview/GUI/ClientLocation.cs create mode 100644 Eve-O-Preview/GUI/GuiNativeMethods.cs create mode 100644 Eve-O-Preview/GUI/ZoomAnchor.cs delete mode 100644 Eve-O-Preview/preview toy_TemporaryKey.pfx diff --git a/Eve-O-Mock/Eve-O-Mock.csproj b/Eve-O-Mock/Eve-O-Mock.csproj index 1b48ffa..6c0f85f 100644 --- a/Eve-O-Mock/Eve-O-Mock.csproj +++ b/Eve-O-Mock/Eve-O-Mock.csproj @@ -8,7 +8,7 @@ WinExe Properties EveOMock - exefile + ExeFile v4.5 512 {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} @@ -23,6 +23,7 @@ DEBUG;TRACE prompt 4 + false AnyCPU diff --git a/Eve-O-Preview/DwmAPI/DwmApiNativeMethods.cs b/Eve-O-Preview/DwmAPI/DwmApiNativeMethods.cs index 027f6ac..445252a 100644 --- a/Eve-O-Preview/DwmAPI/DwmApiNativeMethods.cs +++ b/Eve-O-Preview/DwmAPI/DwmApiNativeMethods.cs @@ -51,8 +51,10 @@ namespace EveOPreview public const int WM_NCLBUTTONDOWN = 0xA1; public const int HTCAPTION = 0x2; + [DllImport("User32.dll")] public static extern bool ReleaseCapture(); + [DllImport("User32.dll")] public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); diff --git a/Eve-O-Preview/DwmAPI/RECT.cs b/Eve-O-Preview/DwmAPI/RECT.cs index 68eee6a..bc9f5ec 100644 --- a/Eve-O-Preview/DwmAPI/RECT.cs +++ b/Eve-O-Preview/DwmAPI/RECT.cs @@ -5,17 +5,17 @@ namespace EveOPreview [StructLayout(LayoutKind.Sequential)] struct RECT { - public int left; - public int top; - public int right; - public int bottom; + public int Left; + public int Top; + public int Right; + public int Bottom; public RECT(int left, int top, int right, int bottom) { - this.left = left; - this.top = top; - this.right = right; - this.bottom = bottom; + this.Left = left; + this.Top = top; + this.Right = right; + this.Bottom = bottom; } } } \ No newline at end of file diff --git a/Eve-O-Preview/Eve-O-Preview.csproj b/Eve-O-Preview/Eve-O-Preview.csproj index 71ecbe9..2a654c5 100644 --- a/Eve-O-Preview/Eve-O-Preview.csproj +++ b/Eve-O-Preview/Eve-O-Preview.csproj @@ -82,6 +82,13 @@ true + + false + + + + + @@ -100,6 +107,9 @@ + + + @@ -140,7 +150,6 @@ Designer - SettingsSingleFileGenerator diff --git a/Eve-O-Preview/GUI/ClientLocation.cs b/Eve-O-Preview/GUI/ClientLocation.cs new file mode 100644 index 0000000..6f66438 --- /dev/null +++ b/Eve-O-Preview/GUI/ClientLocation.cs @@ -0,0 +1,10 @@ +namespace EveOPreview +{ + public struct ClientLocation + { + public int X; + public int Y; + public int Width; + public int Height; + } +} \ No newline at end of file diff --git a/Eve-O-Preview/GUI/GuiNativeMethods.cs b/Eve-O-Preview/GUI/GuiNativeMethods.cs new file mode 100644 index 0000000..d46dfb1 --- /dev/null +++ b/Eve-O-Preview/GUI/GuiNativeMethods.cs @@ -0,0 +1,22 @@ +using System; +using System.Runtime.InteropServices; + +namespace EveOPreview +{ + // TODO This is a really bad name for this class + static class GuiNativeMethods + { + public const int WM_SIZE = 5; + public const int SIZE_RESTORED = 0; + public const int SIZE_MINIMIZED = 1; + public const int SIZE_MAXIMIZED = 2; + public const int SIZE_MAXSHOW = 3; + public const int SIZE_MAXHIDE = 4; + + [DllImport("user32.dll")] + public static extern int GetWindowRect(IntPtr hwnd, out RECT rect); + + [DllImport("user32.dll")] + public static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint); + } +} \ No newline at end of file diff --git a/Eve-O-Preview/GUI/MainForm.cs b/Eve-O-Preview/GUI/MainForm.cs index 21af088..389ea25 100644 --- a/Eve-O-Preview/GUI/MainForm.cs +++ b/Eve-O-Preview/GUI/MainForm.cs @@ -2,943 +2,893 @@ using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; -using System.Runtime.InteropServices; using System.Diagnostics; +using System.Globalization; using System.Windows.Threading; using System.Xml.Linq; using System.IO; namespace EveOPreview { - public partial class MainForm : Form - { - private const int WM_SIZE = 5; - private const int SIZE_RESTORED = 0; - private const int SIZE_MINIMIZED = 1; - private const int SIZE_MAXIMIZED = 2; - private const int SIZE_MAXSHOW = 3; - private const int SIZE_MAXHIDE = 4; - - public event EventHandler Minimized; - public event EventHandler Maximized; - public event EventHandler Restored; + public partial class MainForm : Form + { + public event EventHandler Minimized; + public event EventHandler Maximized; + public event EventHandler Restored; - private readonly Dictionary _previews; - private DispatcherTimer _dispatcherTimer; + private readonly Dictionary _previews; + private DispatcherTimer _dispatcherTimer; - private IntPtr _activeClientHandle; - private String _activeClientTitle; + private IntPtr _activeClientHandle; + private string _activeClientTitle; - private Dictionary> unique_layouts; - private Dictionary flat_layout; - private Dictionary flat_layout_shortcuts; - private Dictionary client_layout; + private readonly Dictionary> _uniqueLayouts; + private readonly Dictionary _flatLayout; + private readonly Dictionary _flatLayoutShortcuts; + private readonly Dictionary _clientLayout; - private bool is_initialized; + private readonly bool _isInitialized; - private Stopwatch ignoring_size_sync; + private readonly Stopwatch _ignoringSizeSync; - Dictionary xml_bad_to_ok_chars; + private readonly Dictionary _xmlBadToOkChars; - [DllImport("user32.dll")] - private static extern int GetWindowRect(IntPtr hwnd, out Rect rect); + private Dictionary _zoomAnchorButtonMap; - [DllImport("user32.dll")] - public static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint); - - private struct Rect - { - public int Left; - public int Top; - public int Right; - public int Bottom; - } - - private struct ClientLocation - { - public int X; - public int Y; - public int Width; - public int Height; - } - - public enum zoom_anchor_t - { - NW = 0, - N, - NE, - W, - C, - E, - SW, - S, - SE - }; - - private Dictionary zoom_anchor_button_map; - - public MainForm() - { - is_initialized = false; + public MainForm() + { + _isInitialized = false; this._activeClientHandle = (IntPtr)0; this._activeClientTitle = ""; - _previews = new Dictionary(); + _previews = new Dictionary(); - xml_bad_to_ok_chars = new Dictionary(); - xml_bad_to_ok_chars["<"] = "---lt---"; - xml_bad_to_ok_chars["&"] = "---amp---"; - xml_bad_to_ok_chars[">"] = "---gt---"; - xml_bad_to_ok_chars["\""] = "---quot---"; - xml_bad_to_ok_chars["\'"] = "---apos---"; - xml_bad_to_ok_chars[","] = "---comma---"; - xml_bad_to_ok_chars["."] = "---dot---"; + _xmlBadToOkChars = new Dictionary(); + _xmlBadToOkChars["<"] = "---lt---"; + _xmlBadToOkChars["&"] = "---amp---"; + _xmlBadToOkChars[">"] = "---gt---"; + _xmlBadToOkChars["\""] = "---quot---"; + _xmlBadToOkChars["\'"] = "---apos---"; + _xmlBadToOkChars[","] = "---comma---"; + _xmlBadToOkChars["."] = "---dot---"; - unique_layouts = new Dictionary>(); - flat_layout = new Dictionary(); - flat_layout_shortcuts = new Dictionary(); - client_layout = new Dictionary(); + _uniqueLayouts = new Dictionary>(); + _flatLayout = new Dictionary(); + _flatLayoutShortcuts = new Dictionary(); + _clientLayout = new Dictionary(); - ignoring_size_sync = new Stopwatch(); - ignoring_size_sync.Start(); + _ignoringSizeSync = new Stopwatch(); + _ignoringSizeSync.Start(); - InitializeComponent(); - init_options(); + InitializeComponent(); + init_options(); - // DispatcherTimer setup - _dispatcherTimer = new DispatcherTimer(); - _dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick); - _dispatcherTimer.Interval = new TimeSpan(0, 0, 1); - _dispatcherTimer.Start(); + // DispatcherTimer setup + _dispatcherTimer = new DispatcherTimer(); + _dispatcherTimer.Tick += dispatcherTimer_Tick; + _dispatcherTimer.Interval = new TimeSpan(0, 0, 1); + _dispatcherTimer.Start(); - is_initialized = true; + _isInitialized = true; - previews_check_listbox.DisplayMember = "Text"; + previews_check_listbox.DisplayMember = "Text"; - } + } - private void GlassForm_Load(object sender, EventArgs e) - { - refresh_thumbnails(); - } - - private void init_options() - { - this.Minimized += new EventHandler(MainForm_Minimized); + private void GlassForm_Load(object sender, EventArgs e) + { + refresh_thumbnails(); + } + + private void init_options() + { + this.Minimized += MainForm_Minimized; - option_zoom_on_hover.Checked = Properties.Settings.Default.zoom_on_hover; - zoom_anchor_button_map = new Dictionary(); - zoom_anchor_button_map[zoom_anchor_t.NW] = option_zoom_anchor_NW; - zoom_anchor_button_map[zoom_anchor_t.N] = option_zoom_anchor_N; - zoom_anchor_button_map[zoom_anchor_t.NE] = option_zoom_anchor_NE; - zoom_anchor_button_map[zoom_anchor_t.W] = option_zoom_anchor_W; - zoom_anchor_button_map[zoom_anchor_t.C] = option_zoom_anchor_C; - zoom_anchor_button_map[zoom_anchor_t.E] = option_zoom_anchor_E; - zoom_anchor_button_map[zoom_anchor_t.SW] = option_zoom_anchor_SW; - zoom_anchor_button_map[zoom_anchor_t.S] = option_zoom_anchor_S; - zoom_anchor_button_map[zoom_anchor_t.SE] = option_zoom_anchor_SE; - zoom_anchor_button_map[(zoom_anchor_t)Properties.Settings.Default.zoom_anchor].Checked = true; - option_zoom_factor.Text = Properties.Settings.Default.zoom_amount.ToString(); - - option_always_on_top.Checked = Properties.Settings.Default.always_on_top; - option_hide_active.Checked = Properties.Settings.Default.hide_active; - option_hide_all_if_not_right_type.Checked = Properties.Settings.Default.hide_all; - - option_unique_layout.Checked = Properties.Settings.Default.unique_layout; - - option_sync_size.Checked = Properties.Settings.Default.sync_resize; - option_sync_size_x.Text = Properties.Settings.Default.sync_resize_x.ToString(); - option_sync_size_y.Text = Properties.Settings.Default.sync_resize_y.ToString(); - - option_show_thumbnail_frames.Checked = Properties.Settings.Default.show_thumb_frames; - - option_show_overlay.Checked = Properties.Settings.Default.show_overlay; - - option_track_client_windows.Checked = Properties.Settings.Default.track_client_windows; - - option_minToTray.Checked = Properties.Settings.Default.minimizeToTray; - - // disable/enable zoom suboptions - option_zoom_factor.Enabled = Properties.Settings.Default.zoom_on_hover; - foreach (var kv in zoom_anchor_button_map) - { - kv.Value.Enabled = Properties.Settings.Default.zoom_on_hover; - } - - opacity_bar.Value = Math.Min(100, (int)(100.0 * Properties.Settings.Default.opacity)); - - load_layout(); - } - - - private void spawn_and_kill_previews() - { - if (!is_initialized) { return; } - - Process[] processes = Process.GetProcessesByName("ExeFile"); - List processHandles = new List(); - - // pop new previews - - foreach (Process process in processes) - { - processHandles.Add(process.MainWindowHandle); - - Size sync_size = new Size(); - sync_size.Width = (int)Properties.Settings.Default.sync_resize_x; - sync_size.Height = (int)Properties.Settings.Default.sync_resize_y; - - if (!_previews.ContainsKey(process.MainWindowHandle) && process.MainWindowTitle != "") - { - _previews[process.MainWindowHandle] = new Preview(process.MainWindowHandle, "...", this, sync_size); - _previews[process.MainWindowHandle].set_render_area_size(sync_size); - - // apply more thumbnail specific options - _previews[process.MainWindowHandle].MakeTopMost(Properties.Settings.Default.always_on_top); - set_thumbnail_frame_style(_previews[process.MainWindowHandle], Properties.Settings.Default.show_thumb_frames); - - // add a preview also - previews_check_listbox.BeginUpdate(); - previews_check_listbox.Items.Add(_previews[process.MainWindowHandle]); - previews_check_listbox.EndUpdate(); - - refresh_client_window_locations(process); - } - - else if (_previews.ContainsKey(process.MainWindowHandle) && process.MainWindowTitle != _previews[process.MainWindowHandle].Text) //or update the preview titles - { - _previews[process.MainWindowHandle].SetLabel(process.MainWindowTitle); - string key = _previews[process.MainWindowHandle].Text; - string value; - if (flat_layout_shortcuts.TryGetValue(key, out value)) - { - _previews[process.MainWindowHandle].registerShortcut(value); - } - refresh_client_window_locations(process); - } - - if (process.MainWindowHandle == DwmApiNativeMethods.GetForegroundWindow()) - { - _activeClientHandle = process.MainWindowHandle; - _activeClientTitle = process.MainWindowTitle; - } - - } - - // clean up old previews - List to_be_pruned = new List(); - foreach (IntPtr processHandle in _previews.Keys) - { - if (!(processHandles.Contains(processHandle))) - { - to_be_pruned.Add(processHandle); - } - } - - foreach (IntPtr processHandle in to_be_pruned) - { - previews_check_listbox.BeginUpdate(); - previews_check_listbox.Items.Remove(_previews[processHandle]); - previews_check_listbox.EndUpdate(); - - _previews[processHandle].overlay.Close(); - _previews[processHandle].Close(); - _previews.Remove(processHandle); - } - - previews_check_listbox.Update(); - - } - - private void refresh_client_window_locations(Process process) - { - if (Properties.Settings.Default.track_client_windows && client_layout.ContainsKey(process.MainWindowTitle)) - { - MoveWindow( - process.MainWindowHandle, - client_layout[process.MainWindowTitle].X, - client_layout[process.MainWindowTitle].Y, - client_layout[process.MainWindowTitle].Width, - client_layout[process.MainWindowTitle].Height, - true); - } - } - - - private string remove_nonconform_xml_characters(string entry) - { - foreach (var kv in xml_bad_to_ok_chars) - { - entry = entry.Replace(kv.Key, kv.Value); - } - return entry; - } - - private string restore_nonconform_xml_characters(string entry) - { - foreach (var kv in xml_bad_to_ok_chars) - { - entry = entry.Replace(kv.Value, kv.Key); - } - return entry; - } - - private XElement MakeXElement(string input) - { - string clean = remove_nonconform_xml_characters(input).Replace(" ", "_"); - return new XElement(clean); - } - - private string ParseXElement(XElement input) - { - return restore_nonconform_xml_characters(input.Name.ToString()).Replace("_", " "); - } - - private void load_layout() - { - if (File.Exists("layout.xml")) - { - XElement rootElement = XElement.Load("layout.xml"); - foreach (var el in rootElement.Elements()) - { - Dictionary inner = new Dictionary(); - foreach (var inner_el in el.Elements()) - { - inner[ParseXElement(inner_el)] = new Point(Convert.ToInt32(inner_el.Element("x").Value), Convert.ToInt32(inner_el.Element("y").Value)); - } - unique_layouts[ParseXElement(el)] = inner; - } - } - - if (File.Exists("flat_layout.xml")) - { - XElement rootElement = XElement.Load("flat_layout.xml"); - foreach (var el in rootElement.Elements()) - { - flat_layout[ParseXElement(el)] = new Point(Convert.ToInt32(el.Element("x").Value), Convert.ToInt32(el.Element("y").Value)); - flat_layout_shortcuts[ParseXElement(el)] = ""; - - if (el.Element("shortcut") != null) - { - flat_layout_shortcuts[ParseXElement(el)] = el.Element("shortcut").Value; - } - } - } - - if (File.Exists("client_layout.xml")) - { - XElement rootElement = XElement.Load("client_layout.xml"); - foreach (var el in rootElement.Elements()) - { - ClientLocation clientLocation = new ClientLocation(); - clientLocation.X = Convert.ToInt32(el.Element("x").Value); - clientLocation.Y = Convert.ToInt32(el.Element("y").Value); - clientLocation.Width = Convert.ToInt32(el.Element("width").Value); - clientLocation.Height = Convert.ToInt32(el.Element("height").Value); - - client_layout[ParseXElement(el)] = clientLocation; - } - } - } - - private void store_layout() - { - XElement el = new XElement("layouts"); - foreach (var client in unique_layouts.Keys) - { - if (client == "") - { - continue; - } - XElement layout = MakeXElement(client); - foreach (var thumbnail_ in unique_layouts[client]) - { - String thumbnail = thumbnail_.Key; - if (thumbnail == "" || thumbnail == "...") - { - continue; - } - XElement position = MakeXElement(thumbnail); - position.Add(new XElement("x", thumbnail_.Value.X)); - position.Add(new XElement("y", thumbnail_.Value.Y)); - layout.Add(position); - } - el.Add(layout); - } - - el.Save("layout.xml"); - - XElement el2 = new XElement("flat_layout"); - foreach (var clientKV in flat_layout) - { - if (clientKV.Key == "" || clientKV.Key == "...") - { - continue; - } - XElement layout = MakeXElement(clientKV.Key); - layout.Add(new XElement("x", clientKV.Value.X)); - layout.Add(new XElement("y", clientKV.Value.Y)); - - string shortcut; - if (flat_layout_shortcuts.TryGetValue(clientKV.Key, out shortcut)) - { - layout.Add(new XElement("shortcut", shortcut)); - } - el2.Add(layout); - } - - el2.Save("flat_layout.xml"); - - XElement el3 = new XElement("client_layout"); - foreach (var clientKV in client_layout) - { - if (clientKV.Key == "" || clientKV.Key == "...") - { - continue; - } - XElement layout = MakeXElement(clientKV.Key); - layout.Add(new XElement("x", clientKV.Value.X)); - layout.Add(new XElement("y", clientKV.Value.Y)); - layout.Add(new XElement("width", clientKV.Value.Width)); - layout.Add(new XElement("height", clientKV.Value.Height)); - el3.Add(layout); - } - - el3.Save("client_layout.xml"); - } - - private void handle_unique_layout(Preview preview, String last_known_active_window) - { - Dictionary layout; - if (unique_layouts.TryGetValue(last_known_active_window, out layout)) - { - Point new_loc; - if (Properties.Settings.Default.unique_layout && layout.TryGetValue(preview.Text, out new_loc)) - { - preview.doMove(new_loc); - } - else - { - // create inner dict - layout[preview.Text] = preview.Location; - } - } - else if (last_known_active_window != "") - { - // create outer dict - unique_layouts[last_known_active_window] = new Dictionary(); - unique_layouts[last_known_active_window][preview.Text] = preview.Location; - } - } - - - private void update_client_locations() - { - Process[] processes = Process.GetProcessesByName("ExeFile"); - List processHandles = new List(); - - foreach (Process process in processes) - { - Rect rect = new Rect(); - GetWindowRect(process.MainWindowHandle, out rect); - - int left = Math.Abs(rect.Left); - int right = Math.Abs(rect.Right); - int client_width = Math.Abs(left - right); - - int top = Math.Abs(rect.Top); - int bottom = Math.Abs(rect.Bottom); - int client_height = Math.Abs(top - bottom); - - ClientLocation clientLocation = new ClientLocation(); - clientLocation.X = rect.Left; - clientLocation.Y = rect.Top; - clientLocation.Width = client_width; - clientLocation.Height = client_height; - - - client_layout[process.MainWindowTitle] = clientLocation; - } - } - - - public void preview_did_switch() - { - update_client_locations(); - store_layout(); //todo: check if it actually changed ... - foreach (KeyValuePair entry in _previews) - { - entry.Value.MakeTopMost(Properties.Settings.Default.always_on_top); - //makes the PreviewOverlay topmost - entry.Value.overlay.makeTopMost(); - } - } - - - private void handle_flat_layout(Preview preview) - { - Point layout; - if (flat_layout.TryGetValue(preview.Text, out layout)) - { - preview.doMove(layout); - } - else if (preview.Text != "") - { - flat_layout[preview.Text] = preview.Location; - } - } - - private bool window_is_preview_or_client(IntPtr window) - { - bool active_window_is_right_type = false; - foreach (KeyValuePair entry in _previews) - { - if (entry.Key == window || entry.Value.Handle == window || this.Handle == window || entry.Value.overlay.Handle == window) - { - active_window_is_right_type = true; - } - } - return active_window_is_right_type; - } - - - private void refresh_thumbnails() - { - - IntPtr active_window = DwmApiNativeMethods.GetForegroundWindow(); - - // hide, show, resize and move - foreach (KeyValuePair entry in _previews) - { - if (!window_is_preview_or_client(active_window) && Properties.Settings.Default.hide_all) - { - entry.Value.Hide(); - } - else if (entry.Key == _activeClientHandle && Properties.Settings.Default.hide_active) - { - entry.Value.Hide(); - } - else - { - entry.Value.Show(); - if (Properties.Settings.Default.unique_layout) - { - handle_unique_layout(entry.Value, _activeClientTitle); - } - else - { - handle_flat_layout(entry.Value); - } - } - entry.Value.hover_zoom = Properties.Settings.Default.zoom_on_hover; - entry.Value.show_overlay = Properties.Settings.Default.show_overlay; - //makes the PreviewOverlay TopMost - entry.Value.overlay.makeTopMost(); - if (!entry.Value.is_hovered_over) - { - entry.Value.Opacity = Properties.Settings.Default.opacity; - } - } - - DwmApiNativeMethods.DwmIsCompositionEnabled(); - } - - - public void syncronize_preview_size(Size sync_size) - { - if (!is_initialized) { return; } - - if (Properties.Settings.Default.sync_resize && - Properties.Settings.Default.show_thumb_frames && - ignoring_size_sync.ElapsedMilliseconds > 500) - { - ignoring_size_sync.Stop(); - - option_sync_size_x.Text = sync_size.Width.ToString(); - option_sync_size_y.Text = sync_size.Height.ToString(); - - foreach (KeyValuePair entry in _previews) - { - if (entry.Value.Handle != DwmApiNativeMethods.GetForegroundWindow()) - { - entry.Value.set_render_area_size(sync_size); - } - } - - } - - } - - - public void register_preview_position(String preview_title, Point position) - { - - if (Properties.Settings.Default.unique_layout) - { - Dictionary layout; - if (unique_layouts.TryGetValue(_activeClientTitle, out layout)) - { - layout[preview_title] = position; - } - else if (_activeClientTitle == "") - { - unique_layouts[_activeClientTitle] = new Dictionary(); - unique_layouts[_activeClientTitle][preview_title] = position; - } - } - else - { - flat_layout[preview_title] = position; - } - - } - - - private void dispatcherTimer_Tick(object sender, EventArgs e) - { - spawn_and_kill_previews(); - refresh_thumbnails(); - if (ignoring_size_sync.ElapsedMilliseconds > 500) { ignoring_size_sync.Stop(); }; - - if (DwmApiNativeMethods.DwmIsCompositionEnabled()) - { - aero_status_label.Text = "AERO is ON"; - aero_status_label.ForeColor = Color.Black; - } - else - { - aero_status_label.Text = "AERO is OFF"; - aero_status_label.ForeColor = Color.Red; - } - - } - - - private void option_hide_all_if_noneve_CheckedChanged(object sender, EventArgs e) - { - Properties.Settings.Default.hide_all = option_hide_all_if_not_right_type.Checked; - Properties.Settings.Default.Save(); - refresh_thumbnails(); - } - - - private void option_unique_layout_CheckedChanged(object sender, EventArgs e) - { - Properties.Settings.Default.unique_layout = option_unique_layout.Checked; - Properties.Settings.Default.Save(); - refresh_thumbnails(); - } - - - private void option_hide_active_CheckedChanged(object sender, EventArgs e) - { - Properties.Settings.Default.hide_active = option_hide_active.Checked; - Properties.Settings.Default.Save(); - refresh_thumbnails(); - } - - - private void option_sync_size_CheckedChanged(object sender, EventArgs e) - { - Properties.Settings.Default.sync_resize = option_sync_size.Checked; - Properties.Settings.Default.Save(); - refresh_thumbnails(); - } - - - private void parse_size_entry() - { - UInt32 x = 0, y = 0; - - try - { - y = Convert.ToUInt32(option_sync_size_y.Text); - x = Convert.ToUInt32(option_sync_size_x.Text); - } - catch (System.FormatException) - { - return; - } - - if (x < 64 || y < 64) - { - return; - } - - Properties.Settings.Default.sync_resize_y = y; - Properties.Settings.Default.sync_resize_x = x; - Properties.Settings.Default.Save(); - - // resize - syncronize_preview_size(new Size((int)Properties.Settings.Default.sync_resize_x, - (int)Properties.Settings.Default.sync_resize_y)); - } - - - private void option_sync_size_x_TextChanged(object sender, EventArgs e) - { - parse_size_entry(); - } - - - private void option_sync_size_y_TextChanged(object sender, EventArgs e) - { - parse_size_entry(); - } - - - private void option_always_on_top_CheckedChanged(object sender, EventArgs e) - { - Properties.Settings.Default.always_on_top = option_always_on_top.Checked; - Properties.Settings.Default.Save(); - refresh_thumbnails(); - } - - - void set_thumbnail_frame_style(Preview preview, bool show_frames) - { - if (show_frames) - { - preview.FormBorderStyle = FormBorderStyle.SizableToolWindow; - } - else - { - preview.FormBorderStyle = FormBorderStyle.None; - } - } - - private void option_show_thumbnail_frames_CheckedChanged(object sender, EventArgs e) - { - Properties.Settings.Default.show_thumb_frames = option_show_thumbnail_frames.Checked; - Properties.Settings.Default.Save(); - - if (Properties.Settings.Default.show_thumb_frames) - { - ignoring_size_sync.Stop(); - ignoring_size_sync.Reset(); - ignoring_size_sync.Start(); - } - - foreach (var thumbnail in _previews) - { - set_thumbnail_frame_style(thumbnail.Value, Properties.Settings.Default.show_thumb_frames); - } - - } - - - private void list_running_clients_SelectedIndexChanged(object sender, EventArgs e) { } - - - private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) - { - string url = "https://bitbucket.org/ulph/eve-o-preview-git"; - ProcessStartInfo sInfo = new ProcessStartInfo(new Uri(url).AbsoluteUri); - Process.Start(sInfo); - } - - - private void previewToyMainBindingSource_CurrentChanged(object sender, EventArgs e) - { - - } - - private void option_zoom_on_hover_CheckedChanged(object sender, EventArgs e) - { - Properties.Settings.Default.zoom_on_hover = option_zoom_on_hover.Checked; - Properties.Settings.Default.Save(); - refresh_thumbnails(); - option_zoom_factor.Enabled = Properties.Settings.Default.zoom_on_hover; - if (is_initialized) - { - foreach (var kv in zoom_anchor_button_map) - { - kv.Value.Enabled = Properties.Settings.Default.zoom_on_hover; - } - } - } - - private void option_show_overlay_CheckedChanged(object sender, EventArgs e) - { - Properties.Settings.Default.show_overlay = option_show_overlay.Checked; - Properties.Settings.Default.Save(); - refresh_thumbnails(); - } - - - private void handle_zoom_anchor_setting() - { - foreach (var kv in zoom_anchor_button_map) - { - if (kv.Value.Checked == true) - Properties.Settings.Default.zoom_anchor = (byte)kv.Key; - } - } - - private void option_zoom_anchor_X_CheckedChanged(object sender, EventArgs e) - { - handle_zoom_anchor_setting(); - Properties.Settings.Default.Save(); - } - - private void option_zoom_factor_TextChanged(object sender, EventArgs e) - { - try - { - float tmp = (float)Convert.ToDouble(option_zoom_factor.Text); - if (tmp < 1) - { - tmp = 1; - } - else if (tmp > 10) - { - tmp = 10; - } - Properties.Settings.Default.zoom_amount = tmp; - option_zoom_factor.Text = tmp.ToString(); - Properties.Settings.Default.Save(); - } - catch - { - // do naught - } - } - - private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e) - { - refresh_thumbnails(); - } - - private void checkedListBox1_SelectedIndexChanged2(object sender, EventArgs e) - { - System.Windows.Forms.ItemCheckEventArgs arg = (System.Windows.Forms.ItemCheckEventArgs)e; - ((Preview)this.previews_check_listbox.Items[arg.Index]).MakeHidden(arg.NewValue == System.Windows.Forms.CheckState.Checked); - refresh_thumbnails(); - } - - private void flowLayoutPanel1_Paint(object sender, PaintEventArgs e) - { - - } - - private void checkBox1_CheckedChanged(object sender, EventArgs e) - { - Properties.Settings.Default.track_client_windows = option_track_client_windows.Checked; - Properties.Settings.Default.Save(); - refresh_thumbnails(); - } - - - private void opacity_bar_Scroll(object sender, ScrollEventArgs e) - { - // fire off opacity change - Properties.Settings.Default.opacity = Math.Min((float)e.NewValue / 100.0f, 1.0f); - Properties.Settings.Default.Save(); - refresh_thumbnails(); - } - - - private void OnMinimized(EventArgs e) - { - if (Minimized != null && Properties.Settings.Default.minimizeToTray) - { - this.Hide(); - } - else if (Minimized != null && !Properties.Settings.Default.minimizeToTray) - { - Minimized(this, e); - } - } - - private void OnMaximized(EventArgs e) - { - if (Maximized != null) - { - Maximized(this, e); - } - } - - private void OnRestored(EventArgs e) - { - if (Restored != null) - { - Restored(this, e); - } - } - - protected override void WndProc(ref Message m) - { - switch (m.Msg) - { - case WM_SIZE: - switch (m.WParam.ToInt32()) - { - case SIZE_RESTORED: - OnRestored(EventArgs.Empty); - break; - case SIZE_MINIMIZED: - OnMinimized(EventArgs.Empty); - break; - case SIZE_MAXIMIZED: - OnMaximized(EventArgs.Empty); - break; - } - break; - default: - break; - } - base.WndProc(ref m); - } - - void MainForm_Minimized(object sender, EventArgs e) - { - // TODO: do something here - } - - private void option_minToTray_CheckedChanged(object sender, EventArgs e) - { - Properties.Settings.Default.minimizeToTray = option_minToTray.Checked; - Properties.Settings.Default.Save(); - } - - private void exitToolStripMenuItem_Click(object sender, EventArgs e) - { - Application.Exit(); - } - - private void restoreToolStripMenuItem_Click(object sender, EventArgs e) - { - if (!this.Visible) - { - this.Show(); - } - else if (Restored != null) - { - Restored(this, e); - } - else - { - this.BringToFront(); - } - } - - private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e) - { - if (!this.Visible) - { - this.Show(); - } - else if (Restored != null) - { - Restored(this, e); - } - else - { - this.BringToFront(); - } - } - } + option_zoom_on_hover.Checked = Properties.Settings.Default.zoom_on_hover; + _zoomAnchorButtonMap = new Dictionary(); + _zoomAnchorButtonMap[ZoomAnchor.NW] = option_zoom_anchor_NW; + _zoomAnchorButtonMap[ZoomAnchor.N] = option_zoom_anchor_N; + _zoomAnchorButtonMap[ZoomAnchor.NE] = option_zoom_anchor_NE; + _zoomAnchorButtonMap[ZoomAnchor.W] = option_zoom_anchor_W; + _zoomAnchorButtonMap[ZoomAnchor.C] = option_zoom_anchor_C; + _zoomAnchorButtonMap[ZoomAnchor.E] = option_zoom_anchor_E; + _zoomAnchorButtonMap[ZoomAnchor.SW] = option_zoom_anchor_SW; + _zoomAnchorButtonMap[ZoomAnchor.S] = option_zoom_anchor_S; + _zoomAnchorButtonMap[ZoomAnchor.SE] = option_zoom_anchor_SE; + _zoomAnchorButtonMap[(ZoomAnchor)Properties.Settings.Default.zoom_anchor].Checked = true; + option_zoom_factor.Text = Properties.Settings.Default.zoom_amount.ToString(CultureInfo.InvariantCulture); + + option_always_on_top.Checked = Properties.Settings.Default.always_on_top; + option_hide_active.Checked = Properties.Settings.Default.hide_active; + option_hide_all_if_not_right_type.Checked = Properties.Settings.Default.hide_all; + + option_unique_layout.Checked = Properties.Settings.Default.unique_layout; + + option_sync_size.Checked = Properties.Settings.Default.sync_resize; + option_sync_size_x.Text = Properties.Settings.Default.sync_resize_x.ToString(); + option_sync_size_y.Text = Properties.Settings.Default.sync_resize_y.ToString(); + + option_show_thumbnail_frames.Checked = Properties.Settings.Default.show_thumb_frames; + + option_show_overlay.Checked = Properties.Settings.Default.show_overlay; + + option_track_client_windows.Checked = Properties.Settings.Default.track_client_windows; + + option_minToTray.Checked = Properties.Settings.Default.minimizeToTray; + + // disable/enable zoom suboptions + option_zoom_factor.Enabled = Properties.Settings.Default.zoom_on_hover; + foreach (var kv in _zoomAnchorButtonMap) + { + kv.Value.Enabled = Properties.Settings.Default.zoom_on_hover; + } + + opacity_bar.Value = Math.Min(100, (int)(100.0 * Properties.Settings.Default.opacity)); + + load_layout(); + } + + + private void spawn_and_kill_previews() + { + if (!_isInitialized) { return; } + + Process[] processes = Process.GetProcessesByName("ExeFile"); + List processHandles = new List(); + + // pop new previews + + foreach (Process process in processes) + { + processHandles.Add(process.MainWindowHandle); + + Size sync_size = new Size(); + sync_size.Width = (int)Properties.Settings.Default.sync_resize_x; + sync_size.Height = (int)Properties.Settings.Default.sync_resize_y; + + if (!_previews.ContainsKey(process.MainWindowHandle) && process.MainWindowTitle != "") + { + _previews[process.MainWindowHandle] = new Preview(process.MainWindowHandle, "...", this, sync_size); + _previews[process.MainWindowHandle].set_render_area_size(sync_size);// TODO Remove + + // apply more thumbnail specific options + _previews[process.MainWindowHandle].MakeTopMost(Properties.Settings.Default.always_on_top); + set_thumbnail_frame_style(_previews[process.MainWindowHandle], Properties.Settings.Default.show_thumb_frames); + + // add a preview also + previews_check_listbox.BeginUpdate(); + previews_check_listbox.Items.Add(_previews[process.MainWindowHandle]); + previews_check_listbox.EndUpdate(); + + refresh_client_window_locations(process); + } + + else if (_previews.ContainsKey(process.MainWindowHandle) && process.MainWindowTitle != _previews[process.MainWindowHandle].Text) //or update the preview titles + { + _previews[process.MainWindowHandle].SetLabel(process.MainWindowTitle); + string key = _previews[process.MainWindowHandle].Text; + string value; + if (_flatLayoutShortcuts.TryGetValue(key, out value)) + { + _previews[process.MainWindowHandle].registerShortcut(value); + } + refresh_client_window_locations(process); + } + + if (process.MainWindowHandle == DwmApiNativeMethods.GetForegroundWindow()) + { + _activeClientHandle = process.MainWindowHandle; + _activeClientTitle = process.MainWindowTitle; + } + + } + + // clean up old previews + List to_be_pruned = new List(); + foreach (IntPtr processHandle in _previews.Keys) + { + if (!(processHandles.Contains(processHandle))) + { + to_be_pruned.Add(processHandle); + } + } + + foreach (IntPtr processHandle in to_be_pruned) + { + previews_check_listbox.BeginUpdate(); + previews_check_listbox.Items.Remove(_previews[processHandle]); + previews_check_listbox.EndUpdate(); + + _previews[processHandle].overlay.Close(); + _previews[processHandle].Close(); + _previews.Remove(processHandle); + } + + previews_check_listbox.Update(); + + } + + private void refresh_client_window_locations(Process process) + { + if (Properties.Settings.Default.track_client_windows && _clientLayout.ContainsKey(process.MainWindowTitle)) + { + GuiNativeMethods.MoveWindow(process.MainWindowHandle, _clientLayout[process.MainWindowTitle].X, + _clientLayout[process.MainWindowTitle].Y, _clientLayout[process.MainWindowTitle].Width, + _clientLayout[process.MainWindowTitle].Height, true); + } + } + + + private string remove_nonconform_xml_characters(string entry) + { + foreach (var kv in _xmlBadToOkChars) + { + entry = entry.Replace(kv.Key, kv.Value); + } + return entry; + } + + private string restore_nonconform_xml_characters(string entry) + { + foreach (var kv in _xmlBadToOkChars) + { + entry = entry.Replace(kv.Value, kv.Key); + } + return entry; + } + + private XElement MakeXElement(string input) + { + string clean = remove_nonconform_xml_characters(input).Replace(" ", "_"); + return new XElement(clean); + } + + private string ParseXElement(XElement input) + { + return restore_nonconform_xml_characters(input.Name.ToString()).Replace("_", " "); + } + + private void load_layout() + { + if (File.Exists("layout.xml")) + { + XElement rootElement = XElement.Load("layout.xml"); + foreach (var el in rootElement.Elements()) + { + Dictionary inner = new Dictionary(); + foreach (var inner_el in el.Elements()) + { + inner[ParseXElement(inner_el)] = new Point(Convert.ToInt32(inner_el.Element("x")?.Value), Convert.ToInt32(inner_el.Element("y")?.Value)); + } + _uniqueLayouts[ParseXElement(el)] = inner; + } + } + + if (File.Exists("flat_layout.xml")) + { + XElement rootElement = XElement.Load("flat_layout.xml"); + foreach (var el in rootElement.Elements()) + { + _flatLayout[ParseXElement(el)] = new Point(Convert.ToInt32(el.Element("x").Value), Convert.ToInt32(el.Element("y").Value)); + _flatLayoutShortcuts[ParseXElement(el)] = ""; + + if (el.Element("shortcut") != null) + { + _flatLayoutShortcuts[ParseXElement(el)] = el.Element("shortcut").Value; + } + } + } + + if (File.Exists("client_layout.xml")) + { + XElement rootElement = XElement.Load("client_layout.xml"); + foreach (var el in rootElement.Elements()) + { + ClientLocation clientLocation = new ClientLocation(); + clientLocation.X = Convert.ToInt32(el.Element("x").Value); + clientLocation.Y = Convert.ToInt32(el.Element("y").Value); + clientLocation.Width = Convert.ToInt32(el.Element("width").Value); + clientLocation.Height = Convert.ToInt32(el.Element("height").Value); + + _clientLayout[ParseXElement(el)] = clientLocation; + } + } + } + + private void store_layout() + { + XElement el = new XElement("layouts"); + foreach (var client in _uniqueLayouts.Keys) + { + if (client == "") + { + continue; + } + XElement layout = MakeXElement(client); + foreach (var thumbnail_ in _uniqueLayouts[client]) + { + string thumbnail = thumbnail_.Key; + if (thumbnail == "" || thumbnail == "...") + { + continue; + } + XElement position = MakeXElement(thumbnail); + position.Add(new XElement("x", thumbnail_.Value.X)); + position.Add(new XElement("y", thumbnail_.Value.Y)); + layout.Add(position); + } + el.Add(layout); + } + + el.Save("layout.xml"); + + XElement el2 = new XElement("flat_layout"); + foreach (var clientKV in _flatLayout) + { + if (clientKV.Key == "" || clientKV.Key == "...") + { + continue; + } + XElement layout = MakeXElement(clientKV.Key); + layout.Add(new XElement("x", clientKV.Value.X)); + layout.Add(new XElement("y", clientKV.Value.Y)); + + string shortcut; + if (_flatLayoutShortcuts.TryGetValue(clientKV.Key, out shortcut)) + { + layout.Add(new XElement("shortcut", shortcut)); + } + el2.Add(layout); + } + + el2.Save("flat_layout.xml"); + + XElement el3 = new XElement("client_layout"); + foreach (var clientKV in _clientLayout) + { + if (clientKV.Key == "" || clientKV.Key == "...") + { + continue; + } + XElement layout = MakeXElement(clientKV.Key); + layout.Add(new XElement("x", clientKV.Value.X)); + layout.Add(new XElement("y", clientKV.Value.Y)); + layout.Add(new XElement("width", clientKV.Value.Width)); + layout.Add(new XElement("height", clientKV.Value.Height)); + el3.Add(layout); + } + + el3.Save("client_layout.xml"); + } + + private void handle_unique_layout(Preview preview, string last_known_active_window) + { + Dictionary layout; + if (_uniqueLayouts.TryGetValue(last_known_active_window, out layout)) + { + Point new_loc; + if (Properties.Settings.Default.unique_layout && layout.TryGetValue(preview.Text, out new_loc)) + { + preview.doMove(new_loc); + } + else + { + // create inner dict + layout[preview.Text] = preview.Location; + } + } + else if (last_known_active_window != "") + { + // create outer dict + _uniqueLayouts[last_known_active_window] = new Dictionary(); + _uniqueLayouts[last_known_active_window][preview.Text] = preview.Location; + } + } + + + private void update_client_locations() + { + Process[] processes = Process.GetProcessesByName("ExeFile"); + List processHandles = new List(); + + foreach (Process process in processes) + { + RECT rect = new RECT(); + GuiNativeMethods.GetWindowRect(process.MainWindowHandle, out rect); + + int left = Math.Abs(rect.Left); + int right = Math.Abs(rect.Right); + int client_width = Math.Abs(left - right); + + int top = Math.Abs(rect.Top); + int bottom = Math.Abs(rect.Bottom); + int client_height = Math.Abs(top - bottom); + + ClientLocation clientLocation = new ClientLocation(); + clientLocation.X = rect.Left; + clientLocation.Y = rect.Top; + clientLocation.Width = client_width; + clientLocation.Height = client_height; + + + _clientLayout[process.MainWindowTitle] = clientLocation; + } + } + + + public void preview_did_switch() + { + update_client_locations(); + store_layout(); //todo: check if it actually changed ... + foreach (KeyValuePair entry in _previews) + { + entry.Value.MakeTopMost(Properties.Settings.Default.always_on_top); + //makes the PreviewOverlay topmost + entry.Value.overlay.MakeTopMost(); + } + } + + + private void handle_flat_layout(Preview preview) + { + Point layout; + if (_flatLayout.TryGetValue(preview.Text, out layout)) + { + preview.doMove(layout); + } + else if (preview.Text != "") + { + _flatLayout[preview.Text] = preview.Location; + } + } + + private bool window_is_preview_or_client(IntPtr window) + { + bool active_window_is_right_type = false; + foreach (KeyValuePair entry in _previews) + { + if (entry.Key == window || entry.Value.Handle == window || this.Handle == window || entry.Value.overlay.Handle == window) + { + active_window_is_right_type = true; + } + } + return active_window_is_right_type; + } + + + private void refresh_thumbnails() + { + + IntPtr active_window = DwmApiNativeMethods.GetForegroundWindow(); + + // hide, show, resize and move + foreach (KeyValuePair entry in _previews) + { + if (!window_is_preview_or_client(active_window) && Properties.Settings.Default.hide_all) + { + entry.Value.Hide(); + } + else if (entry.Key == _activeClientHandle && Properties.Settings.Default.hide_active) + { + entry.Value.Hide(); + } + else + { + entry.Value.Show(); + if (Properties.Settings.Default.unique_layout) + { + handle_unique_layout(entry.Value, _activeClientTitle); + } + else + { + handle_flat_layout(entry.Value); + } + } + entry.Value.hover_zoom = Properties.Settings.Default.zoom_on_hover; + entry.Value.show_overlay = Properties.Settings.Default.show_overlay; + //makes the PreviewOverlay TopMost + entry.Value.overlay.MakeTopMost(); + if (!entry.Value.is_hovered_over) + { + entry.Value.Opacity = Properties.Settings.Default.opacity; + } + } + + DwmApiNativeMethods.DwmIsCompositionEnabled(); + } + + + public void syncronize_preview_size(Size sync_size) + { + if (!_isInitialized) { return; } + + if (Properties.Settings.Default.sync_resize && + Properties.Settings.Default.show_thumb_frames && + _ignoringSizeSync.ElapsedMilliseconds > 500) + { + _ignoringSizeSync.Stop(); + + option_sync_size_x.Text = sync_size.Width.ToString(); + option_sync_size_y.Text = sync_size.Height.ToString(); + + foreach (KeyValuePair entry in _previews) + { + if (entry.Value.Handle != DwmApiNativeMethods.GetForegroundWindow()) + { + entry.Value.set_render_area_size(sync_size); + } + } + + } + + } + + + public void register_preview_position(string preview_title, Point position) + { + + if (Properties.Settings.Default.unique_layout) + { + Dictionary layout; + if (_uniqueLayouts.TryGetValue(_activeClientTitle, out layout)) + { + layout[preview_title] = position; + } + else if (_activeClientTitle == "") + { + _uniqueLayouts[_activeClientTitle] = new Dictionary(); + _uniqueLayouts[_activeClientTitle][preview_title] = position; + } + } + else + { + _flatLayout[preview_title] = position; + } + + } + + + private void dispatcherTimer_Tick(object sender, EventArgs e) + { + spawn_and_kill_previews(); + refresh_thumbnails(); + if (_ignoringSizeSync.ElapsedMilliseconds > 500) { _ignoringSizeSync.Stop(); }; + + if (DwmApiNativeMethods.DwmIsCompositionEnabled()) + { + aero_status_label.Text = "AERO is ON"; + aero_status_label.ForeColor = Color.Black; + } + else + { + aero_status_label.Text = "AERO is OFF"; + aero_status_label.ForeColor = Color.Red; + } + + } + + + private void option_hide_all_if_noneve_CheckedChanged(object sender, EventArgs e) + { + Properties.Settings.Default.hide_all = option_hide_all_if_not_right_type.Checked; + Properties.Settings.Default.Save(); + refresh_thumbnails(); + } + + + private void option_unique_layout_CheckedChanged(object sender, EventArgs e) + { + Properties.Settings.Default.unique_layout = option_unique_layout.Checked; + Properties.Settings.Default.Save(); + refresh_thumbnails(); + } + + + private void option_hide_active_CheckedChanged(object sender, EventArgs e) + { + Properties.Settings.Default.hide_active = option_hide_active.Checked; + Properties.Settings.Default.Save(); + refresh_thumbnails(); + } + + + private void option_sync_size_CheckedChanged(object sender, EventArgs e) + { + Properties.Settings.Default.sync_resize = option_sync_size.Checked; + Properties.Settings.Default.Save(); + refresh_thumbnails(); + } + + + private void parse_size_entry() + { + UInt32 x = 0, y = 0; + + try + { + y = Convert.ToUInt32(option_sync_size_y.Text); + x = Convert.ToUInt32(option_sync_size_x.Text); + } + catch (System.FormatException) + { + return; + } + + if (x < 64 || y < 64) + { + return; + } + + Properties.Settings.Default.sync_resize_y = y; + Properties.Settings.Default.sync_resize_x = x; + Properties.Settings.Default.Save(); + + // resize + syncronize_preview_size(new Size((int)Properties.Settings.Default.sync_resize_x, + (int)Properties.Settings.Default.sync_resize_y)); + } + + + private void option_sync_size_x_TextChanged(object sender, EventArgs e) + { + parse_size_entry(); + } + + + private void option_sync_size_y_TextChanged(object sender, EventArgs e) + { + parse_size_entry(); + } + + + private void option_always_on_top_CheckedChanged(object sender, EventArgs e) + { + Properties.Settings.Default.always_on_top = option_always_on_top.Checked; + Properties.Settings.Default.Save(); + refresh_thumbnails(); + } + + + void set_thumbnail_frame_style(Preview preview, bool show_frames) + { + if (show_frames) + { + preview.FormBorderStyle = FormBorderStyle.SizableToolWindow; + } + else + { + preview.FormBorderStyle = FormBorderStyle.None; + } + } + + private void option_show_thumbnail_frames_CheckedChanged(object sender, EventArgs e) + { + Properties.Settings.Default.show_thumb_frames = option_show_thumbnail_frames.Checked; + Properties.Settings.Default.Save(); + + if (Properties.Settings.Default.show_thumb_frames) + { + _ignoringSizeSync.Stop(); + _ignoringSizeSync.Reset(); + _ignoringSizeSync.Start(); + } + + foreach (var thumbnail in _previews) + { + set_thumbnail_frame_style(thumbnail.Value, Properties.Settings.Default.show_thumb_frames); + } + + } + + + private void list_running_clients_SelectedIndexChanged(object sender, EventArgs e) { } + + + private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + string url = "https://bitbucket.org/ulph/eve-o-preview-git"; + ProcessStartInfo sInfo = new ProcessStartInfo(new Uri(url).AbsoluteUri); + Process.Start(sInfo); + } + + + private void previewToyMainBindingSource_CurrentChanged(object sender, EventArgs e) + { + + } + + private void option_zoom_on_hover_CheckedChanged(object sender, EventArgs e) + { + Properties.Settings.Default.zoom_on_hover = option_zoom_on_hover.Checked; + Properties.Settings.Default.Save(); + refresh_thumbnails(); + option_zoom_factor.Enabled = Properties.Settings.Default.zoom_on_hover; + if (_isInitialized) + { + foreach (var kv in _zoomAnchorButtonMap) + { + kv.Value.Enabled = Properties.Settings.Default.zoom_on_hover; + } + } + } + + private void option_show_overlay_CheckedChanged(object sender, EventArgs e) + { + Properties.Settings.Default.show_overlay = option_show_overlay.Checked; + Properties.Settings.Default.Save(); + refresh_thumbnails(); + } + + + private void handle_zoom_anchor_setting() + { + foreach (var kv in _zoomAnchorButtonMap) + { + if (kv.Value.Checked == true) + Properties.Settings.Default.zoom_anchor = (byte)kv.Key; + } + } + + private void option_zoom_anchor_X_CheckedChanged(object sender, EventArgs e) + { + handle_zoom_anchor_setting(); + Properties.Settings.Default.Save(); + } + + private void option_zoom_factor_TextChanged(object sender, EventArgs e) + { + try + { + float tmp = (float)Convert.ToDouble(option_zoom_factor.Text); + if (tmp < 1) + { + tmp = 1; + } + else if (tmp > 10) + { + tmp = 10; + } + Properties.Settings.Default.zoom_amount = tmp; + option_zoom_factor.Text = tmp.ToString(); + Properties.Settings.Default.Save(); + } + catch + { + // do naught + } + } + + private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e) + { + refresh_thumbnails(); + } + + private void checkedListBox1_SelectedIndexChanged2(object sender, EventArgs e) + { + System.Windows.Forms.ItemCheckEventArgs arg = (System.Windows.Forms.ItemCheckEventArgs)e; + ((Preview)this.previews_check_listbox.Items[arg.Index]).MakeHidden(arg.NewValue == System.Windows.Forms.CheckState.Checked); + refresh_thumbnails(); + } + + private void flowLayoutPanel1_Paint(object sender, PaintEventArgs e) + { + + } + + private void checkBox1_CheckedChanged(object sender, EventArgs e) + { + Properties.Settings.Default.track_client_windows = option_track_client_windows.Checked; + Properties.Settings.Default.Save(); + refresh_thumbnails(); + } + + + private void opacity_bar_Scroll(object sender, ScrollEventArgs e) + { + // fire off opacity change + Properties.Settings.Default.opacity = Math.Min((float)e.NewValue / 100.0f, 1.0f); + Properties.Settings.Default.Save(); + refresh_thumbnails(); + } + + + private void OnMinimized(EventArgs e) + { + if (Minimized != null && Properties.Settings.Default.minimizeToTray) + { + this.Hide(); + } + else if (Minimized != null && !Properties.Settings.Default.minimizeToTray) + { + Minimized(this, e); + } + } + + private void OnMaximized(EventArgs e) + { + if (Maximized != null) + { + Maximized(this, e); + } + } + + private void OnRestored(EventArgs e) + { + Restored?.Invoke(this, e); + } + + protected override void WndProc(ref Message m) + { + switch (m.Msg) + { + case GuiNativeMethods.WM_SIZE: + switch (m.WParam.ToInt32()) + { + case GuiNativeMethods.SIZE_RESTORED: + OnRestored(EventArgs.Empty); + break; + case GuiNativeMethods.SIZE_MINIMIZED: + OnMinimized(EventArgs.Empty); + break; + case GuiNativeMethods.SIZE_MAXIMIZED: + OnMaximized(EventArgs.Empty); + break; + } + break; + } + + base.WndProc(ref m); + } + + void MainForm_Minimized(object sender, EventArgs e) + { + // TODO: do something here + } + + private void option_minToTray_CheckedChanged(object sender, EventArgs e) + { + Properties.Settings.Default.minimizeToTray = option_minToTray.Checked; + Properties.Settings.Default.Save(); + } + + private void exitToolStripMenuItem_Click(object sender, EventArgs e) + { + Application.Exit(); + } + + private void restoreToolStripMenuItem_Click(object sender, EventArgs e) + { + if (!this.Visible) + { + this.Show(); + } + else if (Restored != null) + { + Restored(this, e); + } + else + { + this.BringToFront(); + } + } + + private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e) + { + if (!this.Visible) + { + this.Show(); + } + else if (Restored != null) + { + Restored(this, e); + } + else + { + this.BringToFront(); + } + } + } } \ No newline at end of file diff --git a/Eve-O-Preview/GUI/ZoomAnchor.cs b/Eve-O-Preview/GUI/ZoomAnchor.cs new file mode 100644 index 0000000..ebfcb97 --- /dev/null +++ b/Eve-O-Preview/GUI/ZoomAnchor.cs @@ -0,0 +1,15 @@ +namespace EveOPreview +{ + public enum ZoomAnchor + { + NW = 0, + N, + NE, + W, + C, + E, + SW, + S, + SE + } +} \ No newline at end of file diff --git a/Eve-O-Preview/Preview/Preview.Designer.cs b/Eve-O-Preview/Preview/Preview.Designer.cs index c6d52dc..9a83820 100644 --- a/Eve-O-Preview/Preview/Preview.Designer.cs +++ b/Eve-O-Preview/Preview/Preview.Designer.cs @@ -14,53 +14,53 @@ namespace EveOPreview /// private void InitializeComponent() { - this.render_area = new System.Windows.Forms.PictureBox(); - ((System.ComponentModel.ISupportInitialize)(this.render_area)).BeginInit(); - this.SuspendLayout(); - // - // render_area - // - this.render_area.BackColor = System.Drawing.Color.Transparent; - this.render_area.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.render_area.Cursor = System.Windows.Forms.Cursors.Hand; - this.render_area.Dock = System.Windows.Forms.DockStyle.Fill; - this.render_area.Location = new System.Drawing.Point(0, 0); - this.render_area.Margin = new System.Windows.Forms.Padding(0); - this.render_area.Name = "render_area"; - this.render_area.Size = new System.Drawing.Size(153, 89); - this.render_area.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; - this.render_area.TabIndex = 0; - this.render_area.TabStop = false; - this.render_area.MouseUp += new System.Windows.Forms.MouseEventHandler(this.render_area_Click); - // - // Preview - // - this.AccessibleRole = System.Windows.Forms.AccessibleRole.None; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(153, 89); - this.ControlBox = false; - this.Controls.Add(this.render_area); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(64, 64); - this.Name = "Preview"; - this.Opacity = 0.1D; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.Text = "Preview"; - this.TopMost = true; - this.Load += new System.EventHandler(this.Preview_Load); - ((System.ComponentModel.ISupportInitialize)(this.render_area)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); + this.RenderAreaPictureBox = new System.Windows.Forms.PictureBox(); + ((System.ComponentModel.ISupportInitialize)(this.RenderAreaPictureBox)).BeginInit(); + this.SuspendLayout(); + // + // RenderAreaPictureBox + // + this.RenderAreaPictureBox.BackColor = System.Drawing.Color.Transparent; + this.RenderAreaPictureBox.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; + this.RenderAreaPictureBox.Cursor = System.Windows.Forms.Cursors.Hand; + this.RenderAreaPictureBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.RenderAreaPictureBox.Location = new System.Drawing.Point(0, 0); + this.RenderAreaPictureBox.Margin = new System.Windows.Forms.Padding(0); + this.RenderAreaPictureBox.Name = "RenderAreaPictureBox"; + this.RenderAreaPictureBox.Size = new System.Drawing.Size(153, 89); + this.RenderAreaPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; + this.RenderAreaPictureBox.TabIndex = 0; + this.RenderAreaPictureBox.TabStop = false; + this.RenderAreaPictureBox.MouseUp += new System.Windows.Forms.MouseEventHandler(this.render_area_Click); + // + // Preview + // + this.AccessibleRole = System.Windows.Forms.AccessibleRole.None; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(153, 89); + this.ControlBox = false; + this.Controls.Add(this.RenderAreaPictureBox); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(64, 64); + this.Name = "Preview"; + this.Opacity = 0.1D; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.Text = "Preview"; + this.TopMost = true; + this.Load += new System.EventHandler(this.Preview_Load); + ((System.ComponentModel.ISupportInitialize)(this.RenderAreaPictureBox)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); } #endregion - private System.Windows.Forms.PictureBox render_area; + private System.Windows.Forms.PictureBox RenderAreaPictureBox; } diff --git a/Eve-O-Preview/Preview/Preview.cs b/Eve-O-Preview/Preview/Preview.cs index 53823b7..23806db 100644 --- a/Eve-O-Preview/Preview/Preview.cs +++ b/Eve-O-Preview/Preview/Preview.cs @@ -4,346 +4,342 @@ using System.Windows.Forms; namespace EveOPreview { - public partial class Preview : Form - { - public bool show_overlay = true; - public bool hover_zoom = true; - public bool is_zoomed = false; - public bool is_hovered_over = false; + public partial class Preview : Form + { + public bool show_overlay = true; + public bool hover_zoom = true; + public bool is_zoomed = false; + public bool is_hovered_over = false; - private bool mouse_over_lock = false; - private Size old_size; - private Point old_position; + private bool mouse_over_lock = false; + private Size old_size; + private Point old_position; - private IntPtr m_hThumbnail; - public IntPtr sourceWindow; - private DWM_THUMBNAIL_PROPERTIES m_ThumbnailProperties; - private bool has_been_set_up = false; - private bool thumbnail_has_been_set_up = false; - private MainForm spawner; - private Hotkey hotkey; + private IntPtr m_hThumbnail; + public IntPtr sourceWindow; + private DWM_THUMBNAIL_PROPERTIES m_ThumbnailProperties; + private bool has_been_set_up = false; + private bool thumbnail_has_been_set_up = false; + private MainForm spawner; + private Hotkey hotkey; - private bool hide = false; + private bool hide = false; - public PreviewOverlay overlay; - - public void MakeHidden(bool wha) - { - hide = wha; - } - - public override string ToString() - { - return this.Text; - } + public PreviewOverlay overlay; + public Preview(IntPtr sourceWindow, String title, MainForm spawner, Size size) + { + has_been_set_up = false; - public void MakeTopMost(bool topmost) - { - this.TopMost = topmost && !(this.hide); - } + this.sourceWindow = sourceWindow; + this.spawner = spawner; - public Preview(IntPtr sourceWindow, String title, MainForm spawner, Size size) - { - has_been_set_up = false; + InitializeComponent(); - this.sourceWindow = sourceWindow; - this.spawner = spawner; + this.Text = title; - InitializeComponent(); + this.overlay = new PreviewOverlay(this); - this.Text = title; + this.RenderAreaPictureBox.MouseHover += new System.EventHandler(this.preview_MouseHover); + this.RenderAreaPictureBox.MouseLeave += new System.EventHandler(this.preview_MouseLeave); - this.overlay = new PreviewOverlay(this); + this.old_size = this.Size; + this.old_position = this.Location; - this.render_area.MouseHover += new System.EventHandler(this.preview_MouseHover); - this.render_area.MouseLeave += new System.EventHandler(this.preview_MouseLeave); + has_been_set_up = true; + } - this.old_size = this.Size; - this.old_position = this.Location; + public void MakeHidden(bool wha) + { + hide = wha; + } - has_been_set_up = true; + public override string ToString() + { + return this.Text; + } + public void MakeTopMost(bool topmost) + { + this.TopMost = topmost && !(this.hide); + } - } + public void preview_MouseHover(object sender, System.EventArgs e) + { + if (!mouse_over_lock) + { + mouse_over_lock = true; + if (hover_zoom) + doZoom(); - public void preview_MouseHover(object sender, System.EventArgs e) - { - if (!mouse_over_lock) - { - mouse_over_lock = true; - if (hover_zoom) - doZoom(); + TopMost = true; + overlay.TopMost = true; + } + this.Opacity = 1.0f; + this.is_hovered_over = true; + RefreshPreview(); + } - TopMost = true; - overlay.TopMost = true; - } - this.Opacity = 1.0f; - this.is_hovered_over = true; - RefreshPreview(); - } + protected override CreateParams CreateParams + { + get + { + var Params = base.CreateParams; + Params.ExStyle |= 0x80; + return Params; + } + } - protected override CreateParams CreateParams - { - get - { - var Params = base.CreateParams; - Params.ExStyle |= 0x80; - return Params; - } - } + public void registerShortcut(string shortcut) + { + if (shortcut == "") + return; + var cvt = new KeysConverter(); + var key = (Keys)cvt.ConvertFrom(shortcut); - public void registerShortcut(string shortcut) - { - if (shortcut == "") - return; - var cvt = new KeysConverter(); - var key = (Keys)cvt.ConvertFrom(shortcut); + Hotkey hotkey = new Hotkey(); - Hotkey hotkey = new Hotkey(); + if ((key & Keys.Shift) == Keys.Shift) + { + hotkey.Shift = true; + } + if ((key & Keys.Alt) == Keys.Alt) + { + hotkey.Alt = true; + } + if ((key & Keys.Control) == Keys.Control) + { + hotkey.Control = true; + } - if ((key & Keys.Shift) == Keys.Shift) - { - hotkey.Shift = true; - } - if ((key & Keys.Alt) == Keys.Alt) - { - hotkey.Alt = true; - } - if ((key & Keys.Control) == Keys.Control) - { - hotkey.Control = true; - } + key = key & ~Keys.Shift & ~Keys.Alt & ~Keys.Control; + hotkey.KeyCode = key; + hotkey.Register(this); + hotkey.Pressed += delegate { bring_client_to_foreground(); spawner.preview_did_switch(); }; - key = key & ~Keys.Shift & ~Keys.Alt & ~Keys.Control; - hotkey.KeyCode = key; - hotkey.Register(this); - hotkey.Pressed += delegate { bring_client_to_foreground(); spawner.preview_did_switch(); }; + this.hotkey = hotkey; + } - this.hotkey = hotkey; - } + public void doZoom() + { + if (is_zoomed) + return; - public void doZoom() - { - if (is_zoomed) - return; - - is_zoomed = true; + is_zoomed = true; - float hover_zoom_factor = Properties.Settings.Default.zoom_amount; + float hover_zoom_factor = Properties.Settings.Default.zoom_amount; - old_size = Size; - old_position = Location; + old_size = Size; + old_position = Location; - Size = new Size((int)(hover_zoom_factor * (float)Size.Width), (int)(hover_zoom_factor * (float)Size.Height)); + Size = new Size((int)(hover_zoom_factor * (float)Size.Width), (int)(hover_zoom_factor * (float)Size.Height)); - switch ((MainForm.zoom_anchor_t)Properties.Settings.Default.zoom_anchor) - { - case (MainForm.zoom_anchor_t.NW): - break; - case (MainForm.zoom_anchor_t.N): - Location = new Point(Location.X - Size.Width / 2 + old_size.Width / 2, Location.Y); - break; - case (MainForm.zoom_anchor_t.NE): - Location = new Point(Location.X - Size.Width + old_size.Width, Location.Y); - break; + switch ((ZoomAnchor)Properties.Settings.Default.zoom_anchor) + { + case (ZoomAnchor.NW): + break; + case (ZoomAnchor.N): + Location = new Point(Location.X - Size.Width / 2 + old_size.Width / 2, Location.Y); + break; + case (ZoomAnchor.NE): + Location = new Point(Location.X - Size.Width + old_size.Width, Location.Y); + break; - case (MainForm.zoom_anchor_t.W): - Location = new Point(Location.X, Location.Y - Size.Height / 2 + old_size.Height / 2); - break; - case (MainForm.zoom_anchor_t.C): - Location = new Point(Location.X - Size.Width / 2 + old_size.Width / 2, Location.Y - Size.Height / 2 + old_size.Height / 2); - break; - case (MainForm.zoom_anchor_t.E): - Location = new Point(Location.X - Size.Width + old_size.Width, Location.Y - Size.Height / 2 + old_size.Height / 2); - break; + case (ZoomAnchor.W): + Location = new Point(Location.X, Location.Y - Size.Height / 2 + old_size.Height / 2); + break; + case (ZoomAnchor.C): + Location = new Point(Location.X - Size.Width / 2 + old_size.Width / 2, Location.Y - Size.Height / 2 + old_size.Height / 2); + break; + case (ZoomAnchor.E): + Location = new Point(Location.X - Size.Width + old_size.Width, Location.Y - Size.Height / 2 + old_size.Height / 2); + break; - case (MainForm.zoom_anchor_t.SW): - Location = new Point(Location.X, Location.Y - Size.Height + old_size.Height); - break; - case (MainForm.zoom_anchor_t.S): - Location = new Point(Location.X - Size.Width / 2 + old_size.Width / 2, Location.Y - Size.Height + old_size.Height); - break; - case (MainForm.zoom_anchor_t.SE): - Location = new Point(Location.X - Size.Width + old_size.Width, Location.Y - Size.Height + old_size.Height); - break; - } - } + case (ZoomAnchor.SW): + Location = new Point(Location.X, Location.Y - Size.Height + old_size.Height); + break; + case (ZoomAnchor.S): + Location = new Point(Location.X - Size.Width / 2 + old_size.Width / 2, Location.Y - Size.Height + old_size.Height); + break; + case (ZoomAnchor.SE): + Location = new Point(Location.X - Size.Width + old_size.Width, Location.Y - Size.Height + old_size.Height); + break; + } + } - public void restoreZoom() - { - if (!is_zoomed) - return; + public void restoreZoom() + { + if (!is_zoomed) + return; - Size = old_size; - Location = old_position; - is_zoomed = false; - } + Size = old_size; + Location = old_position; + is_zoomed = false; + } - public void preview_MouseLeave(object sender, System.EventArgs e) - { - if (mouse_over_lock) - { - if (hover_zoom) - { - restoreZoom(); - } - mouse_over_lock = false; - } - this.is_hovered_over = false; - this.Opacity = Properties.Settings.Default.opacity; - RefreshPreview(); - } + public void preview_MouseLeave(object sender, System.EventArgs e) + { + if (mouse_over_lock) + { + if (hover_zoom) + { + restoreZoom(); + } + mouse_over_lock = false; + } + this.is_hovered_over = false; + this.Opacity = Properties.Settings.Default.opacity; + RefreshPreview(); + } - protected override void OnResize(EventArgs e) - { - RefreshPreview(); - base.OnResize(e); - if (has_been_set_up && !mouse_over_lock) - this.spawner.syncronize_preview_size(this.Size); - } + protected override void OnResize(EventArgs e) + { + RefreshPreview(); + base.OnResize(e); + if (has_been_set_up && !mouse_over_lock) + this.spawner.syncronize_preview_size(this.Size); + } - protected override void OnMove(EventArgs e) - { - base.OnMove(e); - if (has_been_set_up && !mouse_over_lock) - this.spawner.register_preview_position(this.Text, this.Location); + protected override void OnMove(EventArgs e) + { + base.OnMove(e); + if (has_been_set_up && !mouse_over_lock) + this.spawner.register_preview_position(this.Text, this.Location); - RefreshPreview(); - } + RefreshPreview(); + } - public void doMove(Point position) - { - if (has_been_set_up && !mouse_over_lock) - Location = position; + public void doMove(Point position) + { + if (has_been_set_up && !mouse_over_lock) + Location = position; - RefreshPreview(); - } + RefreshPreview(); + } - public void SetLabel(String label) - { - this.Text = label; - this.overlay.client_label.Text = label; - } + public void SetLabel(String label) + { + this.Text = label; + this.overlay.SetOverlayLabel(label); + } - public void RefreshPreview() - { - if (has_been_set_up) - { - if (DwmApiNativeMethods.DwmIsCompositionEnabled()) - { - if (thumbnail_has_been_set_up == false) - { - this.SetUpThumbnail(); - } - m_ThumbnailProperties.rcDestination = new RECT(0, 0, ClientRectangle.Right, ClientRectangle.Bottom); - DwmApiNativeMethods.DwmUpdateThumbnailProperties(m_hThumbnail, m_ThumbnailProperties); - } - else - { - thumbnail_has_been_set_up = false; - } + public void RefreshPreview() + { + if (has_been_set_up) + { + if (DwmApiNativeMethods.DwmIsCompositionEnabled()) + { + if (thumbnail_has_been_set_up == false) + { + this.SetUpThumbnail(); + } + m_ThumbnailProperties.rcDestination = new RECT(0, 0, ClientRectangle.Right, ClientRectangle.Bottom); + DwmApiNativeMethods.DwmUpdateThumbnailProperties(m_hThumbnail, m_ThumbnailProperties); + } + else + { + thumbnail_has_been_set_up = false; + } - Size overlay_size = this.render_area.Size; - overlay_size.Width -= 2 * 5; - overlay_size.Height -= 2 * 5; + Size overlay_size = this.RenderAreaPictureBox.Size; + overlay_size.Width -= 2 * 5; + overlay_size.Height -= 2 * 5; - Point overlay_location = this.Location; - overlay_location.X += 5 + (this.Size.Width - this.render_area.Size.Width) / 2; - overlay_location.Y += 5 + (this.Size.Height - this.render_area.Size.Height) - (this.Size.Width - this.render_area.Size.Width) / 2; + Point overlay_location = this.Location; + overlay_location.X += 5 + (this.Size.Width - this.RenderAreaPictureBox.Size.Width) / 2; + overlay_location.Y += 5 + (this.Size.Height - this.RenderAreaPictureBox.Size.Height) - (this.Size.Width - this.RenderAreaPictureBox.Size.Width) / 2; - this.overlay.Size = overlay_size; - this.overlay.Location = overlay_location; + this.overlay.Size = overlay_size; + this.overlay.Location = overlay_location; - } - } + } + } - new public void Show() - { - if (!hide) - { - base.Show(); - if (show_overlay) - this.overlay.Show(); - else - this.overlay.Hide(); - } - else - { - this.Hide(); - this.overlay.Hide(); - } - } + new public void Show() + { + if (!hide) + { + base.Show(); + if (show_overlay) + this.overlay.Show(); + else + this.overlay.Hide(); + } + else + { + this.Hide(); + this.overlay.Hide(); + } + } - new public void Hide() - { - base.Hide(); - this.overlay.Hide(); - } + new public void Hide() + { + base.Hide(); + this.overlay.Hide(); + } - private void SetUpThumbnail() - { - if (DwmApiNativeMethods.DwmIsCompositionEnabled() && !thumbnail_has_been_set_up) - { - m_hThumbnail = DwmApiNativeMethods.DwmRegisterThumbnail(this.Handle, sourceWindow); + private void SetUpThumbnail() + { + if (DwmApiNativeMethods.DwmIsCompositionEnabled() && !thumbnail_has_been_set_up) + { + m_hThumbnail = DwmApiNativeMethods.DwmRegisterThumbnail(this.Handle, sourceWindow); - m_ThumbnailProperties = new DWM_THUMBNAIL_PROPERTIES(); - m_ThumbnailProperties.dwFlags = DWM_THUMBNAIL_PROPERTIES.DWM_TNP_VISIBLE - + DWM_THUMBNAIL_PROPERTIES.DWM_TNP_OPACITY - + DWM_THUMBNAIL_PROPERTIES.DWM_TNP_RECTDESTINATION - + DWM_THUMBNAIL_PROPERTIES.DWM_TNP_SOURCECLIENTAREAONLY; - m_ThumbnailProperties.opacity = 255; - m_ThumbnailProperties.fVisible = true; - m_ThumbnailProperties.fSourceClientAreaOnly = true; - m_ThumbnailProperties.rcDestination = new RECT(0, 0, ClientRectangle.Right, ClientRectangle.Bottom); + m_ThumbnailProperties = new DWM_THUMBNAIL_PROPERTIES(); + m_ThumbnailProperties.dwFlags = DWM_THUMBNAIL_PROPERTIES.DWM_TNP_VISIBLE + + DWM_THUMBNAIL_PROPERTIES.DWM_TNP_OPACITY + + DWM_THUMBNAIL_PROPERTIES.DWM_TNP_RECTDESTINATION + + DWM_THUMBNAIL_PROPERTIES.DWM_TNP_SOURCECLIENTAREAONLY; + m_ThumbnailProperties.opacity = 255; + m_ThumbnailProperties.fVisible = true; + m_ThumbnailProperties.fSourceClientAreaOnly = true; + m_ThumbnailProperties.rcDestination = new RECT(0, 0, ClientRectangle.Right, ClientRectangle.Bottom); - DwmApiNativeMethods.DwmUpdateThumbnailProperties(m_hThumbnail, m_ThumbnailProperties); + DwmApiNativeMethods.DwmUpdateThumbnailProperties(m_hThumbnail, m_ThumbnailProperties); - thumbnail_has_been_set_up = true; - } - } + thumbnail_has_been_set_up = true; + } + } - private void Preview_Load(object sender, EventArgs e) - { + private void Preview_Load(object sender, EventArgs e) + { - } + } - public void bring_client_to_foreground() - { - DwmApiNativeMethods.SetForegroundWindow(sourceWindow); - int style = DwmApiNativeMethods.GetWindowLong(sourceWindow, DwmApiNativeMethods.GWL_STYLE); - if ((style & DwmApiNativeMethods.WS_MAXIMIZE) == DwmApiNativeMethods.WS_MAXIMIZE) - { - //It's maximized - } - else if ((style & DwmApiNativeMethods.WS_MINIMIZE) == DwmApiNativeMethods.WS_MINIMIZE) - { - DwmApiNativeMethods.ShowWindowAsync(sourceWindow, DwmApiNativeMethods.SW_SHOWNORMAL); - } - } + public void bring_client_to_foreground() + { + DwmApiNativeMethods.SetForegroundWindow(sourceWindow); + int style = DwmApiNativeMethods.GetWindowLong(sourceWindow, DwmApiNativeMethods.GWL_STYLE); + if ((style & DwmApiNativeMethods.WS_MAXIMIZE) == DwmApiNativeMethods.WS_MAXIMIZE) + { + //It's maximized + } + else if ((style & DwmApiNativeMethods.WS_MINIMIZE) == DwmApiNativeMethods.WS_MINIMIZE) + { + DwmApiNativeMethods.ShowWindowAsync(sourceWindow, DwmApiNativeMethods.SW_SHOWNORMAL); + } + } - public void render_area_Click(object sender, MouseEventArgs e) - { - if (e.Button == MouseButtons.Left) - { - bring_client_to_foreground(); - spawner.preview_did_switch(); - } - if (e.Button == MouseButtons.Right) - { - // do smth cool? - } - if (e.Button == MouseButtons.Middle) - { - // do smth cool? - } - } + public void render_area_Click(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + bring_client_to_foreground(); + spawner.preview_did_switch(); + } + if (e.Button == MouseButtons.Right) + { + // do smth cool? + } + if (e.Button == MouseButtons.Middle) + { + // do smth cool? + } + } - public void set_render_area_size(Size size) - { - this.Size = size; - } - - } + public void set_render_area_size(Size size) + { + this.Size = size; + } + } } \ No newline at end of file diff --git a/Eve-O-Preview/Preview/PreviewOverlay.Designer.cs b/Eve-O-Preview/Preview/PreviewOverlay.Designer.cs index c02c9a0..d49b54f 100644 --- a/Eve-O-Preview/Preview/PreviewOverlay.Designer.cs +++ b/Eve-O-Preview/Preview/PreviewOverlay.Designer.cs @@ -28,66 +28,63 @@ /// private void InitializeComponent() { - this.overlay_area = new System.Windows.Forms.PictureBox(); - this.client_label = new System.Windows.Forms.Label(); - ((System.ComponentModel.ISupportInitialize)(this.overlay_area)).BeginInit(); - this.SuspendLayout(); - // - // overlay_area - // - this.overlay_area.BackColor = System.Drawing.Color.Transparent; - this.overlay_area.Cursor = System.Windows.Forms.Cursors.Hand; - this.overlay_area.Dock = System.Windows.Forms.DockStyle.Fill; - this.overlay_area.Location = new System.Drawing.Point(0, 0); - this.overlay_area.Name = "overlay_area"; - this.overlay_area.Size = new System.Drawing.Size(284, 262); - this.overlay_area.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; - this.overlay_area.TabIndex = 0; - this.overlay_area.TabStop = false; - this.overlay_area.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_Click); - // - // client_label - // - this.client_label.AutoSize = true; - this.client_label.Dock = System.Windows.Forms.DockStyle.Top; - this.client_label.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.client_label.ForeColor = System.Drawing.Color.DarkGray; - this.client_label.Location = new System.Drawing.Point(0, 0); - this.client_label.Name = "client_label"; - this.client_label.Size = new System.Drawing.Size(25, 13); - this.client_label.TabIndex = 1; - this.client_label.Text = "..."; - this.client_label.Click += new System.EventHandler(this.client_label_Click); - // - // PreviewOverlay - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.Black; - this.ClientSize = new System.Drawing.Size(284, 262); - this.ControlBox = false; - this.Controls.Add(this.client_label); - this.Controls.Add(this.overlay_area); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "PreviewOverlay"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; - this.Text = "PreviewOverlay"; - this.TransparencyKey = System.Drawing.Color.Black; - this.Load += new System.EventHandler(this.PreviewOverlay_Load); - ((System.ComponentModel.ISupportInitialize)(this.overlay_area)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); + System.Windows.Forms.PictureBox OverlayAreaPictureBox; + this.OverlayLabel = new System.Windows.Forms.Label(); + OverlayAreaPictureBox = new System.Windows.Forms.PictureBox(); + ((System.ComponentModel.ISupportInitialize)(OverlayAreaPictureBox)).BeginInit(); + this.SuspendLayout(); + // + // OverlayAreaPictureBox + // + OverlayAreaPictureBox.BackColor = System.Drawing.Color.Transparent; + OverlayAreaPictureBox.Cursor = System.Windows.Forms.Cursors.Hand; + OverlayAreaPictureBox.Dock = System.Windows.Forms.DockStyle.Fill; + OverlayAreaPictureBox.Location = new System.Drawing.Point(0, 0); + OverlayAreaPictureBox.Name = "OverlayAreaPictureBox"; + OverlayAreaPictureBox.Size = new System.Drawing.Size(284, 262); + OverlayAreaPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; + OverlayAreaPictureBox.TabIndex = 0; + OverlayAreaPictureBox.TabStop = false; + OverlayAreaPictureBox.MouseUp += new System.Windows.Forms.MouseEventHandler(this.OverlayArea_Click); + // + // OverlayLabel + // + this.OverlayLabel.AutoSize = true; + this.OverlayLabel.Dock = System.Windows.Forms.DockStyle.Top; + this.OverlayLabel.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.OverlayLabel.ForeColor = System.Drawing.Color.DarkGray; + this.OverlayLabel.Location = new System.Drawing.Point(0, 0); + this.OverlayLabel.Name = "OverlayLabel"; + this.OverlayLabel.Size = new System.Drawing.Size(25, 13); + this.OverlayLabel.TabIndex = 1; + this.OverlayLabel.Text = "..."; + // + // PreviewOverlay + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.Black; + this.ClientSize = new System.Drawing.Size(284, 262); + this.ControlBox = false; + this.Controls.Add(this.OverlayLabel); + this.Controls.Add(OverlayAreaPictureBox); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "PreviewOverlay"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.Text = "PreviewOverlay"; + this.TransparencyKey = System.Drawing.Color.Black; + ((System.ComponentModel.ISupportInitialize)(OverlayAreaPictureBox)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); } - #endregion + #endregion - public System.Windows.Forms.PictureBox overlay_area; - public System.Windows.Forms.Label client_label; - - } + private System.Windows.Forms.Label OverlayLabel; + } } \ No newline at end of file diff --git a/Eve-O-Preview/Preview/PreviewOverlay.cs b/Eve-O-Preview/Preview/PreviewOverlay.cs index b1f0aab..b3a11d5 100644 --- a/Eve-O-Preview/Preview/PreviewOverlay.cs +++ b/Eve-O-Preview/Preview/PreviewOverlay.cs @@ -1,55 +1,40 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; +using System.Windows.Forms; namespace EveOPreview { - public partial class PreviewOverlay : Form - { - private Preview parent; - private Color original_color; - public PreviewOverlay(Preview parent) - { - this.parent = parent; - InitializeComponent(); - original_color = overlay_area.BackColor; - } + public partial class PreviewOverlay : Form + { + private readonly Preview _parent; - private void PreviewOverlay_Load(object sender, EventArgs e) - { + public PreviewOverlay(Preview parent) + { + this._parent = parent; + InitializeComponent(); + } - } + private void OverlayArea_Click(object sender, MouseEventArgs e) + { + this._parent.render_area_Click(sender, e); + } - private void pictureBox1_Click(object sender, MouseEventArgs e) - { - this.parent.render_area_Click(sender, e); - } + public void MakeTopMost() + { + this.TopMost = true; + } - public void makeTopMost() - { - this.TopMost = true; - } + public void SetOverlayLabel(string label) + { + this.OverlayLabel.Text = label; + } - private void client_label_Click(object sender, EventArgs e) - { - - } - - protected override CreateParams CreateParams - { - get - { - var Params = base.CreateParams; - Params.ExStyle |= 0x80; - return Params; - } - } - - } + protected override CreateParams CreateParams + { + get + { + var Params = base.CreateParams; + Params.ExStyle |= 0x80; + return Params; + } + } + } } diff --git a/Eve-O-Preview/Preview/PreviewOverlay.resx b/Eve-O-Preview/Preview/PreviewOverlay.resx index 29dcb1b..6a0cc5e 100644 --- a/Eve-O-Preview/Preview/PreviewOverlay.resx +++ b/Eve-O-Preview/Preview/PreviewOverlay.resx @@ -117,4 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + False + \ No newline at end of file diff --git a/Eve-O-Preview/Properties/AssemblyInfo.cs b/Eve-O-Preview/Properties/AssemblyInfo.cs index d272cb5..5d9a712 100644 --- a/Eve-O-Preview/Properties/AssemblyInfo.cs +++ b/Eve-O-Preview/Properties/AssemblyInfo.cs @@ -1,16 +1,18 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -[assembly: AssemblyTitle("PreviewToy")] +[assembly: AssemblyTitle("EVE-O Preview")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("?")] -[assembly: AssemblyProduct("PreviewToy")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("EVE-O Preview")] [assembly: AssemblyCopyright("")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] [assembly: Guid("04f08f8d-9e98-423b-acdb-4effb31c0d35")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.18.0.0")] +[assembly: AssemblyFileVersion("1.18.0.0")] + +// Provide your own key name to build the app locally +[assembly: AssemblyKeyName("Phrynohyas")] diff --git a/Eve-O-Preview/preview toy_TemporaryKey.pfx b/Eve-O-Preview/preview toy_TemporaryKey.pfx deleted file mode 100644 index 007e1107fe9977ab417385ea6be395c318be7073..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1652 zcmY*Yc{G%37=LH+jim`0$z>2JyKi*In1n1bEp{Q1YA7l~26Ue3tl5RK zREm(LWMXiV<+MmDp)KN>RQ9k7C9z)!jRb<_~j;EtSEJkEkItMJtt+gMks zzj`|3{4f(%D3>&yL3P4Fs9^`)D{ROHS5*zMNL96ir)sJ zUX1u2@*zh)ZXjpKx<$y%>J=GG zQoq(*M4AHO@fZLAeBif8qSz?x1!sXNpn0ndo59fQM5qWIoJad(S$H~3__E{Q0x?JfHm+1Ob`T4fzxOl1;IcGIHLCt z#UC6)Gjo)Og8)=Jh2}xvFv@*?PALJqpM9Zd<^{Y#5b8viU%w|ns5u#^WP!y16pVgX zFn`z;`e9dc=@{|3QWWWjUC$#}30`tWBY6>;y516m323p1d@)%xw0?lA>-$J@&od|A zIR#r=VrypnVWW)K?9R45npzX`TK4*F+H-9IXKD836E0FWI%?Z0UMy8q`)LG}R+YM? zm#8Wzb0yCooL)|E8kiSY-&1ohVA@`ZA3nzkDabX5Um4muW}+T4%W6(9UKmQD1~*9U zka1khsXax<&VS!0hke*2!BLvMu(@O$@1!fei5k>>)g>geV%pZ`u40kwLHn`5 z`%J0Z7fO4mER7x-eSMhBl8%dJjJpoUOwQpz_3K0l8|5=*>>Ey3BF4#;O$nL1?j`S5 zPN1xOXm%_JQ8^Tai@H@7rII&dP%tBKRsYI2-^T3syeP_Fn#T`9+l&|~Cxh7pS`~Zz z&7N>O6Q0QRyO0x?w`xo8xF%gPfv@@^(ct%~)nu7@;JW@3 z2W~r#6UYpYRxT|}-(|=vZ>H$*jv7xUEMcKaS3afUw2zG(d1@J{rmDX>lIFtgbv+t% z$#(R`o7f3bKUI74V54O%?t9$ng_Spa|Ko9eupz7n6CfeYwK(iwcvALaVC8hlu>btV nI;Hr$B15uxz8juIE=XN>kJrZ%=T4m|PV2Cf@2nF0u~7d46Bn+g From 97855fe593c6d07be63197ee45a82a8f8da51a2d Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Sat, 14 May 2016 00:51:24 +0300 Subject: [PATCH 12/17] Drop obsolete .hgignore file --- .hgignore | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .hgignore diff --git a/.hgignore b/.hgignore deleted file mode 100644 index aa6e832..0000000 --- a/.hgignore +++ /dev/null @@ -1,3 +0,0 @@ -syntax: glob -bin/* -obj/* From 3e5f54857f4e6bff552bd9c4ba82849d57671acf Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Sat, 14 May 2016 00:52:01 +0300 Subject: [PATCH 13/17] Mark assemblies as CLSCompliant --- Eve-O-Mock/Properties/AssemblyInfo.cs | 5 ++++- Eve-O-Preview/Properties/AssemblyInfo.cs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Eve-O-Mock/Properties/AssemblyInfo.cs b/Eve-O-Mock/Properties/AssemblyInfo.cs index 6be2b76..8f04a3c 100644 --- a/Eve-O-Mock/Properties/AssemblyInfo.cs +++ b/Eve-O-Mock/Properties/AssemblyInfo.cs @@ -1,4 +1,5 @@ -using System.Reflection; +using System; +using System.Reflection; using System.Runtime.InteropServices; using System.Windows; @@ -23,3 +24,5 @@ using System.Windows; [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] + +[assembly: CLSCompliant(true)] \ No newline at end of file diff --git a/Eve-O-Preview/Properties/AssemblyInfo.cs b/Eve-O-Preview/Properties/AssemblyInfo.cs index 5d9a712..75c665f 100644 --- a/Eve-O-Preview/Properties/AssemblyInfo.cs +++ b/Eve-O-Preview/Properties/AssemblyInfo.cs @@ -1,4 +1,5 @@ -using System.Reflection; +using System; +using System.Reflection; using System.Runtime.InteropServices; [assembly: AssemblyTitle("EVE-O Preview")] @@ -16,3 +17,5 @@ using System.Runtime.InteropServices; // Provide your own key name to build the app locally [assembly: AssemblyKeyName("Phrynohyas")] + +[assembly: CLSCompliant(true)] From b9ca9bd7240565f6907f70c2b25f187f0a90c2ab Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Sat, 14 May 2016 00:53:32 +0300 Subject: [PATCH 14/17] Dropped the DataSources folder --- Eve-O-Preview/Eve-O-Preview.csproj | 1 - .../Properties/DataSources/PreviewToyMain.datasource | 10 ---------- 2 files changed, 11 deletions(-) delete mode 100644 Eve-O-Preview/Properties/DataSources/PreviewToyMain.datasource diff --git a/Eve-O-Preview/Eve-O-Preview.csproj b/Eve-O-Preview/Eve-O-Preview.csproj index 2a654c5..f5ea476 100644 --- a/Eve-O-Preview/Eve-O-Preview.csproj +++ b/Eve-O-Preview/Eve-O-Preview.csproj @@ -150,7 +150,6 @@ Designer - SettingsSingleFileGenerator Settings.Designer.cs diff --git a/Eve-O-Preview/Properties/DataSources/PreviewToyMain.datasource b/Eve-O-Preview/Properties/DataSources/PreviewToyMain.datasource deleted file mode 100644 index 8e957e6..0000000 --- a/Eve-O-Preview/Properties/DataSources/PreviewToyMain.datasource +++ /dev/null @@ -1,10 +0,0 @@ - - - - PreviewToy.PreviewToyMain, eve-o preview test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - \ No newline at end of file From aaf859a1e3ffabb437b865a47f74d4a45cf0f2c8 Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Sat, 14 May 2016 13:46:48 +0300 Subject: [PATCH 15/17] Preview update --- Eve-O-Preview/DwmAPI/DwmApiNativeMethods.cs | 15 +- Eve-O-Preview/Eve-O-Preview.csproj | 1 - Eve-O-Preview/GUI/GuiNativeMethods.cs | 22 -- Eve-O-Preview/GUI/MainForm.cs | 24 +- Eve-O-Preview/Preview/Preview.Designer.cs | 2 + Eve-O-Preview/Preview/Preview.cs | 304 +++++++++++--------- Eve-O-Preview/Preview/PreviewOverlay.cs | 18 +- 7 files changed, 203 insertions(+), 183 deletions(-) delete mode 100644 Eve-O-Preview/GUI/GuiNativeMethods.cs diff --git a/Eve-O-Preview/DwmAPI/DwmApiNativeMethods.cs b/Eve-O-Preview/DwmAPI/DwmApiNativeMethods.cs index 445252a..e3c663f 100644 --- a/Eve-O-Preview/DwmAPI/DwmApiNativeMethods.cs +++ b/Eve-O-Preview/DwmAPI/DwmApiNativeMethods.cs @@ -117,5 +117,18 @@ namespace EveOPreview public const UInt32 WS_EX_LAYOUTRTL = 0x00400000; // Right to left mirroring public const UInt32 WS_EX_COMPOSITED = 0x02000000; public const UInt32 WS_EX_NOACTIVATE = 0x08000000; - } + + public const int WM_SIZE = 5; + public const int SIZE_RESTORED = 0; + public const int SIZE_MINIMIZED = 1; + public const int SIZE_MAXIMIZED = 2; + public const int SIZE_MAXSHOW = 3; + public const int SIZE_MAXHIDE = 4; + + [DllImport("user32.dll")] + public static extern int GetWindowRect(IntPtr hwnd, out RECT rect); + + [DllImport("user32.dll")] + public static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint); + } } \ No newline at end of file diff --git a/Eve-O-Preview/Eve-O-Preview.csproj b/Eve-O-Preview/Eve-O-Preview.csproj index f5ea476..f88d2a7 100644 --- a/Eve-O-Preview/Eve-O-Preview.csproj +++ b/Eve-O-Preview/Eve-O-Preview.csproj @@ -108,7 +108,6 @@ - diff --git a/Eve-O-Preview/GUI/GuiNativeMethods.cs b/Eve-O-Preview/GUI/GuiNativeMethods.cs deleted file mode 100644 index d46dfb1..0000000 --- a/Eve-O-Preview/GUI/GuiNativeMethods.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -namespace EveOPreview -{ - // TODO This is a really bad name for this class - static class GuiNativeMethods - { - public const int WM_SIZE = 5; - public const int SIZE_RESTORED = 0; - public const int SIZE_MINIMIZED = 1; - public const int SIZE_MAXIMIZED = 2; - public const int SIZE_MAXSHOW = 3; - public const int SIZE_MAXHIDE = 4; - - [DllImport("user32.dll")] - public static extern int GetWindowRect(IntPtr hwnd, out RECT rect); - - [DllImport("user32.dll")] - public static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint); - } -} \ No newline at end of file diff --git a/Eve-O-Preview/GUI/MainForm.cs b/Eve-O-Preview/GUI/MainForm.cs index 389ea25..3aa95aa 100644 --- a/Eve-O-Preview/GUI/MainForm.cs +++ b/Eve-O-Preview/GUI/MainForm.cs @@ -151,8 +151,7 @@ namespace EveOPreview if (!_previews.ContainsKey(process.MainWindowHandle) && process.MainWindowTitle != "") { - _previews[process.MainWindowHandle] = new Preview(process.MainWindowHandle, "...", this, sync_size); - _previews[process.MainWindowHandle].set_render_area_size(sync_size);// TODO Remove + _previews[process.MainWindowHandle] = new Preview(this, process.MainWindowHandle, "...", sync_size); // apply more thumbnail specific options _previews[process.MainWindowHandle].MakeTopMost(Properties.Settings.Default.always_on_top); @@ -202,7 +201,6 @@ namespace EveOPreview previews_check_listbox.Items.Remove(_previews[processHandle]); previews_check_listbox.EndUpdate(); - _previews[processHandle].overlay.Close(); _previews[processHandle].Close(); _previews.Remove(processHandle); } @@ -215,7 +213,7 @@ namespace EveOPreview { if (Properties.Settings.Default.track_client_windows && _clientLayout.ContainsKey(process.MainWindowTitle)) { - GuiNativeMethods.MoveWindow(process.MainWindowHandle, _clientLayout[process.MainWindowTitle].X, + DwmApiNativeMethods.MoveWindow(process.MainWindowHandle, _clientLayout[process.MainWindowTitle].X, _clientLayout[process.MainWindowTitle].Y, _clientLayout[process.MainWindowTitle].Width, _clientLayout[process.MainWindowTitle].Height, true); } @@ -397,7 +395,7 @@ namespace EveOPreview foreach (Process process in processes) { RECT rect = new RECT(); - GuiNativeMethods.GetWindowRect(process.MainWindowHandle, out rect); + DwmApiNativeMethods.GetWindowRect(process.MainWindowHandle, out rect); int left = Math.Abs(rect.Left); int right = Math.Abs(rect.Right); @@ -426,8 +424,6 @@ namespace EveOPreview foreach (KeyValuePair entry in _previews) { entry.Value.MakeTopMost(Properties.Settings.Default.always_on_top); - //makes the PreviewOverlay topmost - entry.Value.overlay.MakeTopMost(); } } @@ -450,7 +446,7 @@ namespace EveOPreview bool active_window_is_right_type = false; foreach (KeyValuePair entry in _previews) { - if (entry.Key == window || entry.Value.Handle == window || this.Handle == window || entry.Value.overlay.Handle == window) + if (entry.Key == window || entry.Value.IsPreviewHandle(window)) { active_window_is_right_type = true; } @@ -489,8 +485,6 @@ namespace EveOPreview } entry.Value.hover_zoom = Properties.Settings.Default.zoom_on_hover; entry.Value.show_overlay = Properties.Settings.Default.show_overlay; - //makes the PreviewOverlay TopMost - entry.Value.overlay.MakeTopMost(); if (!entry.Value.is_hovered_over) { entry.Value.Opacity = Properties.Settings.Default.opacity; @@ -518,7 +512,7 @@ namespace EveOPreview { if (entry.Value.Handle != DwmApiNativeMethods.GetForegroundWindow()) { - entry.Value.set_render_area_size(sync_size); + entry.Value.SetSize(sync_size); } } @@ -824,16 +818,16 @@ namespace EveOPreview { switch (m.Msg) { - case GuiNativeMethods.WM_SIZE: + case DwmApiNativeMethods.WM_SIZE: switch (m.WParam.ToInt32()) { - case GuiNativeMethods.SIZE_RESTORED: + case DwmApiNativeMethods.SIZE_RESTORED: OnRestored(EventArgs.Empty); break; - case GuiNativeMethods.SIZE_MINIMIZED: + case DwmApiNativeMethods.SIZE_MINIMIZED: OnMinimized(EventArgs.Empty); break; - case GuiNativeMethods.SIZE_MAXIMIZED: + case DwmApiNativeMethods.SIZE_MAXIMIZED: OnMaximized(EventArgs.Empty); break; } diff --git a/Eve-O-Preview/Preview/Preview.Designer.cs b/Eve-O-Preview/Preview/Preview.Designer.cs index 9a83820..d33bce3 100644 --- a/Eve-O-Preview/Preview/Preview.Designer.cs +++ b/Eve-O-Preview/Preview/Preview.Designer.cs @@ -31,6 +31,8 @@ namespace EveOPreview this.RenderAreaPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; this.RenderAreaPictureBox.TabIndex = 0; this.RenderAreaPictureBox.TabStop = false; + this.RenderAreaPictureBox.MouseLeave += new System.EventHandler(this.preview_MouseLeave); + this.RenderAreaPictureBox.MouseHover += new System.EventHandler(this.preview_MouseHover); this.RenderAreaPictureBox.MouseUp += new System.Windows.Forms.MouseEventHandler(this.render_area_Click); // // Preview diff --git a/Eve-O-Preview/Preview/Preview.cs b/Eve-O-Preview/Preview/Preview.cs index 23806db..5e2e654 100644 --- a/Eve-O-Preview/Preview/Preview.cs +++ b/Eve-O-Preview/Preview/Preview.cs @@ -6,50 +6,151 @@ namespace EveOPreview { public partial class Preview : Form { + #region Private fields + private readonly bool _isInitializing; + private readonly IntPtr _sourceWindow; + private readonly MainForm _parentForm; + private readonly PreviewOverlay _overlay; + + private Size _normalSize; + private Point _normalPosition; + + private bool _isThumbnailSetUp; + private DWM_THUMBNAIL_PROPERTIES _Thumbnail; + private IntPtr _ThumbnailHandle; + #endregion + + // TODO Hide the parent form behind an interface + public Preview(MainForm parent, IntPtr sourceWindow, String title, Size size) + { + this._isInitializing = true; + + this._sourceWindow = sourceWindow; + this._parentForm = parent; + + this._isThumbnailSetUp = false; + + InitializeComponent(); + + this.Text = title; + + this._overlay = new PreviewOverlay(this.render_area_Click); + + this._isInitializing = false; + + this.SetSize(size); + } + + public bool IsPreviewHandle(IntPtr handle) + { + return (this.Handle == handle) || (this._overlay.Handle == handle); + } + + public void SetSize(Size size) + { + this.Size = size; + this._normalSize = this.Size; + this._normalPosition = this.Location; + } + + public void MakeTopMost(bool topmost) + { + if (!this.hide) + { + return; + } + + this.TopMost = topmost; + this.MakeOverlayTopMost(); + } + + protected override CreateParams CreateParams + { + get + { + var Params = base.CreateParams; + Params.ExStyle |= (int)DwmApiNativeMethods.WS_EX_TOOLWINDOW; + return Params; + } + } + + private void MakeOverlayTopMost() + { + this._overlay.TopMost = true; + } + + private void RefreshPreview() + { + if (this._isInitializing) + { + return; + } + + if (DwmApiNativeMethods.DwmIsCompositionEnabled()) + { + if (this._isThumbnailSetUp == false) + { + this.SetUpThumbnail(); + } + + this._Thumbnail.rcDestination = new RECT(0, 0, this.ClientRectangle.Right, this.ClientRectangle.Bottom); + DwmApiNativeMethods.DwmUpdateThumbnailProperties(this._ThumbnailHandle, this._Thumbnail); + } + else + { + this._isThumbnailSetUp = false; + } + + Size overlaySize = this.RenderAreaPictureBox.Size; + overlaySize.Width -= 2 * 5; + overlaySize.Height -= 2 * 5; + + Point overlayLocation = this.Location; + overlayLocation.X += 5 + (this.Size.Width - this.RenderAreaPictureBox.Size.Width) / 2; + overlayLocation.Y += 5 + (this.Size.Height - this.RenderAreaPictureBox.Size.Height) - (this.Size.Width - this.RenderAreaPictureBox.Size.Width) / 2; + + this._overlay.Size = overlaySize; + this._overlay.Location = overlayLocation; + } + + private void SetUpThumbnail() + { + // TODO Remove this API call on Win 8+ hosts + if (this._isThumbnailSetUp || !DwmApiNativeMethods.DwmIsCompositionEnabled()) + { + return; + } + + this._ThumbnailHandle = DwmApiNativeMethods.DwmRegisterThumbnail(this.Handle, this._sourceWindow); + + this._Thumbnail = new DWM_THUMBNAIL_PROPERTIES(); + this._Thumbnail.dwFlags = DWM_THUMBNAIL_PROPERTIES.DWM_TNP_VISIBLE + + DWM_THUMBNAIL_PROPERTIES.DWM_TNP_OPACITY + + DWM_THUMBNAIL_PROPERTIES.DWM_TNP_RECTDESTINATION + + DWM_THUMBNAIL_PROPERTIES.DWM_TNP_SOURCECLIENTAREAONLY; + this._Thumbnail.opacity = 255; + this._Thumbnail.fVisible = true; + this._Thumbnail.fSourceClientAreaOnly = true; + this._Thumbnail.rcDestination = new RECT(0, 0, ClientRectangle.Right, ClientRectangle.Bottom); + + DwmApiNativeMethods.DwmUpdateThumbnailProperties(_ThumbnailHandle, _Thumbnail); + + _isThumbnailSetUp = true; + } + + public bool show_overlay = true; public bool hover_zoom = true; public bool is_zoomed = false; public bool is_hovered_over = false; private bool mouse_over_lock = false; - private Size old_size; - private Point old_position; - private IntPtr m_hThumbnail; - public IntPtr sourceWindow; - private DWM_THUMBNAIL_PROPERTIES m_ThumbnailProperties; - private bool has_been_set_up = false; - private bool thumbnail_has_been_set_up = false; - private MainForm spawner; + private Hotkey hotkey; private bool hide = false; - public PreviewOverlay overlay; - - - public Preview(IntPtr sourceWindow, String title, MainForm spawner, Size size) - { - has_been_set_up = false; - - this.sourceWindow = sourceWindow; - this.spawner = spawner; - - InitializeComponent(); - - this.Text = title; - - this.overlay = new PreviewOverlay(this); - - this.RenderAreaPictureBox.MouseHover += new System.EventHandler(this.preview_MouseHover); - this.RenderAreaPictureBox.MouseLeave += new System.EventHandler(this.preview_MouseLeave); - - this.old_size = this.Size; - this.old_position = this.Location; - - has_been_set_up = true; - } - public void MakeHidden(bool wha) { hide = wha; @@ -60,11 +161,6 @@ namespace EveOPreview return this.Text; } - public void MakeTopMost(bool topmost) - { - this.TopMost = topmost && !(this.hide); - } - public void preview_MouseHover(object sender, System.EventArgs e) { if (!mouse_over_lock) @@ -73,24 +169,13 @@ namespace EveOPreview if (hover_zoom) doZoom(); - TopMost = true; - overlay.TopMost = true; + this.MakeTopMost(true); } this.Opacity = 1.0f; this.is_hovered_over = true; RefreshPreview(); } - protected override CreateParams CreateParams - { - get - { - var Params = base.CreateParams; - Params.ExStyle |= 0x80; - return Params; - } - } - public void registerShortcut(string shortcut) { if (shortcut == "") @@ -116,7 +201,8 @@ namespace EveOPreview key = key & ~Keys.Shift & ~Keys.Alt & ~Keys.Control; hotkey.KeyCode = key; hotkey.Register(this); - hotkey.Pressed += delegate { bring_client_to_foreground(); spawner.preview_did_switch(); }; + // TODO Make this a method + hotkey.Pressed += (s, e) => { bring_client_to_foreground(); this._parentForm.preview_did_switch(); }; this.hotkey = hotkey; } @@ -130,8 +216,8 @@ namespace EveOPreview float hover_zoom_factor = Properties.Settings.Default.zoom_amount; - old_size = Size; - old_position = Location; + _normalSize = Size; + _normalPosition = Location; Size = new Size((int)(hover_zoom_factor * (float)Size.Width), (int)(hover_zoom_factor * (float)Size.Height)); @@ -140,30 +226,30 @@ namespace EveOPreview case (ZoomAnchor.NW): break; case (ZoomAnchor.N): - Location = new Point(Location.X - Size.Width / 2 + old_size.Width / 2, Location.Y); + Location = new Point(Location.X - Size.Width / 2 + _normalSize.Width / 2, Location.Y); break; case (ZoomAnchor.NE): - Location = new Point(Location.X - Size.Width + old_size.Width, Location.Y); + Location = new Point(Location.X - Size.Width + _normalSize.Width, Location.Y); break; case (ZoomAnchor.W): - Location = new Point(Location.X, Location.Y - Size.Height / 2 + old_size.Height / 2); + Location = new Point(Location.X, Location.Y - Size.Height / 2 + _normalSize.Height / 2); break; case (ZoomAnchor.C): - Location = new Point(Location.X - Size.Width / 2 + old_size.Width / 2, Location.Y - Size.Height / 2 + old_size.Height / 2); + Location = new Point(Location.X - Size.Width / 2 + _normalSize.Width / 2, Location.Y - Size.Height / 2 + _normalSize.Height / 2); break; case (ZoomAnchor.E): - Location = new Point(Location.X - Size.Width + old_size.Width, Location.Y - Size.Height / 2 + old_size.Height / 2); + Location = new Point(Location.X - Size.Width + _normalSize.Width, Location.Y - Size.Height / 2 + _normalSize.Height / 2); break; case (ZoomAnchor.SW): - Location = new Point(Location.X, Location.Y - Size.Height + old_size.Height); + Location = new Point(Location.X, Location.Y - Size.Height + _normalSize.Height); break; case (ZoomAnchor.S): - Location = new Point(Location.X - Size.Width / 2 + old_size.Width / 2, Location.Y - Size.Height + old_size.Height); + Location = new Point(Location.X - Size.Width / 2 + _normalSize.Width / 2, Location.Y - Size.Height + _normalSize.Height); break; case (ZoomAnchor.SE): - Location = new Point(Location.X - Size.Width + old_size.Width, Location.Y - Size.Height + old_size.Height); + Location = new Point(Location.X - Size.Width + _normalSize.Width, Location.Y - Size.Height + _normalSize.Height); break; } } @@ -173,8 +259,8 @@ namespace EveOPreview if (!is_zoomed) return; - Size = old_size; - Location = old_position; + Size = _normalSize; + Location = _normalPosition; is_zoomed = false; } @@ -197,22 +283,23 @@ namespace EveOPreview { RefreshPreview(); base.OnResize(e); - if (has_been_set_up && !mouse_over_lock) - this.spawner.syncronize_preview_size(this.Size); + + if (!this._isInitializing && !mouse_over_lock) + this._parentForm.syncronize_preview_size(this.Size); } protected override void OnMove(EventArgs e) { base.OnMove(e); - if (has_been_set_up && !mouse_over_lock) - this.spawner.register_preview_position(this.Text, this.Location); + if (!this._isInitializing && !mouse_over_lock) + this._parentForm.register_preview_position(this.Text, this.Location); RefreshPreview(); } public void doMove(Point position) { - if (has_been_set_up && !mouse_over_lock) + if (!this._isInitializing && !mouse_over_lock) Location = position; RefreshPreview(); @@ -221,39 +308,7 @@ namespace EveOPreview public void SetLabel(String label) { this.Text = label; - this.overlay.SetOverlayLabel(label); - } - - public void RefreshPreview() - { - if (has_been_set_up) - { - if (DwmApiNativeMethods.DwmIsCompositionEnabled()) - { - if (thumbnail_has_been_set_up == false) - { - this.SetUpThumbnail(); - } - m_ThumbnailProperties.rcDestination = new RECT(0, 0, ClientRectangle.Right, ClientRectangle.Bottom); - DwmApiNativeMethods.DwmUpdateThumbnailProperties(m_hThumbnail, m_ThumbnailProperties); - } - else - { - thumbnail_has_been_set_up = false; - } - - Size overlay_size = this.RenderAreaPictureBox.Size; - overlay_size.Width -= 2 * 5; - overlay_size.Height -= 2 * 5; - - Point overlay_location = this.Location; - overlay_location.X += 5 + (this.Size.Width - this.RenderAreaPictureBox.Size.Width) / 2; - overlay_location.Y += 5 + (this.Size.Height - this.RenderAreaPictureBox.Size.Height) - (this.Size.Width - this.RenderAreaPictureBox.Size.Width) / 2; - - this.overlay.Size = overlay_size; - this.overlay.Location = overlay_location; - - } + this._overlay.SetOverlayLabel(label); } new public void Show() @@ -262,43 +317,31 @@ namespace EveOPreview { base.Show(); if (show_overlay) - this.overlay.Show(); + { + this._overlay.Show(); + this.MakeOverlayTopMost(); + } else - this.overlay.Hide(); + { + this._overlay.Hide(); + } } else { this.Hide(); - this.overlay.Hide(); } } new public void Hide() { base.Hide(); - this.overlay.Hide(); + this._overlay.Hide(); } - private void SetUpThumbnail() + new public void Close() { - if (DwmApiNativeMethods.DwmIsCompositionEnabled() && !thumbnail_has_been_set_up) - { - m_hThumbnail = DwmApiNativeMethods.DwmRegisterThumbnail(this.Handle, sourceWindow); - - m_ThumbnailProperties = new DWM_THUMBNAIL_PROPERTIES(); - m_ThumbnailProperties.dwFlags = DWM_THUMBNAIL_PROPERTIES.DWM_TNP_VISIBLE - + DWM_THUMBNAIL_PROPERTIES.DWM_TNP_OPACITY - + DWM_THUMBNAIL_PROPERTIES.DWM_TNP_RECTDESTINATION - + DWM_THUMBNAIL_PROPERTIES.DWM_TNP_SOURCECLIENTAREAONLY; - m_ThumbnailProperties.opacity = 255; - m_ThumbnailProperties.fVisible = true; - m_ThumbnailProperties.fSourceClientAreaOnly = true; - m_ThumbnailProperties.rcDestination = new RECT(0, 0, ClientRectangle.Right, ClientRectangle.Bottom); - - DwmApiNativeMethods.DwmUpdateThumbnailProperties(m_hThumbnail, m_ThumbnailProperties); - - thumbnail_has_been_set_up = true; - } + this._overlay.Close(); + base.Close(); } private void Preview_Load(object sender, EventArgs e) @@ -308,15 +351,15 @@ namespace EveOPreview public void bring_client_to_foreground() { - DwmApiNativeMethods.SetForegroundWindow(sourceWindow); - int style = DwmApiNativeMethods.GetWindowLong(sourceWindow, DwmApiNativeMethods.GWL_STYLE); + DwmApiNativeMethods.SetForegroundWindow(this._sourceWindow); + int style = DwmApiNativeMethods.GetWindowLong(this._sourceWindow, DwmApiNativeMethods.GWL_STYLE); if ((style & DwmApiNativeMethods.WS_MAXIMIZE) == DwmApiNativeMethods.WS_MAXIMIZE) { //It's maximized } else if ((style & DwmApiNativeMethods.WS_MINIMIZE) == DwmApiNativeMethods.WS_MINIMIZE) { - DwmApiNativeMethods.ShowWindowAsync(sourceWindow, DwmApiNativeMethods.SW_SHOWNORMAL); + DwmApiNativeMethods.ShowWindowAsync(this._sourceWindow, DwmApiNativeMethods.SW_SHOWNORMAL); } } @@ -325,7 +368,7 @@ namespace EveOPreview if (e.Button == MouseButtons.Left) { bring_client_to_foreground(); - spawner.preview_did_switch(); + this._parentForm.preview_did_switch(); } if (e.Button == MouseButtons.Right) { @@ -336,10 +379,5 @@ namespace EveOPreview // do smth cool? } } - - public void set_render_area_size(Size size) - { - this.Size = size; - } } } \ No newline at end of file diff --git a/Eve-O-Preview/Preview/PreviewOverlay.cs b/Eve-O-Preview/Preview/PreviewOverlay.cs index b3a11d5..a2aec56 100644 --- a/Eve-O-Preview/Preview/PreviewOverlay.cs +++ b/Eve-O-Preview/Preview/PreviewOverlay.cs @@ -1,25 +1,21 @@ -using System.Windows.Forms; +using System; +using System.Windows.Forms; namespace EveOPreview { public partial class PreviewOverlay : Form { - private readonly Preview _parent; + private readonly Action _areaClickAction; - public PreviewOverlay(Preview parent) + public PreviewOverlay(Action areaClickAction) { - this._parent = parent; + this._areaClickAction = areaClickAction; InitializeComponent(); } private void OverlayArea_Click(object sender, MouseEventArgs e) { - this._parent.render_area_Click(sender, e); - } - - public void MakeTopMost() - { - this.TopMost = true; + this._areaClickAction(sender, e); } public void SetOverlayLabel(string label) @@ -32,7 +28,7 @@ namespace EveOPreview get { var Params = base.CreateParams; - Params.ExStyle |= 0x80; + Params.ExStyle |= (int)DwmApiNativeMethods.WS_EX_TOOLWINDOW; return Params; } } From a6f5e2edec7a09d72821a04c061fc4a1f189be10 Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Sat, 14 May 2016 19:50:11 +0300 Subject: [PATCH 16/17] Provide better Preview API --- .../DwmAPI/DWM_THUMBNAIL_PROPERTIES.cs | 8 +- Eve-O-Preview/DwmAPI/DWM_TNP_CONSTANTS.cs | 11 + Eve-O-Preview/Eve-O-Preview.csproj | 23 +- Eve-O-Preview/GUI/MainForm.cs | 93 ++-- Eve-O-Preview/Preview/Preview.cs | 383 --------------- Eve-O-Preview/Thumbnail/IThumbnail.cs | 31 ++ Eve-O-Preview/Thumbnail/ThumbnailFactory.cs | 13 + .../ThumbnailOverlay.Designer.cs} | 4 +- .../ThumbnailOverlay.cs} | 4 +- .../ThumbnailOverlay.resx} | 0 .../ThumbnailWindow.Designer.cs} | 11 +- Eve-O-Preview/Thumbnail/ThumbnailWindow.cs | 437 ++++++++++++++++++ .../ThumbnailWindow.resx} | 0 13 files changed, 556 insertions(+), 462 deletions(-) create mode 100644 Eve-O-Preview/DwmAPI/DWM_TNP_CONSTANTS.cs delete mode 100644 Eve-O-Preview/Preview/Preview.cs create mode 100644 Eve-O-Preview/Thumbnail/IThumbnail.cs create mode 100644 Eve-O-Preview/Thumbnail/ThumbnailFactory.cs rename Eve-O-Preview/{Preview/PreviewOverlay.Designer.cs => Thumbnail/ThumbnailOverlay.Designer.cs} (95%) rename Eve-O-Preview/{Preview/PreviewOverlay.cs => Thumbnail/ThumbnailOverlay.cs} (79%) rename Eve-O-Preview/{Preview/PreviewOverlay.resx => Thumbnail/ThumbnailOverlay.resx} (100%) rename Eve-O-Preview/{Preview/Preview.Designer.cs => Thumbnail/ThumbnailWindow.Designer.cs} (89%) create mode 100644 Eve-O-Preview/Thumbnail/ThumbnailWindow.cs rename Eve-O-Preview/{Preview/Preview.resx => Thumbnail/ThumbnailWindow.resx} (100%) diff --git a/Eve-O-Preview/DwmAPI/DWM_THUMBNAIL_PROPERTIES.cs b/Eve-O-Preview/DwmAPI/DWM_THUMBNAIL_PROPERTIES.cs index b5d270a..5c12e31 100644 --- a/Eve-O-Preview/DwmAPI/DWM_THUMBNAIL_PROPERTIES.cs +++ b/Eve-O-Preview/DwmAPI/DWM_THUMBNAIL_PROPERTIES.cs @@ -3,7 +3,7 @@ using System.Runtime.InteropServices; namespace EveOPreview { [StructLayout(LayoutKind.Sequential)] - internal class DWM_THUMBNAIL_PROPERTIES + class DWM_THUMBNAIL_PROPERTIES { public uint dwFlags; public RECT rcDestination; @@ -13,11 +13,5 @@ namespace EveOPreview public bool fVisible; [MarshalAs(UnmanagedType.Bool)] public bool fSourceClientAreaOnly; - - public const uint DWM_TNP_RECTDESTINATION = 0x00000001; - public const uint DWM_TNP_RECTSOURCE = 0x00000002; - public const uint DWM_TNP_OPACITY = 0x00000004; - public const uint DWM_TNP_VISIBLE = 0x00000008; - public const uint DWM_TNP_SOURCECLIENTAREAONLY = 0x00000010; } } \ No newline at end of file diff --git a/Eve-O-Preview/DwmAPI/DWM_TNP_CONSTANTS.cs b/Eve-O-Preview/DwmAPI/DWM_TNP_CONSTANTS.cs new file mode 100644 index 0000000..7042770 --- /dev/null +++ b/Eve-O-Preview/DwmAPI/DWM_TNP_CONSTANTS.cs @@ -0,0 +1,11 @@ +namespace EveOPreview +{ + static class DWM_TNP_CONSTANTS + { + public const uint DWM_TNP_RECTDESTINATION = 0x00000001; + public const uint DWM_TNP_RECTSOURCE = 0x00000002; + public const uint DWM_TNP_OPACITY = 0x00000004; + public const uint DWM_TNP_VISIBLE = 0x00000008; + public const uint DWM_TNP_SOURCECLIENTAREAONLY = 0x00000010; + } +} \ No newline at end of file diff --git a/Eve-O-Preview/Eve-O-Preview.csproj b/Eve-O-Preview/Eve-O-Preview.csproj index f88d2a7..9e8f21c 100644 --- a/Eve-O-Preview/Eve-O-Preview.csproj +++ b/Eve-O-Preview/Eve-O-Preview.csproj @@ -105,6 +105,7 @@ + @@ -117,11 +118,13 @@ MainForm.cs - + + + Form - - PreviewOverlay.cs + + ThumbnailOverlay.cs @@ -129,17 +132,17 @@ Designer MainForm.cs - - PreviewOverlay.cs + + ThumbnailOverlay.cs ResXFileCodeGenerator Resources.Designer.cs Designer - + Designer - Preview.cs + ThumbnailWindow.cs True @@ -158,11 +161,11 @@ Settings.settings True - + Form - - Preview.cs + + ThumbnailWindow.cs diff --git a/Eve-O-Preview/GUI/MainForm.cs b/Eve-O-Preview/GUI/MainForm.cs index 3aa95aa..52f7249 100644 --- a/Eve-O-Preview/GUI/MainForm.cs +++ b/Eve-O-Preview/GUI/MainForm.cs @@ -12,12 +12,14 @@ namespace EveOPreview { public partial class MainForm : Form { + private readonly ThumbnailFactory _thumbnailFactory; + public event EventHandler Minimized; public event EventHandler Maximized; public event EventHandler Restored; - private readonly Dictionary _previews; + private readonly Dictionary _previews; private DispatcherTimer _dispatcherTimer; private IntPtr _activeClientHandle; @@ -43,7 +45,7 @@ namespace EveOPreview this._activeClientHandle = (IntPtr)0; this._activeClientTitle = ""; - _previews = new Dictionary(); + this._previews = new Dictionary(); _xmlBadToOkChars = new Dictionary(); _xmlBadToOkChars["<"] = "---lt---"; @@ -71,6 +73,8 @@ namespace EveOPreview _dispatcherTimer.Interval = new TimeSpan(0, 0, 1); _dispatcherTimer.Start(); + this._thumbnailFactory = new ThumbnailFactory(); + _isInitialized = true; previews_check_listbox.DisplayMember = "Text"; @@ -151,11 +155,11 @@ namespace EveOPreview if (!_previews.ContainsKey(process.MainWindowHandle) && process.MainWindowTitle != "") { - _previews[process.MainWindowHandle] = new Preview(this, process.MainWindowHandle, "...", sync_size); + _previews[process.MainWindowHandle] = this._thumbnailFactory.Create(this, process.MainWindowHandle, "...", sync_size); // apply more thumbnail specific options - _previews[process.MainWindowHandle].MakeTopMost(Properties.Settings.Default.always_on_top); - set_thumbnail_frame_style(_previews[process.MainWindowHandle], Properties.Settings.Default.show_thumb_frames); + _previews[process.MainWindowHandle].SetTopMost(Properties.Settings.Default.always_on_top); + _previews[process.MainWindowHandle].SetWindowFrames(Properties.Settings.Default.show_thumb_frames); // add a preview also previews_check_listbox.BeginUpdate(); @@ -165,14 +169,14 @@ namespace EveOPreview refresh_client_window_locations(process); } - else if (_previews.ContainsKey(process.MainWindowHandle) && process.MainWindowTitle != _previews[process.MainWindowHandle].Text) //or update the preview titles + else if (_previews.ContainsKey(process.MainWindowHandle) && process.MainWindowTitle != _previews[process.MainWindowHandle].GetLabel()) //or update the preview titles { _previews[process.MainWindowHandle].SetLabel(process.MainWindowTitle); - string key = _previews[process.MainWindowHandle].Text; + string key = _previews[process.MainWindowHandle].GetLabel(); string value; if (_flatLayoutShortcuts.TryGetValue(key, out value)) { - _previews[process.MainWindowHandle].registerShortcut(value); + _previews[process.MainWindowHandle].RegisterShortcut(value); } refresh_client_window_locations(process); } @@ -201,7 +205,7 @@ namespace EveOPreview previews_check_listbox.Items.Remove(_previews[processHandle]); previews_check_listbox.EndUpdate(); - _previews[processHandle].Close(); + _previews[processHandle].CloseThumbnail(); _previews.Remove(processHandle); } @@ -362,27 +366,27 @@ namespace EveOPreview el3.Save("client_layout.xml"); } - private void handle_unique_layout(Preview preview, string last_known_active_window) + private void handle_unique_layout(IThumbnail thumbnailWindow, string last_known_active_window) { Dictionary layout; if (_uniqueLayouts.TryGetValue(last_known_active_window, out layout)) { Point new_loc; - if (Properties.Settings.Default.unique_layout && layout.TryGetValue(preview.Text, out new_loc)) + if (Properties.Settings.Default.unique_layout && layout.TryGetValue(thumbnailWindow.GetLabel(), out new_loc)) { - preview.doMove(new_loc); + thumbnailWindow.SetLocation(new_loc); } else { // create inner dict - layout[preview.Text] = preview.Location; + layout[thumbnailWindow.GetLabel()] = thumbnailWindow.GetLocation(); } } else if (last_known_active_window != "") { // create outer dict _uniqueLayouts[last_known_active_window] = new Dictionary(); - _uniqueLayouts[last_known_active_window][preview.Text] = preview.Location; + _uniqueLayouts[last_known_active_window][thumbnailWindow.GetLabel()] = thumbnailWindow.GetLocation(); } } @@ -417,34 +421,34 @@ namespace EveOPreview } - public void preview_did_switch() + public void NotifyPreviewSwitch() { update_client_locations(); store_layout(); //todo: check if it actually changed ... - foreach (KeyValuePair entry in _previews) + foreach (KeyValuePair entry in _previews) { - entry.Value.MakeTopMost(Properties.Settings.Default.always_on_top); + entry.Value.SetTopMost(Properties.Settings.Default.always_on_top); } } - private void handle_flat_layout(Preview preview) + private void handle_flat_layout(IThumbnail thumbnailWindow) { Point layout; - if (_flatLayout.TryGetValue(preview.Text, out layout)) + if (_flatLayout.TryGetValue(thumbnailWindow.GetLabel(), out layout)) { - preview.doMove(layout); + thumbnailWindow.SetLocation(layout); } - else if (preview.Text != "") + else if (thumbnailWindow.GetLabel() != "") { - _flatLayout[preview.Text] = preview.Location; + _flatLayout[thumbnailWindow.GetLabel()] = thumbnailWindow.GetLocation(); } } private bool window_is_preview_or_client(IntPtr window) { bool active_window_is_right_type = false; - foreach (KeyValuePair entry in _previews) + foreach (KeyValuePair entry in _previews) { if (entry.Key == window || entry.Value.IsPreviewHandle(window)) { @@ -461,19 +465,19 @@ namespace EveOPreview IntPtr active_window = DwmApiNativeMethods.GetForegroundWindow(); // hide, show, resize and move - foreach (KeyValuePair entry in _previews) + foreach (KeyValuePair entry in _previews) { if (!window_is_preview_or_client(active_window) && Properties.Settings.Default.hide_all) { - entry.Value.Hide(); + entry.Value.HideThumbnail(); } else if (entry.Key == _activeClientHandle && Properties.Settings.Default.hide_active) { - entry.Value.Hide(); + entry.Value.HideThumbnail(); } else { - entry.Value.Show(); + entry.Value.ShowThumbnail(); if (Properties.Settings.Default.unique_layout) { handle_unique_layout(entry.Value, _activeClientTitle); @@ -483,19 +487,16 @@ namespace EveOPreview handle_flat_layout(entry.Value); } } - entry.Value.hover_zoom = Properties.Settings.Default.zoom_on_hover; - entry.Value.show_overlay = Properties.Settings.Default.show_overlay; - if (!entry.Value.is_hovered_over) - { - entry.Value.Opacity = Properties.Settings.Default.opacity; - } + entry.Value.IsZoomEnabled = Properties.Settings.Default.zoom_on_hover; + entry.Value.IsOverlayEnabled = Properties.Settings.Default.show_overlay; + entry.Value.SetOpacity(Properties.Settings.Default.opacity); } DwmApiNativeMethods.DwmIsCompositionEnabled(); } - public void syncronize_preview_size(Size sync_size) + public void SyncPreviewSize(Size sync_size) { if (!_isInitialized) { return; } @@ -508,9 +509,9 @@ namespace EveOPreview option_sync_size_x.Text = sync_size.Width.ToString(); option_sync_size_y.Text = sync_size.Height.ToString(); - foreach (KeyValuePair entry in _previews) + foreach (KeyValuePair entry in _previews) { - if (entry.Value.Handle != DwmApiNativeMethods.GetForegroundWindow()) + if (entry.Value.IsPreviewHandle(DwmApiNativeMethods.GetForegroundWindow())) { entry.Value.SetSize(sync_size); } @@ -521,7 +522,7 @@ namespace EveOPreview } - public void register_preview_position(string preview_title, Point position) + public void UpdatePreviewPosition(string preview_title, Point position) { if (Properties.Settings.Default.unique_layout) @@ -621,7 +622,7 @@ namespace EveOPreview Properties.Settings.Default.Save(); // resize - syncronize_preview_size(new Size((int)Properties.Settings.Default.sync_resize_x, + SyncPreviewSize(new Size((int)Properties.Settings.Default.sync_resize_x, (int)Properties.Settings.Default.sync_resize_y)); } @@ -646,18 +647,6 @@ namespace EveOPreview } - void set_thumbnail_frame_style(Preview preview, bool show_frames) - { - if (show_frames) - { - preview.FormBorderStyle = FormBorderStyle.SizableToolWindow; - } - else - { - preview.FormBorderStyle = FormBorderStyle.None; - } - } - private void option_show_thumbnail_frames_CheckedChanged(object sender, EventArgs e) { Properties.Settings.Default.show_thumb_frames = option_show_thumbnail_frames.Checked; @@ -672,7 +661,7 @@ namespace EveOPreview foreach (var thumbnail in _previews) { - set_thumbnail_frame_style(thumbnail.Value, Properties.Settings.Default.show_thumb_frames); + thumbnail.Value.SetWindowFrames(Properties.Settings.Default.show_thumb_frames); } } @@ -763,7 +752,7 @@ namespace EveOPreview private void checkedListBox1_SelectedIndexChanged2(object sender, EventArgs e) { System.Windows.Forms.ItemCheckEventArgs arg = (System.Windows.Forms.ItemCheckEventArgs)e; - ((Preview)this.previews_check_listbox.Items[arg.Index]).MakeHidden(arg.NewValue == System.Windows.Forms.CheckState.Checked); + ((ThumbnailWindow)this.previews_check_listbox.Items[arg.Index]).IsPreviewEnabled = (arg.NewValue != System.Windows.Forms.CheckState.Checked); refresh_thumbnails(); } diff --git a/Eve-O-Preview/Preview/Preview.cs b/Eve-O-Preview/Preview/Preview.cs deleted file mode 100644 index 5e2e654..0000000 --- a/Eve-O-Preview/Preview/Preview.cs +++ /dev/null @@ -1,383 +0,0 @@ -using System; -using System.Drawing; -using System.Windows.Forms; - -namespace EveOPreview -{ - public partial class Preview : Form - { - #region Private fields - private readonly bool _isInitializing; - private readonly IntPtr _sourceWindow; - private readonly MainForm _parentForm; - private readonly PreviewOverlay _overlay; - - private Size _normalSize; - private Point _normalPosition; - - private bool _isThumbnailSetUp; - private DWM_THUMBNAIL_PROPERTIES _Thumbnail; - private IntPtr _ThumbnailHandle; - #endregion - - // TODO Hide the parent form behind an interface - public Preview(MainForm parent, IntPtr sourceWindow, String title, Size size) - { - this._isInitializing = true; - - this._sourceWindow = sourceWindow; - this._parentForm = parent; - - this._isThumbnailSetUp = false; - - InitializeComponent(); - - this.Text = title; - - this._overlay = new PreviewOverlay(this.render_area_Click); - - this._isInitializing = false; - - this.SetSize(size); - } - - public bool IsPreviewHandle(IntPtr handle) - { - return (this.Handle == handle) || (this._overlay.Handle == handle); - } - - public void SetSize(Size size) - { - this.Size = size; - this._normalSize = this.Size; - this._normalPosition = this.Location; - } - - public void MakeTopMost(bool topmost) - { - if (!this.hide) - { - return; - } - - this.TopMost = topmost; - this.MakeOverlayTopMost(); - } - - protected override CreateParams CreateParams - { - get - { - var Params = base.CreateParams; - Params.ExStyle |= (int)DwmApiNativeMethods.WS_EX_TOOLWINDOW; - return Params; - } - } - - private void MakeOverlayTopMost() - { - this._overlay.TopMost = true; - } - - private void RefreshPreview() - { - if (this._isInitializing) - { - return; - } - - if (DwmApiNativeMethods.DwmIsCompositionEnabled()) - { - if (this._isThumbnailSetUp == false) - { - this.SetUpThumbnail(); - } - - this._Thumbnail.rcDestination = new RECT(0, 0, this.ClientRectangle.Right, this.ClientRectangle.Bottom); - DwmApiNativeMethods.DwmUpdateThumbnailProperties(this._ThumbnailHandle, this._Thumbnail); - } - else - { - this._isThumbnailSetUp = false; - } - - Size overlaySize = this.RenderAreaPictureBox.Size; - overlaySize.Width -= 2 * 5; - overlaySize.Height -= 2 * 5; - - Point overlayLocation = this.Location; - overlayLocation.X += 5 + (this.Size.Width - this.RenderAreaPictureBox.Size.Width) / 2; - overlayLocation.Y += 5 + (this.Size.Height - this.RenderAreaPictureBox.Size.Height) - (this.Size.Width - this.RenderAreaPictureBox.Size.Width) / 2; - - this._overlay.Size = overlaySize; - this._overlay.Location = overlayLocation; - } - - private void SetUpThumbnail() - { - // TODO Remove this API call on Win 8+ hosts - if (this._isThumbnailSetUp || !DwmApiNativeMethods.DwmIsCompositionEnabled()) - { - return; - } - - this._ThumbnailHandle = DwmApiNativeMethods.DwmRegisterThumbnail(this.Handle, this._sourceWindow); - - this._Thumbnail = new DWM_THUMBNAIL_PROPERTIES(); - this._Thumbnail.dwFlags = DWM_THUMBNAIL_PROPERTIES.DWM_TNP_VISIBLE - + DWM_THUMBNAIL_PROPERTIES.DWM_TNP_OPACITY - + DWM_THUMBNAIL_PROPERTIES.DWM_TNP_RECTDESTINATION - + DWM_THUMBNAIL_PROPERTIES.DWM_TNP_SOURCECLIENTAREAONLY; - this._Thumbnail.opacity = 255; - this._Thumbnail.fVisible = true; - this._Thumbnail.fSourceClientAreaOnly = true; - this._Thumbnail.rcDestination = new RECT(0, 0, ClientRectangle.Right, ClientRectangle.Bottom); - - DwmApiNativeMethods.DwmUpdateThumbnailProperties(_ThumbnailHandle, _Thumbnail); - - _isThumbnailSetUp = true; - } - - - public bool show_overlay = true; - public bool hover_zoom = true; - public bool is_zoomed = false; - public bool is_hovered_over = false; - - private bool mouse_over_lock = false; - - - private Hotkey hotkey; - - private bool hide = false; - - public void MakeHidden(bool wha) - { - hide = wha; - } - - public override string ToString() - { - return this.Text; - } - - public void preview_MouseHover(object sender, System.EventArgs e) - { - if (!mouse_over_lock) - { - mouse_over_lock = true; - if (hover_zoom) - doZoom(); - - this.MakeTopMost(true); - } - this.Opacity = 1.0f; - this.is_hovered_over = true; - RefreshPreview(); - } - - public void registerShortcut(string shortcut) - { - if (shortcut == "") - return; - var cvt = new KeysConverter(); - var key = (Keys)cvt.ConvertFrom(shortcut); - - Hotkey hotkey = new Hotkey(); - - if ((key & Keys.Shift) == Keys.Shift) - { - hotkey.Shift = true; - } - if ((key & Keys.Alt) == Keys.Alt) - { - hotkey.Alt = true; - } - if ((key & Keys.Control) == Keys.Control) - { - hotkey.Control = true; - } - - key = key & ~Keys.Shift & ~Keys.Alt & ~Keys.Control; - hotkey.KeyCode = key; - hotkey.Register(this); - // TODO Make this a method - hotkey.Pressed += (s, e) => { bring_client_to_foreground(); this._parentForm.preview_did_switch(); }; - - this.hotkey = hotkey; - } - - public void doZoom() - { - if (is_zoomed) - return; - - is_zoomed = true; - - float hover_zoom_factor = Properties.Settings.Default.zoom_amount; - - _normalSize = Size; - _normalPosition = Location; - - Size = new Size((int)(hover_zoom_factor * (float)Size.Width), (int)(hover_zoom_factor * (float)Size.Height)); - - switch ((ZoomAnchor)Properties.Settings.Default.zoom_anchor) - { - case (ZoomAnchor.NW): - break; - case (ZoomAnchor.N): - Location = new Point(Location.X - Size.Width / 2 + _normalSize.Width / 2, Location.Y); - break; - case (ZoomAnchor.NE): - Location = new Point(Location.X - Size.Width + _normalSize.Width, Location.Y); - break; - - case (ZoomAnchor.W): - Location = new Point(Location.X, Location.Y - Size.Height / 2 + _normalSize.Height / 2); - break; - case (ZoomAnchor.C): - Location = new Point(Location.X - Size.Width / 2 + _normalSize.Width / 2, Location.Y - Size.Height / 2 + _normalSize.Height / 2); - break; - case (ZoomAnchor.E): - Location = new Point(Location.X - Size.Width + _normalSize.Width, Location.Y - Size.Height / 2 + _normalSize.Height / 2); - break; - - case (ZoomAnchor.SW): - Location = new Point(Location.X, Location.Y - Size.Height + _normalSize.Height); - break; - case (ZoomAnchor.S): - Location = new Point(Location.X - Size.Width / 2 + _normalSize.Width / 2, Location.Y - Size.Height + _normalSize.Height); - break; - case (ZoomAnchor.SE): - Location = new Point(Location.X - Size.Width + _normalSize.Width, Location.Y - Size.Height + _normalSize.Height); - break; - } - } - - public void restoreZoom() - { - if (!is_zoomed) - return; - - Size = _normalSize; - Location = _normalPosition; - is_zoomed = false; - } - - public void preview_MouseLeave(object sender, System.EventArgs e) - { - if (mouse_over_lock) - { - if (hover_zoom) - { - restoreZoom(); - } - mouse_over_lock = false; - } - this.is_hovered_over = false; - this.Opacity = Properties.Settings.Default.opacity; - RefreshPreview(); - } - - protected override void OnResize(EventArgs e) - { - RefreshPreview(); - base.OnResize(e); - - if (!this._isInitializing && !mouse_over_lock) - this._parentForm.syncronize_preview_size(this.Size); - } - - protected override void OnMove(EventArgs e) - { - base.OnMove(e); - if (!this._isInitializing && !mouse_over_lock) - this._parentForm.register_preview_position(this.Text, this.Location); - - RefreshPreview(); - } - - public void doMove(Point position) - { - if (!this._isInitializing && !mouse_over_lock) - Location = position; - - RefreshPreview(); - } - - public void SetLabel(String label) - { - this.Text = label; - this._overlay.SetOverlayLabel(label); - } - - new public void Show() - { - if (!hide) - { - base.Show(); - if (show_overlay) - { - this._overlay.Show(); - this.MakeOverlayTopMost(); - } - else - { - this._overlay.Hide(); - } - } - else - { - this.Hide(); - } - } - - new public void Hide() - { - base.Hide(); - this._overlay.Hide(); - } - - new public void Close() - { - this._overlay.Close(); - base.Close(); - } - - private void Preview_Load(object sender, EventArgs e) - { - - } - - public void bring_client_to_foreground() - { - DwmApiNativeMethods.SetForegroundWindow(this._sourceWindow); - int style = DwmApiNativeMethods.GetWindowLong(this._sourceWindow, DwmApiNativeMethods.GWL_STYLE); - if ((style & DwmApiNativeMethods.WS_MAXIMIZE) == DwmApiNativeMethods.WS_MAXIMIZE) - { - //It's maximized - } - else if ((style & DwmApiNativeMethods.WS_MINIMIZE) == DwmApiNativeMethods.WS_MINIMIZE) - { - DwmApiNativeMethods.ShowWindowAsync(this._sourceWindow, DwmApiNativeMethods.SW_SHOWNORMAL); - } - } - - public void render_area_Click(object sender, MouseEventArgs e) - { - if (e.Button == MouseButtons.Left) - { - bring_client_to_foreground(); - this._parentForm.preview_did_switch(); - } - if (e.Button == MouseButtons.Right) - { - // do smth cool? - } - if (e.Button == MouseButtons.Middle) - { - // do smth cool? - } - } - } -} \ No newline at end of file diff --git a/Eve-O-Preview/Thumbnail/IThumbnail.cs b/Eve-O-Preview/Thumbnail/IThumbnail.cs new file mode 100644 index 0000000..1b396c4 --- /dev/null +++ b/Eve-O-Preview/Thumbnail/IThumbnail.cs @@ -0,0 +1,31 @@ +using System; +using System.Drawing; + +namespace EveOPreview +{ + public interface IThumbnail + { + bool IsZoomEnabled { get; set; } + bool IsPreviewEnabled { get; set; } + bool IsOverlayEnabled { get; set; } + + bool IsPreviewHandle(IntPtr handle); + + void ShowThumbnail(); + void HideThumbnail(); + void CloseThumbnail(); + + void RegisterShortcut(string shortcut); + + void SetLabel(string label); + string GetLabel(); + + void SetLocation(Point location); + Point GetLocation(); + + void SetOpacity(double opacity); + void SetTopMost(bool topmost); + void SetWindowFrames(bool enable); + void SetSize(Size size); + } +} \ No newline at end of file diff --git a/Eve-O-Preview/Thumbnail/ThumbnailFactory.cs b/Eve-O-Preview/Thumbnail/ThumbnailFactory.cs new file mode 100644 index 0000000..a603043 --- /dev/null +++ b/Eve-O-Preview/Thumbnail/ThumbnailFactory.cs @@ -0,0 +1,13 @@ +using System; +using System.Drawing; + +namespace EveOPreview +{ + public class ThumbnailFactory + { + public IThumbnail Create(MainForm parent, IntPtr sourceWindow, string title, Size size) + { + return new ThumbnailWindow(parent, sourceWindow, title, size); + } + } +} \ No newline at end of file diff --git a/Eve-O-Preview/Preview/PreviewOverlay.Designer.cs b/Eve-O-Preview/Thumbnail/ThumbnailOverlay.Designer.cs similarity index 95% rename from Eve-O-Preview/Preview/PreviewOverlay.Designer.cs rename to Eve-O-Preview/Thumbnail/ThumbnailOverlay.Designer.cs index d49b54f..fee5bc5 100644 --- a/Eve-O-Preview/Preview/PreviewOverlay.Designer.cs +++ b/Eve-O-Preview/Thumbnail/ThumbnailOverlay.Designer.cs @@ -1,6 +1,6 @@ namespace EveOPreview { - partial class PreviewOverlay + partial class ThumbnailOverlay { /// /// Required designer variable. @@ -71,7 +71,7 @@ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.MaximizeBox = false; this.MinimizeBox = false; - this.Name = "PreviewOverlay"; + this.Name = "ThumbnailOverlay"; this.ShowIcon = false; this.ShowInTaskbar = false; this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; diff --git a/Eve-O-Preview/Preview/PreviewOverlay.cs b/Eve-O-Preview/Thumbnail/ThumbnailOverlay.cs similarity index 79% rename from Eve-O-Preview/Preview/PreviewOverlay.cs rename to Eve-O-Preview/Thumbnail/ThumbnailOverlay.cs index a2aec56..434b648 100644 --- a/Eve-O-Preview/Preview/PreviewOverlay.cs +++ b/Eve-O-Preview/Thumbnail/ThumbnailOverlay.cs @@ -3,11 +3,11 @@ using System.Windows.Forms; namespace EveOPreview { - public partial class PreviewOverlay : Form + public partial class ThumbnailOverlay : Form { private readonly Action _areaClickAction; - public PreviewOverlay(Action areaClickAction) + public ThumbnailOverlay(Action areaClickAction) { this._areaClickAction = areaClickAction; InitializeComponent(); diff --git a/Eve-O-Preview/Preview/PreviewOverlay.resx b/Eve-O-Preview/Thumbnail/ThumbnailOverlay.resx similarity index 100% rename from Eve-O-Preview/Preview/PreviewOverlay.resx rename to Eve-O-Preview/Thumbnail/ThumbnailOverlay.resx diff --git a/Eve-O-Preview/Preview/Preview.Designer.cs b/Eve-O-Preview/Thumbnail/ThumbnailWindow.Designer.cs similarity index 89% rename from Eve-O-Preview/Preview/Preview.Designer.cs rename to Eve-O-Preview/Thumbnail/ThumbnailWindow.Designer.cs index d33bce3..0134590 100644 --- a/Eve-O-Preview/Preview/Preview.Designer.cs +++ b/Eve-O-Preview/Thumbnail/ThumbnailWindow.Designer.cs @@ -1,6 +1,6 @@ namespace EveOPreview { - partial class Preview + partial class ThumbnailWindow { /// /// Required designer variable. @@ -31,9 +31,9 @@ namespace EveOPreview this.RenderAreaPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; this.RenderAreaPictureBox.TabIndex = 0; this.RenderAreaPictureBox.TabStop = false; - this.RenderAreaPictureBox.MouseLeave += new System.EventHandler(this.preview_MouseLeave); - this.RenderAreaPictureBox.MouseHover += new System.EventHandler(this.preview_MouseHover); - this.RenderAreaPictureBox.MouseUp += new System.Windows.Forms.MouseEventHandler(this.render_area_Click); + this.RenderAreaPictureBox.MouseLeave += new System.EventHandler(this.Preview_MouseLeave); + this.RenderAreaPictureBox.MouseHover += new System.EventHandler(this.Preview_MouseHover); + this.RenderAreaPictureBox.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Preview_Click); // // Preview // @@ -47,13 +47,12 @@ namespace EveOPreview this.MaximizeBox = false; this.MinimizeBox = false; this.MinimumSize = new System.Drawing.Size(64, 64); - this.Name = "Preview"; + this.Name = "ThumbnailWindow"; this.Opacity = 0.1D; this.ShowIcon = false; this.ShowInTaskbar = false; this.Text = "Preview"; this.TopMost = true; - this.Load += new System.EventHandler(this.Preview_Load); ((System.ComponentModel.ISupportInitialize)(this.RenderAreaPictureBox)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); diff --git a/Eve-O-Preview/Thumbnail/ThumbnailWindow.cs b/Eve-O-Preview/Thumbnail/ThumbnailWindow.cs new file mode 100644 index 0000000..71c05c9 --- /dev/null +++ b/Eve-O-Preview/Thumbnail/ThumbnailWindow.cs @@ -0,0 +1,437 @@ +using System; +using System.Drawing; +using System.Windows.Forms; + +namespace EveOPreview +{ + public partial class ThumbnailWindow : Form, IThumbnail + { + #region Private fields + private readonly bool _isInitializing; + private readonly IntPtr _sourceWindow; + private readonly MainForm _parentForm; + private readonly ThumbnailOverlay _overlay; + private Hotkey _hotkey; // This field stores the hotkey reference + + private Size _baseSize; + private Point _basePosition; + + private bool _isThumbnailSetUp; + private DWM_THUMBNAIL_PROPERTIES _Thumbnail; + private IntPtr _ThumbnailHandle; + + private bool _ignoreMouseOverEvent; + private bool _isHoverEffectActive; + private bool _isZoomActive; + #endregion + + // This constructor should never be used directly + public ThumbnailWindow(MainForm parent, IntPtr sourceWindow, string title, Size size) + { + this._isInitializing = true; + + this.IsPreviewEnabled = true; + this.IsOverlayEnabled = true; + + this._sourceWindow = sourceWindow; + this._parentForm = parent; + + this._isThumbnailSetUp = false; + this._ignoreMouseOverEvent = false; + this._isHoverEffectActive = false; + this._isZoomActive = false; + + InitializeComponent(); + + this.Text = title; + + this._overlay = new ThumbnailOverlay(this.Preview_Click); + + this._isInitializing = false; + + this.SetSize(size); + } + + public bool IsZoomEnabled { get; set; } + + public bool IsPreviewEnabled { get; set; } + + public bool IsOverlayEnabled { get; set; } + + public bool IsPreviewHandle(IntPtr handle) + { + return (this.Handle == handle) || (this._overlay.Handle == handle); + } + + public void ShowThumbnail() + { + if (this.IsPreviewEnabled) + { + this.Show(); + if (this.IsOverlayEnabled) + { + this._overlay.Show(); + this.MakeOverlayTopMost(); + } + else + { + this._overlay.Hide(); + } + } + else + { + this.HideThumbnail(); + } + } + + public void HideThumbnail() + { + this.Hide(); + this._overlay.Hide(); + } + + public void CloseThumbnail() + { + this._overlay.Close(); + this.Close(); + } + + public void SetLabel(string label) + { + this.Text = label; + this._overlay.SetOverlayLabel(label); + } + + public string GetLabel() + { + return this.Text; + } + + public void SetSize(Size size) + { + this.Size = size; + this._baseSize = this.Size; + this._basePosition = this.Location; + } + + public void SetLocation(Point location) + { + if (!(this._isInitializing || this._ignoreMouseOverEvent)) + { + this.Location = location; + } + + this.RefreshPreview(); + } + + public Point GetLocation() + { + return this.Location; + } + + public void SetOpacity(double opacity) + { + if (this._isHoverEffectActive) + { + return; + } + + this.Opacity = opacity; + } + + public void RegisterShortcut(string shortcut) + { + if (String.IsNullOrEmpty(shortcut)) + { + return; + } + + KeysConverter converter = new KeysConverter(); + object keysObject = converter.ConvertFrom(shortcut); + if (keysObject == null) + { + return; + } + + Keys key = (Keys)keysObject; + + Hotkey hotkey = new Hotkey(); + + if ((key & Keys.Shift) == Keys.Shift) + { + hotkey.Shift = true; + } + + if ((key & Keys.Alt) == Keys.Alt) + { + hotkey.Alt = true; + } + + if ((key & Keys.Control) == Keys.Control) + { + hotkey.Control = true; + } + + key = key & ~Keys.Shift & ~Keys.Alt & ~Keys.Control; + hotkey.KeyCode = key; + hotkey.Pressed += Hotkey_Pressed; + hotkey.Register(this); + + this._hotkey = hotkey; + } + + public void SetTopMost(bool topmost) + { + if (!this.IsPreviewEnabled) + { + return; + } + + this.TopMost = topmost; + this.MakeOverlayTopMost(); + } + + public void SetWindowFrames(bool enable) + { + this.FormBorderStyle = enable ? FormBorderStyle.SizableToolWindow : FormBorderStyle.None; + } + + protected override CreateParams CreateParams + { + get + { + var Params = base.CreateParams; + Params.ExStyle |= (int)DwmApiNativeMethods.WS_EX_TOOLWINDOW; + return Params; + } + } + + private void Preview_MouseHover(object sender, EventArgs e) + { + if (!this._ignoreMouseOverEvent) + { + this._ignoreMouseOverEvent = true; + if (this.IsZoomEnabled) + { + this.ZoomIn(); + } + + this.SetTopMost(true); + } + + this.Opacity = 1.0f; + this._isHoverEffectActive = true; + + this.RefreshPreview(); + } + + private void Preview_MouseLeave(object sender, EventArgs e) + { + if (this._ignoreMouseOverEvent) + { + if (this.IsZoomEnabled) + { + this.ZoomOut(); + } + + this._ignoreMouseOverEvent = false; + } + + this._isHoverEffectActive = false; + this.Opacity = Properties.Settings.Default.opacity; // TODO Use local object + + this.RefreshPreview(); + } + + private void Preview_Click(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + this.ActivateClient(); + this._parentForm.NotifyPreviewSwitch(); + } + + if (e.Button == MouseButtons.Right) + { + // do smth cool? + } + + if (e.Button == MouseButtons.Middle) + { + // do smth cool? + } + } + + private void Hotkey_Pressed(Object sender, EventArgs e) + { + this.ActivateClient(); + this._parentForm.NotifyPreviewSwitch(); + } + + protected override void OnResize(EventArgs e) + { + this.RefreshPreview(); + + base.OnResize(e); + + if (!(this._isInitializing || this._ignoreMouseOverEvent)) + { + this._parentForm.SyncPreviewSize(this.Size); + } + } + + protected override void OnMove(EventArgs e) + { + base.OnMove(e); + + if (!(this._isInitializing || this._ignoreMouseOverEvent)) + { + this._parentForm.UpdatePreviewPosition(this.Text, this.Location); + } + + this.RefreshPreview(); + } + + private void MakeOverlayTopMost() + { + this._overlay.TopMost = true; + } + + private void RefreshPreview() + { + if (this._isInitializing) + { + return; + } + + if (DwmApiNativeMethods.DwmIsCompositionEnabled()) + { + if (this._isThumbnailSetUp == false) + { + this.SetUpThumbnail(); + } + + this._Thumbnail.rcDestination = new RECT(0, 0, this.ClientRectangle.Right, this.ClientRectangle.Bottom); + DwmApiNativeMethods.DwmUpdateThumbnailProperties(this._ThumbnailHandle, this._Thumbnail); + } + else + { + this._isThumbnailSetUp = false; + } + + Size overlaySize = this.RenderAreaPictureBox.Size; + overlaySize.Width -= 2 * 5; + overlaySize.Height -= 2 * 5; + + Point overlayLocation = this.Location; + overlayLocation.X += 5 + (this.Size.Width - this.RenderAreaPictureBox.Size.Width) / 2; + overlayLocation.Y += 5 + (this.Size.Height - this.RenderAreaPictureBox.Size.Height) - (this.Size.Width - this.RenderAreaPictureBox.Size.Width) / 2; + + this._overlay.Size = overlaySize; + this._overlay.Location = overlayLocation; + } + + private void SetUpThumbnail() + { + if (this._isThumbnailSetUp || !DwmApiNativeMethods.DwmIsCompositionEnabled()) + { + return; + } + + this._ThumbnailHandle = DwmApiNativeMethods.DwmRegisterThumbnail(this.Handle, this._sourceWindow); + + this._Thumbnail = new DWM_THUMBNAIL_PROPERTIES(); + this._Thumbnail.dwFlags = DWM_TNP_CONSTANTS.DWM_TNP_VISIBLE + + DWM_TNP_CONSTANTS.DWM_TNP_OPACITY + + DWM_TNP_CONSTANTS.DWM_TNP_RECTDESTINATION + + DWM_TNP_CONSTANTS.DWM_TNP_SOURCECLIENTAREAONLY; + this._Thumbnail.opacity = 255; + this._Thumbnail.fVisible = true; + this._Thumbnail.fSourceClientAreaOnly = true; + this._Thumbnail.rcDestination = new RECT(0, 0, this.ClientRectangle.Right, this.ClientRectangle.Bottom); + + DwmApiNativeMethods.DwmUpdateThumbnailProperties(this._ThumbnailHandle, this._Thumbnail); + + this._isThumbnailSetUp = true; + } + + private void ZoomIn() + { + if (this._isZoomActive) + { + return; + } + + this._isZoomActive = true; + + // TODO Use global settings object + float zoomFactor = Properties.Settings.Default.zoom_amount; + + this._baseSize = this.Size; + this._basePosition = this.Location; + + this.Size = new Size((int)(zoomFactor * this.Size.Width), (int)(zoomFactor * this.Size.Height)); + + // TODO Use global settings object + switch ((ZoomAnchor)Properties.Settings.Default.zoom_anchor) + { + case ZoomAnchor.NW: + break; + case ZoomAnchor.N: + this.Location = new Point(this.Location.X - this.Size.Width / 2 + this._baseSize.Width / 2, this.Location.Y); + break; + case ZoomAnchor.NE: + this.Location = new Point(this.Location.X - this.Size.Width + this._baseSize.Width, this.Location.Y); + break; + + case ZoomAnchor.W: + this.Location = new Point(this.Location.X, this.Location.Y - this.Size.Height / 2 + this._baseSize.Height / 2); + break; + case ZoomAnchor.C: + this.Location = new Point(this.Location.X - this.Size.Width / 2 + this._baseSize.Width / 2, this.Location.Y - this.Size.Height / 2 + this._baseSize.Height / 2); + break; + case ZoomAnchor.E: + this.Location = new Point(this.Location.X - this.Size.Width + this._baseSize.Width, this.Location.Y - this.Size.Height / 2 + this._baseSize.Height / 2); + break; + + case ZoomAnchor.SW: + this.Location = new Point(this.Location.X, this.Location.Y - this.Size.Height + this._baseSize.Height); + break; + case ZoomAnchor.S: + this.Location = new Point(this.Location.X - this.Size.Width / 2 + this._baseSize.Width / 2, this.Location.Y - this.Size.Height + this._baseSize.Height); + break; + case ZoomAnchor.SE: + this.Location = new Point(this.Location.X - this.Size.Width + this._baseSize.Width, this.Location.Y - this.Size.Height + this._baseSize.Height); + break; + } + } + + private void ZoomOut() + { + if (!this._isZoomActive) + { + return; + } + + this.Size = this._baseSize; + this.Location = this._basePosition; + + this._isZoomActive = false; + } + + private void ActivateClient() + { + DwmApiNativeMethods.SetForegroundWindow(this._sourceWindow); + + int style = DwmApiNativeMethods.GetWindowLong(this._sourceWindow, DwmApiNativeMethods.GWL_STYLE); + if ((style & DwmApiNativeMethods.WS_MAXIMIZE) == DwmApiNativeMethods.WS_MAXIMIZE) + { + // Client is already maximized, no action is required + } + else if ((style & DwmApiNativeMethods.WS_MINIMIZE) == DwmApiNativeMethods.WS_MINIMIZE) + { + DwmApiNativeMethods.ShowWindowAsync(this._sourceWindow, DwmApiNativeMethods.SW_SHOWNORMAL); + } + } + } +} \ No newline at end of file diff --git a/Eve-O-Preview/Preview/Preview.resx b/Eve-O-Preview/Thumbnail/ThumbnailWindow.resx similarity index 100% rename from Eve-O-Preview/Preview/Preview.resx rename to Eve-O-Preview/Thumbnail/ThumbnailWindow.resx From a8a93b11ba612e9dfdc1a7c31b70b146bbc90040 Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Fri, 20 May 2016 21:41:58 +0300 Subject: [PATCH 17/17] Extreact Thumbnail and Settings management code from main form --- Eve-O-Preview/Configuration/Configuration.cs | 7 + .../Configuration/ConfigurationStorage.cs | 7 + Eve-O-Preview/Eve-O-Preview.csproj | 3 + Eve-O-Preview/GUI/MainForm.cs | 617 ++++-------------- Eve-O-Preview/Thumbnail/ThumbnailFactory.cs | 4 +- Eve-O-Preview/Thumbnail/ThumbnailManager.cs | 507 ++++++++++++++ Eve-O-Preview/Thumbnail/ThumbnailWindow.cs | 14 +- 7 files changed, 644 insertions(+), 515 deletions(-) create mode 100644 Eve-O-Preview/Configuration/Configuration.cs create mode 100644 Eve-O-Preview/Configuration/ConfigurationStorage.cs create mode 100644 Eve-O-Preview/Thumbnail/ThumbnailManager.cs diff --git a/Eve-O-Preview/Configuration/Configuration.cs b/Eve-O-Preview/Configuration/Configuration.cs new file mode 100644 index 0000000..62d40ec --- /dev/null +++ b/Eve-O-Preview/Configuration/Configuration.cs @@ -0,0 +1,7 @@ +namespace EveOPreview +{ + public class Configuration + { + + } +} \ No newline at end of file diff --git a/Eve-O-Preview/Configuration/ConfigurationStorage.cs b/Eve-O-Preview/Configuration/ConfigurationStorage.cs new file mode 100644 index 0000000..974930e --- /dev/null +++ b/Eve-O-Preview/Configuration/ConfigurationStorage.cs @@ -0,0 +1,7 @@ +namespace EveOPreview.Managers +{ + public class ConfigurationStorage + { + + } +} \ No newline at end of file diff --git a/Eve-O-Preview/Eve-O-Preview.csproj b/Eve-O-Preview/Eve-O-Preview.csproj index 9e8f21c..99848fb 100644 --- a/Eve-O-Preview/Eve-O-Preview.csproj +++ b/Eve-O-Preview/Eve-O-Preview.csproj @@ -110,6 +110,7 @@ + @@ -118,8 +119,10 @@ MainForm.cs + + Form diff --git a/Eve-O-Preview/GUI/MainForm.cs b/Eve-O-Preview/GUI/MainForm.cs index 52f7249..902c16a 100644 --- a/Eve-O-Preview/GUI/MainForm.cs +++ b/Eve-O-Preview/GUI/MainForm.cs @@ -12,29 +12,13 @@ namespace EveOPreview { public partial class MainForm : Form { - private readonly ThumbnailFactory _thumbnailFactory; - public event EventHandler Minimized; public event EventHandler Maximized; public event EventHandler Restored; - - private readonly Dictionary _previews; - private DispatcherTimer _dispatcherTimer; - - private IntPtr _activeClientHandle; - private string _activeClientTitle; - - private readonly Dictionary> _uniqueLayouts; - private readonly Dictionary _flatLayout; - private readonly Dictionary _flatLayoutShortcuts; - private readonly Dictionary _clientLayout; - private readonly bool _isInitialized; + private readonly ThumbnailManager _manager; - private readonly Stopwatch _ignoringSizeSync; - - private readonly Dictionary _xmlBadToOkChars; private Dictionary _zoomAnchorButtonMap; @@ -42,49 +26,63 @@ namespace EveOPreview { _isInitialized = false; - this._activeClientHandle = (IntPtr)0; - this._activeClientTitle = ""; - - this._previews = new Dictionary(); - - _xmlBadToOkChars = new Dictionary(); - _xmlBadToOkChars["<"] = "---lt---"; - _xmlBadToOkChars["&"] = "---amp---"; - _xmlBadToOkChars[">"] = "---gt---"; - _xmlBadToOkChars["\""] = "---quot---"; - _xmlBadToOkChars["\'"] = "---apos---"; - _xmlBadToOkChars[","] = "---comma---"; - _xmlBadToOkChars["."] = "---dot---"; - - _uniqueLayouts = new Dictionary>(); - _flatLayout = new Dictionary(); - _flatLayoutShortcuts = new Dictionary(); - _clientLayout = new Dictionary(); - - _ignoringSizeSync = new Stopwatch(); - _ignoringSizeSync.Start(); - InitializeComponent(); init_options(); - // DispatcherTimer setup - _dispatcherTimer = new DispatcherTimer(); - _dispatcherTimer.Tick += dispatcherTimer_Tick; - _dispatcherTimer.Interval = new TimeSpan(0, 0, 1); - _dispatcherTimer.Start(); + // TODO Fix this + previews_check_listbox.DisplayMember = "Text"; - this._thumbnailFactory = new ThumbnailFactory(); + this._manager = new ThumbnailManager(add_thumbnail,remove_thumbnail, set_aero_status, set_size); _isInitialized = true; - previews_check_listbox.DisplayMember = "Text"; - + this._manager.Activate(); } + private void add_thumbnail(IList thumbnails) + { + this.previews_check_listbox.BeginUpdate(); + foreach (string th in thumbnails) + { + previews_check_listbox.Items.Add(th); + } + this.previews_check_listbox.EndUpdate(); + } + + private void remove_thumbnail(IList thumbnails) + { + this.previews_check_listbox.BeginUpdate(); + foreach (string th in thumbnails) + { + previews_check_listbox.Items.Remove(th); + } + this.previews_check_listbox.EndUpdate(); + } + + private void set_aero_status(bool value) + { + + if (value) + { + aero_status_label.Text = "AERO is ON"; + aero_status_label.ForeColor = Color.Black; + } + else + { + aero_status_label.Text = "AERO is OFF"; + aero_status_label.ForeColor = Color.Red; + } + } + + private void set_size(int x, int y) + { + option_sync_size_x.Text = x.ToString(); + option_sync_size_y.Text = y.ToString(); + } private void GlassForm_Load(object sender, EventArgs e) { - refresh_thumbnails(); + this._manager.refresh_thumbnails(); } private void init_options() @@ -131,470 +129,60 @@ namespace EveOPreview } opacity_bar.Value = Math.Min(100, (int)(100.0 * Properties.Settings.Default.opacity)); - - load_layout(); } - private void spawn_and_kill_previews() - { - if (!_isInitialized) { return; } - - Process[] processes = Process.GetProcessesByName("ExeFile"); - List processHandles = new List(); - - // pop new previews - - foreach (Process process in processes) - { - processHandles.Add(process.MainWindowHandle); - - Size sync_size = new Size(); - sync_size.Width = (int)Properties.Settings.Default.sync_resize_x; - sync_size.Height = (int)Properties.Settings.Default.sync_resize_y; - - if (!_previews.ContainsKey(process.MainWindowHandle) && process.MainWindowTitle != "") - { - _previews[process.MainWindowHandle] = this._thumbnailFactory.Create(this, process.MainWindowHandle, "...", sync_size); - - // apply more thumbnail specific options - _previews[process.MainWindowHandle].SetTopMost(Properties.Settings.Default.always_on_top); - _previews[process.MainWindowHandle].SetWindowFrames(Properties.Settings.Default.show_thumb_frames); - - // add a preview also - previews_check_listbox.BeginUpdate(); - previews_check_listbox.Items.Add(_previews[process.MainWindowHandle]); - previews_check_listbox.EndUpdate(); - - refresh_client_window_locations(process); - } - - else if (_previews.ContainsKey(process.MainWindowHandle) && process.MainWindowTitle != _previews[process.MainWindowHandle].GetLabel()) //or update the preview titles - { - _previews[process.MainWindowHandle].SetLabel(process.MainWindowTitle); - string key = _previews[process.MainWindowHandle].GetLabel(); - string value; - if (_flatLayoutShortcuts.TryGetValue(key, out value)) - { - _previews[process.MainWindowHandle].RegisterShortcut(value); - } - refresh_client_window_locations(process); - } - - if (process.MainWindowHandle == DwmApiNativeMethods.GetForegroundWindow()) - { - _activeClientHandle = process.MainWindowHandle; - _activeClientTitle = process.MainWindowTitle; - } - - } - - // clean up old previews - List to_be_pruned = new List(); - foreach (IntPtr processHandle in _previews.Keys) - { - if (!(processHandles.Contains(processHandle))) - { - to_be_pruned.Add(processHandle); - } - } - - foreach (IntPtr processHandle in to_be_pruned) - { - previews_check_listbox.BeginUpdate(); - previews_check_listbox.Items.Remove(_previews[processHandle]); - previews_check_listbox.EndUpdate(); - - _previews[processHandle].CloseThumbnail(); - _previews.Remove(processHandle); - } - - previews_check_listbox.Update(); - - } - - private void refresh_client_window_locations(Process process) - { - if (Properties.Settings.Default.track_client_windows && _clientLayout.ContainsKey(process.MainWindowTitle)) - { - DwmApiNativeMethods.MoveWindow(process.MainWindowHandle, _clientLayout[process.MainWindowTitle].X, - _clientLayout[process.MainWindowTitle].Y, _clientLayout[process.MainWindowTitle].Width, - _clientLayout[process.MainWindowTitle].Height, true); - } - } - - - private string remove_nonconform_xml_characters(string entry) - { - foreach (var kv in _xmlBadToOkChars) - { - entry = entry.Replace(kv.Key, kv.Value); - } - return entry; - } - - private string restore_nonconform_xml_characters(string entry) - { - foreach (var kv in _xmlBadToOkChars) - { - entry = entry.Replace(kv.Value, kv.Key); - } - return entry; - } - - private XElement MakeXElement(string input) - { - string clean = remove_nonconform_xml_characters(input).Replace(" ", "_"); - return new XElement(clean); - } - - private string ParseXElement(XElement input) - { - return restore_nonconform_xml_characters(input.Name.ToString()).Replace("_", " "); - } - - private void load_layout() - { - if (File.Exists("layout.xml")) - { - XElement rootElement = XElement.Load("layout.xml"); - foreach (var el in rootElement.Elements()) - { - Dictionary inner = new Dictionary(); - foreach (var inner_el in el.Elements()) - { - inner[ParseXElement(inner_el)] = new Point(Convert.ToInt32(inner_el.Element("x")?.Value), Convert.ToInt32(inner_el.Element("y")?.Value)); - } - _uniqueLayouts[ParseXElement(el)] = inner; - } - } - - if (File.Exists("flat_layout.xml")) - { - XElement rootElement = XElement.Load("flat_layout.xml"); - foreach (var el in rootElement.Elements()) - { - _flatLayout[ParseXElement(el)] = new Point(Convert.ToInt32(el.Element("x").Value), Convert.ToInt32(el.Element("y").Value)); - _flatLayoutShortcuts[ParseXElement(el)] = ""; - - if (el.Element("shortcut") != null) - { - _flatLayoutShortcuts[ParseXElement(el)] = el.Element("shortcut").Value; - } - } - } - - if (File.Exists("client_layout.xml")) - { - XElement rootElement = XElement.Load("client_layout.xml"); - foreach (var el in rootElement.Elements()) - { - ClientLocation clientLocation = new ClientLocation(); - clientLocation.X = Convert.ToInt32(el.Element("x").Value); - clientLocation.Y = Convert.ToInt32(el.Element("y").Value); - clientLocation.Width = Convert.ToInt32(el.Element("width").Value); - clientLocation.Height = Convert.ToInt32(el.Element("height").Value); - - _clientLayout[ParseXElement(el)] = clientLocation; - } - } - } - - private void store_layout() - { - XElement el = new XElement("layouts"); - foreach (var client in _uniqueLayouts.Keys) - { - if (client == "") - { - continue; - } - XElement layout = MakeXElement(client); - foreach (var thumbnail_ in _uniqueLayouts[client]) - { - string thumbnail = thumbnail_.Key; - if (thumbnail == "" || thumbnail == "...") - { - continue; - } - XElement position = MakeXElement(thumbnail); - position.Add(new XElement("x", thumbnail_.Value.X)); - position.Add(new XElement("y", thumbnail_.Value.Y)); - layout.Add(position); - } - el.Add(layout); - } - - el.Save("layout.xml"); - - XElement el2 = new XElement("flat_layout"); - foreach (var clientKV in _flatLayout) - { - if (clientKV.Key == "" || clientKV.Key == "...") - { - continue; - } - XElement layout = MakeXElement(clientKV.Key); - layout.Add(new XElement("x", clientKV.Value.X)); - layout.Add(new XElement("y", clientKV.Value.Y)); - - string shortcut; - if (_flatLayoutShortcuts.TryGetValue(clientKV.Key, out shortcut)) - { - layout.Add(new XElement("shortcut", shortcut)); - } - el2.Add(layout); - } - - el2.Save("flat_layout.xml"); - - XElement el3 = new XElement("client_layout"); - foreach (var clientKV in _clientLayout) - { - if (clientKV.Key == "" || clientKV.Key == "...") - { - continue; - } - XElement layout = MakeXElement(clientKV.Key); - layout.Add(new XElement("x", clientKV.Value.X)); - layout.Add(new XElement("y", clientKV.Value.Y)); - layout.Add(new XElement("width", clientKV.Value.Width)); - layout.Add(new XElement("height", clientKV.Value.Height)); - el3.Add(layout); - } - - el3.Save("client_layout.xml"); - } - - private void handle_unique_layout(IThumbnail thumbnailWindow, string last_known_active_window) - { - Dictionary layout; - if (_uniqueLayouts.TryGetValue(last_known_active_window, out layout)) - { - Point new_loc; - if (Properties.Settings.Default.unique_layout && layout.TryGetValue(thumbnailWindow.GetLabel(), out new_loc)) - { - thumbnailWindow.SetLocation(new_loc); - } - else - { - // create inner dict - layout[thumbnailWindow.GetLabel()] = thumbnailWindow.GetLocation(); - } - } - else if (last_known_active_window != "") - { - // create outer dict - _uniqueLayouts[last_known_active_window] = new Dictionary(); - _uniqueLayouts[last_known_active_window][thumbnailWindow.GetLabel()] = thumbnailWindow.GetLocation(); - } - } - - - private void update_client_locations() - { - Process[] processes = Process.GetProcessesByName("ExeFile"); - List processHandles = new List(); - - foreach (Process process in processes) - { - RECT rect = new RECT(); - DwmApiNativeMethods.GetWindowRect(process.MainWindowHandle, out rect); - - int left = Math.Abs(rect.Left); - int right = Math.Abs(rect.Right); - int client_width = Math.Abs(left - right); - - int top = Math.Abs(rect.Top); - int bottom = Math.Abs(rect.Bottom); - int client_height = Math.Abs(top - bottom); - - ClientLocation clientLocation = new ClientLocation(); - clientLocation.X = rect.Left; - clientLocation.Y = rect.Top; - clientLocation.Width = client_width; - clientLocation.Height = client_height; - - - _clientLayout[process.MainWindowTitle] = clientLocation; - } - } - - - public void NotifyPreviewSwitch() - { - update_client_locations(); - store_layout(); //todo: check if it actually changed ... - foreach (KeyValuePair entry in _previews) - { - entry.Value.SetTopMost(Properties.Settings.Default.always_on_top); - } - } - - - private void handle_flat_layout(IThumbnail thumbnailWindow) - { - Point layout; - if (_flatLayout.TryGetValue(thumbnailWindow.GetLabel(), out layout)) - { - thumbnailWindow.SetLocation(layout); - } - else if (thumbnailWindow.GetLabel() != "") - { - _flatLayout[thumbnailWindow.GetLabel()] = thumbnailWindow.GetLocation(); - } - } - - private bool window_is_preview_or_client(IntPtr window) - { - bool active_window_is_right_type = false; - foreach (KeyValuePair entry in _previews) - { - if (entry.Key == window || entry.Value.IsPreviewHandle(window)) - { - active_window_is_right_type = true; - } - } - return active_window_is_right_type; - } - - - private void refresh_thumbnails() - { - - IntPtr active_window = DwmApiNativeMethods.GetForegroundWindow(); - - // hide, show, resize and move - foreach (KeyValuePair entry in _previews) - { - if (!window_is_preview_or_client(active_window) && Properties.Settings.Default.hide_all) - { - entry.Value.HideThumbnail(); - } - else if (entry.Key == _activeClientHandle && Properties.Settings.Default.hide_active) - { - entry.Value.HideThumbnail(); - } - else - { - entry.Value.ShowThumbnail(); - if (Properties.Settings.Default.unique_layout) - { - handle_unique_layout(entry.Value, _activeClientTitle); - } - else - { - handle_flat_layout(entry.Value); - } - } - entry.Value.IsZoomEnabled = Properties.Settings.Default.zoom_on_hover; - entry.Value.IsOverlayEnabled = Properties.Settings.Default.show_overlay; - entry.Value.SetOpacity(Properties.Settings.Default.opacity); - } - - DwmApiNativeMethods.DwmIsCompositionEnabled(); - } - - - public void SyncPreviewSize(Size sync_size) - { - if (!_isInitialized) { return; } - - if (Properties.Settings.Default.sync_resize && - Properties.Settings.Default.show_thumb_frames && - _ignoringSizeSync.ElapsedMilliseconds > 500) - { - _ignoringSizeSync.Stop(); - - option_sync_size_x.Text = sync_size.Width.ToString(); - option_sync_size_y.Text = sync_size.Height.ToString(); - - foreach (KeyValuePair entry in _previews) - { - if (entry.Value.IsPreviewHandle(DwmApiNativeMethods.GetForegroundWindow())) - { - entry.Value.SetSize(sync_size); - } - } - - } - - } - - - public void UpdatePreviewPosition(string preview_title, Point position) - { - - if (Properties.Settings.Default.unique_layout) - { - Dictionary layout; - if (_uniqueLayouts.TryGetValue(_activeClientTitle, out layout)) - { - layout[preview_title] = position; - } - else if (_activeClientTitle == "") - { - _uniqueLayouts[_activeClientTitle] = new Dictionary(); - _uniqueLayouts[_activeClientTitle][preview_title] = position; - } - } - else - { - _flatLayout[preview_title] = position; - } - - } - - - private void dispatcherTimer_Tick(object sender, EventArgs e) - { - spawn_and_kill_previews(); - refresh_thumbnails(); - if (_ignoringSizeSync.ElapsedMilliseconds > 500) { _ignoringSizeSync.Stop(); }; - - if (DwmApiNativeMethods.DwmIsCompositionEnabled()) - { - aero_status_label.Text = "AERO is ON"; - aero_status_label.ForeColor = Color.Black; - } - else - { - aero_status_label.Text = "AERO is OFF"; - aero_status_label.ForeColor = Color.Red; - } - - } private void option_hide_all_if_noneve_CheckedChanged(object sender, EventArgs e) { + if (!_isInitialized) + { + return; + } + Properties.Settings.Default.hide_all = option_hide_all_if_not_right_type.Checked; Properties.Settings.Default.Save(); - refresh_thumbnails(); + this._manager.refresh_thumbnails(); } private void option_unique_layout_CheckedChanged(object sender, EventArgs e) { + if (!_isInitialized) + { + return; + } + Properties.Settings.Default.unique_layout = option_unique_layout.Checked; Properties.Settings.Default.Save(); - refresh_thumbnails(); + this._manager.refresh_thumbnails(); } private void option_hide_active_CheckedChanged(object sender, EventArgs e) { + if (!_isInitialized) + { + return; + } + Properties.Settings.Default.hide_active = option_hide_active.Checked; Properties.Settings.Default.Save(); - refresh_thumbnails(); + this._manager.refresh_thumbnails(); } private void option_sync_size_CheckedChanged(object sender, EventArgs e) { + if (!_isInitialized) + { + return; + } + Properties.Settings.Default.sync_resize = option_sync_size.Checked; Properties.Settings.Default.Save(); - refresh_thumbnails(); + this._manager.refresh_thumbnails(); } @@ -622,51 +210,59 @@ namespace EveOPreview Properties.Settings.Default.Save(); // resize - SyncPreviewSize(new Size((int)Properties.Settings.Default.sync_resize_x, + this._manager.SyncPreviewSize(new Size((int)Properties.Settings.Default.sync_resize_x, (int)Properties.Settings.Default.sync_resize_y)); } private void option_sync_size_x_TextChanged(object sender, EventArgs e) { + if (!_isInitialized) + { + return; + } + parse_size_entry(); } private void option_sync_size_y_TextChanged(object sender, EventArgs e) { + if (!_isInitialized) + { + return; + } + parse_size_entry(); } private void option_always_on_top_CheckedChanged(object sender, EventArgs e) { + if (!_isInitialized) + { + return; + } + Properties.Settings.Default.always_on_top = option_always_on_top.Checked; Properties.Settings.Default.Save(); - refresh_thumbnails(); + this._manager.refresh_thumbnails(); } private void option_show_thumbnail_frames_CheckedChanged(object sender, EventArgs e) { + if (!_isInitialized) + { + return; + } + Properties.Settings.Default.show_thumb_frames = option_show_thumbnail_frames.Checked; Properties.Settings.Default.Save(); - if (Properties.Settings.Default.show_thumb_frames) - { - _ignoringSizeSync.Stop(); - _ignoringSizeSync.Reset(); - _ignoringSizeSync.Start(); - } - - foreach (var thumbnail in _previews) - { - thumbnail.Value.SetWindowFrames(Properties.Settings.Default.show_thumb_frames); - } - + this._manager.set_frames(); } - private void list_running_clients_SelectedIndexChanged(object sender, EventArgs e) { } @@ -685,24 +281,25 @@ namespace EveOPreview private void option_zoom_on_hover_CheckedChanged(object sender, EventArgs e) { + if (!_isInitialized) return; + Properties.Settings.Default.zoom_on_hover = option_zoom_on_hover.Checked; Properties.Settings.Default.Save(); - refresh_thumbnails(); + this._manager.refresh_thumbnails(); option_zoom_factor.Enabled = Properties.Settings.Default.zoom_on_hover; - if (_isInitialized) - { + foreach (var kv in _zoomAnchorButtonMap) { kv.Value.Enabled = Properties.Settings.Default.zoom_on_hover; } - } + } private void option_show_overlay_CheckedChanged(object sender, EventArgs e) { Properties.Settings.Default.show_overlay = option_show_overlay.Checked; Properties.Settings.Default.Save(); - refresh_thumbnails(); + this._manager.refresh_thumbnails(); } @@ -746,14 +343,14 @@ namespace EveOPreview private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e) { - refresh_thumbnails(); + this._manager.refresh_thumbnails(); } private void checkedListBox1_SelectedIndexChanged2(object sender, EventArgs e) { System.Windows.Forms.ItemCheckEventArgs arg = (System.Windows.Forms.ItemCheckEventArgs)e; ((ThumbnailWindow)this.previews_check_listbox.Items[arg.Index]).IsPreviewEnabled = (arg.NewValue != System.Windows.Forms.CheckState.Checked); - refresh_thumbnails(); + this._manager.refresh_thumbnails(); } private void flowLayoutPanel1_Paint(object sender, PaintEventArgs e) @@ -763,18 +360,26 @@ namespace EveOPreview private void checkBox1_CheckedChanged(object sender, EventArgs e) { + if (!_isInitialized) + { + return; + } Properties.Settings.Default.track_client_windows = option_track_client_windows.Checked; Properties.Settings.Default.Save(); - refresh_thumbnails(); + this._manager.refresh_thumbnails(); } private void opacity_bar_Scroll(object sender, ScrollEventArgs e) { + if (!_isInitialized) + { + return; + } // fire off opacity change Properties.Settings.Default.opacity = Math.Min((float)e.NewValue / 100.0f, 1.0f); Properties.Settings.Default.Save(); - refresh_thumbnails(); + this._manager.refresh_thumbnails(); } diff --git a/Eve-O-Preview/Thumbnail/ThumbnailFactory.cs b/Eve-O-Preview/Thumbnail/ThumbnailFactory.cs index a603043..f56fbf5 100644 --- a/Eve-O-Preview/Thumbnail/ThumbnailFactory.cs +++ b/Eve-O-Preview/Thumbnail/ThumbnailFactory.cs @@ -5,9 +5,9 @@ namespace EveOPreview { public class ThumbnailFactory { - public IThumbnail Create(MainForm parent, IntPtr sourceWindow, string title, Size size) + public IThumbnail Create(ThumbnailManager manager, IntPtr sourceWindow, string title, Size size) { - return new ThumbnailWindow(parent, sourceWindow, title, size); + return new ThumbnailWindow(manager, sourceWindow, title, size); } } } \ No newline at end of file diff --git a/Eve-O-Preview/Thumbnail/ThumbnailManager.cs b/Eve-O-Preview/Thumbnail/ThumbnailManager.cs new file mode 100644 index 0000000..3a52deb --- /dev/null +++ b/Eve-O-Preview/Thumbnail/ThumbnailManager.cs @@ -0,0 +1,507 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Drawing; +using System.IO; +using System.Windows.Threading; +using System.Xml.Linq; + +namespace EveOPreview +{ + public class ThumbnailManager + { + private readonly Stopwatch _ignoringSizeSync; + private DispatcherTimer _dispatcherTimer; + private readonly ThumbnailFactory _thumbnailFactory; + private readonly Dictionary _previews; + + private IntPtr _activeClientHandle; + private string _activeClientTitle; + + private readonly Dictionary> _uniqueLayouts; + private readonly Dictionary _flatLayout; + private readonly Dictionary _flatLayoutShortcuts; + private readonly Dictionary _clientLayout; + + private readonly Dictionary _xmlBadToOkChars; + + private readonly Action> _addThumbnail; + private readonly Action> _removeThumbnail; + private readonly Action _setAeroStatus; + private readonly Action _sizeChange; + + public ThumbnailManager(Action> addThumbnail, Action> removeThumbnail, Action setAeroStatus, Action sizeChange) + { + _addThumbnail = addThumbnail; + _removeThumbnail = removeThumbnail; + _setAeroStatus = setAeroStatus; + _sizeChange = sizeChange; + + _ignoringSizeSync = new Stopwatch(); + _ignoringSizeSync.Start(); + + this._activeClientHandle = (IntPtr)0; + this._activeClientTitle = ""; + + _xmlBadToOkChars = new Dictionary(); + _xmlBadToOkChars["<"] = "---lt---"; + _xmlBadToOkChars["&"] = "---amp---"; + _xmlBadToOkChars[">"] = "---gt---"; + _xmlBadToOkChars["\""] = "---quot---"; + _xmlBadToOkChars["\'"] = "---apos---"; + _xmlBadToOkChars[","] = "---comma---"; + _xmlBadToOkChars["."] = "---dot---"; + + _uniqueLayouts = new Dictionary>(); + _flatLayout = new Dictionary(); + _flatLayoutShortcuts = new Dictionary(); + _clientLayout = new Dictionary(); + + this._previews = new Dictionary(); + + // DispatcherTimer setup + _dispatcherTimer = new DispatcherTimer(); + _dispatcherTimer.Tick += dispatcherTimer_Tick; + _dispatcherTimer.Interval = new TimeSpan(0, 0, 1); + + this._thumbnailFactory = new ThumbnailFactory(); + } + + public void Activate() + { + this.load_layout(); + this._dispatcherTimer.Start(); + } + + public void Deactivate() + { + this._dispatcherTimer.Stop(); + } + + private void spawn_and_kill_previews() + { + // TODO Extract this! + Process[] processes = Process.GetProcessesByName("ExeFile"); + List processHandles = new List(); + List addedList=new List(); + List removedList = new List(); + // pop new previews + + foreach (Process process in processes) + { + processHandles.Add(process.MainWindowHandle); + + Size sync_size = new Size(); + sync_size.Width = (int)Properties.Settings.Default.sync_resize_x; + sync_size.Height = (int)Properties.Settings.Default.sync_resize_y; + + if (!_previews.ContainsKey(process.MainWindowHandle) && process.MainWindowTitle != "") + { + _previews[process.MainWindowHandle] = this._thumbnailFactory.Create(this, process.MainWindowHandle, "...", sync_size); + + // apply more thumbnail specific options + _previews[process.MainWindowHandle].SetTopMost(Properties.Settings.Default.always_on_top); + _previews[process.MainWindowHandle].SetWindowFrames(Properties.Settings.Default.show_thumb_frames); + + // add a preview also + addedList.Add(_previews[process.MainWindowHandle].GetLabel()); + + refresh_client_window_locations(process); + } + + else if (_previews.ContainsKey(process.MainWindowHandle) && process.MainWindowTitle != _previews[process.MainWindowHandle].GetLabel()) //or update the preview titles + { + _previews[process.MainWindowHandle].SetLabel(process.MainWindowTitle); + string key = _previews[process.MainWindowHandle].GetLabel(); + string value; + if (_flatLayoutShortcuts.TryGetValue(key, out value)) + { + _previews[process.MainWindowHandle].RegisterShortcut(value); + } + refresh_client_window_locations(process); + } + + if (process.MainWindowHandle == DwmApiNativeMethods.GetForegroundWindow()) + { + _activeClientHandle = process.MainWindowHandle; + _activeClientTitle = process.MainWindowTitle; + } + + } + + // TODO Check for empty list + _addThumbnail(addedList); + + // clean up old previews + List to_be_pruned = new List(); + foreach (IntPtr processHandle in _previews.Keys) + { + if (!(processHandles.Contains(processHandle))) + { + to_be_pruned.Add(processHandle); + } + } + + foreach (IntPtr processHandle in to_be_pruned) + { + removedList.Add(_previews[processHandle].GetLabel()); + + _previews[processHandle].CloseThumbnail(); + _previews.Remove(processHandle); + } + + _removeThumbnail(removedList); + } + + private void refresh_client_window_locations(Process process) + { + if (Properties.Settings.Default.track_client_windows && _clientLayout.ContainsKey(process.MainWindowTitle)) + { + DwmApiNativeMethods.MoveWindow(process.MainWindowHandle, _clientLayout[process.MainWindowTitle].X, + _clientLayout[process.MainWindowTitle].Y, _clientLayout[process.MainWindowTitle].Width, + _clientLayout[process.MainWindowTitle].Height, true); + } + } + + private void dispatcherTimer_Tick(object sender, EventArgs e) + { + spawn_and_kill_previews(); + refresh_thumbnails(); + if (_ignoringSizeSync.ElapsedMilliseconds > 500) { _ignoringSizeSync.Stop(); }; + + // TODO Do this once in 10 seconds + _setAeroStatus(DwmApiNativeMethods.DwmIsCompositionEnabled()); + } + + public void NotifyPreviewSwitch() + { + update_client_locations(); + store_layout(); //todo: check if it actually changed ... + foreach (KeyValuePair entry in _previews) + { + entry.Value.SetTopMost(Properties.Settings.Default.always_on_top); + } + } + + + public void SyncPreviewSize(Size sync_size) + { + if (Properties.Settings.Default.sync_resize && + Properties.Settings.Default.show_thumb_frames && + _ignoringSizeSync.ElapsedMilliseconds > 500) + { + _ignoringSizeSync.Stop(); + + _sizeChange(sync_size.Width, sync_size.Height); + + foreach (KeyValuePair entry in _previews) + { + if (entry.Value.IsPreviewHandle(DwmApiNativeMethods.GetForegroundWindow())) + { + entry.Value.SetSize(sync_size); + } + } + + } + + } + + + public void UpdatePreviewPosition(string preview_title, Point position) + { + + if (Properties.Settings.Default.unique_layout) + { + Dictionary layout; + if (_uniqueLayouts.TryGetValue(_activeClientTitle, out layout)) + { + layout[preview_title] = position; + } + else if (_activeClientTitle == "") + { + _uniqueLayouts[_activeClientTitle] = new Dictionary(); + _uniqueLayouts[_activeClientTitle][preview_title] = position; + } + } + else + { + _flatLayout[preview_title] = position; + } + + } + + private string remove_nonconform_xml_characters(string entry) + { + foreach (var kv in _xmlBadToOkChars) + { + entry = entry.Replace(kv.Key, kv.Value); + } + return entry; + } + + private string restore_nonconform_xml_characters(string entry) + { + foreach (var kv in _xmlBadToOkChars) + { + entry = entry.Replace(kv.Value, kv.Key); + } + return entry; + } + + private XElement MakeXElement(string input) + { + string clean = remove_nonconform_xml_characters(input).Replace(" ", "_"); + return new XElement(clean); + } + + private string ParseXElement(XElement input) + { + return restore_nonconform_xml_characters(input.Name.ToString()).Replace("_", " "); + } + + private void load_layout() + { + if (File.Exists("layout.xml")) + { + XElement rootElement = XElement.Load("layout.xml"); + foreach (var el in rootElement.Elements()) + { + Dictionary inner = new Dictionary(); + foreach (var inner_el in el.Elements()) + { + inner[ParseXElement(inner_el)] = new Point(Convert.ToInt32(inner_el.Element("x")?.Value), Convert.ToInt32(inner_el.Element("y")?.Value)); + } + _uniqueLayouts[ParseXElement(el)] = inner; + } + } + + if (File.Exists("flat_layout.xml")) + { + XElement rootElement = XElement.Load("flat_layout.xml"); + foreach (var el in rootElement.Elements()) + { + _flatLayout[ParseXElement(el)] = new Point(Convert.ToInt32(el.Element("x").Value), Convert.ToInt32(el.Element("y").Value)); + _flatLayoutShortcuts[ParseXElement(el)] = ""; + + if (el.Element("shortcut") != null) + { + _flatLayoutShortcuts[ParseXElement(el)] = el.Element("shortcut").Value; + } + } + } + + if (File.Exists("client_layout.xml")) + { + XElement rootElement = XElement.Load("client_layout.xml"); + foreach (var el in rootElement.Elements()) + { + ClientLocation clientLocation = new ClientLocation(); + clientLocation.X = Convert.ToInt32(el.Element("x").Value); + clientLocation.Y = Convert.ToInt32(el.Element("y").Value); + clientLocation.Width = Convert.ToInt32(el.Element("width").Value); + clientLocation.Height = Convert.ToInt32(el.Element("height").Value); + + _clientLayout[ParseXElement(el)] = clientLocation; + } + } + } + + private void store_layout() + { + XElement el = new XElement("layouts"); + foreach (var client in _uniqueLayouts.Keys) + { + if (client == "") + { + continue; + } + XElement layout = MakeXElement(client); + foreach (var thumbnail_ in _uniqueLayouts[client]) + { + string thumbnail = thumbnail_.Key; + if (thumbnail == "" || thumbnail == "...") + { + continue; + } + XElement position = MakeXElement(thumbnail); + position.Add(new XElement("x", thumbnail_.Value.X)); + position.Add(new XElement("y", thumbnail_.Value.Y)); + layout.Add(position); + } + el.Add(layout); + } + + el.Save("layout.xml"); + + XElement el2 = new XElement("flat_layout"); + foreach (var clientKV in _flatLayout) + { + if (clientKV.Key == "" || clientKV.Key == "...") + { + continue; + } + XElement layout = MakeXElement(clientKV.Key); + layout.Add(new XElement("x", clientKV.Value.X)); + layout.Add(new XElement("y", clientKV.Value.Y)); + + string shortcut; + if (_flatLayoutShortcuts.TryGetValue(clientKV.Key, out shortcut)) + { + layout.Add(new XElement("shortcut", shortcut)); + } + el2.Add(layout); + } + + el2.Save("flat_layout.xml"); + + XElement el3 = new XElement("client_layout"); + foreach (var clientKV in _clientLayout) + { + if (clientKV.Key == "" || clientKV.Key == "...") + { + continue; + } + XElement layout = MakeXElement(clientKV.Key); + layout.Add(new XElement("x", clientKV.Value.X)); + layout.Add(new XElement("y", clientKV.Value.Y)); + layout.Add(new XElement("width", clientKV.Value.Width)); + layout.Add(new XElement("height", clientKV.Value.Height)); + el3.Add(layout); + } + + el3.Save("client_layout.xml"); + } + + private void handle_unique_layout(IThumbnail thumbnailWindow, string last_known_active_window) + { + Dictionary layout; + if (_uniqueLayouts.TryGetValue(last_known_active_window, out layout)) + { + Point new_loc; + if (Properties.Settings.Default.unique_layout && layout.TryGetValue(thumbnailWindow.GetLabel(), out new_loc)) + { + thumbnailWindow.SetLocation(new_loc); + } + else + { + // create inner dict + layout[thumbnailWindow.GetLabel()] = thumbnailWindow.GetLocation(); + } + } + else if (last_known_active_window != "") + { + // create outer dict + _uniqueLayouts[last_known_active_window] = new Dictionary(); + _uniqueLayouts[last_known_active_window][thumbnailWindow.GetLabel()] = thumbnailWindow.GetLocation(); + } + } + + private void update_client_locations() + { + Process[] processes = Process.GetProcessesByName("ExeFile"); + List processHandles = new List(); + + foreach (Process process in processes) + { + RECT rect = new RECT(); + DwmApiNativeMethods.GetWindowRect(process.MainWindowHandle, out rect); + + int left = Math.Abs(rect.Left); + int right = Math.Abs(rect.Right); + int client_width = Math.Abs(left - right); + + int top = Math.Abs(rect.Top); + int bottom = Math.Abs(rect.Bottom); + int client_height = Math.Abs(top - bottom); + + ClientLocation clientLocation = new ClientLocation(); + clientLocation.X = rect.Left; + clientLocation.Y = rect.Top; + clientLocation.Width = client_width; + clientLocation.Height = client_height; + + + _clientLayout[process.MainWindowTitle] = clientLocation; + } + } + + private void handle_flat_layout(IThumbnail thumbnailWindow) + { + Point layout; + if (_flatLayout.TryGetValue(thumbnailWindow.GetLabel(), out layout)) + { + thumbnailWindow.SetLocation(layout); + } + else if (thumbnailWindow.GetLabel() != "") + { + _flatLayout[thumbnailWindow.GetLabel()] = thumbnailWindow.GetLocation(); + } + } + + private bool window_is_preview_or_client(IntPtr window) + { + bool active_window_is_right_type = false; + foreach (KeyValuePair entry in _previews) + { + if (entry.Key == window || entry.Value.IsPreviewHandle(window)) + { + active_window_is_right_type = true; + } + } + return active_window_is_right_type; + } + + public void refresh_thumbnails() + { + + IntPtr active_window = DwmApiNativeMethods.GetForegroundWindow(); + + // hide, show, resize and move + foreach (KeyValuePair entry in _previews) + { + if (!window_is_preview_or_client(active_window) && Properties.Settings.Default.hide_all) + { + entry.Value.HideThumbnail(); + } + else if (entry.Key == _activeClientHandle && Properties.Settings.Default.hide_active) + { + entry.Value.HideThumbnail(); + } + else + { + entry.Value.ShowThumbnail(); + if (Properties.Settings.Default.unique_layout) + { + handle_unique_layout(entry.Value, _activeClientTitle); + } + else + { + handle_flat_layout(entry.Value); + } + } + entry.Value.IsZoomEnabled = Properties.Settings.Default.zoom_on_hover; + entry.Value.IsOverlayEnabled = Properties.Settings.Default.show_overlay; + entry.Value.SetOpacity(Properties.Settings.Default.opacity); + } + + DwmApiNativeMethods.DwmIsCompositionEnabled(); + } + + public void set_frames() + { + if (Properties.Settings.Default.show_thumb_frames) + { + _ignoringSizeSync.Stop(); + _ignoringSizeSync.Reset(); + _ignoringSizeSync.Start(); + } + + foreach (var thumbnail in _previews) + { + thumbnail.Value.SetWindowFrames(Properties.Settings.Default.show_thumb_frames); + } + + } + + } +} \ No newline at end of file diff --git a/Eve-O-Preview/Thumbnail/ThumbnailWindow.cs b/Eve-O-Preview/Thumbnail/ThumbnailWindow.cs index 71c05c9..1f24b27 100644 --- a/Eve-O-Preview/Thumbnail/ThumbnailWindow.cs +++ b/Eve-O-Preview/Thumbnail/ThumbnailWindow.cs @@ -9,7 +9,7 @@ namespace EveOPreview #region Private fields private readonly bool _isInitializing; private readonly IntPtr _sourceWindow; - private readonly MainForm _parentForm; + private readonly ThumbnailManager _manager; private readonly ThumbnailOverlay _overlay; private Hotkey _hotkey; // This field stores the hotkey reference @@ -26,7 +26,7 @@ namespace EveOPreview #endregion // This constructor should never be used directly - public ThumbnailWindow(MainForm parent, IntPtr sourceWindow, string title, Size size) + public ThumbnailWindow(ThumbnailManager manager, IntPtr sourceWindow, string title, Size size) { this._isInitializing = true; @@ -34,7 +34,7 @@ namespace EveOPreview this.IsOverlayEnabled = true; this._sourceWindow = sourceWindow; - this._parentForm = parent; + this._manager = manager; this._isThumbnailSetUp = false; this._ignoreMouseOverEvent = false; @@ -248,7 +248,7 @@ namespace EveOPreview if (e.Button == MouseButtons.Left) { this.ActivateClient(); - this._parentForm.NotifyPreviewSwitch(); + this._manager.NotifyPreviewSwitch(); } if (e.Button == MouseButtons.Right) @@ -265,7 +265,7 @@ namespace EveOPreview private void Hotkey_Pressed(Object sender, EventArgs e) { this.ActivateClient(); - this._parentForm.NotifyPreviewSwitch(); + this._manager.NotifyPreviewSwitch(); } protected override void OnResize(EventArgs e) @@ -276,7 +276,7 @@ namespace EveOPreview if (!(this._isInitializing || this._ignoreMouseOverEvent)) { - this._parentForm.SyncPreviewSize(this.Size); + this._manager.SyncPreviewSize(this.Size); } } @@ -286,7 +286,7 @@ namespace EveOPreview if (!(this._isInitializing || this._ignoreMouseOverEvent)) { - this._parentForm.UpdatePreviewPosition(this.Text, this.Location); + this._manager.UpdatePreviewPosition(this.Text, this.Location); } this.RefreshPreview();