本文介绍了我如何能够和他人一起缩小图像并移动所有图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在画布上显示图像,我想要移动所有图像。目前我能够移动我带上画布的最后一张图片。而且我也希望我能放大这些图像。所以请帮助我。



我尝试了什么:



I display the images on canvas and I want that i move all the images. Currently I am able to move the last image which i brought on canvas. And I also want that i zoom these images.so please help me in this.

What I have tried:

private TranslateTransform dragTranslation;

       // Constructor


       void Drag_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
       {
           // Move the rectangle.
           dragTranslation.X += e.Delta.Translation.X;
           dragTranslation.Y += e.Delta.Translation.Y;

       }





private void Stickers1_SelectionChanged(object sender,SelectionChangedEventArgs e)

{



var selecteditem = e.AddedItems [0] as StickersImageListModel;



{

Stickers1.Visibility = Visibility.Collapsed;

图片imageitem = new Image();

BitmapImage image = new BitmapImage(new System.Uri(selecteditem.Imageurl) ,UriKind.Absolute));

imageitem.Source = image;

my_canvas.Children.Add(imageitem);

imageitem.AllowDrop = true;

imageitem.ManipulationMode = ManipulationModes.All;

imageitem.ManipulationDelta + = Drag_ManipulationDelta;

dragTranslation = new TranslateTransform();

imageitem .RenderTransform = this.dragTranslation;

var st =(ScaleTransform)imageitem.RenderTransform;

double zoom = e.Delta> 0? .2:-.2;

st.ScaleX + =缩放;

st.ScaleY + =缩放;



}

my_canvas.Visibility = Visibility.Visible;

}



private void Stickers1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{

var selecteditem = e.AddedItems[0] as StickersImageListModel;

{
Stickers1.Visibility = Visibility.Collapsed;
Image imageitem = new Image();
BitmapImage image = new BitmapImage(new System.Uri(selecteditem.Imageurl, UriKind.Absolute));
imageitem.Source = image;
my_canvas.Children.Add(imageitem);
imageitem.AllowDrop = true;
imageitem.ManipulationMode = ManipulationModes.All;
imageitem.ManipulationDelta += Drag_ManipulationDelta;
dragTranslation = new TranslateTransform();
imageitem.RenderTransform = this.dragTranslation;
var st = (ScaleTransform)imageitem.RenderTransform;
double zoom = e.Delta > 0 ? .2 : -.2;
st.ScaleX += zoom;
st.ScaleY += zoom;

}
my_canvas.Visibility = Visibility.Visible;
}

推荐答案


这篇关于我如何能够和他人一起缩小图像并移动所有图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 02:15