public static void OnReplaceWordEvent(object sender, ReplaceWordEventArgs e) { if (ReplaceEventRised != null) { ReplaceEventRised(sender, e); } EventAggregator.OnModelDataChanged(sender, new ModelValueChangedEventArgs()); }
/// <summary> /// 置換が発生した時のイベント /// </summary> private void OnReplaceWordEvent(object sender, ReplaceWordEventArgs arg) { if(arg.fromStr.Length == 0) { return ; } if (arg.replaceAll) { var obj = Clipboard.GetText(); Clipboard.SetText(arg.toStr); int idx = 0; while (true) { idx = _writersBFView.Editor.GetText().IndexOf(arg.fromStr, idx); if (idx == -1) { break; } if (arg.toStr.Length == 0) { ReplaceOneWord(arg.fromStr, idx, true); } else { ReplaceOneWord(arg.fromStr, idx, false); } idx += arg.toStr.Length; } Clipboard.SetText(obj); } else { var obj = Clipboard.GetText(); Clipboard.SetText(arg.toStr); var idx = _writersBFView.Editor.GetText().IndexOf(arg.fromStr, arg.headIndex); if (idx == arg.headIndex) { if (arg.toStr.Length == 0) { ReplaceOneWord(arg.fromStr, idx, true); } else { ReplaceOneWord(arg.fromStr, idx, false); } } Clipboard.SetText(obj); } }