本文整理汇总了C#中System.Windows.Media.TranslateTransform类的典型用法代码示例。如果您正苦于以下问题:C# TranslateTransform类的具体用法?C# TranslateTransform怎么用?C# TranslateTransform使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TranslateTransform类属于System.Windows.Media命名空间,在下文中一共展示了TranslateTransform类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MainWindow
public MainWindow()
{
view = new ViewParams();
InitializeComponent();
scale = new ScaleTransform(1, 1, 0, 0);
pan = new TranslateTransform(0, plot.Height);
signals = new SignalCollection(this);
signals.scaleSignalStrokes(scale);
signals.updateLabels();
resetTransform();
ports = SerialPort.GetPortNames();
Console.WriteLine("ports:");
foreach(string port in ports){
comportList.Items.Add(port.ToString());
Console.WriteLine(port);
}
arduinoPort = new SerialPort();
arduinoPort.Parity = Parity.None;
arduinoPort.StopBits = StopBits.One;
arduinoPort.DataBits = 8;
arduinoPort.BaudRate = 9600;
arduinoPort.ReadTimeout = 200;
if (comportList.Items.Count > 0)
{
arduinoPort.PortName = comportList.Items[0].ToString();
}
else
{
Console.WriteLine("No ports available");
connectButton.IsEnabled = false;
}
}
示例2: OnRender
protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
{
TranslateTransform translation = this.RenderTransform as TranslateTransform;
if( translation == null)
{
translation = new TranslateTransform();
this.RenderTransform = translation;
}
double width = this.Width;
double height = this.Height;
if (double.IsNaN(width))
{
width = this.ActualWidth;
}
if (double.IsNaN(height))
{
height = this.ActualHeight;
}
translation.X = -width * 0.5;
translation.Y = -height * 0.5;
base.OnRender(drawingContext);
}
示例3: SetTransform
public void SetTransform()
{
if (pageHolder == null)
return;
TranslateTransform t = new TranslateTransform(pageHolder.HeadersSizeActive.Width + 3, 3);
gr.Transform = t;
}
示例4: CountDownWpf
public CountDownWpf()
{
InitializeComponent();
countdownTimer = new Timer {Interval = 1000};
countdownTimer.Elapsed += countdownTimer_Elapsed;
RenderTransform = new TranslateTransform() {X = 900, Y=300};
}
示例5: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
if (AdornedElement.RenderSize.Width < 20)
return;
TranslateTransform transform = new TranslateTransform
(
AdornedElement.RenderSize.Width - 15,
(AdornedElement.RenderSize.Height - 5) / 2
);
transform = new TranslateTransform
(
AdornedElement.RenderSize.Width / 2 - 3.5,
AdornedElement.RenderSize.Height / 2 - 10
);
drawingContext.PushTransform(transform);
Geometry geometry = ascGeometry;
if (this.Direction == ListSortDirection.Descending)
geometry = descGeometry;
drawingContext.DrawGeometry(Brushes.LightGray, null, geometry);
drawingContext.Pop();
}
示例6: OnMouseMove
protected override void OnMouseMove(MouseEventArgs e)
{
Window wnd = Window.GetWindow(this);
Point currentLocation = e.MouseDevice.GetPosition(wnd);
var move = new TranslateTransform(
currentLocation.X - _previousLocation.X, currentLocation.Y - _previousLocation.Y);
if (e.LeftButton == MouseButtonState.Pressed)
{
var group = new TransformGroup();
if (_previousTransform != null)
{
group.Children.Add(_previousTransform);
}
group.Children.Add(move);
RenderTransform = group;
}
else
{
Cursor = Cursors.Hand;
}
_previousLocation = currentLocation;
_previousTransform = RenderTransform;
MainWindow.Instance.CalculatePositions();
base.OnMouseMove(e);
}
示例7: Wall
public Wall(Canvas container, Point position, double width, double height) {
this.container = container;
this.position = position;
this.width = width;
this.height = height;
this.image = new ImageBrush();
Debug.WriteLine("IMG width: " + imageSource.PixelWidth + ", height: " + imageSource.PixelHeight);
this.image.ImageSource = imageSource;
this.image.Stretch = Stretch.None;
transform = new TranslateTransform();
transform.X = -this.position.X;
transform.Y = -this.position.Y;
st = new ScaleTransform();
st.ScaleX = 1.55;
st.ScaleY = 2;
this.image.RelativeTransform = st;
this.image.Transform = transform;
this.imageContainer = new Canvas();
this.imageContainer.Width = width;
this.imageContainer.Height = height;
this.imageContainer.Background = this.image;
this.container.Children.Add(this.imageContainer);
Canvas.SetLeft(this.imageContainer, this.position.X);
Canvas.SetTop(this.imageContainer, this.position.Y);
Canvas.SetZIndex(this.imageContainer, 2);
}
示例8: PerformTranstition
public override void PerformTranstition(UserControl newPage, UserControl oldPage)
{
this.newPage = newPage;
this.oldPage = oldPage;
Duration duration = new Duration(TimeSpan.FromSeconds(1));
DoubleAnimation animation = new DoubleAnimation();
animation.Duration = duration;
switch (direction)
{
case WipeDirection.LeftToRight:
animation.To = oldPage.ActualWidth;
break;
case WipeDirection.RightToLeft:
animation.To = -oldPage.ActualWidth;
break;
}
Storyboard sb = new Storyboard();
sb.Duration = duration;
sb.Children.Add(animation);
sb.Completed += sb_Completed;
TranslateTransform sc = new TranslateTransform();
oldPage.RenderTransform = sc;
Storyboard.SetTarget(animation, sc);
Storyboard.SetTargetProperty(animation, new PropertyPath("X"));
//oldPage.Resources.Add(sb);
sb.Begin();
}
示例9: LayoutRoot_MouseLeftButtonUp
private void LayoutRoot_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
PointCollection points = new PointCollection();
foreach (Point p in poly.Points)
points.Add(p);
Point newPoint = e.GetPosition(poly);
points.Add(newPoint);
poly.Points = points;
// placeholder
Ellipse ph = new Ellipse
{
Fill = new SolidColorBrush(Colors.Black),
Width = 4D,
Height = 4D
};
TranslateTransform t = new TranslateTransform { X = newPoint.X - 2D, Y = newPoint.Y - 2D };
ph.RenderTransform = t;
cnv.Children.Add(ph);
//
TextBlock tb = new TextBlock
{
Foreground = new SolidColorBrush(Colors.Gray),
FontSize = 8
};
tb.Text = newPoint.ToString();
tb.RenderTransform = t;
cnv.Children.Add(tb);
}
示例10: ImageControls
/// <summary>
/// ImageControls constructor
/// </summary>
/// <param name="uiImage">User's Image</param>
/// <param name="uiImageCanvas">Canvas the image is displayed on</param>
/// <param name="uiProcImage">Processed Image</param>
/// <param name="uiProcImageCanvas">Canvas that the processed image is displayed on</param>
public ImageControls(Image uiImage, Canvas uiImageCanvas, Image uiProcImage, Canvas uiProcImageCanvas)
{
image = uiImage;
imageCanvas = uiImageCanvas;
procImage = uiProcImage;
procImageCanvas = uiProcImageCanvas;
//Create transform group that includes ScaleTransform (zooming) and TranslateTransform (panning)
TransformGroup group = new TransformGroup();
ScaleTransform xform = new ScaleTransform();
group.Children.Add(xform);
TranslateTransform tt = new TranslateTransform();
TranslateTransform ttp = new TranslateTransform();
group.Children.Add(tt);
group.Children.Add(ttp);
//Add transform group to both images. Cant add to canvas because there is no boundry for the canvas, thus the images will expand outside the GUI
image.RenderTransform = group;
image.MouseWheel += image_MouseWheel;
image.MouseLeftButtonDown += image_MouseLeftButtonDown;
image.MouseLeftButtonUp += image_MouseLeftButtonUp;
image.MouseMove += image_MouseMove;
procImage.RenderTransform = group;
procImage.MouseWheel += procImage_MouseWheel;
procImage.MouseLeftButtonDown += procImage_MouseLeftButtonDown;
procImage.MouseLeftButtonUp += procImage_MouseLeftButtonUp;
procImage.MouseMove += procImage_MouseMove;
}
示例11: sp_MouseMove
void sp_MouseMove(object sender, MouseEventArgs e)
{
if (dragging_ && !firstDown_) {
Point currentPosition = e.GetPosition(dragTarget_);
var transform = dragTarget_.RenderTransform as TranslateTransform;
if (transform == null) {
transform = new TranslateTransform();
dragTarget_.RenderTransform = transform;
}
transform.X += currentPosition.X - clickPosition.X;
transform.Y += currentPosition.Y - clickPosition.Y;
clickPosition = e.GetPosition(dragTarget_);
//transform.X = currentPosition.X - clickPosition.X;
//transform.Y = currentPosition.Y - clickPosition.Y;
if (transform.X + dragTarget_.ActualWidth > canvas.MinWidth) {
canvas.MinWidth = canvas.Width = transform.X + dragTarget_.ActualWidth * 2;
canvas.InvalidateMeasure();
scroller.InvalidateMeasure();
scroller.InvalidateScrollInfo();
}
} else if (firstDown_)
firstDown_ = false;
}
示例12: gdValues_MouseMove
void gdValues_MouseMove(object sender, MouseEventArgs e)
{
if (inFocus)
{
TranslateTransform rt = new TranslateTransform();
rt.Y = e.GetPosition(this).Y - 400;
gdValues.RenderTransform = rt;
start = rt.Y;
foreach (var c in gdValues.Children)
{
double lblTop = lblSelectedValue.PointToScreen(new Point(0, 0)).Y;
if ((c as UIElement).PointToScreen(new Point(0, 0)).Y >= lblTop - 20 && (c as UIElement).PointToScreen(new Point(0, 0)).Y <= lblTop + 20)
{
(c as Label).Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF005DFF"));
selectedText = (c as Label).Content.ToString();
(c as Label).BorderBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF005DFF"));
element = (c as UIElement);
}
else
{
(c as Label).BorderBrush = new SolidColorBrush(Colors.White);
(c as Label).Background = new SolidColorBrush(Colors.Transparent);
}
}
}
}
示例13: Bounce
/// <summary>
/// Bounces the specified element.
/// </summary>
/// <param name="element">The element.</param>
/// <param name="direction">The direction.</param>
/// <param name="whenDone">The when done.</param>
public static void Bounce(UIElement element, Direction direction, EventHandler whenDone = null)
{
var translateTransform = new TranslateTransform();
element.RenderTransform = translateTransform;
switch (direction)
{
case Direction.Up:
translateTransform.BeginAnimation(
TranslateTransform.YProperty,
CreateDoubleAnimation(
0,
-15,
0.2,
(o, e) => translateTransform.BeginAnimation(TranslateTransform.YProperty, CreateDoubleAnimationWithEasing(-15, 0, 0.8, new BounceEase { Bounces = 3, EasingMode = EasingMode.EaseOut })),
whenDone));
break;
case Direction.Down:
translateTransform.BeginAnimation(
TranslateTransform.YProperty,
CreateDoubleAnimation(
0,
15,
0.2,
(o, e) => translateTransform.BeginAnimation(TranslateTransform.YProperty, CreateDoubleAnimationWithEasing(15, 0, 0.8, new BounceEase { Bounces = 3, EasingMode = EasingMode.EaseOut })),
whenDone));
break;
}
}
示例14: Manager
//Editor Ed = new Editor(Edit);
public Manager(TabControl tabs, StackPanel Background, StackPanel Edit)
{
// TODO: Complete member initialization
this.tabs = tabs;
this.Background = Background;
this.Edit = Edit;
trSkw = new SkewTransform(0, 0);
trRot = new RotateTransform(0);
trTns = new TranslateTransform(0, 0);
trScl = new ScaleTransform(1, 1);
trSkw2 = new SkewTransform(0, 0);
trRot2 = new RotateTransform(0);
trTns2 = new TranslateTransform(0, 0);
trScl2 = new ScaleTransform(1, 1);
trGrp2 = new TransformGroup();
trGrp2.Children.Add(trSkw2);
trGrp2.Children.Add(trRot2);
trGrp2.Children.Add(trTns2);
trGrp2.Children.Add(trScl2);
trGrp = new TransformGroup();
trGrp.Children.Add(trSkw);
trGrp.Children.Add(trRot);
trGrp.Children.Add(trTns);
trGrp.Children.Add(trScl);
}
示例15: ArrangeOverride
/// <summary>
/// Provides the behavior for the Arrange pass of Silverlight layout. Classes can override this method to define their own Arrange pass behavior.
/// </summary>
/// <param name="finalSize">The final area within the parent that this object should use to arrange itself and its children.</param>
/// <returns>
/// The actual size that is used after the element is arranged in layout.
/// </returns>
protected override Size ArrangeOverride(Size finalSize)
{
if (Symbol is ESRI.ArcGIS.Client.Symbols.MarkerSymbol)
{
UIElement child = GetChild();
Transform childTransform = child == null ? null : child.RenderTransform;
if (childTransform != null)
{
// Arrange the symbol following it's desired size, the final size which is taking care of the transform is not the good one
Size size = child.DesiredSize.Height == 0 && child.DesiredSize.Width == 0 ? finalSize : child.DesiredSize;
child.Arrange(new Rect(new Point(0, 0), size));
// Now we need to translate the symbol in order that the visual part of the symbol be in the snapshot
Rect rect = childTransform.TransformBounds(new Rect(new Point(0, 0), child.DesiredSize)); // visual position of the symbol after transformation
child.RenderTransformOrigin = new Point(0, 0); // for the swatch, the transform origin must be (0,0) whatever the transform origin used in the map
if (rect.X != 0 || rect.Y != 0)
RenderTransform = new TranslateTransform { X = -rect.X, Y = -rect.Y }; // Center the symbol
return finalSize;
}
}
return base.ArrangeOverride(finalSize);
}