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


C# Cairo.SetSourceColor方法代码示例

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


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

示例1: OnDrawn

        protected override bool OnDrawn(Cairo.Context cr)
        {
            double step_width = Allocation.Width / (double)steps;
            double step_height = Allocation.Height / (double)steps;
            double h = 1.0;
            double s = 0.0;

            for (int xi = 0, i = 0; xi < steps; xi++) {
                for (int yi = 0; yi < steps; yi++, i++) {
                    double bg_b = (double)(i / 255.0);
                    double fg_b = 1.0 - bg_b;

                    double x = xi * step_width;
                    double y = yi * step_height;

                    cr.Rectangle (x, y, step_width, step_height);
                    cr.SetSourceColor (CairoExtensions.ColorFromHsb (h, s, bg_b));
                    cr.Fill ();

                    int tw, th;
                    Pango.Layout layout = new Pango.Layout (PangoContext);
                    layout.SetText (((int)(bg_b * 255.0)).ToString ());
                    layout.GetPixelSize (out tw, out th);

                    cr.Translate (0.5, 0.5);
                    cr.MoveTo (x + (step_width - tw) / 2.0, y + (step_height - th) / 2.0);
                    cr.SetSourceColor (CairoExtensions.ColorFromHsb (h, s, fg_b));
                    Pango.CairoHelper.ShowLayout (cr, layout);
                    cr.Translate (-0.5, -0.5);
                }
            }

            return true;
        }
开发者ID:GNOME,项目名称:hyena,代码行数:34,代码来源:ShadingTestWindow.cs

示例2: DrawFrameBorder

        public override void DrawFrameBorder(Cairo.Context cr, Gdk.Rectangle alloc)
        {
            if (IsPanelWidget) {
                return;
            } else if (!IsSourceViewWidget) {
                base.DrawFrameBorder (cr, alloc);
                return;
            }

            cr.SetSourceColor (TextMidColor);
            cr.LineWidth = 1.0;
            cr.Antialias = Cairo.Antialias.None;

            cr.MoveTo (alloc.Right - 1, alloc.Top);
            cr.LineTo (alloc.Right - 1, alloc.Bottom);
            cr.Stroke ();

            if (Widget.Allocation.Bottom < Widget.Toplevel.Allocation.Height) {
                cr.MoveTo (alloc.Left, alloc.Bottom - 1);
                cr.LineTo (alloc.Right, alloc.Bottom - 1);
                cr.Stroke ();
            }

            cr.Antialias = Cairo.Antialias.Default;
        }
开发者ID:dufoli,项目名称:banshee,代码行数:25,代码来源:MediaPanelTheme.cs

示例3: OnDrawn

		protected override bool OnDrawn(Cairo.Context cr)
		{
			bool ret = true;
			var rect = this.Allocation;
			if (rect.Width > 0 && rect.Height > 0)
			{
				var arrowWidth = popupButton.Allocation.Width;
				var arrowPos = rect.Width - arrowWidth;
				var arrowSize = 10;

				StyleContext.Save();
				StyleContext.AddClass("entry");
				StyleContext.RenderBackground(cr, 0, 0, rect.Width, rect.Height);

				ret = base.OnDrawn(cr);

				StyleContext.RenderArrow(cr, Math.PI, arrowPos, (rect.Height - arrowSize) / 2, arrowSize);

				cr.SetSourceColor(new Cairo.Color(.8, .8, .8));
				cr.Rectangle(arrowPos - 5, 2, 1, rect.Height - 4);
				cr.Fill();

				Entry.StyleContext.RenderFrame(cr, 0, 0, rect.Width, rect.Height);
				StyleContext.Restore();

			}
			return ret;
		}
开发者ID:mhusen,项目名称:Eto,代码行数:28,代码来源:BaseComboBox.cs

示例4: Draw

		internal protected override void Draw (Cairo.Context cr, Cairo.Rectangle area, DocumentLine lineSegment, int line, double x, double y, double lineHeight)
		{
			cr.MoveTo (x + 0.5, y);
			cr.LineTo (x + 0.5, y + lineHeight);
			cr.SetSourceColor (color);
			cr.Stroke ();
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:7,代码来源:DashedLineMargin.cs

示例5: DrawBackground

		public override bool DrawBackground (TextEditor editor, Cairo.Context cr, double y, LineMetrics metrics)
		{
			if (metrics.SelectionStart > 0)
				return true;
			cr.SetSourceColor (color);
			cr.Rectangle (metrics.TextRenderStartPosition, y, metrics.TextRenderEndPosition - metrics.TextRenderStartPosition, editor.LineHeight);
			cr.Fill ();
			return true;
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:9,代码来源:LineBackgroundMarker.cs

示例6: DrawMarginBackground

		void DrawMarginBackground (Cairo.Context cr, int line, double x, double y, double lineHeight)
		{
			if (editor.Caret.Line == line) {
				editor.TextViewMargin.DrawCaretLineMarker (cr, x, y, Width, lineHeight);
				return;
			}
			cr.Rectangle (x, y, Width, lineHeight);
			cr.SetSourceColor (editor.ColorStyle.LineNumbers.Background);
			cr.Fill ();
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:10,代码来源:ActionMargin.cs

示例7: DrawFrameBackground

 public override void DrawFrameBackground(Cairo.Context cr, Gdk.Rectangle alloc, Cairo.Color color, Cairo.Pattern pattern)
 {
     color.A = Context.FillAlpha;
     if (pattern != null) {
         cr.SetSource (pattern);
     } else {
         cr.SetSourceColor (color);
     }
     CairoExtensions.RoundedRectangle (cr, alloc.X, alloc.Y, alloc.Width, alloc.Height, Context.Radius, CairoCorners.All);
     cr.Fill ();
 }
开发者ID:GNOME,项目名称:hyena,代码行数:11,代码来源:GtkTheme.cs

示例8: DrawHand

		void DrawHand(double fThickness, double length, Cairo.Color color, double radians, Cairo.Context e)
		{
			e.MoveTo(new Cairo.PointD(center.X - (length / 9 * Math.Sin(radians)), center.Y + (length / 9 * Math.Cos(radians))));
			e.LineTo(new Cairo.PointD(center.X + (length * Math.Sin(radians)), center.Y - (length * Math.Cos(radians))));
			e.ClosePath();
			e.LineCap = Cairo.LineCap.Round;
			e.LineJoin = Cairo.LineJoin.Round;
			e.SetSourceColor(color);
			e.LineWidth = fThickness;
			e.Stroke();
		}
开发者ID:mhusen,项目名称:Eto,代码行数:11,代码来源:AnalogClock.cs

示例9: Draw

		public override void Draw (Mono.TextEditor.MonoTextEditor editor, Cairo.Context cr, LineMetrics metrics, int startOffset, int endOffset)
		{
			this.editor = editor;
			var line = editor.GetLine (loc.Line);
			if (line == null)
				return;
			var x = editor.ColumnToX (line, loc.Column) - editor.HAdjustment.Value + editor.TextViewMargin.XOffset + editor.TextViewMargin.TextStartPosition;

			cr.Rectangle (Math.Floor (x), Math.Floor (metrics.LineYRenderStartPosition) + (line == editor.GetLineByOffset (startOffset) ? editor.LineHeight - tagMarkerHeight : 0), tagMarkerWidth, tagMarkerHeight);
			cr.SetSourceColor ((HslColor.Brightness (editor.ColorStyle.PlainText.Background) < 0.5 ? Ide.Gui.Styles.Editor.SmartTagMarkerColorDark : Ide.Gui.Styles.Editor.SmartTagMarkerColorLight).ToCairoColor ());
			cr.Fill ();
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:12,代码来源:SmartTagMarker.cs

示例10: DrawBar

		protected virtual void DrawBar (Cairo.Context cr)
		{
			if (vadjustment == null || vadjustment.Upper <= vadjustment.PageSize) 
				return;

			double x, y, w, h;
			GetBarDimensions (out x, out y, out w, out h);

			if (Platform.IsWindows) {
				cr.Rectangle (x, y, w, h);
			} else {
				MonoDevelop.Components.CairoExtensions.RoundedRectangle (cr, x, y, w, h, 4);
			}

			bool prelight = State == StateType.Prelight;

			Cairo.Color c;
			if (Platform.IsWindows) {
				c = prelight ? win81SliderPrelight : win81Slider;
				//compute new color such that it will produce same color when blended with bg
				c = AddAlpha (win81Background, c, 0.5d);
			} else {
				c = new Cairo.Color (0, 0, 0, (prelight ? 50.0 : 22.0) / 255);
			}
			cr.SetSourceColor (c);
			cr.Fill ();
		}
开发者ID:GroM,项目名称:monodevelop,代码行数:27,代码来源:QuickTaskOverviewMode.cs

示例11: DrawQuickTasks

		protected Severity DrawQuickTasks (Cairo.Context cr)
		{
			Severity severity = Severity.None;
			/*
			foreach (var usage in AllUsages) {
				double y = GetYPosition (usage.Line);
				var usageColor = TextEditor.ColorStyle.PlainText.Foreground;
				usageColor.A = 0.4;
				cr.Color = usageColor;
				cr.MoveTo (0, y - 3);
				cr.LineTo (5, y);
				cr.LineTo (0, y + 3);
				cr.ClosePath ();
				cr.Fill ();
			}
*/
			foreach (var task in AllTasks) {
				double y = GetYPosition (task.Location.Line);

				cr.SetSourceColor (GetBarColor (task.Severity));
				cr.Rectangle (0, Math.Round (y) - 1, Allocation.Width, 2);
				cr.Fill ();

				switch (task.Severity) {
				case Severity.Error:
					severity = Severity.Error;
					break;
				case Severity.Warning:
					if (severity == Severity.None)
						severity = Severity.Warning;
					break;
				}
			}
			return severity;
		}
开发者ID:GroM,项目名称:monodevelop,代码行数:35,代码来源:QuickTaskOverviewMode.cs

示例12: DrawIndicator

		void DrawIndicator (Cairo.Context cr, Cairo.Color color, Cairo.Color borderColor)
		{
			var width = Allocation.Width;

			int diameter = Math.Min (width, (int)IndicatorHeight) - indicatorPadding * 2;
			var x1 = Math.Round (width / 2d);
			double y1 = indicatorPadding + diameter / 2;
			if (diameter % 2 == 0) {
				x1 += 0.5;
				y1 += 0.5;
			}

			cr.Arc (x1, y1, diameter / 2d, 0, 2 * Math.PI);

			if (Platform.IsWindows) {
				using (var pattern = new Cairo.SolidPattern (color)) {
					cr.SetSource (pattern);
					cr.FillPreserve ();
				}
			} else {
				using (var pattern = new Cairo.RadialGradient (x1, y1, width / 2, x1 - width, y1 - width, width)) {
					pattern.AddColorStop (0, borderColor);
					pattern.AddColorStop (1, color);
					cr.SetSource (pattern);
					cr.FillPreserve ();
				}
			}
			
			cr.SetSourceColor (borderColor);
			cr.Stroke ();
		}
开发者ID:GroM,项目名称:monodevelop,代码行数:31,代码来源:QuickTaskOverviewMode.cs

示例13: Draw

			public override void Draw (Cairo.Context cr, Cairo.Rectangle erea)
			{
				TextEditor editor = mode.editor;
				
				double y = editor.LineToY (mode.CurrentInsertionPoint.Line) - editor.VAdjustment.Value; 
				double x = GetLineIndentationStart ();
				double x2 = editor.Allocation.Width - mode.HelpWindow.Allocation.Width - InsertionCursorEditMode.HelpWindowMargin * 2;
				cr.MoveTo (x, y);
				cr.LineTo (x2, y);

				cr.SetSourceColor (LineColor);
				cr.Stroke ();
				
//				DrawArrow (cr, x - 4, y);
			}
开发者ID:riverans,项目名称:monodevelop,代码行数:15,代码来源:InsertionCursorEditMode.cs

示例14: DrawBackground

		public override bool DrawBackground (TextEditor editor, Cairo.Context g, double y, LineMetrics metrics)
		{
			if (!IsVisible)
				return false;
			bool markerShouldDrawnAsHidden = cache.CurrentSelectedTextMarker != null && cache.CurrentSelectedTextMarker != this;
			if (metrics.LineSegment.Markers.Any (m => m is DebugTextMarker))
				return false;

			EnsureLayoutCreated (editor);
			double x = editor.TextViewMargin.XOffset;
			int right = editor.Allocation.Width;
			bool isCaretInLine = metrics.TextStartOffset <= editor.Caret.Offset && editor.Caret.Offset <= metrics.TextEndOffset;
			int errorCounterWidth = GetErrorCountBounds (metrics).Item1;

			double x2 = System.Math.Max (right - LayoutWidth - border - (ShowIconsInBubble ? cache.errorPixbuf.Width : 0) - errorCounterWidth, editor.TextViewMargin.XOffset + editor.LineHeight / 2);

			bool isEolSelected = editor.IsSomethingSelected && editor.SelectionMode != Mono.TextEditor.SelectionMode.Block ? editor.SelectionRange.Contains (lineSegment.Offset + lineSegment.Length) : false;

			int active = editor.Document.GetTextAt (lineSegment) == initialText ? 0 : 1;
			bool highlighted = active == 0 && isCaretInLine;

			// draw background
			if (!markerShouldDrawnAsHidden) {
				DrawRectangle (g, x, y, right, editor.LineHeight);
				g.SetSourceColor (LineColor.Color);
				g.Fill ();

				if (metrics.Layout.StartSet || metrics.SelectionStart == metrics.TextEndOffset) {
					double startX;
					double endX;

					if (metrics.SelectionStart != metrics.TextEndOffset) {
						var start = metrics.Layout.Layout.IndexToPos ((int)metrics.Layout.SelectionStartIndex);
						startX = (int)(start.X / Pango.Scale.PangoScale);
						var end = metrics.Layout.Layout.IndexToPos ((int)metrics.Layout.SelectionEndIndex);
						endX = (int)(end.X / Pango.Scale.PangoScale);
					} else {
						startX = x2;
						endX = startX;
					}

					if (editor.MainSelection.SelectionMode == Mono.TextEditor.SelectionMode.Block && startX == endX)
						endX = startX + 2;
					startX += metrics.TextRenderStartPosition;
					endX += metrics.TextRenderStartPosition;
					startX = Math.Max (editor.TextViewMargin.XOffset, startX);
					// clip region to textviewmargin start
					if (isEolSelected)
						endX = editor.Allocation.Width + (int)editor.HAdjustment.Value;
					if (startX < endX) {
						DrawRectangle (g, startX, y, endX - startX, editor.LineHeight);
						g.SetSourceColor (GetLineColor (highlighted, true));
						g.Fill ();
					}
				}
				DrawErrorMarkers (editor, g, metrics, y);
			}

			double y2 = y + 0.5;
			double y2Bottom = y2 + editor.LineHeight - 1;
			var selected = isEolSelected;
			var lineTextPx = editor.TextViewMargin.XOffset + editor.TextViewMargin.TextStartPosition + metrics.Layout.Width;
			if (x2 < lineTextPx) 
				x2 = lineTextPx;

			if (editor.Options.ShowRuler) {
				double divider = Math.Max (editor.TextViewMargin.XOffset, x + editor.TextViewMargin.RulerX);
				if (divider >= x2) {
					g.MoveTo (new Cairo.PointD (divider + 0.5, y2));
					g.LineTo (new Cairo.PointD (divider + 0.5, y2Bottom));
					g.SetSourceColor (GetLineColorBorder (highlighted, selected));
					g.Stroke ();
				}
			}

			return true;
		}
开发者ID:llucenic,项目名称:monodevelop,代码行数:77,代码来源:MessageBubbleTextMarker.cs

示例15: DrawIconMarginBackground

		void DrawIconMarginBackground (TextEditor ed, Cairo.Context cr, MarginDrawMetrics metrics)
		{
			cr.Rectangle (metrics.X, metrics.Y, metrics.Width, metrics.Height);
			cr.SetSourceColor (IconMarginColor.Color);
			cr.Fill ();
			cr.MoveTo (metrics.Right - 0.5, metrics.Y);
			cr.LineTo (metrics.Right - 0.5, metrics.Bottom);
			cr.SetSourceColor (IconMarginColor.BorderColor);
			cr.Stroke ();
			if (cache.CurrentSelectedTextMarker != null && cache.CurrentSelectedTextMarker != this) {
				cr.Rectangle (metrics.X, metrics.Y, metrics.Width, metrics.Height);
				cr.SetSourceRGBA (ed.ColorStyle.IndicatorMargin.Color.R, ed.ColorStyle.IndicatorMargin.Color.G, ed.ColorStyle.IndicatorMargin.Color.B, 0.5);
				cr.Fill ();
			}
		}
开发者ID:llucenic,项目名称:monodevelop,代码行数:15,代码来源:MessageBubbleTextMarker.cs


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