/// <summary> /// 卡牌添加事件 /// </summary> public void Add_Click(object obj) { // 卡编是否重复判断 if (CardUtils.IsNumberExist(CardQueryModel.Number)) { BaseDialogUtils.ShowDialogAuto(StringConst.CardIsExitst); return; } // 添加确认 if (!BaseDialogUtils.ShowDialogConfirm(StringConst.AddConfirm)) { return; } // 数据库添加 var addSql = CeSqlUtils.GetAddSql(CardQueryModel); var isAdd = DataManager.Execute(addSql); BaseDialogUtils.ShowDialogAuto(isAdd ? StringConst.AddSucceed : StringConst.AddFailed); if (!isAdd) { return; } // 数据库更新 DataManager.FillDataToDataSet(); // 跟踪历史 if (null == _cardPreviewVm.MemoryQueryModel) { _cardPreviewVm.MemoryQueryModel = GetCardQueryExMdoel(); } _cardPreviewVm.UpdateCardPreviewList(_cardPreviewVm.MemoryQueryModel); }
public void Export_Click(object obj) { var pack = CardQueryModel.Pack; if (pack.Equals(StringConst.NotApplicable) || pack.Contains(StringConst.Series)) { BaseDialogUtils.ShowDialogOk(StringConst.PackChoiceNone); return; } var exportPath = DialogUtils.ShowExport(pack); if (exportPath.Equals(string.Empty)) { return; } var sql = SqlUtils.GetExportSql(pack); var dataSet = new DataSet(); if (!DataManager.FillDataToDataSet(dataSet, sql)) { return; } var isExport = ExcelHelper.ExportPackToExcel(exportPath, dataSet); BaseDialogUtils.ShowDialogAuto(isExport ? StringConst.ExportSucceed : StringConst.ExportFailed); }
/// <summary> /// 卡牌删除事件 /// </summary> public void Delete_Click(object obj) { // 选择判空 var selectedItem = _cardPreviewVm.SelectedItem; if (null == selectedItem) { BaseDialogUtils.ShowDialogAuto(StringConst.CardChioceNone); return; } // 删除确认 if (!BaseDialogUtils.ShowDialogConfirm(StringConst.DeleteConfirm)) { return; } // 数据库删除 var deleteSql = CeSqlUtils.GetDeleteSql(selectedItem.Number); var isDelete = DataManager.Execute(deleteSql); BaseDialogUtils.ShowDialogAuto(isDelete ? StringConst.DeleteSucceed : StringConst.DeleteFailed); if (!isDelete) { return; } // 数据库更新 DataManager.FillDataToDataSet(); // 跟踪历史 if (null == _cardPreviewVm.MemoryQueryModel) { _cardPreviewVm.MemoryQueryModel = GetCardQueryExMdoel(); } _cardPreviewVm.UpdateCardPreviewList(_cardPreviewVm.MemoryQueryModel); }
public void DeckLoad() { OnPropertyChanged(nameof(DeckName)); if ((DeckName == null) || DeckName.Equals(string.Empty)) { return; } DeckList.Clear(); var deckPath = CardUtils.GetDeckPath(DeckName); try { var sr = File.OpenText(deckPath); var numberListString = sr.ReadToEnd().Trim(); sr.Close(); var idList = JsonUtils.Deserialize <List <int> >(numberListString); foreach (var id in idList) { AddCard(id); } } catch (Exception exception) { BaseDialogUtils.ShowDialogAuto(exception.Message); } }
private void BtnClear_Click(object sender, RoutedEventArgs e) { var sqlList = GetClearSqlList(); // 数据库覆写 var isExecute = DataManager.Execute(sqlList); BaseDialogUtils.ShowDialogAuto(isExecute ? "Succeed" : "Failed"); }
public void DownloadImages_Click(object obj) { if (0 == CardModels.Count) { BaseDialogUtils.ShowDialogAuto("请选择图鉴目录"); return; } DownloadImages(CardModels.ToList(), false); }
/// <summary> /// 卡组另存事件 /// </summary> public void Resave_Click(object obj) { var deckPath = CardUtils.GetDeckPath(DeckName); if (!File.Exists(deckPath)) { Save(); } BaseDialogUtils.ShowDialogAuto(StringConst.DeckNameExist); }
public void Md5Cover_Click(object obj) { if (!BaseDialogUtils.ShowDialogConfirm("确认覆写?")) { return; } var sqlList = SqlUtils.GetMd5SqlList(); var succeed = DataManager.Execute(sqlList); BaseDialogUtils.ShowDialogAuto(succeed ? StringConst.UpdateSucceed : StringConst.UpdateFailed); }
/// <summary>程序载入</summary> private void Window_Loaded(object sender, RoutedEventArgs e) { _dbOperationVm = new DbOperationVm(this); DbOperationView.DataContext = _dbOperationVm; if (!_dbOperationVm.UpdateDataset()) { BaseDialogUtils.ShowDialogOk(StringConst.DbOpenError); return; } InitView(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { if (DataManager.FillDataToDataSet(DataManager.DsAllCache, SqlUtils.GetQueryAllSql())) { if (!Directory.Exists(PathManager.DeckFolderPath)) { Directory.CreateDirectory(PathManager.DeckFolderPath); } } else { BaseDialogUtils.ShowDialogOk("数据库初始化失败"); } }
public void Decrypt_Click(object obj) { if (Password.Equals(string.Empty)) { BaseDialogUtils.ShowDialogOk(StringConst.PasswordNone); return; } if (DataManager.Decrypt()) { UpdatePasswordVisibility(true, false); BaseDialogUtils.ShowDialogAuto(StringConst.DncryptSucced); return; } BaseDialogUtils.ShowDialogOk(StringConst.DncryptFailed); }
private void CardPreviewWindow_OnLoaded(object sender, RoutedEventArgs e) { LogUtils.Show(); DataManager.Init(DataManager.BahamutDbName, PathManager.RootPath + DataManager.BahamutDbName, ""); if (DataManager.FillDataToDataSet(DataManager.DsAllCache, SqlExUtils.GetQueryAllSql(), DataManager.BahamutDbName)) { AppbarView.DataContext = new AppbarVm(this); ContentView.DataContext = new CardPreviewVm(); CardUtils.InitCgPath(); } else { BaseDialogUtils.ShowDialogOk("数据库异常"); } }
public void Encrypt_Click(object obj) { if (Password.Equals(string.Empty)) { BaseDialogUtils.ShowDialogOk(StringConst.PasswordNone); return; } if (DataManager.Encrypt(DataManager.DsAllCache, SqlUtils.GetQueryAllSql())) { UpdatePasswordVisibility(false, true); BaseDialogUtils.ShowDialogAuto(StringConst.EncryptSucced); _cardEditor.InitView(); return; } BaseDialogUtils.ShowDialogOk(StringConst.EncryptFailed); }
public void DeckResave_Click(object obj) { OnPropertyChanged(nameof(DeckName)); if (DeckName.Equals(string.Empty)) { BaseDialogUtils.ShowDialogAuto(StringConst.DeckNameNone); return; } var deckPath = CardUtils.GetDeckPath(DeckName); if (File.Exists(deckPath)) { BaseDialogUtils.ShowDialogAuto(StringConst.DeckNameExist); return; } DeckSave_Click(DeckName); }
/// <summary> /// 卡牌更新事件 /// </summary> public void Update_Click(object obj) { // 选择判空 var selectedItem = _cardPreviewVm.SelectedItem; if (null == selectedItem) { BaseDialogUtils.ShowDialogAuto(StringConst.CardChioceNone); return; } // 卡编是否重复判断 var checkNumber = selectedItem.Number.Equals(CardQueryModel.Number) || !CardUtils.IsNumberExist(CardQueryModel.Number); if (!checkNumber) { BaseDialogUtils.ShowDialogAuto(StringConst.CardIsExitst); return; } // 修改确认 if (!BaseDialogUtils.ShowDialogConfirm(StringConst.UpdateConfirm)) { return; } // 数据库修改 var updateSql = CeSqlUtils.GetUpdateSql(CardQueryModel, selectedItem.Number); var updateSqls = new List <string> { updateSql }; if (_cardQueryExVm.ModeType.Equals(Enums.ModeType.Develop)) { updateSqls.Add(CeSqlUtils.GetUpdateSql(CardQueryModel)); } var isUpdate = DataManager.Execute(updateSqls); BaseDialogUtils.ShowDialogAuto(isUpdate ? StringConst.UpdateSucceed : StringConst.UpdateFailed); if (!isUpdate) { return; } // 数据库更新 DataManager.FillDataToDataSet(); _cardPreviewVm.UpdateCardPreviewList(_cardPreviewVm.MemoryQueryModel); }
public void DeckSave_Click(object obl) { OnPropertyChanged(nameof(DeckName)); if (DeckName.Equals(string.Empty)) { BaseDialogUtils.ShowDialogAuto(StringConst.DeckNameNone); return; } var deckPath = CardUtils.GetDeckPath(DeckName); var deckBuilder = new StringBuilder(); var deckNumberList = new List <int>(); deckNumberList.AddRange(DeckList.Select(deck => deck.Id).ToList()); deckBuilder.Append(JsonUtils.Serializer(deckNumberList)); var isSaveSucceed = FileUtils.SaveFile(deckPath, deckBuilder.ToString()); BaseDialogUtils.ShowDialogAuto(isSaveSucceed ? StringConst.SaveSucceed : StringConst.SaveFailed); }
private void BtnCvCover_Click(object sender, RoutedEventArgs e) { var filePath = TxtFilePath.Text.Trim(); if (filePath.Equals("")) { BaseDialogUtils.ShowDialogAuto("源文件不存在"); return; } var jsonString = FileUtils.GetFileContent(filePath); var cvDic = JsonUtils.GetDictionary(jsonString); // 生成覆写的数据库语句集合 var insertSqlList = GetUpdateSqlList(SqliteConst.ColumnCv, cvDic); // 数据库覆写 var isExecute = DataManager.Execute(insertSqlList); BaseDialogUtils.ShowDialogAuto(isExecute ? "Succeed" : "Failed"); }
private void Save() { if (DeckName.Equals(string.Empty)) { BaseDialogUtils.ShowDialogAuto(StringConst.DeckNameNone); return; } var deckPath = CardUtils.GetDeckPath(DeckName); var deckBuilder = new StringBuilder(); var deckNumberList = new List <string>(); deckNumberList.AddRange(_playerVm.PlayerModels.Select(deckEntity => deckEntity.NumberEx).ToList()); deckNumberList.AddRange(_deckVm.IgModels.Select(deckEntity => deckEntity.NumberEx).ToList()); deckNumberList.AddRange(_deckVm.UgModels.Select(deckEntity => deckEntity.NumberEx).ToList()); deckNumberList.AddRange(_deckVm.ExModels.Select(deckEntity => deckEntity.NumberEx).ToList()); deckBuilder.Append(JsonUtils.Serializer(deckNumberList)); var isSave = FileUtils.SaveFile(deckPath, deckBuilder.ToString()); BaseDialogUtils.ShowDialogAuto(isSave ? StringConst.SaveSucceed : StringConst.SaveFailed); }
public async void DeckDelete_Click(object obj) { OnPropertyChanged(nameof(DeckName)); if (DeckName.Equals(string.Empty)) { return; } if (!await BaseDialogUtils.ShowDialogConfirm(StringConst.DeleteHint)) { return; } var deckPath = CardUtils.GetDeckPath(DeckName); if (!File.Exists(deckPath)) { return; } File.Delete(deckPath); DeckList.Clear(); }
/// <summary> /// 卡组删除事件 /// </summary> public void Delete_Click(object obj) { if (DeckName.Equals(string.Empty)) { return; } if (!BaseDialogUtils.ShowDialogConfirm(StringConst.DeleteHint)) { return; } var deckPath = CardUtils.GetDeckPath(DeckName); if (!File.Exists(deckPath)) { return; } File.Delete(deckPath); ClearDeck(); DeckName = string.Empty; BaseDialogUtils.ShowDialogAuto(StringConst.DeleteSucceed); }
private void BtnLinesCover_Click(object sender, RoutedEventArgs e) { var filePath = TxtFilePath.Text.Trim(); if (filePath.Equals("")) { BaseDialogUtils.ShowDialogAuto("源文件不存在"); return; } var jsonString = FileUtils.GetFileContent(filePath); var flavourDic = JsonUtils.GetDictionary(jsonString); var tempFlavourDic = new Dictionary <string, string>(); var tempFlavourList = new List <string>(); foreach (var dic in flavourDic) { if (dic.Key.EndsWith("_01") || dic.Key.EndsWith("_02")) { if (dic.Key.EndsWith("_01")) { tempFlavourList.Clear(); tempFlavourList.Add(dic.Value.ToString()); } else { tempFlavourList.Add(dic.Value.ToString()); tempFlavourDic.Add(dic.Key.Substring(0, 9), JsonUtils.Serializer(tempFlavourList)); } } else { tempFlavourDic.Add(dic.Key, dic.Value.ToString()); } } var sqlList = GetUpdateSqlList(SqliteConst.ColumnFlavour, tempFlavourDic); // 数据库覆写 var isExecute = DataManager.Execute(sqlList); BaseDialogUtils.ShowDialogAuto(isExecute ? "Succeed" : "Failed"); }
private async void BtnBaseCover_Click(object sender, RoutedEventArgs e) { var filePath = TxtFilePath.Text.Trim(); if (filePath.Equals("")) { BaseDialogUtils.ShowDialogAuto("源文件不存在"); return; } var packName = TxtPackName.Text.Trim(); if (packName.Equals("")) { BaseDialogUtils.ShowDialogAuto("请输入表格名称"); return; } // 获取源文件所有的信息 var dtSource = new DataSet(); var isImport = ExcelHelper.ImportExcelToDataTable(filePath, packName, dtSource); if (!isImport) { BaseDialogUtils.ShowDialogAuto("文件中数据异常"); return; } // 确认状态 if (!await BaseDialogUtils.ShowDialogConfirm("确认覆写?")) { return; } var sourceCardEntitys = GetSourceCardEntities(dtSource); // 生成覆写的数据库语句集合 var insertSqlList = GetInsertSqlList(sourceCardEntitys); // 数据库覆写 var isExecute = DataManager.Execute(insertSqlList); BaseDialogUtils.ShowDialogAuto(isExecute ? "Succeed" : "Failed"); }
public MainWindow() { InitializeComponent(); if (File.Exists(PathManager.BackgroundPath)) { var uri = new Uri(PathManager.BackgroundPath, UriKind.Relative); var imageBrush = new ImageBrush { ImageSource = new BitmapImage(uri) }; BorderView.Background = imageBrush; } if (!Directory.Exists(PathManager.DeckFolderPath)) { Directory.CreateDirectory(PathManager.DeckFolderPath); } if (!DataManager.FillDataToDataSet()) { BaseDialogUtils.ShowDialogOk(StringConst.DbOpenError); } }
/// <summary> /// 卡组载入 /// </summary> public void LoadDeck() { if (DeckName.Equals(string.Empty)) { return; } ClearDeck(); var deckPath = CardUtils.GetDeckPath(DeckName); try { var numberListString = FileUtils.GetFileContent(deckPath); var numberExList = JsonUtils.Deserialize <List <string> >(numberListString); foreach (var numberEx in numberExList) { AddCard(numberEx); } } catch (Exception exception) { BaseDialogUtils.ShowDialogAuto(exception.Message); } }
private void BtnCover_Click(object sender, RoutedEventArgs e) { var filePath = TxtFilePath.Text.Trim(); if (filePath.Equals("")) { BaseDialogUtils.ShowDialogAuto("源文件不存在"); return; } var packName = TxtPackName.Text.Trim(); if (packName.Equals("")) { BaseDialogUtils.ShowDialogAuto("请输入卡包名称"); return; } // 获取源文件所有的信息 var dtSource = new DataSet(); var isImport = ExcelHelper.ImportExcelToDataTable(filePath, packName, dtSource); if (!isImport) { BaseDialogUtils.ShowDialogAuto("文件中数据异常"); return; } // 确认状态 if (!BaseDialogUtils.ShowDialogConfirm("确认覆写?")) { return; } // 获取源文件编号 var dtNumberList = dtSource.Tables[0].Rows.Cast <DataRow>().Select(column => column["编号"].ToString()).ToList(); var sourceList = GetSourceCardModelList(dtSource); // 获取覆写所有的信息 var dataList = dtNumberList.Select(CardUtils.GetCardModel).ToList(); var selectColumnList = GetSelectColumnList(); // 填充覆写的数据 for (var i = 0; i != dataList.Count; i++) { var dataNumber = dataList[i].Number; foreach (var editorModel in sourceList) { if (!editorModel.Number.Equals(dataNumber)) { continue; } if (selectColumnList.Contains("种类")) { dataList[i].Type = editorModel.Type; } if (selectColumnList.Contains("色")) { dataList[i].Camp = editorModel.Camp; } if (selectColumnList.Contains("种族")) { dataList[i].Race = editorModel.Race; } if (selectColumnList.Contains("标记")) { dataList[i].Sign = editorModel.Sign; } if (selectColumnList.Contains("罕贵度")) { dataList[i].Race = editorModel.Race; } if (selectColumnList.Contains("卡片名_中")) { dataList[i].CName = editorModel.CName; } if (selectColumnList.Contains("COST")) { dataList[i].Cost = int.Parse(editorModel.CostValue); } if (selectColumnList.Contains("力量")) { dataList[i].Power = int.Parse(editorModel.PowerValue); } if (selectColumnList.Contains("能力_中")) { dataList[i].Ability = editorModel.Ability; } } } // 生成覆写的数据库语句集合 var updateSqlList = dataList .Select(cardEntity => GetUpdateSql(cardEntity, cardEntity.Number)) .ToList(); // 数据库覆写 var isExecute = DataManager.Execute(updateSqlList); BaseDialogUtils.ShowDialogAuto(isExecute ? StringConst.UpdateSucceed : StringConst.UpdateFailed); }