6
6
using System . Diagnostics ;
7
7
using System . Globalization ;
8
8
using System . IO ;
9
+ using System . Linq ;
9
10
using System . Reflection ;
10
11
using System . Threading . Tasks ;
12
+ using System . Windows ;
11
13
12
14
namespace GTweak . Utilities
13
15
{
14
- internal struct Settings
16
+ internal readonly struct Settings
15
17
{
16
18
internal static string PathConfig = string . Empty ;
17
19
internal static string PathSound => Path . Combine ( Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) ) + @"\GTweak\Sound.mp3" ;
@@ -101,44 +103,51 @@ internal static void ChangingParameters<T>(T value, string selection)
101
103
102
104
internal static void SaveFileConfig ( )
103
105
{
104
- SaveFileDialog saveFileDialog = new SaveFileDialog
105
- {
106
- FileName = "Config GTweak" ,
107
- Filter = "(*.INI)|*.INI" ,
108
- RestoreDirectory = true
109
- } ;
110
-
111
- Nullable < bool > isResult = saveFileDialog . ShowDialog ( ) ;
106
+ if ( СonfigSettings . configConfidentiality . Count == 0 && СonfigSettings . configInterface . Count == 0
107
+ && СonfigSettings . configServices . Count == 0 && СonfigSettings . configSystem . Count == 0 )
108
+ new ViewNotification ( ) . Show ( "" , ( string ) Application . Current . Resources [ "title1_notification" ] , ( string ) Application . Current . Resources [ "export_warning_notification" ] ) ;
112
109
113
- if ( isResult == true )
110
+ else
114
111
{
115
- string path = Path . GetDirectoryName ( saveFileDialog . FileName ) ;
116
- string filename = Path . GetFileNameWithoutExtension ( saveFileDialog . FileName ) ;
112
+ SaveFileDialog saveFileDialog = new SaveFileDialog
113
+ {
114
+ FileName = "Config GTweak" ,
115
+ Filter = "(*.INI)|*.INI" ,
116
+ RestoreDirectory = true
117
+ } ;
117
118
118
- try
119
+ Nullable < bool > isResult = saveFileDialog . ShowDialog ( ) ;
120
+
121
+ if ( isResult == true )
119
122
{
120
- PathConfig = path + @"\" + filename + ".ini" ;
123
+ string path = Path . GetDirectoryName ( saveFileDialog . FileName ) ;
124
+ string filename = Path . GetFileNameWithoutExtension ( saveFileDialog . FileName ) ;
125
+
126
+ try
127
+ {
128
+ PathConfig = path + @"\" + filename + ".ini" ;
121
129
122
- if ( File . Exists ( PathConfig ) )
123
- File . Delete ( PathConfig ) ;
130
+ if ( File . Exists ( PathConfig ) )
131
+ File . Delete ( PathConfig ) ;
124
132
125
- СonfigSettings settingsFileINI = new СonfigSettings ( PathConfig ) ;
126
- settingsFileINI . WriteConfig ( "GTweak" , "Author" , "Greedeks" ) ;
127
- settingsFileINI . WriteConfig ( "GTweak" , "Release" , "v4" ) ;
133
+ СonfigSettings settingsFileINI = new СonfigSettings ( PathConfig ) ;
134
+ settingsFileINI . WriteConfig ( "GTweak" , "Author" , "Greedeks" ) ;
135
+ settingsFileINI . WriteConfig ( "GTweak" , "Release" , "v4" ) ;
128
136
129
- foreach ( KeyValuePair < string , string > addConfidentiality in СonfigSettings . configConfidentiality )
130
- settingsFileINI . WriteConfig ( "Confidentiality Tweaks" , addConfidentiality . Key , addConfidentiality . Value ) ;
137
+ foreach ( KeyValuePair < string , string > addConfidentiality in СonfigSettings . configConfidentiality )
138
+ settingsFileINI . WriteConfig ( "Confidentiality Tweaks" , addConfidentiality . Key , addConfidentiality . Value ) ;
131
139
132
- foreach ( KeyValuePair < string , string > addInterface in СonfigSettings . configInterface )
133
- settingsFileINI . WriteConfig ( "Interface Tweaks" , addInterface . Key , addInterface . Value ) ;
140
+ foreach ( KeyValuePair < string , string > addInterface in СonfigSettings . configInterface )
141
+ settingsFileINI . WriteConfig ( "Interface Tweaks" , addInterface . Key , addInterface . Value ) ;
134
142
135
- foreach ( KeyValuePair < string , string > addServices in СonfigSettings . configServices )
136
- settingsFileINI . WriteConfig ( "Services Tweaks" , addServices . Key , addServices . Value ) ;
143
+ foreach ( KeyValuePair < string , string > addServices in СonfigSettings . configServices )
144
+ settingsFileINI . WriteConfig ( "Services Tweaks" , addServices . Key , addServices . Value ) ;
137
145
138
- foreach ( KeyValuePair < string , string > addSystem in СonfigSettings . configSystem )
139
- settingsFileINI . WriteConfig ( "System Tweaks" , addSystem . Key , addSystem . Value ) ;
146
+ foreach ( KeyValuePair < string , string > addSystem in СonfigSettings . configSystem )
147
+ settingsFileINI . WriteConfig ( "System Tweaks" , addSystem . Key , addSystem . Value ) ;
148
+ }
149
+ catch ( Exception ex ) { Debug . WriteLine ( ex . Message . ToString ( ) ) ; }
140
150
}
141
- catch ( Exception ex ) { Debug . WriteLine ( ex . Message . ToString ( ) ) ; }
142
151
}
143
152
}
144
153
@@ -156,9 +165,14 @@ internal static void OpenFileConfig()
156
165
СonfigSettings settingsFileINI = new СonfigSettings ( PathConfig ) ;
157
166
158
167
if ( settingsFileINI . ReadConfig ( "GTweak" , "Author" ) . Contains ( "Greedeks" ) && settingsFileINI . ReadConfig ( "GTweak" , "Release" ) . Contains ( "v4" ) )
159
- new ImportWindow ( ) . ShowDialog ( ) ;
168
+ {
169
+ if ( File . ReadLines ( PathConfig ) . Any ( line => line . Contains ( "TglButton" ) ) || File . ReadLines ( PathConfig ) . Any ( line => line . Contains ( "Slider" ) ) )
170
+ new ImportWindow ( ) . ShowDialog ( ) ;
171
+ else
172
+ new ViewNotification ( ) . Show ( "" , ( string ) Application . Current . Resources [ "title1_notification" ] , ( string ) Application . Current . Resources [ "import_empty_notification" ] ) ;
173
+ }
160
174
else
161
- new ViewNotification ( ) . Show ( "" , ( string ) System . Windows . Application . Current . Resources [ "title1_notification" ] , ( string ) System . Windows . Application . Current . Resources [ "import_warning_notification" ] ) ;
175
+ new ViewNotification ( ) . Show ( "" , ( string ) Application . Current . Resources [ "title1_notification" ] , ( string ) Application . Current . Resources [ "import_warning_notification" ] ) ;
162
176
}
163
177
}
164
178
@@ -170,7 +184,7 @@ internal static void SelfRemoval()
170
184
RegistryHelp . DeleteFolderTree ( Registry . LocalMachine , @"SOFTWARE\Microsoft\Tracing\GTweak_RASAPI32" ) ;
171
185
RegistryHelp . DeleteFolderTree ( Registry . LocalMachine , @"SOFTWARE\Microsoft\Tracing\GTweak_RASMANCS" ) ;
172
186
173
- System . Windows . Application . Current . Shutdown ( ) ;
187
+ Application . Current . Shutdown ( ) ;
174
188
Process . Start ( new ProcessStartInfo ( )
175
189
{
176
190
Arguments = "/C choice /C Y /N /D Y /T 3 & Del \" " + ( new FileInfo ( new Uri ( Assembly . GetExecutingAssembly ( ) . CodeBase ) . LocalPath ) ) . Name + "\" & " +
0 commit comments