/// <summary> /// Constructs a screen object from a shape /// </summary> /// <param name="shp"></param> /// <returns></returns> public Shape Object2Shape(ScreenObject obj) { if (obj != null) { if (obj.Type == ScreenObjectType.Line) { return new Line() { X1 = obj.X1, X2 = obj.X2, Y1 = obj.Y1, Y2 = obj.Y2, StrokeThickness = obj.Thickness, Stroke = new SolidColorBrush(ColorHelper.ColorFromString(obj.StrokeColor)) }; } else if (obj.Type==ScreenObjectType.Ellipse) { var shp = new Ellipse(); CopyValues(obj, shp); return shp; } else if (obj.Type == ScreenObjectType.Rectangle) { var shp = new Rectangle(); CopyValues(obj, shp); return shp; } } return null; }
private void UpdateButton_Click(object sender, RoutedEventArgs e) { try { var txt = this.TalkText.Text; this.TalkText.Text = string.Empty; var talk = new ScreenObject() { Text = txt, Type = ScreenObjectType.Text }; drawArea.MessageCollection.Insert(0, new TalkItem() { Text = talk.Text, Time = DateTime.Now.ToShortTimeString(), From = "Me" }); var obj = new ScreenObject[] { talk }; proxy.Client.DrawAsync(obj.JsonSerialize()); } catch { } }
/// <summary> /// Copy the values to shape /// </summary> /// <param name="obj"></param> /// <param name="shp"></param> private void CopyValues(ScreenObject obj, Shape shp) { Canvas.SetLeft(shp, obj.X1); Canvas.SetTop(shp, obj.Y1); shp.Width = obj.Width; shp.Height = obj.Height; shp.StrokeThickness = obj.Thickness; try { shp.Fill = new SolidColorBrush(ColorHelper.ColorFromString(obj.FillColor)); shp.Stroke = new SolidColorBrush(ColorHelper.ColorFromString(obj.StrokeColor)); } catch { } }