本文整理汇总了C#中System.Windows.Ink.Stroke类的典型用法代码示例。如果您正苦于以下问题:C# Stroke类的具体用法?C# Stroke怎么用?C# Stroke使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Stroke类属于System.Windows.Ink命名空间,在下文中一共展示了Stroke类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: MyIP_MouseLeftButtonDown
//A new stroke object named MyStroke is created. MyStroke is added to the StrokeCollection of the InkPresenter named MyIP
private void MyIP_MouseLeftButtonDown(object sender, MouseEventArgs e)
{
MyIP.CaptureMouse();
if (eraseflag == true)
{
StylusPointCollection MyStylusPointCollection = new StylusPointCollection();
MyStylusPointCollection.Add(e.StylusDevice.GetStylusPoints(MyIP));
NewStroke = new Stroke(MyStylusPointCollection);
NewStroke.DrawingAttributes.Color = Colors.Red;
MyIP.Strokes.Add(NewStroke); StylusPointCollection ErasePointCollection = new StylusPointCollection();
}
else
{
StylusPointCollection pointErasePoints = e.StylusDevice.GetStylusPoints(MyIP);
StrokeCollection hitStrokes = MyIP.Strokes.HitTest(pointErasePoints);
if (hitStrokes.Count > 0)
{
foreach (Stroke hitStroke in hitStrokes)
{
MyIP.Strokes.Remove(hitStroke);
//undoStack.Push(hitStroke);
//undoStateBufferStack.Push(true);
}
}
}
}
开发者ID:TinusGreen,项目名称:GendacProjects,代码行数:30,代码来源:MainPage.xaml.cs
示例2: signaturePad_MouseLeftButtonDown
private void signaturePad_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
signaturePad.CaptureMouse();
_currentStroke = new Stroke();
_currentStroke.StylusPoints.Add(GetStylusPoint(e.GetPosition(signaturePad)));
_currentStroke.DrawingAttributes.Color = Colors.Blue;
signaturePad.Strokes.Add(_currentStroke);
}
开发者ID:KerrN,项目名称:IceHockeyTeam,代码行数:8,代码来源:SignatureView.xaml.cs
示例3: TouchPoint2
public TouchPoint2(TouchInfo info, UIElement source, StylusPointCollection stylusPoints)
{
this.Source = source;
Stroke = new Stroke(stylusPoints);
TouchDeviceId = info.TouchDeviceId;
StartTime = DateTime.Now;
UpdateTouchInfo(info);
}
开发者ID:tuliosouza,项目名称:ASG,代码行数:8,代码来源:TouchPoint2.cs
示例4: Stroke_Default_Bounds
public void Stroke_Default_Bounds ()
{
Stroke s = new Stroke ();
Rect bounds = s.GetBounds ();
Assert.AreEqual (-1.5, bounds.Top, "Top");
Assert.AreEqual (-1.5, bounds.Left, "Left");
Assert.AreEqual (3, bounds.Height, "Height");
Assert.AreEqual (3, bounds.Width, "Width");
}
开发者ID:dfr0,项目名称:moon,代码行数:10,代码来源:StrokeTest.cs
示例5: Graph
public Graph(IDelegate _del, Stroke b)
{
del = _del;
box = b;
bounds = box.GetBounds();
box.StylusPoints = InkUtils.xkcd(InkUtils.box(bounds));
box.DrawingAttributes.Color = Colors.Blue;
analyzer = new InkAnalyzer();
analyzer.ContextNodeCreated += ContextNodeCreated;
}
开发者ID:rudi-c,项目名称:htn-stylus,代码行数:10,代码来源:GraphAnalyzer.cs
示例6: Stroke_Default
public void Stroke_Default ()
{
Stroke s = new Stroke ();
Assert.AreEqual (0, s.StylusPoints.Count, "StylusPoints");
Assert.Throws<ArgumentException> (delegate {
s.HitTest (null);
}, "HitTest-null");
Assert.IsFalse (s.HitTest (s.StylusPoints), "HitTest-StylusPoints");
}
开发者ID:dfr0,项目名称:moon,代码行数:11,代码来源:StrokeTest.cs
示例7: ipMouseLeftButtonDown
public void ipMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
myInkPresenter.CaptureMouse();
_stroke = new Stroke(e.StylusDevice.GetStylusPoints(myInkPresenter))
{
DrawingAttributes = {Color = Colors.Blue,
OutlineColor = Colors.White},
};
myInkPresenter.Strokes.Add(_stroke);
}
开发者ID:stiano,项目名称:sl4,代码行数:12,代码来源:Login.xaml.cs
示例8: myInkPresenter_MouseLeftButtonDown
private void myInkPresenter_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
//捕获鼠标焦点
myInkPresenter.CaptureMouse();
myPointCollection = new StylusPointCollection();
myPointCollection.Add(e.StylusDevice.GetStylusPoints(myInkPresenter));
currentStroke = new Stroke(myPointCollection);
//设置画笔属性
currentStroke.DrawingAttributes.Color = currentColor;
currentStroke.DrawingAttributes.Height = sliderThickness.Value;
currentStroke.DrawingAttributes.Width = sliderThickness.Value;
myInkPresenter.Strokes.Add(currentStroke);
}
开发者ID:Tek-Eternal,项目名称:MyInkPresenter,代码行数:13,代码来源:MainPage.xaml.cs
示例9: annotoPenReceiver_PenUp
void annotoPenReceiver_PenUp(object sender, AnnotoPenMotionEventArgs e)
{
Dispatcher.BeginInvoke((Action)delegate()
{
/*if (currentPts == null || currentPts.Count == 0)
{
return;
}
inkCanvas.Strokes.Add(new Stroke(currentPts));
currentPts = new StylusPointCollection();*/
currentStroke = null;
Trace.WriteLine("Pen Up");
}, null);
}
开发者ID:zhuangfangwang,项目名称:ise,代码行数:15,代码来源:AnnotoPenViewer.xaml.cs
示例10: StrokeToString
private string StrokeToString(Stroke stroke)
{
var strokestring = "<stroke>";
strokestring += "<color>" + stroke.DrawingAttributes.Color.ToString() + "</color>";
strokestring += "<size>" + stroke.DrawingAttributes.Height.ToString() + "</size>";
strokestring += "<creator>" + me + "</creator>";
strokestring += "<points>";
foreach (StylusPoint sp in stroke.StylusPoints)
{
strokestring += sp.X + "," + sp.Y + "," + sp.PressureFactor + " ";
}
strokestring.TrimEnd(new char[] { ' ' });
strokestring += "</points>";
strokestring += "</stroke>";
return strokestring;
}
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:16,代码来源:MainPage.xaml.cs
示例11: GetIterator
/// <summary>
/// Helper wrapper
/// </summary>
internal static StrokeNodeIterator GetIterator(Stroke stroke, DrawingAttributes drawingAttributes)
{
if (stroke == null)
{
throw new System.ArgumentNullException("stroke");
}
if (drawingAttributes == null)
{
throw new System.ArgumentNullException("drawingAttributes");
}
StylusPointCollection stylusPoints =
drawingAttributes.FitToCurve ? stroke.GetBezierStylusPoints() : stroke.StylusPoints;
return GetIterator(stylusPoints, drawingAttributes);
}
开发者ID:JianwenSun,项目名称:cc,代码行数:19,代码来源:StrokeNodeEnumerator.cs
示例12: process
public void process(InkAnalyzer inkAnalyzer)
{
ContextNodeCollection nodeCollection = inkAnalyzer.FindLeafNodes();
foreach (ContextNode childNodes in nodeCollection)
{
foreach (Stroke stroke in childNodes.Strokes)
{
if (strokeIsCaret(stroke))
{
insertionBox.Visibility = Visibility.Visible;
Canvas.SetLeft(insertionBox, stroke.StylusPoints[0].X - 140);
Canvas.SetTop(insertionBox, stroke.StylusPoints[1].Y);
inkAnalyzer.RemoveStroke(stroke);
strokeToBeReplaced = stroke;
}
}
}
}
开发者ID:rudi-c,项目名称:htn-stylus,代码行数:18,代码来源:InsertionProcessor.cs
示例13: Update
protected void Update( object sender, EventArgs e )
{
paintCanvas.Strokes.Clear();
windowWidth = (float)this.Width;
windowHeight = (float)this.Height;
Leap.Frame frame = leap.Frame();
InteractionBox interactionBox = leap.Frame().InteractionBox;
foreach ( Pointable pointable in leap.Frame().Pointables ) {
// ここから追加
// 伸びている指、ツール以外は無視する
//if ( !pointable.IsExtended ) {
// continue;
//}
// ここまで追加
Leap.Vector normalizedPosition =
interactionBox.NormalizePoint( pointable.StabilizedTipPosition );
float tx = normalizedPosition.x * windowWidth;
float ty = windowHeight - normalizedPosition.y * windowHeight;
int alpha = 255;
if ( (pointable.TouchDistance > 0 && pointable.TouchZone != Pointable.Zone.ZONENONE ) ) {
alpha = 255 - (int)(255 * pointable.TouchDistance);
touchIndicator.Color = Color.FromArgb( (byte)alpha, 0x0, 0xff, 0x0 );
}
else if ( pointable.TouchDistance <= 0 ) {
alpha = -(int)(255 * pointable.TouchDistance);
touchIndicator.Color = Color.FromArgb( (byte)alpha, 0xff, 0x0, 0x0 );
}
else {
alpha = 50;
touchIndicator.Color = Color.FromArgb( (byte)alpha, 0x0, 0x0, 0xff );
}
StylusPoint touchPoint = new StylusPoint( tx, ty );
StylusPointCollection tips =
new StylusPointCollection( new StylusPoint[] { touchPoint } );
Stroke touchStroke = new Stroke( tips, touchIndicator );
paintCanvas.Strokes.Add( touchStroke );
}
}
开发者ID:kaorun55,项目名称:LeapMotionIntroduction2,代码行数:43,代码来源:MainWindow.xaml.cs
示例14: Stroke_StylusPointCollection
public void Stroke_StylusPointCollection ()
{
StylusPointCollection spc = new StylusPointCollection ();
spc.Add (new StylusPoint (1, 2));
Stroke s = new Stroke (spc);
Assert.AreEqual (1, s.StylusPoints.Count, "StylusPoints-1");
spc.Add (new StylusPoint (3, 4));
Assert.AreEqual (2, s.StylusPoints.Count, "StylusPoints-2");
s.StylusPoints.Add (new StylusPoint (5, 6));
Assert.AreEqual (3, s.StylusPoints.Count, "StylusPoints-3a");
Assert.AreEqual (3, spc.Count, "StylusPoints-3b");
Assert.Throws<ArgumentException> (delegate {
s.HitTest (null);
}, "HitTest-null");
Assert.IsTrue (s.HitTest (s.StylusPoints), "HitTest-StylusPoints");
}
开发者ID:dfr0,项目名称:moon,代码行数:20,代码来源:StrokeTest.cs
示例15: StrokeVisual
/// <summary>
/// Constructor
/// </summary>
/// <param name="stroke">a stroke to render into this visual</param>
/// <param name="renderer">a renderer associated to this visual</param>
internal StrokeVisual(Stroke stroke, Renderer renderer) : base()
{
Debug.Assert(renderer != null);
if (stroke == null)
{
throw new System.ArgumentNullException("stroke");
}
_stroke = stroke;
_renderer = renderer;
// The original value of the color and IsHighlighter are cached so
// when Stroke.Invalidated is fired, Renderer knows whether re-arranging
// the visual tree is needed.
_cachedColor = stroke.DrawingAttributes.Color;
_cachedIsHighlighter = stroke.DrawingAttributes.IsHighlighter;
// Update the visual contents
Update();
}
开发者ID:JianwenSun,项目名称:cc,代码行数:26,代码来源:Renderer.cs
示例16: DecodeStroke
/// <summary>
/// Loads a stroke from the stream based on Stroke Descriptor, StylusPointDescription, Drawing Attributes, Stroke IDs, transform and GuidList
/// </summary>
/// <param name="stream"></param>
/// <param name="size"></param>
/// <param name="guidList"></param>
/// <param name="strokeDescriptor"></param>
/// <param name="stylusPointDescription"></param>
/// <param name="drawingAttributes"></param>
/// <param name="transform"></param>
/// <param name="stroke">Newly decoded stroke</param>
#endif
internal static uint DecodeStroke(Stream stream,
uint size,
GuidList guidList,
StrokeDescriptor strokeDescriptor,
StylusPointDescription stylusPointDescription,
DrawingAttributes drawingAttributes,
Matrix transform,
#if OLD_ISF
Compressor compressor,
#endif
out Stroke stroke)
{
ExtendedPropertyCollection extendedProperties;
StylusPointCollection stylusPoints;
uint cb = DecodeISFIntoStroke(
#if OLD_ISF
compressor,
#endif
stream,
size,
guidList,
strokeDescriptor,
stylusPointDescription,
transform,
out stylusPoints,
out extendedProperties);
if (cb != size)
{
throw new ArgumentException(StrokeCollectionSerializer.ISFDebugMessage("Stroke size (" +
cb.ToString(System.Globalization.CultureInfo.InvariantCulture) + ") != expected (" +
size.ToString(System.Globalization.CultureInfo.InvariantCulture) + ")"));
}
stroke = new Stroke(stylusPoints, drawingAttributes, extendedProperties);
return cb;
}
开发者ID:JianwenSun,项目名称:cc,代码行数:51,代码来源:StrokeSerializer.cs
示例17: ConvertToStrokeCollection
public static StrokeCollection ConvertToStrokeCollection(SerializableStrokeCollection strokeCollection)
{
StrokeCollection resultCollection = new StrokeCollection();
foreach (var stroke in strokeCollection)
{
DrawingAttributes drawingAttr = new DrawingAttributes
{
Color = stroke.DrawingAttributes.Color,
FitToCurve = stroke.DrawingAttributes.FitToCurve,
Height = stroke.DrawingAttributes.Height,
Width = stroke.DrawingAttributes.Width,
IgnorePressure = stroke.DrawingAttributes.IgnorePressure,
IsHighlighter = stroke.DrawingAttributes.IsHighlighter,
StylusTipTransform = stroke.DrawingAttributes.StylusTipTransform
};
switch (stroke.DrawingAttributes.StylusTip)
{
case SerializableDrawingAttributes.StylusTips.Ellipse:
drawingAttr.StylusTip = StylusTip.Ellipse;
break;
case SerializableDrawingAttributes.StylusTips.Rectangle:
drawingAttr.StylusTip = StylusTip.Rectangle;
break;
default:
break;
}
StylusPointCollection spc = new StylusPointCollection();
foreach (var stylusPoint in stroke.StylusPoints)
{
StylusPoint sp = new StylusPoint { X = stylusPoint.X, Y = stylusPoint.Y, PressureFactor = stylusPoint.PressureFactor };
spc.Add(sp);
}
Stroke newStroke = new Stroke(spc);
newStroke.DrawingAttributes = drawingAttr;
resultCollection.Add(newStroke);
}
return resultCollection;
}
开发者ID:tuliosouza,项目名称:ASG,代码行数:39,代码来源:StrokeHelper.cs
示例18: CreatingPage_GetResault
static void CreatingPage_GetResault(PhoneApplicationPage sender, string obj)
{
foreach (ApplicationBarIconButton appBarBtn in (sender as CreatingPage).ApplicationBar.Buttons) {
appBarBtn.IsEnabled = true;
}
if (obj != null) {
StrokePattern newPattern = new StrokePattern();
newPattern.PatternName = obj;
foreach (Stroke stroke in (sender as CreatingPage).inkPresenter.Strokes) {
Stroke modifiedStroke = new Stroke();
modifiedStroke.DrawingAttributes.Color = Colors.White;
modifiedStroke.DrawingAttributes.Width = 3;
modifiedStroke.DrawingAttributes.Height = 3;
foreach (StylusPoint point in stroke.StylusPoints) {
modifiedStroke.StylusPoints.Add(new StylusPoint(point.X / 3, point.Y / 3));
}
newPattern.Items.Add(new StrokeCollection { modifiedStroke });
}
App.PatternViewModel.UserPatterns.Add(newPattern);
sender.NavigationService.GoBack();
}
}
开发者ID:shadowfox3141,项目名称:HuaZhengZi,代码行数:22,代码来源:CreatingPage.xaml.cs
示例19: StrokeOverlayAdorner
public StrokeOverlayAdorner(InkCanvas canvas, Stroke stroke)
: base(canvas)
{
this.stroke = stroke;
}
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:5,代码来源:OverlayAdorner.cs
示例20: CheckRemoveGate
private bool CheckRemoveGate(Stroke stroke)
{
Rect strokeBound = stroke.GetBounds();
bool removeGate = false;
List<Gate> removedGates = new List<Gate>();
for(int i = 0; i < circuitInkCanvas.Children.Count; i++)
{
UIElement gate = circuitInkCanvas.Children[i];
if (gate is Gate)
{
Gate g = gate as Gate;
Rect grect = new Rect(g.Margin.Left + 40, g.Margin.Top + 40, g.Width - 40, g.Height - 40);
if (strokeBound.Contains(grect))
{
//this.RemoveGate(g);
removedGates.Add(g);
removeGate = true;
}
}else if(gate is ConnectedWire)
{
ConnectedWire wire = gate as ConnectedWire;
//Debug.WriteLine("Stroke Rect Bound: " + strokeBound.ToString());
//Debug.WriteLine("Wire Origin is " + wire.Origin.ToString());
//Debug.WriteLine("Wire Destination is " + wire.Destination.ToString());
//Debug.WriteLine("Wire Outer Margin is " + wire.Outer.Margin.ToString());
HitTestResult result = null;
int count = 0;
foreach(StylusPoint pt in stroke.StylusPoints)
{
result = VisualTreeHelper.HitTest(wire, pt.ToPoint());
if(result != null)
{
count++;
}
}
//Debug.WriteLine("Count is " + count.ToString());
if(count >= 3)
{
//trigger remove wire
//From connectedWire to get terminal
Gates.Terminal t = new Gates.Terminal(wire.DestTerminalID.ID, wire.DestinationGate);
c.Disconnect1(t);
circuitInkCanvas.Children.Remove(wire);
/*
for (int j = 0; j < wire.DestinationGate.NumberOfInputs; j++)
{
Gates.Terminal t = new Gates.Terminal(j, wire.DestinationGate);
//Gates.Terminal t = new Gates.Terminal(j, wire.OriginGate);
if (t != null)
{
c.Disconnect1(t);
circuitInkCanvas.Children.Remove(wire);
}
}
*/
removeGate = true;
}
}
}
if(removeGate)
{
foreach (Gate g in removedGates)
{
this.RemoveGate(g);
}
return true;
}
return false;
}
开发者ID:buptkang,项目名称:LogicPad,代码行数:87,代码来源:GateInkCanvas.xaml.cs
注:本文中的System.Windows.Ink.Stroke类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论