private void FreeDrawingMode(bool doEnter) { if (doEnter) { _ink.IsHitTestVisible = true; _inkPalette.Visibility = Visibility.Visible; _palette.Visibility = Visibility.Hidden; //set drawing attributes of current palette owner var da = _ink.DefaultDrawingAttributes.Clone(); da.Width = 4; da.Height = 4; _inkPalette.OnDrawingStarted(); da.Color = DaoUtils.UserIdToColor(_palette.GetOwnerId()); _ink.DefaultDrawingAttributes = da; } else { _ink.IsHitTestVisible = false; _inkPalette.Visibility = Visibility.Hidden; _palette.Visibility = Visibility.Visible; _modeMgr.Mode = ShapeInputMode.ManipulationExpected; //create free form shape if we have locally created strokes var ownColor = DaoUtils.UserIdToColor(_palette.GetOwnerId()); //while we have been drawing, somebody else could draw and still hasn't finalized drawing, so ink canvas can contain //strokes from multiple authors var ownStrokes = _ink.Strokes.Where(st => st.DrawingAttributes.Color == ownColor); if (ownStrokes.Count() > 0) { //don't take cursor for free draw var freeFrmSh = (VdFreeForm)_doc.BeginCreateShape(VdShapeType.FreeForm, 0, 0, false, DocTools.TAG_UNDEFINED); freeFrmSh.locallyJustCreated = true; //enable one-time stroke send var ownStrokeCollection = new StrokeCollection(ownStrokes); freeFrmSh.extractGeomtry(ownStrokeCollection, ownStrokeCollection.GetBounds()); //but set focus _doc.VolatileCtx.UnfocusAll(); freeFrmSh.SetFocus(); //send state update to other clients SendSyncState(freeFrmSh); //remove own strokes var notOwnStrokes = _ink.Strokes.Where(st => st.DrawingAttributes.Color != ownColor); _ink.Strokes = new StrokeCollection(notOwnStrokes); TryEndHostCaption(freeFrmSh, CaptionType.FreeDraw); } //update ink on other clients sendLocalInk(); } }