本文整理汇总了C#中Gtk.Clipboard类的典型用法代码示例。如果您正苦于以下问题:C# Clipboard类的具体用法?C# Clipboard怎么用?C# Clipboard使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Clipboard类属于Gtk命名空间,在下文中一共展示了Clipboard类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PasteJson
void PasteJson(Clipboard c, string text)
{
if (string.IsNullOrEmpty (text)) {
InsertCSharp (string.Empty);
return;
}
var gen = new JsonClassGenerator {
Example = text,
MainClass = "RootObject",
UseProperties = true,
CodeWriter = new CSharpCodeWriter ()
};
try {
using (var sw = new StringWriter ()) {
gen.OutputStream = sw;
gen.GenerateClasses ();
sw.Flush ();
var generatedString = sw.ToString ();
InsertCSharp (generatedString);
}
} catch (Exception ex) {
Console.WriteLine (ex.Message);
MessageService.ShowWarning (string.Format ("Invalid JSON: {0}", ex.Message));
}
gen = null;
}
示例2: Main
static HttpListener listener; // http server providing clipboard history selection
public static void Main (string[] args)
{
// make UI methods for clipboard access available
Application.Init ();
// setup http interface
listener = new HttpListener();
listener.Prefixes.Add("http://*:5544/");
listener.Start();
listener.BeginGetContext(ProcessRequest, null);
// initialize access to clipboard
clippy = Gtk.Clipboard.Get(Gdk.Atom.Intern("PRIMARY", false));
// schedule polling of clipboard content
timer = new System.Timers.Timer(300);
timer.Elapsed += new System.Timers.ElapsedEventHandler(ReadClipboardUI);
timer.Start();
// just to prevent termination of the app
Application.Run();
// shutdown http interface
listener.Stop();
}
示例3: ClearProxy
void ClearProxy (Clipboard clipboard)
{
if (Data ["clear_func"] != null) {
ClipboardClearFunc clear = Data ["clear_func"] as ClipboardClearFunc;
clear (clipboard);
}
SetPersistentData (null, null, null);
}
示例4: clipboardTextReceived
protected void clipboardTextReceived(Clipboard clipboard, string text)
{
try{
XmlTextReader reader = new XmlTextReader(new StringReader(text));
KMLDistance myKmlDistance = new KMLDistance(reader);
fillDistancesToTreeview(myKmlDistance);
}catch{
}
}
示例5: ClipboardGetFunc
public void ClipboardGetFunc(Clipboard clipboard, SelectionData selection_data, uint info)
{
if (selection_data == null)
return;
switch (info) {
case TextType:
selection_data.Text = Utils.ToNormalString (lyrics_text);
break;
}
}
示例6: ClippyItem
public ClippyItem ()
{
Icon = "edit-cut";
if (trackMouseSelections)
clipboard = Gtk.Clipboard.Get (Gdk.Selection.Primary);
else
clipboard = Gtk.Clipboard.Get (Gdk.Selection.Clipboard);
timer = GLib.Timeout.Add (timerDelay, CheckClipboard);
Updated ();
}
示例7: Clipboard
/// <summary>
/// Creates clipboard object.
/// </summary>
private Clipboard()
{
this.timerLock = new object();
this.KeyboardItem = null;
this.MouseItem = null;
this.Items = new ItemsCollection();
this.keyboardClipboard = Gtk.Clipboard.Get(Gdk.Selection.Clipboard);
this.keyboardClipboard.OwnerChange += this.OnKeyboardClipboardOwnerChanged;
this.mouseClipboard = Gtk.Clipboard.Get(Gdk.Selection.Primary);
this.mouseClipboard.OwnerChange += this.OnMouseClipboardOwnerChanged;
this.pixbufFormats = Pixbuf.Formats;
this.OnKeyboardClipboardOwnerChanged(this, null);
this.OnMouseClipboardOwnerChanged(this, null);
}
示例8: ReceivedFunc
private void ReceivedFunc(Clipboard clipboard, SelectionData selection) {
string temp = Encoding.ASCII.GetString(selection.Data);
if (temp==null) return;
string[] items = temp.Split('\n', '\r');
List<Uri> paths = new List<Uri>(items.Length);
for(int i = 1; i < items.Length; ++i) {
if(items[i] == string.Empty) continue;
Uri fileFrom = new Uri(items[i]);
paths.Add(fileFrom);
}
inData = new ClipboardData(paths, items[0] == "cut" ? ClipboardOperationType.Cut : ClipboardOperationType.Copy);
evt(null, null);
}
示例9: OnCopy
internal void OnCopy ()
{
TreeModel model;
StringBuilder txt = new StringBuilder ();
foreach (Gtk.TreePath p in view.Selection.GetSelectedRows (out model)) {
TreeIter it;
if (!model.GetIter (out it, p))
continue;
LogMessage msg = (LogMessage) model.GetValue (it, (int) Columns.Message);
if (txt.Length > 0)
txt.Append ('\n');
txt.AppendFormat ("{0} - {1} - {2}", msg.Level, msg.TimeStamp.ToLongTimeString (), msg.Message);
}
clipboard = Clipboard.Get (Gdk.Atom.Intern ("CLIPBOARD", false));
clipboard.Text = txt.ToString ();
clipboard = Clipboard.Get (Gdk.Atom.Intern ("PRIMARY", false));
clipboard.Text = txt.ToString ();
}
示例10: OnUserTaskCopied
void OnUserTaskCopied (object o, EventArgs args)
{
Task task;
TreeModel model;
TreeIter iter;
if (view.Selection.GetSelected (out model, out iter))
{
task = (Task) model.GetValue (iter, (int)Columns.UserTask);
}
else return; // no one selected
clipboard = Clipboard.Get (Gdk.Atom.Intern ("CLIPBOARD", false));
clipboard.Text = task.ToString ();
clipboard = Clipboard.Get (Gdk.Atom.Intern ("PRIMARY", false));
clipboard.Text = task.ToString ();
}
示例11: InitPlugin
public override void InitPlugin() {
clip = Gtk.Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", false));
}
示例12: OnGenTaskCopied
void OnGenTaskCopied (object o, EventArgs args)
{
Task task = SelectedTask;
if (task != null) {
clipboard = Clipboard.Get (Gdk.Atom.Intern ("CLIPBOARD", false));
clipboard.Text = task.ToString ();
clipboard = Clipboard.Get (Gdk.Atom.Intern ("PRIMARY", false));
clipboard.Text = task.ToString ();
}
}
示例13: ClipboardClearFunc
public void ClipboardClearFunc(Clipboard clipboard)
{
}
示例14: PasteFrom
static int PasteFrom (Clipboard clipboard, TextEditorData data, bool preserveSelection, int insertionOffset, bool preserveState)
{
int result = -1;
if (!data.CanEdit (data.Document.OffsetToLineNumber (insertionOffset)))
return result;
clipboard.RequestContents (CopyOperation.MD_ATOM, delegate(Clipboard clp, SelectionData selectionData) {
if (selectionData.Length > 0) {
byte[] selBytes = selectionData.Data;
string text = System.Text.Encoding.UTF8.GetString (selBytes, 1, selBytes.Length - 1);
bool pasteBlock = (selBytes[0] & 1) == 1;
bool pasteLine = (selBytes[0] & 2) == 2;
if (!pasteBlock && !pasteLine)
return;
data.Document.BeginAtomicUndo ();
if (preserveSelection && data.IsSomethingSelected)
data.DeleteSelectedText ();
data.Caret.PreserveSelection = true;
if (pasteBlock) {
string[] lines = text.Split ('\r');
int lineNr = data.Document.OffsetToLineNumber (insertionOffset);
int col = insertionOffset - data.Document.GetLine (lineNr).Offset;
int visCol = data.Document.GetLine (lineNr).GetVisualColumn (data, col);
LineSegment curLine;
int lineCol = col;
result = 0;
for (int i = 0; i < lines.Length; i++) {
while (data.Document.LineCount <= lineNr + i) {
data.Insert (data.Document.Length, Environment.NewLine);
result += Environment.NewLine.Length;
}
curLine = data.Document.GetLine (lineNr + i);
if (lines[i].Length > 0) {
lineCol = curLine.GetLogicalColumn (data, visCol);
if (curLine.EditableLength + 1 < lineCol) {
result += lineCol - curLine.EditableLength;
data.Insert (curLine.Offset + curLine.EditableLength, new string (' ', lineCol - curLine.EditableLength));
}
data.Insert (curLine.Offset + lineCol, lines[i]);
result += lines[i].Length;
}
if (!preserveState)
data.Caret.Offset = curLine.Offset + lineCol + lines[i].Length;
}
} else if (pasteLine) {
result += text.Length;
LineSegment curLine = data.Document.GetLine (data.Caret.Line);
data.Insert (curLine.Offset, text + data.EolMarker);
if (!preserveState)
data.Caret.Offset += text.Length + data.EolMarker.Length;
}
/* data.MainSelection = new Selection (data.Document.OffsetToLocation (insertionOffset),
data.Caret.Location,
lines.Length > 1 ? SelectionMode.Block : SelectionMode.Normal);*/
if (!preserveState)
data.ClearSelection ();
data.Caret.PreserveSelection = false;
data.Document.EndAtomicUndo ();
}
});
if (result < 0) {
clipboard.WaitIsTextAvailable ();
clipboard.RequestText (delegate(Clipboard clp, string text) {
if (string.IsNullOrEmpty (text))
return;
data.Document.BeginAtomicUndo ();
int caretPos = data.Caret.Offset;
if (data.IsSomethingSelected && data.MainSelection.SelectionMode == SelectionMode.Block) {
data.Caret.PreserveSelection = true;
if (!data.MainSelection.IsDirty) {
data.DeleteSelectedText (false);
data.MainSelection.IsDirty = true;
}
int textLength = 0;
int column = data.Caret.Column;
int minLine = data.MainSelection.MinLine;
int maxLine = data.MainSelection.MaxLine;
for (int lineNumber = minLine; lineNumber <= maxLine; lineNumber++) {
int offset = data.Document.GetLine (lineNumber).Offset + column;
textLength = data.Insert (offset, text);
data.PasteText (offset, text);
}
data.Caret.Offset += textLength;
data.MainSelection.Anchor = new DocumentLocation (data.Caret.Line == minLine ? maxLine : minLine, data.Caret.Column - textLength);
data.MainSelection.Lead = new DocumentLocation (data.Caret.Line, data.Caret.Column);
data.Caret.PreserveSelection = false;
data.Document.CommitMultipleLineUpdate (data.MainSelection.MinLine, data.MainSelection.MaxLine);
} else {
ISegment selection = data.SelectionRange;
if (preserveSelection && data.IsSomethingSelected)
data.DeleteSelectedText ();
data.Caret.PreserveSelection = true;
//int oldLine = data.Caret.Line;
int textLength = data.Insert (insertionOffset, text);
result = textLength;
//.........这里部分代码省略.........
示例15: PasteReceived
void PasteReceived (Clipboard clipboard, string text)
{
pasteEntry.Text = text;
}