public async static void Loading(Action action, string text) { Page4 page4 = new Page4(); page4.IsLoading = true; MainWindow.Frame1.Navigate(page4); Load.Content = text; await Task.Run(action); MainWindow.Frame1.Navigate(null); }
private void TextBox_BackGround_TextChanged(object sender, TextChangedEventArgs e) { JArray jArray = JArray.Parse(XMCL.Properties.Resources.Egg); string Text = TextBox_BackGround.Text; for (int i = 0; i < jArray.Count; i++) { JObject jObject = (JObject)jArray[i]; if (Text == (string)jObject["name"]) { string[] color = ((string)jObject["Color"]).Split(':'); string Filename = App.Folder_XMCL + "\\" + jObject["File"]; Page4.Loading(new Action(() => { WebClient web = new WebClient(); try { this.Dispatcher.Invoke(new Action(async() => { await MainWindow.ShowTip("彩蛋主题正在配置中.....\r\n请不要关闭XL启动器", 2); })); web.DownloadFile((string)jObject["Url"], Filename); this.Dispatcher.Invoke(new Action(() => { TextBox_BackGround.Text = Filename; Json.Write("Individualization", "Background", Filename); MainWindow.Background.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Settings.Background)); App.Themes(color[0], color[1], color[2]); })); } catch { } web.Dispose(); this.Dispatcher.Invoke(new Action(async() => { await MainWindow.ShowTip("彩蛋主题配置完成", 2); })); }), "正在更换主题"); } } }