當前位置: 首頁>>代碼示例>>C#>>正文


C# DrawingContext.PushTransform方法代碼示例

本文整理匯總了C#中System.Windows.Media.DrawingContext.PushTransform方法的典型用法代碼示例。如果您正苦於以下問題:C# DrawingContext.PushTransform方法的具體用法?C# DrawingContext.PushTransform怎麽用?C# DrawingContext.PushTransform使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Media.DrawingContext的用法示例。


在下文中一共展示了DrawingContext.PushTransform方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: OnRender

 protected override void OnRender(DrawingContext drawingContext)
 {
     base.OnRender(drawingContext);
     drawingContext.PushTransform(new TranslateTransform(AdornedElement.RenderSize.Width - 14, (AdornedElement.RenderSize.Height - 18) / 2.0));
     drawingContext.DrawGeometry(ArrowBrush, null, sda_render_geometry);
     drawingContext.Pop();
 }
開發者ID:WilliamCopland,項目名稱:YPILIS,代碼行數:7,代碼來源:SortDirectionAdorner.cs

示例2: OnRender

        protected override void OnRender(DrawingContext dc)
        {
            Point pos, tangent;
            double angleInRadians;
            double angleInDegrees;
            TransformGroup tg;
            Pen pen = new Pen(Stroke, StrokeThickness);
            //dc.DrawGeometry(null, pen, LinePath);
            if (BeginCap != null)
            {

                LinePath.GetPointAtFractionLength(0.01d, out pos, out tangent);
                angleInRadians = Math.Atan2(tangent.Y, tangent.X) + Math.PI;
                angleInDegrees = angleInRadians * 180 / Math.PI + 180;
                tg = new TransformGroup();
                tg.Children.Add(new RotateTransform(angleInDegrees));
                LinePath.GetPointAtFractionLength(0.0d, out pos, out tangent);
                tg.Children.Add(new TranslateTransform(pos.X, pos.Y));
                dc.PushTransform(tg);
                dc.DrawGeometry(Brushes.DeepPink, pen, BeginCap);
                dc.Pop();
            }
            if (EndCap != null)
            {
                LinePath.GetPointAtFractionLength(0.99, out pos, out tangent);
                angleInRadians = Math.Atan2(tangent.Y, tangent.X) + Math.PI;
                angleInDegrees = angleInRadians * 180 / Math.PI;
                tg = new TransformGroup();
                tg.Children.Add(new RotateTransform(angleInDegrees));
                LinePath.GetPointAtFractionLength(1, out pos, out tangent);
                tg.Children.Add(new TranslateTransform(pos.X, pos.Y));
                dc.PushTransform(tg);
                dc.DrawGeometry(Brushes.DeepPink, pen, EndCap);
            }
        }
開發者ID:keithgemeinhart,項目名稱:ArcGis.Wpf.ArrowheadDemo,代碼行數:35,代碼來源:CappedLine.cs

示例3: drawLimb

		public void drawLimb(DrawingContext dc, Point p1, Point p2, int margin)
		{

			dc.PushTransform(new TranslateTransform(p1.X, p1.Y));
			
			Vector diff = p2 - p1;
			diff.Normalize();

			double angle = Math.Acos(diff.Y) * (180.0 / Math.PI);
			if (Double.IsNaN(angle))
				angle = 0;

            if (Double.IsNaN(diff.X))
                diff.X = 0;

			dc.PushTransform(new RotateTransform(Math.Sign(diff.X) * (-1) * angle));

			Vector diff2 = p2 - p1;
			double scale = diff2.Length / (this.Height - 2 * margin);
			dc.PushTransform(new ScaleTransform(1, scale));

			dc.PushTransform(new TranslateTransform(-this.Width / 2.0, -margin));

			
			dc.DrawImage(this.Image, new Rect(0, 0, this.Width, this.Height));

			dc.Pop();
			dc.Pop();
			dc.Pop();
			dc.Pop();
		}
開發者ID:SimonWallner,項目名稱:uit2012-lab4,代碼行數:31,代碼來源:Sprite.cs

示例4: DrawPointElement

        protected override void DrawPointElement(DrawingContext dc, int Zoom)
        {
            dc.DrawLine(new Pen(Brushes.Black, 2), new Point(), new Point(0, -BodyOffset));

            dc.PushTransform(new TranslateTransform(0, - 0.5 * BodyHeight - BodyOffset));

            dc.DrawRectangle(Brushes.Black, null,
                             new Rect(-0.5 * BodyWidth, -0.5 * BodyHeight, BodyWidth, BodyHeight));

            for (int i = 0; i < Lights.Length; i++)
                dc.DrawEllipse(Lights[i], null, new Point(0, (2 + LightRadius + 1) * (i - 1)), LightRadius, LightRadius);

            dc.PushTransform(new TranslateTransform(0.5 * BodyWidth + 2, -0.5 * BodyHeight));

            if (Zoom > 11)
            {
                PrintStack(dc,
                           new FormattedText(Target.Name, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Verdana"), 10, Brushes.Black),
                           new FormattedText(OrdinateString, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Verdana"), 8, Brushes.Blue));
            }

            dc.Pop();

            dc.Pop();
        }
開發者ID:NpoSaut,項目名稱:netEMapTools,代碼行數:25,代碼來源:MapTrafficLightElement.cs

示例5: InnerDraw

		protected override void InnerDraw(DrawingContext drawingContext)
		{
			drawingContext.PushTransform(_translateTransform);
			drawingContext.PushTransform(_rotateTransform);
			base.InnerDraw(drawingContext);
			drawingContext.Pop();
			drawingContext.Pop();
		}
開發者ID:xbadcode,項目名稱:Rubezh,代碼行數:8,代碼來源:PointPainter.cs

示例6: DrawTriangle

    private void DrawTriangle(DrawingContext drawingContext, Point origin, double rotation)
    {
      drawingContext.PushTransform(new TranslateTransform(origin.X, origin.Y));
      drawingContext.PushTransform(new RotateTransform(rotation));

      drawingContext.DrawGeometry(m_Pen.Brush, null, m_Triangle);

      drawingContext.Pop();
      drawingContext.Pop();
    }
開發者ID:squaredinfinity,項目名稱:Foundation,代碼行數:10,代碼來源:DropTargetInsertionAdorner.cs

示例7: RenderHeader

 /// <summary>This method performs the actual render operation to show a text label</summary>
 /// <param name="dc">Drawing context</param>
 /// <param name="info">Render info</param>
 /// <param name="scale">The scale.</param>
 /// <param name="offset">The offset.</param>
 public virtual void RenderHeader(DrawingContext dc, AutoHeaderTextRenderInfo info, double scale, Point offset)
 {
     dc.PushTransform(new TranslateTransform(offset.X, offset.Y));
     dc.PushTransform(new ScaleTransform(scale, scale));
     dc.PushClip(new RectangleGeometry(info.RenderRect));
     info.FormattedText.SetMaxTextWidths(new[] { info.RenderRect.Width });
     info.FormattedText.MaxLineCount = 1;
     info.FormattedText.Trimming = TextTrimming.CharacterEllipsis;
     dc.DrawText(info.FormattedText, info.RenderRect.TopLeft);
     dc.Pop();
     dc.Pop();
     dc.Pop();
 }
開發者ID:sat1582,項目名稱:CODEFramework,代碼行數:18,代碼來源:AutoLayoutHeaderRenderer.cs

示例8: OnRender

        protected override void OnRender(DrawingContext drawingContext)
        {
            AnimationControl();
            var width = Width < 1 ? 1 : Width;
            drawingContext.PushTransform(new TranslateTransform(RenderSize.Width / 2, RenderSize.Height / 2));

            for (int i = 0; i < c_Blobs; i++)
            {
                drawingContext.PushTransform(new RotateTransform((360 / c_Blobs) * i));
                drawingContext.DrawRectangle(m_Brushes[i], null, new Rect(0, width / 4.25, width / 16.0, width / 4.0));
                drawingContext.Pop();
            }
            drawingContext.Pop();
        }
開發者ID:rba100,項目名稱:foosnet,代碼行數:14,代碼來源:Spinner.cs

示例9: OnRender

        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            if (AdornedElement.RenderSize.Width < 20)
                return;

            TranslateTransform transform = new TranslateTransform
                    (
                            AdornedElement.RenderSize.Width - 15,
                            (AdornedElement.RenderSize.Height - 5) / 2
                    );
            transform = new TranslateTransform
                    (
                            AdornedElement.RenderSize.Width / 2 - 3.5,
                            AdornedElement.RenderSize.Height / 2 - 10
                    );
            drawingContext.PushTransform(transform);

            Geometry geometry = ascGeometry;
            if (this.Direction == ListSortDirection.Descending)
                geometry = descGeometry;
            drawingContext.DrawGeometry(Brushes.LightGray, null, geometry);

            drawingContext.Pop();
        }
開發者ID:RomanHodulak,項目名稱:WPFClient,代碼行數:26,代碼來源:SortAdorner.cs

示例10: RenderImportanceArrow

        private void RenderImportanceArrow(DrawingContext dc, FrameworkElement mostImportant, FrameworkElement leastImportant)
        {
            var startPoint = FindPoint(mostImportant, new Point(mostImportant.ActualWidth/2, mostImportant.ActualHeight));
            var endPoint = FindPoint(leastImportant, new Point(leastImportant.ActualWidth/2, 0));

            var vector = Point.Subtract(endPoint, startPoint);

            var midPoint = Point.Add(startPoint, Vector.Multiply(vector, 0.66));

            Transform arrowTransform = Transform.Identity;
            double angle;
            if (Math.Abs((angle = Vector.AngleBetween(vector, new Vector(0, -1))) - 0) > double.Epsilon)
            {
                arrowTransform = new RotateTransform(angle, midPoint.X, midPoint.Y);
            }

            var line = BuildPath.From(startPoint).LineTo(endPoint.X, endPoint.Y).Build();
            var arrow = BuildPath.From(midPoint.X - 3, midPoint.Y - 3).LineTo(midPoint.X, midPoint.Y)
                .LineTo(midPoint.X + 3, midPoint.Y - 3).Build();

            dc.DrawGeometry(null, _pen, line);

            dc.PushTransform(arrowTransform);

            dc.DrawGeometry(null, _pen, arrow);

            dc.Pop();
        }
開發者ID:ArildF,項目名稱:PTB,代碼行數:28,代碼來源:TaskPriorityAdorner.cs

示例11: RenderBackground

 /// <summary>This method draws a rectangular background around a group of elements</summary>
 /// <param name="dc">The drawing context.</param>
 /// <param name="info">Render info</param>
 /// <param name="scale">The scale.</param>
 /// <param name="offset">The offset.</param>
 public virtual void RenderBackground(DrawingContext dc, GroupBackgroundRenderInfo info, double scale, Point offset)
 {
     dc.PushTransform(new TranslateTransform(offset.X, offset.Y));
     dc.PushTransform(new ScaleTransform(scale, scale));
     dc.DrawRectangle(info.Background, null, info.RenderRect);
     if (info.Border != null && info.BorderWidth > 0)
     {
         var rect2 = new Rect(info.RenderRect.X + (info.BorderWidth/2),
                              info.RenderRect.Y + (info.BorderWidth/2),
                              info.RenderRect.Width + info.BorderWidth,
                              info.RenderRect.Height + info.BorderWidth);
         dc.DrawRectangle(null, new Pen(info.Border, info.BorderWidth), rect2);
     }
     dc.Pop();
     dc.Pop();
 }
開發者ID:sat1582,項目名稱:CODEFramework,代碼行數:21,代碼來源:AutoLayoutHeaderRenderer.cs

示例12: OnRender

        protected override void OnRender(DrawingContext drawingContext)
        {
            PushButton pushButton = Visual as PushButton;
            if (pushButton.Pushed && _pushedImage != null)
            {
                drawingContext.DrawImage(_pushedImage, _imageRect);
            }
            else if (_image != null)
            {
                drawingContext.DrawImage(_image, _imageRect);
            }

            if (pushButton.Pushed)
            {
                drawingContext.PushTransform(new TranslateTransform(pushButton.TextPushOffset.X, pushButton.TextPushOffset.Y));
            }

            if (pushButton.Glyph != PushButtonGlyph.None)
            {
                drawingContext.DrawGeometry(_glyphBrush, _glyphPen, _glyphPath);
            }
            pushButton.TextFormat.RenderText(drawingContext, _textBrush, pushButton.Text, _imageRect);

            if (pushButton.Pushed)
            {
                drawingContext.Pop();
            }
        }
開發者ID:Heliflyer,項目名稱:helios,代碼行數:28,代碼來源:PushButtonRenderer.cs

示例13: DrawPointElement

        protected override void DrawPointElement(DrawingContext dc, int Zoom)
        {
            if (Zoom > 12 || IsMouseOver)
            {
                string postLabelText = string.Format("{0}км", (double)Post.Ordinate / 1000);
                var postLabel = new FormattedText(postLabelText, CultureInfo.CurrentCulture,
                                                  FlowDirection.LeftToRight, new Typeface("Verdana"), 10, mainBrush);

                const int flagHeight = 22;
                dc.PushTransform(new TranslateTransform(0, -flagHeight));

                dc.DrawRectangle(Brushes.White, new Pen(mainBrush, 1), new Rect(-0.5, -0.5, Math.Round(postLabel.Width) + 5, Math.Round(postLabel.Height) + 2));
                dc.DrawText(postLabel, new Point(2, 0));
                dc.DrawLine(new Pen(mainBrush, 2), new Point(0, 0), new Point(0, flagHeight));

                dc.Pop();
            }

            if (Zoom > 8)
                dc.DrawEllipse(SectionBrush, new Pen(mainBrush, 1.5), new Point(0, 0), 5, 5);
            else
                dc.DrawRectangle(SectionBrush, null, new Rect(-2, -2, 4, 4));

            if (IsMouseOver)
            {
                dc.PushTransform(new TranslateTransform(3, 10));
                PrintStack(dc,
                           new FormattedText(Post.Direction == OrdinateDirection.Increasing ? "Возрастает по неч." : "Убывает по неч.",
                                             CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Verdana"), 10, Brushes.DarkBlue),
                           new FormattedText(String.Format("Пути: {0}", string.Join(", ", Post.Tracks.Select(TrackName))),
                                             CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Verdana"), 10, Brushes.DarkOliveGreen));
                dc.Pop();
            }
        }
開發者ID:NpoSaut,項目名稱:netEMapTools,代碼行數:34,代碼來源:KilometerPostMapElement.cs

示例14: InnerDraw

		protected override void InnerDraw(DrawingContext drawingContext)
		{
			base.InnerDraw(drawingContext);
			drawingContext.PushTransform(_scaleTransform);
			drawingContext.DrawDrawing(_textDrawing);
			drawingContext.Pop();
		}
開發者ID:xbadcode,項目名稱:Rubezh,代碼行數:7,代碼來源:PassCardImagePropertyPainter.cs

示例15: ApplyFilter

        /// <summary>
        /// Applies the <see cref="ShinyFloorFilter" /> to the specified <paramref name="source"/>.
        /// </summary>
        /// <param name="source">The source image.</param>
        /// <param name="dc"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        protected override void ApplyFilter(FastBitmap source, DrawingContext dc, int width, int height)
        {
            // First, draw reflected image with an opacity mask.
            int reflectionHeight = (int)(source.Height * (ReflectionPercentage / 100.0f));
            dc.PushTransform(new TransformGroup
            {
                Children = new TransformCollection
                {
                    new ScaleTransform {ScaleY = -1},
                    new TranslateTransform {Y = GetReflectionOffsetY(source) + reflectionHeight}
                }
            });
            dc.PushOpacityMask(new LinearGradientBrush(
                Colors.Transparent,
                Color.FromArgb((byte)(255.0f * (ReflectionOpacity / 100.0f)), 0, 0, 0),
                new Point(0, 0),
                new Point(0, 1)));

            dc.DrawImage(new CroppedBitmap(source.InnerBitmap, new Int32Rect(0, source.Height - reflectionHeight, source.Width, reflectionHeight)),
                new Rect(0, 0, source.Width, reflectionHeight));

            dc.Pop();
            dc.Pop();

            // Draw original image.
            dc.DrawImage(source.InnerBitmap, new Rect(0, 0, source.Width, source.Height));
        }
開發者ID:sitdap,項目名稱:dynamic-image,代碼行數:34,代碼來源:ShinyFloorFilter.cs


注:本文中的System.Windows.Media.DrawingContext.PushTransform方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。