Ejemplo n.º 1
0
        private void B_More(object sender, RoutedEventArgs e)
        {
            // 设置
            Pages.Options opt = new Pages.Options();
            Application   app = Application.Current;

            changePage(opt, (string)app.Resources["options"]);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 检查更新
        /// </summary>
        /// <returns></returns>
        private void getUpdate()
        {
            Log.AddLog("update", "正在检查更新……");

            if (File.Exists("UpdateBash.bat"))
            {
                File.Delete("UpdateBash.bat");
                if (File.Exists("run.vbs"))
                {
                    File.Delete("run.vbs");
                }
                Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate()
                {
                    MsgAdd(
                        new List <string> {
                        "更新完成", "我们成功更新了 Stapx Steve Tool Box!开始体验全新的功能吧!"
                    },
                        new List <string> {
                        "好"
                    }, null);
                });
            }

            if (Options.GetOpt("stopUpd")[0] == "false" || Options.GetOpt("stopUpd")[0] == "ERR")
            {
                try
                {
                    string updateVersion = "1";

                    int    updLink = Options.GetOpt("updLink")[0] == "ERR" ? 0 : int.Parse(Options.GetOpt("updLink")[0]);
                    string getStr  = HttpUitls.Get(linkList[updLink].link);
                    try
                    {
                        JObject obj = JObject.Parse(getStr);
                        if (obj["Version"].ToString() == updateVersion)
                        {
                            back.Add(obj["MainVersion"].ToString());
                            back.Add(obj["Time"].ToString());
                            back.Add(obj["Url"].ToString());
                            back.Add(obj["Logs"].ToString());
                            Log.AddLog("update", "检查更新完成。");
                        }
                        else
                        {
                            Log.AddErr("update", "检查更新失败:更新文件版本不符合,更新失败。");
                        }
                    }
                    catch (Exception e)
                    {
                        Log.AddErr("update", "检查更新失败:" + e + "\n" + getStr.Replace("\n", "\\n").Replace("\t", "\\t"));
                        UI.ToastHelper.Add("检查更新失败");
                    }
                    if (back.Count != 0 && double.Parse(back[0]) <= verInfo.verNum)
                    {
                        Log.AddLog("update", "当前版本为最新。");
                    }
                    else
                    {
                        Log.AddLog("update", "最新版本为:" + back[0] + " > " + verInfo.verNum);
                        Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate()
                        {
                            // 切换到设置界面
                            Pages.Options opt = new Pages.Options();
                            Application app   = Application.Current;
                            changePage(opt, app.Resources["options"] + " - " + app.Resources["options_main_title_def"]);
                        });
                    }
                }
                catch (Exception e)
                {
                    Log.AddErr("update", "检查更新失败:" + e);
                    UI.ToastHelper.Add("检查更新失败");
                }
            }
            else
            {
                Log.AddLog("update", "检查更新已关闭。");
            }
        }