Paste() public method

public Paste ( string text ) : void
text string
return void
Exemplo n.º 1
0
Arquivo: Form1.cs Projeto: Gwee/csharp
        private void Button_Click(object sender, System.EventArgs e)
        {
            Button btn = (Button)sender;
            string str = btn.Text;

            switch (str)
            {
            case "Copy":
                if (TextBox1.SelectionLength > 0)
                {
                    TextBox1.Copy();
                }
                break;

            case "Cut":
                if (TextBox1.SelectionLength > 0)
                {
                    TextBox1.Cut();
                }
                break;

            case "Paste":
                TextBox1.Paste();
                break;

            case "Undo":
                TextBox1.Undo();
                break;
            }
        }
Exemplo n.º 2
0
        void OnLineBoxOnKeyDown(object sender, KeyEventArgs args)
        {
            string shortcutId = PluginBase.MainForm.GetShortcutItemId(args.KeyData);

            if (string.IsNullOrEmpty(shortcutId))
            {
                return;
            }

            switch (shortcutId)
            {
            case "EditMenu.ToLowercase":
            case "EditMenu.ToUppercase":
                string selectedText = lineBox.SelectedText;
                if (string.IsNullOrEmpty(selectedText))
                {
                    break;
                }
                selectedText = shortcutId == "EditMenu.ToLowercase" ? selectedText.ToLower() : selectedText.ToUpper();
                int selectionStart  = lineBox.SelectionStart;
                int selectionLength = lineBox.SelectionLength;
                lineBox.Paste(selectedText);
                SelectRange(selectionStart, selectionLength);
                break;
            }
        }
Exemplo n.º 3
0
 private void menuPaste_Click(object sender, System.EventArgs e)
 ///this menu item is only enabled when there is text in the Clipboard
 ///The .Paste method will past the Clipoard text at the current cursor
 ///position
 {
     textBox1.Paste();
 }
Exemplo n.º 4
0
        protected override void ProcessRecord()
        {
            TextBox clipStore = new TextBox();
            clipStore.Multiline = true;
            clipStore.Paste();

            var files = clipStore.Text.Trim().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var file in files)
            {
                WriteObject(string.Format("Copying {0}", file));
                File.Copy(file, Path.Combine(SessionState.Path.CurrentLocation.Path, Path.GetFileName(file)), true);
            }
        }
 private void menuItemPaste_Click(object sender, System.EventArgs e)
 {
     if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text) == true)
     {
         if (textBoxEdit.SelectionLength > 0)
         {
             DialogResult result;
             result = MessageBox.Show("你想覆盖掉选择的文本吗?", "覆盖确认", MessageBoxButtons.YesNo);
             if (result == DialogResult.No)
             {
                 textBoxEdit.SelectionStart = textBoxEdit.SelectionStart + textBoxEdit.SelectionLength;
             }
         }
         textBoxEdit.Paste();
     }
 }
Exemplo n.º 6
0
		private void AdjustToUpperInvariant(TextBox tb)
		{
			try
			{
				fInTextChanged = true;
				//Adjusting needs to position the cursor at the end of the text. Therefore
				//Paste() is a way to do this.
				String tmp = tb.Text.Trim().ToUpperInvariant();
				tb.Clear();
				tb.Paste(tmp);
			}
			finally
			{
				fInTextChanged = false;
			}
		}
Exemplo n.º 7
0
        public void OnKeyPress(object sender, KeyPressEventArgs e)
        {
            string hexChars = "0123456789ABCDEF";

            if (textBoxString1.ContainsFocus | textBoxString2.ContainsFocus
                | textBoxString3.ContainsFocus |textBoxString4.ContainsFocus)
            { // ignore typing in textboxes
                return;
            }
            
            // check for copy/cut
            if ((e.KeyChar == 3) || (e.KeyChar == 24))
            {
                textBoxDisplay.Copy();
                return;
            }

            if (radioButtonDisconnect.Checked)
            { // don't do anything else if not connected
                return;
            }

            textBoxDisplay.Focus();
            
            if (radioButtonHex.Checked)
            { // hex mode
                string charTyped = e.KeyChar.ToString();    // get typed char
                charTyped = charTyped.ToUpper();
                if (charTyped.IndexOfAny(hexChars.ToCharArray()) == 0)
                { // valid Hex character
                    if (labelTypeHex.Visible)
                    { // first nibble already typed - send byte
                        string dataString = labelTypeHex.Text.Substring(11,1) + charTyped;
                        labelTypeHex.Text = "Type Hex : ";
                        labelTypeHex.Visible = false;
                        byte[] hexByte = new byte[1];
                        hexByte[0] = (byte)Utilities.Convert_Value_To_Int("0x" + dataString);
                        dataString = "TX:  " + dataString + "\r\n";
                        textBoxDisplay.AppendText(dataString);
                        textBoxDisplay.SelectionStart = textBoxDisplay.Text.Length;
                        textBoxDisplay.ScrollToCaret();
                        if (logFile != null)
                        {
                            logFile.Write(dataString);
                        }
                        Pk2.DataDownload(hexByte, 0, hexByte.Length);
                    }
                    else
                    { // show first nibble
                        labelTypeHex.Text = "Type Hex : " + charTyped + "_";
                        labelTypeHex.Visible = true;
                    }
                }
                else
                { // other char - clear typed hex
                    labelTypeHex.Text = "Type Hex : ";
                    labelTypeHex.Visible = false;
                }
            }
            else
            { // ASCII mode
                // check for paste
                if (e.KeyChar == 22)
                {
                    textBoxDisplay.SelectionStart = textBoxDisplay.Text.Length; //cursor at end
                    TextBox tempBox = new TextBox();
                    tempBox.Multiline = true;
                    tempBox.Paste();
                    do
                    {
                        int pasteLength = tempBox.Text.Length;
                        if (pasteLength > 60)
                        {
                            pasteLength = 60;
                        }
                        sendString(tempBox.Text.Substring(0, pasteLength), false);
                        tempBox.Text = tempBox.Text.Substring(pasteLength);
                        
                        // wait according to the baud rate so we don't overflow the download buffer
                        float baud = float.Parse((comboBoxBaud.SelectedItem.ToString()));
                        baud = (1F / baud) * 12F * (float)pasteLength; // to ensure we don't overflow, give each byte 12 bits
                        baud *= 1000F; // baud is now in ms.
                        Thread.Sleep((int)baud);
                    } while (tempBox.Text.Length > 0);
                    
                    tempBox.Dispose();
                    return;
                }
                
                string charTyped = e.KeyChar.ToString();
                if (charTyped == "\r")
                {
                    charTyped = "\r\n";
                }
                sendString(charTyped, false);
            }
        }
Exemplo n.º 8
0
 /// <include file='doc\ToolStripTextBox.uex' path='docs/doc[@for="ToolStripTextBox.Paste"]/*' />
 public void Paste()
 {
     TextBox.Paste();
 }
Exemplo n.º 9
0
 /// <summary> method: menuPaste_Click
 ///this menu item is only enabled when there is text in the Clipboard
 ///The .Paste method will past the Clipoard text at the current cursor
 ///position
 /// </summary>
 private void menuPaste_Click(object sender, System.EventArgs e)
 {
     textBox1.Paste();
 }
Exemplo n.º 10
0
		public void ModifiedTest ()
		{
			TextBox t = new TextBox ();
			Assert.AreEqual (false, t.Modified, "modified-1");

			t.Modified = true;
			Assert.AreEqual (true, t.Modified, "modified-2");

			t.Modified = false;
			Assert.AreEqual (false, t.Modified, "modified-3");

			// Changes in Text property don't change Modified,
			// as opposed what the .net docs say
			t.ModifiedChanged += new EventHandler (TextBox_ModifiedChanged);

			modified_changed_fired = false;
			t.Text = "TEXT";
			Assert.AreEqual (false, t.Modified, "modified-4");
			Assert.AreEqual (false, modified_changed_fired, "modified-4-1");

			t.Modified = true;
			modified_changed_fired = false;
			t.Text = "hello";
			Assert.AreEqual (true, t.Modified, "modified-5");
			Assert.AreEqual (false, modified_changed_fired, "modified-5-1");

			t.Modified = false;
			modified_changed_fired = false;
			t.Text = "hello mono";
			Assert.AreEqual (false, t.Modified, "modified-6");
			Assert.AreEqual (false, modified_changed_fired, "modified-6-1");

			// The methods changing the text value, however,
			// do change Modified
			t.Modified = true;
			modified_changed_fired = false;
			t.AppendText ("a");
			Assert.AreEqual (false, t.Modified, "modified-7");
			Assert.AreEqual (true, modified_changed_fired, "modified-7-1");

			t.Modified = true;
			modified_changed_fired = false;
			t.Clear ();
			Assert.AreEqual (false, t.Modified, "modified-8");
			Assert.AreEqual (true, modified_changed_fired, "modified-8-1");

			t.Text = "a message";
			t.SelectAll ();
			t.Modified = false;
			t.Cut ();
			Assert.AreEqual (true, t.Modified, "modified-9");

			t.Modified = false;
			t.Paste ();
			Assert.AreEqual (true, t.Modified, "modified-10");

			t.Modified = false;
			t.Undo ();
			Assert.AreEqual (true, t.Modified, "modified-11");
		}
Exemplo n.º 11
0
 //편집 > 붙여넣기
 private void menuEditPaste_Click(object sender, System.EventArgs e)
 {
     mainTextBox.Paste();
 }
Exemplo n.º 12
0
 public static void ApplyControlBackspace(TextBox textBox)
 {
     if (textBox.SelectionLength == 0)
     {
         var text = textBox.Text;
         var deleteUpTo = textBox.SelectionStart;
         if (deleteUpTo > 0 && deleteUpTo <= text.Length)
         {
             text = text.Substring(0, deleteUpTo);
             var textElementIndices = StringInfo.ParseCombiningCharacters(text);
             var index = textElementIndices.Length;
             var textIndex = deleteUpTo;
             var deleteFrom = -1;
             while (index > 0)
             {
                 index--;
                 textIndex = textElementIndices[index];
                 if (!IsSpaceCategory(CharUnicodeInfo.GetUnicodeCategory(text, textIndex)))
                     break;
             }
             if (index > 0) // HTML tag?
             {
                 if (text[textIndex] == '>')
                 {
                     var openingBracketIndex = text.LastIndexOf('<', textIndex - 1);
                     if (openingBracketIndex >= 0 && text.IndexOf('>', openingBracketIndex + 1) == textIndex)
                         deleteFrom = openingBracketIndex; // delete whole tag
                 }
                 else if (text[textIndex] == '}')
                 {
                     var startIdx = text.LastIndexOf(@"{\", textIndex - 1, StringComparison.Ordinal);
                     if (startIdx >= 0 && text.IndexOf('}', startIdx + 1) == textIndex)
                     {
                         deleteFrom = startIdx;
                     }
                 }
             }
             if (deleteFrom < 0)
             {
                 if (BreakChars.Contains(text[textIndex]))
                     deleteFrom = -2;
                 while (index > 0)
                 {
                     index--;
                     textIndex = textElementIndices[index];
                     if (IsSpaceCategory(CharUnicodeInfo.GetUnicodeCategory(text, textIndex)))
                     {
                         if (deleteFrom > -2)
                         {
                             if (deleteFrom < 0)
                                 deleteFrom = textElementIndices[index + 1];
                             break;
                         }
                         deleteFrom = textElementIndices[index + 1];
                         if (!":!?".Contains(text[deleteFrom]))
                             break;
                     }
                     else if (BreakChars.Contains(text[textIndex]))
                     {
                         if (deleteFrom > -2)
                         {
                             if (deleteFrom < 0)
                                 deleteFrom = textElementIndices[index + 1];
                             break;
                         }
                     }
                     else
                     {
                         deleteFrom = -1;
                     }
                 }
             }
             if (deleteFrom < deleteUpTo)
             {
                 if (deleteFrom < 0)
                     deleteFrom = 0;
                 textBox.Select(deleteFrom, deleteUpTo - deleteFrom);
                 textBox.Paste(string.Empty);
             }
         }
     }
 }
Exemplo n.º 13
0
 public void Paste()
 {
     TB.Paste();
 }
Exemplo n.º 14
0
 private void pasteClick(object sender, System.EventArgs e)
 {
     textBox.Paste();
 }
Exemplo n.º 15
0
 public void Paste()
 {
     txtEdit.Paste();
 }
 void MPasteClick(object sender, System.EventArgs e)
 {
     editorBox.Paste();
 }
Exemplo n.º 17
-1
        private void PasteString(TextBox oTB, string sText)
        {
            StringBuilder oBuffer = new StringBuilder(sText);

            if (sText == Environment.NewLine)
            {
                int iSelStart = oTB.SelectionStart;
                int iLigne = oTB.GetLineFromCharIndex(iSelStart);

                if (oTB.Lines.Length > iLigne)
                {
                    string sLigne = oTB.Lines[iLigne];
                    foreach (char c in sLigne)
                    {
                        if (c == ' ' || c == '\t')
                        {
                            oBuffer.Append(c);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
            oTB.Paste(oBuffer.ToString());
        }