/// <summary> /// 保存皮肤文件 /// </summary> /// <param name="model"></param> /// <returns></returns> public Set SaveSkinModel(Skin model) { var set = new Set(); if (model != null) { try { if (model.Id == 0) { _skin.Add(model); } else { _skin.Update(model); } set.State = true; } catch { set.State = false; } } return(set); }
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 检查更新版本数据库() { //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("请确认程序拥有对软件目录的读写权限", "数据整理失败!"); } } }