1
+ using System ;
2
+ using System . Diagnostics ;
3
+ using System . IO ;
4
+ using System . Linq ;
5
+ using System . Threading . Tasks ;
6
+
7
+ namespace Steam_Library_Manager . Definitions
8
+ {
9
+ public class UplayAppInfo : App
10
+ {
11
+ public UplayAppInfo ( Library library , string appName , int appId , DirectoryInfo installationDirectory , bool isCompressed )
12
+ {
13
+ Library = library ;
14
+ AppName = appName ;
15
+ AppId = appId ;
16
+ InstallationDirectory = installationDirectory ;
17
+ IsCompressed = isCompressed ;
18
+
19
+ LastUpdated = InstallationDirectory . LastWriteTimeUtc ;
20
+ CompressedArchivePath = new FileInfo ( Path . Combine ( Library . FullPath , AppId + ".zip" ) ) ;
21
+ SizeOnDisk = ( ! IsCompressed ) ? Functions . FileSystem . GetDirectorySize ( InstallationDirectory , true ) : CompressedArchivePath . Length ;
22
+ IsCompacted = CompactStatus ( ) . Result ;
23
+ }
24
+
25
+ public override async void ParseMenuItemActionAsync ( string action )
26
+ {
27
+ try
28
+ {
29
+ switch ( action . ToLowerInvariant ( ) )
30
+ {
31
+ case "disk" :
32
+ InstallationDirectory . Refresh ( ) ;
33
+
34
+ if ( InstallationDirectory . Exists )
35
+ {
36
+ Process . Start ( InstallationDirectory . FullName ) ;
37
+ }
38
+
39
+ break ;
40
+
41
+ case "compress" :
42
+ if ( Functions . TaskManager . TaskList . Count ( x => x . App == this && x . TargetLibrary == Library && x . TaskType == Enums . TaskType . Compress ) == 0 )
43
+ {
44
+ Functions . TaskManager . AddTask ( new List . TaskInfo
45
+ {
46
+ App = this ,
47
+ TargetLibrary = Library ,
48
+ TaskType = Enums . TaskType . Compress ,
49
+ Compress = ! IsCompressed
50
+ } ) ;
51
+ }
52
+ break ;
53
+
54
+ case "compact" :
55
+ if ( Functions . TaskManager . TaskList . Count ( x => x . App == this && x . TargetLibrary == Library && x . TaskType == Enums . TaskType . Compact ) == 0 )
56
+ {
57
+ Functions . TaskManager . AddTask ( new List . TaskInfo
58
+ {
59
+ App = this ,
60
+ TargetLibrary = Library ,
61
+ TaskType = Enums . TaskType . Compact
62
+ } ) ;
63
+ }
64
+ break ;
65
+
66
+ case "deleteappfiles" :
67
+ await Task . Run ( async ( ) => await DeleteFilesAsync ( ) ) . ConfigureAwait ( false ) ;
68
+
69
+ Library . Apps . Remove ( this ) ;
70
+ if ( SLM . CurrentSelectedLibrary == Library )
71
+ Functions . App . UpdateAppPanel ( Library ) ;
72
+
73
+ break ;
74
+
75
+ case "deleteappfilestm" :
76
+ Functions . TaskManager . AddTask ( new List . TaskInfo
77
+ {
78
+ App = this ,
79
+ TargetLibrary = Library ,
80
+ TaskType = Enums . TaskType . Delete
81
+ } ) ;
82
+ break ;
83
+ }
84
+ }
85
+ catch ( Exception ex )
86
+ {
87
+ Logger . Error ( ex ) ;
88
+ }
89
+ }
90
+ }
91
+ }
0 commit comments