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


C# Cairo.Context.SetSourceColor方法代码示例

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


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

示例1: RedrawText

        /// <summary>
        /// Draws the text.
        /// </summary>
        /// <param name="showCursor">Whether or not to show the mouse cursor in the drawing.</param>
        /// <param name="useTextLayer">Whether or not to use the TextLayer (as opposed to the Userlayer).</param>
        private void RedrawText(bool showCursor, bool useTextLayer)
        {
            Rectangle r = CurrentTextLayout.GetLayoutBounds();
            r.Inflate(10 + OutlineWidth, 10 + OutlineWidth);
            InflateAndInvalidate(r);
            CurrentTextBounds = r;

            Rectangle cursorBounds = Rectangle.Zero;

            Cairo.ImageSurface surf;

            if (!useTextLayer)
            {
                //Draw text on the current UserLayer's surface as finalized text.
                surf = PintaCore.Workspace.ActiveDocument.CurrentUserLayer.Surface;
            }
            else
            {
                //Draw text on the current UserLayer's TextLayer's surface as re-editable text.
                surf = PintaCore.Workspace.ActiveDocument.CurrentUserLayer.TextLayer.Layer.Surface;

                ClearTextLayer();
            }

            using (var g = new Cairo.Context (surf)) {
                g.Save ();

                // Show selection if on text layer
                if (useTextLayer) {
                    // Selected Text
                    Cairo.Color c = new Cairo.Color (0.7, 0.8, 0.9, 0.5);
                    foreach (Rectangle rect in CurrentTextLayout.SelectionRectangles)
                        g.FillRectangle (rect.ToCairoRectangle (), c);
                }

                if (selection != null) {
                    g.AppendPath (selection.SelectionPath);
                    g.FillRule = Cairo.FillRule.EvenOdd;
                    g.Clip ();
                }

                g.MoveTo (new Cairo.PointD (CurrentTextEngine.Origin.X, CurrentTextEngine.Origin.Y));

                g.SetSourceColor (PintaCore.Palette.PrimaryColor);

                //Fill in background
                if (BackgroundFill) {
                    using (var g2 = new Cairo.Context (surf)) {
                        g2.FillRectangle(CurrentTextLayout.GetLayoutBounds().ToCairoRectangle(), PintaCore.Palette.SecondaryColor);
                    }
                }

                // Draw the text
                if (FillText)
                    Pango.CairoHelper.ShowLayout (g, CurrentTextLayout.Layout);

                if (FillText && StrokeText) {
                    g.SetSourceColor (PintaCore.Palette.SecondaryColor);
                    g.LineWidth = OutlineWidth;

                    Pango.CairoHelper.LayoutPath (g, CurrentTextLayout.Layout);
                    g.Stroke ();
                } else if (StrokeText) {
                    g.SetSourceColor (PintaCore.Palette.PrimaryColor);
                    g.LineWidth = OutlineWidth;

                    Pango.CairoHelper.LayoutPath (g, CurrentTextLayout.Layout);
                    g.Stroke ();
                }

                if (showCursor) {
                    var loc = CurrentTextLayout.GetCursorLocation ();
                    var color = PintaCore.Palette.PrimaryColor;

                    g.Antialias = Cairo.Antialias.None;
                    g.DrawLine (new Cairo.PointD (loc.X, loc.Y),
                            new Cairo.PointD (loc.X, loc.Y + loc.Height),
                            color, 1);

                    cursorBounds = Rectangle.Inflate (loc, 2, 10);
                }

                g.Restore ();

                if (useTextLayer && (is_editing || ctrlKey) && !CurrentTextEngine.IsEmpty())
                {
                    //Draw the text edit rectangle.

                    g.Save();

                    g.Translate(.5, .5);

                    using (Cairo.Path p = g.CreateRectanglePath(CurrentTextBounds.ToCairoRectangle ()))
                    {
                        g.AppendPath(p);
//.........这里部分代码省略.........
开发者ID:PintaProject,项目名称:Pinta,代码行数:101,代码来源:TextTool.cs

示例2: BgBufferUpdate

				public BgBufferUpdate (Minimpap mode)
				{
					this.mode = mode;
					
					cr = Gdk.CairoHelper.Create (mode.backgroundBuffer);
					
					cr.LineWidth = 1;
					int w = mode.backgroundBuffer.ClipRegion.Clipbox.Width;
					int h = mode.backgroundBuffer.ClipRegion.Clipbox.Height;
					cr.Rectangle (0, 0, w, h);
					if (mode.TextEditor.ColorStyle != null)
						cr.SetSourceColor (mode.TextEditor.ColorStyle.PlainText.Background);
					cr.Fill ();
					
					maxLine = mode.TextEditor.GetTextEditorData ().VisibleLineCount;
					sx = w / (double)mode.TextEditor.Allocation.Width;
					sy = Math.Min (1, lineHeight * maxLine / (double)mode.TextEditor.GetTextEditorData ().TotalHeight );
					cr.Scale (sx, sy);
					
					handler = GLib.Idle.Add (BgBufferUpdater);
				}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:21,代码来源:QuickTaskMiniMapMode.cs


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