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


C# StreamGeometry.Freeze方法代码示例

本文整理汇总了C#中System.Windows.Media.StreamGeometry.Freeze方法的典型用法代码示例。如果您正苦于以下问题:C# StreamGeometry.Freeze方法的具体用法?C# StreamGeometry.Freeze怎么用?C# StreamGeometry.Freeze使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Media.StreamGeometry的用法示例。


在下文中一共展示了StreamGeometry.Freeze方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CalculateShape

		private void CalculateShape()
		{
			//Vorberechnen für bessere Performance
			float angle = Angle * (float)(Math.PI / 180);
			float sinAngle = (float)Math.Sin(angle);
			float cosAngle = (float)Math.Cos(angle);

			//P_L
			startPoint = new Point(Size - cosAngle * Size, Size + sinAngle * Size);
			//P_O
			circleIntersectionPoint = new Point(2 * Size, Size);
			//P_R
			circleEndPoint = new Point(Size * 3 + cosAngle * Size, Size + sinAngle * Size);
			//P_U
			Vector angledVector = new Vector(-sinAngle, cosAngle);
			double lineLength = (2 * Size - (Size * 3 + cosAngle * Size)) / angledVector.X;
			trianglePoint = Point.Add(circleEndPoint, Vector.Multiply(angledVector, lineLength));

			//Form aus Punkten erstellen
			heart = new StreamGeometry();
			using (StreamGeometryContext ctx = heart.Open())
			{
				ctx.BeginFigure(startPoint, true, true);
				ctx.ArcTo(circleIntersectionPoint, new Size(Size, Size), Math.PI + angle, true, SweepDirection.Clockwise, true, false);
				ctx.ArcTo(circleEndPoint, new Size(Size, Size), Math.PI + angle, true, SweepDirection.Clockwise, true, false);
				ctx.LineTo(trianglePoint, true, false);
			}
			heart.Freeze();
		}
开发者ID:lkempf,项目名称:Bwinf-34-r2,代码行数:29,代码来源:Cake.cs

示例2: MakeGeometry

        internal void MakeGeometry()
        {
            if (Edge.Points.Count > 0)
            {
                var points = Edge.Points;
                StreamGeometry g = new StreamGeometry();
                StreamGeometryContext c = g.Open();

                c.BeginFigure(points[0], false, false);
                var r = Edge.Points.Where(p => p != Edge.Points[0]);
                c.PolyBezierTo(r.ToList(), true, false);

                if (Edge.EndPoint.HasValue)
                {
                    Point from = Edge.Points.Last();
                    Point to = Edge.EndPoint.Value;

                    DrawArrow(c, from, to, 4);
                }

                if (Edge.StartPoint.HasValue)
                {
                    Point from = Edge.Points.First();
                    Point to = Edge.StartPoint.Value;

                    DrawArrow(c, from, to, 4);
                }

                c.Close();
                g.Freeze();

                EdgeGeometry = g;
            }
        }
开发者ID:smartcaveman,项目名称:graphviznet,代码行数:34,代码来源:EdgePresenter.cs

示例3: Draw

 public void Draw(TextView textView, DrawingContext drawingContext)
 {
     foreach (TextSegment current in this.SearchHitsSegments)
     {
         foreach (Rect current2 in BackgroundGeometryBuilder.GetRectsForSegment(textView, current))
         {
             Point bottomLeft = current2.BottomLeft;
             Point bottomRight = current2.BottomRight;
             Pen pen = new Pen(new SolidColorBrush(Colors.OrangeRed), 1);
             pen.Freeze();
             double num = 2.5;
             int count = System.Math.Max((int)((bottomRight.X - bottomLeft.X) / num) + 1, 4);
             StreamGeometry streamGeometry = new StreamGeometry();
             using (StreamGeometryContext streamGeometryContext = streamGeometry.Open())
             {
                 streamGeometryContext.BeginFigure(bottomLeft, true, true);
                 streamGeometryContext.LineTo(current2.TopLeft, true, false);
                 streamGeometryContext.LineTo(current2.TopRight, true, false);
                 streamGeometryContext.LineTo(current2.BottomRight, true, false);
             }
             streamGeometry.Freeze();
             drawingContext.DrawGeometry(Brushes.Transparent, pen, streamGeometry);
         }
     }
 }
开发者ID:BernardNotarianni,项目名称:DownmarkerWPF,代码行数:25,代码来源:SearchBackgroundRenderer.cs

示例4: GetOrCreateBoxGeometry

        protected override Geometry GetOrCreateBoxGeometry(Size renderSize)
        {
            var rect = new Rect(new Point(0, 0), renderSize);
            this.SetCurrentValue(RectProperty, rect);
            if (rect.Width <= 0 || rect.Height <= 0)
            {
                return Geometry.Empty;
            }

            if (this.CornerRadius.IsAllEqual())
            {
                // using TopLeft here as we have already checked that they are equal
                if (this.BoxGeometry is RectangleGeometry)
                {
                    return this.BoxGeometry;
                }

                var geometry = new RectangleGeometry();
                geometry.Bind(RectangleGeometry.RectProperty)
                    .OneWayTo(this, RectProperty);
                geometry.Bind(RectangleGeometry.RadiusXProperty)
                    .OneWayTo(this, CornerRadiusProperty, CornerRadiusTopLeftConverter.Default);
                geometry.Bind(RectangleGeometry.RadiusYProperty)
                    .OneWayTo(this, CornerRadiusProperty, CornerRadiusTopLeftConverter.Default);
                return geometry;
            }
            else
            {
                var geometry = new StreamGeometry();
                using (var context = geometry.Open())
                {
                    var cr = this.AdjustedCornerRadius();
                    var p = cr.TopLeft > 0
                        ? new Point(cr.TopLeft + this.StrokeThickness / 2, this.StrokeThickness / 2)
                        : new Point(this.StrokeThickness / 2, this.StrokeThickness / 2);
                    context.BeginFigure(p, true, true);
                    p = p.WithOffset(rect.Width - cr.TopLeft - cr.TopRight, 0);
                    context.LineTo(p, true, true);
                    p = context.DrawCorner(p, cr.TopRight, cr.TopRight);

                    p = p.WithOffset(0, rect.Height - cr.TopRight - cr.BottomRight);
                    context.LineTo(p, true, true);
                    p = context.DrawCorner(p, -cr.BottomRight, cr.BottomRight);

                    p = p.WithOffset(-rect.Width + cr.BottomRight + cr.BottomLeft, 0);
                    context.LineTo(p, true, true);
                    p = context.DrawCorner(p, -cr.BottomLeft, -cr.BottomLeft);

                    p = p.WithOffset(0, -rect.Height + cr.TopLeft + cr.BottomLeft);
                    context.LineTo(p, true, true);
                    context.DrawCorner(p, cr.TopLeft, -cr.TopLeft);
                }

                geometry.Freeze();
                return geometry;
            }
        }
开发者ID:JohanLarsson,项目名称:Gu.Wpf.Geometry,代码行数:57,代码来源:BoxBalloon.cs

示例5: OnRender

		protected override void OnRender(DrawingContext drawingContext)
		{
			if (Plotter2D == null) return;
			if (DataSource == null) return;
			if (Collection == null) return;
			if (Collection.Lines.Count == 0)
			{
				IsolineBuilder.DataSource = DataSource;
			}

			var dc = drawingContext;
			var dataSource = DataSource;
			var localMinMax = dataSource.GetMinMax();
			var globalMinMax = dataSource.Range.Value;
			double lengthsRatio = globalMinMax.GetLength() / localMinMax.GetLength();

			if (lengthsRatio > 16)
			{
				double log = Math.Round(Math.Log(lengthsRatio, 2));
				double number = 2 * Math.Pow(2, log);
				double delta = globalMinMax.GetLength() / number;

				double start = Math.Floor((localMinMax.Min - globalMinMax.Min) / delta) * delta + globalMinMax.Min;
				double end = localMinMax.Max;

				var transform = Plotter2D.Transform;
				var strokeThickness = StrokeThickness;

				double x = start;
				while (x < end)
				{
					var collection = IsolineBuilder.BuildIsoline(x);

					foreach (LevelLine line in collection)
					{
						StreamGeometry lineGeometry = new StreamGeometry();
						using (var context = lineGeometry.Open())
						{
							context.BeginFigure(line.StartPoint.ViewportToScreen(transform), false, false);
							context.PolyLineTo(line.OtherPoints.ViewportToScreen(transform).ToArray(), true, true);
						}
						lineGeometry.Freeze();

						var paletteRatio = (line.RealValue - globalMinMax.Min) / globalMinMax.GetLength();
						Pen pen = new Pen(new SolidColorBrush(Palette.GetColor(paletteRatio)), strokeThickness);

						dc.DrawGeometry(null, pen, lineGeometry);
					}

					x += delta;
				}
			}
			//dc.DrawRectangle(Brushes.Green.MakeTransparent(0.3), null, new Rect(RenderSize));
		}
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:54,代码来源:AdditionalLinesDisplay.cs

示例6: DeserializeStreamGeometry

        internal static object DeserializeStreamGeometry( BinaryReader reader )
        {
            StreamGeometry geometry = new StreamGeometry();
            
            using (StreamGeometryContext context = geometry.Open())
            {
                ParserStreamGeometryContext.Deserialize( reader, context, geometry ); 
            }
            geometry.Freeze();

            return geometry; 
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:12,代码来源:parserscommon.cs

示例7: Invalidate

		public void Invalidate()
		{
			_geometry = new StreamGeometry();
			using (StreamGeometryContext ctx = _geometry.Open())
				foreach (var gridLine in GridLines)
				{
					ctx.BeginFigure(gridLine.Orientation == Orientation.Horizontal ? new Point(0, gridLine.Position) : new Point(gridLine.Position, 0), false, false);
					ctx.LineTo(gridLine.Orientation == Orientation.Horizontal ? new Point(_canvas.Width, gridLine.Position) : new Point(gridLine.Position, _canvas.Height), true, false);
				}
			_geometry.Freeze();
			_clipGeometry = new RectangleGeometry(new Rect(0, 0, _canvas.CanvasWidth, _canvas.CanvasHeight));
			_canvas.Refresh();
		}
开发者ID:saeednazari,项目名称:Rubezh,代码行数:13,代码来源:GridLineController.cs

示例8: Draw

        public void Draw(DrawingContext dc, List<Point> filteredPoints, ChartStyle chartStyle)
        {
            var geometry = new StreamGeometry();
            using (StreamGeometryContext context = geometry.Open())
            {
                context.BeginFigure(filteredPoints[0], false, false);
                context.PolyLineTo(filteredPoints, true, true);
            }
            geometry.Freeze();

            Pen pen = new Pen(chartStyle.LineColor, 1);

            dc.DrawGeometry(null, pen, geometry);
        }
开发者ID:anndream,项目名称:StockCharts-1,代码行数:14,代码来源:LineChart.cs

示例9: RegenerateShape

        public override void RegenerateShape(GMapControl map)
        {
            if (map != null)
            {
                if (Points.Count > 1)
                {
                    var localPath = new List<Point>();
                    var offset = map.FromLatLngToLocal(Points[0]);
                    foreach (PointLatLng i in Points)
                    {
                        var p = map.FromLatLngToLocal(new PointLatLng(i.Lat, i.Lng));
                        localPath.Add(new Point(p.X - offset.X, p.Y - offset.Y));
                    }

                    // Create a StreamGeometry to use to specify myPath.
                    var geometry = new StreamGeometry();

                    using (StreamGeometryContext ctx = geometry.Open())
                    {
                        ctx.BeginFigure(localPath[0], true, true);

                        // Draw a line to the next specified point.
                        ctx.PolyLineTo(localPath, true, true);
                    }

                    // Freeze the geometry (make it unmodifiable)
                    // for additional performance benefits.
                    geometry.Freeze();

                    // Create a path to draw a geometry with.
                    Shape = new Path
                        {
                            Data = geometry,
                            Fill = Brushes.Transparent,
                            StrokeThickness = 20,
                            Stroke = Brushes.Transparent,
                            IsHitTestVisible = true
                        };
                }
                else
                {
                    Shape = null;
                }
            }
        }
开发者ID:rmunn,项目名称:cog,代码行数:45,代码来源:RegionHitMarker.cs

示例10: RemoveButton

		static RemoveButton()
		{
			_tabItemCloseButtonHoverBackgroundBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFc13535"));
			_tabItemCloseButtonPressedBackgroundBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF431e20"));
			_tabItemCloseButtonPressedForegroundPen = new Pen(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFf9ebeb")), 2);
			_tabItemCloseButtonHoverForegroundPen = new Pen(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFf9ebeb")), 2);
			_geometry = new StreamGeometry();
			using (StreamGeometryContext context = _geometry.Open())
			{
				context.BeginFigure(new Point(-3, -3), true, false);
				context.LineTo(new Point(3, 3), true, false);
				context.BeginFigure(new Point(-3, 3), true, false);
				context.LineTo(new Point(3, -3), true, false);
				context.Close();
			}
			_tabItemCloseButtonHoverBackgroundBrush.Freeze();
			_tabItemCloseButtonPressedBackgroundBrush.Freeze();
			_tabItemCloseButtonPressedForegroundPen.Freeze();
			_tabItemCloseButtonHoverForegroundPen.Freeze();
			_geometry.Freeze();
		}
开发者ID:saeednazari,项目名称:Rubezh,代码行数:21,代码来源:RemoveButton.cs

示例11: Draw

 public void Draw(TextView textView, DrawingContext drawingContext)
 {
     foreach (var current in ErrorSegments)
     {
         foreach (var current2 in BackgroundGeometryBuilder.GetRectsForSegment(textView, current))
         {
             var bottomLeft = current2.BottomLeft;
             var bottomRight = current2.BottomRight;
             var pen = new Pen(new SolidColorBrush(Colors.Red), 0.6);
             pen.Freeze();
             const double num = 2.0;
             var count = Math.Max((int)((bottomRight.X - bottomLeft.X)/num) + 1, 4);
             var streamGeometry = new StreamGeometry();
             using (var streamGeometryContext = streamGeometry.Open())
             {
                 streamGeometryContext.BeginFigure(bottomLeft, false, false);
                 streamGeometryContext.PolyLineTo(CreatePoints(bottomLeft, num, count).ToArray(), true, false);
             }
             streamGeometry.Freeze();
             drawingContext.DrawGeometry(Brushes.Transparent, pen, streamGeometry);
         }
     }
 }
开发者ID:jhorv,项目名称:Markdown-Edit,代码行数:23,代码来源:SpellCheckBackgroundRenderer.cs

示例12: Draw

        public override void Draw(DrawingContext dc)
        {
            Point p1 = A.Mid(B), p2 = B.Mid(C);

            //dc.DrawLine (pen, A, B);
            //dc.DrawLine (pen, B, C);
            double h1 = A.Heading(B), h2 = B.Heading(C);
            double hp1 = h1 + Math.PI / 2, hp2 = B.Heading(C) + Math.PI / 2;

            //dc.DrawEllipse (Brushes.Blue, null, p1, 2, 2);
            //dc.DrawEllipse (Brushes.Blue, null, p2, 2, 2);

            Point p3 = p1.PolarMove(500, hp1);
            Point p4 = p2.PolarMove(500, hp2);
            //dc.DrawLine (pen, p1, p3);
            //dc.DrawLine (pen, p2, p4);

            Point cen = Extensions.Intersect(p1, p3, p2, p4);
            //dc.DrawEllipse (Brushes.Green, null, cen, 5, 5);
            double rad = cen.DistTo(A);

            double turn = h2 - h1;
            if (turn < -Math.PI) turn += 2 * Math.PI;
            else if (turn > Math.PI) turn -= 2 * Math.PI;
            SweepDirection sweep = (turn < 0) ? SweepDirection.Counterclockwise : SweepDirection.Clockwise;
            bool largeArc = Math.Abs(turn) > Math.PI / 2;

            StreamGeometry sg = new StreamGeometry();
            using (StreamGeometryContext ctx = sg.Open())
            {
                ctx.BeginFigure(A, false, false);
                ctx.ArcTo(C, new Size(rad, rad), 0, largeArc, sweep, true, false);
            }
            sg.Freeze();
            dc.DrawGeometry(null, MakePen(), sg);
        }
开发者ID:keshavb-96,项目名称:CAD,代码行数:36,代码来源:Drawing.cs

示例13: creategeometry

        //Redraw data
        private void creategeometry(int value)
        {
            // Create a StreamGeometry to use to specify myPath.
            geometry = new StreamGeometry();
            geometry.Open();
            // Open a StreamGeometryContext that can be used to describe this StreamGeometry  
            // object's contents. 
            using (StreamGeometryContext geo = geometry.Open())
            {
                if (direction == LineDirection.Horizontal)
                {
                    geo.BeginFigure(new Point(0, value), false, false);
                    geo.LineTo(new Point(view.XMAX, value), true, false);

                }
                else if (direction == LineDirection.Vertical)
                {
                    geo.BeginFigure(new Point(value, 0), false, false);
                    geo.LineTo(new Point(value, view.YMAX), true, false);
                }
            }
            geometry.Freeze();
            line.Data = geometry;
        }
开发者ID:DiLRandI,项目名称:ArduinoMonitor,代码行数:25,代码来源:gridLine.cs

示例14: RenderIsolineCollection

		protected void RenderIsolineCollection(DrawingContext dc, double strokeThickness, IsolineCollection collection, CoordinateTransform transform)
		{
			foreach (LevelLine line in collection)
			{
				StreamGeometry lineGeometry = new StreamGeometry();
				using (var context = lineGeometry.Open())
				{
					context.BeginFigure(line.StartPoint.ViewportToScreen(transform), false, false);
					if (!UseBezierCurves)
					{
						context.PolyLineTo(line.OtherPoints.ViewportToScreen(transform).ToArray(), true, true);
					}
					else
					{
						context.PolyBezierTo(BezierBuilder.GetBezierPoints(line.AllPoints.ViewportToScreen(transform).ToArray()).Skip(1).ToArray(), true, true);
					}
				}
				lineGeometry.Freeze();

				Pen pen = new Pen(new SolidColorBrush(Palette.GetColor(line.Value01)), strokeThickness);

				dc.DrawGeometry(null, pen, lineGeometry);
			}
		}
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:24,代码来源:IsolineRenderer.cs

示例15: RegenerateShape

        public override void RegenerateShape(GMapControl map)
        {
            if (map != null)
            {
                if (Points.Count > 1)
                {
                    var localPath = new List<Point>();
                    var offset = map.FromLatLngToLocal(Points[0]);
                    foreach (PointLatLng i in Points)
                    {
                        var p = map.FromLatLngToLocal(new PointLatLng(i.Lat, i.Lng));
                        localPath.Add(new Point(p.X - offset.X, p.Y - offset.Y));
                    }

                    // Create a StreamGeometry to use to specify myPath.
                    var geometry = new StreamGeometry();

                    using (StreamGeometryContext ctx = geometry.Open())
                    {
                        ctx.BeginFigure(localPath[0], true, true);

                        // Draw a line to the next specified point.
                        ctx.PolyLineTo(localPath, true, true);
                    }

                    // Freeze the geometry (make it unmodifiable)
                    // for additional performance benefits.
                    geometry.Freeze();

                    var fillBrush = new SolidColorBrush();
                    BindingOperations.SetBinding(fillBrush, SolidColorBrush.ColorProperty, new Binding("Variety.ClusterIndex") {Converter = new IndexToColorConverter(), ConverterParameter = Colors.CornflowerBlue});
                    var strokeBrush = new SolidColorBrush();
                    BindingOperations.SetBinding(strokeBrush, SolidColorBrush.ColorProperty, new Binding("Color") {Source = fillBrush, Converter = new ColorBrightnessConverter(), ConverterParameter = -0.15});
                    // Create a path to draw a geometry with.
                    var path = new Path
                        {
                            Data = geometry,
                            Effect = new BlurEffect {KernelType = KernelType.Gaussian, Radius = 3.0, RenderingBias = RenderingBias.Quality},
                            Stroke = strokeBrush,
                            Fill = fillBrush,
                            StrokeThickness = 3,
                            Opacity = 0.5,
                            IsHitTestVisible = true,
                            DataContext = _region,
                            Visibility = Shape == null ? Visibility.Visible : Shape.Visibility
                        };
                    Shape = path;
                    Shape.MouseEnter += Shape_MouseEnter;
                    Shape.MouseLeave += Region_MouseLeave;
                }
                else
                {
                    Shape = null;
                }
            }
        }
开发者ID:StephenEhmann,项目名称:cog,代码行数:56,代码来源:RegionMarker.cs


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