Пример #1
0
        private void UpdateStatusBar(object sender, RoutedEventArgs e)      //更新状态栏
        {
            //行列
            int row = NotepadTextBox.GetLineIndexFromCharacterIndex(NotepadTextBox.CaretIndex);
            int col = NotepadTextBox.CaretIndex - NotepadTextBox.GetCharacterIndexFromLineIndex(row);

            CursorPosition.Text = "第 " + (row + 1) + " 行," + "第 " + (col + 1) + " 列";
            //缩放值
            ZoomScaleDisplayer.Text = ZoomScale.ToString() + "%";
        }
Пример #2
0
        private void InsertDateTime(object sender, RoutedEventArgs e)         //菜单-编辑-时间日期
        {
            if (NotepadTextBox.SelectionLength > 0)                           //若选中文本
            {
                this.TextDelete(this, null);
            }
            string result    = NotepadTextBox.Text;                             //复制原编辑区副本
            int    cursorPos = NotepadTextBox.SelectionStart;                   //获取光标位置
            string nowTime   = DateTime.Now.ToString();                         //获取当前时间

            result = result.Insert(cursorPos, nowTime);                         //计算结果
            NotepadTextBox.Text           = result;                             //将结果放入编辑区
            NotepadTextBox.SelectionStart = cursorPos + nowTime.Length;         //重新定位光标
            NotepadTextBox.Focus();
        }
Пример #3
0
        private void TextDelete(object sender, RoutedEventArgs e)               //菜单-编辑-删除
        {
            int delNum = NotepadTextBox.SelectedText.Length;

            if (delNum == 0)
            {
                return;
            }
            string result    = NotepadTextBox.Text;
            int    cursorPos = NotepadTextBox.SelectionStart;

            result = result.Remove(cursorPos, delNum);
            NotepadTextBox.Text           = result;
            NotepadTextBox.SelectionStart = cursorPos;
            NotepadTextBox.Focus();
        }
Пример #4
0
 private void SelectAll(object sender, RoutedEventArgs e)        //菜单-编辑-全选
 {
     NotepadTextBox.SelectAll();
 }
Пример #5
0
 private void TextPaste(object sender, RoutedEventArgs e)                //菜单-编辑-粘贴
 {
     NotepadTextBox.Paste();
 }
Пример #6
0
 private void TextCopy(object sender, RoutedEventArgs e)                 //菜单-编辑-复制
 {
     NotepadTextBox.Copy();
 }
Пример #7
0
 private void TextCut(object sender, RoutedEventArgs e)                  //菜单-编辑-剪切
 {
     NotepadTextBox.Cut();
 }
Пример #8
0
 private void Undo(object sender, RoutedEventArgs e)                     //菜单-编辑-撤销
 {
     NotepadTextBox.Undo();
 }