本文整理汇总了C#中System.Windows.Ink.DrawingAttributes类的典型用法代码示例。如果您正苦于以下问题:C# DrawingAttributes类的具体用法?C# DrawingAttributes怎么用?C# DrawingAttributes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DrawingAttributes类属于System.Windows.Ink命名空间,在下文中一共展示了DrawingAttributes类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Convert
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
double thickness = (double) value;
DrawingAttributes attr = new DrawingAttributes
{Width = thickness, Height = thickness, FitToCurve = false, Color = Colors.White};
return attr;
}
开发者ID:stewmc,项目名称:vixen,代码行数:7,代码来源:StrokeThicknessToDrawingAttributesConverter.cs
示例2: DrawCore
protected override void DrawCore(DrawingContext drawingContext, DrawingAttributes drawingAttributes)
{
if (drawingContext == null)
{
throw new ArgumentNullException("drawingContext");
}
if (null == drawingAttributes)
{
throw new ArgumentNullException("drawingAttributes");
}
Pen pen = new Pen
{
StartLineCap = PenLineCap.Round,
EndLineCap = PenLineCap.Round,
Brush = new SolidColorBrush(drawingAttributes.Color),
Thickness = drawingAttributes.Width
};
BrushConverter bc = new BrushConverter();
Brush BackGround = (Brush)bc.ConvertFromString(drawingAttributes.GetPropertyData(DrawAttributesGuid.BackgroundColor).ToString());
drawingContext.DrawRectangle(
BackGround,
pen,
new Rect(new Point(StylusPoints[0].X, StylusPoints[0].Y),
new Point(StylusPoints[1].X, StylusPoints[1].Y)));
}
开发者ID:sonicrang,项目名称:RangPaint,代码行数:27,代码来源:RectangleStroke.cs
示例3: OnMouseMove
public override void OnMouseMove(InkCanvas inkCanvas, System.Windows.Input.MouseEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
var p = e.GetPosition(inkCanvas);
if (p != point)
{
point = p;
GetBrush(pts, (s) =>
{
if (StrokeResult != null)
inkCanvas.Strokes.Remove(StrokeResult);
DrawingAttributes drawingAttributes = new DrawingAttributes
{
Color = inkCanvas.DefaultDrawingAttributes.Color,
Width = inkCanvas.DefaultDrawingAttributes.Width,
StylusTip = StylusTip.Ellipse,
IgnorePressure = true,
FitToCurve = true
};
StrokeResult = new BrushStroke(s, drawingAttributes);
inkCanvas.Strokes.Add(StrokeResult);
}
);
}
}
}
开发者ID:sonicrang,项目名称:RangPaint,代码行数:29,代码来源:DrawBrush.cs
示例4: Draw
/// <summary>
/// Render the StrokeCollection under the specified DrawingContext. This draw method uses the
/// passing in drawing attribute to override that on the stroke.
/// </summary>
/// <param name="drawingContext"></param>
/// <param name="drawingAttributes"></param>
public void Draw(DrawingContext drawingContext, DrawingAttributes drawingAttributes)
{
if (null == drawingContext)
{
throw new System.ArgumentNullException("context");
}
if (null == drawingAttributes)
{
throw new System.ArgumentNullException("drawingAttributes");
}
// context.VerifyAccess();
//our code never calls this public API so we can assume that opacity
//has not been set up
if (drawingAttributes.IsHighlighter)
{
drawingContext.PushOpacity(StrokeRenderer.HighlighterOpacity);
try
{
this.DrawInternal(drawingContext, StrokeRenderer.GetHighlighterAttributes(this, this.DrawingAttributes), false);
}
finally
{
drawingContext.Pop();
}
}
else
{
this.DrawInternal(drawingContext, drawingAttributes, false);
}
}
开发者ID:JianwenSun,项目名称:cc,代码行数:40,代码来源:Stroke2.cs
示例5: DrawCore
//Переопределение базового метода, который позволяет рисовать круг, имея координаты центра и радиус
protected override void DrawCore(DrawingContext context, DrawingAttributes overrides)
{
StylusPointCollection points = this.GetBezierStylusPoints();
StylusPoint p1 = points[0];
context.DrawEllipse(new SolidColorBrush(fillColor), new Pen(new SolidColorBrush(strokeColor), thickness), new Point(p1.X, p1.Y), xRadius, yRaduis);
}
开发者ID:Optofizik,项目名称:Graphic-Editor,代码行数:8,代码来源:CircleStroke.cs
示例6: DrawCore
protected override void DrawCore(DrawingContext drawingContext, DrawingAttributes drawingAttributes)
{
if (drawingContext == null)
{
throw new ArgumentNullException("drawingContext");
}
if (null == drawingAttributes)
{
throw new ArgumentNullException("drawingAttributes");
}
Pen pen = new Pen
{
StartLineCap = PenLineCap.Round,
EndLineCap = PenLineCap.Round,
Brush = new SolidColorBrush(drawingAttributes.Color),
Thickness = drawingAttributes.Width
};
BrushConverter bc = new BrushConverter();
Brush BackGround = (Brush)bc.ConvertFromString(drawingAttributes.GetPropertyData(DrawAttributesGuid.BackgroundColor).ToString());
GeometryConverter gc = new GeometryConverter();
Geometry geometry = (Geometry)gc.ConvertFromString(string.Format("M {0},{1} {2},{3} {4},{5} Z", StylusPoints[0].X, StylusPoints[1].Y, (Math.Abs(StylusPoints[1].X - StylusPoints[0].X))/2 + StylusPoints[0].X, StylusPoints[0].Y, StylusPoints[1].X, StylusPoints[1].Y));
GeometryDrawing gd = new GeometryDrawing(BackGround, pen, geometry);
drawingContext.DrawDrawing(gd);
}
开发者ID:sonicrang,项目名称:RangPaint,代码行数:25,代码来源:TriangleStroke.cs
示例7: ToWindowsStroke
public static WindowsInk.Stroke ToWindowsStroke(NineInk.Stroke nineStroke)
{
var points = new StylusPointCollection();
foreach (var point in nineStroke.Points)
points.Add(new StylusPoint(point.X, point.Y, point.Pressure));
var drwAttr = new WindowsInk.DrawingAttributes();
var c = new Color();
c.R = nineStroke.DrawingAttributes.Color.R;
c.G = nineStroke.DrawingAttributes.Color.G;
c.B = nineStroke.DrawingAttributes.Color.B;
c.A = nineStroke.DrawingAttributes.Color.A;
drwAttr.Color = c;
switch (nineStroke.DrawingAttributes.Brush.Name)
{
case "Rectangle":
drwAttr.StylusTip = WindowsInk.StylusTip.Rectangle;
break;
case "Ellipse":
default:
drwAttr.StylusTip = WindowsInk.StylusTip.Ellipse;
break;
}
drwAttr.Height = nineStroke.DrawingAttributes.Height;
drwAttr.Width = nineStroke.DrawingAttributes.Width;
drwAttr.IsHighlighter = nineStroke.DrawingAttributes.IsHighlighter;
return new WindowsInk.Stroke(points, drwAttr);
}
开发者ID:aragoubi,项目名称:Nine,代码行数:31,代码来源:StrokeConverter.cs
示例8: OnMouseMove
public override void OnMouseMove(InkCanvas inkCanvas, System.Windows.Input.MouseEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
endPoint = e.GetPosition(inkCanvas);
if (startPoint != endPoint)
{
StylusPointCollection pts = new StylusPointCollection();
GetLine(pts, (s) =>
{
if (StrokeResult != null)
inkCanvas.Strokes.Remove(StrokeResult);
DrawingAttributes drawingAttributes = new DrawingAttributes
{
Color = inkCanvas.DefaultDrawingAttributes.Color,
Width = inkCanvas.DefaultDrawingAttributes.Width,
StylusTip = StylusTip.Ellipse,
IgnorePressure = true,
FitToCurve = true
};
StrokeResult = new ArrowLineStroke(s, drawingAttributes);
inkCanvas.Strokes.Add(StrokeResult);
}
);
}
}
}
开发者ID:sonicrang,项目名称:RangPaint,代码行数:30,代码来源:DrawArrowLine.cs
示例9: AttachVisuals
//-------------------------------------------------------------------------------
//
// Public Methods
//
//-------------------------------------------------------------------------------
#region Public Methods
/// <summary>
/// AttachVisual method
/// </summary>
/// <param name="visual">The stroke visual which needs to be attached</param>
/// <param name="drawingAttributes">The DrawingAttributes of the stroke</param>
public void AttachVisuals(Visual visual, DrawingAttributes drawingAttributes)
{
VerifyAccess();
EnsureRootVisual();
_renderer.AttachIncrementalRendering(visual, drawingAttributes);
}
开发者ID:JianwenSun,项目名称:cc,代码行数:20,代码来源:InkPresenter.cs
示例10: SetValue
public void SetValue(string value)
{
try
{
if (String.IsNullOrEmpty(value) || !(value.Contains(':'))) return;
var parts = value.Split(new[] { ":" }, StringSplitOptions.RemoveEmptyEntries);
switch (parts[0])
{
case "SetDrawingAttributes":
//This should come in the format of "SetDrawingAttributes:FF FF FF FF:15:false"
if (parts.Count() < 4 || String.IsNullOrEmpty(parts[2]) || String.IsNullOrEmpty(parts[3]) || !(parts[1].Contains(' '))) return;
var ARGBvalues = parts[1].Split(new[] { ' ' });
if (!(ARGBvalues.Count() == 4)) return;
Commands.SetLayer.Execute("sketch");
var color = Color.FromArgb(Byte.Parse(ARGBvalues[0]), Byte.Parse(ARGBvalues[1]), Byte.Parse(ARGBvalues[2]), Byte.Parse(ARGBvalues[3]));
var da = new DrawingAttributes { Color = color, Height = Double.Parse(parts[2]), Width = Double.Parse(parts[2]), IsHighlighter = Boolean.Parse(parts[3]) };
Commands.SetDrawingAttributes.Execute(da);
break;
case "SetInkCanvasMode":
//This should come in the format of "SetInkCanvas:Ink"
if (parts.Count() < 2 || String.IsNullOrEmpty(parts[1]) || !(new []{"Ink","EraseByStroke","Select","None"}.Contains(parts[1]))) return;
Commands.SetInkCanvasMode.Execute(parts[1]);
break;
case "SetLayer":
//This should come in the format of "SetLayer:Sketch"
if (parts.Count() < 2 || String.IsNullOrEmpty(parts[1]) || !(new []{"Select","Sketch","Text","Insert","View"}.Contains(parts[1]))) return;
Commands.SetLayer.Execute(parts[1]);
break;
}
}
catch (Exception e)
{
App.auditor.error("SetValue", "CommandBridgeAutomationPeer", e);
}
}
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:35,代码来源:CommandBridge.xaml.cs
示例11: OnMouseMove
public override void OnMouseMove(System.Windows.Controls.InkCanvas inkCanvas, System.Windows.Input.MouseEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
bottomRight = e.GetPosition(inkCanvas);
if(topLeft != bottomRight)
{
StylusPointCollection pts = new StylusPointCollection();
GetRectangle(pts, (s) =>
{
if (StrokeResult != null)
inkCanvas.Strokes.Remove(StrokeResult);
DrawingAttributes drawingAttributes = new DrawingAttributes
{
Color = inkCanvas.DefaultDrawingAttributes.Color,
Width = inkCanvas.DefaultDrawingAttributes.Width,
StylusTip = StylusTip.Ellipse,
IgnorePressure = true,
FitToCurve = true
};
var BackgroundColor = inkCanvas.DefaultDrawingAttributes.GetPropertyData(DrawAttributesGuid.BackgroundColor);
drawingAttributes.AddPropertyData(DrawAttributesGuid.BackgroundColor, BackgroundColor);
StrokeResult = new RectangleStroke(s, drawingAttributes);
inkCanvas.Strokes.Add(StrokeResult);
}
);
}
}
}
开发者ID:sonicrang,项目名称:RangPaint,代码行数:32,代码来源:DrawRectangle.cs
示例12: GetPenCursor
internal static Cursor GetPenCursor(DrawingAttributes drawingAttributes, bool isHollow, bool isRightToLeft)
{
// Create pen Drawing.
Drawing penDrawing = CreatePenDrawing(drawingAttributes, isHollow, isRightToLeft);
// Create Cursor from Drawing
return CreateCursorFromDrawing(penDrawing, new Point(0, 0));
}
开发者ID:JianwenSun,项目名称:cc,代码行数:8,代码来源:PenCursorManager.cs
示例13: DrawCore
//Переопределение базового метода DrawCore, который позволяет отрисовать линию штрихом, соединяющим заданные точки
protected override void DrawCore(DrawingContext drawingContext, DrawingAttributes drawingAttributes)
{
StylusPointCollection points = this.StylusPoints;
StylusPoint p1 = points[0];
StylusPoint p2 = points[1];
drawingContext.DrawLine(new Pen(new SolidColorBrush(this.strokeColor), this.thickness), (Point)p1, (Point)p2);
}
开发者ID:Optofizik,项目名称:Graphic-Editor,代码行数:10,代码来源:LineStroke.cs
示例14: DrawCore
//Переопредение базового метода, которое позволяет построить прямоугольник, имея левую нижнюю и правую верхнюю вершины
protected override void DrawCore(DrawingContext context, DrawingAttributes overrides)
{
StylusPointCollection points = this.StylusPoints;
StylusPoint p1 = points[0];
StylusPoint p2 = points[1];
context.DrawRectangle(new SolidColorBrush(this.fillColor), new Pen(new SolidColorBrush(this.strokeColor), thickness), new Rect((Point)p1, new Vector(p2.X - p1.X, p2.Y - p1.Y)));
}
开发者ID:Optofizik,项目名称:Graphic-Editor,代码行数:10,代码来源:RectangleStroke.cs
示例15: Convert
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
Brush colorBrush = (Brush) value;
SolidColorBrush newBrush = (SolidColorBrush) colorBrush;
DrawingAttributes attr = new DrawingAttributes()
{
Color = newBrush.Color
};
return attr;
}
开发者ID:stewmc,项目名称:vixen,代码行数:10,代码来源:BrushToDrawingAttributesConverter.cs
示例16: penSize_Click
private void penSize_Click(object sender, RoutedEventArgs e)
{
var rad = sender as RadioButton;
var inkDA = new DrawingAttributes();
inkDA.Width = rad.FontSize;
inkDA.Height = rad.FontSize;
inkDA.Color = InkCanv.DefaultDrawingAttributes.Color;
inkDA.IsHighlighter = InkCanv.DefaultDrawingAttributes.IsHighlighter;
InkCanv.DefaultDrawingAttributes = inkDA;
}
开发者ID:randomgeekdom,项目名称:StorySuite,代码行数:10,代码来源:MapEditorView.xaml.cs
示例17: penSize_Click
private void penSize_Click(object sender, RoutedEventArgs e)
{
RadioButton rad = sender as RadioButton;
var inkDA = new DrawingAttributes();
this.InkCanvas.UsesTouchShape = false;
inkDA.Width = rad.FontSize;
inkDA.Height = rad.FontSize;
inkDA.Color = this.InkCanvas.DefaultDrawingAttributes.Color;
inkDA.IsHighlighter = this.InkCanvas.DefaultDrawingAttributes.IsHighlighter;
this.InkCanvas.DefaultDrawingAttributes = inkDA;
}
开发者ID:gdlprj,项目名称:duscusys,代码行数:11,代码来源:InkPalette.xaml.cs
示例18: generateCursor
public static Cursor generateCursor(DrawingAttributes pen)
{
using (DdMonitor.Lock(lockObject))
{
if (pen == previousPen) return previousCursor;
var color = System.Drawing.Color.FromArgb(pen.Color.A, pen.Color.R, pen.Color.G, pen.Color.B);
previousPen = pen;
previousCursor = CursorHelper.CreateCursor((int)pen.Width, (int)pen.Height, color, (int)(pen.Width / 2), (int)(pen.Height / 2));
return previousCursor;
}
}
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:11,代码来源:CursorExtensions.cs
示例19: CreateDefaultValue
/// <summary>
/// Creates a mutable default value
/// </summary>
internal override object CreateDefaultValue(DependencyObject owner, DependencyProperty property)
{
// Instantiate our default value instance.
DrawingAttributes defaultValue = new DrawingAttributes();
// Add event handlers for tracking the changes on the default value instance.
DrawingAttributesDefaultPromoter promoter = new DrawingAttributesDefaultPromoter((InkCanvas)owner);
defaultValue.AttributeChanged += new PropertyDataChangedEventHandler(promoter.OnDrawingAttributesChanged);
defaultValue.PropertyDataChanged += new PropertyDataChangedEventHandler(promoter.OnDrawingAttributesChanged);
return defaultValue;
}
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:16,代码来源:DrawingAttributesDefaultValueFactory.cs
示例20: CreateBrush
/// <summary>
/// Create a new Brush
/// </summary>
/// <param name="brushColor">The color of the brush</param>
/// <param name="brushSize">The width and height of the brush</param>
/// <returns></returns>
public DrawingAttributes CreateBrush(Color brushColor, double brushSize)
{
DrawingAttributes newDA = new DrawingAttributes();
newDA.Color = brushColor;
newDA.IsHighlighter = false;
newDA.IgnorePressure = true;
newDA.StylusTip = StylusTip.Ellipse;
newDA.Height = brushSize;
newDA.Width = brushSize;
return newDA;
}
开发者ID:WillVandergrift,项目名称:SketchIt,代码行数:19,代码来源:DrawingToolsHelper.cs
注:本文中的System.Windows.Ink.DrawingAttributes类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论