Example #1
0
        private static void OnQQChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            string QQ     = e.NewValue.ToString();
            Action action = new Action(() => {
                String iduri   = "https://api.toubiec.cn/qq?qq=" + QQ + "&size=300";
                string GetJson = HttpUitls.Get(iduri, "DEFALT");
                JObject obj    = JObject.Parse(GetJson);
                Info.QQName    = obj["name"].ToString();
            });

            action.BeginInvoke(null, null);
        }
Example #2
0
        //运行
        private void RunTool(object sender, RoutedEventArgs e)
        {
            this.IconCard.Visibility = Visibility.Collapsed;
            ButtonHelper.SetIsWaiting(RunButton, true);
            if (String.IsNullOrWhiteSpace(PackageIn.Text))
            {
                error.ErrorTo("发现错误(SOS - 001):输入为空。", Percent, Errorsay);
                ButtonHelper.SetIsWaiting(RunButton, false);
                this.RunCard.Visibility = Visibility.Visible;
                return;
            }

            try
            {
                string url       = "https://setting.smartisan.com/app/icon";
                string packageof = "[{\"package\":\"" + PackageIn.Text + "\"}]";

                string GetJson = HttpUitls.Post(url, packageof, "", "application/json");

                JObject obj = JObject.Parse(GetJson);

                JToken record = obj["body"]["app_icon"][PackageIn.Text];

                JToken recorda = obj["body"]["app_icon"][PackageIn.Text];
                int    num     = -1;
                int    numa    = 0;
                if (!Directory.Exists("SSTB/Files/Logo"))
                {
                    Directory.CreateDirectory("SSTB/Files/Logo");
                }
                if (!fist)
                {
                    Grid grida = new Grid();
                    for (int i = 0; i < names.Length; i++)
                    {
                        grida = Iconall.FindName(names[i]) as Grid;
                        Iconall.Children.Remove(grida);
                        Iconall.UnregisterName(names[i]);
                    }
                }
                fist = false;
                foreach (JObject jpa in recorda)
                {
                    numa++;
                }
                names = new String[numa];
                foreach (JObject jp in record)
                {
                    num++;
                    if (!Directory.Exists("SSTB/Files/Logo/" + num))
                    {
                        Directory.CreateDirectory("SSTB/Files/Logo/" + num);
                    }
                    string filepath  = "SSTB/Files/Logo/" + num + "/logo.png";
                    string filepatha = "SSTB/Files/Logo/" + num + "/md5.xml";
                    string filepathb = "SSTB/Files/Logo/logo" + num + ".png";

                    WebClient mywebclient = new WebClient();

                    string urlPng = jp["logo"].ToString();
                    string urlmd5 = jp["md5"].ToString();

                    mywebclient.DownloadFile(urlPng, filepath);
                    mywebclient.DownloadFile(urlmd5, filepatha);
                    mywebclient.DownloadFile(urlPng, filepathb);

                    Image img  = new Image();
                    Grid  grid = new Grid();

                    Iconall.Children.Add(grid);
                    grid.Children.Add(img);

                    RegisterName("grid" + num, grid);
                    names[num] = "grid" + num;

                    img.Height = 256;
                    img.Width  = 540;
                    Thickness thickness = new Thickness();
                    thickness.Left   = 0;
                    thickness.Top    = 18;
                    thickness.Right  = 0;
                    thickness.Bottom = 15;
                    img.Margin       = thickness;
                    img.Source       = new BitmapImage(new Uri(urlPng));
                    //this.T.Source = new BitmapImage(new Uri(urlPng));
                }
                T5.Text = "原图以及MD5检验文件已保存在程序所在目录的File/Logo文件夹下";
                this.IconCard.Visibility = Visibility.Visible;

                this.RunCard.Visibility = Visibility.Collapsed;
            }
            catch (Exception ex)
            {
                error.ErrorTo("发现错误(SOS - 003):请求图标失败, 错误原因:", "" + ex, Percent, Errorsay);
                this.RunCard.Visibility = Visibility.Visible;
                ButtonHelper.SetIsWaiting(RunButton, false);
                return;
            }
            ButtonHelper.SetIsWaiting(RunButton, false);
        }
Example #3
0
        //运行
        private void RunTool(object sender, RoutedEventArgs e)
        {
            err = -1;
            this.HandCard.Visibility = Visibility.Collapsed;
            this.ColCard.Visibility  = Visibility.Collapsed;
            Error error = new Error();

            Action action = new Action(() => {
                this.Dispatcher.BeginInvoke(new Action(() =>
                {
                    if (String.IsNullOrWhiteSpace(QQ.Text) || String.IsNullOrWhiteSpace(QQY.Text))
                    {
                        error.ErrorTo("发现错误(EQQ - 002):输入为空。", Percent, Errorsay);
                        this.RunCard.Visibility = Visibility.Visible;
                        return;
                    }
                }), System.Windows.Threading.DispatcherPriority.SystemIdle, null);
                try
                {
                    err        = 0;
                    string QQa = "NULL";
                    this.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        QQa = QQ.Text;
                    }), System.Windows.Threading.DispatcherPriority.SystemIdle, null);
                    Thread.Sleep(3000);
                    string url            = "http://q1.qlogo.cn/g?b=qq&nk=" + QQa + "&s=5";
                    string filepath       = "SSTB/Files/Head/Head" + QQa + ".jpg";
                    WebClient mywebclient = new WebClient();
                    mywebclient.DownloadFile(url, filepath);

                    string urls = "http://q1.qlogo.cn/g?b=qq&nk=" + QQa + "&s=3";
                    this.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        this.Hand.Source         = new BitmapImage(new Uri(urls));
                        T5.Text                  = "高清头像已保存到程序File所在位置";
                        this.HandCard.Visibility = Visibility.Visible;
                    }), System.Windows.Threading.DispatcherPriority.SystemIdle, null);
                }
                catch (Exception ex)
                {
                    this.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        err = 1;
                        String errorString = ex.ToString();
                        error.ErrorTo("发现错误(EQQ - 001):请求头像失败, 错误原因:" + errorString.Substring(0, errorString.IndexOf("在")), Percent, Errorsay);
                    }), System.Windows.Threading.DispatcherPriority.SystemIdle, null);
                }
            });

            action.BeginInvoke(null, null);

            Action actiona = new Action(() => {
                try
                {
                    err        = 0;
                    string QQa = "NULL";
                    this.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        QQa = QQ.Text;
                    }), System.Windows.Threading.DispatcherPriority.SystemIdle, null);
                    Thread.Sleep(3000);
                    String iduri   = "https://api.toubiec.cn/qq?qq=" + QQa + "&size=300";
                    string GetJson = HttpUitls.Get(iduri, "DEFALT");
                    JObject obj    = JObject.Parse(GetJson);
                    this.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        if (err == 1)
                        {
                            return;
                        }
                        MT3.Text = "其他操作" + " —— " + obj["name"].ToString();
                        this.ColCard.Visibility = Visibility.Visible;
                    }), System.Windows.Threading.DispatcherPriority.SystemIdle, null);
                }
                catch (Exception ex)
                {
                    this.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        err = 1;
                        String errorString = ex.ToString();
                        error.ErrorTo("发现错误(EQQ - 003):请求昵称失败, 错误原因:" + errorString.Substring(0, errorString.IndexOf("在")), Percent, Errorsay);
                    }), System.Windows.Threading.DispatcherPriority.SystemIdle, null);
                }
            });

            actiona.BeginInvoke(null, null);
            if (err == 1)
            {
                this.RunCard.Visibility = Visibility.Visible;
            }
            else if (err == 0)
            {
                this.RunCard.Visibility = Visibility.Collapsed;
            }
        }
Example #4
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", "检查更新已关闭。");
            }
        }