Skip to content

Commit bb7fb4d

Browse files
committed
optimize startup #54 (remove origResourceColors)
1 parent d46c20f commit bb7fb4d

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

Diff for: UnityLauncherPro/MainWindow.xaml.cs

+6-11
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ public partial class MainWindow : Window
6666
string defaultDateFormat = "dd/MM/yyyy HH:mm:ss";
6767
string adbLogCatArgs = defaultAdbLogCatArgs;
6868

69-
Dictionary<string, SolidColorBrush> origResourceColors = new Dictionary<string, SolidColorBrush>();
70-
7169
string currentBuildReportProjectPath = null;
7270
string currentBuildPluginsRelativePath = null;
7371
//List<List<string>> buildReports = new List<List<string>>();
@@ -168,12 +166,6 @@ void Start()
168166
// build notifyicon (using windows.forms)
169167
notifyIcon.MouseClick += new System.Windows.Forms.MouseEventHandler(NotifyIcon_MouseClick);
170168

171-
// get original colors
172-
foreach (DictionaryEntry item in Application.Current.Resources.MergedDictionaries[0])
173-
{
174-
origResourceColors[item.Key.ToString()] = (SolidColorBrush)item.Value;
175-
}
176-
177169
ApplyTheme(txtCustomThemeFile.Text);
178170

179171
// for autostart with minimized
@@ -198,7 +190,7 @@ void Start()
198190
if (Settings.Default.disableUnityHubLaunch == true) StartHubPipe();
199191

200192
isInitializing = false;
201-
}
193+
} // Start()
202194

203195
private static NamedPipeServerStream hubPipeServer;
204196
private CancellationTokenSource _hubCancellationTokenSource;
@@ -2762,9 +2754,12 @@ void ApplyTheme(string themeFile)
27622754

27632755
void ResetTheme()
27642756
{
2765-
foreach (KeyValuePair<string, SolidColorBrush> item in origResourceColors)
2757+
foreach (DictionaryEntry item in Application.Current.Resources.MergedDictionaries[0])
27662758
{
2767-
Application.Current.Resources[item.Key] = item.Value;
2759+
if (item.Key is string key && item.Value is SolidColorBrush brush)
2760+
{
2761+
Application.Current.Resources[key] = brush;
2762+
}
27682763
}
27692764
}
27702765

0 commit comments

Comments
 (0)