/// <summary> /// Actual handler to invoke user call backs /// </summary> /// <param name="sender"></param> private static void ClipboardHandler(object sender) { IDataObject iData = (DataObject)sender; ClipboardContentTypes format = default(ClipboardContentTypes); object data = null; bool validDataType = false; if (iData.GetDataPresent(DataFormats.Text)) { format = ClipboardContentTypes.PlainText; data = iData.GetData(DataFormats.Text); validDataType = true; } else if (iData.GetDataPresent(DataFormats.Rtf)) { format = ClipboardContentTypes.RichText; data = iData.GetData(DataFormats.Rtf); validDataType = true; } else if (iData.GetDataPresent(DataFormats.CommaSeparatedValue)) { format = ClipboardContentTypes.Csv; data = iData.GetData(DataFormats.CommaSeparatedValue); validDataType = true; } else if (iData.GetDataPresent(DataFormats.Html)) { format = ClipboardContentTypes.Html; data = iData.GetData(DataFormats.Html); validDataType = true; } else if (iData.GetDataPresent(DataFormats.StringFormat)) { format = ClipboardContentTypes.PlainText; data = iData.GetData(DataFormats.StringFormat); validDataType = true; } else if (iData.GetDataPresent(DataFormats.UnicodeText)) { format = ClipboardContentTypes.UnicodeText; data = iData.GetData(DataFormats.UnicodeText); validDataType = true; } if (!validDataType) { return; } OnClipboardModified?.Invoke(null, new ClipboardEventArgs() { Data = data, DataFormat = format }); }
private void ClipboardHandler(object sender) { IDataObject iData = (DataObject)sender; var format = default(EnumClipboardContentTypes); object data = null; bool validDataType = false; if (iData.GetDataPresent(DataFormats.Text)) { format = EnumClipboardContentTypes.PLAIN_TEXT; data = iData.GetData(DataFormats.Text); validDataType = true; } else if (iData.GetDataPresent(DataFormats.Rtf)) { format = EnumClipboardContentTypes.RICH_TEXT; data = iData.GetData(DataFormats.Rtf); validDataType = true; } else if (iData.GetDataPresent(DataFormats.CommaSeparatedValue)) { format = EnumClipboardContentTypes.CSV; data = iData.GetData(DataFormats.CommaSeparatedValue); validDataType = true; } else if (iData.GetDataPresent(DataFormats.Html)) { format = EnumClipboardContentTypes.HTML; data = iData.GetData(DataFormats.Html); validDataType = true; } else if (iData.GetDataPresent(DataFormats.StringFormat)) { format = EnumClipboardContentTypes.PLAIN_TEXT; data = iData.GetData(DataFormats.StringFormat); validDataType = true; } else if (iData.GetDataPresent(DataFormats.UnicodeText)) { format = EnumClipboardContentTypes.UNICODE_TEXT; data = iData.GetData(DataFormats.UnicodeText); validDataType = true; } if (!validDataType) { return; } OnClipboardModified?.Invoke(null, new ClipboardHookEventArgs { Data = data, DataFormat = format }); }