本文整理汇总了C#中System.Windows.Input.MouseWheelEventArgs.GetPosition方法的典型用法代码示例。如果您正苦于以下问题:C# MouseWheelEventArgs.GetPosition方法的具体用法?C# MouseWheelEventArgs.GetPosition怎么用?C# MouseWheelEventArgs.GetPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Input.MouseWheelEventArgs
的用法示例。
在下文中一共展示了MouseWheelEventArgs.GetPosition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MouseWheel
public static void MouseWheel(Canvas c, TransformGroup tg, MouseWheelEventArgs e)
{
int deltaValue;
deltaValue = e.Delta;
TranslateTransform tt = (TranslateTransform)tg.Children[1];
ScaleTransform st = (ScaleTransform)tg.Children[0];
double xSpot = e.GetPosition(c).X;
double ySpot = e.GetPosition(c).Y;
Double x = e.GetPosition(c).X - tt.X;
Double y = e.GetPosition(c).Y - tt.Y;
Double centerX = st.CenterX * (st.ScaleX - 1);
Double centerY = st.CenterY * (st.ScaleY - 1);
st.CenterX = x;
st.CenterY = y;
if (deltaValue > 0)
{
st.ScaleX *= 1.25;
st.ScaleY *= 1.25;
}
else
{
st.ScaleX *= 0.75;
st.ScaleY *= 0.75;
}
}
示例2: PlotControl_MouseWheel
void PlotControl_MouseWheel(object sender, MouseWheelEventArgs e)
{
bool control = (Keyboard.IsKeyDown(Key.LeftCtrl));
bool shift = (Keyboard.IsKeyDown(Key.LeftShift));
OnMouseWheel(e.GetPosition(pc), e.Delta, control, shift);
}
示例3: OnMouseWheel
private void OnMouseWheel(object sender, MouseWheelEventArgs e) {
if (!e.Handled) {
Point mousePos = e.GetPosition(this);
int delta = -e.Delta;
MouseWheelZoom(mousePos, delta);
}
}
示例4: MapLayoutPanel_MouseWheel
private void MapLayoutPanel_MouseWheel(object sender, MouseWheelEventArgs e)
{
if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
{
var map = (VirtualizingZoomablePanel)sender;
var scrollViewer = Utils.FindAncestor<ScrollViewer>(map);
var mousePos = e.GetPosition(map);
if (map is System.Windows.Controls.Primitives.IScrollInfo)
{
mousePos.X += scrollViewer.HorizontalOffset;
mousePos.Y += scrollViewer.VerticalOffset;
}
var logicalPos = map.PixelsToLogical(mousePos, map.Scale, map.displayOffset);
double lat, lon;
UsaCities.EarthLocation.MercatorUnProject(logicalPos.X, logicalPos.Y, out lat, out lon);
if (e.Delta > 0)
{
map.Scale *= 1.1;
}
else if (e.Delta < 0)
{
map.Scale /= 1.1;
}
map.UpdateLayout();
var newDisplayPos = map.LogicalToPixels(logicalPos, map.Scale, map.displayOffset);
scrollViewer.ScrollToHorizontalOffset(scrollViewer.HorizontalOffset + (newDisplayPos.X - mousePos.X));
scrollViewer.ScrollToVerticalOffset(scrollViewer.VerticalOffset + (newDisplayPos.Y - mousePos.Y));
e.Handled = true;
}
}
示例5: OnMouseWheel
protected override void OnMouseWheel(MouseWheelEventArgs e)
{
base.OnMouseWheel(e);
var zoomDelta = MouseWheelZoomDelta * (double)e.Delta / 120d;
ZoomMap(e.GetPosition(this), TargetZoomLevel + zoomDelta);
}
示例6: OnGraphControlMouseWheel
private void OnGraphControlMouseWheel(object sender, MouseWheelEventArgs e)
{
ZoomAndPanControl.ZoomAboutPoint(
ZoomAndPanControl.ContentScale + e.Delta / 1000.0f,
e.GetPosition(GraphControl));
e.Handled = true;
}
示例7: source_MouseWheel
void source_MouseWheel(object sender, MouseWheelEventArgs e)
{
// zoom into the content. Calculate the zoom factor based on the direction of the mouse wheel.
double zoomFactor = this.DefaultZoomFactor;
if (e.Delta <= 0) zoomFactor = 1.0 / this.DefaultZoomFactor;
// DoZoom requires both the logical and physical location of the mouse pointer
var physicalPoint = e.GetPosition(this);
DoZoom(zoomFactor, this.transformGroup.Inverse.Transform(physicalPoint), physicalPoint);
}
示例8: timelineCanvas_MouseWheel
private void timelineCanvas_MouseWheel(object sender, MouseWheelEventArgs e)
{
const double zoomSpeed = 0.0012;
Point mousePos = e.GetPosition((UIElement)sender);
double zoomCenter;
if (trackVM.OffsetX == 0 && mousePos.X < 128) zoomCenter = 0;
else zoomCenter = (trackVM.OffsetX + mousePos.X) / trackVM.QuarterWidth;
trackVM.QuarterWidth *= 1 + e.Delta * zoomSpeed;
trackVM.OffsetX = Math.Max(0, Math.Min(trackVM.TotalWidth, zoomCenter * trackVM.QuarterWidth - mousePos.X));
}
示例9: player_MouseWheel
//static internal Uri doGetImageSourceFromResource(string psAssemblyName, string psResourceName) {
// Uri oUri = new Uri("pack://application:,,,/" + psAssemblyName + ";component/" + psResourceName, UriKind.RelativeOrAbsolute);
// return oUri;
//}
void player_MouseWheel(object sender, MouseWheelEventArgs e) {
if (e.Delta > 0) {
if (Double.IsNaN(viewPortContainer.Height)) {
scroller.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
scroller.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
viewPortContainer.Height = viewPortContainer.ActualHeight;
viewPortContainer.Width = viewPortContainer.ActualWidth;
}
viewPortContainer.Height += 20;
viewPortContainer.Width += 20;
double actualH = scroller.ActualHeight;
double actualW = scroller.ActualWidth;
Point mousePointer = e.GetPosition(scroller);
if (mousePointer.X < actualW/2) {
}else{
scroller.LineRight();
}
if (mousePointer.Y < actualH / 2) {
} else {
scroller.LineDown();
}
} else {
double actualH = scroller.ActualHeight;
if (actualH <= viewPortContainer.ActualHeight) {
viewPortContainer.Height = Double.NaN;
viewPortContainer.Width = Double.NaN;
scroller.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
scroller.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled;
} else {
viewPortContainer.Height -= 20;
viewPortContainer.Width -= 20;
double actualW = scroller.ActualWidth;
Point mousePointer = e.GetPosition(scroller);
if (mousePointer.X < actualW / 2) {
scroller.LineUp();
} else {
}
if (mousePointer.Y < actualH / 2) {
scroller.LineLeft();
} else {
}
}
}
e.Handled = true;
}
示例10: OnMouseWheel
protected override void OnMouseWheel(MouseWheelEventArgs e)
{
e.Handled = true;
Point center = e.GetPosition(cardsView);
var mess = new MouseWheelTableZoom(e.Delta,center);
Messenger.Default.Send(mess);
base.OnMouseWheel(e);
}
示例11: image_MouseWheel
private void image_MouseWheel(object sender, MouseWheelEventArgs e)
{
var mousePosition = e.GetPosition(snap);
snap.RenderTransformOrigin = new Point(mousePosition.X / snap.ActualWidth, mousePosition.Y / snap.ActualHeight);
var transformGroup = (TransformGroup)snap.RenderTransform;
var transform = (ScaleTransform)transformGroup.Children[0];
double zoom = e.Delta > 0 ? .2 : -.2;
if ((transform.ScaleX > 0.21 && zoom < 0) || (zoom > 0 && transform.ScaleX < 4))
{
transform.ScaleX += zoom;
transform.ScaleY += zoom;
}
Console.WriteLine(transform.ScaleX);
}
示例12: HandleMouseWheel
protected virtual void HandleMouseWheel(object sender, MouseWheelEventArgs e)
{
var zoom = e.Delta > 0 ? .2 : -.2;
if (!(e.Delta > 0) && (ScaleTransform.ScaleX < .4 || ScaleTransform.ScaleY < .4))
return;
foreach (Border child in Children)
{
child.UpdateLayout();
var position = e.GetPosition(child);
child.RenderTransformOrigin = new Point(position.X/child.ActualWidth, position.Y/child.ActualHeight);
}
ScaleTransform.ScaleX += zoom;
ScaleTransform.ScaleY += zoom;
}
示例13: Zoom_PreviewMouseWheel
private void Zoom_PreviewMouseWheel(object sender,MouseWheelEventArgs e) {
if(!(Keyboard.Modifiers == ModifierKeys.Control))
return;
Point pos = e.GetPosition(this);
double scaleFactor = 0.0;
if(e.Delta > 0) {
scaleFactor = e.Delta / 100.0;
} else if(e.Delta < 0) {
scaleFactor = 100.0 / -e.Delta;
}
EquipmentScaleUtilis.SetScaleFactor(scaleFactor,this,Equipment_Viewbox);
}
示例14: child_MouseWheel
public void child_MouseWheel(object sender,MouseWheelEventArgs e)
{
if(!(child.IsMouseCaptured) && enabled) {
ScaleTransform scaleTransform = GetScaleTransform(child);
TranslateTransform translateTransform = GetTranslateTransform(child);
double zoom;
if(e.Delta > 0) {
zoom = 0.5;
} else {
zoom = -0.5;
}
if((!(e.Delta < 0) && (scaleTransform.ScaleX > 4.5 || scaleTransform.ScaleY > 4.5)) || (!(e.Delta > 0) && (scaleTransform.ScaleX < 1.0 || scaleTransform.ScaleY < 1.0))) {
return;
}
Point relative = e.GetPosition(child);
double abosuluteX = relative.X* scaleTransform.ScaleX + translateTransform.X;
double abosuluteY = relative.Y * scaleTransform.ScaleY + translateTransform.Y;
scaleTransform.ScaleX += zoom;
scaleTransform.ScaleY += zoom;
translateTransform.X = abosuluteX - relative.X * scaleTransform.ScaleX;
translateTransform.Y = abosuluteY - relative.Y * scaleTransform.ScaleY;
}
}
示例15: Content_MouseWheel
private void Content_MouseWheel(object sender, MouseWheelEventArgs e)
{
double zoom = Math.Pow(Zoomer.ZoomFactor, e.Delta / 120.0);
Point offset = e.GetPosition(this.Viewbox);
this.Zoom(zoom, offset);
}