Esempio n. 1
0
        public async void OnSelectionChanged(InkCanvasSelectionChangingEventArgs args)
        {
            if (IsSelectionDifferent(args.GetSelectedStrokes()))
            {
                // We make the previously selected strokes unselected
                var strokesToUpdate = new Dictionary <string, string>();
                DrawingModel?.SelectedStrokes?.Where(x => x.Value == UserId).ForEach(x => strokesToUpdate[x.Key] = null);

                // We make the currently selected strokes selected
                var selectedStrokes = new List <StrokeModel>();
                foreach (var s in args.GetSelectedStrokes())
                {
                    var stroke = s as StrokeModel;
                    if (stroke == null || IsSelectedByOtherUser(stroke))
                    {
                        continue;
                    }
                    selectedStrokes.Add(stroke as StrokeModel);
                }

                SelectedStrokesIds = new HashSet <string>(selectedStrokes.Select(x => x.Id));
                SelectedStrokesIds.ForEach(x => strokesToUpdate[x] = UserId);

                SelectionChanged?.Invoke(SelectedStrokes);
                args.SetSelectedStrokes(new StrokeCollection(SelectedStrokes));

                if (!IsOffline)
                {
                    await DatabaseService.Ref(DatabasePaths.Drawings)
                    .Child(Id)
                    .Child(DatabasePaths.SelectedStrokes)
                    .Update(strokesToUpdate);
                }
            }
        }
Esempio n. 2
0
 private void surfaceDessin_SelectionChanging(object sender, InkCanvasSelectionChangingEventArgs e)
 {
     if (!this.surfaceDessin.AllowSelection) //if the change is from the view
     {
         (DataContext as VueModele).HandleSelection(e.GetSelectedStrokes());
         e.Cancel = true;
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Prevent user from selecting eraser strokes
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void selectionChanging(object sender, InkCanvasSelectionChangingEventArgs e)
        {
            StrokeCollection selectedStrokes         = e.GetSelectedStrokes();
            StrokeCollection actuallySelectedStrokes = new StrokeCollection();

            foreach (Stroke stroke in selectedStrokes)
            {
                if (stroke.DrawingAttributes.Color != Color.FromRgb(255, 255, 255))
                {
                    actuallySelectedStrokes.Add(stroke);
                }
            }
            e.SetSelectedStrokes(actuallySelectedStrokes);
        }
Esempio n. 4
0
        //</Snippet15>

        // <Snippet14>
        void inkCanvas1_SelectionChanging(object sender, InkCanvasSelectionChangingEventArgs e)
        {
            StrokeCollection selectedStrokes = e.GetSelectedStrokes();

            foreach (Stroke aStroke in inkCanvas1.Strokes)
            {
                if (selectedStrokes.Contains(aStroke))
                {
                    aStroke.DrawingAttributes.Color = Colors.RoyalBlue;
                }
                else
                {
                    aStroke.DrawingAttributes.Color = inkCanvas1.DefaultDrawingAttributes.Color;
                }
            }
        }
Esempio n. 5
0
        /// <summary>当套索选择笔画时,会自动调用此方法</summary>
        protected override void OnSelectionChanging(InkCanvasSelectionChangingEventArgs e)
        {
            StrokeCollection selection = e.GetSelectedStrokes();

            foreach (Stroke v in Strokes)
            {
                if (selection.Contains(v) == true)
                {
                    v.DrawingAttributes.Color = Colors.RoyalBlue;
                }
                else
                {
                    v.DrawingAttributes.Color = fillColor;
                }
            }
            base.OnSelectionChanging(e);
        }
Esempio n. 6
0
        protected override void OnSelectionChanging(InkCanvasSelectionChangingEventArgs e)
        {
            bool selBak = Keyboard.Modifiers == ModifierKeys.Control;
            ReadOnlyCollection <UIElement> col = e.GetSelectedElements();
            List <UIElement> rez = new List <UIElement>();

            foreach (UIElement el in col)
            {
                if (selBak && el == bkg)
                {
                    rez.Add(el);
                }
                else if (!selBak && el != bkg)
                {
                    rez.Add(el);
                }
            }
            e.SetSelectedElements(rez);
        }
Esempio n. 7
0
        /// <summary>
        /// OnSelectionChanging raised when selection is changing on the InkAnalysisCanvas
        /// we use this to select entire nodes instead of just a stroke
        /// </summary>
        protected override void OnSelectionChanging(InkCanvasSelectionChangingEventArgs e)
        {
            StrokeCollection currentSelectedStrokes = e.GetSelectedStrokes();

            if (currentSelectedStrokes.Count > 0)
            {
                ContextNodeCollection nodes =
                    _inkAnalyzer.FindInkLeafNodes(e.GetSelectedStrokes());

                if (nodes.Count > 0)
                {
                    StrokeCollection expandedSelection = new StrokeCollection();
                    //add all related strokes if they aren't part of selectedStrokes already
                    foreach (ContextNode node in nodes)
                    {
                        expandedSelection.Add(node.Strokes);
                    }
                    //modify the collection
                    e.SetSelectedStrokes(expandedSelection);
                }
            }

            base.OnSelectionChanging(e);
        }
Esempio n. 8
0
 private void SelectionChanging(object sender, InkCanvasSelectionChangingEventArgs e)
 {
     Trace.WriteLine("InkCanvas selection changing.");
 }
Esempio n. 9
0
 protected override void OnSelectionChanging(InkCanvasSelectionChangingEventArgs e)
 {
     Console.WriteLine("OnSelectionChanging");
     base.OnSelectionChanging(e);
 }
Esempio n. 10
0
 protected override void OnSelectionChanging(InkCanvasSelectionChangingEventArgs e)
 {
     base.OnSelectionChanging(e);
 }
Esempio n. 11
0
 private void InkCanvas_SelectionChanging(object sender, InkCanvasSelectionChangingEventArgs e)
 {
 }
Esempio n. 12
0
 private void InkCanvas_SelectionChanging(object sender, InkCanvasSelectionChangingEventArgs e)
 {
     textBox.Text += "InkCanvas_SelectionChanging\n";
 }