|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace DiagramDesigner
{
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private void OnClickNew(object sender, RoutedEventArgs args)
{
MyDesignerCanvas.Children.Clear();
}
private void OnClickRotateLeft(object sender, RoutedEventArgs args)
{
Rotate(-90);
}
private void OnClickRotateRight(object sender, RoutedEventArgs args)
{
Rotate(90);
}
// sort of a hack, only values of 90 (right) or -90 (left) make sense
// for demo purposes only
private void Rotate(double angle)
{
foreach (DesignerItem item in MyDesignerCanvas.SelectedItems)
{
FrameworkElement element = item.Content as FrameworkElement;
if (element != null)
{
RotateTransform rotateTransform = element.LayoutTransform as RotateTransform;
if (rotateTransform == null)
{
rotateTransform = new RotateTransform();
element.LayoutTransform = rotateTransform;
}
rotateTransform.Angle = (rotateTransform.Angle + angle) % 360;
Canvas.SetLeft(item, Canvas.GetLeft(item) - (item.Height - item.Width) / 2);
Canvas.SetTop(item, Canvas.GetTop(item) - (item.Width - item.Height) / 2);
double width = item.Width;
item.Width = item.Height;
item.Height = width;
}
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.