private void MergeWithFile(bool justEmpty) { string oldPath = ""; if (!String.IsNullOrEmpty(poFilePath)) { oldPath = openFileDialog1.FileName; } DialogResult dr = openFileDialog1.ShowDialog(); if (dr == DialogResult.OK) { string mergeFilePath = openFileDialog1.FileName; if (mergeFilePath == oldPath) { return; } if (String.IsNullOrEmpty(mergeFilePath)) { return; } POFile mergeFile = new POFile(mergeFilePath); currentPOFile.MergeFile(mergeFile, justEmpty); RefreshFile(); } if (!String.IsNullOrEmpty(poFilePath)) { openFileDialog1.FileName = oldPath; } }
public void MergeFile(POFile otherFile, bool justMissing = false) { foreach (WordPair wp in wordPairs) { foreach (WordPair wp2 in otherFile.wordPairs) { if (wp.Source == wp2.Source) { if (justMissing) { if (wp.Translation == "" && wp2.Translation != "") { wp.Translation = wp2.Translation; } } else { if (wp2.Translation != "") { wp.Translation = wp2.Translation; } } } } } }
private void LoadFile(bool shouldClear = true) { if (currentPOFile != null) { currentPOFile.FreeFile(); } currentPOFile = new POFile(poFilePath); if (shouldClear) { RefreshFile(); } }