Export (0) Print
Expand All

InkCanvas.SelectionResizing Event

Occurs at the onset of the selected strokes and elements being resized.

Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public event InkCanvasSelectionEditingEventHandler SelectionResizing
/** @event */
public void add_SelectionResizing (InkCanvasSelectionEditingEventHandler value)

/** @event */
public void remove_SelectionResizing (InkCanvasSelectionEditingEventHandler value)

In JScript, you can handle the events defined by a class, but you cannot define your own.
<object SelectionResizing="InkCanvasSelectionEditingEventHandler" .../>

This event occurs after the user requests a selection of strokes and/or elements to be resized and before the change is applied.

The event handler receives an argument of type InkCanvasSelectionEditingEventArgs that contains two properties, OldRectangle and NewRectangle, which respectively contain the rectangle that defines the boundaries of the selection before the resizing operation and the rectangle that defines the boundaries of the selection after the resizing operation.

After the strokes and/or elements have been updated with the new size, the SelectionResized event will occur.

The following example prevents the user from making a selection smaller than its original size.

Rect selectionBounds;

// Don't allow the user to make the selection smaller than its original size.
void inkCanvas1_SelectionResizing(object sender, InkCanvasSelectionEditingEventArgs e)
{
    if (selectionBounds == null || selectionBounds.IsEmpty)
    {
        return;
    }

    double resizeHeight;
    double resizeWidth;

    // If the user made the height of the selection smaller, 
    // use the selection's original height.
    if (e.NewRectangle.Height < selectionBounds.Height)
    {
        resizeHeight = selectionBounds.Height;
    }
    else
    {
        resizeHeight = e.NewRectangle.Height;
    }

    // If the user made the width of the selection smaller, 
    // use the selection's original width.
    if (e.NewRectangle.Width < selectionBounds.Width)
    {
        resizeWidth = selectionBounds.Width;
    }
    else
    {
        resizeWidth = e.NewRectangle.Width;
    }

    // Create a the new rectangle with the appropriate width and height.
    e.NewRectangle = new Rect(e.NewRectangle.X, e.NewRectangle.Y, resizeWidth, resizeHeight);
}

// Keep track of the selection bounds.
void inkCanvas1_SelectionChanged(object sender, EventArgs e)
{
    selectionBounds = inkCanvas1.GetSelectionBounds();
}

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft