@@ -22,23 +22,23 @@ namespace plugin_Kinect360;
2222
2323internal class SetupData : ICoreSetupData
2424{
25- public object PluginIcon => new PathIcon
26- {
27- Data = ( Geometry ) XamlBindingHelper . ConvertValue ( typeof ( Geometry ) ,
28- "M55.75,3.68a2.27,2.27,0,0,0-2.42-2.4c-8.5.05-17,0-25.5,0H2.38c-.22,0-.44,0-.66,0A1.84,1.84,0,0,0,0,3.12c0,2.4,0,4.81,0,7.21a2.06,2.06,0,0,0,.44,1.12,1.9,1.9,0,0,0,1.66.67H23.76c1.48,0,1.46,0,1.47,1.46,0,.38-.09.54-.52.61-2.79.46-5.57,1-8.35,1.43-.35.06-.47.21-.45.56,0,.64,0,1.28,0,1.92,0,.88.35,1.22,1.25,1.23H38.45c.9,0,1.24-.34,1.25-1.23,0-.64,0-1.28,0-1.92,0-.35-.1-.5-.45-.56L31.68,14.3c-1.28-.22-1.26-.22-1.3-1.51,0-.53.12-.7.68-.69,7.46,0,14.92,0,22.37,0a2.07,2.07,0,0,0,2.3-2.3C55.73,7.77,55.67,5.72,55.75,3.68ZM18.77,9a2.3,2.3,0,1,1,2.3-2.27A2.31,2.31,0,0,1,18.77,9ZM29.66,9a2.3,2.3,0,1,1,2.28-2.3A2.32,2.32,0,0,1,29.66,9ZM37.4,9a2.26,2.26,0,0,1-2.32-2.3,2.25,2.25,0,0,1,2.27-2.29,2.32,2.32,0,0,1,2.34,2.31A2.29,2.29,0,0,1,37.4,9Z" )
29- } ;
30-
31- public string GroupName => "kinect" ;
32- public Type PluginType => typeof ( ITrackingDevice ) ;
25+ public object PluginIcon => new PathIcon
26+ {
27+ Data = ( Geometry ) XamlBindingHelper . ConvertValue ( typeof ( Geometry ) ,
28+ "M55.75,3.68a2.27,2.27,0,0,0-2.42-2.4c-8.5.05-17,0-25.5,0H2.38c-.22,0-.44,0-.66,0A1.84,1.84,0,0,0,0,3.12c0,2.4,0,4.81,0,7.21a2.06,2.06,0,0,0,.44,1.12,1.9,1.9,0,0,0,1.66.67H23.76c1.48,0,1.46,0,1.47,1.46,0,.38-.09.54-.52.61-2.79.46-5.57,1-8.35,1.43-.35.06-.47.21-.45.56,0,.64,0,1.28,0,1.92,0,.88.35,1.22,1.25,1.23H38.45c.9,0,1.24-.34,1.25-1.23,0-.64,0-1.28,0-1.92,0-.35-.1-.5-.45-.56L31.68,14.3c-1.28-.22-1.26-.22-1.3-1.51,0-.53.12-.7.68-.69,7.46,0,14.92,0,22.37,0a2.07,2.07,0,0,0,2.3-2.3C55.73,7.77,55.67,5.72,55.75,3.68ZM18.77,9a2.3,2.3,0,1,1,2.3-2.27A2.31,2.31,0,0,1,18.77,9ZM29.66,9a2.3,2.3,0,1,1,2.28-2.3A2.32,2.32,0,0,1,29.66,9ZM37.4,9a2.26,2.26,0,0,1-2.32-2.3,2.25,2.25,0,0,1,2.27-2.29,2.32,2.32,0,0,1,2.34,2.31A2.29,2.29,0,0,1,37.4,9Z" )
29+ } ;
30+
31+ public string GroupName => "kinect" ;
32+ public Type PluginType => typeof ( ITrackingDevice ) ;
3333}
3434
3535internal class SdkInstaller : IDependencyInstaller
3636{
37- public IDependencyInstaller . ILocalizationHost Host { get ; set ; }
37+ public IDependencyInstaller . ILocalizationHost Host { get ; set ; }
3838
39- public List < IDependency > ListDependencies ( )
40- {
41- return
39+ public List < IDependency > ListDependencies ( )
40+ {
41+ return
4242 [
4343 new KinectSdk
4444 {
@@ -47,157 +47,156 @@ public List<IDependency> ListDependencies()
4747 "Kinect for Xbox 360 SDK"
4848 }
4949 ] ;
50- }
50+ }
5151
52- public List < IFix > ListFixes ( )
53- {
54- return
52+ public List < IFix > ListFixes ( )
53+ {
54+ return
5555 [
5656 new NotPoweredFix
5757 {
5858 Host = Host ,
5959 Name = Host ? . RequestLocalizedString ( // Without the "fix" part
60- "/Plugins/Kinect360/Fixes/NotPowered/Name" ) ?? "Not Powered"
60+ "/Plugins/Kinect360/Fixes/NotPowered/Name" ) ?? "Not Powered"
6161 } ,
6262 new NotReadyFix
6363 {
6464 Host = Host ,
6565 Name = Host ? . RequestLocalizedString ( // Without the "fix" part
66- "/Plugins/Kinect360/Fixes/NotReady/Name" ) ?? "Not Ready"
67- } ,
66+ "/Plugins/Kinect360/Fixes/NotReady/Name" ) ?? "Not Ready"
67+ }
6868 ] ;
69- }
69+ }
7070}
7171
7272internal class KinectSdk : IDependency
7373{
74- private List < string > SdkFilesToInstall { get ; } =
74+ private List < string > SdkFilesToInstall { get ; } =
7575 [
7676 "KinectDrivers-v1.8-x64.WHQL.msi" ,
7777 "KinectRuntime-v1.8-x64.msi" ,
7878 "KinectSDK-v1.8-x64.msi"
7979 ] ;
8080
81- public IDependencyInstaller . ILocalizationHost Host { get ; set ; }
82-
83- public string Name { get ; set ; }
84- public bool IsMandatory => true ;
85-
86- public bool IsInstalled
87- {
88- get
89- {
90- try
91- {
92- // Well, this is pretty much all we need for the plugin to be loaded
93- return File . Exists ( @"C:\Windows\System32\Kinect10.dll" ) ;
94- }
95- catch ( Exception )
96- {
97- // Access denied?
98- return false ;
99- }
100- }
101- }
102-
103- public string InstallerEula
104- {
105- get
106- {
107- try
108- {
109- return File . ReadAllText ( Path . Join (
110- Directory . GetParent ( Assembly . GetExecutingAssembly ( ) . Location ) ! . FullName ,
111- "Assets" , "Resources" , "eula.md" ) ) ;
112- }
113- catch ( Exception )
114- {
115- return string . Empty ;
116- }
117- }
118- }
119-
120- public async Task < bool > Install ( IProgress < InstallationProgress > progress , CancellationToken cancellationToken )
121- {
122- // Amethyst will handle this exception for us anyway
123- cancellationToken . ThrowIfCancellationRequested ( ) ;
124- var dependenciesFolder = Path . Join ( Directory . GetParent (
125- Assembly . GetExecutingAssembly ( ) . Location ) ! . FullName ,
126- "Assets" , "Resources" , "Dependencies" ) ;
127-
128- // Copy to temp if amethyst is packaged
129- // ReSharper disable once InvertIf
130- if ( PackageUtils . IsAmethystPackaged )
131- {
132- // Create a shared folder with the dependencies
133- var dependenciesFolderInternal = await ApplicationData . Current . TemporaryFolder . CreateFolderAsync (
134- Guid . NewGuid ( ) . ToString ( ) . ToUpper ( ) , CreationCollisionOption . OpenIfExists ) ;
135-
136- // Copy all driver files to Amethyst's local data folder
137- new DirectoryInfo ( Path . Join ( Directory . GetParent ( Assembly . GetExecutingAssembly ( ) . Location ) ! . FullName ,
138- "Assets" , "Resources" , "Dependencies" ) )
139- . CopyToFolder ( dependenciesFolderInternal . Path ) ;
140-
141- // Update the installation paths
142- dependenciesFolder = dependenciesFolderInternal . Path ;
143- }
144-
145- // Finally install the packages
146- return InstallFiles ( SdkFilesToInstall . Select ( x => Path . Join (
147- dependenciesFolder , x ) ) , progress , cancellationToken ) ;
148-
149- // Apply other related fixes, non-critical
150- // ReSharper disable once ConditionIsAlwaysTrueOrFalse
151- // (await SetupPost(progress) || true); // TODO
152- }
153-
154- private bool InstallFiles ( IEnumerable < string > files ,
155- IProgress < InstallationProgress > progress , CancellationToken cancellationToken )
156- {
157- // Amethyst will handle this exception for us anyway
158- cancellationToken . ThrowIfCancellationRequested ( ) ;
159-
160- // Execute each install
161- foreach ( var installFile in files )
162- try
163- {
164- // msi /qn /norestart
165- progress . Report ( new InstallationProgress
166- {
167- IsIndeterminate = true ,
168- StageTitle =
169- ( Host ? . RequestLocalizedString ( "/Plugins/Kinect360/Stages/Installing" ) ??
170- "Installing {0}..." ) . Replace ( "{0}" , Path . GetFileName ( installFile ) )
171- } ) ;
172-
173- var msiExecutableStart = new ProcessStartInfo
174- {
175- FileName = Path . Join ( Environment . GetFolderPath ( Environment . SpecialFolder . Windows ) ,
176- @"System32\msiexec.exe" ) ,
177- WorkingDirectory = Directory . GetParent ( installFile ) ! . FullName ,
178- Arguments = $ "/i { installFile } /quiet /qn /norestart ALLUSERS=1",
179- CreateNoWindow = true ,
180- WindowStyle = ProcessWindowStyle . Hidden ,
181- UseShellExecute = true ,
182- Verb = "runas"
183- } ;
184-
185- var msiExecutable = Process . Start ( msiExecutableStart ) ;
186- msiExecutable ! . WaitForExit ( 60000 ) ;
187- }
188- catch ( Exception e )
189- {
190- progress . Report ( new InstallationProgress
191- {
192- IsIndeterminate = true ,
193- StageTitle =
194- ( Host ? . RequestLocalizedString ( "/Plugins/Kinect360/Stages/Exceptions/Other" ) ??
195- "Exception: {0}" ) . Replace ( "{0}" , e . Message )
196- } ) ;
197-
198- return false ;
199- }
200-
201- return true ;
202- }
203- }
81+ public IDependencyInstaller . ILocalizationHost Host { get ; set ; }
82+
83+ public string Name { get ; set ; }
84+ public bool IsMandatory => true ;
85+
86+ public bool IsInstalled
87+ {
88+ get
89+ {
90+ try
91+ {
92+ // Well, this is pretty much all we need for the plugin to be loaded
93+ return File . Exists ( @"C:\Windows\System32\Kinect10.dll" ) ;
94+ }
95+ catch ( Exception )
96+ {
97+ // Access denied?
98+ return false ;
99+ }
100+ }
101+ }
102+
103+ public string InstallerEula
104+ {
105+ get
106+ {
107+ try
108+ {
109+ return File . ReadAllText ( Path . Join (
110+ Directory . GetParent ( Assembly . GetExecutingAssembly ( ) . Location ) ! . FullName ,
111+ "Assets" , "Resources" , "eula.md" ) ) ;
112+ }
113+ catch ( Exception )
114+ {
115+ return string . Empty ;
116+ }
117+ }
118+ }
119+
120+ public async Task < bool > Install ( IProgress < InstallationProgress > progress , CancellationToken cancellationToken )
121+ {
122+ // Amethyst will handle this exception for us anyway
123+ cancellationToken . ThrowIfCancellationRequested ( ) ;
124+ var dependenciesFolder = Path . Join ( Directory . GetParent (
125+ Assembly . GetExecutingAssembly ( ) . Location ) ! . FullName ,
126+ "Assets" , "Resources" , "Dependencies" ) ;
127+
128+ await PathsHandler . Setup ( ) ;
129+
130+ // Copy to temp if amethyst is packaged
131+ // ReSharper disable once InvertIf
132+ // Create a shared folder with the dependencies
133+ var dependenciesFolderInternal = await PathsHandler . TemporaryFolder . CreateFolderAsync (
134+ Guid . NewGuid ( ) . ToString ( ) . ToUpper ( ) , CreationCollisionOption . OpenIfExists ) ;
135+
136+ // Copy all driver files to Amethyst's local data folder
137+ new DirectoryInfo ( Path . Join ( Directory . GetParent ( Assembly . GetExecutingAssembly ( ) . Location ) ! . FullName ,
138+ "Assets" , "Resources" , "Dependencies" ) )
139+ . CopyToFolder ( dependenciesFolderInternal . Path ) ;
140+
141+ // Update the installation paths
142+ dependenciesFolder = dependenciesFolderInternal . Path ;
143+
144+ // Finally install the packages
145+ return InstallFiles ( SdkFilesToInstall . Select ( x => Path . Join (
146+ dependenciesFolder , x ) ) , progress , cancellationToken ) ;
147+
148+ // Apply other related fixes, non-critical
149+ // ReSharper disable once ConditionIsAlwaysTrueOrFalse
150+ // (await SetupPost(progress) || true); // TODO
151+ }
152+
153+ private bool InstallFiles ( IEnumerable < string > files ,
154+ IProgress < InstallationProgress > progress , CancellationToken cancellationToken )
155+ {
156+ // Amethyst will handle this exception for us anyway
157+ cancellationToken . ThrowIfCancellationRequested ( ) ;
158+
159+ // Execute each install
160+ foreach ( var installFile in files )
161+ try
162+ {
163+ // msi /qn /norestart
164+ progress . Report ( new InstallationProgress
165+ {
166+ IsIndeterminate = true ,
167+ StageTitle =
168+ ( Host ? . RequestLocalizedString ( "/Plugins/Kinect360/Stages/Installing" ) ??
169+ "Installing {0}..." ) . Replace ( "{0}" , Path . GetFileName ( installFile ) )
170+ } ) ;
171+
172+ var msiExecutableStart = new ProcessStartInfo
173+ {
174+ FileName = Path . Join ( Environment . GetFolderPath ( Environment . SpecialFolder . Windows ) ,
175+ @"System32\msiexec.exe" ) ,
176+ WorkingDirectory = Directory . GetParent ( installFile ) ! . FullName ,
177+ Arguments = $ "/i { installFile } /quiet /qn /norestart ALLUSERS=1",
178+ CreateNoWindow = true ,
179+ WindowStyle = ProcessWindowStyle . Hidden ,
180+ UseShellExecute = true ,
181+ Verb = "runas"
182+ } ;
183+
184+ var msiExecutable = Process . Start ( msiExecutableStart ) ;
185+ msiExecutable ! . WaitForExit ( 60000 ) ;
186+ }
187+ catch ( Exception e )
188+ {
189+ progress . Report ( new InstallationProgress
190+ {
191+ IsIndeterminate = true ,
192+ StageTitle =
193+ ( Host ? . RequestLocalizedString ( "/Plugins/Kinect360/Stages/Exceptions/Other" ) ??
194+ "Exception: {0}" ) . Replace ( "{0}" , e . Message )
195+ } ) ;
196+
197+ return false ;
198+ }
199+
200+ return true ;
201+ }
202+ }
0 commit comments