コード例 #1
0
ファイル: Form1.cs プロジェクト: Lestar/text-editor-c-
        public void paste(SimpleForm form)
        {
            String clipboardText = Clipboard.GetText();

            if (form.getTextBox().SelectionStart == 0)
            {
                form.setTextArea(clipboardText + form.getTextArea());
                return;
            }
            if (form.getTextBox().SelectionStart > 0 && form.getTextBox().SelectionStart < form.getTextArea().Length)
            {
                form.setTextArea(form.getTextArea().Substring(0, form.getTextBox().SelectionStart) + clipboardText + form.getTextArea().Substring(form.getTextBox().SelectionStart, form.getTextArea().Length));
                return;
            }
            if (form.getTextBox().SelectionStart == form.getTextArea().Length)
            {
                form.setTextArea(form.getTextArea() + clipboardText);
                return;
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: Lestar/text-editor-c-
 public void cut(SimpleForm form)
 {
     int cp;
     if (form.getTextBox().SelectedText.Length != 0)
     {
         copy(form);
         cp = form.getTextBox().SelectionStart;
         form.getList().newPutString(form.getTextBox().SelectedText, cp, actionsHistory.action.SUB);
         if (form.getTextBox().SelectionStart == 0)
         {
             form.setTextArea(form.getTextArea().Substring(form.getTextBox().SelectedText.Length, form.getTextArea().Length));
             form.getTextBox().SelectionStart = cp;
             return;
         }
         if (form.getTextBox().SelectionStart > 0 && form.getTextBox().SelectionStart < form.getTextArea().Length)
         {
             form.setTextArea(form.getTextArea().Substring(0, form.getTextBox().SelectionStart) + form.getTextArea().Substring(form.getTextBox().SelectionStart + form.getTextBox().SelectedText.Length, form.getTextArea().Length));
             form.getTextBox().SelectionStart = cp;
             return;
         }
         if (form.getTextBox().SelectionStart == form.getTextArea().Length)
         {
             form.setTextArea(form.getTextArea().Substring(0, form.getTextBox().SelectionStart));
             form.getTextBox().SelectionStart = cp;
             return;
         }
     }
 }
コード例 #3
0
ファイル: Form1.cs プロジェクト: Lestar/text-editor-c-
 public void delete(SimpleForm form)
 {
     if (form.getTextBox().SelectedText.Length != null)
     {
         form.setAction(false);
         form.setTextArea(form.getTextArea().Substring(0, form.getTextBox().SelectionStart) + form.getTextArea().Substring(form.getTextBox().SelectionLength, form.getTextArea().Length));
         form.getList().newPutString(form.getTextBox().SelectedText, form.getTextBox().SelectionStart, actionsHistory.action.SUB);
         form.setAction(true);
     }
 }
コード例 #4
0
ファイル: Form1.cs プロジェクト: Lestar/text-editor-c-
 public void copy(SimpleForm form)
 {
     if (form.getTextBox().SelectedText.Length != 0)
     {
         string stringSelection = form.getTextBox().SelectedText;
         Clipboard.SetText(stringSelection);
     }
 }