You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
3.4 KiB
C#

using Prism.Events;
using Prism.Regions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Txgy.EWS.Client.Common.MessageEvents;
namespace Txgy.EWS.Client.PageModule.Views
{
/// <summary>
/// DataOutputView.xaml 的交互逻辑
/// </summary>
public partial class ReportView : UserControl
{
public TransformGroup transGroup;
Point _downPoint = new Point(0, 0);
Point previousMousePoint;
bool _isMoving = false;
private IEventAggregator ea;
public ReportView(IEventAggregator ea)
{
InitializeComponent();
transGroup = new TransformGroup();
transGroup.Children.Add(new ScaleTransform(2, 2));
transGroup.Children.Add(new TranslateTransform(-200, -150));
canvasPlan.RenderTransform = transGroup;
this.ea = ea;
this.ea.GetEvent<UpdateCanvasChildrenMessage>().Subscribe(u =>
{
canvasPlan.RenderTransform = transGroup;
});
}
private void canvasMain_MouseMove(object sender, MouseEventArgs e)
{
if (_isMoving)
{
Point currentPoint = e.GetPosition(sender as Grid);
//this.mainView.SetValue(Canvas.LeftProperty, left + (currentPoint.X - _downPoint.X));
//this.mainView.SetValue(Canvas.TopProperty, top + (currentPoint.Y - _downPoint.Y));
TranslateTransform tt = transGroup.Children[1] as TranslateTransform;
this.DoImageMove(tt, currentPoint);
e.Handled = true;
}
}
private void DoImageMove(TranslateTransform transform, Point position)
{
//trgroup = group.Children[1] as TransformGroup;
//Debug.Assert(group != null, "Can't find transform group from image compare panel resource");
//TranslateTransform transform = group.Children[1] as TranslateTransform;
transform.X += position.X - this.previousMousePoint.X;
transform.Y += position.Y - this.previousMousePoint.Y;
this.previousMousePoint = position;
}
private void canvasMain_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
_downPoint = e.GetPosition(sender as Grid);
this.previousMousePoint = _downPoint;
//left = double.Parse(this.mainView.GetValue(Canvas.LeftProperty).ToString());
//top = double.Parse(this.mainView.GetValue(Canvas.TopProperty).ToString());
_isMoving = true;
(sender as Grid).CaptureMouse();
e.Handled = true;
}
private void canvasMain_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
_isMoving = false;
(sender as Grid).ReleaseMouseCapture();
e.Handled = true;
}
private void canvasMain_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
}
private void canvasMain_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
{
}
}
}