本文整理汇总了C#中System.Windows.Media.DrawingVisual.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# DrawingVisual.SetValue方法的具体用法?C# DrawingVisual.SetValue怎么用?C# DrawingVisual.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.DrawingVisual
的用法示例。
在下文中一共展示了DrawingVisual.SetValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public void Draw( EdgeLayout layoutState )
{
var styleState = myPresentation.GetPropertySetFor<EdgeStyle>().Get( Owner.Id );
var stream = new StreamGeometry();
var context = stream.Open();
context.BeginFigure( layoutState.Points.First(), false, false );
context.PolyBezierTo( layoutState.Points.Skip( 1 ).ToList(), true, false );
// draw arrow head
var start = layoutState.Points.Last();
var v = start - layoutState.Points.ElementAt( layoutState.Points.Count() - 2 );
v.Normalize();
start = start - v * 0.15;
context.BeginFigure( start + v * 0.28, true, true );
double t = v.X; v.X = v.Y; v.Y = -t; // Rotate 90°
context.LineTo( start + v * 0.08, true, true );
context.LineTo( start + v * -0.08, true, true );
context.Close();
var pen = new Pen( styleState.Color, 0.016 );
// http://stackoverflow.com/questions/1755520/improve-drawingvisual-renders-speed
Visual = new DrawingVisual();
var dc = Visual.RenderOpen();
dc.DrawGeometry( pen.Brush, pen, stream );
dc.Close();
Visual.SetValue( GraphItemProperty, Owner );
}
示例2: Draw
public void Draw( EdgeLayout layoutState )
{
var styleState = myPresentation.GetPropertySetFor<EdgeStyle>().Get( Owner.Id );
var label = myPresentation.GetPropertySetFor<Caption>().Get( Owner.Id );
var stream = new StreamGeometry();
var context = stream.Open();
context.BeginFigure( layoutState.Points.First(), false, false );
context.PolyBezierTo( layoutState.Points.Skip( 1 ).ToList(), true, false );
// draw arrow head
var start = layoutState.Points.Last();
var v = start - layoutState.Points.ElementAt( layoutState.Points.Count() - 2 );
v.Normalize();
start = start - v * 0.15;
context.BeginFigure( start + v * 0.28, true, true );
double t = v.X; v.X = v.Y; v.Y = -t; // Rotate 90°
context.LineTo( start + v * 0.08, true, true );
context.LineTo( start + v * -0.08, true, true );
context.Close();
var pen = new Pen( styleState.Color, 0.016 );
// http://stackoverflow.com/questions/1755520/improve-drawingvisual-renders-speed
Visual = new DrawingVisual();
var dc = Visual.RenderOpen();
dc.DrawGeometry( pen.Brush, pen, stream );
if( label.DisplayText != label.OwnerId )
{
var sourceLayoutState = myPresentation.GetModule<IGraphLayoutModule>().GetLayout( Owner.Source );
var tx = new FormattedText( label.DisplayText,
CultureInfo.InvariantCulture,
FlowDirection.LeftToRight,
myFont,
sourceLayoutState.Height * 0.5, Brushes.Black );
dc.DrawText( tx, new Point( layoutState.LabelPosition.X - tx.Width, layoutState.LabelPosition.Y - tx.Height ) );
}
dc.Close();
Visual.SetValue( GraphItemProperty, Owner );
}
示例3: Draw
// TODO: we should interpret the shape/style/color attributes ...
public void Draw( NodeLayout layoutState )
{
var style = myPresentation.GetPropertySetFor<NodeStyle>().Get( Owner.Id );
var label = myPresentation.GetPropertySetFor<Caption>().Get( Owner.Id );
Visual = new DrawingVisual();
var dc = Visual.RenderOpen();
dc.DrawEllipse( style.FillColor, new Pen( style.BorderColor, 0.016 ), layoutState.Center, layoutState.Width, layoutState.Height );
var tx = new FormattedText( label.DisplayText,
CultureInfo.InvariantCulture,
FlowDirection.LeftToRight,
myFont,
layoutState.Height * 0.7, Brushes.Black );
dc.DrawText( tx, new Point( layoutState.Center.X - tx.Width / 2, layoutState.Center.Y - tx.Height / 2 ) );
dc.Close();
Visual.SetValue( GraphItemProperty, Owner );
}
示例4: SaveVertexOnDrawingVisual
//*************************************************************************
// Method: SaveVertexOnDrawingVisual()
//
/// <summary>
/// Saves a vertex on the DrawingVisual with which the vertex was drawn.
/// </summary>
///
/// <param name="oVertex">
/// The vertex that was drawn.
/// </param>
///
/// <param name="oDrawingVisual">
/// The DrawingVisual with which <paramref name="oVertex" /> was drawn.
/// </param>
///
/// <remarks>
/// The vertex can be retrieved from the DrawingVisual with <see
/// cref="RetrieveVertexFromDrawingVisual" />.
/// </remarks>
//*************************************************************************
protected void SaveVertexOnDrawingVisual(
IVertex oVertex,
DrawingVisual oDrawingVisual
)
{
Debug.Assert(oVertex != null);
Debug.Assert(oDrawingVisual != null);
AssertValid();
// DrawingVisual has no Tag property, so use FrameworkElement's Tag
// property as an attached property.
oDrawingVisual.SetValue(FrameworkElement.TagProperty, oVertex);
}