AGS.Editor.Utilities.CopyTextToClipboard C# (CSharp) Метод

CopyTextToClipboard() публичный статический Метод

public static CopyTextToClipboard ( string text ) : void
text string
Результат void
        public static void CopyTextToClipboard(string text)
        {
            try
            {
                Clipboard.SetText(text);
            }
            catch (System.Runtime.InteropServices.ExternalException)
            {
                Factory.GUIController.ShowMessage("Unable to copy the text to the clipboard. The clipboard might be in use by another application.", System.Windows.Forms.MessageBoxIcon.Warning);
            }
        }

Usage Example

Пример #1
0
        private void ContextMenuEventHandler(object sender, EventArgs e)
        {
            String result = string.Empty;

            foreach (ListViewItem item in lvwResults.Items)
            {
                String thisLine = string.Empty;
                if (item.SubItems.Count > 1)
                {
                    thisLine += item.SubItems[1].Text;                      // filename

                    if ((item.SubItems.Count > 2) &&
                        (item.SubItems[2].Text.Length > 0))
                    {
                        thisLine += "(" + item.SubItems[2].Text + ")";                          // line number
                    }
                }
                if (thisLine.Length > 0)
                {
                    thisLine += ": ";
                }
                thisLine += item.SubItems[0].Text;
                thisLine += Environment.NewLine;
                result   += thisLine;
            }

            if (!string.IsNullOrEmpty(result))
            {
                Utilities.CopyTextToClipboard(result);
            }
        }
All Usage Examples Of AGS.Editor.Utilities::CopyTextToClipboard