private void mainFragment_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e) { if (Math.Abs(e.CumulativeManipulation.Translation.X) < 0) { return; } if (e.CumulativeManipulation.Translation.X >= _listFragment.Width) { mainFragment_ManipulationCompleted(this, null); return; } _deltaTransform.X = -_listFragment.Width + e.CumulativeManipulation.Translation.X; _listFragment.RenderTransform = _deltaTransform; MoveShadowFragment(e.CumulativeManipulation.Translation.X); }
void winControl_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e) { // Left to Right: +X // Right to Left: -X // Top to Bottom: +Y // Bottom to Top: -Y // get the movement both directionally and absolute val var delX = e.CumulativeManipulation.Translation.X; var absX = Math.Abs(delX); var delY = e.CumulativeManipulation.Translation.Y; var absY = Math.Abs(delY); // calculate how much change will trigger an action based on the control's size var upDownMinDelta = this.ActualHeight * deltaPercentage; var leftRightMinDelta = this.ActualWidth * deltaPercentage; //System.Diagnostics.Debug.WriteLine("X: {0}, Y: {1}", delX, delY); if (absX > absY && absX > leftRightMinDelta) { if (delX < 0) { this.Element.OnSwipeLeft(); } else { this.Element.OnSwipeRight(); } e.Complete(); } else if (absY > absX && absY > upDownMinDelta) { if (delY < 0) { this.Element.OnSwipeUp(); } else { this.Element.OnSwipeDown(); } e.Complete(); } }
private void viewport_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e) { if (e.PinchManipulation != null) { double newWidth, newHieght; if (m_Width < m_Height) // box new size between image size and viewport actual size { newHieght = m_Height * m_Zoom * e.PinchManipulation.CumulativeScale; newHieght = Math.Max(viewport.ActualHeight, newHieght); newHieght = Math.Min(newHieght, m_Height); newWidth = newHieght * m_Width / m_Height; } else { newWidth = m_Width * m_Zoom * e.PinchManipulation.CumulativeScale; newWidth = Math.Max(viewport.ActualWidth, newWidth); newWidth = Math.Min(newWidth, m_Width); newHieght = newWidth * m_Height / m_Width; } if (newWidth < m_Width && newHieght < m_Height) { // Tells image positione in viewport (offset) MatrixTransform transform = image.TransformToVisual(viewport) as MatrixTransform; // Calculate center of pinch gesture on image (not screen) Point pinchCenterOnImage = transform.Transform(e.PinchManipulation.Original.Center); // Calculate relative point (0-1) of pinch center in image Point relativeCenter = new Point(e.PinchManipulation.Original.Center.X / image.Width, e.PinchManipulation.Original.Center.Y / image.Height); // Calculate and set new origin point of viewport Point newOriginPoint = new Point(relativeCenter.X * newWidth - pinchCenterOnImage.X, relativeCenter.Y * newHieght - pinchCenterOnImage.Y); viewport.SetViewportOrigin(newOriginPoint); } image.Width = newWidth; image.Height = newHieght; // Set new view port bound viewport.Bounds = new Rect(0, 0, newWidth, newHieght); } }
private void ViewportControl_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e) { if (e.PinchManipulation != null) { double newWidth, newHieght; if (m_Width < m_Height) { newHieght = m_Height * m_Zoom * e.PinchManipulation.CumulativeScale; newHieght = Math.Max(viewport.ActualHeight, newHieght); newHieght = Math.Min(newHieght, m_Height); newWidth = newHieght * m_Width / m_Height; } else { newWidth = m_Width * m_Zoom * e.PinchManipulation.CumulativeScale; newWidth = Math.Max(viewport.ActualWidth, newWidth); newWidth = Math.Min(newWidth, m_Width); newHieght = newWidth * m_Height / m_Width; } if (newWidth < m_Width && newHieght < m_Height) { MatrixTransform transform = map.TransformToVisual(viewport) as MatrixTransform; Point pinchCenterOnImage = transform.Transform(e.PinchManipulation.Original.Center); Point relativeCenter = new Point(e.PinchManipulation.Original.Center.X / map.Width, e.PinchManipulation.Original.Center.Y / map.Height); Point newOriginPoint = new Point(relativeCenter.X * newWidth - pinchCenterOnImage.X, relativeCenter.Y * newHieght - pinchCenterOnImage.Y); viewport.SetViewportOrigin(newOriginPoint); } _mapTransform.ScaleX = map.Width / m_Width; _mapTransform.ScaleY = map.Width / m_Width; map.Width = newWidth; map.Height = newHieght; viewport.Bounds = new Rect(0, 0, newWidth, newHieght); e.Handled = true; } }
private void Grid_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e) { var ct = (sender as Grid).RenderTransform as CompositeTransform; var sum = ct.TranslateX + e.DeltaManipulation.Translation.X; if (sum < -200) { ct.TranslateX = -200; } else if (sum > 0) { ct.TranslateX = 0; } else { ct.TranslateX = sum; } var bo = VisualTreeHelper.GetChild(VisualTreeHelper.GetParent(sender as Grid), 0) as Border; bo.Opacity = sum / -200; }
void svi_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e) { // Get a reference to the ScatterViewItem item. ScatterViewItem item = (ScatterViewItem)e.Source; //Console.WriteLine("width: " + item.ActualWidth); //Console.WriteLine("heigth: " + item.ActualHeight); if (item.ActualWidth <= 100) { Control_Minimized(this, new MinimizeEventArgs(((DeviceControl)item.Content).device, MinimizeEventType.Minimized, item.Center)); Logger.Log("minimize", "size reduce"); item.Width = 156; item.Height = 309; e.Handled = true; return; } if (item.ActualWidth >= 600) { Maximize(item); } int dist = 10; int minX = 0 + dist; int minY = 0 + dist; int maxX = 1024 - dist; int maxY = 768 - dist; if (item.Center.X < minX || item.Center.X > maxX || item.Center.Y < minY || item.Center.Y > maxY) { Control_Minimized(this, new MinimizeEventArgs(((DeviceControl)item.Content).device, MinimizeEventType.Minimized, CalculateEdgePosition(item.Center))); Logger.Log("minimize", "off edge"); e.Handled = true; return; } e.Handled = true; }
void rotation_Slider_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e) { //Because the model is rotated once the ApplicationSetting is changed we only change it once //a manipulation has completed for performance reasons //But we still want to update the text of the appropriate textblock var slider = sender as Slider; if (slider.Name[0] == 'x')//slider.Name.Contains("x")) { //xRotation_TextBlock.Text = "X Rotation: " + (int)slider.Value; xRotation_TextBox.Text = ((int)slider.Value).ToString(); } else if (slider.Name[0] == 'y')//slider.Name.Contains("y")) { //yRotation_TextBlock.Text = "Y Rotation: " + (int)slider.Value; yRotation_TextBox.Text = ((int)slider.Value).ToString(); } else { //zRotation_TextBlock.Text = "Z Rotation: " + (int)slider.Value; zRotation_TextBox.Text = ((int)slider.Value).ToString(); } }
private void PlaceHolder_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e) { //if (Math.Abs(e.CumulativeManipulation.Translation.Y) > 5) return; //if (Math.Abs(e.DeltaManipulation.Translation.X) < 2) return; var container = sender as FrameworkElement; double earlyFlipFactor = container.ActualWidth / 3;// to make it faster to reach the middle double desiredFlipWidth = container.ActualWidth - earlyFlipFactor; double cumulative = e.CumulativeManipulation.Translation.X; double rotateValue = (cumulative / desiredFlipWidth) * -180; if (Math.Abs(e.CumulativeManipulation.Translation.X) < 2) { //If user is clicking return; } var PlaceHolderprojection = (PlaceHolder.Projection as PlaneProjection); double NextValue = (360 + startRotation + rotateValue) % 360; //Assign New Rotation Value PlaceHolderprojection.RotationY = NextValue; //Determine which part will be on top SetZIndex(NextValue); SetOpacity(NextValue); }
private void ScrollViewer_ManipulationDelta_1(object sender, System.Windows.Input.ManipulationDeltaEventArgs e) { BottomGrid.Height -= e.DeltaManipulation.Translation.Y; }
private void Containter_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e) { }
private void Map_ManipulationDelta([CanBeNull] object?sender, [NotNull] System.Windows.Input.ManipulationDeltaEventArgs e) { var map = AssociatedObject; map.Center += e.DeltaManipulation.Translation; }
private static void MapManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e) { e.Handled = true; }
void ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e) { TranslateTransform transform = null; if (sender == LeftTouch) { transform = _leftTransform; } else if (sender == RightTouch) { transform = _rightTransform; } if (transform != null) { var newTransform = transform.X + e.DeltaManipulation.Translation.X; var stepLength = RenderSize.Width / ((MaxValue - MinValue) / Step); var translation = 0.0; if (e.DeltaManipulation.Translation.X < 0) { translation = Math.Ceiling(e.DeltaManipulation.Translation.X * -1 / stepLength); translation *= -1; } else { translation = Math.Ceiling(e.DeltaManipulation.Translation.X / stepLength); } var cumulativeTranslation = e.CumulativeManipulation.Translation.X; if ((translation > 0 && cumulativeTranslation / stepLength > _lastStep) || translation < 0 && cumulativeTranslation / stepLength < _lastStep) { if (translation > 0) { _lastStep++; } else { _lastStep--; } transform.X += translation * stepLength; if (transform.X > (this.RenderSize.Width / 2 - 10)) { transform.X = this.RenderSize.Width / 2 - 10; } else if (transform.X < -(this.RenderSize.Width / 2 - 10)) { transform.X = -(this.RenderSize.Width / 2 - 10); } var leftPosition = Left.TransformToVisual(this).Transform(new Point(0, 0)); var rightPosition = Right.TransformToVisual(this).Transform(new Point(0, 0)); if (rightPosition.X <= leftPosition.X) { if (sender == RightTouch) { _rightTransform.X = _leftTransform.X + stepLength; } else { _leftTransform.X = _rightTransform.X - stepLength; } leftPosition = Left.TransformToVisual(this).Transform(new Point(0, 0)); rightPosition = Right.TransformToVisual(this).Transform(new Point(0, 0)); } if (sender == LeftTouch) { _rangeTransform.X = leftPosition.X; if (_rangeTransform.X < 0) { _rangeTransform.X = 0; } } var width = rightPosition.X - leftPosition.X; if (width >= 0) { Range.Width = width; } } SetTouchAreaTransform(); } CaluclateValues(); }
protected override void OnManipulationDelta(System.Windows.Input.ManipulationDeltaEventArgs e) { offset += e.DeltaManipulation.Translation.Y; ScrollToVerticalOffset(offset); base.OnManipulationDelta(e); }
private void MonitorSwipeDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e) { }
void BrdFrame_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e) { if (e.PinchManipulation == null) { //Drag double horizontalChange = e.DeltaManipulation.Translation.X; double verticalChange = e.DeltaManipulation.Translation.Y; //좌측으로 if (horizontalChange < 0 && protectDirection != DragDirection.Left) { transform.TranslateX += horizontalChange; transform.TranslateY += verticalChange; protectDirection = DragDirection.None; } //우측으로 else if (horizontalChange > 0 && protectDirection != DragDirection.Right) { transform.TranslateX += horizontalChange; transform.TranslateY += verticalChange; protectDirection = DragDirection.None; } else if (verticalChange < 0 && protectDirection != DragDirection.Top) { //위로 transform.TranslateX += horizontalChange; transform.TranslateY += verticalChange; protectDirection = DragDirection.None; } else if (verticalChange > 0 && protectDirection != DragDirection.Bottom) { //아래로 transform.TranslateX += horizontalChange; transform.TranslateY += verticalChange; protectDirection = DragDirection.None; } else { return; } //일단 움직이면 축소 가능하도록 설정 canZoomOut = true; GeneralTransform gtf = ImgDetail.TransformToVisual(ImgFrame); Point pt = gtf.Transform(new Point(ImgDetail.ActualWidth, ImgDetail.ActualHeight)); //좌측선 if (pt.X < innerRect.Left) { transform.TranslateX += innerRect.Left - pt.X; protectDirection = DragDirection.Left; canZoomOut = false; } //상단선 if (pt.Y < innerRect.Top) { transform.TranslateY += innerRect.Top - pt.Y; protectDirection = DragDirection.Top; canZoomOut = false; } gtf = ImgFrame.TransformToVisual(ImgDetail); pt = gtf.Transform(new Point(innerRect.Left + innerRect.Width, innerRect.Top + innerRect.Height)); //우측선 if (pt.X < 0) { transform.TranslateX += pt.X; protectDirection = DragDirection.Right; canZoomOut = false; } //하단선 if (pt.Y < 0) { transform.TranslateY += pt.Y; protectDirection = DragDirection.Bottom; canZoomOut = false; } } else { //Pinch double distanceRatio = e.PinchManipulation.CumulativeScale; Size scale = new Size(currentScale.X * distanceRatio, currentScale.Y * distanceRatio); bool isZoomIn = scale.Width > transform.ScaleX; if (isZoomIn) { canZoomOut = true; protectDirection = DragDirection.None; } if (scale.Width <= SCALE_MAX && (canZoomOut || isZoomIn)) { //축소일때 최소영역보다 이하이면 축소하지 않음 if (ImgDetail.ActualWidth * scale.Width >= innerRect.Width / 2 && ImgDetail.ActualHeight * scale.Height >= innerRect.Height / 2) { transform.ScaleX = scale.Width; transform.ScaleY = scale.Height; Point inPoint = new Point(innerRect.Left + innerRect.Width, innerRect.Top + innerRect.Height); CompensationPinch(distanceRatio, ImgFrame, ImgDetail, inPoint, 0, true); CompensationPinch(distanceRatio, ImgFrame, ImgDetail, inPoint, 0, false); inPoint = new Point(ImgDetail.ActualWidth, ImgDetail.ActualHeight); CompensationPinch(distanceRatio, ImgDetail, ImgFrame, inPoint, innerRect.Left, true); CompensationPinch(distanceRatio, ImgDetail, ImgFrame, inPoint, innerRect.Top, false); } } } }
private void UserControl_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e) { _viewModel.ManipulationDelta(e.DeltaManipulation.Translation.X); }
protected override void OnManipulationDelta(System.Windows.Input.ManipulationDeltaEventArgs e) { }
void Control_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e) { Element element = GetElement(sender); if (e.PinchManipulation != null) { double pinch = e.PinchManipulation.CumulativeScale; Console.WriteLine("Control_ManipulationDelta pinch = " + pinch); if (pinch > 1) { this.RaiseEvent(element, new GestureMonitorEventArgs(element, GestureType.Stretch)); e.Handled = true; } else if (pinch < 1) { this.RaiseEvent(element, new GestureMonitorEventArgs(element, GestureType.Pinch)); e.Handled = true; } } else if (e.DeltaManipulation != null) { System.Windows.Point p = e.DeltaManipulation.Translation; if (((p.X * p.X) + (p.Y * p.Y)) > 244) { this.RaiseEvent(element, new GestureMonitorEventArgs(element, GestureType.Swiping)); if (p.X > 10) { this.RaiseEvent(element, new GestureMonitorEventArgs(element, GestureType.SwipingRight)); } if (p.X < -10) { this.RaiseEvent(element, new GestureMonitorEventArgs(element, GestureType.SwipingLeft)); } if (p.Y > 10) { this.RaiseEvent(element, new GestureMonitorEventArgs(element, GestureType.SwipingDown)); } if (p.Y < -10) { this.RaiseEvent(element, new GestureMonitorEventArgs(element, GestureType.SwipingUp)); } } else { this.RaiseEvent(element, new GestureMonitorEventArgs(element, GestureType.Panning)); if (p.X > 2) { this.RaiseEvent(element, new GestureMonitorEventArgs(element, GestureType.PanningRight)); } if (p.X < -2) { this.RaiseEvent(element, new GestureMonitorEventArgs(element, GestureType.PanningLeft)); } if (p.Y > 2) { this.RaiseEvent(element, new GestureMonitorEventArgs(element, GestureType.PanningDown)); } if (p.Y < -2) { this.RaiseEvent(element, new GestureMonitorEventArgs(element, GestureType.PanningUp)); } } } else { Console.WriteLine("Control_ManipulationDelta "); } }
private void Window_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e) { logger.InfoFormat("{0:D3}.{1}", ++numberIndex, MethodBase.GetCurrentMethod().Name); }
void MainPage_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e) { }
private void BoxExRenderer_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e) { var el = this.Element as BoxViewEx; el.OnManipulationDelta(el, new PazzleDrag.ManipulationDeltaRoutedEventArgs(el, e.DeltaManipulation.Translation.X, e.DeltaManipulation.Translation.Y)); }
private void OnManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e) { xDistance = e.CumulativeManipulation.Translation.X; yDistance = e.CumulativeManipulation.Translation.Y; base.OnManipulationDelta(e); }
private void ManipulationDeltaHandler(object sender, System.Windows.Input.ManipulationDeltaEventArgs e) { var sourceElement = e.Source as FrameworkElement; if (sourceElement != null) { // e.DeltaManipulation has the changes // Scale is a delta multiplier; 1.0 is last size, (so 1.1 == scale 10%, 0.8 = shrink 20%) // Rotate = Rotation, in degrees // Pan = Translation, == Translate offset, in Device Independent Pixels var deltaManipulation = e.DeltaManipulation; var matrixTransform = sourceElement.RenderTransform as MatrixTransform; if (matrixTransform == null) { matrixTransform = new MatrixTransform(); sourceElement.RenderTransform = matrixTransform; } var matrix = matrixTransform.Matrix; if (_previousMatrix == null) { _previousMatrix = matrix; } // Center the translation around the user's fingers Point center = ((FrameworkElement)e.ManipulationContainer) .TranslatePoint(e.ManipulationOrigin, sourceElement); // transform it to take into account transforms from previous manipulations center = matrix.Transform(center); // Perform a scaling (zoom) tranformation if ((deltaManipulation.Scale.X < 1 && matrix.Determinant >= this.MinimumScale) || (deltaManipulation.Scale.X > 1 && matrix.Determinant <= this.MaximumScale)) { matrix.ScaleAt(deltaManipulation.Scale.X, deltaManipulation.Scale.Y, center.X, center.Y); } // Prevent scaling below the minimum scale amount. if (matrix.Determinant < this.MinimumScale) { return; } // Rotation if (this.AllowRotate) { matrix.RotateAt(e.DeltaManipulation.Rotation, center.X, center.Y); } // Limit the X/Y translation extent to prevent the element from 'jumping' when using slow touchscreens, or many touch points. double translationThreshold = 100.0; // Perform a translation (pan) tranformation if ((deltaManipulation.Translation.X < translationThreshold && deltaManipulation.Translation.X > -translationThreshold) && (deltaManipulation.Translation.Y < translationThreshold && deltaManipulation.Translation.Y > -translationThreshold)) { matrix.Translate(e.DeltaManipulation.Translation.X, e.DeltaManipulation.Translation.Y); } // Perform the render transform on the element. sourceElement.RenderTransform = new MatrixTransform(matrix); e.Handled = true; } }
public ManipulationArgs(ObjectPositionDescriptor positionDescriptor, System.Windows.Input.ManipulationDeltaEventArgs deltaEventArgs) { PositionDescriptor = positionDescriptor; DeltaEventArgs = deltaEventArgs; }
private void LayoutRoot_OnManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e) { var fill = BlurredImage.OverlayFillPercentage + (e.DeltaManipulation.Translation.Y); BlurredImage.OverlayFillPercentage = Math.Max(0, Math.Min(fill, 100)); }
private void PhoneApplicationPageManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e) { // Move the rectangle. //translation.X += e.DeltaManipulation.Translation.X; //translation.Y += e.DeltaManipulation.Translation.Y; }
private void SlideViewQuestion_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e) { //disable sliding of SlideViewer e.Handled = true; }
private void OverlayInformationPanel_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e) { y = e.CumulativeManipulation.Translation.Y; OverlayInformationPanelTranslateTransform.Y = (y < 0.0) ? y : 0.0; }
private void fieldGrid_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e) { manipulationHandler.ManipulationDelta(e.DeltaManipulation.Translation); }
private void LayoutRoot_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e) { }