/// <exception cref="ArgumentNullException"><paramref name="context" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="data" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentException"><paramref name="data" /> is empty.</exception> public override IClipboardOperationResult Write(IClipboardWritingContext context, byte[] data) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (data == null) { throw new ArgumentNullException(nameof(data)); } if (!data.Any()) { throw new ArgumentException($"{nameof(data)} cannot be empty."); } var unicodeData = TransformToUnicodeClipboardBytes(data); try { var result = context.SetData(ClipboardDataType.UnicodeLittleEndianText, unicodeData); return(result); } finally { Array.Clear(unicodeData, 0, unicodeData.Length); } }
public override IClipboardOperationResult Write(IClipboardWritingContext context, IEnumerable <string> data) { if (data == null) { throw new ArgumentNullException(nameof(data)); } if (!data.Any()) { throw new ArgumentException($"{nameof(data)} is empty list"); } // https://msdn.microsoft.com/en-us/library/windows/desktop/bb776902(v=vs.85).aspx#CF_HDROP // The file name array consists of a series of strings, each containing one file's fully qualified path, including // the terminating NULL character. An additional null character is appended to the final string to terminate the // array. For example, if the files c:\temp1.txt and c:\temp2.txt are being transferred, the character array looks // like this: // c:\temp1.txt'\0'c:\temp2.txt'\0''\0' var sb = new StringBuilder(); sb.Append(Header); foreach (var filePath in data) { sb.Append(filePath + '\0'); } sb.Append(Terminator); var stringData = sb.ToString(); var bytes = TextService.GetBytes(stringData); var result = context.SetData(ClipboardDataType.FileDropList, bytes); return(result); }
public override IClipboardOperationResult Write(IClipboardWritingContext context, string data) { var bytes = TextService.GetBytes(data); var unicodeBytesWriter = Factory.Get <UnicodeBytesWriter>(); var result = unicodeBytesWriter.Write(context, bytes); return(result); }
/// <exception cref="T:System.ArgumentNullException"><paramref name="context" /> is <see langword="null" /></exception> /// <exception cref="T:System.ArgumentNullException"><paramref name="data" /> is <see langword="null" /></exception> public override IClipboardOperationResult Write(IClipboardWritingContext context, string data) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (data == null) { throw new ArgumentNullException(nameof(data)); } var bytes = TextService.GetBytes(data); var unicodeBytesWriter = Factory.Get <UnicodeBytesWriter>(); var result = unicodeBytesWriter.Write(context, bytes); return(result); }
/// <summary> /// Reads the data from specified <see cref="IWindowsClipboardSession" />. /// </summary> /// <param name="context">Clipboard session context.</param> /// <returns>Result of the reading operation.</returns> public abstract IClipboardOperationResult Write(IClipboardWritingContext context, TData data);