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


C# DrawingImage.Freeze方法代码示例

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


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

示例1: CreateVisuals

        /// <summary>
        /// Within the given line add the scarlet box behind the a
        /// </summary>
        private void CreateVisuals(ITextViewLine line)
        {
            //grab a reference to the lines in the current TextView 
            IWpfTextViewLineCollection textViewLines = _view.TextViewLines;
            int start = line.Start;
            int end = line.End;

            //Loop through each character, and place a box around any a 
            for (int i = start; (i < end); ++i)
            {
                if (_view.TextSnapshot[i] == 'a')
                {
                    SnapshotSpan span = new SnapshotSpan(_view.TextSnapshot, Span.FromBounds(i, i + 1));
                    Geometry g = textViewLines.GetMarkerGeometry(span);
                    if (g != null)
                    {
                        GeometryDrawing drawing = new GeometryDrawing(_brush, _pen, g);
                        drawing.Freeze();

                        DrawingImage drawingImage = new DrawingImage(drawing);
                        drawingImage.Freeze();

                        Image image = new Image();
                        image.Source = drawingImage;

                        //Align the image with the top of the bounds of the text geometry
                        Canvas.SetLeft(image, g.Bounds.Left);
                        Canvas.SetTop(image, g.Bounds.Top);

                        _layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, null, image, null);
                    }
                }
            }
        }
开发者ID:AlmatoolboxCE,项目名称:AlmaStyleFix,代码行数:37,代码来源:TextAdornment1.cs

示例2: CreateAndAddAdornment

        void CreateAndAddAdornment(ITextViewLine line, SnapshotSpan span, Brush brush, bool extendToRight)
        {
            var markerGeometry = _view.TextViewLines.GetMarkerGeometry(span);

            double left = markerGeometry.Bounds.Left;
            double width = extendToRight ? _view.ViewportWidth + _view.MaxTextRightCoordinate : markerGeometry.Bounds.Width;

            Rect rect = new Rect(left, line.Top, width, line.Height);

            RectangleGeometry geometry = new RectangleGeometry(rect);

            GeometryDrawing drawing = new GeometryDrawing(brush, new Pen(), geometry);
            drawing.Freeze();

            DrawingImage drawingImage = new DrawingImage(drawing);
            drawingImage.Freeze();

            Image image = new Image();
            image.Source = drawingImage;

            Canvas.SetLeft(image, geometry.Bounds.Left);
            Canvas.SetTop(image, geometry.Bounds.Top);

            _layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, null, image, null);
        }
开发者ID:NoahRic,项目名称:BackgroundColorFix,代码行数:25,代码来源:BackgroundColorVisualManager.cs

示例3: TranslationAdornment

        /// <summary>
        /// Creates a square image and attaches an event handler to the layout changed event that
        /// adds the the square in the upper right-hand corner of the TextView via the adornment layer
        /// </summary>
        /// <param name="view">The <see cref="IWpfTextView"/> upon which the adornment will be drawn</param>
        public TranslationAdornment(IWpfTextView view)
        {
            _view = view;

            Brush brush = new SolidColorBrush(Colors.BlueViolet);
            brush.Freeze();
            Brush penBrush = new SolidColorBrush(Colors.Red);
            penBrush.Freeze();
            Pen pen = new Pen(penBrush, 0.5);
            pen.Freeze();

            //draw a square with the created brush and pen
            System.Windows.Rect r = new System.Windows.Rect(0, 0, 30, 30);
            Geometry g = new RectangleGeometry(r);
            GeometryDrawing drawing = new GeometryDrawing(brush, pen, g);
            drawing.Freeze();

            DrawingImage drawingImage = new DrawingImage(drawing);
            drawingImage.Freeze();

            _image = new Image();
            _image.Source = drawingImage;

            //Grab a reference to the adornment layer that this adornment should be added to
            _adornmentLayer = view.GetAdornmentLayer("TranslationAdornment");

            _view.ViewportHeightChanged += delegate { this.onSizeChange(); };
            _view.ViewportWidthChanged += delegate { this.onSizeChange(); };
        }
开发者ID:JeanAzzopardi,项目名称:TranslatorExtensionPackage,代码行数:34,代码来源:TranslationAdornment.cs

示例4: AddDecorationError

        public void AddDecorationError(BasePropertyDeclarationSyntax _property, string textFull, string toolTipText, FixErrorCallback errorCallback)
        {
            var lineSpan = tree.GetLineSpan(_property.Span, usePreprocessorDirectives: false);
            int lineNumber = lineSpan.StartLinePosition.Line;
            var line = _textView.TextSnapshot.GetLineFromLineNumber(lineNumber);
            var textViewLine = _textView.GetTextViewLineContainingBufferPosition(line.Start);
            int startSpace = textFull.Length - textFull.TrimStart().Length;
            int endSpace = textFull.Length - textFull.TrimEnd().Length;

            SnapshotSpan span = new SnapshotSpan(_textView.TextSnapshot, Span.FromBounds(line.Start.Position + startSpace, line.End.Position - endSpace));
            Geometry g = _textView.TextViewLines.GetMarkerGeometry(span);
            if (g != null)
            {
                rects.Add(g.Bounds);

                GeometryDrawing drawing = new GeometryDrawing(_brush, _pen, g);
                drawing.Freeze();

                DrawingImage drawingImage = new DrawingImage(drawing);
                drawingImage.Freeze();

                Image image = new Image();
                image.Source = drawingImage;
                //image.Visibility = Visibility.Hidden;

                Canvas.SetLeft(image, g.Bounds.Left);
                Canvas.SetTop(image, g.Bounds.Top);
                _layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, null, image, (t, ui) =>
                {
                    rects.Remove(g.Bounds);
                });

                DrawIcon(span, g.Bounds.Left - 30, g.Bounds.Top, toolTipText, errorCallback);
            }
        }
开发者ID:jefflequeux,项目名称:DarkangeUtils,代码行数:35,代码来源:BaseMef.cs

示例5: GetImageSourceFromAxoColor

		public static ImageSource GetImageSourceFromAxoColor(AxoColor axoColor, int width, int height)
		{
			var innerRect = new Rect(0, 0, width, height);
			var geometryDrawing = new GeometryDrawing() { Geometry = new RectangleGeometry(innerRect) };
			geometryDrawing.Brush = new SolidColorBrush(GuiHelper.ToWpf(axoColor));
			DrawingImage geometryImage = new DrawingImage(geometryDrawing);
			geometryImage.Freeze(); // Freeze the DrawingImage for performance benefits.
			return geometryImage;
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:9,代码来源:MaterialConverter.cs

示例6: Manager

        private Manager()
        {
            #region Creates Loading Threads

            _loaderThreadForThumbnails = new Thread(LoaderThreadThumbnails)
            {
                IsBackground = true,
                Priority = ThreadPriority.BelowNormal
            };
            _loaderThreadForThumbnails.Start();

            _loaderThreadForNormalSize = new Thread(LoaderThreadNormalSize)
            {
                IsBackground = true,
                Priority = ThreadPriority.BelowNormal
            };
            _loaderThreadForNormalSize.Start();

            #endregion

            Application.Current.Exit += Current_Exit;

            #region Loading Images from Resources

            var resourceDictionary = new ResourceDictionary
            {
                Source = new Uri("csCommon;component/Resources/Styles/Resources.xaml", UriKind.Relative)
            };
            _loadingImage = resourceDictionary["ImageLoading"] as DrawingImage;
            _loadingImage.Freeze();
            _errorThumbnail = resourceDictionary["ImageError"] as DrawingImage;
            _errorThumbnail.Freeze();

            #endregion

            # region Create Loading Animation

            ScaleTransform scaleTransform = new ScaleTransform(0.5, 0.5);
            SkewTransform skewTransform = new SkewTransform(0, 0);
            RotateTransform rotateTransform = new RotateTransform(0);
            TranslateTransform translateTransform = new TranslateTransform(0, 0);

            TransformGroup group = new TransformGroup();
            group.Children.Add(scaleTransform);
            group.Children.Add(skewTransform);
            group.Children.Add(rotateTransform);
            group.Children.Add(translateTransform);

            DoubleAnimation doubleAnimation = new DoubleAnimation(0, 359, new TimeSpan(0, 0, 0, 1));
            doubleAnimation.RepeatBehavior = RepeatBehavior.Forever;

            rotateTransform.BeginAnimation(RotateTransform.AngleProperty, doubleAnimation);

            _loadingAnimationTransform = group;

            #endregion
        }
开发者ID:TNOCS,项目名称:csTouch,代码行数:57,代码来源:Manager.cs

示例7: CreateImageToHighlightLine

        private Image CreateImageToHighlightLine(Geometry geometry, LineResultMarker marker)
        {
            GeometryDrawing backgroundGeometry = new GeometryDrawing(marker.Fill, marker.Outline, geometry);
            backgroundGeometry.Freeze();

            DrawingImage backgroundDrawning = new DrawingImage(backgroundGeometry);
            backgroundDrawning.Freeze();

            return new Image {Source = backgroundDrawning};
        }
开发者ID:BenHall,项目名称:lonestar,代码行数:10,代码来源:EditorHighlighterProcessor.cs

示例8: CreateImage

        /// <summary>
        /// Freezes and then creates an image object from a GeometryGroup.
        /// </summary>
        /// <param name="brush">The fill brush for the group.</param>
        /// <param name="pen">The Border pen for the group.</param>
        /// <param name="group">The group to create an image from.</param>
        /// <returns>An image object that can be added to the canvas.</returns>
        public static Image CreateImage(this  GeometryGroup group, Brush brush, Pen pen)
        {
            group.Freeze();

            var drawing = new GeometryDrawing(brush, pen, group);
            drawing.Freeze();

            var drawingImage = new DrawingImage(drawing);
            drawingImage.Freeze();

            return new Image { Source = drawingImage };
        }
开发者ID:vserrago,项目名称:LiveDescribe-Desktop,代码行数:19,代码来源:GeometryGroupExtensions.cs

示例9: AddMarker

        private void AddMarker(SnapshotSpan span, Geometry markerGeometry, FormatInfo formatInfo)
        {
            GeometryDrawing drawing = new GeometryDrawing(formatInfo.Background, formatInfo.Outline, markerGeometry);
            drawing.Freeze();

            DrawingImage drawingImage = new DrawingImage(drawing);
            drawingImage.Freeze();

            Image image = new Image();
            image.Source = drawingImage;

            // Align the image with the top of the bounds of the text geometry
            Canvas.SetLeft(image, markerGeometry.Bounds.Left);
            Canvas.SetTop(image, markerGeometry.Bounds.Top);

            adornmentLayer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, null, image, null);
        }
开发者ID:ygoe,项目名称:TodoHighlighter,代码行数:17,代码来源:TodoHighlighter.cs

示例10: UpdateDebugInfo

        private void UpdateDebugInfo(object sender, EventArgs e)
        {
            if (m_bWaitThread && Singleton<BusinessLogic>.Instance.ThreadHasFinished())
            {
                m_bWaitThread = false;
                Info.Content = "完成";

                m_timer.Stop();
                m_timer = null;

                // 随便画画
                DrawingGroup imageDrawings = new DrawingGroup();

                Card[] cards = Singleton<CardRepository>.Instance.Cards;
                for (int i = 0; i < cards.Length; ++i)
                {
                    ImageDrawing image = new ImageDrawing();
                    image.Rect = new Rect(i * 50, 50, 150, 200);
                    image.ImageSource = new BitmapImage(new Uri(cards[i].ImagePath, UriKind.Relative));

                    imageDrawings.Children.Add(image);
                }

                DrawingImage drawingImageSource = new DrawingImage(imageDrawings);
                drawingImageSource.Freeze();

                Image imageControl = new Image();
                imageControl.Stretch = Stretch.None;
                imageControl.Source = drawingImageSource;

                Border imageBorder = new Border();
                imageBorder.BorderBrush = Brushes.Gray;
                imageBorder.BorderThickness = new Thickness(1);
                imageBorder.HorizontalAlignment = HorizontalAlignment.Left;
                imageBorder.VerticalAlignment = VerticalAlignment.Top;
                imageBorder.Margin = new Thickness(20);
                imageBorder.Child = imageControl;

                CardsBrowser.Content = imageBorder;
            }
            else
            {
                Info.Content = m_strMsg;
            }
        }
开发者ID:linghuyong,项目名称:DeckManager,代码行数:45,代码来源:MainWnd.xaml.cs

示例11: GetColorSwatch

        public static ImageSource GetColorSwatch(System.Drawing.Color value)
        {
            Color color = Color.FromArgb(value.A, value.R, value.G, value.B);

            GeometryGroup group = new GeometryGroup();
            group.Children.Add(new RectangleGeometry(new Rect(new Size(50, 50))));

            GeometryDrawing drawing = new GeometryDrawing()
            {
                Geometry = group,
                Brush = new SolidColorBrush(color),
                Pen = new Pen(Brushes.Transparent, 10),
            };

            DrawingImage image = new DrawingImage(drawing);
            image.Freeze();

            return image;
        }
开发者ID:GProulx,项目名称:WebEssentials2013,代码行数:19,代码来源:ColorSwatchCompletionListFilter.cs

示例12: Manager

        private Manager()
        {
            #region Creates Loading Threads
            _loaderThreadForThumbnails = new Thread(new ThreadStart(LoaderThreadThumbnails));
            _loaderThreadForThumbnails.IsBackground = true;  // otherwise, the app won't quit with the UI...
            _loaderThreadForThumbnails.Priority = ThreadPriority.BelowNormal;
            _loaderThreadForThumbnails.Start();

            _loaderThreadForNormalSize = new Thread(new ThreadStart(LoaderThreadNormalSize));
            _loaderThreadForNormalSize.IsBackground = true;  // otherwise, the app won't quit with the UI...
            _loaderThreadForNormalSize.Priority = ThreadPriority.BelowNormal;
            _loaderThreadForNormalSize.Start();
            #endregion

            #region Loading Images from Resources
            ResourceDictionary resourceDictionary = new ResourceDictionary();
            resourceDictionary.Source = new Uri("/ByteFlood;component/Controls/PhotoLoader/Resources.xaml", UriKind.Relative);
            _loadingImage = resourceDictionary["ImageLoading"] as DrawingImage;
            _loadingImage.Freeze();
            _errorThumbnail = resourceDictionary["ImageError"] as DrawingImage;
            _errorThumbnail.Freeze();
            #endregion

            # region Create Loading Animation
            ScaleTransform scaleTransform = new ScaleTransform(0.5, 0.5);
            SkewTransform skewTransform = new SkewTransform(0, 0);
            RotateTransform rotateTransform = new RotateTransform(0);
            TranslateTransform translateTransform = new TranslateTransform(0, 0);

            TransformGroup group = new TransformGroup();
            group.Children.Add(scaleTransform);
            group.Children.Add(skewTransform);
            group.Children.Add(rotateTransform);
            group.Children.Add(translateTransform);

            DoubleAnimation doubleAnimation = new DoubleAnimation(0, 359, new TimeSpan(0, 0, 0, 1));
            doubleAnimation.RepeatBehavior = RepeatBehavior.Forever;

            rotateTransform.BeginAnimation(RotateTransform.AngleProperty, doubleAnimation);

            _loadingAnimationTransform = group;
            #endregion
        }
开发者ID:hexafluoride,项目名称:byteflood,代码行数:43,代码来源:Manager.cs

示例13: UpdateRazerDisplay

        public void UpdateRazerDisplay(Color[,] colors)
        {
            // No point updating the display if the view isn't visible
            if (!IsActive)
                return;

            var visual = new DrawingVisual();
            using (var dc = visual.RenderOpen())
            {
                dc.PushClip(new RectangleGeometry(new Rect(0, 0, 22, 6)));
                for (var y = 0; y < 6; y++)
                {
                    for (var x = 0; x < 22; x++)
                        dc.DrawRectangle(new SolidColorBrush(colors[y, x]), null, new Rect(x, y, 1, 1));
                }
            }
            var drawnDisplay = new DrawingImage(visual.Drawing);
            drawnDisplay.Freeze();
            RazerDisplay = drawnDisplay;
        }
开发者ID:SpoinkyNL,项目名称:Artemis,代码行数:20,代码来源:DebugViewModel.cs

示例14: GetImage


//.........这里部分代码省略.........
				drawing1.Geometry = new LineGeometry(new Point(0, height / 2), new Point(width, height / 2));
				drawing1.Pen = new Pen(Brushes.Black, lineWidth);
				group.Children.Add(drawing1);

				drawing1 = new GeometryDrawing();
				drawing1.Geometry = new LineGeometry(new Point(width / 2, 0), new Point(width / 2, height));
				drawing1.Pen = new Pen(Brushes.Black, lineWidth);
				group.Children.Add(drawing1);
			}
			else
			{
				var drawing1 = new GeometryDrawing();
				if (absscale > 2)
					drawing1.Geometry = new EllipseGeometry(new Point(width / 2, height / 2), (width / 2), (height / 2) / absscale);
				else if (absscale > 1)
					drawing1.Geometry = new EllipseGeometry(new Point(width / 2, height / 2), (width / 4) * absscale, (height / 4));
				else if (absscale > 0.5)
					drawing1.Geometry = new EllipseGeometry(new Point(width / 2, height / 2), (width / 4), (height / 4) / absscale);
				else if (absscale > 0)
					drawing1.Geometry = new EllipseGeometry(new Point(width / 2, height / 2), (width / 2) * absscale, (height / 2));

				//	drawing1.Brush = new RadialGradientBrush(Color.FromRgb(204, 204, 255), Color.FromRgb(100, 100, 255));
				if (scale > 0)
					drawing1.Brush = new LinearGradientBrush(Color.FromRgb(204, 204, 255), Color.FromRgb(100, 100, 255), 0);
				else
					drawing1.Brush = new LinearGradientBrush(Color.FromRgb(100, 100, 255), Color.FromRgb(204, 204, 255), 0);

				group.Children.Add(drawing1);

				drawing1 = new GeometryDrawing();
				drawing1.Geometry = new LineGeometry(new Point(0, height / 2), new Point(width, height / 2));
				drawing1.Pen = new Pen(Brushes.Black, lineWidth);
				group.Children.Add(drawing1);

				Point d11, d12, d13;
				Point d21, d22, d23;

				if (absscale > 1)
				{
					// triangles pointing outside;
					d11 = new Point(0, height / 2);
					d12 = new Point(width / 4, height / 2 + height / 8);
					d13 = new Point(width / 4, height / 2 - height / 8);

					d21 = new Point(width, height / 2);
					d22 = new Point(width - width / 4, height / 2 + height / 8);
					d23 = new Point(width - width / 4, height / 2 - height / 8);
				}
				else
				{
					// triangles pointing inside
					d11 = new Point(width / 4, height / 2);
					d12 = new Point(0, height / 2 + height / 8);
					d13 = new Point(0, height / 2 - height / 8);

					d21 = new Point(width - width / 4, height / 2);
					d22 = new Point(width, height / 2 + height / 8);
					d23 = new Point(width, height / 2 - height / 8);
				}

				// now adjust the triangles a little
				if (absscale > 2)
				{
					// nothing to do here, the triangles are already max outside
				}
				else if (absscale > 1)
				{
					double offs = width / 2 - absscale * (width / 4);
					d11.X += offs; d12.X += offs; d13.X += offs;
					d21.X -= offs; d22.X -= offs; d23.X -= offs;
				}
				else if (absscale > 0.5)
				{
					// nothing to do here, the triangles are already max outside
				}
				else if (absscale > 0)
				{
					double offs = width / 4 - absscale * width / 2;
					d11.X += offs; d12.X += offs; d13.X += offs;
					d21.X -= offs; d22.X -= offs; d23.X -= offs;
				}

				var fig1 = new PathFigure(d11, new PathSegment[] { new LineSegment(d12, false), new LineSegment(d13, false) }, true);
				var fig2 = new PathFigure(d21, new PathSegment[] { new LineSegment(d22, false), new LineSegment(d23, false) }, true);

				drawing1 = new GeometryDrawing();
				drawing1.Geometry = new PathGeometry(new PathFigure[] { fig1, fig2 });
				drawing1.Brush = Brushes.Black;
				group.Children.Add(drawing1);
			}

			if (isForY)
				group.Transform = new RotateTransform(90, width / 2, height / 2);

			var geometryImage = new DrawingImage(group);

			// Freeze the DrawingImage for performance benefits.
			geometryImage.Freeze();
			return geometryImage;
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:101,代码来源:ScaleComboBox.xaml.cs

示例15: CreateVisuals

        private void CreateVisuals(ITextViewLine line)
        {

            {
                var text = line.Extent.GetText();
                if (!regex.IsMatch(text)) return;

            }


            IWpfTextViewLineCollection textViewLines = this.view.TextViewLines;

            // Loop through each character, and place a box around any 'a'
            for (int charIndex = line.Start; charIndex < line.End; charIndex++)
            {
                if (this.view.TextSnapshot[charIndex] == 'a')
                {
                    SnapshotSpan span = new SnapshotSpan(this.view.TextSnapshot, Span.FromBounds(charIndex, charIndex + 1));
                    Geometry geometry = textViewLines.GetMarkerGeometry(span);
                    if (geometry != null)
                    {
                        var drawing = new GeometryDrawing(this.brush, this.pen, geometry);
                        drawing.Freeze();

                        var drawingImage = new DrawingImage(drawing);
                        drawingImage.Freeze();

                        var image = new Image
                        {
                            Source = drawingImage,
                        };

                        // Align the image with the top of the bounds of the text geometry
                        Canvas.SetLeft(image, geometry.Bounds.Left);
                        Canvas.SetTop(image, geometry.Bounds.Top);

                        this.layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, null, image, null);
                    }
                }
            }
        }
开发者ID:powerumc,项目名称:LinkViewerVSIX,代码行数:41,代码来源:LinkViewerTextAdornment.cs


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