int getNodeImageIndex(string id) { int index = 0; if (id != null) { File.Chunk ori = Original.Chunks[id] as File.Chunk; File.Chunk mod = Mod.Chunks[id] as File.Chunk; if (ori != null && mod != null && ori.Message.Original != null && mod.Message.Modify != null) { //if ( ori.Message.Original.Length > 0 ) { if (File.checkAvailable(ori.Message.Original)) { if (ori.Message.Original.CompareTo(mod.Message.Modify) != 0) { index = 1; } } else { index = 1; } } } return(index); }
public MesEditor(string path) { InitializeComponent(); treeViewLine.HideSelection = false; this.Name = path; treeViewLine.ImageList = imageList1; // groupboxを下にしてツリーをうえにするとサイズの自動計算がおかしい open(path); // mes tree //System.IO.FileInfo info = new System.IO.FileInfo( Mod.FilePath ); TreeNode root = new TreeNode(FileName); root.ImageIndex = root.SelectedImageIndex = 2; // nodeのlistだとセット関係が分からないからnodeのchunkのlistがいるのかなあ if (Original.Type == File.FileType.MES) { //int size = Mod.Chunks.Count; int size = Mod.IDs.Count; for (int i = 0; i < size; ++i) { //File.Chunk chunk = Mod.Chunks[ i ] as File.Chunk; File.Chunk chunk = Mod.Chunks[Mod.IDs[i]] as File.Chunk; File.Node id = chunk.ID; File.Node message = chunk.Message; // 空は編集できないようにする if (message.Original != null && message.Original.Length > 0) { TreeNode node = new TreeNode(id.Original); node.Text = chunk.NodeText; node.Tag = chunk; root.Nodes.Add(node); node.ImageIndex = node.SelectedImageIndex = getNodeImageIndex(id.Original); } } root.Expand(); treeViewLine.Nodes.Add(root); } treeViewLine.AfterSelect += new TreeViewEventHandler(treeViewLine_AfterSelect); treeViewLine.MouseDown += new MouseEventHandler(treeViewLine_MouseDown); textBoxModify.ModifiedChanged += new EventHandler(textBoxModify_ModifiedChanged); textBoxModify.TextChanged += new EventHandler(textBoxModify_TextChanged); toolStripButtonNext.Click += new EventHandler(Next_Click); toolStripButtonRestore.Click += new EventHandler(toolStripButtonRestore_Click); textBoxOriginal.ContextMenu = createMenuOriginal(); textBoxModify.ContextMenu = createMenuModify(); // 右押された時点でフォーカス移さないと右クリックメニュー処理がめんどい //textBoxOriginal.ContextMenu.Popup += new EventHandler( ContextMenu_Popup ); }
void textBoxModify_TextChanged(object sender, EventArgs e) { TextBox box = sender as TextBox; if (box != null) { TreeNode node = box.Tag as TreeNode; if (node != null) { File.Chunk chunk = node.Tag as File.Chunk; File.Node id = chunk.ID; File.Node text = chunk.Message; history.TextChange(chunk.ID.Original, textBoxModify); text.Modify = box.Text; // ここで必要以上に書き戻されるのが少々気になるが・・・ // 書き戻すのは最後のセーブ時にするか? // 重いし node.Text = chunk.NodeText; // image key node.ImageIndex = node.SelectedImageIndex = getNodeImageIndex(chunk.ID.Original); } } }
public override void Redo_Click(object sender, EventArgs e) { TreeNode node = textBoxModify.Tag as TreeNode; if (node != null) { File.Chunk chunk = node.Tag as File.Chunk; history.Redo(chunk.ID.Original, textBoxModify); MainForm.setStatus(@"やり直し"); } }
void toolStripButtonRestore_Click(object sender, EventArgs e) { TreeNode node = textBoxModify.Tag as TreeNode; if (node != null) { File.Chunk chunk = node.Tag as File.Chunk; File.Node text = chunk.Message; text.Modify = text.Original.Clone() as string; textBoxModify.Text = text.Modify; MainForm.setStatus(@"編集前に戻す"); } }
TreeNode searchNext(TreeNode node, TreeNode stop, Search.Option option, TreeNodeUtill.GetNode getfunc) { TreeNode next = getfunc(node); while (next != null && next != stop) { File.Chunk chunk = next.Tag as File.Chunk; if (option.origin) { chunk = Original.Chunks[chunk.ID.Original] as File.Chunk; } if (option.line) { if (compare(chunk.Message.Modify, option)) { treeViewLine.SelectedNode = next; if (option.origin) { textBoxOriginal.Focus(); } else { textBoxModify.Focus(); } return(next); } } if (option.id) { if (compare(chunk.ID.Original, option)) { treeViewLine.SelectedNode = next; treeViewLine.Focus(); return(next); } } next = getfunc(next); } return(null); }
void treeViewLine_AfterSelect(object sender, TreeViewEventArgs e) { if (e.Node != null) { File.Chunk chunk = e.Node.Tag as File.Chunk; if (chunk != null) { textBoxModify.Tag = e.Node; File.Node id = chunk.ID; File.Chunk origin = Original.Chunks[id.Original] as File.Chunk; File.Node otext = origin.Message; File.Node text = chunk.Message; history.NodeChange(chunk.ID.Original); groupBoxID.Text = id.Original; MainForm.setTitle(" - " + FileName + " {" + id.Original + "}"); textBoxOriginal.Text = otext.Original; textBoxModify.Text = text.Modify; // textchangeが呼ばれる //textBoxModify.Modified = false; } } }
void calcProgress(string name, List <ProgressCount> progress, System.Collections.Hashtable ignore) { if (System.IO.Directory.Exists(name) == false) { return; } { // dir part string current = System.IO.Directory.GetCurrentDirectory(); string[] dirs = System.IO.Directory.GetDirectories(name); foreach (string dir in dirs) { if (IOController.validDirectory(dir)) { calcProgress(dir, progress, ignore); } } } { // file part string dname = System.IO.Path.GetFileName(name); dname = dname.ToLower(); if (dname == Path.Data.DialogDirectoryName || dname == Path.Data.MessageDirectoryName) { string[] files = System.IO.Directory.GetFiles(name); foreach (string file in files) { // 除外ファイル if (IOController.validDlgMesFile(file) && ignore.ContainsKey(file) == false) { File ori = new File(); ori.open(file, true); int num = 0; int idnum = ori.IDs.Count; string modpath = Path.Data.ModifiedDirectory + file; bool exist = System.IO.File.Exists(modpath); if (exist) { File mod = new File(); mod.open(modpath, false); int count = 0; // compair for (int i = 0; i < idnum; ++i) { string id = ori.IDs[i] as string; if (id != null) { File.Chunk oc = ori.Chunks[id] as File.Chunk; File.Chunk mc = mod.Chunks[id] as File.Chunk; if (oc != null && mc != null) { // この比較回数を削りたい if (ori.Type == File.FileType.MES) { File.Node omes = oc.Message; File.Node mmes = mc.Message; if (File.checkAvailable(omes.Original)) { ++count; if (omes.Original.CompareTo(mmes.Modify) != 0) { ++num; } } else { //++num; } } else { File.Node omale = oc.MaleLine; File.Node ofemale = oc.FemaleLine; File.Node mmale = mc.MaleLine; File.Node mfemale = mc.FemaleLine; // 二つあるしどういう条件にしようかなと 0.5? // 空はどうするかね // ある程度除外しないとあれだが、その辺はしょうがないのかねえ // だが[E:]みたいなのは、別ファイル参照なので除外してもいいかも // 男女別でカウント if (File.checkAvailable(omale.Original)) { if (omale.Original.CompareTo(mmale.Modify) != 0) { if (File.checkAvailable(ofemale.Original)) { ++count; if (ofemale.Original.CompareTo(mfemale.Modify) != 0) { ++num; } } else { //++num; } } } if (File.checkAvailable(ofemale.Original)) { ++count; if (ofemale.Original.CompareTo(mfemale.Modify) != 0) { ++num; } } else { //++num; } } } } } idnum = count; #if false if (num < idnum) { System.Console.WriteLine("\t" + modpath + ": " + num + " / " + idnum); } else { System.Console.WriteLine(modpath + ": " + num + " / " + idnum); } #endif } else { int count = 0; for (int i = 0; i < idnum; ++i) { string id = ori.IDs[i] as string; if (id != null) { File.Chunk oc = ori.Chunks[id] as File.Chunk; if (oc != null) { // この比較回数を削りたいのう if (ori.Type == File.FileType.MES) { File.Node omes = oc.Message; if (File.checkAvailable(omes.Original)) { ++count; } } else { File.Node omale = oc.MaleLine; File.Node ofemale = oc.FemaleLine; // 二つあるしどういう条件にしようかなと 0.5? // 空はどうするかね // ある程度除外しないとあれだが、その辺はしょうがないのかねえ // だが[E:]みたいなのは、別ファイル参照なので除外してもいいかも // 男女別でカウント if (File.checkAvailable(omale.Original)) { ++count; } if (File.checkAvailable(ofemale.Original)) { ++count; } #if false if (File.checkAvailable(omale.Original) || File.checkAvailable(ofemale.Original)) { ++count; } #endif } } } } idnum = count; } progress.Add(new ProgressCount(file, num, idnum, exist)); } else { //System.Console.WriteLine( "invalid format:" + file ); } incrementProgressBar(); } } } }