private void ResourcesFileShow_Click(object sender, RoutedEventArgs e) { // MessageBox.Show("ファイル内容表示処理開始"); int childSelectIndex = 0; int girdDataIndex = 0; // Resourceファイル用リスト初期化 resList.Clear(); // テーブルの初期化 try { if (string.IsNullOrEmpty(txtExistJpFolder.Text)) { MessageBox.Show("既存日本語プロジェクトフォルダを選択してください。"); return; } DataTable dtShowResxContent = InitTables(); // 選択したファイルを判定する ResourceLanguage resxJpFileContent = null; foreach (Model.TreeModel tree in amiTreeView.ItemsSourceData) { foreach (Model.TreeModel treeChild in tree.Children) { if (treeChild.IsChecked) { childSelectIndex++; ResourceLanguage resxChFileContent = new ResourceLanguage(treeChild.PathInfo); string jpResxPath = GetJpResxPath(treeChild.PathInfo); if (File.Exists(jpResxPath)) { resxJpFileContent = new ResourceLanguage(jpResxPath); } // Resourceファイル内容設定 ResourceModel multipleRes = new ResourceModel(); multipleRes.ResourceOld = resxChFileContent; multipleRes.ResourceNew = resxJpFileContent; multipleRes.MultipleResList.Add(multipleRes); resList.Add(multipleRes); // girdDataIndex初期化 girdDataIndex = 0; foreach (string itemKey in resxChFileContent.ResourceKeys) { // ファイル内容をGirdデータに追加 DataRow newRowItem; newRowItem = dtShowResxContent.NewRow(); newRowItem["item_key"] = itemKey; newRowItem["item_index"] = girdDataIndex + 1; newRowItem["item_ch_content"] = resxChFileContent.GetValue(itemKey); if (resxJpFileContent != null) { newRowItem["item_jp_content"] = resxJpFileContent.GetValue(itemKey); } else { newRowItem["item_jp_content"] = ""; } dtShowResxContent.Rows.Add(newRowItem); girdDataIndex++; } } } } if (childSelectIndex > 0) { // グリッドにバインド dataGrid1.DataContext = dtShowResxContent; } else { // グリッドにバインド dataGrid1.DataContext = null; MessageBox.Show("Resourceファイルを選択してください。"); } } catch (Exception ex) { MessageBox.Show(ex.Message, Title, MessageBoxButton.OK, MessageBoxImage.Error); return; } }
private void ResourcesFileReplace_Click(object sender, RoutedEventArgs e) { // MessageBox.Show("切替処理開始"); int childSelectIndex = 0; int girdDataIndex = 0; // テーブルの初期化 try { if (dataGrid1.DataContext == null) { MessageBox.Show("Resourceファイルを選択してください。"); return; } // 対応日本語の内容を切替 foreach (ResourceModel resxModel in resList) { foreach (string itemKey in resxModel.ResourceOld.ResourceKeys) { if (String.IsNullOrEmpty(resxModel.ResourceOld.GetValue(itemKey)) || resxModel.ResourceNew == null || String.CompareOrdinal(resxModel.ResourceOld.GetValue(itemKey), resxModel.ResourceNew.GetValue(itemKey)) == 0) { continue; } else { resxModel.ResourceNew.SetValue(itemKey, resxModel.ResourceOld.GetValue(itemKey)); resxModel.ResourceNew.Save(); } } } // Datagird再表示 DataTable dtShowResxContent = InitTables(); // 選択したファイルを判定する ResourceLanguage resxJpFileContent = null; foreach (Model.TreeModel tree in amiTreeView.ItemsSourceData) { foreach (Model.TreeModel treeChild in tree.Children) { if (treeChild.IsChecked) { childSelectIndex++; ResourceLanguage resxChFileContent = new ResourceLanguage(treeChild.PathInfo); string jpResxPath = GetJpResxPath(treeChild.PathInfo); if (File.Exists(jpResxPath)) { resxJpFileContent = new ResourceLanguage(jpResxPath); } // girdDataIndex初期化 girdDataIndex = 0; foreach (string itemKey in resxChFileContent.ResourceKeys) { // ファイル内容をGirdデータに追加 DataRow newRowItem; newRowItem = dtShowResxContent.NewRow(); newRowItem["item_key"] = itemKey; newRowItem["item_index"] = girdDataIndex + 1; newRowItem["item_ch_content"] = resxChFileContent.GetValue(itemKey); if (resxJpFileContent != null) { newRowItem["item_jp_content"] = resxJpFileContent.GetValue(itemKey); } else { newRowItem["item_jp_content"] = ""; } dtShowResxContent.Rows.Add(newRowItem); girdDataIndex++; } } } } if (childSelectIndex > 0) { // グリッドにバインド dataGrid1.DataContext = dtShowResxContent; } else { // グリッドにバインド dataGrid1.DataContext = null; MessageBox.Show("Resourceファイルを選択してください。"); } } catch (Exception ex) { MessageBox.Show(ex.Message, Title, MessageBoxButton.OK, MessageBoxImage.Error); return; } }