本文整理汇总了C#中System.Windows.Ink.DrawingAttributes.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# DrawingAttributes.Clone方法的具体用法?C# DrawingAttributes.Clone怎么用?C# DrawingAttributes.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Ink.DrawingAttributes
的用法示例。
在下文中一共展示了DrawingAttributes.Clone方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetDrawingAttributes
private void SetDrawingAttributes(DrawingAttributes logicalAttributes)
{
if (logicalAttributes == null) return;
if (me.ToLower() == "projector") return;
var zoomCompensatedAttributes = logicalAttributes.Clone();
try
{
zoomCompensatedAttributes.Width = logicalAttributes.Width * zoom;
zoomCompensatedAttributes.Height = logicalAttributes.Height * zoom;
var visualAttributes = logicalAttributes.Clone();
visualAttributes.Width = logicalAttributes.Width * 2;
visualAttributes.Height = logicalAttributes.Height * 2;
UseCustomCursor = true;
Cursor = CursorExtensions.generateCursor(visualAttributes);
}
catch (Exception e) {
Trace.TraceInformation("Cursor failed (no crash):", e.Message);
}
DefaultDrawingAttributes = zoomCompensatedAttributes;
}
示例2: StrokeInfo
DynamicRendererHostVisual _strokeHV; // App thread rendering HostVisual
public StrokeInfo(DrawingAttributes drawingAttributes, int stylusDeviceId, int startTimestamp, DynamicRendererHostVisual hostVisual)
{
_stylusId = stylusDeviceId;
_startTime = startTimestamp;
_lastTime = _startTime;
_drawingAttributes = drawingAttributes.Clone(); // stroke copy for duration of stroke.
_strokeNodeIterator = new StrokeNodeIterator(_drawingAttributes);
Color color = _drawingAttributes.Color;
_opacity = _drawingAttributes.IsHighlighter ? 0 : (double)color.A / (double)StrokeRenderer.SolidStrokeAlpha;
color.A = StrokeRenderer.SolidStrokeAlpha;
// Set the brush to be used with this new stroke too (since frozen can be shared by threads)
SolidColorBrush brush = new SolidColorBrush(color);
brush.Freeze();
_fillBrush = brush;
_strokeHV = hostVisual;
hostVisual.AddStrokeInfoRef(this); // Add ourselves as reference.
}
示例3: DrawCore
protected override void DrawCore(DrawingContext drawingContext, DrawingAttributes drawingAttributes)
{
if (drawingContext == null)
{
throw new ArgumentNullException("drawingContext");
}
if (null == drawingAttributes)
{
throw new ArgumentNullException("drawingAttributes");
}
DrawingAttributes originalDa = drawingAttributes.Clone();
originalDa.Width = this.size;
originalDa.Height = this.size;
//ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(@"test3.png", UriKind.Relative)));
string path = "pack://application:,,,/Resources/ColorBrush/BColor_" + color + ".png";
ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(path, UriKind.RelativeOrAbsolute)));
brush.Freeze();
drawingContext.DrawGeometry(brush, null, this.GetGeometry(originalDa));
}
示例4: DrawCore
/// <summary>
/// The core functionality to draw a stroke. The function can be called from the following code paths.
/// i) From StrokeVisual.OnRender
/// a. Highlighter strokes have been grouped and the correct opacity has been set on the container visual.
/// b. For a highlighter stroke with color.A != 255, the DA passed in is a copy with color.A set to 255.
/// c. _drawAsHollow can be true, i.e., Selected stroke is drawn as hollow
/// ii) From StrokeCollection.Draw.
/// a. Highlighter strokes have been grouped and the correct opacity has been pushed.
/// b. For a highlighter stroke with color.A != 255, the DA passed in is a copy with color.A set to 255.
/// c. _drawAsHollow is always false, i.e., Selected stroke is not drawn as hollow
/// iii) From Stroke.Draw
/// a. The correct opacity has been pushed for a highlighter stroke
/// b. For a highlighter stroke with color.A != 255, the DA passed in is a copy with color.A set to 255.
/// c. _drawAsHollow is always false, i.e., Selected stroke is not drawn as hollow
/// We need to document the following:
/// 1) our default implementation so developers can see what we've done here -
/// including how we handle IsHollow
/// 2) the fact that opacity has already been set up correctly for the call.
/// 3) that developers should not call base.DrawCore if they override this
/// </summary>
/// <param name="drawingContext">DrawingContext to draw on</param>
/// <param name="drawingAttributes">DrawingAttributes to draw with</param>
protected virtual void DrawCore(DrawingContext drawingContext, DrawingAttributes drawingAttributes)
{
if (null == drawingContext)
{
throw new System.ArgumentNullException("drawingContext");
}
if (null == drawingAttributes)
{
throw new System.ArgumentNullException("drawingAttributes");
}
if (_drawAsHollow == true)
{
// Draw as hollow. Our profiler result shows that the two-pass-rendering approach is about 5 times
// faster that using GetOutlinePathGeometry.
// also, the minimum display size for selected ink is our default width / height
Matrix innerTransform, outerTransform;
DrawingAttributes selectedDA = drawingAttributes.Clone();
selectedDA.Height = Math.Max(selectedDA.Height, DrawingAttributes.DefaultHeight);
selectedDA.Width = Math.Max(selectedDA.Width, DrawingAttributes.DefaultWidth);
CalcHollowTransforms(selectedDA, out innerTransform, out outerTransform);
// First pass drawing. Use drawingAttributes.Color to create a solid color brush. The stroke will be drawn as
// 1 avalon-unit higher and wider (HollowLineSize = 1.0f)
selectedDA.StylusTipTransform = outerTransform;
SolidColorBrush brush = new SolidColorBrush(drawingAttributes.Color);
brush.Freeze();
drawingContext.DrawGeometry(brush, null, GetGeometry(selectedDA));
//Second pass drawing with a white color brush. The stroke will be drawn as
// 1 avalon-unit shorter and narrower (HollowLineSize = 1.0f) if the actual-width/height (considering StylusTipTransform)
// is larger than HollowLineSize. Otherwise the same size stroke is drawn.
selectedDA.StylusTipTransform = innerTransform;
drawingContext.DrawGeometry(Brushes.White, null, GetGeometry(selectedDA));
}
else
{
#if DEBUG_RENDERING_FEEDBACK
//render debug feedback?
Guid guid = new Guid("52053C24-CBDD-4547-AAA1-DEFEBF7FD1E1");
if (this.ContainsPropertyData(guid))
{
double thickness = (double)this.GetPropertyData(guid);
//first, draw the outline of the stroke
drawingContext.DrawGeometry(null,
new Pen(Brushes.Black, thickness),
GetGeometry());
Geometry g2;
Rect b2;
//next, overlay the connecting quad points
StrokeRenderer.CalcGeometryAndBounds(StrokeNodeIterator.GetIterator(this, drawingAttributes),
drawingAttributes,
drawingContext, thickness, true,
true, //calc bounds
out g2,
out b2);
}
else
{
#endif
SolidColorBrush brush = new SolidColorBrush(drawingAttributes.Color);
brush.Freeze();
drawingContext.DrawGeometry(brush, null, GetGeometry(drawingAttributes));
#if DEBUG_RENDERING_FEEDBACK
}
#endif
}
}