本文整理汇总了C#中System.Windows.Input.ManipulationDeltaEventArgs.ReportBoundaryFeedback方法的典型用法代码示例。如果您正苦于以下问题:C# ManipulationDeltaEventArgs.ReportBoundaryFeedback方法的具体用法?C# ManipulationDeltaEventArgs.ReportBoundaryFeedback怎么用?C# ManipulationDeltaEventArgs.ReportBoundaryFeedback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Input.ManipulationDeltaEventArgs
的用法示例。
在下文中一共展示了ManipulationDeltaEventArgs.ReportBoundaryFeedback方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnManipulationDelta
protected override void OnManipulationDelta(ManipulationDeltaEventArgs args)
{
if (!manipulationDeltaInProgress)
{
IsActive = true;
if (!tapInertiaInProgess)
SelectedIndex = -1;
}
manipulationDeltaInProgress = true;
// This is the fake inertia from a tap
if (tapInertiaInProgess)
{
VerticalOffset -= args.DeltaManipulation.Translation.Y;
}
// All other direct manipulation and inertia
else
{
// For non-wrappable panel, check for end of the line
if (!isWrappableStackPanel)
{
double newVerticalOffset = VerticalOffset - inertiaDirection * args.DeltaManipulation.Translation.Y;
if (FractionalCenteredIndexFromVerticalOffset(newVerticalOffset, false) < 0)
{
double verticalOffsetIncrement = VerticalOffset - VerticalOffsetFromCenteredIndex(0);
double verticalOffsetExcess = args.DeltaManipulation.Translation.Y - verticalOffsetIncrement;
VerticalOffset -= verticalOffsetIncrement;
SelectedIndex = 0;
args.ReportBoundaryFeedback(new ManipulationDelta(new Vector(0, verticalOffsetExcess), 0, new Vector(), new Vector()));
args.Complete();
}
else if (FractionalCenteredIndexFromVerticalOffset(newVerticalOffset, false) > Items.Count - 1)
{
double verticalOffsetIncrement = VerticalOffsetFromCenteredIndex(Items.Count - 1) - VerticalOffset;
double verticalOffsetExcess = args.DeltaManipulation.Translation.Y - verticalOffsetIncrement;
VerticalOffset += verticalOffsetIncrement;
SelectedIndex = Items.Count - 1;
args.ReportBoundaryFeedback(new ManipulationDelta(new Vector(0, verticalOffsetExcess), 0, new Vector(), new Vector()));
args.Complete();
}
}
// Here's where scrolling might reverse itself
if (args.IsInertial && inertiaToUnknownIndex && !reverseInertiaChecked)
CheckForBackupManeuver(VerticalOffset, args.DeltaManipulation.Translation.Y, args.Velocities.LinearVelocity.Y);
// This is the normal direct manipulation and inertia
VerticalOffset -= inertiaDirection * args.DeltaManipulation.Translation.Y;
}
base.OnManipulationDelta(args);
}
示例2: ManipulateScroll
private void ManipulateScroll(ManipulationDeltaEventArgs e)
{
Debug.Assert(_panningInfo != null);
PanningMode panningMode = _panningInfo.PanningMode;
if (panningMode != PanningMode.VerticalOnly)
{
// Scroll horizontally unless the mode is VerticalOnly
ManipulateScroll(e.DeltaManipulation.Translation.X, e.CumulativeManipulation.Translation.X, true);
}
if (panningMode != PanningMode.HorizontalOnly)
{
// Scroll vertically unless the mode is HorizontalOnly
ManipulateScroll(e.DeltaManipulation.Translation.Y, e.CumulativeManipulation.Translation.Y, false);
}
if (e.IsInertial && IsPastInertialLimit())
{
e.Complete();
}
else
{
double unusedX = _panningInfo.UnusedTranslation.X;
if (!_panningInfo.InHorizontalFeedback &&
DoubleUtil.LessThan(Math.Abs(unusedX), PanningInfo.PreFeedbackTranslationX))
{
unusedX = 0;
}
_panningInfo.InHorizontalFeedback = (!DoubleUtil.AreClose(unusedX, 0));
double unusedY = _panningInfo.UnusedTranslation.Y;
if (!_panningInfo.InVerticalFeedback &&
DoubleUtil.LessThan(Math.Abs(unusedY), PanningInfo.PreFeedbackTranslationY))
{
unusedY = 0;
}
_panningInfo.InVerticalFeedback = (!DoubleUtil.AreClose(unusedY, 0));
if (_panningInfo.InHorizontalFeedback || _panningInfo.InVerticalFeedback)
{
// Report boundary feedback if needed
e.ReportBoundaryFeedback(new ManipulationDelta(new Vector(unusedX, unusedY), 0.0, new Vector(1.0, 1.0), new Vector()));
if (e.IsInertial && _panningInfo.InertiaBoundaryBeginTimestamp == 0)
{
_panningInfo.InertiaBoundaryBeginTimestamp = Environment.TickCount;
}
}
}
}
示例3: initManipulationDelta
private void initManipulationDelta(object sender, ManipulationDeltaEventArgs e)
{
FrameworkElement element = e.Source as FrameworkElement;
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(recordingFilename);
XmlNode root = xmlDoc.DocumentElement;
XmlNode eventsNode = xmlDoc.GetElementsByTagName("Events").Item(0);
XmlElement scaleNode = xmlDoc.CreateElement("Scale");
XmlElement rotateNode = xmlDoc.CreateElement("Rotate");
XmlElement translateNode = xmlDoc.CreateElement("Translate");
if (element != null)
{
ManipulationDelta deltaManipulation = e.DeltaManipulation;
Matrix matrix = ((MatrixTransform)element.RenderTransform).Matrix;
Point center = new Point(element.ActualWidth / 2, element.ActualHeight / 2);
center = matrix.Transform(center);
//Zoom
if (!noScale)
{
if (deltaManipulation.Scale.X != 1 && deltaManipulation.Scale.Y != 1)
{
eventsNode.AppendChild(scaleNode);
scaleNode.SetAttribute("Element", element.Name);
scaleNode.SetAttribute("X", deltaManipulation.Scale.X.ToString());
scaleNode.SetAttribute("Y", deltaManipulation.Scale.Y.ToString());
scaleNode.SetAttribute("CenterX", center.X.ToString());
scaleNode.SetAttribute("CenterY", center.Y.ToString());
}
matrix.ScaleAt(deltaManipulation.Scale.X, deltaManipulation.Scale.Y, center.X, center.Y);
}
// Rotate
if (!noRotate)
{
if (deltaManipulation.Rotation != 0)
{
eventsNode.AppendChild(rotateNode);
rotateNode.SetAttribute("Element", element.Name);
rotateNode.SetAttribute("Rotation", deltaManipulation.Rotation.ToString());
rotateNode.SetAttribute("CenterX", center.X.ToString());
rotateNode.SetAttribute("CenterY", center.Y.ToString());
}
matrix.RotateAt(deltaManipulation.Rotation, center.X, center.Y);
}
//Pan
if (!noTranslate)
{
if (deltaManipulation.Translation.X != 0 && deltaManipulation.Translation.Y != 0)
{
eventsNode.AppendChild(translateNode);
translateNode.SetAttribute("Element", element.Name);
translateNode.SetAttribute("X", deltaManipulation.Translation.X.ToString());
translateNode.SetAttribute("Y", deltaManipulation.Translation.Y.ToString());
}
matrix.Translate(deltaManipulation.Translation.X, deltaManipulation.Translation.Y);
}
xmlDoc.Save(recordingFilename);
//((MatrixTransform)element.RenderTransform).Matrix = matrix;
element.RenderTransform = new MatrixTransform(matrix);
if (e.IsInertial)
{
Rect containingRect = new Rect(((FrameworkElement)e.ManipulationContainer).RenderSize);
Rect shapeBounds = element.RenderTransform.TransformBounds(new Rect(element.RenderSize));
if (!containingRect.Contains(shapeBounds))
{
//let us know if we go outside the boundaries
e.ReportBoundaryFeedback(e.DeltaManipulation);
e.Complete();
}
}
e.Handled = true;
}
}
示例4: image_ManipulationDelta
void image_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
{
var element = e.Source as FrameworkElement;
if (element != null)
{
var deltaManipulation = e.DeltaManipulation;
var matrix = ((MatrixTransform)element.RenderTransform).Matrix;
System.Windows.Point center = new System.Windows.Point(element.ActualWidth / 2, element.ActualHeight / 2);
center = matrix.Transform(center);
matrix.ScaleAt(deltaManipulation.Scale.X, deltaManipulation.Scale.Y, center.X, center.Y);
matrix.RotateAt(e.DeltaManipulation.Rotation, center.X, center.Y);
matrix.Translate(e.DeltaManipulation.Translation.X, e.DeltaManipulation.Translation.Y);
((MatrixTransform)element.RenderTransform).Matrix = matrix;
e.Handled = true;
if (e.IsInertial)
{
Rect containingRect = new Rect(((FrameworkElement)e.ManipulationContainer).RenderSize);
Rect shapeBounds = element.RenderTransform.TransformBounds(new Rect(element.RenderSize));
if (e.IsInertial && !containingRect.Contains(shapeBounds))
{
e.ReportBoundaryFeedback(e.DeltaManipulation);
e.Complete();
}
}
}
}
示例5: cnvTable_ManipulationDelta
private void cnvTable_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
{
Piece element = e.OriginalSource as Piece;
// find the old center; arguaby this could be cached
Point center = new Point(element.ActualWidth / 2, element.ActualHeight / 2);
//element.RotatePiece(e.DeltaManipulation.Rotation,
// e.ManipulationOrigin.X,
// e.ManipulationOrigin.Y);
//element.RotatePiece(e.DeltaManipulation.Rotation,
// center.X,
// center.Y);
element.Rotate(e.DeltaManipulation.Rotation);
element.MoveDeltaPiece(e.DeltaManipulation.Translation.X,
e.DeltaManipulation.Translation.Y);
e.Handled = true;
// checking boundaries during inertia
if (e.IsInertial)
{
Rect containingRect = new Rect(((FrameworkElement)e.ManipulationContainer).RenderSize);
Rect shapeBounds = element.RenderTransform.TransformBounds(new Rect(element.RenderSize));
// Check if the element is completely in the window.
// If it is not and intertia is occuring, stop the manipulation.
if (e.IsInertial && !containingRect.Contains(shapeBounds))
{
//Report that we have gone over our boundary
e.ReportBoundaryFeedback(e.DeltaManipulation);
e.Complete();
}
}
UnionValidation();
VerticalUnionValidation();
}