Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C# by Maulik Shah ( 12 years ago )
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.Windows.Media.Imaging;
using System.Windows.Media;
using System.Windows.Input;
using System.Diagnostics;
using System.Windows.Shapes;
namespace TestApp
{
public partial class TestPage : PhoneApplicationPage
{
int trX = 0;
int trY = 0;
TextBlock croppingRectangle;
public TestPage()
{
InitializeComponent();
init();
}
public void init()
{
TextBlock rect = new TextBlock();
rect.Text = "Hello......Hello......";
rect.Height = 94; //fixed
rect.MaxHeight = image1.Height;
rect.MaxWidth = image1.Width;
rect.Width = 300; //fixed
rect.TextWrapping = TextWrapping.Wrap;
rect.Foreground = new SolidColorBrush(Colors.Black);
rect.F
rect.F
rect.Margin = image1.Margin;
rect.ManipulationDelta += new EventHandler<ManipulationDeltaEventArgs>(rect_ManipulationDelta);
LayoutRoot.Children.Add(rect);
LayoutRoot.Height = image1.Height;
LayoutRoot.Width = image1.Width;
}
private void rect_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
{
GeneralTransform gt = ((TextBlock)sender).TransformToVisual(LayoutRoot);
Point p = gt.Transform(new Point(0, 0));
int intermediateValueY = (int)((LayoutRoot.Height - ((TextBlock)sender).Height));
int intermediateValueX = (int)((LayoutRoot.Width - ((TextBlock)sender).Width));
croppingRectangle = (TextBlock)sender;
TranslateTransform tr = new TranslateTransform();
trX += (int)e.DeltaManipulation.Translation.X;
trY += (int)e.DeltaManipulation.Translation.Y;
if (trY < (-intermediateValueY / 2))
{
trY = (-intermediateValueY / 2);
}
else if (trY > (intermediateValueY / 2))
{
trY = (intermediateValueY / 2);
}
if (trX < (-intermediateValueX / 2))
{
trX = (-intermediateValueX / 2);
}
else if (trX > (intermediateValueX / 2))
{
trX = (intermediateValueX / 2);
}
tr.X = trX;
tr.Y = trY;
croppingRectangle.RenderTransform = tr;
}
}
}
Revise this Paste