예제 #1
0
    private void inkoverlay_SelectionChanging(object sender, InkOverlaySelectionChangingEventArgs e)
    {
        dbg.WriteLine("----- inkoverlay_SelectionChanging -----");

        // Ensure we're on the UI thread.
        dbg.Assert(!this.InvokeRequired);

        try         // To prevent exceptions from propagating back to ink runtime.
        {
            if (e.NewSelection.Count > 0)
            {
                // Get objects for selected stroke(s); remove mechanisms from bucket.
                MechanismBase[] mechs = doc.GetMechanismsFor(e.NewSelection);
                foreach (MechanismBase mech in mechs)
                {
                    Stroke mechstroke = GetStrokeById(mech.strokeid);
                    e.NewSelection.Remove(mechstroke);
                }

                // Don't allow gravity to be selected, either.
                if (doc.Gravity != null)
                {
                    Stroke gravstroke = GetStrokeById(doc.Gravity.strokeid);
                    e.NewSelection.Remove(gravstroke);
                }
            }
        }
        catch (Exception ex)
        {
            // Log the error.
            Global.HandleThreadException(this, new System.Threading.ThreadExceptionEventArgs(ex));
        }
    }
예제 #2
0
        private void sketchInk_SelectionChanging(object sender, InkOverlaySelectionChangingEventArgs e)
        {
            // Don't do anything if we were moving or resizing the selection
            if (this.mouseDown || this.selectionMoving || this.selectionResizing)
            {
                lTool.UnThickenLabel(this.inkPic.Selection);
                return;
            }

            // If we've clicked outside our selection or not close enough to a stroke
            else if (e.NewSelection.Count == 0)
            {
                lTool.UnThickenLabel(this.inkPic.Selection);

                this.strokesClicked.Clear();
            }

            // If we've clicked on a stroke or group of closely connected strokes
            else if (this.clicked)
            {
                lTool.UnThickenLabel(this.inkPic.Selection);

                foreach (Microsoft.Ink.Stroke s in this.strokesClicked)
                {
                    if (!e.NewSelection.Contains(s))
                    {
                        e.NewSelection.Add(s);
                    }
                }

                lTool.ThickenLabel(e.NewSelection);
            }

            // If we've performed a lasso selection
            else
            {
                lTool.UnThickenLabel(this.inkPic.Selection);

                this.strokesClicked.Clear();
                this.strokesClicked.Add(e.NewSelection);

                lTool.ThickenLabel(this.strokesClicked);
            }
        }
예제 #3
0
    private void inkoverlay_SelectionChanging(object sender, InkOverlaySelectionChangingEventArgs e)
    {
        dbg.WriteLine("----- inkoverlay_SelectionChanging -----");

        // Ensure we're on the UI thread.
        dbg.Assert(!this.InvokeRequired);

        try // To prevent exceptions from propagating back to ink runtime.
        {
            if (e.NewSelection.Count > 0)
            {
                // Get objects for selected stroke(s); remove mechanisms from bucket.
                MechanismBase[] mechs = doc.GetMechanismsFor(e.NewSelection);
                foreach (MechanismBase mech in mechs)
                {
                    Stroke mechstroke = GetStrokeById(mech.strokeid);
                    e.NewSelection.Remove(mechstroke);
                }

                // Don't allow gravity to be selected, either.
                if (doc.Gravity != null)
                {
                        if(doc.Ink.Strokes.Count > 0)
                        {
                            foreach (Stroke S in doc.Ink.Strokes)
                            {
                                if (S.Id == doc.Gravity.strokeid)
                                {
                                    e.NewSelection.Remove(S);
                                    return;
                                }
                            }
                        }

                    // Stroke gravstroke = GetStrokeById(doc.Gravity.strokeid);
                    // e.NewSelection.Remove(gravstroke);
                }
            }
        }
        catch (Exception ex)
        {
            // Log the error.
            Global.HandleThreadException(this, new System.Threading.ThreadExceptionEventArgs(ex));
        }
    }