@@ -12,41 +12,21 @@ namespace PEunion
12
12
{
13
13
public class Project : ObservableObject
14
14
{
15
- private string _SaveLocation ;
16
- private bool _IsDirty ;
17
- private BuildPlatform _Platform ;
18
- private BuildManifest _Manifest ;
19
- private string _IconPath ;
20
- private string _AssemblyTitle ;
21
- private string _AssemblyProduct ;
22
- private string _AssemblyCopyright ;
23
- private string _AssemblyVersion ;
24
- private BuildObfuscationType _Obfuscation ;
25
- private bool _StringEncryption ;
26
- private bool _StringLiteralEncryption ;
27
- private bool _DeleteZoneID ;
28
- private bool _Melt ;
29
- private ObservableCollection < ProjectItem > _Items ;
30
- private ValidationError [ ] _ValidationErrors ;
31
- private int _ValidationErrorCount ;
32
- private int _ValidationWarningCount ;
33
- private int _ValidationMessageCount ;
34
-
35
15
public string SaveLocation
36
16
{
37
- get => _SaveLocation ;
17
+ get => Get ( ( ) => SaveLocation ) ;
38
18
set
39
19
{
40
- Set ( ( ) => SaveLocation , ref _SaveLocation , value ) ;
20
+ Set ( ( ) => SaveLocation , value ) ;
41
21
RaisePropertyChanged ( ( ) => ProjectName ) ;
42
22
}
43
23
}
44
24
public bool IsDirty
45
25
{
46
- get => _IsDirty ;
26
+ get => Get ( ( ) => IsDirty ) ;
47
27
set
48
28
{
49
- Set ( ( ) => IsDirty , ref _IsDirty , value ) ;
29
+ Set ( ( ) => IsDirty , value ) ;
50
30
WindowMain . Singleton . Title = ProjectName + ( value ? " *" : null ) + " - PEunion" ;
51
31
WindowMain . Singleton . txtProjectTabIsDirty . SetVisibility ( value ) ;
52
32
@@ -58,7 +38,7 @@ public bool IsDirty
58
38
else
59
39
{
60
40
WindowMain . Singleton . ctrlBrowseIcon . Text = Path . GetFileName ( IconPath ) ;
61
- WindowMain . Singleton . ctrlBrowseIcon . IconImageSource = File . Exists ( IconPath ) ? new FileInfo ( IconPath ) . GetFileIcon ( true ) . ToBitmapSource ( ) : Utility . GetImageResource ( "ImageMissingIcon" ) ;
41
+ WindowMain . Singleton . ctrlBrowseIcon . IconImageSource = File . Exists ( IconPath ) ? FileEx . GetIcon ( IconPath , true ) . ToBitmapSource ( ) : Utility . GetImageResource ( "ImageMissingIcon" ) ;
62
42
}
63
43
WindowMain . Singleton . ctrlBrowseIcon . IsResetButtonEnabled = IconPath != null ;
64
44
@@ -67,144 +47,144 @@ public bool IsDirty
67
47
}
68
48
public BuildPlatform Platform
69
49
{
70
- get => _Platform ;
50
+ get => Get ( ( ) => Platform ) ;
71
51
set
72
52
{
73
- Set ( ( ) => Platform , ref _Platform , value ) ;
53
+ Set ( ( ) => Platform , value ) ;
74
54
IsDirty = true ;
75
55
}
76
56
}
77
57
public BuildManifest Manifest
78
58
{
79
- get => _Manifest ;
59
+ get => Get ( ( ) => Manifest ) ;
80
60
set
81
61
{
82
- Set ( ( ) => Manifest , ref _Manifest , value ) ;
62
+ Set ( ( ) => Manifest , value ) ;
83
63
IsDirty = true ;
84
64
}
85
65
}
86
66
public string IconPath
87
67
{
88
- get => _IconPath ;
68
+ get => Get ( ( ) => IconPath ) ;
89
69
set
90
70
{
91
- Set ( ( ) => IconPath , ref _IconPath , value ) ;
71
+ Set ( ( ) => IconPath , value ) ;
92
72
IsDirty = true ;
93
73
}
94
74
}
95
75
public string AssemblyTitle
96
76
{
97
- get => _AssemblyTitle ;
77
+ get => Get ( ( ) => AssemblyTitle ) ;
98
78
set
99
79
{
100
- Set ( ( ) => AssemblyTitle , ref _AssemblyTitle , value ) ;
80
+ Set ( ( ) => AssemblyTitle , value ) ;
101
81
IsDirty = true ;
102
82
}
103
83
}
104
84
public string AssemblyProduct
105
85
{
106
- get => _AssemblyProduct ;
86
+ get => Get ( ( ) => AssemblyProduct ) ;
107
87
set
108
88
{
109
- Set ( ( ) => AssemblyProduct , ref _AssemblyProduct , value ) ;
89
+ Set ( ( ) => AssemblyProduct , value ) ;
110
90
IsDirty = true ;
111
91
}
112
92
}
113
93
public string AssemblyCopyright
114
94
{
115
- get => _AssemblyCopyright ;
95
+ get => Get ( ( ) => AssemblyCopyright ) ;
116
96
set
117
97
{
118
- Set ( ( ) => AssemblyCopyright , ref _AssemblyCopyright , value ) ;
98
+ Set ( ( ) => AssemblyCopyright , value ) ;
119
99
IsDirty = true ;
120
100
}
121
101
}
122
102
public string AssemblyVersion
123
103
{
124
- get => _AssemblyVersion ;
104
+ get => Get ( ( ) => AssemblyVersion ) ;
125
105
set
126
106
{
127
- Set ( ( ) => AssemblyVersion , ref _AssemblyVersion , value ) ;
107
+ Set ( ( ) => AssemblyVersion , value ) ;
128
108
IsDirty = true ;
129
109
}
130
110
}
131
111
public BuildObfuscationType Obfuscation
132
112
{
133
- get => _Obfuscation ;
113
+ get => Get ( ( ) => Obfuscation ) ;
134
114
set
135
115
{
136
- Set ( ( ) => Obfuscation , ref _Obfuscation , value ) ;
116
+ Set ( ( ) => Obfuscation , value ) ;
137
117
RaisePropertyChanged ( ( ) => ObfuscationExample ) ;
138
118
IsDirty = true ;
139
119
}
140
120
}
141
121
public bool StringEncryption
142
122
{
143
- get => _StringEncryption ;
123
+ get => Get ( ( ) => StringEncryption ) ;
144
124
set
145
125
{
146
- Set ( ( ) => StringEncryption , ref _StringEncryption , value ) ;
126
+ Set ( ( ) => StringEncryption , value ) ;
147
127
IsDirty = true ;
148
128
}
149
129
}
150
130
public bool StringLiteralEncryption
151
131
{
152
- get => _StringLiteralEncryption ;
132
+ get => Get ( ( ) => StringLiteralEncryption ) ;
153
133
set
154
134
{
155
- Set ( ( ) => StringLiteralEncryption , ref _StringLiteralEncryption , value ) ;
135
+ Set ( ( ) => StringLiteralEncryption , value ) ;
156
136
IsDirty = true ;
157
137
}
158
138
}
159
139
public bool DeleteZoneID
160
140
{
161
- get => _DeleteZoneID ;
141
+ get => Get ( ( ) => DeleteZoneID ) ;
162
142
set
163
143
{
164
- Set ( ( ) => DeleteZoneID , ref _DeleteZoneID , value ) ;
144
+ Set ( ( ) => DeleteZoneID , value ) ;
165
145
IsDirty = true ;
166
146
}
167
147
}
168
148
public bool Melt
169
149
{
170
- get => _Melt ;
150
+ get => Get ( ( ) => Melt ) ;
171
151
set
172
152
{
173
- Set ( ( ) => Melt , ref _Melt , value ) ;
153
+ Set ( ( ) => Melt , value ) ;
174
154
IsDirty = true ;
175
155
}
176
156
}
177
157
public ObservableCollection < ProjectItem > Items
178
158
{
179
- get => _Items ;
159
+ get => Get ( ( ) => Items ) ;
180
160
set
181
161
{
182
- if ( _Items != null ) _Items . CollectionChanged -= _Items_CollectionChanged ;
183
- Set ( ( ) => Items , ref _Items , value ) ;
184
- if ( _Items != null ) _Items . CollectionChanged += _Items_CollectionChanged ;
162
+ if ( Get ( ( ) => Items ) != null ) Get ( ( ) => Items ) . CollectionChanged -= Items_CollectionChanged ;
163
+ Set ( ( ) => Items , value ) ;
164
+ if ( value != null ) value . CollectionChanged += Items_CollectionChanged ;
185
165
RaisePropertyChanged ( ( ) => ProjectName ) ;
186
166
IsDirty = true ;
187
167
}
188
168
}
189
169
public ValidationError [ ] ValidationErrors
190
170
{
191
- get => _ValidationErrors ;
192
- set => Set ( ( ) => ValidationErrors , ref _ValidationErrors , value ) ;
171
+ get => Get ( ( ) => ValidationErrors ) ;
172
+ set => Set ( ( ) => ValidationErrors , value ) ;
193
173
}
194
174
public int ValidationErrorCount
195
175
{
196
- get => _ValidationErrorCount ;
197
- set => Set ( ( ) => ValidationErrorCount , ref _ValidationErrorCount , value ) ;
176
+ get => Get ( ( ) => ValidationErrorCount ) ;
177
+ set => Set ( ( ) => ValidationErrorCount , value ) ;
198
178
}
199
179
public int ValidationWarningCount
200
180
{
201
- get => _ValidationWarningCount ;
202
- set => Set ( ( ) => ValidationWarningCount , ref _ValidationWarningCount , value ) ;
181
+ get => Get ( ( ) => ValidationWarningCount ) ;
182
+ set => Set ( ( ) => ValidationWarningCount , value ) ;
203
183
}
204
184
public int ValidationMessageCount
205
185
{
206
- get => _ValidationMessageCount ;
207
- set => Set ( ( ) => ValidationMessageCount , ref _ValidationMessageCount , value ) ;
186
+ get => Get ( ( ) => ValidationMessageCount ) ;
187
+ set => Set ( ( ) => ValidationMessageCount , value ) ;
208
188
}
209
189
210
190
public string ObfuscationExample => Lookups . ObfuscationExamples [ Obfuscation ] ;
@@ -518,8 +498,8 @@ public ValidationError[] ValidateBuild()
518
498
}
519
499
else
520
500
{
521
- string originalExtension = PathEx . GetExtension ( file . FullName ) ;
522
- string newExtension = PathEx . GetExtension ( file . Name ) ;
501
+ string originalExtension = Path . GetExtension ( file . FullName ) . TrimStart ( '.' ) ;
502
+ string newExtension = Path . GetExtension ( file . Name ) . TrimStart ( '.' ) ;
523
503
if ( newExtension == "" )
524
504
{
525
505
errors . Add ( ValidationError . CreateWarning ( file . SourceFileName , "'" + file . Name . Trim ( ) + "' has no extension (suggested: " + originalExtension + ")" ) ) ;
@@ -529,7 +509,7 @@ public ValidationError[] ValidateBuild()
529
509
errors . Add ( ValidationError . CreateWarning ( file . SourceFileName , "'" + file . Name . Trim ( ) + "' has a different extension than the original file (" + originalExtension + ")" ) ) ;
530
510
}
531
511
532
- if ( PathEx . GetExtension ( file . Name , true ) . EqualsAny ( unintendedFileExtensions ) )
512
+ if ( Path . GetExtension ( file . Name ) . TrimStart ( '.' ) . ToLower ( ) . EqualsAny ( unintendedFileExtensions ) )
533
513
{
534
514
errors . Add ( ValidationError . CreateWarning ( file . SourceFileName , "File extension '" + Path . GetExtension ( file . Name ) + "' - Possibly unintended file" ) ) ;
535
515
}
@@ -569,11 +549,11 @@ public ValidationError[] ValidateBuild()
569
549
}
570
550
else
571
551
{
572
- if ( PathEx . GetExtension ( url . Name ) == "" )
552
+ if ( Path . GetExtension ( url . Name ) . TrimStart ( '.' ) == "" )
573
553
{
574
554
errors . Add ( ValidationError . CreateWarning ( source , "'" + url . Name . Trim ( ) + "' has no extension" ) ) ;
575
555
}
576
- if ( PathEx . GetExtension ( url . Name , true ) . EqualsAny ( unintendedFileExtensions ) )
556
+ if ( Path . GetExtension ( url . Name ) . TrimStart ( '.' ) . ToLower ( ) . EqualsAny ( unintendedFileExtensions ) )
577
557
{
578
558
errors . Add ( ValidationError . CreateWarning ( source , "File extension '" + Path . GetExtension ( url . Name ) + "' - Possibly unintended file" ) ) ;
579
559
}
@@ -608,7 +588,7 @@ public ValidationError[] ValidateBuild()
608
588
return errors . ToArray ( ) ;
609
589
}
610
590
611
- private void _Items_CollectionChanged ( object sender , NotifyCollectionChangedEventArgs e )
591
+ private void Items_CollectionChanged ( object sender , NotifyCollectionChangedEventArgs e )
612
592
{
613
593
RaisePropertyChanged ( ( ) => ProjectName ) ;
614
594
}
0 commit comments