StrokePreserve() public method

public StrokePreserve ( ) : void
return void
Ejemplo n.º 1
0
        private void DrawTriangle(Cairo.Context context)
        {
            double height = sideLength * Math.Sqrt(3) / 2;

            double x1 = offsetX;
            double y1 = height + offsetY;

            double x2 = 0.5 * sideLength + offsetX;
            double y2 = 0 + offsetY;

            double x3 = sideLength + offsetX;
            double y3 = height + offsetY;

            context.NewPath();
            context.SetSourceColor(Utility.Colour.ToOxy(owner.MainWidget.StyleContext.GetColor(StateFlags.Normal).ToColour().ToGdk()));

            context.MoveTo(x1, y1);

            context.LineTo(x2, y2);
            context.StrokePreserve();
            context.LineTo(x3, y3);
            context.StrokePreserve();
            context.LineTo(x1, y1);
            context.StrokePreserve();
        }
Ejemplo n.º 2
0
    protected void DrawingPlace(object sender, ExposeEventArgs args)
    {
        DrawingArea area = (DrawingArea)sender;

        Cairo.Context cc = Gdk.CairoHelper.Create(area.GdkWindow);

        cc.SelectFontFace("Sans", Cairo.FontSlant.Italic, Cairo.FontWeight.Bold);
        cc.SetFontSize(25);
        cc.MoveTo(15, 20);
        cc.ShowText("Диаграмма");
        cc.MoveTo(330, 40);
        cc.SetFontSize(15);
        cc.SelectFontFace("Sans", Cairo.FontSlant.Normal, Cairo.FontWeight.Normal);
        cc.ShowText("Выручка");

        cc.SetSourceRGB(0.2, 0.23, 0.9);
        cc.LineWidth = 1;

        int s      = 50;
        int s_next = 40;
        int w;
        int i = 0;
        int h = 65;

        foreach (var item in global_1)
        {
            w = Convert.ToInt32(item);
            cc.SetFontSize(15);
            cc.MoveTo(0, h);
            cc.SetSourceRGB(0, 0, 0);
            cc.SelectFontFace("Sans", Cairo.FontSlant.Normal, Cairo.FontWeight.Normal);
            cc.ShowText(Convert.ToString(i + 1));
            i = i + 1;
            cc.SetSourceRGB(0.2, 0.23, 0.9);
            cc.Rectangle(10, s, w, 30);
            h = h + 40;
            s = s + s_next;
        }

        cc.LineTo(10, 50);
        cc.LineTo(10, 390);
        cc.StrokePreserve();
        cc.Fill();

        cc.LineTo(10, 50);
        cc.LineTo(390, 50);
        cc.StrokePreserve();
        cc.Fill();

        cc.MoveTo(0, 390);
        cc.SetSourceRGB(0, 0, 0);
        cc.SetFontSize(15);
        cc.SelectFontFace("Sans", Cairo.FontSlant.Normal, Cairo.FontWeight.Normal);
        cc.ShowText("Период");

        ((IDisposable)cc).Dispose();
    }
Ejemplo n.º 3
0
        public static void DrawRoundedRectangle(Cairo.Context gr, double x, double y,
                                                double width, double height, double radius,
                                                Cairo.Color color, Cairo.Color borderColor)
        {
            gr.Save();

            if ((radius > height / 2) || (radius > width / 2))
            {
                radius = Math.Min(height / 2, width / 2);
            }

            gr.MoveTo(x, y + radius);
            gr.Arc(x + radius, y + radius, radius, Math.PI, -Math.PI / 2);
            gr.LineTo(x + width - radius, y);
            gr.Arc(x + width - radius, y + radius, radius, -Math.PI / 2, 0);
            gr.LineTo(x + width, y + height - radius);
            gr.Arc(x + width - radius, y + height - radius, radius, 0, Math.PI / 2);
            gr.LineTo(x + radius, y + height);
            gr.Arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI);
            gr.ClosePath();
            gr.Restore();

            gr.LineJoin = LineJoin.Round;
            gr.Color    = borderColor;
            gr.StrokePreserve();
            gr.Color = color;
            gr.Fill();
        }
Ejemplo n.º 4
0
		protected override Gdk.Rectangle OnMouseMove (Context g, Color strokeColor, ImageSurface surface,
		                                              int x, int y, int lastX, int lastY)
		{
			// Cairo does not support a single-pixel-long single-pixel-wide line
			if (x == lastX && y == lastY && g.LineWidth == 1 &&
			    PintaCore.Workspace.ActiveWorkspace.PointInCanvas (new PointD(x,y))) {
				surface.Flush ();

				ColorBgra source = surface.GetColorBgraUnchecked (x, y);
				source = UserBlendOps.NormalBlendOp.ApplyStatic (source, strokeColor.ToColorBgra ());
				surface.SetColorBgra (source, x, y);
				surface.MarkDirty ();

				return new Gdk.Rectangle (x - 1, y - 1, 3, 3);
			}

			g.MoveTo (lastX + 0.5, lastY + 0.5);
			g.LineTo (x + 0.5, y + 0.5);
			g.StrokePreserve ();

			Gdk.Rectangle dirty = g.FixedStrokeExtents ().ToGdkRectangle ();

			// For some reason (?!) we need to inflate the dirty
			// rectangle for small brush widths in zoomed images
			dirty.Inflate (1, 1);

			return dirty;
		}
Ejemplo n.º 5
0
        /// <summary>Paint on the graphics context</summary>
        /// <param name="context">The graphics context to draw on</param>
        public override void Paint(Cairo.Context context)
        {
            if (Selected)
            {
                context.SetSourceColor(OxyColors.Blue);
            }
            else
            {
                context.SetSourceColor(ForegroundColour);
            }

            // Draw circle
            context.LineWidth = 3;
            context.NewPath();
            context.Arc(Location.X, Location.Y, Width / 2, 0, 2 * Math.PI);
            context.StrokePreserve();
            context.SetSourceColor(Colour);
            context.Fill();

            // Write text
            context.LineWidth = 1;
            context.SetSourceColor(OxyColors.Black);
            context.SetFontSize(13);

            DrawCentredText(context, Name, Location);
        }
Ejemplo n.º 6
0
        public void Draw(Cairo.Context g, double scale, bool fillSelection)
        {
            g.Save();
            g.Translate(0.5, 0.5);
            g.Scale(scale, scale);

            g.AppendPath(selection_path);

            if (fillSelection)
            {
                g.Color    = new Cairo.Color(0.7, 0.8, 0.9, 0.2);
                g.FillRule = Cairo.FillRule.EvenOdd;
                g.FillPreserve();
            }

            g.LineWidth = 1 / scale;

            // Draw a white line first so it shows up on dark backgrounds
            g.Color = new Cairo.Color(1, 1, 1);
            g.StrokePreserve();

            // Draw a black dashed line over the white line
            g.SetDash(new double[] { 2 / scale, 4 / scale }, 0);
            g.Color = new Cairo.Color(0, 0, 0);

            g.Stroke();
            g.Restore();
        }
Ejemplo n.º 7
0
        void DrawCurveTabs(Cairo.Context cr, Cairo.Rectangle rectangle)
        {
            if (IsSeparator)
            {
                return;
            }

            cr.MoveTo(rectangle.X, rectangle.Y);

            double bottom = rectangle.Y + rectangle.Height - 1;

            cr.CurveTo(
                rectangle.X + SpacerWidth / 2, rectangle.Y,
                rectangle.X + SpacerWidth / 2, bottom,
                rectangle.X + SpacerWidth, bottom);

            cr.LineTo(rectangle.X + rectangle.Width - SpacerWidth, bottom);

            cr.CurveTo(
                rectangle.X + rectangle.Width - SpacerWidth / 2, bottom,
                rectangle.X + rectangle.Width - SpacerWidth / 2, rectangle.Y,
                rectangle.X + rectangle.Width, rectangle.Y);

            cr.Color = (HslColor)parent.Style.Dark(StateType.Normal);
            cr.StrokePreserve();
            cr.ClosePath();
            if (Active)
            {
                cr.Color = (HslColor)parent.Style.Background(StateType.Prelight);
            }
            else if (HoverPosition.X >= 0)
            {
                double rx = rectangle.X + HoverPosition.X;
                double ry = rectangle.Y + HoverPosition.Y;
                Cairo.RadialGradient gradient = new Cairo.RadialGradient(rx, ry, rectangle.Height * 1.5,
                                                                         rx, ry, 2);
                var color = (HslColor)parent.Style.Mid(StateType.Normal);
                color.L *= 1.05;
                gradient.AddColorStop(0, color);
                color.L *= 1.07;
                gradient.AddColorStop(1, color);
                cr.Pattern = gradient;
            }
            else
            {
                cr.Color = (HslColor)parent.Style.Mid(StateType.Normal);
            }
            cr.Fill();

            cr.Save();
            cr.Translate(rectangle.X + (rectangle.Width - w) / 2, (rectangle.Height - h) / 2);
            cr.Color = (HslColor)parent.Style.Text(StateType.Normal);

            cr.ShowLayout(layout);

            cr.Restore();
        }
Ejemplo n.º 8
0
    public static void Cleaning(object sender)
    {
        DrawingArea area = (DrawingArea)sender;

        Cairo.Context cc = Gdk.CairoHelper.Create(area.GdkWindow);

        cc.SetSourceRGB(1, 1, 1);
        cc.Rectangle(0, 0, 200, 200);
        cc.StrokePreserve();
        cc.Fill();
        cc.SetSourceRGB(0, 0, 0);
        cc.LineWidth = 1;
        cc.SetFontSize(15);
        cc.SelectFontFace("Sans", Cairo.FontSlant.Normal, Cairo.FontWeight.Normal);
        cc.MoveTo(20, 100);
        cc.ShowText(DateTime.Now.ToString());
        cc.StrokePreserve();
        cc.Fill();
    }
        protected virtual void DrawBorder(Cairo.Context context, Gdk.Rectangle region)
        {
            LayoutRoundedRectangle(context, region, -1, -1);
            context.LineWidth = 1;
            context.SetSourceColor(Styles.StatusBarInnerColor);
            context.Stroke();

            LayoutRoundedRectangle(context, region);
            context.LineWidth = 1;
            context.SetSourceColor(Styles.StatusBarBorderColor);
            context.StrokePreserve();
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Raises the expose event and draws the map.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="args">Arguments.</param>
        private void OnExpose(object sender, ExposeEventArgs args)
        {
            DrawingArea area = (DrawingArea)sender;

            Cairo.Context cairoContext = Gdk.CairoHelper.Create(area.GdkWindow);

            // Draw the background.
            cairoContext.Rectangle(0, 0, viewWidth, viewHeight);
            cairoContext.SetSourceRGB(255, 255, 255);
            cairoContext.StrokePreserve();
            cairoContext.Fill();

            // Draw the grid.
            cairoContext.LineWidth = 1.0;
            cairoContext.LineCap   = LineCap.Butt;
            cairoContext.SetSourceRGB(0, 0, 0);

            // Columns.
            int position = cellWidth;

            for (; position <= viewWidth - cellWidth; position += cellWidth)
            {
                // We have to add 0.5 to the x position otherwise Cairo will
                // smear it across 2 pixels.
                cairoContext.MoveTo(position + 0.5, 0.0);
                cairoContext.LineTo(position + 0.5, viewHeight);
                cairoContext.Stroke();
            }

            // Rows.
            position = cellHeight;

            for (; position <= viewHeight - cellHeight; position += cellHeight)
            {
                // We have to add 0.5 to the y position otherwise Cairo will
                // smear it across 2 pixels.
                cairoContext.MoveTo(0.0, position + 0.5);
                cairoContext.LineTo(viewWidth, position + 0.5);
                cairoContext.Stroke();
            }

            if (robotView.Robot.PathPointList.Count > 1)
            {
                pathView.Draw(cairoContext, centerX, centerY, 1.0);
            }

            robotView.Draw(cairoContext, centerX, centerY, 1.0);
            landmarkView.Draw(cairoContext, centerX, centerY, 1.0);

            ((IDisposable)cairoContext.GetTarget()).Dispose();
            ((IDisposable)cairoContext).Dispose();
        }
        private void Render(Clutter.CairoTexture texture, int with_state, bool outwards)
        {
            texture.Clear();
            Cairo.Context context = texture.Create();

            double lwidth  = 1;
            double hlwidth = lwidth * 0.5;

            //Draw outline rectangles:
            context.Rectangle(hlwidth, hlwidth, texture.Width - lwidth, texture.Height - lwidth);
            context.SetSourceRGB(1.0, 1.0, 1.0);
            context.LineWidth = lwidth;
            context.StrokePreserve();
            double sat = (with_state == 0 ? 0.4 : (with_state == 1 ? 0.6 : 0.8));

            context.SetSourceRGB(sat, sat, sat);
            context.Fill();

            double dim = 4;

            context.MoveTo(-dim, 0);
            context.LineTo(outwards ? 0 : -dim, outwards ? 0 : dim);
            context.LineTo(0, dim);
            context.MoveTo(-dim, dim);
            context.LineTo(0, 0);
            context.ClosePath();
            Cairo.Path arrow = context.CopyPath();
            context.NewPath();

            double margin = 2 + hlwidth;
            PointD center = new PointD(texture.Width * 0.5, texture.Height * 0.5);
            PointD transl = new PointD(center.X - margin, -(center.Y - margin));

            context.LineWidth = lwidth;
            sat = (with_state == 1 ? 0.0 : 1.0);
            context.SetSourceRGB(sat, sat, sat);

            context.Translate(center.X, center.Y);
            for (int i = 0; i < 4; i++)
            {
                context.Rotate(Math.PI * 0.5 * i);
                context.Translate(transl.X, transl.Y);
                context.AppendPath(arrow);
                context.Stroke();
                context.Translate(-transl.X, -transl.Y);
            }

            ((IDisposable)arrow).Dispose();
            ((IDisposable)context.Target).Dispose();
            ((IDisposable)context).Dispose();
        }
		protected override void DrawBackground (Context context, Gdk.Rectangle region)
		{
			LayoutRoundedRectangle (context, region);
			context.Clip ();

			context.SetSourceColor (CairoExtensions.ParseColor ("D3E6FF"));
			context.Paint ();

			context.Save ();
			context.Translate (region.X + region.Width / 2.0, region.Y + region.Height);

			using (var rg = new RadialGradient (0, 0, 0, 0, 0, region.Height * 1.2)) {
				var color = CairoExtensions.ParseColor ("E5F0FF");
				rg.AddColorStop (0, color);
				color.A = 0;
				rg.AddColorStop (1, color);

				context.Scale (region.Width / (double)region.Height, 1.0);
				context.SetSource (rg);
				context.Paint ();
			}

			context.Restore ();

			LayoutRoundedRectangle (context, region, -3, -3, 2);
			context.SetSourceRGBA (1, 1, 1, 0.4);
			context.LineWidth = 1;
			context.StrokePreserve ();

			context.Clip ();

			int boxSize = 11;
			int x = region.Left + (region.Width % boxSize) / 2;
			for (; x < region.Right; x += boxSize) {
				context.MoveTo (x + 0.5, region.Top);
				context.LineTo (x + 0.5, region.Bottom);
			}

			int y = region.Top + (region.Height % boxSize) / 2;
			y += boxSize / 2;
			for (; y < region.Bottom; y += boxSize) {
				context.MoveTo (region.Left, y + 0.5);
				context.LineTo (region.Right, y + 0.5);
			}

			context.SetSourceRGBA (1, 1, 1, 0.2);
			context.Stroke ();

			context.ResetClip ();
		}
Ejemplo n.º 13
0
        void DrawTimeNodes(Gdk.Window win)
        {
            bool hasSelectedTimeNode = false;

            using (Cairo.Context g = Gdk.CairoHelper.Create(win)) {
                int height;
                int width;

                win.Resize((int)(frames / pixelRatio), Allocation.Height);
                win.GetSize(out width, out height);

                g.Operator = Operator.Over;

                foreach (T tn in list)
                {
                    if (filter != null && !filter.IsVisible(tn))
                    {
                        continue;
                    }

                    if (!tn.Equals(selected))
                    {
                        Cairo.Color borderColor = new Cairo.Color(color.R + 0.1, color.G + 0.1, color.B + 0.1, 1);
                        CairoUtils.DrawRoundedRectangle(g, tn.StartFrame / pixelRatio, 3,
                                                        tn.TotalFrames / pixelRatio, height - 6,
                                                        SECTION_HEIGHT / 7, color, borderColor);
                    }
                    else
                    {
                        hasSelectedTimeNode = true;
                    }
                }
                //Then we draw the selected TimeNode over the others
                if (hasSelectedTimeNode)
                {
                    Cairo.Color borderColor = new Cairo.Color(0, 0, 0, 1);
                    CairoUtils.DrawRoundedRectangle(g, selected.StartFrame / pixelRatio, 3,
                                                    selected.TotalFrames / pixelRatio, height - 6,
                                                    SECTION_HEIGHT / 7, color, borderColor);
                    if (selected.HasDrawings)
                    {
                        g.MoveTo(selected.KeyFrame / pixelRatio, 3);
                        g.LineTo(selected.KeyFrame / pixelRatio, SECTION_HEIGHT - 3);
                        g.StrokePreserve();
                    }
                }
                DrawLines(win, g, height, width);
            }
        }
Ejemplo n.º 14
0
 //Draws the dots on the screen, end is a moot parameter
 public void DrawDot(Cairo.Context ctx, PointD start, PointD end)
 {
     if (!start.Equals(prevDot))
     {
         ctx.SetSourceRGBA(R, G, B, A);
         ctx.Arc(start.X, start.Y, 1, 0, 2 * Math.PI);
         ctx.StrokePreserve();
         ctx.Fill();
         if (startRecordPoints)
         {
             currentDrawnPoints.Add(start);
         }
         prevDot = start;
     }
 }
Ejemplo n.º 15
0
    void LetsDraw(object sender, ExposeEventArgs args)
    {
        DrawingArea darea = (DrawingArea)sender;

        Cairo.Context shape = Gdk.CairoHelper.Create(darea.GdkWindow);

        //Write the shape code
        shape.SetSourceRGB(0.2, 0.5, 0.7);       // set the color
        shape.Arc(100, 90, 70, 10, 2 * Math.PI); // our circle segment

        shape.StrokePreserve();
        shape.Fill();

        ((IDisposable)shape).Dispose();
    }
Ejemplo n.º 16
0
    void LetsDraw(object sender, ExposeEventArgs args)
    {
        DrawingArea darea = (DrawingArea)sender;

        Cairo.Context shape = Gdk.CairoHelper.Create(darea.GdkWindow);

        //Write the shape code
        shape.SetSourceRGB(0.2, 0.5, 0.7); // set the color
        shape.Rectangle(100, 50, 100, 50); // our rectangle, his size: 100*50

        shape.StrokePreserve();
        shape.Fill();

        ((IDisposable)shape).Dispose();
    }
Ejemplo n.º 17
0
    void LetsDraw(object sender, ExposeEventArgs args)
    {
        DrawingArea darea = (DrawingArea)sender;

        Cairo.Context shape = Gdk.CairoHelper.Create(darea.GdkWindow);

        //Write the shape code
        shape.SetSourceRGB(0.2, 0.5, 0.7); // set the color
        shape.LineTo(100, 50);             //first point
        shape.LineTo(300, 90);             // second point

        shape.StrokePreserve();
        shape.Fill();

        ((IDisposable)shape).Dispose();
    }
Ejemplo n.º 18
0
    void LetsDraw(object sender, ExposeEventArgs args)
    {
        DrawingArea darea = (DrawingArea)sender;

        Cairo.Context shape = Gdk.CairoHelper.Create(darea.GdkWindow);

        //Write the shape code
        shape.SetSourceRGB(0.2, 0.5, 0.7);          // set the color
        shape.MoveTo(25, 130);
        shape.CurveTo(100, 235, 165, 25, 255, 130); //our curve line

        shape.StrokePreserve();
        shape.Fill();

        ((IDisposable)shape).Dispose();
    }
Ejemplo n.º 19
0
		protected override Gdk.Rectangle OnMouseMove (Context g, Color strokeColor, ImageSurface surface,
		                                              int x, int y, int lastX, int lastY)
		{
			int dx = x - lastX;
			int dy = y - lastY;
			double px = Math.Cos (theta) * dx - Math.Sin (theta) * dy;
			double py = Math.Sin (theta) * dx + Math.Cos (theta) * dy;

			g.MoveTo (lastX - px, lastY - py);
			g.LineTo (lastX + px, lastY + py);
			g.LineTo (x + px, y + py);
			g.LineTo (x - px, y - py);
			g.LineTo (lastX - px, lastY - py);

			g.StrokePreserve ();

			return g.FixedStrokeExtents ().ToGdkRectangle ();
		}
Ejemplo n.º 20
0
		public static void Draw(Context grw, RectangleElement rect)
		{
			if (rect.Foregraund != null) {
				grw.SetSourceRGBA (
					rect.Foregraund.Red, 
					rect.Foregraund.Green, 
					rect.Foregraund.Blue, 
					rect.Alpha);
			}

			grw.Rectangle (
				new Rectangle (
					rect.LeftBottom.GeometryX, 
					rect.LeftBottom.GeometryY, 
					rect.GeometryWidth, 
					rect.GeometryHeight));

			grw.StrokePreserve();
			grw.Fill();
		}
Ejemplo n.º 21
0
		public static void Draw(Context grw, Connector con)
		{
			var c = con.Selected ? AppController.Instance.Config.SelectedConnectorColor : 
				!con.ConnectedTo.Any() ? 
				con.Foregraund : 
				AppController.Instance.Config.ConnectedColor;

			if ( c != null) {
				grw.SetSourceRGB (
					c.Red, 
					c.Green, 
					c.Blue);
			}

			grw.Arc (
				con.Center.GeometryX, 
				con.Center.GeometryY, 
				con.GeometryRadius, 
				0, 2 * Math.PI);

			grw.StrokePreserve ();
			grw.Fill ();
		}
Ejemplo n.º 22
0
        /// <summary>Paint on the graphics context</summary>
        /// <param name="context">The graphics context to draw on</param>
        public override void Paint(Cairo.Context context)
        {
            OxyColor outlineColour;

            if (Selected)
            {
                outlineColour = OxyColors.Blue;
            }
            else if (transparent)
            {
                outlineColour = DefaultBackgroundColour;
            }
            else
            {
                outlineColour = DefaultOutlineColour;
            }

            OxyColor backgroundColour = transparent ? DefaultBackgroundColour : Colour;
            OxyColor textColour       = DefaultOutlineColour;

            // Draw circle
            context.SetSourceColor(outlineColour);
            context.LineWidth = 3;
            context.NewPath();
            context.Arc(Location.X, Location.Y, Width / 2, 0, 2 * Math.PI);
            context.StrokePreserve();
            context.SetSourceColor(backgroundColour);
            context.Fill();

            // Write text
            context.LineWidth = 1;
            context.SetSourceColor(textColour);
            context.SetFontSize(13);


            DrawCentredText(context, Name, Location);
        }
Ejemplo n.º 23
0
        private void referencia_mapa(Cairo.Context cr)
        {
            cr.Save();
            cr.SetSourceRGB(0, 0, 0);
            cr.LineWidth = 1;
            cr.Rectangle(2, 2, 250, 100);
            cr.StrokePreserve();
            cr.SetSourceRGB(1, 1, 1);
            cr.Fill();
            cr.Restore();

            double[] color;
            for (int i = 27; i < 227; i++)
            {
                color = calcular_mapa_calor(i, 27, 227);
                cr.Save();
                cr.SetSourceRGBA(color[0], color[1], color[2], 1);
                cr.Rectangle(i, 27, 1, 50);
                cr.Fill();
                cr.Restore();
            }

            cr.Save();
            cr.SetSourceRGB(0, 0, 0);
            cr.SelectFontFace("Arial", FontSlant.Normal, FontWeight.Normal);
            cr.SetFontSize(10);
            cr.MoveTo(7, 92);
            cr.ShowText("Menos visitado");
            cr.MoveTo(192, 92);
            cr.ShowText("Mas visitado");
            cr.MoveTo(12, 12);
            cr.ShowText("Nro. de visitas acumuladas de boids por casillero ");
            cr.MoveTo(12, 24);
            cr.ShowText("por unidad de tiempo");
            cr.Restore();
        }
        private void DrawPoint(Context context, Color c, Complex z)
        {
            context.SetSourceRGB (c.R, c.G, c.B);

            int x = (int)(0.5 * (Width - 10) * z.Real / _axis.YLimUp + 0.5 * Width);
            int y = (int)(0.5 * (Height - 10) * z.Imaginary / _axis.YLimUp + 0.5 * Height);

            context.MoveTo (x, y);
            context.Arc(x, y, 2, 0, 2 * Math.PI);
            context.StrokePreserve();
            context.Fill();
        }
        private void DrawAxes(Context context, double min, double max)
        {
            context.Rectangle(0, 0, Width, Height);
            context.Color = Background;
            context.Fill();

            context.LineWidth = 1;
            context.SetSourceRGB(0.0, 0.0, 0.0);

            context.MoveTo (0, Height / 2);
            context.LineTo (Width, Height / 2);
            context.StrokePreserve();

            context.MoveTo (Width / 2, 0);
            context.LineTo (Width / 2, Height);
            context.StrokePreserve();

            KeyValuePair<double, string>[] ax = _axis.AxisSteps (min, max);
            double y;

            foreach (var a in ax) {
                y = a.Key / _axis.YLimUp * Height / 2 + Height / 2;
                context.MoveTo (Width / 2 - 6, y);
                context.LineTo (Width / 2 + 6, y);
                context.StrokePreserve();

                context.MoveTo (y, Height / 2 - 6);
                context.LineTo (y, Height / 2 + 6);
                context.StrokePreserve();

                if (a.Key != 0) {
                    context.MoveTo (Width / 2 - 10, Height - (y - 1));
                    _axis.Text (context, a.Value, HorizontalTextAlignment.Right);

                    context.MoveTo (y - 1, Height / 2 + 10);
                    _axis.Text (context, a.Value, HorizontalTextAlignment.Center, VerticalTextAlignment.Top);
                } else {
                    //context.MoveTo (Width / 2 + 5, Height / 2 + 5);
                    //_axis.Text (context, a.Value, HorizontalTextAlignment.Left, VerticalTextAlignment.Top);
                }
            }
        }
Ejemplo n.º 26
0
        void DrawTab(Cairo.Context ctx, DockNotebookTab tab, Gdk.Rectangle allocation, Gdk.Rectangle tabBounds, bool highlight, bool active, bool dragging, Pango.Layout la)
        {
            // This logic is stupid to have here, should be in the caller!
            if (dragging)
            {
                tabBounds.X = (int)(tabBounds.X + (dragX - tabBounds.X) * dragXProgress);
                tabBounds.X = Clamp(tabBounds.X, tabStartX, tabEndX - tabBounds.Width);
            }
            int padding = LeftRightPadding;

            padding = (int)(padding * Math.Min(1.0, Math.Max(0.5, (tabBounds.Width - 30) / 70.0)));


            ctx.LineWidth = 1;
            LayoutTabBorder(ctx, allocation, tabBounds.Width, tabBounds.X, 0, active);
            ctx.ClosePath();
            using (LinearGradient gr = new LinearGradient(tabBounds.X, TopBarPadding, tabBounds.X, allocation.Bottom)) {
                if (active)
                {
                    gr.AddColorStop(0, Styles.BreadcrumbGradientStartColor.MultiplyAlpha(tab.Opacity));
                    gr.AddColorStop(1, Styles.BreadcrumbBackgroundColor.MultiplyAlpha(tab.Opacity));
                }
                else
                {
                    gr.AddColorStop(0, CairoExtensions.ParseColor("f4f4f4").MultiplyAlpha(tab.Opacity));
                    gr.AddColorStop(1, CairoExtensions.ParseColor("cecece").MultiplyAlpha(tab.Opacity));
                }
                ctx.Pattern = gr;
            }
            ctx.Fill();

            ctx.Color = new Cairo.Color(1, 1, 1, .5).MultiplyAlpha(tab.Opacity);
            LayoutTabBorder(ctx, allocation, tabBounds.Width, tabBounds.X, 1, active);
            ctx.Stroke();

            ctx.Color = Styles.BreadcrumbBorderColor.MultiplyAlpha(tab.Opacity);
            LayoutTabBorder(ctx, allocation, tabBounds.Width, tabBounds.X, 0, active);
            ctx.StrokePreserve();

            if (tab.GlowStrength > 0)
            {
                Gdk.Point mouse = tracker.MousePosition;
                using (var rg = new RadialGradient(mouse.X, tabBounds.Bottom, 0, mouse.X, tabBounds.Bottom, 100)) {
                    rg.AddColorStop(0, new Cairo.Color(1, 1, 1, 0.4 * tab.Opacity * tab.GlowStrength));
                    rg.AddColorStop(1, new Cairo.Color(1, 1, 1, 0));

                    ctx.Pattern = rg;
                    ctx.Fill();
                }
            }
            else
            {
                ctx.NewPath();
            }

            // Render Close Button (do this first so we can tell how much text to render)

            var ch    = allocation.Height - TopBarPadding - BottomBarPadding + CloseImageTopOffset;
            var crect = new Gdk.Rectangle(tabBounds.Right - padding - CloseButtonSize + 3,
                                          tabBounds.Y + TopBarPadding + (ch - CloseButtonSize) / 2,
                                          CloseButtonSize, CloseButtonSize);

            tab.CloseButtonAllocation = crect;
            tab.CloseButtonAllocation.Inflate(2, 2);

            bool closeButtonHovered = tracker.Hovered && tab.CloseButtonAllocation.Contains(tracker.MousePosition) && tab.WidthModifier >= 1.0f;
            bool drawCloseButton    = tabBounds.Width > 60 || highlight || closeButtonHovered;

            if (drawCloseButton)
            {
                DrawCloseButton(ctx, new Gdk.Point(crect.X + crect.Width / 2, crect.Y + crect.Height / 2), closeButtonHovered, tab.Opacity, tab.DirtyStrength);
            }

            // Render Text
            int w = tabBounds.Width - (padding * 2 + CloseButtonSize);

            if (!drawCloseButton)
            {
                w += CloseButtonSize;
            }

            int textStart = tabBounds.X + padding;

            ctx.MoveTo(textStart, tabBounds.Y + TopPadding + TextOffset + VerticalTextSize);
            // ellipses are for space wasting ..., we cant afford that
            using (var lg = new LinearGradient(textStart + w - 5, 0, textStart + w + 3, 0)) {
                var color = tab.Notify ? new Cairo.Color(0, 0, 1) : Styles.TabBarActiveTextColor;
                color = color.MultiplyAlpha(tab.Opacity);
                lg.AddColorStop(0, color);
                color.A = 0;
                lg.AddColorStop(1, color);
                ctx.Pattern = lg;
                Pango.CairoHelper.ShowLayoutLine(ctx, la.GetLine(0));
            }
            la.Dispose();
        }
Ejemplo n.º 27
0
 public virtual void Paint(Context ctx)
 {
     PointD size = this.MeasureSize (ctx);
     PaintContour (ctx,size);
     KnownColors.SetFontFacePieceName(ctx);
     TextExtents te = ctx.TextExtents(this.Name), ten;
     double y0 = 0.5d*(size.Y-te.Width);
     ctx.MoveTo(0.5d*Margin,y0);
     ctx.Save();
     ctx.Rotate(0.5d*Math.PI);
     ctx.ShowText(this.Name);
     ctx.Restore();
     double x0 = Margin+te.Height;
     KnownColors.SetFontFaceNormal(ctx);
     te = ctx.TextExtents(OptionalString);
     y0 = 2.0d*Margin;
     int index = 0x00;
     PointD siz;
     foreach(IPuzzlePiece ipp in this.arguments) {
         ctx.Save();
         ctx.Translate(x0,Margin);
         if(ipp == null) {
             siz = new PointD(MinimumWidth,size.Y-4.0d*Margin);
             ctx.Rectangle(Margin,Margin,siz.X,siz.Y);
             ctx.Pattern = KnownColors.ConstructionPattern;
             ctx.FillPreserve();
         }
         else {
             siz = ipp.MeasureSize(ctx);
         }
         ctx.Rectangle(0.0d,0.0d,siz.X+2.0d*Margin,siz.Y+2.0d*Margin);
         ctx.Color = KnownColors.Black;
         ctx.StrokePreserve();
         if(ipp == null) {
             ctx.Pattern = ExtensionMethods.GenerateColorSequencePattern(siz.X+2.0d*Margin,TypeColorArguments[index]);
             ctx.Fill();
             ctx.Translate(Margin,Margin);
             ctx.MoveTo(0.0d,0.0d);
             ctx.LineTo(MinimumWidth,0.0d);
             ctx.RelLineTo(0.0d,5.0d);
             ctx.LineTo(5.0d,5.0d);
             ctx.ClosePath();
             ctx.Pattern = KnownColors.ShadowDownPattern;
             ctx.Fill();
             ctx.MoveTo(0.0d,0.0d);
             ctx.LineTo(0.0d,siz.Y);
             ctx.RelLineTo(5.0d,0.0d);
             ctx.LineTo(5.0d,5.0d);
             ctx.ClosePath();
             ctx.Pattern = KnownColors.ShadowRightPattern;
             ctx.Fill();
         }
         else {
             ctx.Pattern = ExtensionMethods.GenerateColorSequencePattern(siz.X+2.0d*Margin,TypeColorArguments[index]);
             ctx.Fill();
             ctx.Color = KnownColors.Black;
             ctx.Translate(Margin,Margin);
             ipp.Paint(ctx);
         }
         ctx.Restore();
         subpieces[index] = new Rectangle(x0+Margin,2.0d*Margin,siz.X,siz.Y);
         x0 += siz.X+3.0d*Margin;
         if(index >= NumberOfArguments-NumberOfOptionalArguments) {
             ctx.MoveTo(x0-2.0d*Margin-0.5d*(siz.X+te.Width),siz.Y+3.0d*Margin-2.0d);
             ctx.ShowText(OptionalString);
         }
         if(this.ArgumentNames != null && index < arguments.Length) {
             ten = ctx.TextExtents(this.ArgumentNames[index]);
             ctx.MoveTo(x0-2.0d*Margin-0.5d*(siz.X+ten.Width),-te.YBearing+Margin+2.0d);
             ctx.ShowText(this.ArgumentNames[index]);
         }
         index++;
     }
 }
Ejemplo n.º 28
0
        void OnExpose(object sender, ExposeEventArgs args)
        {
            area = (DrawingArea) sender;
            cr =  Gdk.CairoHelper.Create(area.GdkWindow);

            cr.LineWidth = 2;
            cr.SetSourceRGB(0.7, 0.2, 0.0);

            cr.Translate(width/2, height/2);
            cr.Rectangle(pX , pY, width, height);
            //cr.Arc(pX, pY, (width < height ? width : height) / 2 - 10, 0, 2*Math.PI);
            cr.StrokePreserve();
            cr.SetSourceRGB(0.3, 0.4, 0.6);
            cr.Fill();

            pX=pY=4;

            //drawInterfaceEth();

            drawInterfaceUps();

            ((IDisposable) cr.Target).Dispose();
            ((IDisposable) cr).Dispose();
        }
Ejemplo n.º 29
0
        private void RenderNodeGroup(NodeGroup ng, Network network, Cairo.Context gc)
        {
            gc.Save();

            SizeD size = CalculateNodeGroupSize(ng, gc);

            ng.Dimension = size;
            CreateRoundedRectPath(gc, ng.Position.X, ng.Position.Y, size.Width, size.Height, 20);
            gc.Color = new Cairo.Color(0, 0, 0, 0.5);
            gc.FillPreserve();

            if (selectedGroup == ng)
            {
                gc.Save();
                gc.Color = orangeOverlay;
                gc.StrokePreserve();
                gc.Restore();
            }

            var titleTextSize = CalculateNodeGroupTitleTextSize(ng, gc);
            var titleSize     = new SizeD(size.Width, titleTextSize.Height + (Padding * 2.0));

            gc.Clip();
            gc.Rectangle(ng.Position.X, ng.Position.Y, titleSize.Width, titleSize.Height);
            gc.Fill();
            gc.ResetClip();

            gc.Color = lightGray;

            double hostTextX = ng.Position.X + (titleSize.Width / 2.0) - (titleTextSize.Width / 2.0);
            double hostTextY = ng.Position.Y + (titleSize.Height / 2.0) - (titleTextSize.Height / 2.0);

            gc.MoveTo(hostTextX, hostTextY /* + titleTextSize.Height */);

            Pango.Layout layout = new Pango.Layout(this.PangoContext);
            layout.FontDescription      = this.PangoContext.FontDescription.Copy();
            layout.FontDescription.Size = Pango.Units.FromDouble(NodegroupNameFontSize);
            layout.SetText(ng.Name);
            Pango.CairoHelper.ShowLayout(gc, layout);

            SizeD nodesSize = CalculateNodeGroupSize(ng, gc);

            if (ng.Nodes.Count == 1)
            {
                double positionY = ng.Position.Y + titleSize.Height + Padding;
                double positionX = ng.Position.X + (ng.Dimension.Width / 2.0) - HalfAvatarDimension;
                RenderNode(gc, (Node)ng.Nodes[0], positionX, positionY);
            }
            else if (ng.Nodes.Count == 2)
            {
                // position them side-by-side, separated by (padding) number of pixels, centered in the
                // space.
                double positionY  = ng.Position.Y + titleSize.Height + Padding;
                double position1X = ng.Position.X + (ng.Dimension.Width / 2.0) - (Padding / 2.0) - AvatarDimension;
                double position2X = position1X + Padding + AvatarDimension;
                RenderNode(gc, (Node)ng.Nodes[0], position1X, positionY);
                RenderNode(gc, (Node)ng.Nodes[1], position2X, positionY);
            }
            else
            {
                double deg = 0;
                double x   = 0;
                double y   = 0;

                var contentY      = ng.Position.Y + titleSize.Height;
                var contentHeight = size.Height - titleSize.Height;
                var middle        = new System.Drawing.Point(Convert.ToInt32(ng.Position.X + size.Width - (size.Width / 2.0)),
                                                             Convert.ToInt32(contentY + contentHeight - (contentHeight / 2.0)));

                int nodeSize = Convert.ToInt32(AvatarDimension);
                for (int i = 0; i < ng.Nodes.Count; i++)
                {
                    x = Math.Sin(deg) * ((size.Width / 2.0) - (nodeSize)) + middle.X - (nodeSize / 2.0);
                    y = Math.Cos(deg) * ((contentHeight / 2.0) - (nodeSize)) + middle.Y - (nodeSize / 2.0);
                    RenderNode(gc, (Node)ng.Nodes[i], x, y);
                    deg += Math.PI / (ng.Nodes.Count / 2.0);
                }
            }
            gc.Restore();
        }
Ejemplo n.º 30
0
        internal void DrawKeyTip(Context cr, Point reference, double horizontal_align, double vertical_align, Pango.Layout layout)
        {
            Pango.Layout min_layout = Pango.CairoHelper.CreateLayout (cr);

            min_layout.SetText ("O");
            Pango.CairoHelper.UpdateLayout (cr, min_layout);
            int minWidth, minHeight;
            min_layout.GetPixelSize (out minWidth, out minHeight);

            /*layout.SetText (label);
            Pango.CairoHelper.UpdateLayout (cr, layout);*/
            int lblWidth, lblHeight;
            layout.GetPixelSize (out lblWidth, out lblHeight);

            int width = Math.Max (minWidth, lblWidth);
            int height = Math.Max (minHeight, lblHeight);

            double x0 = reference.X - (width * horizontal_align), x1 = x0 + width;
            double y0 = reference.Y - (height * vertical_align), y1 = y0 + height;

            cr.LineWidth = 1.0;

            cr.MoveTo (x0 + 1.5, y0 + 0.5);
            cr.LineTo (x1 - 1.5, y0 + 0.5);
            cr.LineTo (x1 - 0.5, y0 + 1.5);
            cr.LineTo (x1 - 0.5, y1 - 1.5);
            cr.LineTo (x1 - 1.5, y1 - 0.5);
            cr.LineTo (x0 + 1.5, y1 - 0.5);
            cr.LineTo (x0 + 0.5, y1 - 1.5);
            cr.LineTo (x0 + 0.5, y0 + 1.5);
            cr.LineTo (x0 + 0.5, y0 + 0.5);

            cr.Color = new Color (0, 0, 0);
            cr.StrokePreserve ();

            LinearGradient grad = new LinearGradient (0, y0, 0, y1);
            grad.AddColorStop (0, colorScheme.LightBright);
            grad.AddColorStop (1, colorScheme.LightDark);
            cr.Pattern = grad;
            cr.Fill ();
            grad.Destroy ();

            Pango.CairoHelper.UpdateLayout (cr, layout);
            cr.MoveTo (x0 + 1, y0 +1);
            cr.Color = new Color (0, 0, 0);
            Pango.CairoHelper.ShowLayout (cr, layout);
        }
Ejemplo n.º 31
0
        private void DrawAxes(Context context, double min, double max)
        {
            context.Rectangle(0, 0, Width, Height);
            context.SetSourceRGB(Background.R, Background.G, Background.B);
            context.Fill();

            int y = ValueToY (0);
            context.LineWidth = 1;
            context.SetSourceRGB(0.0, 0.0, 0.0);

            context.MoveTo (44, y);
            context.LineTo (Width, y);
            context.StrokePreserve();

            context.MoveTo (50, 0);
            context.LineTo (50, Height);
            context.StrokePreserve();

            KeyValuePair<double, string>[] ax = _axis.AxisSteps (min, max);

            foreach (var a in ax) {
                y = ValueToY (a.Key);
                context.MoveTo (44, y);
                context.LineTo (56, y);
                context.StrokePreserve();
                context.MoveTo (40, y - 1);
                _axis.Text (context, a.Value, HorizontalTextAlignment.Right);
            }
        }
Ejemplo n.º 32
0
        private void StrokeAndFill(Context context)
        {
            context.LineWidth = 4.0;
            context.Color = TangoColors.Chameleon3;
            context.StrokePreserve ();

            context.Color = TangoColors.Chameleon1;
            context.Fill ();
        }
Ejemplo n.º 33
0
		void DrawTab (Context ctx, DockNotebookTab tab, Gdk.Rectangle allocation, Gdk.Rectangle tabBounds, bool highlight, bool active, bool dragging, Pango.Layout la)
		{
			// This logic is stupid to have here, should be in the caller!
			if (dragging) {
				tabBounds.X = (int)(tabBounds.X + (dragX - tabBounds.X) * dragXProgress);
				tabBounds.X = Clamp (tabBounds.X, tabStartX, tabEndX - tabBounds.Width);
			}
			int padding = LeftRightPadding;
			padding = (int)(padding * Math.Min (1.0, Math.Max (0.5, (tabBounds.Width - 30) / 70.0)));

			ctx.LineWidth = 1;
			LayoutTabBorder (ctx, allocation, tabBounds.Width, tabBounds.X, 0, active);
			ctx.ClosePath ();
			using (var gr = new LinearGradient (tabBounds.X, TopBarPadding, tabBounds.X, allocation.Bottom)) {
				if (active) {
					gr.AddColorStop (0, Styles.BreadcrumbGradientStartColor.MultiplyAlpha (tab.Opacity));
					gr.AddColorStop (1, Styles.BreadcrumbBackgroundColor.MultiplyAlpha (tab.Opacity));
				} else {
					gr.AddColorStop (0, CairoExtensions.ParseColor ("f4f4f4").MultiplyAlpha (tab.Opacity));
					gr.AddColorStop (1, CairoExtensions.ParseColor ("cecece").MultiplyAlpha (tab.Opacity));
				}
				ctx.SetSource (gr);
			}
			ctx.Fill ();

			ctx.SetSourceColor (new Cairo.Color (1, 1, 1, .5).MultiplyAlpha (tab.Opacity));
			LayoutTabBorder (ctx, allocation, tabBounds.Width, tabBounds.X, 1, active);
			ctx.Stroke ();

			ctx.SetSourceColor (Styles.BreadcrumbBorderColor.MultiplyAlpha (tab.Opacity));
			LayoutTabBorder (ctx, allocation, tabBounds.Width, tabBounds.X, 0, active);
			ctx.StrokePreserve ();

			if (tab.GlowStrength > 0) {
				Gdk.Point mouse = tracker.MousePosition;
				using (var rg = new RadialGradient (mouse.X, tabBounds.Bottom, 0, mouse.X, tabBounds.Bottom, 100)) {
					rg.AddColorStop (0, new Cairo.Color (1, 1, 1, 0.4 * tab.Opacity * tab.GlowStrength));
					rg.AddColorStop (1, new Cairo.Color (1, 1, 1, 0));

					ctx.SetSource (rg);
					ctx.Fill ();
				}
			} else {
				ctx.NewPath ();
			}

			// Render Close Button (do this first so we can tell how much text to render)

			var ch = allocation.Height - TopBarPadding - BottomBarPadding + CloseImageTopOffset;
			var crect = new Gdk.Rectangle (tabBounds.Right - padding - CloseButtonSize + 3,
				            tabBounds.Y + TopBarPadding + (ch - CloseButtonSize) / 2,
				            CloseButtonSize, CloseButtonSize);
			tab.CloseButtonAllocation = crect;
			tab.CloseButtonAllocation.Inflate (2, 2);

			bool closeButtonHovered = tracker.Hovered && tab.CloseButtonAllocation.Contains (tracker.MousePosition) && tab.WidthModifier >= 1.0f;
			bool drawCloseButton = tabBounds.Width > 60 || highlight || closeButtonHovered;
			if (drawCloseButton) {
				DrawCloseButton (ctx, new Gdk.Point (crect.X + crect.Width / 2, crect.Y + crect.Height / 2), closeButtonHovered, tab.Opacity, tab.DirtyStrength);
			}

			// Render Text
			int w = tabBounds.Width - (padding * 2 + CloseButtonSize);
			if (!drawCloseButton)
				w += CloseButtonSize;

			int textStart = tabBounds.X + padding;

			ctx.MoveTo (textStart, tabBounds.Y + TopPadding + TextOffset + VerticalTextSize);
			if (!MonoDevelop.Core.Platform.IsMac && !MonoDevelop.Core.Platform.IsWindows) {
				// This is a work around for a linux specific problem.
				// A bug in the proprietary ATI driver caused TAB text not to draw.
				// If that bug get's fixed remove this HACK asap.
				la.Ellipsize = Pango.EllipsizeMode.End;
				la.Width = (int)(w * Pango.Scale.PangoScale);
				ctx.SetSourceColor (tab.Notify ? new Cairo.Color (0, 0, 1) : Styles.TabBarActiveTextColor);
				Pango.CairoHelper.ShowLayoutLine (ctx, la.GetLine (0));
			} else {
				// ellipses are for space wasting ..., we cant afford that
				using (var lg = new LinearGradient (textStart + w - 5, 0, textStart + w + 3, 0)) {
					var color = tab.Notify ? new Cairo.Color (0, 0, 1) : Styles.TabBarActiveTextColor;
					color = color.MultiplyAlpha (tab.Opacity);
					lg.AddColorStop (0, color);
					color.A = 0;
					lg.AddColorStop (1, color);
					ctx.SetSource (lg);
					Pango.CairoHelper.ShowLayoutLine (ctx, la.GetLine (0));
				}
			}
			la.Dispose ();
		}
Ejemplo n.º 34
0
 private void DrawHistArea(Context context, double xl, double yl, int i, int j, double value)
 {
     Color c = HistColor (value);
     context.SetSourceRGB (c.R, c.G, c.B);
     context.MoveTo ((int)(j * xl + 50), (int)(i * yl));
     context.LineTo ((int)((j + 1) * xl + 50), (int)(i * yl));
     context.LineTo ((int)((j + 1) * xl + 50), (int)((i + 1) * yl));
     context.LineTo ((int)(j * xl + 50), (int)((i + 1) * yl));
     context.LineTo ((int)(j * xl + 50), (int)(i * yl));
     context.StrokePreserve ();
     context.MoveTo ((int)((j + .5) * xl + 50), (int)((i + .5) * yl));
     context.Fill ();
 }
Ejemplo n.º 35
0
 private void DrawPoint(Context context, int j, double val)
 {
     double xl = 0.5 * (double)(Width - 60) / N;
     int x = (int)((Width - 60) * ((double)j / N) + 50 + xl);
     int y = ValueToY (val);
     context.MoveTo (x, y);
     context.Arc(x, y, 2, 0, 2 * Math.PI);
     context.StrokePreserve();
     context.Fill();
 }
Ejemplo n.º 36
0
        /// <summary>
        /// Paints an overview of the forecast including high/low temps and a condition icon.
        /// </summary>
        /// <param name="cr">
        /// A <see cref="Cairo.Context"/> to do the painting.
        /// </param>
        void DrawVertForecast(Cairo.Context cr)
        {
            int    cellHeight = (int)((Allocation.Height - BUTTON_SIZE) / WeatherController.Weather.ForecastDays / 1.5);
            double xOffset    = 0;
            double yOffset    = cellHeight / 4.0;

            using (Pango.Layout layout = DockServices.Drawing.ThemedPangoLayout()) {
                Pango.Rectangle inkRect, logicalRect;

                layout.FontDescription        = new Gtk.Style().FontDescription;
                layout.FontDescription.Weight = Pango.Weight.Bold;
                layout.Ellipsize = Pango.EllipsizeMode.None;
                layout.Width     = Pango.Units.FromPixels(cellHeight);

                for (int day = 0; day < WeatherController.Weather.ForecastDays; day++)
                {
                    layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels((int)(cellHeight / 5));

                    cr.Color = colorTitle;
                    layout.SetText(string.Format("{0}", WeatherForecast.DayShortName(WeatherController.Weather.Forecasts [day].dow)));
                    layout.GetPixelExtents(out inkRect, out logicalRect);
                    cr.MoveTo(xOffset + (cellHeight - inkRect.Width) / 2, yOffset);
                    Pango.CairoHelper.LayoutPath(cr, layout);
                    cr.Fill();

                    cr.Color = colorHigh;
                    layout.SetText(string.Format("{0}{1}", WeatherController.Weather.Forecasts [day].high, AbstractWeatherSource.TempUnit));
                    layout.GetPixelExtents(out inkRect, out logicalRect);
                    cr.MoveTo(xOffset + (cellHeight - inkRect.Width) / 2, yOffset + (cellHeight - logicalRect.Height) / 2);
                    Pango.CairoHelper.LayoutPath(cr, layout);
                    cr.Fill();

                    cr.Color = colorLow;
                    layout.SetText(string.Format("{0}{1}", WeatherController.Weather.Forecasts [day].low, AbstractWeatherSource.TempUnit));
                    layout.GetPixelExtents(out inkRect, out logicalRect);
                    cr.MoveTo(xOffset + (cellHeight - inkRect.Width) / 2, yOffset + cellHeight - logicalRect.Height);
                    Pango.CairoHelper.LayoutPath(cr, layout);
                    cr.Fill();

                    using (Gdk.Pixbuf pbuf = DockServices.Drawing.LoadIcon(WeatherController.Weather.Forecasts [day].image, cellHeight - 5)) {
                        Gdk.CairoHelper.SetSourcePixbuf(cr, pbuf, xOffset + 5 + cellHeight, yOffset + 2);
                        cr.PaintWithAlpha(WeatherController.Weather.Forecasts [day].chanceOf ? .6 : 1);
                    }

                    if (WeatherController.Weather.Forecasts [day].chanceOf)
                    {
                        layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels((int)(cellHeight / 2));

                        layout.SetText("?");

                        layout.GetPixelExtents(out inkRect, out logicalRect);
                        cr.MoveTo(xOffset + cellHeight + (cellHeight - inkRect.Width) / 2, yOffset + (cellHeight - logicalRect.Height) / 2);

                        cr.LineWidth = 4;
                        cr.Color     = new Cairo.Color(0, 0, 0, 0.3);
                        Pango.CairoHelper.LayoutPath(cr, layout);
                        cr.StrokePreserve();

                        cr.Color = new Cairo.Color(1, 1, 1, .6);
                        cr.Fill();
                    }

                    yOffset += (int)(1.5 * cellHeight);
                }

                layout.FontDescription.Dispose();
                layout.Context.Dispose();
            }
        }
Ejemplo n.º 37
0
			protected override bool OnDrawn (Context cr)
			{
				int w, h;
				this.GdkWindow.GetSize (out w, out h);
				var bounds = new Xwt.Rectangle (0.5, 0.5, w - 1, h - 1);
				var black = Xwt.Drawing.Color.FromBytes (0xee, 0xee, 0xee);
				
				// We clear the surface with a transparent color if possible
				if (supportAlpha)
					cr.SetSourceRGBA (1.0, 1.0, 1.0, 0.0);
				else
					cr.SetSourceRGB (1.0, 1.0, 1.0);
				cr.Operator = Operator.Source;
				cr.Paint ();
				
				var calibratedRect = RecalibrateChildRectangle (bounds);
				// Fill it with one round rectangle
				RoundRectangle (cr, calibratedRect, radius);
				cr.LineWidth = 1;
				
				// Triangle
				// We first begin by positionning ourselves at the top-center or bottom center of the previous rectangle
				var arrowX = bounds.Center.X + arrowDelta;
				var arrowY = arrowPosition == Xwt.Popover.Position.Top ? calibratedRect.Top + cr.LineWidth : calibratedRect.Bottom;
				cr.MoveTo (arrowX, arrowY);
				// We draw the rectangle path
				DrawTriangle (cr);

				// We use it
				cr.SetSourceRGBA (black.Red, black.Green, black.Blue, black.Alpha);
				cr.StrokePreserve ();
				cr.SetSourceRGBA (BackgroundColor.R, BackgroundColor.G, BackgroundColor.B, BackgroundColor.A);
				cr.Fill ();

				return base.OnDrawn (cr);
			}
Ejemplo n.º 38
0
        private void Render(Clutter.CairoTexture texture, int with_state, bool outwards)
        {
            texture.Clear();
            Cairo.Context context = texture.Create();

            double alpha_f = with_state == 0 ? 0.5 : (with_state == 1 ? 0.8 : 1);

            double lwidth  = 1;
            double hlwidth = lwidth * 0.5;

            context.LineWidth = lwidth;

            if (outwards)
            {
                context.MoveTo(texture.Width * 0.5 - texture.Height * 0.45, texture.Height * 0.9);
                context.CurveTo(texture.Width * 0.3, texture.Height, texture.Width * 0.6, texture.Height, texture.Width * 0.5 + texture.Height * 0.45, texture.Height * 0.9);
                context.ArcNegative(texture.Width * 0.5, texture.Height * 0.9, texture.Height * 0.45, 0, Math.PI);
                context.ClosePath();
                Gradient g1 = new LinearGradient(0, texture.Height / 2, 0, texture.Height);
                g1.AddColorStop(0, new Cairo.Color(0.6, 0.6, 0.6, 1.0 * alpha_f));
                g1.AddColorStop(1.0, new Cairo.Color(1.0, 1.0, 1.0, 1.0 * alpha_f));
                context.Pattern = g1;
                context.FillPreserve();
                context.SetSourceRGBA(1.0, 1.0, 1.0, 1.0 * alpha_f);
                context.Stroke();
                ((IDisposable)g1).Dispose();

                context.Arc(Width * 0.5, Height * 0.33 + lwidth, Height * 0.33, 0, Math.PI * 2);
                context.ClosePath();
                context.Operator = Operator.Source;
                Gradient g2 = new RadialGradient(texture.Width * 0.5, texture.Height * 0.25, 0, texture.Width * 0.5, texture.Height * 0.25, texture.Width * 0.5);
                g2.AddColorStop(0, new Cairo.Color(1.0, 1.0, 1.0, 1.0 * alpha_f));
                g2.AddColorStop(1.0, new Cairo.Color(0.6, 0.6, 0.6, 1.0 * alpha_f));
                context.Pattern = g2;
                //context.SetSourceRGBA (1.0, 1.0, 1.0, 1.0*alpha_f);
                context.FillPreserve();
                Gradient g3 = new LinearGradient(0, 0, 0, texture.Height * 0.5);
                g3.AddColorStop(0, new Cairo.Color(1.0, 1.0, 1.0, 1.0 * alpha_f));
                g3.AddColorStop(1.0, new Cairo.Color(0, 0, 0, 1.0 * alpha_f));
                context.Pattern = g3;
                //context.SetSourceRGBA (1.0, 1.0, 1.0, 1.0*alpha_f);
                context.Stroke();
                ((IDisposable)g2).Dispose();
                ((IDisposable)g3).Dispose();
            }
            else
            {
                Cairo.PointD c     = new Cairo.PointD(texture.Width * 0.5, texture.Height * 0.5);
                double       max_r = Math.Min(c.X, c.Y) - hlwidth;

                context.Arc(c.X, c.Y, max_r, 0, Math.PI * 2);
                context.ArcNegative(c.X, c.Y, max_r * 0.25, Math.PI * 2, 0);
                context.ClosePath();
                context.SetSourceRGBA(0.5, 0.5, 0.5, 1.0 * alpha_f);
                context.StrokePreserve();
                Gradient g1 = new LinearGradient(0, texture.Height, texture.Width, 0);
                g1.AddColorStop(0, new Cairo.Color(1.0, 1.0, 1.0, 1.0 * alpha_f));
                g1.AddColorStop(0.5, new Cairo.Color(0.7, 0.7, 0.7, 1.0 * alpha_f));
                g1.AddColorStop(1, new Cairo.Color(0.9, 0.9, 0.9, 1.0 * alpha_f));
                context.Pattern = g1;
                context.Fill();
                ((IDisposable)g1).Dispose();

                context.ArcNegative(c.X, c.Y, max_r * 0.25 + lwidth, Math.PI * 1.75, Math.PI * 0.75);
                context.Arc(c.X, c.Y, max_r, Math.PI * 0.75, Math.PI * 1.75);
                context.ClosePath();
                Gradient g2 = new LinearGradient(c.X, c.Y, c.X * 0.35, c.Y * 0.35);
                g2.AddColorStop(0, new Cairo.Color(1.0, 1.0, 1.0, 1.0 * alpha_f));
                g2.AddColorStop(1, new Cairo.Color(1.0, 1.0, 1.0, 0.0));
                context.Pattern = g2;
                context.Fill();
                ((IDisposable)g2).Dispose();

                context.ArcNegative(c.X, c.Y, max_r * 0.25 + lwidth, Math.PI * 2, 0);
                context.Arc(c.X, c.Y, max_r * 0.45, 0, Math.PI * 2);
                context.SetSourceRGBA(1.0, 1.0, 1.0, 0.8 * alpha_f);
                context.Fill();

                context.Arc(c.X, c.Y, max_r - lwidth, 0, Math.PI * 2);
                Gradient g3 = new LinearGradient(0, texture.Height, texture.Width, 0);
                g3.AddColorStop(0, new Cairo.Color(1.0, 1.0, 1.0, 0.0));
                g3.AddColorStop(1, new Cairo.Color(0.9, 0.9, 0.9, 1.0 * alpha_f));
                context.Pattern = g3;
                context.Stroke();
                ((IDisposable)g3).Dispose();
            }

            ((IDisposable)context.Target).Dispose();
            ((IDisposable)context).Dispose();
        }