本文整理汇总了C#中Gtk.Clipboard类的典型用法代码示例。如果您正苦于以下问题:C# Clipboard类的具体用法?C# Clipboard怎么用?C# Clipboard使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Clipboard类属于Gtk命名空间,在下文中一共展示了Clipboard类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:ryanhair,项目名称:SpecialCopy,代码行数:29,代码来源:JsonConverterHandler.cs
示例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();
}
开发者ID:eugenkrizo,项目名称:tablet-clipboard,代码行数:27,代码来源:Main.cs
示例3: ClearProxy
void ClearProxy (Clipboard clipboard)
{
if (Data ["clear_func"] != null) {
ClipboardClearFunc clear = Data ["clear_func"] as ClipboardClearFunc;
clear (clipboard);
}
SetPersistentData (null, null, null);
}
开发者ID:liberostelios,项目名称:gtk-sharp,代码行数:8,代码来源:Clipboard.cs
示例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{
}
}
开发者ID:BackupTheBerlios,项目名称:earthometer-svn,代码行数:9,代码来源:MainWindow.cs
示例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;
}
}
开发者ID:nailyk,项目名称:banshee-community-extensions,代码行数:10,代码来源:LyricsBrowser.cs
示例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 ();
}
开发者ID:Aurora-and-Equinox,项目名称:docky,代码行数:12,代码来源:ClippyItem.cs
示例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);
}
开发者ID:quequotion,项目名称:glippy,代码行数:17,代码来源:Clipboard.cs
示例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);
}
开发者ID:MI3Guy,项目名称:Xenon-File-Manager--.NET-Mono-,代码行数:15,代码来源:ClipboardGtk.cs
示例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 ();
}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:18,代码来源:InternalLogPad.cs
示例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 ();
}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:17,代码来源:UserTasksView.cs
示例11: InitPlugin
public override void InitPlugin() {
clip = Gtk.Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", false));
}
开发者ID:MI3Guy,项目名称:Xenon-File-Manager--.NET-Mono-,代码行数:3,代码来源:ClipboardGtk.cs
示例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 ();
}
}
开发者ID:Tak,项目名称:monodevelop-novell,代码行数:10,代码来源:CommentTasksView.cs
示例13: ClipboardClearFunc
public void ClipboardClearFunc(Clipboard clipboard)
{
}
开发者ID:nailyk,项目名称:banshee-community-extensions,代码行数:3,代码来源:LyricsBrowser.cs
示例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;
//.........这里部分代码省略.........
开发者ID:pgoron,项目名称:monodevelop,代码行数:101,代码来源:ClipboardActions.cs
示例15: PasteReceived
void PasteReceived (Clipboard clipboard, string text)
{
pasteEntry.Text = text;
}
开发者ID:liberostelios,项目名称:gtk-sharp,代码行数:4,代码来源:DemoClipboard.cs
示例16: 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;
if (clipboard.WaitIsTargetAvailable (CopyOperation.MD_ATOM)) {
clipboard.RequestContents (CopyOperation.MD_ATOM, delegate(Clipboard clp, SelectionData selectionData) {
if (selectionData.Length > 0) {
byte[] selBytes = selectionData.Data;
var upperBound = System.Math.Max (0, System.Math.Min (selBytes [1], selBytes.Length - 2));
byte[] copyData = new byte[upperBound];
Array.Copy (selBytes, 2, copyData, 0, copyData.Length);
var rawTextOffset = 1 + 1 + copyData.Length;
string text = Encoding.UTF8.GetString (selBytes, rawTextOffset, selBytes.Length - rawTextOffset);
bool pasteBlock = (selBytes [0] & 1) == 1;
bool pasteLine = (selBytes [0] & 2) == 2;
if (pasteBlock) {
using (var undo = data.OpenUndoGroup ()) {
var version = data.Document.Version;
if (!preserveSelection)
data.DeleteSelectedText (!data.IsSomethingSelected || data.MainSelection.SelectionMode != SelectionMode.Block);
int startLine = data.Caret.Line;
data.EnsureCaretIsNotVirtual ();
insertionOffset = version.MoveOffsetTo (data.Document.Version, insertionOffset);
data.Caret.PreserveSelection = true;
var lines = new List<string> ();
int offset = 0;
while (true) {
var delimiter = LineSplitter.NextDelimiter (text, offset);
if (delimiter.IsInvalid)
break;
int delimiterEndOffset = delimiter.EndOffset;
lines.Add (text.Substring (offset, delimiter.Offset - offset));
offset = delimiterEndOffset;
}
if (offset < text.Length)
lines.Add (text.Substring (offset, text.Length - offset));
int lineNr = data.Document.OffsetToLineNumber (insertionOffset);
int col = insertionOffset - data.Document.GetLine (lineNr).Offset;
int visCol = data.Document.GetLine (lineNr).GetVisualColumn (data, col);
DocumentLine curLine;
int lineCol = col;
result = 0;
for (int i = 0; i < lines.Count; i++) {
while (data.Document.LineCount <= lineNr + i) {
data.Insert (data.Document.TextLength, Environment.NewLine);
result += Environment.NewLine.Length;
}
curLine = data.Document.GetLine (lineNr + i);
if (lines [i].Length > 0) {
lineCol = curLine.GetLogicalColumn (data, visCol);
if (curLine.Length + 1 < lineCol) {
result += lineCol - curLine.Length;
data.Insert (curLine.Offset + curLine.Length, new string (' ', lineCol - curLine.Length));
}
data.Insert (curLine.Offset + lineCol, lines [i]);
result += lines [i].Length;
}
if (!preserveState)
data.Caret.Offset = curLine.Offset + lineCol + lines [i].Length;
}
if (!preserveState)
data.ClearSelection ();
data.FixVirtualIndentation (startLine);
data.Caret.PreserveSelection = false;
}
} else if (pasteLine) {
using (var undo = data.OpenUndoGroup ()) {
if (!preserveSelection)
data.DeleteSelectedText (!data.IsSomethingSelected || data.MainSelection.SelectionMode != SelectionMode.Block);
data.EnsureCaretIsNotVirtual ();
data.Caret.PreserveSelection = true;
result = text.Length;
DocumentLine curLine = data.Document.GetLine (data.Caret.Line);
result = PastePlainText (data, curLine.Offset, text + data.EolMarker, preserveSelection, copyData);
if (!preserveState)
data.ClearSelection ();
data.Caret.PreserveSelection = false;
data.FixVirtualIndentation (curLine.LineNumber);
}
} else {
result = PastePlainText (data, insertionOffset, text, preserveSelection, copyData);
}
}
});
// we got MD_ATOM text - no need to request text. (otherwise buffer may get copied twice).
return result;
}
if (result < 0 && clipboard.WaitIsTextAvailable ()) {
clipboard.RequestText (delegate(Clipboard clp, string text) {
if (string.IsNullOrEmpty (text))
return;
result = PastePlainText (data, insertionOffset, text, preserveSelection);
});
//.........这里部分代码省略.........
开发者ID:Kalnor,项目名称:monodevelop,代码行数:101,代码来源:ClipboardActions.cs
示例17: TryHandlePaste
public override bool TryHandlePaste(Clipboard cb)
{
if (CurrentTextEngine.EditMode == EditingMode.NotEditing) {
return false;
}
if (!CurrentTextEngine.PerformPaste (cb)) {
return false;
}
RedrawText (true, true);
return true;
}
开发者ID:Kharevich,项目名称:Pinta,代码行数:12,代码来源:TextTool.cs
示例18: ClipboardGetFunc
public void ClipboardGetFunc (Clipboard clipboard, SelectionData selection_data, uint info)
{
SetData (selection_data, info);
}
开发者ID:kekekeks,项目名称:monodevelop,代码行数:4,代码来源:ClipboardActions.cs
示例19: PasteFrom
static int PasteFrom (Clipboard clipboard, TextEditorData data, bool preserveSelection, int insertionOffset)
{
return PasteFrom (clipboard, data, preserveSelection, insertionOffset, false);
}
开发者ID:kekekeks,项目名称:monodevelop,代码行数:4,代码来源:ClipboardActions.cs
示例20: 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;
if (clipboard.WaitIsTargetAvailable (CopyOperation.MD_ATOM)) {
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;
using (var undo = data.OpenUndoGroup ()) {
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);
DocumentLine curLine;
int lineCol = col;
result = 0;
for (int i = 0; i < lines.Length; i++) {
while (data.Document.LineCount <= lineNr + i) {
data.Insert (data.Document.TextLength, Environment.NewLine);
result += Environment.NewLine.Length;
}
curLine = data.Document.GetLine (lineNr + i);
if (lines [i].Length > 0) {
lineCol = curLine.GetLogicalColumn (data, visCol);
if (curLine.Length + 1 < lineCol) {
result += lineCol - curLine.Length;
data.Insert (curLine.Offset + curLine.Length, new string (' ', lineCol - curLine.Length));
}
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;
DocumentLine curLine = data.Document.GetLine (data.Caret.Line);
data.Insert (curLine.Offset, text + data.EolMarker);
} else {
int offset = data.Caret.Offset;
data.InsertAtCaret (text);
data.PasteText (offset, text, data.Caret.Offset - offset);
}
/* 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;
}
}
});
// we got MD_ATOM text - no need to request text. (otherwise buffer may get copied twice).
return result;
}
if (result < 0 && clipboard.WaitIsTextAvailable ()) {
clipboard.RequestText (delegate(Clipboard clp, string text) {
if (string.IsNullOrEmpty (text))
return;
using (var undo = data.OpenUndoGroup ()) {
int caretPos = data.Caret.Offset;
if (data.IsSomethingSelected && data.MainSelection.SelectionMode == SelectionMode.Block) {
data.Caret.PreserveSelection = true;
data.DeleteSelectedText (false);
int textLength = 0;
int minLine = data.MainSelection.MinLine;
int maxLine = data.MainSelection.MaxLine;
var visualInsertLocation = data.LogicalToVisualLocation (data.Caret.Location);
for (int lineNumber = minLine; lineNumber <= maxLine; lineNumber++) {
DocumentLine lineSegment = data.GetLine (lineNumber);
int insertOffset = lineSegment.GetLogicalColumn (data, visualInsertLocation.Column) - 1;
if (lineSegment.Length < insertOffset) {
int visualLastColumn = lineSegment.GetVisualColumn (data, lineSegment.Length + 1);
int charsToInsert = visualInsertLocation.Column - visualLastColumn;
int spaceCount = charsToInsert % data.Options.TabSize;
string textToInsert = new string ('\t', (charsToInsert - spaceCount) / data.Options.TabSize) + new string (' ', spaceCount) + text;
insertOffset = lineSegment.Length;
int insertedChars = data.Insert (lineSegment.Offset + insertOffset, textToInsert);
data.PasteText (lineSegment.Offset + insertOffset, textToInsert, insertedChars);
} else {
textLength = data.Insert (lineSegment.Offset + insertOffset, text);
data.PasteText (lineSegment.Offset + insertOffset, text, textLength);
}
}
data.MainSelection.Anchor = new DocumentLocation (System.Math.Max (DocumentLocation.MinLine, data.Caret.Line == minLine ? maxLine : minLine), System.Math.Max (DocumentLocation.MinColumn, data.Caret.Column - textLength));
data.MainSelection.Lead = new DocumentLocation (data.Caret.Line, data.Caret.Column);
data.Caret.PreserveSelection = false;
//.........这里部分代码省略.........
开发者ID:gary-b,项目名称:monodevelop,代码行数:101,代码来源:ClipboardActions.cs
注:本文中的Gtk.Clipboard类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论