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


C# Cairo.DrawLine方法代码示例

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


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

示例1: DrawRectangleWithRuler

		public void DrawRectangleWithRuler (Cairo.Context cr, double x, Cairo.Rectangle area, Cairo.Color color, bool drawDefaultBackground)
		{
			bool isDefaultColor = color.R == defaultBgColor.R && color.G == defaultBgColor.G && color.B == defaultBgColor.B;
			if (isDefaultColor && !drawDefaultBackground)
				return;
			cr.Color = color;
			var left = (int)(area.X);
			var width = (int)area.Width + 1;
			if (textEditor.Options.ShowRuler) {
				var right = left + width;

				var divider = (int) (System.Math.Max (left, System.Math.Min (x + TextStartPosition + rulerX, right)));
				if (divider < right) {
					var beforeDividerWidth = divider - left;
					if (beforeDividerWidth > 0) {
						cr.Rectangle (left, area.Y, beforeDividerWidth, area.Height);
						cr.Fill ();
					}
					cr.Rectangle (divider, area.Y, right - divider, area.Height);
					cr.Color = DimColor (color);
					cr.Fill ();

					if (beforeDividerWidth > 0) {
						cr.DrawLine (
							ColorStyle.Ruler.Color,
							divider + 0.5, area.Y,
							divider + 0.5, area.Y + area.Height);
					}
					return;
				}
			}

			cr.Rectangle (left, area.Y, System.Math.Ceiling (area.Width), area.Height);
			cr.Fill ();
		}
开发者ID:OnorioCatenacci,项目名称:monodevelop,代码行数:35,代码来源:TextViewMargin.cs

示例2: Draw

		public override void Draw (TextEditor editor, Cairo.Context cr, Pango.Layout layout, bool selected, int startOffset, int endOffset, double y, double startXPos, double endXPos)
		{
			int markerStart = line.Offset + startColumn;
			int markerEnd = line.Offset + endColumn;
	
			if (markerEnd < startOffset || markerStart > endOffset) 
				return; 
	
			double @from;
			double to;
	
			if (markerStart < startOffset && endOffset < markerEnd) {
				@from = startXPos;
				to = endXPos;
			} else {
				int start = startOffset < markerStart ? markerStart : startOffset;
				int end = endOffset < markerEnd ? endOffset : markerEnd;
				int x_pos = layout.IndexToPos (start - startOffset).X;
	
				@from = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
	
				x_pos = layout.IndexToPos (end - startOffset).X;
	
				to = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
			}
	
			@from = System.Math.Max (@from, editor.TextViewMargin.XOffset);
			to = System.Math.Max (to, editor.TextViewMargin.XOffset);
			if (@from < to) {
				cr.DrawLine (selected ? editor.ColorStyle.Selection.CairoColor : editor.ColorStyle.GetChunkStyle (style).CairoColor, @from, y + editor.LineHeight - 1, to, y + editor.LineHeight - 1);
			}
		}
开发者ID:silk,项目名称:monodevelop,代码行数:32,代码来源:TextMarker.cs

示例3: DrawRectangleWithRuler

		public void DrawRectangleWithRuler (Cairo.Context cr, double x, Cairo.Rectangle area, Cairo.Color color, bool drawDefaultBackground)
		{
			bool isDefaultColor = color.R == defaultBgColor.R && color.G == defaultBgColor.G && color.B == defaultBgColor.B;
			if (isDefaultColor && !drawDefaultBackground)
				return;
			cr.Color = color;
			double xp = /*System.Math.Floor*/ (area.X);
			
			if (textEditor.Options.ShowRuler) {
				double divider = System.Math.Max (area.X, System.Math.Min (x + TextStartPosition + rulerX, area.X + area.Width));
				if (divider < area.X + area.Width) {
					cr.Rectangle (xp, area.Y, divider - area.X, area.Height);
					cr.Fill ();
					
					cr.Rectangle (divider, area.Y, area.X + area.Width - divider, area.Height);
					cr.Color = DimColor (color);
					cr.Fill ();
					cr.DrawLine (ColorStyle.Ruler, divider, area.Y, divider, area.Y + area.Height);
					return;
				}
			}
			cr.Rectangle (xp, area.Y, area.Width, area.Height);
			cr.Fill ();
		}
开发者ID:txdv,项目名称:monodevelop,代码行数:24,代码来源:TextViewMargin.cs

示例4: Draw

        /// <summary>
        /// Draw a Grid
        /// </summary>
        /// <param name="dc"></param>
        public override void Draw(Cairo.Context dc)
        {
            var lBB = GetBB();
            dc.Rectangle(lBB.ToCairoRectangle());//DashedPen, 

            dc.DrawLine(lBB.X + lBB.Width / 2, lBB.Y, lBB.X + lBB.Width / 2, lBB.Y + lBB.Height); //DashedPen, 
            dc.DrawLine(lBB.X, lBB.Y + lBB.Height/2, lBB.X + lBB.Width , lBB.Y + lBB.Height/2);  //DashedPen, 
        }
开发者ID:JoeyEremondi,项目名称:tikzedt,代码行数:12,代码来源:OverlayShapeViews.cs

示例5: Draw

		internal protected override void Draw (Cairo.Context cr, Cairo.Rectangle area, DocumentLine lineSegment, int line, double x, double y, double lineHeight)
		{
			var marker = lineSegment != null ? (MarginMarker)lineSegment.Markers.FirstOrDefault (m => m is MarginMarker && ((MarginMarker)m).CanDraw (this)) : null;
			if (marker != null) {
				bool hasDrawn = marker.DrawBackground (editor, cr, new MarginDrawMetrics (this, area, lineSegment, line, x, y, lineHeight));
				if (!hasDrawn)
					marker = null;
			}

			foldSegmentSize = marginWidth * 4 / 6;
			foldSegmentSize -= (foldSegmentSize) % 2;
			
			Cairo.Rectangle drawArea = new Cairo.Rectangle (x, y, marginWidth, lineHeight);
			var state = editor.Document.GetLineState (lineSegment);
			
			bool isFoldStart = false;
			bool isContaining = false;
			bool isFoldEnd = false;
			
			bool isStartSelected = false;
			bool isContainingSelected = false;
			bool isEndSelected = false;
			
			if (editor.Options.ShowFoldMargin && line <= editor.Document.LineCount) {
				startFoldings.Clear ();
				containingFoldings.Clear ();
				endFoldings.Clear ();
				foreach (FoldSegment segment in editor.Document.GetFoldingContaining (lineSegment)) {
					if (segment.StartLine.Offset == lineSegment.Offset) {
						startFoldings.Add (segment);
					} else if (segment.EndLine.Offset == lineSegment.Offset) {
						endFoldings.Add (segment);
					} else {
						containingFoldings.Add (segment);
					}
				}
				
				isFoldStart = startFoldings.Count > 0;
				isContaining = containingFoldings.Count > 0;
				isFoldEnd = endFoldings.Count > 0;
				
				isStartSelected = this.lineHover != null && IsMouseHover (startFoldings);
				isContainingSelected = this.lineHover != null && IsMouseHover (containingFoldings);
				isEndSelected = this.lineHover != null && IsMouseHover (endFoldings);
			}

			if (marker == null) {
				if (editor.GetTextEditorData ().HighlightCaretLine && editor.Caret.Line == line) {
					editor.TextViewMargin.DrawCaretLineMarker (cr, x, y, Width, lineHeight);
				} else {
					var bgGC = foldBgGC;
					if (editor.TextViewMargin.BackgroundRenderer != null) {
						if (isContainingSelected || isStartSelected || isEndSelected) {
							bgGC = foldBgGC;
						} else {
							bgGC = foldLineHighlightedGCBg;
						}
					}
					
					cr.Rectangle (drawArea);
					cr.SetSourceColor (bgGC);
					cr.Fill ();
				}
			}

			if (editor.Options.EnableQuickDiff) {
				if (state == TextDocument.LineState.Changed) {
					cr.SetSourceColor (lineStateChangedGC);
					cr.Rectangle (x + 1, y, marginWidth / 3, lineHeight);
					cr.Fill ();
				} else if (state == TextDocument.LineState.Dirty) {
					cr.SetSourceColor (lineStateDirtyGC);
					cr.Rectangle (x + 1, y, marginWidth / 3, lineHeight);
					cr.Fill ();
				}
			}

			if (editor.Options.ShowFoldMargin && line <= editor.Document.LineCount) {
				double foldSegmentYPos = y + System.Math.Floor (editor.LineHeight - foldSegmentSize) / 2;
				double xPos = x + System.Math.Floor (marginWidth / 2) + 0.5;
				
				if (isFoldStart) {
					bool isVisible         = true;
					bool moreLinedOpenFold = false;
					foreach (FoldSegment foldSegment in startFoldings) {
						if (foldSegment.IsFolded) {
							isVisible = false;
						} else {
							moreLinedOpenFold = foldSegment.EndLine.Offset > foldSegment.StartLine.Offset;
						}
					}
					bool isFoldEndFromUpperFold = false;
					foreach (FoldSegment foldSegment in endFoldings) {
						if (foldSegment.EndLine.Offset > foldSegment.StartLine.Offset && !foldSegment.IsFolded) 
							isFoldEndFromUpperFold = true;
					}
					DrawFoldSegment (cr, x, y, isVisible, isStartSelected);
					
					if (isContaining || isFoldEndFromUpperFold)
						cr.DrawLine (isContainingSelected ? foldLineHighlightedGC : foldLineGC, xPos, drawArea.Y, xPos, foldSegmentYPos - 2);
//.........这里部分代码省略.........
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:101,代码来源:FoldMarkerMargin.cs

示例6: SetSelColor

  /*
  public override void SetSelColor()
  {
      Stroke = new SolidColorBrush(Properties.Settings.Default.Overlay_CoordSelColor);
  }
  public override void SetStdColor()
  {
      Stroke = new SolidColorBrush(Properties.Settings.Default.Overlay_CoordColor);
  }
  */
 
  /// <summary>
  /// Draw an X
  /// </summary>
  /// <param name="dc"></param>
  public override void Draw(Cairo.Context dc)
  {
      Pen p = IsSelected ? SelPen : StdPen;
      Rect lBB = GetBB(Parent.Height);
      dc.SetSourceRGB(1, 0, 0); // todo
      dc.DrawLine(lBB.TopLeft, lBB.BottomRight);
      dc.DrawLine(lBB.BottomLeft, lBB.TopRight);
  }
开发者ID:JoeyEremondi,项目名称:tikzedt,代码行数:23,代码来源:OverlayShapeViews.cs

示例7: DrawFoldSegment

		void DrawFoldSegment (Cairo.Context ctx, double x, double y, bool isOpen, bool isSelected)
		{
			var drawArea = new Cairo.Rectangle (System.Math.Floor (x + (Width - foldSegmentSize) / 2) + 0.5, 
			                                    System.Math.Floor (y + (editor.LineHeight - foldSegmentSize) / 2) + 0.5, foldSegmentSize, foldSegmentSize);
			ctx.Rectangle (drawArea);
			ctx.SetSourceColor (isOpen ? foldBgGC : foldToggleMarkerBackground);
			ctx.FillPreserve ();
			ctx.SetSourceColor (isSelected ? foldLineHighlightedGC  : foldLineGC);
			ctx.Stroke ();
			
			ctx.DrawLine (isSelected ? foldLineHighlightedGC  : foldToggleMarkerGC,
			              drawArea.X  + drawArea.Width * 2 / 10,
			              drawArea.Y + drawArea.Height / 2,
			              drawArea.X + drawArea.Width - drawArea.Width * 2 / 10,
			              drawArea.Y + drawArea.Height / 2);
			
			if (!isOpen)
				ctx.DrawLine (isSelected ? foldLineHighlightedGC  : foldToggleMarkerGC,
				              drawArea.X + drawArea.Width / 2,
				              drawArea.Y + drawArea.Height * 2 / 10,
				              drawArea.X  + drawArea.Width / 2,
				              drawArea.Y + drawArea.Height - drawArea.Height * 2 / 10);
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:23,代码来源:FoldMarkerMargin.cs

示例8: Draw

		internal protected override void Draw (Cairo.Context cr, Cairo.Rectangle area, LineSegment lineSegment, int line, double x, double y, double lineHeight)
		{
			foldSegmentSize = marginWidth * 4 / 6;
			foldSegmentSize -= (foldSegmentSize) % 2;
			
			Cairo.Rectangle drawArea = new Cairo.Rectangle (x, y, marginWidth, lineHeight);
			var state = editor.Document.GetLineState (lineSegment);
			
			bool isFoldStart = false;
			bool isContaining = false;
			bool isFoldEnd = false;
			
			bool isStartSelected = false;
			bool isContainingSelected = false;
			bool isEndSelected = false;
			
			if (line <= editor.Document.LineCount) {
				startFoldings.Clear ();
				containingFoldings.Clear ();
				endFoldings.Clear ();
				foreach (FoldSegment segment in editor.Document.GetFoldingContaining (lineSegment)) {
					if (segment.StartLine.Offset == lineSegment.Offset) {
						startFoldings.Add (segment);
					} else if (segment.EndLine.Offset == lineSegment.Offset) {
						endFoldings.Add (segment);
					} else {
						containingFoldings.Add (segment);
					}
				}
				
				isFoldStart  = startFoldings.Count > 0;
				isContaining = containingFoldings.Count > 0;
				isFoldEnd    = endFoldings.Count > 0;
				
				isStartSelected      = this.lineHover != null && IsMouseHover (startFoldings);
				isContainingSelected = this.lineHover != null && IsMouseHover (containingFoldings);
				isEndSelected        = this.lineHover != null && IsMouseHover (endFoldings);
			}
			
			var bgGC = foldBgGC;
			if (editor.TextViewMargin.BackgroundRenderer != null) {
				if (isContainingSelected || isStartSelected || isEndSelected) {
					bgGC = foldBgGC;
				} else {
					bgGC = foldLineHighlightedGCBg;
				}
			}
			
			cr.Rectangle (drawArea);
			cr.Color = bgGC;
			cr.Fill ();
			
			if (state == TextDocument.LineState.Changed) {
				cr.Color = lineStateChangedGC;
				cr.Rectangle (x + 1, y, marginWidth / 3, lineHeight);
				cr.Fill ();
			} else if (state == TextDocument.LineState.Dirty) {
				cr.Color = lineStateDirtyGC;
				cr.Rectangle (x + 1, y, marginWidth / 3, lineHeight);
				cr.Fill ();
			}
			
			if (line < editor.Document.LineCount) {
				double foldSegmentYPos = y + System.Math.Floor (editor.LineHeight - foldSegmentSize) / 2;
				double xPos = x + System.Math.Floor (marginWidth / 2) + 0.5;
				
				if (isFoldStart) {
					bool isVisible         = true;
					bool moreLinedOpenFold = false;
					foreach (FoldSegment foldSegment in startFoldings) {
						if (foldSegment.IsFolded) {
							isVisible = false;
						} else {
							moreLinedOpenFold = foldSegment.EndLine.Offset > foldSegment.StartLine.Offset;
						}
					}
					bool isFoldEndFromUpperFold = false;
					foreach (FoldSegment foldSegment in endFoldings) {
						if (foldSegment.EndLine.Offset > foldSegment.StartLine.Offset && !foldSegment.IsFolded) 
							isFoldEndFromUpperFold = true;
					}
					DrawFoldSegment (cr, x, y, isVisible, isStartSelected);

					if (isContaining || isFoldEndFromUpperFold)
						cr.DrawLine (isContainingSelected ? foldLineHighlightedGC : foldLineGC, xPos, drawArea.Y, xPos, foldSegmentYPos - 2);
					if (isContaining || moreLinedOpenFold) 
						cr.DrawLine (isEndSelected || (isStartSelected && isVisible) || isContainingSelected ? foldLineHighlightedGC : foldLineGC, xPos, foldSegmentYPos + foldSegmentSize + 2, xPos, drawArea.Y + drawArea.Height);
				} else {

					if (isFoldEnd) {

						double yMid = drawArea.Y + drawArea.Height / 2;
						cr.DrawLine (isEndSelected ? foldLineHighlightedGC : foldLineGC, xPos, yMid, x + marginWidth - 2, yMid);
						cr.DrawLine (isContainingSelected || isEndSelected ? foldLineHighlightedGC : foldLineGC, xPos, drawArea.Y, xPos, yMid);

						if (isContaining) 
							cr.DrawLine (isContainingSelected ? foldLineHighlightedGC : foldLineGC, xPos, yMid + 1, xPos, drawArea.Y + drawArea.Height);
					} else if (isContaining) {
						cr.DrawLine (isContainingSelected ? foldLineHighlightedGC : foldLineGC, xPos, drawArea.Y, xPos, drawArea.Y + drawArea.Height);
					}
//.........这里部分代码省略.........
开发者ID:txdv,项目名称:monodevelop,代码行数:101,代码来源:FoldMarkerMargin.cs

示例9: Draw

		public override void Draw (TextEditor editor, Cairo.Context cr, double y, LineMetrics metrics)
		{
			var startOffset = metrics.TextStartOffset;
			int endOffset = metrics.TextEndOffset;
			double startXPos = metrics.TextRenderStartPosition;
			double endXPos = metrics.TextRenderEndPosition;
			var layout = metrics.Layout.Layout;
			int markerStart = line.Offset + startColumn;
			int markerEnd = line.Offset + endColumn;
	
			if (markerEnd < startOffset || markerStart > endOffset) 
				return; 
	
			double @from;
			double to;
	
			if (markerStart < startOffset && endOffset < markerEnd) {
				@from = startXPos;
				to = endXPos;
			} else {
				int start = startOffset < markerStart ? markerStart : startOffset;
				int end = endOffset < markerEnd ? endOffset : markerEnd;
				int x_pos = layout.IndexToPos (start - startOffset).X;
	
				@from = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
	
				x_pos = layout.IndexToPos (end - startOffset).X;
	
				to = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
			}
	
			@from = System.Math.Max (@from, editor.TextViewMargin.XOffset);
			to = System.Math.Max (to, editor.TextViewMargin.XOffset);
			if (@from < to) {
				cr.DrawLine (editor.ColorStyle.GetForeground (editor.ColorStyle.GetChunkStyle (style)), @from + 0.5, y + editor.LineHeight - 1.5, to + 0.5, y + editor.LineHeight - 1.5);
			}
		}
开发者ID:xiexin36,项目名称:monodevelop,代码行数:37,代码来源:UrlMarker.cs

示例10: Measure

 public Size Measure(Cairo.Context c, Control control)
 {
     Line line = control as Line;
     Cairo.PointD p1 = new Cairo.PointD (line.Location.X ,line.Location.Y);
     Cairo.PointD p2 = new Cairo.PointD (line.End.X, line.End.Y);
     var r = c.DrawLine (p1, p2, line.BackgroundColor.ToCairoColor (), line.LineWidth, line.LineType, false);
     return new Size (r.Width, r.Height);
 }
开发者ID:modesto,项目名称:monoreports,代码行数:8,代码来源:LineRenderer.cs

示例11: Render

 public void Render(Cairo.Context c, Control control)
 {
     Line line = control as Line;
     Cairo.PointD p1 = new Cairo.PointD (line.Location.X ,line.Location.Y);
     Cairo.PointD p2 = new Cairo.PointD (line.End.X, line.End.Y);
     c.DrawLine (p1, p2, line.BackgroundColor.ToCairoColor (), line.LineWidth, line.LineType, true);
 }
开发者ID:modesto,项目名称:monoreports,代码行数:7,代码来源:LineRenderer.cs


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