// S'il y a au moins 1 trait sur la surface, il est possible d'exécuter Empiler.
 public bool PeutEmpiler(object o)
 {
     if (!isStackUpToDate)
     {
         isStackUpToDate = true;
         return(false);
     }
     else if (traits.Count > 0)
     {
         bool isFound = false;
         foreach (CustomStroke stroke in traits)
         {
             if (DrawingService.localAddedStrokes.Contains(stroke.guid.ToString()))
             {
                 strokeEmpilable = stroke;
                 isFound         = true;
             }
         }
         return(isFound && !new List <string>(DrawingService.remoteSelectedStrokes).Contains(strokeEmpilable.guid.ToString()));
     }
     else
     {
         return(false);
     }
 }
        private bool isInTraits(CustomStroke selectedStroke)
        {
            foreach (CustomStroke stroke in traits)
            {
                if (stroke.guid == selectedStroke.guid)
                {
                    return(true);
                }
            }

            return(false);
        }
        public CustomStroke Duplicate()
        {
            this.strokes.get(this.Id.ToString()).stopEditing();
            this.strokes.get(this.Id.ToString()).Unselect();
            CustomStroke duplicate = (CustomStroke)this.Clone();

            duplicate.RefreshGuids();
            for (int i = 0; i < duplicate.StylusPoints.Count; i++)
            {
                duplicate.StylusPoints[i] = new StylusPoint(duplicate.StylusPoints[i].X - 10, duplicate.StylusPoints[i].Y - 10);
            }
            return(duplicate);
        }
        internal CustomStroke AddStrokeFromView(CustomStroke selectedStroke /*StylusPoint firstPoint, StrokeTypes strokeType*/)
        {
            // Deja fait par le binding
            //traits.Add(selectedStroke);

            StrokeAdded(selectedStroke);

            StrokeCollection selectedStrokes = new StrokeCollection {
                selectedStroke
            };

            OutilSelectionne = "lasso";

            return(selectedStroke);
        }
        // On retire le trait du dessus de la pile de traits retirés et on le place sur la surface de dessin.
        public void Depiler(object o)
        {
            try
            {
                isStackUpToDate = false;
                CustomStroke trait = (CustomStroke)traitsRetires.Last();

                if (trait.isLinkStroke())
                {
                    LinkStroke linkStroke = trait as LinkStroke;

                    linkStroke.from.SetDefaults();
                    linkStroke.to.SetDefaults();
                }
                else
                {
                    ShapeStroke shapeStroke = trait as ShapeStroke;
                    shapeStroke.linksTo   = new List <string> {
                    };
                    shapeStroke.linksFrom = new List <string> {
                    };
                }

                traits.Add(trait);
                if (trait.isLinkStroke())
                {
                    DrawingService.CreateLink(trait as LinkStroke);
                }
                else
                {
                    DrawingService.CreateShape(trait as ShapeStroke);
                }
                traitsRetires.Remove(trait);
            }
            catch { }
        }
 private void StrokeAdded(CustomStroke stroke)
 {
     AddStrokeFromModel?.Invoke(this, stroke);
 }