public void OnUserBroadcast(DateTime dateTime, string fromUser, string message) { _dispatcher.Invoke(new Action(delegate { if (message.Length > 50) { Ink2.Strokes.Add(StrokeToString.LoadFromBase64String(message).Last()); } } ) ); //_dispatcher.Invoke(new Action(() => AppendText(dateTime, fromUser, "says", message))); }
private void Ink_StrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e) { var name = userNameTextBox.Text; Stroke temp = e.Stroke; //Ink.Strokes.s Guid currentTimeGuid = Guid.NewGuid(); Count.Add(currentTimeGuid); temp.AddPropertyData(currentTimeGuid, DateTime.Now); string result = StrokeToString.SaveToBase64String(Ink.Strokes); ThreadPool.QueueUserWorkItem(delegate { Send(name, result); }); //Ink2.Strokes.Add(temp);//localhost测试画笔 }
public void OnBroadcast(DateTime dateTime, bool result, string resultMessage, string sentMessage) { if (result) { // Ignore the result message (probably unnecessary information) // Just output what was sent //_dispatcher.Invoke(new Action(() => AppendText(dateTime, "You", "say", sentMessage))); _dispatcher.Invoke(new Action(delegate { if (sentMessage.Length > 50) { Ink2.Strokes.Add(StrokeToString.LoadFromBase64String(sentMessage).Last()); } } ) ); //Ink2.RaiseEvent(new RoutedEventArgs(InkCanvas.StrokeCollectedEvent, Ink2)); return; } // Display the error message _dispatcher.Invoke(new Action(() => AppendText(dateTime, resultMessage, Colors.Red))); }