private DrawingAttributes AddAttributes(IDrawPoint pointServer) { DrawingAttributes drAtt = new DrawingAttributes(); drAtt.Width = pointServer.pointParams.width; drAtt.Height = pointServer.pointParams.width; drAtt.StylusTip = (pointServer.pointParams.pointNature == "ellipse") ? StylusTip.Ellipse : StylusTip.Rectangle; System.Windows.Media.Color colorFromServer = (System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#FF000000"); if (pointServer.pointParams.color != null) { colorFromServer = (System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString(pointServer.pointParams.color); } drAtt.Color = colorFromServer; return(drAtt); }
private int ADD(List <StylusPoint> list, int lastLine, bool firstPoint, IDrawPoint p) { StylusPoint stylusPointServer = new StylusPoint(p.pointServer.x, p.pointServer.y, (float)0.5); list.Add(stylusPointServer); DrawingAttributes drAtt = this.AddAttributes(p); StylusPointCollection toAdd = new StylusPointCollection(list); bool size = true; this.inkCAnvas.Dispatcher.Invoke(() => { size = p.id > this.inkCAnvas.Strokes.Count; }); if (lastLine != p.id || firstPoint || (size && lastLine != p.id)) { lastLine = p.id; this.inkCAnvas.Dispatcher.Invoke(() => { indexes[p.id] = this.inkCAnvas.Strokes.Count; }); Stroke a = new Stroke(toAdd, drAtt); this.inkCAnvas.Dispatcher.Invoke(() => { this.inkCAnvas.Strokes.Add(a); }); } else { this.inkCAnvas.Dispatcher.Invoke(() => { if (lastLine >= 0) { this.inkCAnvas.Strokes[indexes[lastLine]].StylusPoints.Add(toAdd); } }); } list.Clear(); return(lastLine); }