// Copies the internal strokes to the IDataObject protected override void DoCopy(IDataObject dataObject) { // samgeo - Presharp issue // Presharp gives a warning when local IDisposable variables are not closed // in this case, we can't call Dispose since it will also close the underlying stream // which needs to be open for consumers to read #pragma warning disable 1634, 1691 #pragma warning disable 6518 // Save the data in the data object. MemoryStream stream = new MemoryStream(); Strokes.Save(stream); stream.Position = 0; (new UIPermission(UIPermissionClipboard.AllClipboard)).Assert();//BlessedAssert try { dataObject.SetData(StrokeCollection.InkSerializedFormat, stream); } finally { UIPermission.RevertAssert(); } #pragma warning restore 6518 #pragma warning restore 1634, 1691 }
public void GetObjectData(SerializationInfo info, StreamingContext context) { info.AddValue(nameof(Id), Id); info.AddValue(nameof(Shape), Shape); info.AddValue(nameof(Name), Name); info.AddValue(nameof(Content), Content); // serialze strokes using (var stream = new MemoryStream()) { Strokes.Save(stream); var bytes = stream.ToArray(); info.AddValue(nameof(Strokes), bytes); } }
private async Task <bool> StrokeCanvas() { using (MemoryStream memoryStream = new MemoryStream()) { Strokes.Save(memoryStream); try { //var recepient = _selectedParticipant.Name; await chatService.SendBroadcastStrokesAsync(memoryStream.ToArray()); return(true); } catch (Exception) { return(false); } } }