/// <summary> /// When we move the stylus, we change our selection box /// </summary> /// <param name="sender"></param> Ignored :( /// <param name="e"></param> MouseEventArgs, contains mouse location private void InkCanvas_StylusMove(object sender, System.Windows.Input.StylusEventArgs e) { if (!e.Inverted) { ContinueSelection(e.GetPosition(sketchPanel.InkCanvas)); } }
/// <summary> /// When we remove the stylus, we make our selection /// </summary> /// <param name="sender">Ignored :(</param> /// <param name="e">MouseEventArgs, contains mouse location</param> protected override void InkCanvas_StylusUp(object sender, System.Windows.Input.StylusEventArgs e) { if (!e.Inverted) { EndSelection(e.GetPosition(sketchPanel.InkCanvas)); } }
/// <summary> /// When we remove the stylus, we make our selection /// </summary> /// <param name="sender">Ignored :(</param> /// <param name="e">MouseEventArgs, contains mouse location</param> public override void InkCanvas_StylusUp(object sender, System.Windows.Input.StylusEventArgs e) { if (!subscribed || e.Inverted || !makingSelection) { return; } // Update the rectangle one more time BoxSelect_StylusMove(sender, e); // Select the strokes under the box StrokeCollection boxSelection = sketchPanel.InkCanvas.Strokes.HitTest(currentRect, 70); // Look for a stroke directly below us System.Windows.Point point = e.GetPosition(sketchPanel.InkCanvas); Sketch.Substroke substrokeBelow = sketchPanel.InkSketch.Sketch.substrokeAtPoint(point.X, point.Y, SEARCH_RADIUS); if (boxSelection.Count > 0) { selection = boxSelection; } else if (substrokeBelow != null) { Stroke singleStroke = sketchPanel.InkSketch.GetInkStrokeBySubstroke(substrokeBelow); if (selection.Contains(singleStroke)) { if (debug) { System.Console.WriteLine("Stroke being removed"); } selection.Remove(singleStroke); } else { if (debug) { System.Console.WriteLine("Stroke being added"); } selection.Add(singleStroke); } } else if (substrokeBelow == null && boxSelection.Count == 0) { selection.Clear(); } Selection = selection; selectBox.Visibility = System.Windows.Visibility.Hidden; sketchPanel.InkCanvas.Children.Remove(selectBox); if (makingSelection) { selectionMade = selection.Count > 0; } makingSelection = false; }
/// <summary> /// Show ghost gate when you hover near a shape /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void sketchPanel_StylusInAirMove(object sender, System.Windows.Input.StylusEventArgs e) { RemoveGate(hoverGate); System.Windows.Point point = e.GetPosition(sketchPanel.InkCanvas); Shape shape = sketchPanel.Sketch.shapeAtPoint(point.X, point.Y, 50); if (shape != null) { DrawFeedback(shape, true); } }
/// <summary> /// Updates the cursor inside the selection box to display whether stylus down will move the strokes /// or remove a stroke /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void InkCanvas_StylusInAirMove(object sender, System.Windows.Input.StylusEventArgs e) { // If there are no strokes below us, use the automatic cursors. // Otherwise, use the pen cursor. System.Windows.Point point = e.GetPosition(sketchPanel.InkCanvas); Sketch.Substroke substrokeBelow = sketchPanel.InkSketch.Sketch.substrokeAtPoint(point.X, point.Y, SEARCH_RADIUS); if (substrokeBelow != null) { sketchPanel.UseCustomCursor = true; sketchPanel.Cursor = System.Windows.Input.Cursors.Pen; } }
private void imageColorPicker_StylusMove(object sender, System.Windows.Input.StylusEventArgs e) { if (dc_present) { Point s = e.GetPosition(this); Point p = PointToScreen(s); SelectedColor = GetPixelPointColor(p); SelectedPosition = s; RoutedEventArgs re = new RoutedEventArgs(SelectedColorChangedEvent); RaiseEvent(re); } }
/// <summary> /// Invokes Mesh Highlighting depending on mouse position. /// /// Main function for invoking this feedback mechanism. /// </summary> private void InkCanvas_StylusMove(object sender, System.Windows.Input.StylusEventArgs e) { if (!highlightingEnabled) { return; // Do not highlight } Shape shapeToHighlight = sketchPanel.Sketch.shapeAtPoint(e.GetPosition(sketchPanel.InkCanvas).X, e.GetPosition(sketchPanel.InkCanvas).Y, 50); if (shapeToHighlight == currentHighlightedShape) { return; } unHighlightStrokes(); highlightShape(shapeToHighlight, true); currentHighlightedShape = shapeToHighlight; }
private void buttonTouchSelection(System.Windows.Input.StylusEventArgs e) { Point pos = e.GetPosition(inkCanvas); moveX = pos.X; moveY = pos.Y; UIElement currentStylusOver = findShape(moveX, moveY); // If we are still in the same element, then don't need to do anything if (currentStylusOver == null) { lastStylusOver = null; firstHover = true; return; } bool ignore = false; if (currentStylusOver.GetType().ToString().Equals("System.Windows.Shapes.Rectangle")) { if (((Rectangle)currentStylusOver).DesiredSize.Width == 4 || ((Rectangle)currentStylusOver).Fill == Brushes.Transparent) { ignore = true; } } if (firstHover == true) { if (ignore) { return; } double left = InkCanvas.GetLeft(currentStylusOver); double width = InkCanvas.GetRight(currentStylusOver) - left; double middle = left + (width / 2); if (left < moveX && moveX < middle) { left_side = true; } else { left_side = false; } firstHover = false; leftCurrent = currentStylusOver; } if (ignore) { return; } // if the stylus has moved to a different shape, then no way we are going to select. // just reset everything and return if (leftCurrent.Equals(currentStylusOver) == false) { firstHover = true; return; } // If we are crossing over a button or an item control, then don't do anything if (currentStylusOver.GetType().ToString().Equals("System.Windows.Controls.ItemsControl")) { return; } if (currentStylusOver.GetType().ToString().Equals("System.Windows.Controls.Button")) { return; } if (buttonTouchSelect && allowSelection) // shouldSelect is for timing issues // allowSelection is for disabling selection while menu is on { if (left_side) { double left = InkCanvas.GetLeft(currentStylusOver); double width = InkCanvas.GetRight(currentStylusOver) - left; double middle = left + (width / 2); if (left < moveX && moveX < middle) { return; } else { left_side = false; } } else { double left = InkCanvas.GetLeft(currentStylusOver); double width = InkCanvas.GetRight(currentStylusOver) - left; double middle = left + (width / 2); if (left < moveX && moveX < middle) { left_side = true; } else { return; } } if (currentSelection.Contains(currentStylusOver)) { currentSelection.Remove(currentStylusOver); } else { currentSelection.Add(currentStylusOver); } lastStylusOver = currentStylusOver; updateSelection(); } }
/// <summary> /// When we move the stylus, we change our selection box /// </summary> /// <param name="sender"></param> Ignored :( /// <param name="e"></param> MouseEventArgs, contains mouse location public void BoxSelect_StylusMove(object sender, System.Windows.Input.StylusEventArgs e) { //if (debug) System.Console.WriteLine("Box stylus move"); if (!makingSelection || !subscribed || e.Inverted) { return; } // Set box attributes System.Windows.Size rectSize = new System.Windows.Size(Math.Abs(start.X - e.GetPosition(sketchPanel.InkCanvas).X), Math.Abs(start.Y - e.GetPosition(sketchPanel.InkCanvas).Y)); System.Windows.Point rectLocation = new System.Windows.Point(Math.Min(start.X, e.GetPosition(sketchPanel.InkCanvas).X), Math.Min(start.Y, e.GetPosition(sketchPanel.InkCanvas).Y)); currentRect = new System.Windows.Rect(rectLocation, rectSize); selectionMade = false; // Update the box on the screen DrawBox(); }
protected virtual void InkCanvas_StylusUp(object sender, System.Windows.Input.StylusEventArgs e) { EndSelection(e.GetPosition(sketchPanel.InkCanvas)); }