C# Class PhotoSharingApp.Universal.Controls.CropControl

A crop control that allows the user to crop images to a 1:1 ratio before uploading.
Inheritance: Windows.UI.Xaml.Controls.Control, ICropControl, INotifyPropertyChanged
Mostrar archivo Open project: Microsoft/Appsample-Photosharing

Private Properties

Property Type Description
AddCornerEvents void
Corner_PointerMoved void
Corner_PointerPressed void
Corner_PointerReleased void
RemoveCornerEvents void
SelectRegion_ManipulationCompleted void
SelectRegion_ManipulationDelta void
UpdatePreviewImage void
selectedRegion_PropertyChanged void
sourceImage_SizeChanged void

Public Methods

Method Description
CropControl ( ) : System

Initializes a new instance of the CropControl class.

Dispose ( ) : void

Releases resources and unregisters from event handlers.

GetCroppedImage ( ) : Task

Creates the non-scaled cropped image.

LoadImage ( IRandomAccessStream fileStream ) : System.Threading.Tasks.Task

Loads the image.

Protected Methods

Method Description
OnApplyTemplate ( ) : void

Template to manage crop selection of image.

Private Methods

Method Description
AddCornerEvents ( Control corner ) : void

Adds pointer events to the given control.

Corner_PointerMoved ( object sender, PointerRoutedEventArgs e ) : void

If a pointer which is captured by the corner moves,the select region will be updated.

Corner_PointerPressed ( object sender, PointerRoutedEventArgs e ) : void

If a pointer presses in the corner, it means that the user starts to move the corner. 1. Capture the pointer, so that the UIElement can get the Pointer events (PointerMoved, PointerReleased...) even the pointer is outside of the UIElement. 2. Record the start position of the move.

Corner_PointerReleased ( object sender, PointerRoutedEventArgs e ) : void

The pressed pointer is released, which means that the move is ended. 1. Release the Pointer. 2. Clear the position history of the Pointer.

RemoveCornerEvents ( Control corner ) : void

Remove pointer events for the corner.

SelectRegion_ManipulationCompleted ( object sender, ManipulationCompletedRoutedEventArgs e ) : void

The manipulation is completed, and then update the preview image

SelectRegion_ManipulationDelta ( object sender, ManipulationDeltaRoutedEventArgs e ) : void

The user manipulates the selectRegion. The manipulation includes 1. Translate 2. Scale

UpdatePreviewImage ( ) : void

Updates the preview image.

selectedRegion_PropertyChanged ( object sender, PropertyChangedEventArgs e ) : void

Show the select region information.

sourceImage_SizeChanged ( object sender, SizeChangedEventArgs e ) : void

This event will be fired when 1. An new image is opened. 2. The source of the sourceImage is set to null. 3. The view state of this application is changed.

Method Details

CropControl() public method

Initializes a new instance of the CropControl class.
public CropControl ( ) : System
return System

Dispose() public method

Releases resources and unregisters from event handlers.
public Dispose ( ) : void
return void

GetCroppedImage() public method

Creates the non-scaled cropped image.
public GetCroppedImage ( ) : Task
return Task

LoadImage() public method

Loads the image.
The file stream must not be null
public LoadImage ( IRandomAccessStream fileStream ) : System.Threading.Tasks.Task
fileStream IRandomAccessStream The file stream.
return System.Threading.Tasks.Task

OnApplyTemplate() protected method

Template to manage crop selection of image.
protected OnApplyTemplate ( ) : void
return void