本文整理汇总了C#中StrokeCollection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# StrokeCollection.Add方法的具体用法?C# StrokeCollection.Add怎么用?C# StrokeCollection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StrokeCollection
的用法示例。
在下文中一共展示了StrokeCollection.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Representation
public StrokeCollection Representation()
{
StrokeCollection strokes = new StrokeCollection();
foreach (var data in stylusStrokes)
strokes.Add(data.Representation());
return strokes;
}
示例2: RefreshPattern
public void RefreshPattern()
{
if (Pattern != null) {
StrokeCollection collection = new StrokeCollection();
for (int i = 0; i < Count; i++) {
foreach (var stroke in Pattern[i]) {
collection.Add(stroke);
}
}
inkPresenter.Strokes = collection;
}
}
示例3: GetStrokeCollectionFromPoints
private StrokeCollection GetStrokeCollectionFromPoints(dynamic strokePoints)
{
var strokeCollection = new StrokeCollection();
foreach (var stroke in strokePoints.Strokes)
{
var points = new StylusPointCollection();
foreach (var point in stroke.Points)
{
var x = (float)point.X;
var y = (float)point.Y;
points.Add(new StylusPoint(x, y));
}
strokeCollection.Add(new Stroke(points));
}
return strokeCollection;
}
示例4: Erase
/// <summary>
///
/// </summary>
/// <param name="cutAt">Fragment markers for clipping</param>
/// <returns>Survived fragments of current Stroke as a StrokeCollection</returns>
private StrokeCollection Erase(StrokeFIndices[] cutAt)
{
System.Diagnostics.Debug.Assert(cutAt != null);
System.Diagnostics.Debug.Assert(cutAt.Length != 0);
#if DEBUG
//
// Assert there are no overlaps between multiple StrokeFIndices
//
AssertSortedNoOverlap(cutAt);
#endif
StrokeCollection leftovers = new StrokeCollection();
// Return an empty collection if the entire stroke it to erase
if ((cutAt.Length == 0) || ((cutAt.Length == 1) && cutAt[0].IsFull))
{
return leftovers;
}
StylusPointCollection sourceStylusPoints = this.StylusPoints;
if (this.DrawingAttributes.FitToCurve)
{
sourceStylusPoints = this.GetBezierStylusPoints();
}
//
// Assert the findices are NOT out of range with the packets
//
System.Diagnostics.Debug.Assert(false == ((!DoubleUtil.AreClose(cutAt[cutAt.Length - 1].EndFIndex, StrokeFIndices.AfterLast)) &&
Math.Ceiling(cutAt[cutAt.Length - 1].EndFIndex) > sourceStylusPoints.Count - 1));
int i = 0;
double beginFIndex = StrokeFIndices.BeforeFirst;
if (cutAt[0].BeginFIndex == StrokeFIndices.BeforeFirst)
{
beginFIndex = cutAt[0].EndFIndex;
i++;
}
for (; i < cutAt.Length; i++)
{
StrokeFIndices fragment = cutAt[i];
if(DoubleUtil.GreaterThanOrClose(beginFIndex, fragment.BeginFIndex))
{
// ISSUE-2004/06/26-vsmirnov - temporary workaround for bugs
// in point erasing: drop invalid fragments
System.Diagnostics.Debug.Assert(DoubleUtil.LessThan(beginFIndex, fragment.BeginFIndex));
continue;
}
Stroke stroke = Copy(sourceStylusPoints, beginFIndex, fragment.BeginFIndex);
// Add the stroke to the output collection
leftovers.Add(stroke);
beginFIndex = fragment.EndFIndex;
}
if (beginFIndex != StrokeFIndices.AfterLast)
{
Stroke stroke = Copy(sourceStylusPoints, beginFIndex, StrokeFIndices.AfterLast);
// Add the stroke to the output collection
leftovers.Add(stroke);
}
return leftovers;
}
示例5: resizeSelectedObjects
private void resizeSelectedObjects(Rect oldSelection, Rect newSelection)
{
var removingStrokes = new StrokeCollection();
replacementStrokes.Clear();
double WidthFactor = 1;
double HeightFactor = 1;
if (oldSelection.Width != newSelection.Width)
WidthFactor = newSelection.Width / oldSelection.Width;
if (oldSelection.Height != newSelection.Height)
HeightFactor = newSelection.Height / oldSelection.Height;
removeStylingFromStrokes();
foreach (Stroke stroke in referencedStrokes)
{
var newSpc = new StylusPointCollection();
foreach (StylusPoint sp in stroke.StylusPoints)
{
var newSp = new StylusPoint();
newSp.X = ((sp.X - oldSelection.X) * WidthFactor) + newSelection.X;
newSp.Y = ((sp.Y - oldSelection.Y) * HeightFactor) + newSelection.Y;
newSp.PressureFactor = sp.PressureFactor;
newSpc.Add(newSp);
}
var newStroke = new Stroke(newSpc);
newStroke.DrawingAttributes.Color = stroke.DrawingAttributes.Color;
newStroke.DrawingAttributes.OutlineColor = stroke.DrawingAttributes.OutlineColor;
newStroke.DrawingAttributes.Height = stroke.DrawingAttributes.Height;
newStroke.DrawingAttributes.Width = stroke.DrawingAttributes.Width;
removingStrokes.Add(stroke);
replacementStrokes.Add(newStroke);
referencedCanvas.Strokes.Remove(stroke);
referencedCanvas.Strokes.Add(newStroke);
}
referencedCanvas.eventHandler_ReplaceStrokes(removingStrokes, replacementStrokes);
referencedCanvas.eventHandler_ReplaceSelectedStrokes(removingStrokes, replacementStrokes);
referencedStrokes.Clear();
foreach (Stroke stroke in replacementStrokes)
referencedStrokes.Add(stroke);
setupSelectionAdorner();
}
示例6: MainWindow
public MainWindow()
{
InitializeComponent();
client = ClientFactory.Connection(MeTLServerAddress.serverMode.STAGING);
client.events.StatusChanged += (sender, args) => { Dispatcher.adoptAsync(() => { if (args.isConnected)setup(); }); };
client.events.StrokeAvailable += (sender, args) => { Dispatcher.adoptAsync(() => inkCanvas.Strokes.Add(args.stroke.stroke)); };
client.events.DirtyStrokeAvailable += (sender, args) =>
{
Dispatcher.adoptAsync(() =>
{
var strokesToRemove = new StrokeCollection();
for (int i = 0; i < inkCanvas.Strokes.Count; i++)
{
var child = inkCanvas.Strokes[i];
if (child is Stroke && ((Stroke)child).startingSum().ToString() == args.dirtyElement.identifier)
strokesToRemove.Add(inkCanvas.Strokes[i]);
}
foreach (Stroke removedStroke in strokesToRemove)
inkCanvas.Strokes.Remove(removedStroke);
;
});
};
client.events.TextBoxAvailable += (sender, args) =>
{
Dispatcher.adoptAsync(() =>
{
var box = args.textBox.box;
box.Background = Brushes.Transparent;
box.BorderBrush = Brushes.Transparent;
box.BorderThickness = new Thickness(0);
inkCanvas.Children.Add(box);
});
};
client.events.DirtyTextBoxAvailable += (sender, args) =>
{
Dispatcher.adoptAsync(() =>
{
for (int i = 0; i < inkCanvas.Children.Count; i++)
{
var child = inkCanvas.Children[i];
if (child is TextBox && ((TextBox)child).tag().id == args.dirtyElement.identifier)
inkCanvas.Children.Remove(inkCanvas.Children[i]);
}
;
});
};
client.events.ImageAvailable += (sender, args) => { Dispatcher.adoptAsync(() => inkCanvas.Children.Add(args.image.image)); };
client.events.DirtyImageAvailable += (sender, args) =>
{
Dispatcher.adoptAsync(() =>
{
for (int i = 0; i < inkCanvas.Children.Count; i++)
{
var child = inkCanvas.Children[i];
if (child is Image && ((Image)child).tag().id == args.dirtyElement.identifier)
inkCanvas.Children.Remove(inkCanvas.Children[i]);
}
;
});
};
client.events.VideoAvailable += (sender, args) =>
{
Dispatcher.adoptAsync(() =>
{
var me = args.video.video.MediaElement;
me.LoadedBehavior = MediaState.Play;
Canvas.SetLeft(me, args.video.X);
Canvas.SetTop(me, args.video.Y);
me.Width = args.video.Width;
me.Height = args.video.Height;
inkCanvas.Children.Add(me);
});
};
client.events.PreParserAvailable += (sender, args) =>
{
Dispatcher.adoptAsync(() =>
{
var parser = ((PreParser)args.parser);
foreach (TargettedVideo video in parser.videos.Values)
{
var me = video.video.MediaElement;
me.LoadedBehavior = MediaState.Play;
Canvas.SetLeft(me, video.video.X);
Canvas.SetTop(me, video.video.Y);
me.Width = video.video.Width;
me.Height = video.video.Height;
inkCanvas.Children.Add(me);
}
foreach (TargettedImage image in parser.images.Values)
inkCanvas.Children.Add(image.image);
foreach (TargettedTextBox textBox in parser.text.Values)
inkCanvas.Children.Add(textBox.box);
foreach (TargettedStroke stroke in parser.ink)
inkCanvas.Strokes.Add(stroke.stroke);
});
};
client.events.FileAvailable += (sender, args) =>
{
var a = sender;
var b = args;
//.........这里部分代码省略.........
示例7: GetStrokeCollection
public StrokeCollection GetStrokeCollection(int count = HighestCount)
{
StrokeCollection strokeCollection = new StrokeCollection();
for (int i = 0; i < count; i++) {
foreach (Stroke stroke in Items[i]) {
strokeCollection.Add(stroke);
}
}
return strokeCollection;
}
示例8: GetStrokesForString
// Generates a collection of strokes representing an entire word.
StrokeCollection GetStrokesForString(string text,
Dictionary<char, StylusToken> fontData)
{
double currentX = 0.0;
StrokeCollection stringStrokes = new StrokeCollection();
for (int i = 0; i < text.Length; i++)
{
char c = text[i];
if (fontData.Keys.Contains(c))
{
StylusToken token = fontData[c];
double kerningLeft = 2.0;
if (i > 0 && Char.ToLower(text[i - 1]) == text[i - 1] &&
Char.ToLower(c) == c)
kerningLeft += token.width * 0.14;
double kerningRight = 2.0;
if (i < text.Length - 1 && Char.ToLower(text[i + 1]) == text[i + 1] &&
Char.ToLower(c) == c)
kerningRight += token.width * 0.14;
foreach (Stroke stroke in token.strokes)
{
StylusPointCollection newPoints = new StylusPointCollection();
foreach (StylusPoint point in stroke.StylusPoints)
{
newPoints.Add(new StylusPoint(
point.X + currentX + kerningLeft, point.Y));
}
stringStrokes.Add(new Stroke(newPoints));
}
currentX += token.width + kerningLeft + kerningRight;
}
}
return stringStrokes;
}
示例9: OnStrokeStylusPointsChanged
private void OnStrokeStylusPointsChanged(object sender, EventArgs e)
{
Stroke changedStroke = (Stroke)sender;
//a stroke's StylusPoints have changed we need to find
//all affected contextNodes's and mark the dirty region with them
StrokeCollection strokesThatChanged = new StrokeCollection();
strokesThatChanged.Add(changedStroke);
ContextNodeCollection dirtyNodes =
circuitInkCanvas.InkAnalyzer.FindInkLeafNodes(strokesThatChanged);
foreach (ContextNode dirtyNode in dirtyNodes)
{
//let the analyzer know that where the stroke previously
//existed is now dirty
circuitInkCanvas.InkAnalyzer.DirtyRegion.Union(dirtyNode.Location.GetBounds());
}
//let the analyzer know that the stroke data is no longer valid
circuitInkCanvas.InkAnalyzer.ClearStrokeData(changedStroke);
//finally, make the region where the stroke now exists dirty also
circuitInkCanvas.InkAnalyzer.DirtyRegion.Union(changedStroke.GetBounds());
circuitInkCanvas.InkAnalyzer.BackgroundAnalyze();
}
示例10: OnClipboardPaste
public void OnClipboardPaste()
{
var strokesBeforePaste = Strokes.Select(s => s).ToList();
Paste();
var newStrokes = Strokes.Where(s => !strokesBeforePaste.Contains(s)).ToList();
var selection = new StrokeCollection();
ClearAdorners();
foreach (var stroke in newStrokes)
{
selection.Add(stroke);
doMyStrokeAdded(stroke, stroke.tag().privacy);
}
if(EditingMode == InkCanvasEditingMode.Select)
Select(selection);
addAdorners();
}
示例11: InkCanvas_StrokeErasing
private void InkCanvas_StrokeErasing(object sender, InkCanvasStrokeErasingEventArgs e)
{
if (ThisAddIn.instance.wire.isConnected && ThisAddIn.instance.wire.isInConversation)
ThisAddIn.instance.wire.sendRawDirtyStroke(e.Stroke);
InkCanvas source = (InkCanvas)sender;
strokeCollectionsForSlides[lastSlide].Remove(e.Stroke);
foreach (InkCanvas canvas in ActiveCanvasses)
if (canvas != source)
{
detachInkCanvasHandlers(canvas);
var StrokesToRemove = new StrokeCollection();
foreach (Stroke s in canvas.Strokes)
if (e.Stroke.sum().checksum.ToString().Equals(s.sum().checksum.ToString()))
StrokesToRemove.Add(s);
canvas.Strokes.Remove(StrokesToRemove);
attachInkCanvasHandlers(canvas);
}
}
示例12: Erase
/// <summary>
/// Calculate the after-erasing Strokes. Only the "out-segments" are left after this operation.
/// </summary>
/// <param name="cutAt">Array of intersections indicating the erasing locations</param>
/// <returns></returns>
internal StrokeCollection Erase(StrokeIntersection[] cutAt)
{
System.Diagnostics.Debug.Assert(cutAt != null);
// Nothing needs to be erased
if(cutAt.Length == 0)
{
StrokeCollection strokes = new StrokeCollection();
strokes.Add(this.Clone()); //clip and erase always return clones for this condition
return strokes;
}
// Two assertions are deferred to the private erase function to avoid duplicate code.
// 1. AssertSortedNoOverlap
// 2. Check whether the insegments are out of range with the packets
StrokeFIndices[] hitSegments = StrokeIntersection.GetHitSegments(cutAt);
return this.Erase(hitSegments);
}
示例13: CopySelectedData
internal InkCanvasClipboardDataFormats CopySelectedData(IDataObject dataObject)
{
InkCanvasClipboardDataFormats copiedDataFormat = InkCanvasClipboardDataFormats.None;
InkCanvasSelection inkCanvasSelection = InkCanvas.InkCanvasSelection;
StrokeCollection strokes = inkCanvasSelection.SelectedStrokes;
if (strokes.Count > 1)
{
// NTRAID#WINDOWS-1541633-2006/03/03-SAMGEO,
// order the strokes so they are in the correct z-order
// they appear in on the InkCanvas, or else they will be inconsistent
// if copied / pasted
StrokeCollection orderedStrokes = new StrokeCollection();
StrokeCollection inkCanvasStrokes = InkCanvas.Strokes; //cache to avoid multiple property gets
for (int i = 0; i < inkCanvasStrokes.Count && strokes.Count != orderedStrokes.Count; i++)
{
for (int j = 0; j < strokes.Count; j++)
{
if (inkCanvasStrokes[i] == strokes[j])
{
orderedStrokes.Add(strokes[j]);
break;
}
}
}
Debug.Assert(inkCanvasSelection.SelectedStrokes.Count == orderedStrokes.Count);
//Make a copy collection since we will alter the transform before copying the data.
strokes = orderedStrokes.Clone();
}
else
{
//we only have zero or one stroke so we don't need to order, but we
//do need to clone.
strokes = strokes.Clone();
}
List<UIElement> elements = new List<UIElement>(inkCanvasSelection.SelectedElements);
Rect bounds = inkCanvasSelection.SelectionBounds;
// Now copy the selection in the below orders.
if ( strokes.Count != 0 || elements.Count != 0 )
{
// NTRAID-WINDOWS#1412097-2005/12/08-WAYNEZEN,
// The selection should be translated to the origin (0, 0) related to its bounds.
// Get the translate transform as a relative bounds.
Matrix transform = Matrix.Identity;
transform.OffsetX = -bounds.Left;
transform.OffsetY = -bounds.Top;
// Add ISF data first.
if ( strokes.Count != 0 )
{
// Transform the strokes first.
inkCanvasSelection.TransformStrokes(strokes, transform);
ClipboardData data = new ISFClipboardData(strokes);
data.CopyToDataObject(dataObject);
copiedDataFormat |= InkCanvasClipboardDataFormats.ISF;
}
// Then add XAML data.
if ( CopySelectionInXAML(dataObject, strokes, elements, transform, bounds.Size) )
{
// We have to create an InkCanvas as a container and add all the selection to it.
copiedDataFormat |= InkCanvasClipboardDataFormats.XAML;
}
}
else
{
Debug.Assert(false , "CopySelectData: InkCanvas should have a selection!");
}
return copiedDataFormat;
}
示例14: mnTest_Click
private void mnTest_Click(object sender, RoutedEventArgs e)
{
Console.WriteLine("Test...");
Console.WriteLine("Strokes");
StrokeCollection strokeColl = new StrokeCollection();
String boardText = this.tbBoard.Text;
List<UIElement> uiColl = new List<UIElement>();
foreach (Stroke item in this.inkBoard.Strokes)
{
strokeColl.Add(item.Clone());
Console.WriteLine("Ink:\t{0}", item.GetHashCode());
}
foreach (UIElement item in this.inkBoard.Children)
{
if(item is BoardTextBox){ continue; }
Console.WriteLine("Coll:\t{0}", item.GetHashCode());
}
Console.Write("Очистить...");
this.inkBoard.Strokes.Clear();
this.tbBoard.Text = "";
Console.WriteLine("Обновить");
this.inkBoard.Strokes = strokeColl;
}
示例15: 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;
}