private void ErrorMSG(String ex, String say) { this.Dispatcher.BeginInvoke(new Action(() => { SSMessageHelper.noNo = false; ButtonHelper.SetIcon(SSMessageHelper.Icon, ""); SSMessageHelper.Title = "更新失败"; SSMessageHelper.bNOtext = "不用不用"; SSMessageHelper.bOKtext = "打开日志"; SSMessageHelper.Says = "在更新时发生了错误,更新失败。" + say + "\n" + ex; SSMessageBox MB = new SSMessageBox(); ParentWindow.IsMaskVisible = true; MB.WindowStartupLocation = WindowStartupLocation.CenterOwner; MB.Owner = ParentWindow; MB.ShowDialog(); ParentWindow.IsMaskVisible = false; if (SSMessageHelper.buttonOK) { string where = Directory.GetCurrentDirectory(); where = where + @"\SSTB\Log\log.log"; System.Diagnostics.Process process; process = System.Diagnostics.Process.Start(@where); } ForceClose(); }), DispatcherPriority.SystemIdle, null); }
public SSMessageBox() { InitializeComponent(); SSMessageHelper.buttonOK = false; SSMessageHelper.buttonNO = false; BG.BeginInit(); BG.Source = baseColora.Bgpa; BG.EndInit(); this.Background = baseColora.Tran; Border.Background = baseColora.DBg; WindowXCaption.SetHeight(this, 0); this.ICON.Foreground = baseColora.Fg; ButtonHelper.SetHoverBrush(ICON, baseColora.Fg); ButtonHelper.SetIcon(ICON, ButtonHelper.GetIcon(SSMessageHelper.Icon)); this.OK.Content = SSMessageHelper.bOKtext; this.OK.Foreground = baseColora.Fg; this.OK.Background = baseColora.Bg; ButtonHelper.SetHoverBrush(OK, baseColora.Main); ButtonHelper.SetCornerRadius(OK, new CornerRadius(3, 3, 3, 3)); this.CANC.Content = SSMessageHelper.bNOtext; this.CANC.Foreground = baseColora.Fg; this.CANC.Background = baseColora.Bg; ButtonHelper.SetHoverBrush(CANC, baseColora.Main); ButtonHelper.SetCornerRadius(CANC, new CornerRadius(3, 3, 3, 3)); this.TITLE.Text = SSMessageHelper.Title; this.TITLE.Foreground = baseColora.Fg; this.TITLE.Background = baseColora.Tran; this.TITLE.FontFamily = baseColora.Fonts; this.TITLE.FontSize = 25; this.SAY.Text = " " + SSMessageHelper.Says; this.SAY.Foreground = baseColora.Fg; this.SAY.Background = baseColora.Tran; this.SAY.FontFamily = baseColora.Fonts; this.SAY.FontSize = 16; if (SSMessageHelper.noNo) { this.CANC.Visibility = Visibility.Collapsed; } }
void CD_Del(object sender, MouseButtonEventArgs e) { SSMessageHelper.noNo = false; ButtonHelper.SetIcon(SSMessageHelper.Icon, ""); SSMessageHelper.Title = "确认一下"; SSMessageHelper.Says = "确认要删除卡片嘛,它和它里面的事件们将消失很久!(真的很久很久……)"; SSMessageBox MB = new SSMessageBox(); ParentWindow.IsMaskVisible = true; MB.WindowStartupLocation = WindowStartupLocation.CenterOwner; MB.Owner = ParentWindow; MB.ShowDialog(); ParentWindow.IsMaskVisible = false; if (SSMessageHelper.buttonOK) { DeleteItem(1, new ControlItemInfo { IsDelInFile = true, IsFinish = false }); } }
private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (a.IsSelected) { if (isRun) { ButtonHelper.SetIcon(Run, ""); IconHelper.SetFontSize(Run, 15); } else { ButtonHelper.SetIcon(Run, ""); IconHelper.SetFontSize(Run, 25); } } else if (b.IsSelected) { ButtonHelper.SetIcon(Run, ""); IconHelper.SetFontSize(Run, 20); } }
private void TIMEOK_Click(object sender, RoutedEventArgs e) { try { if (!String.IsNullOrWhiteSpace(TIME.Text)) { MainWindow.times = int.Parse(TIME.Text); this.Dispatcher.BeginInvoke(new Action(() => { ParentWindow.RunXH(); }), DispatcherPriority.SystemIdle, null); } } catch { this.Dispatcher.BeginInvoke(new Action(() => { ParentWindow.toolTip.ToolTipText += "\n这不是个数字。(点击消除)"; ButtonHelper.SetIcon(ParentWindow.ERR, ""); }), DispatcherPriority.SystemIdle, null); } }
private void DelCard_Click(object sender, RoutedEventArgs e) { Button button = (Button)sender; string cardname = button.Name.Substring(1); card = (Card)FindName(cardname); SSMessageHelper.noNo = false; ButtonHelper.SetIcon(SSMessageHelper.Icon, ""); SSMessageHelper.Title = "确认一下"; SSMessageHelper.Says = "确认要删除卡片嘛,它和它里面的事件们将消失很久!(真的很久很久……)"; SSMessageBox MB = new SSMessageBox(); ParentWindow.IsMaskVisible = true; MB.WindowStartupLocation = WindowStartupLocation.CenterOwner; MB.Owner = ParentWindow; MB.ShowDialog(); ParentWindow.IsMaskVisible = false; if (SSMessageHelper.buttonOK) { DeleteItem(1, new ControlItemInfo { IsDelInFile = true, IsFinish = false }); } }
private void Seeing() { if (!Directory.Exists("Cache")) { Directory.CreateDirectory("Cache"); } if (File.Exists("Cache\\logs.log")) { File.Delete("Cache\\logs.log"); } this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate() { NamePorc.Text = "加载中"; IDPorc.Text = "加载中"; UsePorc.Text = "加载中"; Ping.Text = "加载中"; }); Process p = SSUserClass.Proc.GetProc("edge"); PerformanceCounter pf1 = new PerformanceCounter("Process", "Working Set - Private", p.ProcessName); this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate() { isRun = true; ButtonHelper.SetIcon(Run, ""); IconHelper.SetFontSize(Run, 15); NamePorc.Text = p.ProcessName; IDPorc.Text = p.Id + "/" + p.SessionId; UsePorc.Text = pf1.NextValue() / 1024 + "KB"; ProgressBarHelper.SetAnimateTo(openPer, 100); isOpen.Text = "启动完成"; TaskBar.ToolTipText = "N2N Desktop Launcher - 正在运行"; taskBarRun.IsChecked = true; logTextBox.Text = ">[ 进程守护 ] 进程监控已正常运转——\n"; PingReply reply = SSUserClass.Net.GetPing(nowUsed.severIP, "abcd"); ButtonHelper.SetIsWaiting(Run, false); if (reply.Status == IPStatus.Success) { Ping.Text = (reply.RoundtripTime).ToString() + "ms"; } }); int failepingTimes = 0; int passtime = 0; while (SSUserClass.Proc.HasProc("edge")) { String nexline = process.StandardOutput.ReadLine(); if (!String.IsNullOrWhiteSpace(nexline)) { this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate() { using (StreamWriter sw = File.AppendText("Cache\\logs.log")) { sw.WriteLine(nexline); } if (nexline.IndexOf("WARNING") > 0) { logTextBox.Text += nexline + "\n"; logTextBox.Text += ">[ 进程守护 ] 发现疑似报错!\n"; } else if (nexline.IndexOf("ERROR") > 0) { logTextBox.Text += nexline + "\n"; logTextBox.Text += ">[ 进程守护 ] 发现严重错误!\n"; panErrorMsg.Visibility = Visibility.Visible; errMode = 0; errorTitle.Text = "错误"; errorSays.Text = "发现了错误:" + nexline; SSUserClass.Proc.KillProc(SSUserClass.Proc.GetProc("edge")); } else { logTextBox.Text += nexline + "\n"; } }); } if (passtime >= 30000) { passtime = 0; } if (passtime % 2000 == 0) { //刷新进程信息 try { p = SSUserClass.Proc.GetProc("edge"); pf1 = new PerformanceCounter("Process", "Working Set - Private", p.ProcessName); this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate() { NamePorc.Text = p.ProcessName; IDPorc.Text = p.Id + "/" + p.SessionId; UsePorc.Text = pf1.NextValue() / 1024 + "KB"; ProgressBarHelper.SetAnimateTo(openPer, 100); }); } catch { } //刷新Ping PingReply reply = SSUserClass.Net.GetPing(nowUsed.severIP, "abcd"); if (reply.Status == IPStatus.Success) { failepingTimes = 0; this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate() { Ping.Text = (reply.RoundtripTime).ToString() + "ms"; }); } else { failepingTimes++; if (failepingTimes >= 5) { //判定掉线重启 SSUserClass.Proc.KillProc(SSUserClass.Proc.GetProc("edge")); RunFun(); } } } passtime += 20; Thread.Sleep(20); } this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate() { RunInfo.Visibility = Visibility.Collapsed; ProgressBarHelper.SetAnimateTo(openPer, 0); isOpen.Text = "未启用"; TaskBar.ToolTipText = "N2N Desktop Launcher -未启用"; ButtonHelper.SetIcon(Run, ""); IconHelper.SetFontSize(Run, 25); taskBarRun.IsChecked = false; }); isRun = false; }
private void UpdateRight() //检查更新 { #if DEBUG return; #endif if (File.Exists("UpdateBash.bat")) { File.Delete("UpdateBash.bat"); if (File.Exists("run.vbs")) { File.Delete("run.vbs"); } this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate() { SSMessageHelper.noNo = true; ButtonHelper.SetIcon(SSMessageHelper.Icon, ""); SSMessageHelper.Title = "更新完成"; SSMessageHelper.Says = "我们成功更新了 SSTB !开始体验全新的功能吧!"; SSMessageBox MB = new SSMessageBox(); this.IsMaskVisible = true; MB.WindowStartupLocation = WindowStartupLocation.CenterOwner; MB.Owner = this; MB.ShowDialog(); this.IsMaskVisible = false; }); } error.logWriter("检查更新……", false); string GetJson; String saysuri = "https://stapxs.neocities.org/SSTB-NowVersion.txt"; try { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; GetJson = HttpUitls.Get(saysuri, "DEFALT"); } catch (Exception ex) { error.logWriter("检查更新错误 :" + ex, false); return; } if (String.IsNullOrWhiteSpace(GetJson)) { return; } JObject obj = JObject.Parse(GetJson); if (int.Parse(obj["Version"].ToString()) != nUpdateVersion) { this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate() { SSMessageHelper.noNo = true; ButtonHelper.SetIcon(SSMessageHelper.Icon, ""); SSMessageHelper.Title = "发现更新"; SSMessageHelper.Says = "我们检查到了版本更新,但是由于更新文件版本不符,我们无法确认更新的可用性,请手动确认版本更新。\n(当前软件内更新文件标记版本为 " + nUpdateVersion + " ,获取到的更新文件标记版本为 " + obj["Version"].ToString() + " )"; SSMessageBox MB = new SSMessageBox(); this.IsMaskVisible = true; MB.WindowStartupLocation = WindowStartupLocation.CenterOwner; MB.Owner = this; MB.ShowDialog(); this.IsMaskVisible = false; }); } else { if (!obj["MainVersion"].ToString().Equals(stVersion)) { this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate() { SSMessageHelper.noNo = false; ButtonHelper.SetIcon(SSMessageHelper.Icon, ""); SSMessageHelper.bOKtext = "在线更新"; SSMessageHelper.bNOtext = "知道了"; SSMessageHelper.Title = "发现更新"; SSMessageHelper.Says = "我们检查到了版本更新,最新版本为:" + obj["MainVersion"].ToString() + ",更新时间:" + obj["Time"].ToString() + ",选择在线更新将从GitHub在线下载。\n( GitHub 有约1小时的CDN缓存延时,建议在更新时间一小时后更新 )\n更新日志如下:\n" + obj["Logs"].ToString(); SSMessageBox MB = new SSMessageBox(); this.IsMaskVisible = true; MB.WindowStartupLocation = WindowStartupLocation.CenterOwner; MB.Owner = this; MB.ShowDialog(); this.IsMaskVisible = false; SSMessageHelper.bOKtext = "好的"; if (SSMessageHelper.buttonOK) { Updater UP = new Updater(); UP.ParentWindow = this; UP.url = obj["Url"].ToString(); this.IsMaskVisible = true; UP.WindowStartupLocation = WindowStartupLocation.CenterOwner; UP.Owner = this; UP.ShowDialog(); this.IsMaskVisible = false; if (UpdateFin == true) { string where = Directory.GetCurrentDirectory(); where = where + @"\run.vbs"; System.Diagnostics.Process process; process = System.Diagnostics.Process.Start(@where); Application.Current.Shutdown(); } } }); } } error.logWriter("检查更新完成。", false); }
private void WContentRendered(object sender, EventArgs e) { if (SetVerErr) { SetVerErr = false; SSMessageHelper.noNo = false; ButtonHelper.SetIcon(SSMessageHelper.Icon, ""); SSMessageHelper.Title = "设置文件版本不符"; SSMessageHelper.Says = "我们发现设置文件版本不符,将对设置文件进行重写。选择取消将退出程序。"; SSMessageBox MB = new SSMessageBox(); this.IsMaskVisible = true; MB.WindowStartupLocation = WindowStartupLocation.CenterOwner; MB.Owner = this; MB.ShowDialog(); this.IsMaskVisible = false; error.logWriter("设置文件版本不符", false); if (SSMessageHelper.buttonNO) { Application.Current.Shutdown(); } else { File.Delete("SSTB/Setup.json"); Settings = Set.newSetup(); } } if (!Directory.Exists("SSTB/Files")) { Directory.CreateDirectory("SSTB/Files"); } if (!File.Exists("SSTB/Files/jrrp.dat")) { try { File.AppendAllText("SSTB/Files/jrrp.dat", System.DateTime.Now.ToString("yyyy-MM")); } catch { } } string temp; using (StreamReader sr = new StreamReader("SSTB/Files/jrrp.dat", Encoding.Default)) { temp = sr.ReadLine(); } if (!temp.Equals(System.DateTime.Now.ToString("yyyy-MM-dd"))) { try { File.Delete("SSTB/Files/jrrp.dat"); File.AppendAllText("SSTB/Files/jrrp.dat", System.DateTime.Now.ToString("yyyy-MM-dd")); } catch { } Random random = new Random(); int all = 11 + 1; string[] sayslist = new string[all]; sayslist[0] = "今天也要加油啦!"; sayslist[1] = "你好世界。"; sayslist[2] = "不挖坑,毋宁死!"; sayslist[3] = "人生如梦……TMD怎么还不醒啊喂!"; sayslist[4] = "有点自信吧,即使在深渊之中。"; sayslist[5] = "山城无处不飞花。"; sayslist[6] = "旅者的努力,或许就是为了那期待的,远处的一片风景。"; sayslist[7] = "现在做的事情,可能就是为了将来能在别人面前装个逼吧。"; sayslist[8] = "感谢遇到你。"; sayslist[9] = "既然身边每个人都在为之努力,那你为什么不加油呢?"; sayslist[10] = "人类这么优秀,一定做得到的!"; sayslist[11] = "遇到困难的话就一鼓作气冲好了,总之,生活不是游戏。(这话好像在哪听过)"; int num = random.Next(0, 100); string say = "欢迎使用林槐工具箱!今天的人品是 " + num + " ,"; int numsay = random.Next(0, all - 1); say = say + sayslist[numsay]; if (numsay == 0 || numsay == 4 || numsay == 8 || numsay == 9 || numsay == 11) { SSMessageHelper.bOKtext = "谢谢"; } SSMessageHelper.noNo = true; ButtonHelper.SetIcon(SSMessageHelper.Icon, ""); SSMessageHelper.Title = "欢迎!"; SSMessageHelper.Says = say; SSMessageBox MB = new SSMessageBox(); this.IsMaskVisible = true; MB.WindowStartupLocation = WindowStartupLocation.CenterOwner; MB.Owner = this; MB.ShowDialog(); this.IsMaskVisible = false; SSMessageHelper.bOKtext = "好的"; } }
private void ERR_Click(object sender, RoutedEventArgs e) { ButtonHelper.SetIcon(this.ERR, null); toolTip.ToolTipText = ""; }
public void UpdateThings() { GET.Text = "—"; DIE.Text = "—"; ALIVE.Text = "—"; MAY.Text = "—"; MAYDIE.Text = "—"; MGET.Text = "确诊"; MMAY.Text = "疑似"; MMAYDIE.Text = "重症"; MDIE.Text = "死亡"; MALIVE.Text = "治愈"; toolTip.ToolTipText = "在 " + DateTime.Now.ToLongTimeString().ToString() + " 数据已刷新。(点击消除)"; ButtonHelper.SetIcon(this.ERR, ""); if (fu) { toolTip.ToolTipText += "\n感谢使用 Stapx Steve 制作的疫情查询!\n做得比较仓促,多多理解。"; ButtonHelper.SetIcon(this.ERR, ""); fu = false; } String ncov; Action actionyq = new Action(() => { if (File.Exists("Ncov.txt")) { File.Delete("Ncov.txt"); } try { //尝试下载丁香园界面…… string url = "https://ncov.dxy.cn/ncovh5/view/pneumonia?scene=2&clicktime=1579582238&enterid=1579582238&from=timeline&isappinstalled=0"; string filepath = "Ncov.txt"; System.Net.WebClient mywebclient = new System.Net.WebClient(); mywebclient.DownloadFile(url, filepath); } catch (Exception ex) { this.Dispatcher.BeginInvoke(new Action(() => { ButtonHelper.SetIcon(this.ERR, ""); this.TOOLTIP.Text += "\n下载丁香园网页错误。" + ex + "(点击消除)"; }), DispatcherPriority.SystemIdle, null); return; } try { ncov = File.ReadAllText("Ncov.txt"); } catch (Exception ex) { this.Dispatcher.BeginInvoke(new Action(() => { ButtonHelper.SetIcon(this.ERR, ""); toolTip.ToolTipText += "\n读取网页数据错误。" + ex + "(点击消除)"; }), DispatcherPriority.SystemIdle, null); return; } this.Dispatcher.BeginInvoke(new Action(() => { GET.Text = "无数据"; DIE.Text = "无数据"; ALIVE.Text = "无数据"; MAY.Text = "无数据"; MAYDIE.Text = "无数据"; }), DispatcherPriority.SystemIdle, null); if (!String.IsNullOrWhiteSpace(wherefind)) { if (!wherefind.Equals("全国")) { iscountry = true; this.Dispatcher.BeginInvoke(new Action(() => { MGET.Text = "确诊"; MMAY.Text = "疑似"; MMAYDIE.Text = "重症"; MDIE.Text = "死亡"; MALIVE.Text = "治愈"; }), DispatcherPriority.SystemIdle, null); string content = File.ReadAllText("Ncov.txt"); string gw = content; int i = gw.IndexOf("getListByCountryTypeService2"); if (i == -1) { this.Dispatcher.BeginInvoke(new Action(() => { ButtonHelper.SetIcon(this.ERR, ""); toolTip.ToolTipText += "\n未找到城市数据区域。(点击消除)"; }), DispatcherPriority.SystemIdle, null); return; } gw = gw.Substring(i); i = gw.IndexOf("getIndexRecommendList"); gw = gw.Substring(0, i); i = gw.IndexOf(wherefind); if (i == -1) { iscountry = false; i = content.IndexOf("getAreaStat"); if (i == -1) { this.Dispatcher.BeginInvoke(new Action(() => { ButtonHelper.SetIcon(this.ERR, ""); toolTip.ToolTipText += "\n未找到城市数据区域。(点击消除)"; }), DispatcherPriority.SystemIdle, null); return; } content = content.Substring(i); i = content.IndexOf(wherefind); if (i == -1) { this.Dispatcher.BeginInvoke(new Action(() => { ButtonHelper.SetIcon(this.ERR, ""); toolTip.ToolTipText += "\n没有找到这个城镇。(点击消除)"; }), DispatcherPriority.SystemIdle, null); return; } } else { content = gw; } try { if (iscountry) { content = content.Substring(i - "stByCountryTypeService2 = [{\"id\":953,\"createTime\":1580027704000,\"modifyTime\":1581144220000,\"tags\":\"\",\"countryType\":2,\"continents\":\"亚洲\",\"provinceId\":\"6\",\"provinceName\":\"".Length); } else { content = content.Substring(i - 30); } i = content.IndexOf("{"); if (i == -1) { this.Dispatcher.BeginInvoke(new Action(() => { ButtonHelper.SetIcon(this.ERR, ""); toolTip.ToolTipText += "\n未找到标识区域1。(点击消除)"; }), DispatcherPriority.SystemIdle, null); return; } content = content.Substring(i); if (iscountry) { i = content.IndexOf("}"); if (i == -1) { this.Dispatcher.BeginInvoke(new Action(() => { ButtonHelper.SetIcon(this.ERR, ""); toolTip.ToolTipText += "\n未找到标识区域2。(点击消除)"; }), DispatcherPriority.SystemIdle, null); return; } content = content.Substring(0, i + 1); } else { string type = content; int j = type.IndexOf("\""); if (j == -1) { this.Dispatcher.BeginInvoke(new Action(() => { ButtonHelper.SetIcon(this.ERR, ""); toolTip.ToolTipText += "\n未找到标识区域3。(点击消除)"; }), DispatcherPriority.SystemIdle, null); return; } type = type.Substring(j + 1); j = type.IndexOf("\""); if (j == -1) { this.Dispatcher.BeginInvoke(new Action(() => { ButtonHelper.SetIcon(this.ERR, ""); toolTip.ToolTipText += "\n未找到标识区域4。(点击消除)"; }), DispatcherPriority.SystemIdle, null); return; } type = type.Substring(0, j); if (type.Equals("cityName")) { i = content.IndexOf("}"); if (i == -1) { this.Dispatcher.BeginInvoke(new Action(() => { ButtonHelper.SetIcon(this.ERR, ""); toolTip.ToolTipText += "\n未找到标识区域5。(点击消除)"; }), DispatcherPriority.SystemIdle, null); return; } content = content.Substring(0, i + 1); } else if (type.Equals("provinceName")) { i = content.IndexOf("\"cities\""); if (i == -1) { this.Dispatcher.BeginInvoke(new Action(() => { ButtonHelper.SetIcon(this.ERR, ""); toolTip.ToolTipText += "\n未找到标识区域6。(点击消除)"; }), DispatcherPriority.SystemIdle, null); return; } content = content.Substring(0, i - 1); content = content + "}"; } else { this.Dispatcher.BeginInvoke(new Action(() => { ButtonHelper.SetIcon(this.ERR, ""); toolTip.ToolTipText += "\n未知错误:城市类型 " + type + " 不存在。(点击消除)"; }), DispatcherPriority.SystemIdle, null); return; } } this.Dispatcher.BeginInvoke(new Action(() => { GET.Text = 0.ToString(); DIE.Text = 0.ToString(); ALIVE.Text = 0.ToString(); MAY.Text = 0.ToString(); MAYDIE.Text = 0.ToString(); }), DispatcherPriority.SystemIdle, null); JObject jObject = JObject.Parse(content); this.Dispatcher.BeginInvoke(new Action(() => { try { if (iscountry) { this.Title = " " + jObject["continents"].ToString() + " - " + wherefind; } GET.Text = jObject["confirmedCount"].ToString(); DIE.Text = jObject["deadCount"].ToString(); ALIVE.Text = jObject["curedCount"].ToString(); MAY.Text = jObject["suspectedCount"].ToString(); MAYDIE.Text = "无数据"; } catch (Exception ex) { ButtonHelper.SetIcon(this.ERR, ""); toolTip.ToolTipText += "\n处理丁香园界面错误1。" + ex + "(点击消除)"; return; } }), DispatcherPriority.SystemIdle, null); } catch (Exception ex) { this.Dispatcher.BeginInvoke(new Action(() => { ButtonHelper.SetIcon(this.ERR, ""); toolTip.ToolTipText += "\n处理丁香园界面错误2。" + ex + "(点击消除)"; }), DispatcherPriority.SystemIdle, null); return; } } else { try { string content = File.ReadAllText("Ncov.txt"); int i = content.IndexOf("getStatisticsService"); content = content.Substring(i + "getStatisticsService".Length); i = content.IndexOf("summary"); content = content.Substring(i - 1); content = "{" + content; i = content.IndexOf("virus"); content = content.Substring(0, i - 2); content = content + "}"; JObject jObject = JObject.Parse(content); this.Dispatcher.BeginInvoke(new Action(() => { try { GET.Text = jObject["currentConfirmedCount"].ToString(); DIE.Text = jObject["deadCount"].ToString(); ALIVE.Text = jObject["curedCount"].ToString(); MAY.Text = jObject["suspectedCount"].ToString(); MAYDIE.Text = jObject["seriousCount"].ToString(); } catch (Exception ex) { ButtonHelper.SetIcon(this.ERR, ""); toolTip.ToolTipText += "\n处理丁香园界面错误3.1。" + ex + "(点击消除)"; } try { MGET.Text = "确诊 " + " " + (int.Parse(jObject["currentConfirmedIncr"].ToString()) <= 0 ? jObject["currentConfirmedIncr"].ToString() : "+" + jObject["currentConfirmedIncr"].ToString()); MMAY.Text = "疑似 " + " " + (int.Parse(jObject["suspectedIncr"].ToString()) <= 0 ? jObject["suspectedIncr"].ToString() : "+" + jObject["suspectedIncr"].ToString()); MMAYDIE.Text = "重症 " + " " + (int.Parse(jObject["seriousIncr"].ToString()) <= 0 ? jObject["seriousIncr"].ToString() : "+" + jObject["seriousIncr"].ToString()); MDIE.Text = "死亡 " + " " + (int.Parse(jObject["deadIncr"].ToString()) <= 0 ? jObject["deadIncr"].ToString() : "+" + jObject["deadIncr"].ToString()); MALIVE.Text = "治愈 " + " " + (int.Parse(jObject["curedIncr"].ToString()) <= 0 ? jObject["curedIncr"].ToString() : "+" + jObject["curedIncr"].ToString()); } catch (Exception ex) { this.Dispatcher.BeginInvoke(new Action(() => { ButtonHelper.SetIcon(this.ERR, ""); toolTip.ToolTipText += "\n处理丁香园界面错误3.2。" + ex + "(点击消除)"; }), DispatcherPriority.SystemIdle, null); return; } }), DispatcherPriority.SystemIdle, null); } catch (Exception ex) { this.Dispatcher.BeginInvoke(new Action(() => { ButtonHelper.SetIcon(this.ERR, ""); toolTip.ToolTipText += "\n处理丁香园界面错误4。" + ex + "(点击消除)"; }), DispatcherPriority.SystemIdle, null); return; } } } }); actionyq.BeginInvoke(null, null); }
/// <summary> /// RunButton_Click_1 /// RunButton按下事件,刷新列表 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void RunButton_Click_1(object sender, RoutedEventArgs e) { //判断私隐密码 if (Main.Settings["Features"]["Privacy"]["Password"].ToString() != "NULL") { PassWordEnterF7 EP = new PassWordEnterF7(); ParentWindow.IsMaskVisible = true; EP.WindowStartupLocation = WindowStartupLocation.CenterOwner; EP.Owner = ParentWindow; EP.ShowDialog(); ParentWindow.IsMaskVisible = false; } else { LoadingSetter.PasswordPass = true; } if (!LoadingSetter.PasswordPass) { return; } LoadingSetter.PasswordPass = false; if (!err) { //判断存档版本 if (Notes["Stat"]["Version"].ToString() != FileVersion.ToString()) { SSMessageHelper.noNo = true; ButtonHelper.SetIcon(SSMessageHelper.Icon, ""); SSMessageHelper.Title = "存档版本不符"; SSMessageHelper.Says = "我们将取消读取档案,请至 File/Setups 文件夹下备份 NoteSaves.json 文件并删除以继续使用。\n(为什么要你手动删除而不自动?因为我想确保你确实去备份了,并且顺便删了。)"; SSMessageBox MB = new SSMessageBox(); ParentWindow.IsMaskVisible = true; MB.WindowStartupLocation = WindowStartupLocation.CenterOwner; MB.Owner = ParentWindow; MB.ShowDialog(); ParentWindow.IsMaskVisible = false; this.RunCard.Visibility = Visibility.Visible; error.ErrorTo("存档版本不符。", Percent, Errorsay); error.logWriter("Tool7:存档版本不符。", false); err = true; return; } } int[] things = new int[3]; try { if (!err && int.Parse(Notes["Stat"]["NumOfDef"].ToString()) != 0) { for (int i = 1; i <= int.Parse(Notes["Stat"]["NumOfDef"].ToString()); i++) { if (int.Parse(Notes["Cards"]["Def"][i.ToString()]["Stat"].ToString()) != 0) { for (int j = 1; j <= int.Parse(Notes["Cards"]["Def"][i.ToString()]["Stat"].ToString()); j++) { things[0] = j; things[1] = i; if (bool.Parse(Notes["Cards"]["Def"][i.ToString()][j.ToString()]["CantDel"].ToString())) { things[2] = 1; } else { things[2] = 0; } AddColtrols(2, things, Notes["Cards"]["Def"][i.ToString()][j.ToString()]["Title"].ToString()); } } } } } catch (Exception ex) { SSMessageHelper.noNo = false; ButtonHelper.SetIcon(SSMessageHelper.Icon, ""); SSMessageHelper.Title = "读取JSON错误"; SSMessageHelper.bNOtext = "不用不用"; SSMessageHelper.bOKtext = "打开日志"; SSMessageHelper.Says = "我们发现了一个崩溃性的错误,是否反馈它,如果不反馈,这个错误将永远得不到修复!\n" + ex; SSMessageBox MB = new SSMessageBox(); ParentWindow.IsMaskVisible = true; MB.WindowStartupLocation = WindowStartupLocation.CenterOwner; MB.Owner = ParentWindow; MB.ShowDialog(); ParentWindow.IsMaskVisible = false; error.logWriter("Tool7:读取JSON错误。" + ex, false); if (SSMessageHelper.buttonOK) { string where = Directory.GetCurrentDirectory(); where = where + @"\SSTB\Log\log.log"; Process process; process = System.Diagnostics.Process.Start(@where); } Application.Current.Shutdown(); } this.CD1.Visibility = Visibility.Visible; this.LOAD.Visibility = Visibility.Collapsed; this.MT1.Visibility = Visibility.Collapsed; }
private void AddWhat_DropDownClosed(object sender, EventArgs e) { AddWhereList = new List <listMain>(); AddWhereList.Add(new listMain() { ID = 0, Name = " < 空 >" }); if (int.Parse(AddWhat.SelectedValue.ToString()) != 1 && int.Parse(AddWhat.SelectedValue.ToString()) != 0) { this.HID.Visibility = Visibility.Visible; } else { this.HID.Visibility = Visibility.Collapsed; } try { if (int.Parse(AddWhat.SelectedValue.ToString()) != 1 && int.Parse(AddWhat.SelectedValue.ToString()) != 0) { for (int i = 1; i <= int.Parse(Notes["Stat"]["NumOfDef"].ToString()); i++) { string str = Notes["Cards"]["Def"][i.ToString()]["Title"].ToString(); if (Notes["Cards"]["Def"][i.ToString()]["Title"].ToString().Length > "四个汉字".Length) { str = Notes["Cards"]["Def"][i.ToString()]["Title"].ToString().Substring(0, "四个汉字".Length) + "…"; } AddWhereList.Add(new listMain() { ID = i, Name = " " + str }); } AddWhere.ItemsSource = AddWhereList; AddWhere.DisplayMemberPath = "Name"; AddWhere.SelectedValuePath = "ID"; AddWhere.SelectedValue = 0; this.AdW.Visibility = Visibility.Visible; } else { this.AdW.Visibility = Visibility.Collapsed; } } catch (Exception ex) { SSMessageHelper.noNo = false; ButtonHelper.SetIcon(SSMessageHelper.Icon, ""); SSMessageHelper.Title = "读取JSON错误"; SSMessageHelper.bNOtext = "不用不用"; SSMessageHelper.bOKtext = "打开日志"; SSMessageHelper.Says = "我们发现了一个崩溃性的错误,是否反馈它,如果不反馈,这个错误将永远得不到修复!\n" + ex; SSMessageBox MB = new SSMessageBox(); ParentWindow.IsMaskVisible = true; MB.WindowStartupLocation = WindowStartupLocation.CenterOwner; MB.Owner = ParentWindow; MB.ShowDialog(); ParentWindow.IsMaskVisible = false; error.logWriter("Tool7:读取JSON错误。" + ex, false); if (SSMessageHelper.buttonOK) { string where = Directory.GetCurrentDirectory(); where = where + @"\SSTB\Log\log.log"; Process process; process = System.Diagnostics.Process.Start(@where); System.Diagnostics.Process.Start("https://ssteamcommunity.wordpress.com/feedback/"); } Application.Current.Shutdown(); } }
private bool AddColtrols(int addWhat, int[] things, String anothers1) { /* addWhat - 创建什么, another,anothers - 其他数据 * 1 - 普通卡片 * 2 - 普通事件 */ if (addWhat == 1) { Card card = new Card(); StackPanel stackPanel = new StackPanel(); Grid grid = new Grid(); TextBlock textBlock = new TextBlock(); Button button = new Button(); ListView listView = new ListView(); ContextMenu contextMenu = new ContextMenu(); MenuItem menuItem1 = new MenuItem(); MenuItem menuItem2 = new MenuItem(); MenuItem menuItem3 = new MenuItem(); menuItem1.Name = "MenuItem1"; menuItem1.Header = "删除卡片"; menuItem1.Icon = ""; menuItem1.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(CD_Del); contextMenu.Items.Add(menuItem1); contextMenu.Width = 150; contextMenu.Background = baseColora.Card; contextMenu.Foreground = baseColora.Fg; ContextMenuHelper.SetShadowColor(contextMenu, baseColora.DBg.Color); ContextMenuHelper.SetItemHeight(contextMenu, 30); textBlock.ContextMenu = contextMenu; card.ContextMenu = contextMenu; card.PreviewMouseRightButtonDown += WhatFuckOpenMeMe; textBlock.Text = things[0] + ". " + anothers1; textBlock.HorizontalAlignment = HorizontalAlignment.Left; textBlock.TextWrapping = TextWrapping.Wrap; textBlock.Margin = new Thickness(34, 25, 34, 10); textBlock.Foreground = baseColora.Fg; textBlock.FontFamily = baseColora.Fonts; textBlock.FontSize = 15; button.Foreground = baseColora.Fg; button.Margin = new Thickness(0, 10, 15, 0); button.Name = "BCDD" + things[0]; button.Width = 30; button.Click += DelCard_Click; button.HorizontalAlignment = HorizontalAlignment.Right; ButtonHelper.SetIcon(button, ""); IconHelper.SetFontSize(button, 16); ButtonHelper.SetButtonStyle(button, ButtonStyle.Link); card.Name = "CDD" + things[0]; card.Margin = new Thickness(5, 15, 20, 5); card.Width = 540; card.Background = baseColora.Card; grid.Children.Add(textBlock); grid.Children.Add(button); stackPanel.Children.Add(grid); card.Content = stackPanel; ScrollViewerHelper.SetScrollBarCornerRadius(listView, new CornerRadius(3)); stackPanel.Children.Add(listView); MainIn.Children.Add(card); RegisterName("CDD" + things[0], card); } else if (addWhat == 2) { Card card = GetChildObjects <Card>(MainIn, "CDD" + things[1].ToString()); if (card == null) { this.RunCard.Visibility = Visibility.Visible; error.ErrorTo("创建控件失败,未找到分类卡片。", Percent, Errorsay); error.logWriter("Tool -7:未找到分类卡片。卡片名称:CDD" + things[1], false); return(false); } List <StackPanel> lstControl = GetChildObjects <StackPanel>(card, typeof(StackPanel)); if (lstControl == null) { this.RunCard.Visibility = Visibility.Visible; error.ErrorTo("创建控件失败,未找到分类卡片中的StackPanel控件。", Percent, Errorsay); error.logWriter("Tool -7:未找到分类卡片中的StackPanel控件。卡片名称:CDD" + things[1], false); return(false); } List <ListView> lstControl1 = GetChildObjects <ListView>(lstControl[0], typeof(ListView)); if (lstControl1 == null) { this.RunCard.Visibility = Visibility.Visible; error.ErrorTo("创建控件失败,未找到分类卡片中的StackPanel控件中的列表控件。", Percent, Errorsay); error.logWriter("Tool -7:未找到分类卡片中的StackPanel控件中的列表控件。卡片名称:CDD" + things[1], false); return(false); } ContextMenu contextMenu = new ContextMenu(); MenuItem menuItem1 = new MenuItem(); MenuItem menuItem2 = new MenuItem(); MenuItem menuItem3 = new MenuItem(); menuItem1.Name = "MenuItem1"; menuItem1.Header = "完成"; menuItem1.Icon = ""; menuItem1.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(ME_Fin); contextMenu.Items.Add(menuItem1); menuItem2.Name = "MenuItem2"; menuItem2.Header = "删除"; menuItem2.Icon = ""; menuItem2.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(ME_Del); if (things[2] == 0) { contextMenu.Items.Add(menuItem2); } contextMenu.Width = 150; contextMenu.Background = baseColora.Card; contextMenu.Foreground = baseColora.Fg; ContextMenuHelper.SetShadowColor(contextMenu, baseColora.DBg.Color); ContextMenuHelper.SetItemHeight(contextMenu, 30); ListViewItem listViewItem = new ListViewItem(); listViewItem.Name = "CDD" + things[1] + "IT" + things[0]; listViewItem.ContextMenu = contextMenu; listViewItem.PreviewMouseRightButtonDown += WhatFuckOpenMe; TextBlock textBlock = new TextBlock(); textBlock.Text = anothers1; textBlock.Background = baseColora.Tran; textBlock.FontFamily = baseColora.Fonts; textBlock.Foreground = baseColora.Font; textBlock.FontSize = 15; textBlock.Margin = new Thickness(38, 5, 38, 5); listViewItem.Content = textBlock; lstControl1[0].Items.Add(listViewItem); } return(true); }
private void RunButton_Click(object sender, RoutedEventArgs e) { if (err) { return; } if (!CD2.IsVisible) //显示添加卡片 { AddWhat.SelectedValue = 0; AddWhere.SelectedValue = 0; What.Text = ""; this.CD2.Visibility = Visibility.Visible; } else //关闭添加卡片并且开始添加操作 { if ((String.IsNullOrWhiteSpace(What.Text) && int.Parse(AddWhat.SelectedValue.ToString()) == 1) || (int.Parse(AddWhat.SelectedValue.ToString()) == 0) || (int.Parse(AddWhat.SelectedValue.ToString()) == 2 && String.IsNullOrWhiteSpace(What.Text) && (int.Parse(AddWhere.SelectedValue.ToString()) == 0))) { this.CD2.Visibility = Visibility.Collapsed; return; } if (bool.Parse(CanDel.IsChecked.ToString())) { SSMessageHelper.noNo = false; ButtonHelper.SetIcon(SSMessageHelper.Icon, ""); SSMessageHelper.Title = "确认一下"; SSMessageHelper.Says = "真的要选择无法删除嘛,这会导致此记录无法选择删除。(你只能通过“完成”选项来消除此记录,我希望你可以好好利用这个功能来督促自己)"; SSMessageBox MB = new SSMessageBox(); ParentWindow.IsMaskVisible = true; MB.WindowStartupLocation = WindowStartupLocation.CenterOwner; MB.Owner = ParentWindow; MB.ShowDialog(); ParentWindow.IsMaskVisible = false; if (SSMessageHelper.buttonNO) { return; } } try { if (int.Parse(AddWhat.SelectedValue.ToString()) == 1) { JObject CardItem = new JObject(); int num = int.Parse(Notes["Stat"]["NumOfDef"].ToString()); Notes["Stat"]["NumOfDef"] = (num + 1).ToString(); num += 1; CardItem["Title"] = What.Text; CardItem["Stat"] = "0"; CardItem["Finished"] = "0"; Notes["Cards"]["Def"][num.ToString()] = CardItem; SaveData(Notes); int[] things = new int[1]; things[0] = int.Parse(Notes["Stat"]["NumOfDef"].ToString()); AddColtrols(int.Parse(AddWhat.SelectedValue.ToString()), things, What.Text); } if (int.Parse(AddWhat.SelectedValue.ToString()) == 2) { int num = int.Parse(Notes["Cards"]["Def"][AddWhere.SelectedValue.ToString()]["Stat"].ToString()); Notes["Cards"]["Def"][AddWhere.SelectedValue.ToString()]["Stat"] = (num + 1).ToString(); num += 1; JObject Item = new JObject { { "Title", What.Text }, { "Finished", false }, { "CantDel", bool.Parse(CanDel.IsChecked.ToString()) } }; Notes["Cards"]["Def"][AddWhere.SelectedValue.ToString()][num.ToString()] = Item; SaveData(Notes); int[] things = new int[3]; things[0] = int.Parse(Notes["Cards"]["Def"][AddWhere.SelectedValue.ToString()]["Stat"].ToString()); things[1] = int.Parse(AddWhere.SelectedValue.ToString()); if (bool.Parse(CanDel.IsChecked.ToString())) { things[2] = 1; } else { things[2] = 0; } AddColtrols(int.Parse(AddWhat.SelectedValue.ToString()), things, What.Text); } } catch (Exception ex) { SSMessageHelper.noNo = false; ButtonHelper.SetIcon(SSMessageHelper.Icon, ""); SSMessageHelper.Title = "写入JSON错误"; SSMessageHelper.bNOtext = "不用不用"; SSMessageHelper.bOKtext = "打开日志"; SSMessageHelper.Says = "我们发现了一个崩溃性的错误,是否反馈它,如果不反馈,这个错误将永远得不到修复!\n" + ex; SSMessageBox MB = new SSMessageBox(); ParentWindow.IsMaskVisible = true; MB.WindowStartupLocation = WindowStartupLocation.CenterOwner; MB.Owner = ParentWindow; MB.ShowDialog(); ParentWindow.IsMaskVisible = false; error.logWriter("Tool7:读取JSON错误。" + ex, false); if (SSMessageHelper.buttonOK) { string where = Directory.GetCurrentDirectory(); where = where + @"\SSTB\Log\log.log"; Process process; process = System.Diagnostics.Process.Start(@where); } Application.Current.Shutdown(); } this.CD2.Visibility = Visibility.Collapsed; this.AdW.Visibility = Visibility.Collapsed; } }