本文整理汇总了C#中System.Windows.Input.StylusEventArgs.GetPosition方法的典型用法代码示例。如果您正苦于以下问题:C# StylusEventArgs.GetPosition方法的具体用法?C# StylusEventArgs.GetPosition怎么用?C# StylusEventArgs.GetPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Input.StylusEventArgs
的用法示例。
在下文中一共展示了StylusEventArgs.GetPosition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessMove
public void ProcessMove(object sender, StylusEventArgs args)
{
PictureTracker pictureTracker = GetPictureTracker(args.StylusDevice.Id);
if (pictureTracker == null)
return;
Point location = args.GetPosition(_canvas);
pictureTracker.ProcessMove(args.StylusDevice.Id, location);
}
示例2: DragSourcePieMenuPreviewMouseMove
public void DragSourcePieMenuPreviewMouseMove(object sender, StylusEventArgs e)
{
if (e.InAir)
_draggedData = null;
if (_draggedData != null)
{
//release the stylus like up event
_draggedData = null;
_stylusCaptured = false;
if (_adorner != null)
{
//_adorner.ReleaseStylusCapture();
_adornerLayer.Children.Remove(_adorner);
}
}
_draggedData = (sender as FrameworkElement).DataContext;
if (!_stylusCaptured && _draggedData != null)
{
// Only drag when user moved the mouse by a reasonable amount.
if (DragDropHelper.IsMovementBigEnough(_initialMousePosition, e.GetPosition(_topUserControl)))
{
try
{
_adorner = (DragDropAdornerBase)GetDragDropControl(sender as DependencyObject);
_adorner.DataContext = _draggedData;
_adorner.Opacity = 0.7;
_adornerLayer.Visibility = Visibility.Collapsed;
_adornerLayer.Children.Add(_adorner);
//_stylusCaptured = Stylus.Capture(_adorner);
Canvas.SetLeft(_adorner, _initialMousePosition.X - 20);
Canvas.SetTop(_adorner, _initialMousePosition.Y - 15);
//_adornerLayer.PreviewMouseMove += new MouseEventHandler(_adorner_MouseMove);
//_adornerLayer.PreviewMouseUp += new MouseButtonEventHandler(_adorner_MouseUp);
//_adornerLayer.StylusUp += new StylusEventHandler(_adornerLayer_StylusUp);
}
catch (Exception eee)
{
System.Diagnostics.Debug.Print(eee.ToString());
// bummer
}
}
}
}
示例3: DragSourcePieMenuPreviewMouseLeftButtonDown
public void DragSourcePieMenuPreviewMouseLeftButtonDown(UserControl diagramUserControl, StylusEventArgs e)
{
try
{
_topUserControl = diagramUserControl;
_initialMousePosition = e.GetPosition(_topUserControl);
_adornerLayer = (Canvas)_topUserControl.FindName("adornerLayer");
_dropTarget = (UIElement)_topUserControl.FindName("inkCanvas");
}
catch (Exception exc)
{
Console.WriteLine("Exception in DragDropHelper: " + exc.InnerException.ToString());
}
}
示例4: OnStylusMove
protected override void OnStylusMove(StylusEventArgs args)
{
base.OnStylusMove(args);
if (isDrawing)
{
Point ptStylus = args.GetPosition(canv);
polyStylus.Points.Add(ptStylus);
polyShadow.Points.Add(ptStylus + vectShadow);
args.Handled = true;
}
}
示例5: Grid_StylusMove
private void Grid_StylusMove(object sender, StylusEventArgs e)
{
Point currentPosition = e.GetPosition(Grid1);
DrawProcessing(currentPosition);
}
示例6: MainInkCanvas_StylusMove
void MainInkCanvas_StylusMove(object sender, StylusEventArgs e)
{
if (e.GetPosition(MainInkCanvas).X <= 10)
{
openSidebar();
}
else
{
hideSidebar();
}
}
示例7: circuitInkCanvas_StylusMove
/*
void circuitInkCanvas_StylusMove(object sender, StylusEventArgs e)
{
if (IsReadOnly)
return;
TimeSpan ts = _stopWatch.Elapsed;
if (ts.TotalSeconds - _lastElapsedSecs> 2)
{
_stopWatch.Stop();
_stopWatch = Stopwatch.StartNew();
MessageBox.Show("Popup");
}
Point mp2 = e.GetPosition(circuitInkCanvas);
circuitInkCanvas.BringIntoView(new Rect(new Point(mp2.X - 10, mp2.Y - 10),
new Point(mp2.X + 10, mp2.Y + 10)));
switch (dragging)
{
case DragState.CONNECT_FROM:
dragWire.Destination = mp2;
break;
case DragState.CONNECT_TO:
dragWire.Origin = mp2;
break;
case DragState.MOVE:
#region DragState is Move
foreach (Gate g in selected)
{
//g.RenderTransform = new TranslateTransform(mp2.X, mp2.Y);
//Direct Move
double dx = mp2.X - mp.X;
double dy = mp2.Y - mp.Y;
((GateLocation)g.Tag).x = ((GateLocation)g.Tag).x + dx;
((GateLocation)g.Tag).y = ((GateLocation)g.Tag).y + dy;
double cx = ((GateLocation)g.Tag).x % GRID_SIZE;
double cy = ((GateLocation)g.Tag).y % GRID_SIZE;
Point op = new Point(g.Margin.Left, g.Margin.Top);
if ((Math.Abs(cx) < DELTA_SNAP || Math.Abs(GRID_SIZE - cx) < DELTA_SNAP) &&
(Math.Abs(cy) < DELTA_SNAP || Math.Abs(GRID_SIZE - cy) < DELTA_SNAP))
{
g.Margin = new Thickness(Math.Round(g.Margin.Left / GRID_SIZE) * GRID_SIZE,
Math.Round(g.Margin.Top / GRID_SIZE) * GRID_SIZE, 0, 0);
}
else
{
g.Margin = new Thickness(((GateLocation)g.Tag).x, ((GateLocation)g.Tag).y, 0, 0);
}
Point np = new Point(g.Margin.Left, g.Margin.Top);
if (op != np)
moves.Add(new UndoRedo.MoveGate(g, this, op, np));
SizeCanvas();
g.BringIntoView(); // still needed because gate larger than 20px block
}
UpdateWireConnections();
break;
#endregion
case DragState.NONE:
#region Drag State is None
// not dragging
// creating a selection rectangle
if (ReadyToSelect)
{
double x1 = Math.Min(mp2.X, sp.X);
double width = Math.Abs(mp2.X - sp.X);
double y1 = Math.Min(mp2.Y, sp.Y);
double height = Math.Abs(mp2.Y - sp.Y);
dragSelect.Margin = new Thickness(x1, y1, 0, 0);
dragSelect.Width = width;
dragSelect.Height = height;
dragSelect.Visibility = Visibility.Visible;
// select any gates inside the rectangle
Rect select = new Rect(x1, y1, width, height);
foreach (Gate g in gates.Values)
{
Rect grect = new Rect(g.Margin.Left, g.Margin.Top, g.Width, g.Height);
if (select.IntersectsWith(grect) && !g.Selected)
{
g.Selected = true;
selected.Add(g);
}
// this is not the same as just "not" or else the above
if (!select.IntersectsWith(grect) && g.Selected)
{
g.Selected = false;
selected.Remove(g);
//.........这里部分代码省略.........
示例8: uigate_StylusUp
void uigate_StylusUp(object sender, StylusEventArgs e)
{
Point mp2 = e.GetPosition(circuitInkCanvas);
Gate tg = (Gate)sender;
Rect gRect = new Rect(tg.Margin.Left, tg.Margin.Top, tg.Width, tg.Height);
if (dragging == DragState.CONNECT_FROM ||
dragging == DragState.CONNECT_TO)
{
foreach (Gate.TerminalID tid in (Gate)sender)
{
Rect tRect = GetTerminalBounds(tg, gRect, tid);
bool condition = tRect.Contains(mp2);
if(condition)
//if (mp2.X >= tRect.Value.Left - 10 && mp2.X <= tRect.Value.Right + 10
// && mp2.Y >= tRect.Value.Top - 10 && mp2.Y <= tRect.Value.Bottom + 10)
//if (tid.t.IsMouseOver)
{
Gates.Terminal origin = null, dest = null;
if (tid.isInput && dragging == DragState.CONNECT_FROM &&
!wires.ContainsKey(new Gates.Terminal(tid.ID, tid.abgate)))
{
origin = new Gates.Terminal(beginTID.ID, beginTID.abgate);
dest = new Gates.Terminal(tid.ID, tid.abgate);
}
if (!tid.isInput && dragging == DragState.CONNECT_TO)
{
origin = new Gates.Terminal(tid.ID, tid.abgate);
dest = new Gates.Terminal(beginTID.ID, beginTID.abgate);
}
if (origin != null)
{
c[dest] = origin;
UndoRedo.ConnectWire cw = new UndoRedo.ConnectWire(c, origin, dest);
if (UndoProvider != null)
UndoProvider.Add(cw);
}
break;
}
}
}
}
示例9: GetPositionReletiveToContainer
public Point GetPositionReletiveToContainer(StylusEventArgs e, Window win)
{
return e.GetPosition(win);
}
示例10: OnStylusUp
/*
* Expression User Control: No
* TruthTable User Control: No
* Diagram User Control: Yes
*
*/
protected override void OnStylusUp(StylusEventArgs e)
{
base.OnStylusUp(e);
InkQueryRegionStruct removedRegion = null;
foreach (UIElement child in Children)
{
if (child is IPassable)
{
if (child is LogicPad2.TruthTable.UserControl1)
{
#region TruthTable User Control
LogicPad2.TruthTable.UserControl1 truthTableUserControl = child as LogicPad2.TruthTable.UserControl1;
//HitTest
Point pt = e.GetPosition(this);
if (truthTableUserControl.UserControlStatus != UserControlStatus.None)
{
//Check HitTest With Other InkCanvas InkQueryRegionStruct
removedRegion = HitTestInkQueryRegionStruct(truthTableUserControl);
truthTableUserControl.UserControlStatus = UserControlStatus.None;
}
truthTableUserControl.ReleaseStylusCapture();
#endregion
}
else if (child is LogicPad2.Diagram.UserControl1)
{
#region Diagram User Control
LogicPad2.Diagram.UserControl1 diagramUserControl = child as LogicPad2.Diagram.UserControl1;
//HitTest
Point pt = e.GetPosition(this);
if (diagramUserControl.UserControlStatus == UserControlStatus.Scale
|| diagramUserControl.UserControlStatus == UserControlStatus.Transform)
{
//HitTest With Other InkCanvas InkQueryRegionStruct
removedRegion = HitTestInkQueryRegionStruct(diagramUserControl);
}
else if (diagramUserControl.UserControlStatus == UserControlStatus.Inking)
{
//Check HitTest Result on InkCanvas
HitTestResult result = VisualTreeHelper.HitTest(diagramUserControl.DiagramInkCanvas, this.TransformToDescendant(diagramUserControl.DiagramInkCanvas).Transform(pt));
if (result != null)
{
(child as IPassable).StylusUp(this, e);
return;
}
}
diagramUserControl.UserControlStatus = UserControlStatus.None;
diagramUserControl.ReleaseStylusCapture();
#endregion
}
else if (child is LogicPad2.Expression.UserControl1)
{
#region Expression User Control
LogicPad2.Expression.UserControl1 expressionUserControl = child as LogicPad2.Expression.UserControl1;
//HitTest
Point pt = e.GetPosition(this);
if (expressionUserControl.UserControlStatus != UserControlStatus.None)
{
//Check HitTest With Other InkCanvas InkQueryRegionStruct
removedRegion = HitTestInkQueryRegionStruct(expressionUserControl);
expressionUserControl.UserControlStatus = UserControlStatus.None;
}
expressionUserControl.ReleaseStylusCapture();
#endregion
}
else if (child is ExpressionWindow.ExpressionRepresentation)
{
#region Expression Representation
ExpressionWindow.ExpressionRepresentation expressionRepr = child as ExpressionWindow.ExpressionRepresentation;
//HitTest
Point pt = e.GetPosition(this);
if (expressionRepr.UserControlStatus != UserControlStatus.None)
{
expressionRepr.UserControlStatus = UserControlStatus.None;
//.........这里部分代码省略.........
示例11: OnStylusMove
/*
* Expression User Control: No
* TruthTable User Control: No
* Diagram User Control: Yes
*
*/
protected override void OnStylusMove(StylusEventArgs e)
{
base.OnStylusMove(e);
foreach (UIElement child in Children)
{
if (child is IPassable)
{
if (child is LogicPad2.Expression.UserControl1)
{
#region Expression User Control
Point pt = e.GetPosition(this);
LogicPad2.Expression.UserControl1 expressionUserControl = child as LogicPad2.Expression.UserControl1;
//Scale User Control Operation
if (expressionUserControl.UserControlStatus == UserControlStatus.Scale)
{
double newBtmX = pt.X;
expressionUserControl.CaptureStylus();
double scaler = -(expressionUserControl.InitBtmX - newBtmX) / expressionUserControl.ActualWidth;
expressionUserControl.InitBtmX = newBtmX;
expressionUserControl.UserControlScaleX += scaler;
expressionUserControl.UserControlScaleY += scaler;
return;
}
else if (expressionUserControl.UserControlStatus == UserControlStatus.Transform)
{
expressionUserControl.CaptureStylus();
expressionUserControl.UserControlX = e.GetPosition(this).X - expressionUserControl.ActualWidth * expressionUserControl.UserControlScaleX;
expressionUserControl.UserControlY = e.GetPosition(this).Y - expressionUserControl.ActualHeight * expressionUserControl.UserControlScaleY;
return;
}
#endregion
}
else if (child is LogicPad2.TruthTable.UserControl1)
{
#region Truth Table User Control
Point pt = e.GetPosition(this);
LogicPad2.TruthTable.UserControl1 truthTableUserControl = child as LogicPad2.TruthTable.UserControl1;
//Scale User Control Operation
if (truthTableUserControl.UserControlStatus == UserControlStatus.Scale)
{
double newBtmX = pt.X;
truthTableUserControl.CaptureStylus();
double scaler = -(truthTableUserControl.InitBtmX - newBtmX) / truthTableUserControl.ActualWidth;
truthTableUserControl.InitBtmX = newBtmX;
truthTableUserControl.UserControlScaleX += scaler;
truthTableUserControl.UserControlScaleY += scaler;
return;
}
else if (truthTableUserControl.UserControlStatus == UserControlStatus.Transform)
{
truthTableUserControl.CaptureStylus();
truthTableUserControl.UserControlX = e.GetPosition(this).X - truthTableUserControl.ActualWidth * truthTableUserControl.UserControlScaleX;
truthTableUserControl.UserControlY = e.GetPosition(this).Y - truthTableUserControl.ActualHeight * truthTableUserControl.UserControlScaleY;
return;
}
#endregion
}
else if (child is LogicPad2.Diagram.UserControl1)
{
#region Diagram User Control
Point pt = e.GetPosition(this);
LogicPad2.Diagram.UserControl1 diagramUserControl = child as LogicPad2.Diagram.UserControl1;
double newBtmX = pt.X;
double newBtmY = pt.Y;
//Scale User Control Operation
if (diagramUserControl.UserControlStatus == UserControlStatus.Scale)
{
diagramUserControl.CaptureStylus();
double scaler = -(diagramUserControl.InitBtmX - newBtmX) / diagramUserControl.ActualWidth;
diagramUserControl.InitBtmX = newBtmX;
diagramUserControl.UserControlScaleX += scaler;
diagramUserControl.UserControlScaleY += scaler;
return;
}
else if (diagramUserControl.UserControlStatus == UserControlStatus.Transform)
{
diagramUserControl.CaptureStylus();
double deltax = -(diagramUserControl.InitBtmX - newBtmX);
double deltay = -(diagramUserControl.InitBtmY - newBtmY);
//diagramUserControl.UserControlX = e.GetPosition(this).X - diagramUserControl.ActualWidth * diagramUserControl.UserControlScaleX;
//.........这里部分代码省略.........
示例12: OnPreviewStylusMove
/*
* Expression User Control: No
* TruthTable User Control: No
* Diagram User Control: Yes
*
*/
protected override void OnPreviewStylusMove(StylusEventArgs e)
{
base.OnPreviewStylusMove(e);
foreach (UIElement child in Children)
{
if (child is IPassable)
{
if (child is LogicPad2.Diagram.UserControl1)
{
#region Diagram User Control
Point pt = e.GetPosition(this);
HitTestResult result = VisualTreeHelper.HitTest(child, this.TransformToDescendant(child).Transform(pt));
if (result != null)
{
LogicPad2.Diagram.UserControl1 diagramUserControl = child as LogicPad2.Diagram.UserControl1;
if (diagramUserControl.UserControlStatus == UserControlStatus.Inking)
{
#region obsolete code
/*
//Adhoc to hittest
for (int i = 0; i < diagramUserControl.DiagramInkCanvas.Children.Count; i++)
{
UIElement uie = diagramUserControl.DiagramInkCanvas.Children[i];
if (uie is ConnectedWire)
{
result = VisualTreeHelper.HitTest(uie, this.TransformToDescendant(diagramUserControl.DiagramInkCanvas).Transform(pt));
if (result != null)
{
ConnectedWire myWire = uie as ConnectedWire;
if (HitTestWireDict.ContainsKey(myWire))
{
HitTestWireDict[myWire]++;
}
else
{
HitTestWireDict.Add(myWire, 1);
}
if(HitTestWireDict[myWire] == 3)
{
HitTestWireDict.Clear();
Debug.WriteLine("This wire is " + myWire.ToString());
(child as IPassable).PreviewStylusMove(uie, e);
}
Debug.WriteLine("HitTest count " + HitTestWireDict[myWire].ToString());
}
}
}
*/
#endregion
//Check HitTest Result on InkCanvas
result = VisualTreeHelper.HitTest(diagramUserControl.DiagramInkCanvas, this.TransformToDescendant(diagramUserControl.DiagramInkCanvas).Transform(pt));
if (result != null)
{
diagramUserControl.UserControlStatus = UserControlStatus.Inking;
(child as IPassable).PreviewStylusMove(this, e);
return;
}
}
}
#endregion
}
}
}
}
示例13: OnTouchMoveHandler
// Touch move event handler.
private void OnTouchMoveHandler(object sender, StylusEventArgs e)
{
// Find the stroke in the collection of the strokes in drawing.
Stroke stroke;
if (_activeStrokes.TryGetValue(e.StylusDevice.Id, out stroke))
{
// Add contact point to the stroke
stroke.Add(e.GetPosition(_canvas));
stroke.AddToCanvas(_canvas);
}
}
示例14: OnStylusMove
protected override void OnStylusMove(StylusEventArgs e)
{
if(TouchEnabled && Core.IsDragging)
{
if(!isDragging)
{
isDragging = true;
Debug.WriteLine("IsDragging = " + isDragging);
}
if(BoundsOfMap.HasValue && !BoundsOfMap.Value.Contains(Position))
{
// ...
}
else
{
System.Windows.Point p = e.GetPosition(this);
if(MapRenderTransform != null)
{
p = MapRenderTransform.Inverse.Transform(p);
}
p = ApplyRotationInversion(p.X, p.Y);
Core.mouseCurrent.X = (int) p.X;
Core.mouseCurrent.Y = (int) p.Y;
{
Core.Drag(Core.mouseCurrent);
}
if(IsRotated)
{
Core_OnMapZoomChanged();
}
else
{
UpdateMarkersOffset();
}
}
InvalidateVisual();
}
base.OnStylusMove(e);
}
示例15: _adornerLayer_StylusUp
void _adornerLayer_StylusUp(object sender, StylusEventArgs e)
{
Debug.WriteLine(_adorner.AdornerDropState.ToString());
switch (_adorner.AdornerDropState)
{
case DropState.CanDrop:
try
{
((Storyboard)_adorner.Resources["canDrop"]).Completed += (s, args) =>
{
_adornerLayer.Children.Clear();
_adornerLayer.Visibility = Visibility.Collapsed;
};
((Storyboard)_adorner.Resources["canDrop"]).Begin(_adorner);
// Added position in drop target
Point pos = e.GetPosition((IInputElement)_dropTarget);
if (ItemDropped != null)
ItemDropped(_adorner, new DragDropEventArgs(_draggedData, pos, _dropTarget));
}
catch (Exception)
{ }
break;
case DropState.CannotDrop:
try
{
Storyboard sb = _adorner.Resources["cannotDrop"] as Storyboard;
DoubleAnimation aniX = sb.Children[0] as DoubleAnimation;
aniX.To = _delta.X;
DoubleAnimation aniY = sb.Children[1] as DoubleAnimation;
aniY.To = _delta.Y;
sb.Completed += (s, args) =>
{
_adornerLayer.Children.Clear();
_adornerLayer.Visibility = Visibility.Collapsed;
};
sb.Begin(_adorner);
}
catch (Exception) { }
break;
}
_draggedData = null;
//_adornerLayer.PreviewMouseMove -= new MouseEventHandler(_adorner_MouseMove);
//_adornerLayer.PreviewMouseUp -= new MouseButtonEventHandler(_adorner_MouseUp);
_adornerLayer.StylusUp -= new StylusEventHandler(_adornerLayer_StylusUp);
if (_adorner != null)
{
_adorner.ReleaseMouseCapture();
}
_adorner = null;
//_mouseCaptured = false;
_stylusCaptured = false;
}