private void 检查数据完整性() { WriteTitle("数据完整性检查...."); FileOperations.CreateDir(Game.SkinPath); var skincount = _lumei.CheckMountSkin(); if (skincount > 0) { var isReBuild = AyMessageBox.Show(string.Format("当前客户端存在{0}条空挂载记录{1}是否清除?", skincount, Environment.NewLine), "挂载文件异常", MessageBoxButton.YesNo) == MessageBoxResult.Yes; if (isReBuild) { if (_lumei.ClearCheckSkin()) { WriteMessage("数据清理成功!"); WriteMessage(string.Format("共清理{0}条无效数据!", skincount)); WriteMessage("数据完整性检查完成"); } else { AyMessageBox.Show("请确认程序拥有足够权限或游戏未运行", "清理失败"); WriteMessage("清理失败!"); WriteMessage("数据完整性检查失败"); State = false; } } } else { WriteMessage("数据完整性检查完成"); } }
public void SknConverter(string sknfile) { if (string.IsNullOrWhiteSpace(sknfile) && !File.Exists(sknfile)) { AyMessageBox.Show("文件不存在,请重新选择!", "文件不存在!"); return; } try { var sklfile = Path.ChangeExtension(sknfile, ".skl"); var skn = new SknFile(sknfile) { Version = 2 }; skn.SaveFile(FileOperations.NewFilePath(sknfile)); if (!string.IsNullOrWhiteSpace(sklfile) && File.Exists(sklfile)) { File.Copy(sklfile, FileOperations.NewFilePath(sklfile), true); } } catch { AyMessageBox.Show("文件读取失败!请确认", "文件错误!"); } }
void Current_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { AyMessageBox.Show(e.Exception.Message, MessageBoxButton.OK, AyMessageBoxImage.Error); AyMessageBox.Show("我们很抱歉,当前应用程序遇到一些问题,该操作已经终止,请进行重试,如果问题继续存在,请联系符文之地-九命喵式微", "意外的操作"); //这里通常需要给用户一些较为友好的提示,并且后续可能的操作 Log.LogError("未知错误", e.Exception); e.Handled = true; //使用这一行代码告诉运行时,该异常被处理了,不再作为UnhandledException抛出了。 }
private void BackSkin(object sender, System.Windows.RoutedEventArgs e) { if (Changed && AyMessageBox.Show("您已修改了本英雄信息,是否保存?", "已被修改", System.Windows.MessageBoxButton.YesNo) == System.Windows.MessageBoxResult.Yes) { AyMessageBox.Show("OK", "OK"); } _soft.BackPageSkin(); }
private void PictureToLoadImage(string picpath) { try { FileOperations.CreateDirWithDelete(Soft.ZipTempPath("Load")); var temppath = Soft.ZipTempPath("Load") + "Load.png"; if (!FileOperations.CreateFileDir(temppath)) { return; } var model = new Skin { Hero = "SRBackground" }; model.SkinName = Path.GetFileNameWithoutExtension(picpath); model.FileName = model.SkinName + ".zip"; model.BackImage = "load.png"; var loadpath = Soft.ZipTempPath("Load") + "DATA\\LoadingScreen\\SRBackground.dds"; CutPic(picpath, temppath); //if (Directory.Exists(Soft.ZipTempPath("Load"))) // Directory.Delete(Soft.ZipTempPath("Load"),true); FileOperations.CreateFileDir(loadpath); var pic = DevIL.DevIL.LoadBitmap(temppath); if (pic == null) { AyMessageBox.Show("图片读取失败!\r\n此图片无法被导入!\r\n原因:我也不知道为啥导入不能……", "读取失败"); return; } DevIL.DevIL.SaveBitmap(loadpath, pic); loadpath = Soft.ZipTempPath("LoadTemp"); FileOperations.CreateDirWithDelete(loadpath); Zip.ZipFile(Soft.ZipTempPath("Load"), loadpath + model.FileName); var savepath = Soft.SkinFile(model); FileOperations.CreateFileDir(savepath); File.Copy(loadpath + model.FileName, savepath, true); File.Copy(temppath, Soft.SkinPath(model) + "load.png", true); //TODO 重新整理文件 _skin.Add(model); AyMessageBox.Show("载入图 " + model.SkinName + " 导入成功!", "导入成功"); _softParam.BackPageSkin(); } catch (Exception ex) { AyMessageBox.Show("载入图导入失败\r\n请重新尝试\r\n或错误原因请查看错误日志!", "载入图导入失败!"); Log.LogError("载入图导入失败", ex); } }
private void 解压压缩包的图片() { Comment = "解压压缩包的图片"; TempPath = Soft.ZipTempPath(Skin.Hero); FileOperations.CreateDir(TempPath); var files = ZipFiles.Where(d => d != null && (d.EndsWith(".dds") || d.EndsWith(".png") || d.EndsWith(".jpg") || d.EndsWith(".jpeg") || d.EndsWith(".bmp")) && !d.ToLower().Contains("particles")).ToList(); try { Zip.UnzipFiles(FilePath, TempPath, files); files = FileOperations.AllFiles(TempPath); 获取各种图片(files); } catch { AyMessageBox.Show("载入图读取失败!", "压缩包错误!"); } }
private void DialogShow() { if (_time < 5) { _time++; } else { AyMessageBox.Show("错误次数过多,请重新运行程序!", "警告"); State = false; return; } var set = new Set(); var dialog = new FolderBrowserDialog { Description = "选择英雄联盟路径,例:C:\\英雄联盟", ShowNewFolderButton = false }; dialog.ShowDialog(); var gamePath = dialog.SelectedPath; dialog.Dispose(); if (string.IsNullOrWhiteSpace(gamePath)) { AyMessageBox.Show("路径不合法,请重新选择!", "路径错误!"); DialogShow(); } else { gamePath = gamePath + "\\"; if (!File.Exists(gamePath + "Game\\Characters.zip")) { set.State = false; set.Title = "游戏路径错误"; set.Message = string.Format("游戏路径选择错误{0}请重新选择!{0}", Environment.NewLine); AyMessageBox.Show(set.Message, set.Title); DialogShow(); } else { State = Config.GameSave("GamePath", gamePath); } } }
private void CheckFile(string file) { var ex = Path.GetExtension(file).ToLower(); // var ex = Path.GetExtension(file)?.ToLower(); switch (ex) { case ".skn": _lumei.SknConverter(file); break; case ".zip": var imp = new SkinImport(); imp.StartImport(file); break; default: AyMessageBox.Show("无法识别此文件格式!", "未知格式"); break; } }
private void 检查重复皮肤() { var skins = _skin.AllSkins(); if (skins.Any(d => d.SkinName == Skin.SkinName && d.Hero == Skin.Hero)) { switch (AyMessageBox.Show("已存在名字为 " + Skin.SkinName + " 的同名皮肤,是否覆盖保存?\r选择是:将覆盖旧皮肤保存\r选择否:将不覆盖旧皮肤保存\r选择取消:将取消导入", "重复皮肤", MessageBoxButton.YesNoCancel)) { case MessageBoxResult.Yes: Skin = skins.FirstOrDefault(d => d.SkinName == Skin.SkinName); break; case MessageBoxResult.No: Skin.SkinName = Skin.SkinName + "[副本]"; break; default: AyMessageBox.Show("取消对当前皮肤" + Skin.SkinName + "的导入!", "取消导入!"); _canGoOn = false; break; } } }
private void 软件更新检查() { WriteTitle("检查更新"); Set = _lumei.CheckUpdate(); if (Set == null) { WriteTitle("更新检查失败!"); WriteMessage("无法连接至服务器!"); } else if (Set.State) { if (AyMessageBox.Show("拥有新版本" + Set.Title + ",是否更新?", "检查更新", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { State = false; this.Dispatcher.BeginInvoke(new Action(() => { _lumei.StartUpdate(); }), null); this.Dispatcher.BeginInvoke(new Action(() => { this.Hide(); }), null); } else { WriteMessage("取消更新!"); } } }
private void 重新整理皮肤包() { try { var temppath = Soft.ZipTempPath(Skin.Hero); var tempzip = Soft.ZipTempPath(Skin.Hero) + Skin.FileName; var savepath = Soft.SkinFile(Skin); if (!FileOperations.CreateDirWithDelete(temppath)) { throw new Exception("文件夹删除失败!"); } Zip.UnZipFile(FilePath, temppath); var tempfile = Directory.GetFiles(temppath, "*.*", SearchOption.AllDirectories); var tempcount = tempfile.Count(); var zipname = string.Format("{0}{1:yyMMMMddHHmmDD}", temppath, DateTime.Now); var skincount = 0; var othercount = ""; ForeachMove(tempfile, zipname, out skincount, out othercount); if (skincount > 0) { AyMessageBox.Show(string.Format("皮肤文件数:{0},整理后文件数:{1},未知文件:{2}", tempcount, skincount, othercount), "整理皮肤"); Zip.ZipFile(zipname, tempzip); } else { AyMessageBox.Show("无法识别该皮肤包,请确认该压缩包内再无压缩包!", "整理失败!"); _canGoOn = false; } FilePath = tempzip; Skin.FileName = Path.GetFileName(FilePath); } catch (Exception ex) { AyMessageBox.Show("请确认本软件拥有对软件目录的读写权限!", "皮肤整理失败"); Log.LogError("皮肤整理失败", ex); } }
private void openMessageBox_Click(object sender, RoutedEventArgs e) { if (cboMsgType.Text == "信息") { AyMessageBox.ShowInformation(winThis, "必须填写用户名"); } else if (cboMsgType.Text == "警告") { AyMessageBox.ShowWarning(winThis, "必须填写用户名"); } else if (cboMsgType.Text == "错误") { AyMessageBox.ShowError(winThis, "必须填写用户名"); } else if (cboMsgType.Text == "异常") { AyMessageBox.ShowError(winThis, "必须填写用户名"); } else if (cboMsgType.Text == "疑问") { AyMessageBox.ShowQuestion(winThis, "必须填写用户名"); } else if (cboMsgType.Text == "长文本内容") { AyMessageBox.ShowInformation(winThis, "我是AY,首先声明,我在做一件很枯燥的事情,我是个91后程序员,每天熬夜完成计划的过着下班后的生活\n" + "那天有人反对,那天有人安慰,那天有人嘲讽,那天有人祝福。\n" + "过了6个月后,我对自己的梦想一直没有改变过,继续坚持,终于,AYUI诞生了。\n" + "今天有人说造轮子,今天有人说你好厉害,今天有人说开源吗 ? 有人说好喜欢...\n" + "有贬有褒,但是好的声音多了。\n" + "但是身体的各种问题也来了.."); } else if (cboMsgType.Text == "DIY的弹窗") { AyMessageBox.Show(winThis, "我是AY,首先声明,我在做一件很枯燥的事情,我是个91后程序员,每天熬夜完成计划的过着下班后的生活\n" + "那天有人反对,那天有人安慰,那天有人嘲讽,那天有人祝福。\n" + "过了6个月后,我对自己的梦想一直没有改变过,继续坚持,终于,AYUI诞生了。\n" + "今天有人说造轮子,今天有人说你好厉害,今天有人说开源吗 ? 有人说好喜欢...\n" + "有贬有褒,但是好的声音多了。\n" + "但是身体的各种问题也来了..", "AY自我介绍", MessageBoxButton.OK, AyMessageBoxImage.None, MessageBoxResult.Yes, MessageBoxOptions.RightAlign); } else if (cboMsgType.Text == "长文本内容") { } else if (cboMsgType.Text == "删除") { if (MessageBoxResult.OK == AyMessageBox.ShowDelete(winThis, "确认删除吗", "删除")) { AyMessageBox.ShowRight("操作成功!"); } else { AyMessageBox.ShowRight(winThis, "操作已经被取消!", "操作"); } } else if (cboMsgType.Text == "疑问确认取消") { if (MessageBoxResult.OK == AyMessageBox.ShowQuestionOkCancel(winThis, "确认操作吗?此操作不可以更改", "操作提示")) { AyMessageBox.ShowRight("操作成功!"); } else { AyMessageBox.ShowRight(winThis, "操作已经被取消!", "操作"); } } else if (cboMsgType.Text == "ok") { AyMessageBox.ShowRight(winThis, "操作成功!"); } }
private void 检查更新版本数据库() { //TODO 检查数据库是否存在AMSkins数据库 if (_skin.CheckAmSkins()) { WriteTitle("开启数据整理!"); //TODO 如果存在则复制此表的数据到Skin表 var oldlist = _skin.AmSkinList(); var list = _lumei.AllSkins(); var i = 0; try { var path = ""; foreach (var item in oldlist) { i++; WriteMessage("数据整理中……[" + i + "/" + oldlist.Count + "]"); if (list.Any(d => d.SkinName == item.SkinName)) { continue; } //TODO 将文件移动到新的文件夹 var oldpath = Soft.SkinOldPath(item); if (!Directory.Exists(oldpath)) { continue; } path = Soft.SkinPath(item); if (Directory.Exists((path))) { Directory.Delete(path, true); } FileOperations.CreateDir(Soft.Skins); Directory.Move(oldpath, path); var load = Soft.SkinLoadPath(item); if (File.Exists(load) && !load.EndsWith(".png")) { try { using (var image = DevIL.DevIL.LoadBitmap(load)) { var rep = load.Substring(load.Length - 3, 3); var newimg = load.Replace(rep, "png"); DevIL.DevIL.SaveBitmap(newimg, image); item.LoadPic = item.LoadPic.Replace(rep, "png"); } File.Delete(load); } catch (Exception ex) { Log.LogError("载入图转换失败", ex); } } _skin.Add(item); } //TODO 并删除AMSkins表 path = string.Format("{0}Skins\\", AppDomain.CurrentDomain.BaseDirectory); if (Directory.Exists(path)) { Directory.Delete(path, true); } WriteMessage(_skin.DeleAmSkin() ? "数据整理完成!" : "数据整理失败!"); } catch (Exception ex) { Log.LogError("数据整理失败!", ex); AyMessageBox.Show("请确认程序拥有对软件目录的读写权限", "数据整理失败!"); } } }
public ViewStartController() { Model = new ViewStartModel(); DoSomething = str => { AyMessageBox.Show("Action方式 " + str.ToString()); }; SomeCommand = new SimpleCommand { ExecuteDelegate = obj => { AyMessageBox.Show("ICommand方式 " + obj.ToString()); } }; SubmitCommand = new SimpleCommand { ExecuteDelegate = obj => { AyMessageBox.Show("提交成功,你提交的数据是: " + obj.ToString()); }, CanExecuteDelegate = x => { if (x.ToObjectString().IsNullAndTrimAndEmpty()) { return(false); } else { return(true); } } }; //演示绑定多个操作 Multy1Command = new SimpleCommand { ExecuteDelegate = obj => { Model.TextBoxStatus = "Multy1 触发了"; } }; Multy2Command = new SimpleCommand { ExecuteDelegate = obj => { Model.TextBoxStatus = "Multy2触发了"; } }; Multy3Action = x => { Model.TextBoxStatus = "Multy3操作 触发了"; }; }