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


C# DrawingContext.PushOpacity方法代码示例

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


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

示例1: OnRender

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

            if (mDraggedElement != null) {
                Win32.POINT screenPos = new Win32.POINT();
                if (Win32.GetCursorPos(ref screenPos)) {
                    Point pos = PointFromScreen(new Point(screenPos.X, screenPos.Y));
                    Rect rect = new Rect(pos.X, pos.Y, mDraggedElement.ActualWidth, mDraggedElement.ActualHeight);
                    drawingContext.PushOpacity(1.0);          
                    drawingContext.DrawRectangle(new VisualBrush(mDraggedElement),
                        new Pen(Brushes.Transparent, 0), rect);
                   // drawingContext.Pop();
                }
            }
        }
开发者ID:ychost,项目名称:PowerControlSimulation,代码行数:15,代码来源:DragDropAdorner.cs

示例2: OnRender

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

            if (_borderVisible)
            {
                dc.DrawRectangle(null, OuterPen, new Rect(0.5, 0.5, Zoom * Screen.PixelWidth - 1, Zoom * Screen.PixelHeight - 1));
                dc.DrawRectangle(null, InnerPen, new Rect(1.5, 1.5, Zoom * Screen.PixelWidth - 3, Zoom * Screen.PixelHeight - 3));
            }

            if (_propertiesVisible)
            {
                dc.PushOpacity(0.5);
                dc.DrawImage(_propertiesBitmap, new Rect(0, 0, Zoom * Screen.PixelWidth, Zoom * Screen.PixelHeight));
                dc.Pop();
            }
        }
开发者ID:Tesserex,项目名称:C--MegaMan-Engine,代码行数:17,代码来源:GuidesLayer.cs

示例3: OnRender

        protected override void OnRender(DrawingContext drawingContext)
        {
            // draw everything except the reflection
            base.OnRender(drawingContext);

            // set opacity
            drawingContext.PushOpacityMask(_opacityMask);
            drawingContext.PushOpacity(0.4);

            // set reflection parameters based on content size
            _reflection.Visual = Child;

            // draw the reflection
            drawingContext.DrawRectangle(_reflection, null, new Rect(0, ActualHeight + _gap, ActualWidth, ActualHeight));

            // cleanup
            drawingContext.Pop();
            drawingContext.Pop();
        }
开发者ID:hegaojie,项目名称:MovieHouse,代码行数:19,代码来源:ReflectionControl.cs

示例4: OnRender

		protected override void OnRender(DrawingContext drawingContext)
		{
			Size renderSize = this.RenderSize;
			drawingContext.DrawRectangle(SystemColors.ControlBrush, null,
			                             new Rect(0, 0, renderSize.Width, renderSize.Height));
			drawingContext.DrawLine(new Pen(SystemColors.ControlDarkBrush, 1),
			                        new Point(renderSize.Width - 0.5, 0),
			                        new Point(renderSize.Width - 0.5, renderSize.Height));
			
			TextView textView = this.TextView;
			if (textView != null && textView.VisualLinesValid) {
				// create a dictionary line number => first bookmark
				Dictionary<int, BookmarkBase> bookmarkDict = new Dictionary<int, BookmarkBase>();
				foreach (var bm in BookmarkManager.Bookmarks) {
					if (DebugData.DecompiledMemberReferences == null || DebugData.DecompiledMemberReferences.Count == 0 ||
					    !DebugData.DecompiledMemberReferences.ContainsKey(bm.MemberReference.MetadataToken.ToInt32()))
						continue;
					
					int line = bm.LineNumber;
					BookmarkBase existingBookmark;
					if (!bookmarkDict.TryGetValue(line, out existingBookmark) || bm.ZOrder > existingBookmark.ZOrder)
						bookmarkDict[line] = bm;
				}
				Size pixelSize = PixelSnapHelpers.GetPixelSize(this);
				foreach (VisualLine line in textView.VisualLines) {
					int lineNumber = line.FirstDocumentLine.LineNumber;
					BookmarkBase bm;
					if (bookmarkDict.TryGetValue(lineNumber, out bm)) {
						Rect rect = new Rect(0, PixelSnapHelpers.Round(line.VisualTop - textView.VerticalOffset, pixelSize.Height), 16, 16);
						if (dragDropBookmark == bm && dragStarted)
							drawingContext.PushOpacity(0.5);
						drawingContext.DrawImage(bm.Image, rect);
						if (dragDropBookmark == bm && dragStarted)
							drawingContext.Pop();
					}
				}
				if (dragDropBookmark != null && dragStarted) {
					Rect rect = new Rect(0, PixelSnapHelpers.Round(dragDropCurrentPoint - 8, pixelSize.Height), 16, 16);
					drawingContext.DrawImage(dragDropBookmark.Image, rect);
				}
			}
		}
开发者ID:rmattuschka,项目名称:ILSpy,代码行数:42,代码来源:IconBarMargin.cs

示例5: OnRender

        protected override void OnRender(DrawingContext drawingContext)
        {
            // draw everything except the reflection
            base.OnRender(drawingContext);

            // set opacity
            drawingContext.PushOpacityMask(_opacityMask);
            drawingContext.PushOpacity(0.3);

            // set reflection parameters based on content size
            _reflection.Visual = Child;
            ((ScaleTransform)_reflection.Transform).CenterY = 3 * ActualHeight / 4;
            ((ScaleTransform)_reflection.Transform).CenterX = ActualWidth / 2;

            // draw the reflection
            drawingContext.DrawRectangle(
                _reflection, null,
                new Rect(0, ActualHeight / 2, ActualWidth, ActualHeight / 2));

            // cleanup
            drawingContext.Pop();
            drawingContext.Pop();
        }
开发者ID:nirdobovizki,项目名称:MvvmControls,代码行数:23,代码来源:ReflectionControl.cs

示例6: OnRender

 protected override void OnRender(DrawingContext dc) {
    dc.PushOpacity(0.7);
    dc.DrawRectangle(Brush, null, Bounds);
    dc.Pop();
 }
开发者ID:borkaborka,项目名称:gmit,代码行数:5,代码来源:ScriptBlock.xaml.cs

示例7: OnRender

 /// <summary>
 /// OnRender
 /// </summary>
 protected override void OnRender(DrawingContext drawingContext)
 {
     drawingContext.PushOpacity(0.45d);
     //recurse through the tree of results
     DrawFeedback(drawingContext, _inkAnalyzer.RootNode);
 }
开发者ID:buptkang,项目名称:LogicPad,代码行数:9,代码来源:InkAnalysisFeedbackAdorner.cs

示例8: RenderText

 private void RenderText(string textMessage, double opacity, DrawingContext drawingContext)
 {
     var text = new FormattedText(
         textMessage,
         CultureInfo.InvariantCulture,
         FlowDirection.LeftToRight,
         new Typeface("Verdana"),
         36,
         Brushes.WhiteSmoke);
     drawingContext.PushOpacity(opacity);
     drawingContext.DrawText(
         text,
         new Point(
             _lastControlSize.Width / 2 - text.Width / 2,
             _lastControlSize.Height / 2 - text.Height / 2));
     drawingContext.Pop();
 }
开发者ID:Bruhankovi4,项目名称:Emotyper,代码行数:17,代码来源:CurveDrawingSurface.cs

示例9: OnRenderCaretSubElement

        /// <summary> 
        /// Performs the actual rendering of the caret on the given context.  Called by
        /// CaretSubElement. 
        /// </summary>
        /// <param name="context">Drawing context</param>
        /// <remarks>This method is on CaretElement instead of CaretSubElement because CaretElement
        /// knows all of the necessary data, and conceptually CaretSubElement only exists to provide 
        /// a rendering surface.</remarks>
        internal void OnRenderCaretSubElement(DrawingContext context) 
        { 
            // [....] up Win32 caret position with Avalon caret position.
            Win32SetCaretPos(); 

            if (_showCaret)
            {
                TextEditorThreadLocalStore threadLocalStore = TextEditor._ThreadLocalStore; 

                Invariant.Assert(!(_italic && this.IsInInterimState), "Assert !(_italic && IsInInterimState)"); 
 
                // Drawing context's pushed count to pop it up
                int contextPushedCount = 0; 

                // Apply internally requested opacity.
                context.PushOpacity(_opacity);
                contextPushedCount++; 

                // Apply italic transformation 
                if (_italic && !(threadLocalStore.Bidi)) 
                {
                    // Rotate transform 20 degree for italic that is the based on 'H' italic degree. 
                    // NOTE: The angle of italic caret is constant. This is Word behavior
                    // established after usability studies with conditional angle dependent
                    // on font properties - they discovered that variations look annoying.
                    // NOTE: We ignore _italic setting in _bidi case. This is Word behavior. 
                    // When flow direction is Right to Left, we need to reverse the caret transform.
                    // 
                    // Get the flow direction which is the flow direction of AdornedElement. 
                    // CaretElement is rendering the caret that based on AdornedElement, so we can
                    // render the right italic caret whatever the text content set the flow direction. 
                    FlowDirection flowDirection = (FlowDirection)AdornedElement.GetValue(FlowDirectionProperty);
                    context.PushTransform(new RotateTransform(
                    flowDirection == FlowDirection.RightToLeft ? -20 : 20,
 
                        0,  _height));
 
                    contextPushedCount++; 
                }
 
                if (this.IsInInterimState || _systemCaretWidth > DefaultNarrowCaretWidth)
                {
                    // Make the block caret partially transparent to avoid obstructing text.
                    context.PushOpacity(CaretOpacity); 
                    contextPushedCount++;
                } 
 
                if (this.IsInInterimState)
                { 
                    // Render the interim block caret as the specified interim block caret width.
                    context.DrawRectangle(_caretBrush, null, new Rect(0, 0, _interimWidth, _height));
                }
                else 
                {
                    // Snap the caret to device pixels. 
                    if (!_italic || threadLocalStore.Bidi) 
                    {
                        GuidelineSet guidelineSet = new GuidelineSet(new double[] { -(_systemCaretWidth / 2), _systemCaretWidth / 2 }, null); 
                        context.PushGuidelineSet(guidelineSet);
                        contextPushedCount++;
                    }
 
                    // If we don't snap, the caret will render as a 2 pixel wide rect, one pixel in each bordering char bounding box.
                    context.DrawRectangle(_caretBrush, null, new Rect(-(_systemCaretWidth / 2), 0, _systemCaretWidth, _height)); 
                } 

                if (threadLocalStore.Bidi) 
                {
                    // Set the Bidi caret indicator width. TextBox/RichTextBox control must have
                    // the enough margin to display BiDi indicator.
                    double bidiCaretIndicatorWidth = BidiCaretIndicatorWidth; 

                    // Get the flow direction which is the flow direction of AdornedElement. 
                    // Because CaretElement is rendering the caret that based on AdornedElement. 
                    // With getting the flow direction, we can render the BiDi caret indicator correctly
                    // whatever AdornedElement's flow direction is set. 
                    FlowDirection flowDirection = (FlowDirection)AdornedElement.GetValue(FlowDirectionProperty);
                    if (flowDirection == FlowDirection.RightToLeft)
                    {
                        // BiDi caret indicator should always direct by the right to left 
                        bidiCaretIndicatorWidth = bidiCaretIndicatorWidth * (-1);
                    } 
 
                    // Draw BIDI caret to indicate the coming input is BIDI characters.
                    // Shape is a little flag oriented to the left - as in Word. 
                    // Orientation does not depend on anything (which seems to be Word behavior).
                    //
                    PathGeometry pathGeometry;
                    PathFigure pathFigure; 

                    pathGeometry = new PathGeometry(); 
                    pathFigure = new PathFigure(); 
//.........这里部分代码省略.........
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:101,代码来源:CaretElement.cs

示例10: DrawChip

        private void DrawChip(DrawingContext drawingContext, System.Windows.Rect r, Face f)
        {
            if (f == null) {
                drawingContext.DrawImage(ChartView.graychip, r);
                //drawingContext.PushOpacity(.1);
                //drawingContext.DrawImage(ChartView.pinkchipBorder, r);
                //drawingContext.Pop();
                return;
            }
            if (f.Finalized) {
                if (f.Gender == "m")
                    drawingContext.DrawImage(ChartView.bluechipBorder, r);
                else if (f.Gender == "f")
                    drawingContext.DrawImage(ChartView.pinkchipBorder, r);
                return;
            }

            drawingContext.DrawImage(ChartView.graychip, r);
            if (f.BetafaceReturned) {
                double percentColor = f.GenderTotalConf / Face.CONF_THRESH;
                if (f.Gender == "m") {
                    drawingContext.PushOpacity(percentColor);
                    drawingContext.DrawImage(ChartView.bluechip, r);
                    drawingContext.Pop();
                } else if (f.Gender == "f") {
                    drawingContext.PushOpacity(percentColor);
                    drawingContext.DrawImage(ChartView.pinkchip, r);
                    drawingContext.Pop();
                }
            }
        }
开发者ID:jkiske,项目名称:Senior-Design,代码行数:31,代码来源:FaceTrackingViewer.xaml.cs

示例11: OnRender

        /// <summary>
        /// Draws a mouse cursor on the adorened element
        /// </summary>
        /// <param name="drawingContext"></param>
        protected override void OnRender(DrawingContext drawingContext)
        {
            GeneralTransform inverse = elementTransform.Inverse;
            if (inverse == null)
                return;

            Brush blackBrush = new SolidColorBrush(Colors.Black);
            blackBrush.Freeze();

            float radius = 5;

            Pen blackPen = new Pen(blackBrush, .7);
            blackPen.Freeze();

            if (isInPanMode)
            {
                //drawing the pan icon symbol
                if (panCursorImage != null)
                    drawingContext.DrawImage(panCursorImage, new Rect(mousePoint, new Size(16, 16)));
            }
            else
            {
                // Draw the normal zooming symbol
                drawingContext.DrawLine(blackPen, new Point(mousePoint.X, mousePoint.Y - radius), new Point(mousePoint.X, mousePoint.Y + radius));
                drawingContext.DrawLine(blackPen, new Point(mousePoint.X - radius, mousePoint.Y), new Point(mousePoint.X + radius, mousePoint.Y));
            }

            if (lockPoints.Count >0)
            {
                foreach(ColoredPoint pt in lockPoints)
                    if (pt.pointData.Y >= 0 && pt.pointData.Y <= canvasSize.Height)
                    {
                        Brush cursorBrush = new SolidColorBrush(pt.pointColor);
                        Pen cursorPen = new Pen(cursorBrush, 0.7);
                        cursorBrush.Freeze();
                        cursorPen.Freeze();

                        drawingContext.DrawEllipse(cursorBrush, cursorPen, pt.pointData, 4, 4);
                    }
            }

            if (isDrawingZoomVisual)
            {
                Rect rect = new Rect();

                rect.X = Math.Min(mouseDownPoint.X, mousePoint.X);
                rect.Y = Math.Min(mouseDownPoint.Y, mousePoint.Y);
                rect.Width = Math.Abs(mouseDownPoint.X - mousePoint.X);
                rect.Height = Math.Abs(mouseDownPoint.Y - mousePoint.Y);

                Brush zoomingBrush = new SolidColorBrush(Colors.LightBlue);

                drawingContext.PushOpacity(0.3);
                drawingContext.DrawRectangle(zoomingBrush, blackPen, rect);
                drawingContext.Pop();
            }
        }
开发者ID:jamesjrg,项目名称:taipan,代码行数:61,代码来源:AdornerCursor.cs

示例12: DrawMapPosition

        private void DrawMapPosition(DrawingContext context)
        {
            var myDoubleAnimation = new DoubleAnimation();
            myDoubleAnimation.From = 1.0;
            myDoubleAnimation.To = 0.0;
            myDoubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(3));

            context.PushOpacity(1.0, myDoubleAnimation.CreateClock());
            context.DrawRectangle(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF2B2B2B")),
                                  null, new Rect(702, 10, 248, 64));
            var relativePositions = RelativePositions();
            var position = new FormattedText(
                        relativePositions.Item1.ToString() + "% / " + relativePositions.Item2.ToString() + "%",
                        CultureInfo.GetCultureInfo("en-us"),
                        FlowDirection.LeftToRight,
                        new Typeface("Charlemagne STD"),
                        36,
                        Brushes.PaleVioletRed);
            context.DrawText(position, new Point(712, 20));
        }
开发者ID:eske,项目名称:INSAWars,代码行数:20,代码来源:GameView.xaml.cs

示例13: DrawInvalidCommand

        private void DrawInvalidCommand(DrawingContext context)
        {
            var origin = CaseVisibleOffset(_displayInvalidCommandOn.X, _displayInvalidCommandOn.Y);
            var myDoubleAnimation = new DoubleAnimation();
            myDoubleAnimation.From = 1.0;
            myDoubleAnimation.To = 0.0;
            myDoubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(3));

            context.PushOpacity(1.0, myDoubleAnimation.CreateClock());
            context.DrawRectangle(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#55FF2B2B")),
                null, new Rect(origin.Item1, origin.Item2, CaseWidth, CaseHeight));
            context.Pop();
        }
开发者ID:eske,项目名称:INSAWars,代码行数:13,代码来源:GameControl.xaml.cs

示例14: Draw

        /// <summary>
        /// Render the StrokeCollection under the specified DrawingContext. This draw method uses the
        /// passing in drawing attribute to override that on the stroke.
        /// </summary>
        /// <param name="drawingContext"></param>
        /// <param name="drawingAttributes"></param>
        public void Draw(DrawingContext drawingContext, DrawingAttributes drawingAttributes)
        {
            if (null == drawingContext)
            {
                throw new System.ArgumentNullException("context");
            }

            if (null == drawingAttributes)
            {
                throw new System.ArgumentNullException("drawingAttributes");
            }

            //             context.VerifyAccess();

            //our code never calls this public API so we can assume that opacity
            //has not been set up

            if (drawingAttributes.IsHighlighter)
            {
                drawingContext.PushOpacity(StrokeRenderer.HighlighterOpacity);
                try
                {
                    this.DrawInternal(drawingContext, StrokeRenderer.GetHighlighterAttributes(this, this.DrawingAttributes), false);
                }
                finally
                {
                    drawingContext.Pop();
                }
            }
            else
            {
                this.DrawInternal(drawingContext, drawingAttributes, false);
            }
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:40,代码来源:Stroke2.cs

示例15: OnRender

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

            drawingContext.PushOpacityMask(ReflectionMask);
            drawingContext.PushOpacity(ReflectionOpacity);

            _mReflection.Visual = Child;

            ((ScaleTransform)_mReflection.Transform).CenterY = 3 * ActualHeight / 4;
            ((ScaleTransform)_mReflection.Transform).CenterX = ActualWidth / 2;

            drawingContext.DrawRectangle(_mReflection, null, new Rect(0, ActualHeight / 2, ActualWidth, ActualHeight / 2));

            drawingContext.Pop();
            drawingContext.Pop();
        }
开发者ID:HWiese1980,项目名称:HAW-Stundenplan,代码行数:17,代码来源:ReflectionControl.cs


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