Exemplo n.º 1
0
        private void AddLine(StrokeCollection[] strokeCollectionArray)
        {
#if DEBUG
            if (this.lastDrawingAttributes.Color == Colors.Transparent)
            {
                throw new Exception("Color should not be Transparent");
            }
#endif
            foreach (StrokeCollection strokeCollection in strokeCollectionArray)
            {
                foreach (var stroke in strokeCollection)
                {
                    bool strokeIsMend = stroke.GetIsMend();
                    if (strokeIsMend == false)
                    {
                        stroke.SetIsMend(true);
                        ShapeStroke line = GetAdjustShapeStroke.Get(stroke.StylusPoints, "Other", this.lastDrawingAttributes);
                        if (line != null)
                        {
                            //line:
                            string strokeId = stroke.GetMendID();
                            line.SetMendID(strokeId);

                            this.inkCanvas.Strokes.Remove(stroke);
                            this.SetMendedStrokeAttribute(line);
                            this.drawingHost.Add(line);
                            //sync
                            List <string> originalStrokeIDs = new List <string> {
                                stroke.GetID()
                            };
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void MendStroke(string shapeKey, StrokeCollection[] strokeCollectionArray, DrawingAttributes defaultDrawingAttributes, StylusPointCollection targetCollection)
        {
            if (targetCollection.Count > 0)
            {
                List <string> originalStrokeIDs = new List <string>();
                ShapeStroke   combineStroke     = GetAdjustShapeStroke.Get(targetCollection, shapeKey, defaultDrawingAttributes);
                if (combineStroke != null)
                {
                    foreach (StrokeCollection strokeCollection in strokeCollectionArray)
                    {
                        foreach (var stroke in strokeCollection)
                        {
                            string id = stroke.GetMendID();
                            if (string.IsNullOrEmpty(id) == false)
                            {
                                Stroke inkStroke = this.inkCanvas.Strokes.FirstOrDefault(item => item.GetMendID() == id);
                                Debug.Assert(inkStroke != null, "inkStroke should not be null in MendStroke method");
                                if (inkStroke != null)
                                {
                                    this.inkCanvas.Strokes.Remove(inkStroke);
                                    originalStrokeIDs.Add(inkStroke.GetID());
                                }
                            }
                        }
                        this.RemoveStrokes(strokeCollection);
                    }
                    this.SetMendedStrokeAttribute(combineStroke);

                    Log.Instance().Info("Whiteboard", "drawing shape is " + shapeKey);
                    //if we add the stroke to the inkcanvas, the incanvas will add some point automatic,so we need send the data before add it to local
                    this.drawingHost.Add(combineStroke);
                }
                else
                {
                    Trace("Can not mend the stroke");
                    foreach (StrokeCollection strokeCollection in strokeCollectionArray)
                    {
                        this.RemoveStrokes(strokeCollection);
                    }
                }
            }
        }