Click here to Skip to main content
15,911,786 members

Comments by kamaraj sp (Top 2 by date)

kamaraj sp 30-Apr-12 2:43am View    
public sealed partial class BlankPage : Page
{
private TransformGroup _transformGroup;
private TranslateTransform _translate;
private ScaleTransform _scale;
private RotateTransform _rotate;
private bool forceManipulationsToEnd;


public BlankPage()
{
this.InitializeComponent();

forceManipulationsToEnd = false;
Img1.ManipulationStarting += new ManipulationStartingEventHandler(Img1_ManipulationStarting);
Img1.ManipulationStarted += new ManipulationStartedEventHandler(Img1_ManipulationStarted);
Img1.ManipulationDelta += new ManipulationDeltaEventHandler(Img1_ManipulationDelta);
Img1.ManipulationCompleted += new ManipulationCompletedEventHandler(Img1_ManipulationCompleted);
InitManipulationTransforms();
}

///
/// Invoked when this page is about to be displayed in a Frame.
///

/// <param name="e">Event data that describes how this page was reached. The Parameter
/// property is typically used to configure the page.</param>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
}

private void InitManipulationTransforms()
{
_translate = new TranslateTransform()
{
X = 0,
Y = 0
};

_scale = new ScaleTransform()
{
ScaleX = 1,
ScaleY = 1,
CenterX = Img1.ActualWidth / 2,
CenterY = Img1.ActualHeight / 2
};

_rotate = new RotateTransform()
{
Angle = 0,
CenterX = Img1.ActualWidth / 2,
CenterY = Img1.ActualHeight / 2
};

_transformGroup = new TransformGroup();
((IList<Transform>)_transformGroup.Children).Add(_rotate);
((IList<Transform>)_transformGroup.Children).Add(_scale);
((IList<Transform>)_transformGroup.Children).Add(_translate);

Img1.RenderTransform = _transformGroup;
}

void Img1_ManipulationStarting(object sender, ManipulationStartingRoutedEventArgs e)
{
forceManipulationsToEnd = false;
e.Handled = true;
}

void Img1_ManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
{
e.Handled = true;
}

void Img1_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
{

if (forceManipulationsToEnd)
{
e.Complete();
return;
}

_rotate.Angle += (e.Delta.Rotation * 180 / Math.PI);
_scale.ScaleX = _scale.ScaleY *= e.Delta.Scale;
_scale.CenterX = Img1.ActualWidth / 2;
_scale.CenterY = Img1.ActualHeight / 2;
_translate.X += e.Delta.Translation.X;
_translate.Y += e.Delta.Translation.Y;

e.Handled = true;

}

void Img1_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
{
e.Handled = true;
}

async private void BtnLoad_Click(object sender, RoutedEventArgs e)
{

FileOpenPicker imagePicker = new FileOpenPicker
{
ViewMode = PickerViewMode.Thumbnail,
SuggestedStartLocation = PickerLocationId.PicturesLibrary,
FileTypeFilter = { ".jpg", ".png", ".bmp", ".gif", ".tif" }
};

StorageFile imageFile = await imagePicker.PickSingleFileAsync();

if (imageFile != null)
{
//this.scenarioId = ScenarioId.Image;
IRandomAccessStream displayStream = await imageFile.OpenAsync(FileA
kamaraj sp 24-Apr-12 5:08am View    
If I zoom out the image more, the image is not visible its looking like a dot and I couldn't zoom again. If I drag the image to corner of the screen, the image is going out of screen.