当前位置: 首页>>代码示例>>C#>>正文


C# DrawingVisual.SetValue方法代码示例

本文整理汇总了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 );
        }
开发者ID:mwidmeyer,项目名称:Plainion.GraphViz,代码行数:33,代码来源:EdgeVisual.cs

示例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 );
        }
开发者ID:JackWangCUMT,项目名称:Plainion.GraphViz,代码行数:48,代码来源:EdgeVisual.cs

示例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 );
        }
开发者ID:JackWangCUMT,项目名称:Plainion.GraphViz,代码行数:23,代码来源:NodeVisual.cs

示例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);
        }
开发者ID:haisreekanth,项目名称:NetMap,代码行数:34,代码来源:GraphDrawer.cs


注:本文中的System.Windows.Media.DrawingVisual.SetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。