當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。