UWP DEMONSTRATIONS
UWP application: http://uwpapplication.com/
UWP DEMONSTRATIONS
UWP DRAWING LINE TEXT CIRCLE
private void Root_PointerPressed(object sender, PointerRoutedEventArgs e)
{
if (line1)
{
key = 1;
lX1 = e.GetCurrentPoint(root).Position.X;
lY1 = e.GetCurrentPoint(root).Position.Y;
line1 = false;
bar1 = false;
circle1 = false;
}
if (bar1)
{
key = 2;
rX1 = e.GetCurrentPoint(root).Position.X;
rY1 = e.GetCurrentPoint(root).Position.Y;
line1 = false;
bar1 = false;
circle1 = false;
}
if (circle1)
{
point = new Point();
ellipse = new Ellipse();
ellipse.Height = 40;
ellipse.Width = 40;
Canvas.SetLeft(ellipse, (int)e.GetCurrentPoint(root).Position.X);
Canvas.SetTop(ellipse, (int)e.GetCurrentPoint(root).Position.X);
ellipse.StrokeThickness = 2;
ellipse.Stroke = new SolidColorBrush(Windows.UI.Colors.Green);
point.X = e.GetCurrentPoint(root).Position.X;
point.Y = e.GetCurrentPoint(root).Position.Y;
// ellipse.RenderTransform.GetValue(new Point(point.X, point.Y);
TranslateTransform translateTransform = new TranslateTransform();
translateTransform.X = point.X-860 ;
translateTransform.Y = point.Y-550 ;
transformGroup = new TransformGroup();
transformGroup.Children.Add(translateTransform);
ellipse.RenderTransform = transformGroup;
root.Children.Add(ellipse);
line1 = false;
bar1 = false;
circle1 = false;
text1 = false;
}
if (text1)
{
text = new TextBlock();
new TextBlock();
text.Text = tb1.Text;
text.Foreground = new SolidColorBrush(Windows.UI.Colors.Green);
point.X = e.GetCurrentPoint(root).Position.X;
point.Y = e.GetCurrentPoint(root).Position.Y - 10;
TranslateTransform translateTransform = new TranslateTransform();
translateTransform.X = point.X;
translateTransform.Y = point.Y;
transformGroup = new TransformGroup();
transformGroup.Children.Add(translateTransform);
text.RenderTransform = transformGroup;
root.Children.Add(text);
}
}
private void Root_PointerMoved(object sender, PointerRoutedEventArgs e)
{
if (key == 1)
{
root.Children.Remove(line);
line = new Line();
line.Stroke = new SolidColorBrush(Windows.UI.Colors.RoyalBlue);
line.StrokeThickness = 2;
line.X1 = lX1;
line.Y1 = lY1;
line.X2 = e.GetCurrentPoint(root).Position.X;
line.Y2 = e.GetCurrentPoint(root).Position.Y;
root.Children.Add(line);
}
if (key == 2)
{
root.Children.Remove(line0);
line0 = new Line();
line0.Stroke = new SolidColorBrush(Windows.UI.Colors.Green);
line0.StrokeThickness = 8;
line0.X1 = rX1;
line0.Y1 = rY1;
line0.X2 = e.GetCurrentPoint(root).Position.X;
line0.Y2 = e.GetCurrentPoint(root).Position.Y;
root.Children.Add(line0);
}
}
private void Root_PointerReleased(object sender, PointerRoutedEventArgs e)
{
if (key == 1)
{
key = 0;
line = new Line();
line.Stroke = new SolidColorBrush(Windows.UI.Colors.RoyalBlue);
line.StrokeThickness = 2;
line.X1 = lX1;
line.Y1 = lY1;
line.X2 = e.GetCurrentPoint(root).Position.X;
line.Y2 = e.GetCurrentPoint(root).Position.Y;
root.Children.Add(line);
}
if (key == 2)
{
key = 0;
line0 = new Line();
line0.Stroke = new SolidColorBrush(Windows.UI.Colors.Green);
line0.StrokeThickness = 8;
line0.X1 = rX1;
line0.Y1 = rY1;
line0.X2 = e.GetCurrentPoint(root).Position.X;
line0.Y2 = e.GetCurrentPoint(root).Position.Y;
root.Children.Add(line0);
}
}
private void Text_Click(object sender, RoutedEventArgs e)
{
text1 = true;
line1 = false;
bar1 = false;
circle1 = false;
}
private void Line_Click(object sender, RoutedEventArgs e)
{
line1 = true;
bar1 = false;
circle1 = false;
text1 = false;
}
private void Bus_Click(object sender, RoutedEventArgs e)
{
bar1 = true;
line1 = false;
circle1 = false;
text1 = false;
}
private void Circle_Click(object sender, RoutedEventArgs e)
{
circle1 = true;
line1 = false;
bar1 = false;
text1 = false;
}

Comments
Post a Comment