private void PerformRotation(Window wnd, ManipulationDeltaRoutedEventArgs e, CompositeTransform transform) { if (wnd.IsFullscreen) { return; } transform.Rotation += e.Delta.Rotation; }
private double GetDeltaX(Window wnd, Point currentPosition, Point deltaPosition) { if (currentPosition.X + deltaPosition.X < 0) { return(-currentPosition.X); } else if (currentPosition.X + wnd.ActualWidth + deltaPosition.X > _workspace.ActualWidth) { return(-(currentPosition.X + wnd.ActualWidth - _workspace.ActualWidth)); } else { return(deltaPosition.X); } }
private double GetDeltaY(Window wnd, Point currentPosition, Point deltaPosition) { if (currentPosition.Y + deltaPosition.Y < 0) { return(-currentPosition.Y); } else if (currentPosition.Y + wnd.ActualHeight + deltaPosition.Y > _workspace.ActualHeight) { return(-(currentPosition.Y + wnd.ActualHeight - _workspace.ActualHeight)); } else { return(deltaPosition.Y); } }
private void PerformTransation(Window wnd, ManipulationDeltaRoutedEventArgs e, CompositeTransform transform) { if (wnd.IsFullscreen) { return; } var currentPosition = new Point(transform.TranslateX, transform.TranslateY); var deltaPosition = new Point(e.Delta.Translation.X, e.Delta.Translation.Y); deltaPosition.X = GetDeltaX(wnd, currentPosition, deltaPosition); deltaPosition.Y = GetDeltaY(wnd, currentPosition, deltaPosition); transform.TranslateX += deltaPosition.X; transform.TranslateY += deltaPosition.Y; }
private void PerformScale(Window wnd, ManipulationDeltaRoutedEventArgs e, CompositeTransform transform, CompositeTransform compositeTransform) { if (wnd.IsFullscreen) { return; } if (e.Delta.Scale == 1) { return; } var minScale = _rootConfigVm.SelectedSession.Root.WindowSettings.MinWindowScale; var maxScale = _rootConfigVm.SelectedSession.Root.WindowSettings.MaxWindowScale; transform.ScaleX *= e.Delta.Scale; transform.ScaleY *= e.Delta.Scale; transform.TranslateX = (e.Delta.Scale * (transform.TranslateX - _relativePosX)) + _relativePosX; transform.TranslateY = (e.Delta.Scale * (transform.TranslateY - _relativePosY)) + _relativePosY; var scaledWidth = transform.ScaleX * wnd.ActualWidth; var scaledHeight = transform.ScaleY * wnd.ActualHeight; if (transform.ScaleX < minScale) { transform.ScaleX = minScale; } if (transform.ScaleY < minScale) { transform.ScaleY = minScale; } if (maxScale != double.MaxValue) { if (transform.ScaleX > maxScale) { transform.ScaleX = maxScale; } if (transform.ScaleY > maxScale) { transform.ScaleY = maxScale; } } else { if (transform.TranslateY + scaledHeight >= _workspace.ActualHeight) { transform.TranslateY = _workspace.ActualHeight - scaledHeight; if (transform.TranslateY < 0) { var maxContainerScale = _workspace.ActualHeight / wnd.ActualHeight; transform.ScaleX = maxContainerScale; transform.ScaleY = maxContainerScale; } } if (transform.TranslateX + scaledWidth >= _workspace.ActualWidth) { transform.TranslateX = _workspace.ActualWidth - scaledWidth; if (transform.TranslateX < 0) { var maxContainerScale = _workspace.ActualWidth / wnd.ActualWidth; transform.ScaleX = maxContainerScale; transform.ScaleY = maxContainerScale; } } } compositeTransform.ScaleX = 1.0d / transform.ScaleX; compositeTransform.ScaleY = 1.0d / transform.ScaleY; }