MoveTo() public method

public MoveTo ( PointD p ) : void
p PointD
return void
示例#1
0
        static void Main()
        {
            // The using statement ensures that potentially heavy objects
            // are disposed immediately.
            using (ImageSurface draw = new ImageSurface(Format.Argb32, 70, 150))
            {
                using (Context gr = new Context(draw))
                {
                    gr.Antialias = Antialias.Subpixel;    // sets the anti-aliasing method
                    gr.LineWidth = 9;          // sets the line width
                    gr.SetSourceColor(new Color(0, 0, 0, 1));   // red, green, blue, alpha
                    gr.MoveTo(10, 10);          // sets the Context's start point.
                    gr.LineTo(40, 60);          // draws a "virtual" line from 5,5 to 20,30
                    gr.Stroke();          //stroke the line to the image surface

                    gr.Antialias = Antialias.Gray;
                    gr.LineWidth = 8;
                    gr.SetSourceColor(new Color(1, 0, 0, 1));
                    gr.LineCap = LineCap.Round;
                    gr.MoveTo(10, 50);
                    gr.LineTo(40, 100);
                    gr.Stroke();

                    gr.Antialias = Antialias.None;    //fastest method but low quality
                    gr.LineWidth = 7;
                    gr.MoveTo(10, 90);
                    gr.LineTo(40, 140);
                    gr.Stroke();

                    draw.WriteToPng("antialias.png");  //save the image as a png image.
                }
            }
        }
示例#2
0
        public override void Draw(Context context)
        {
            SetupLayout(context);

            RectangleD displayBox = DisplayBox;
            displayBox.OffsetDot5();
            double side = 10.0;

            context.LineWidth = LineWidth;
            context.Save ();
            //Box
            context.MoveTo (displayBox.X, displayBox.Y);
            context.LineTo (displayBox.X, displayBox.Y + displayBox.Height);
            context.LineTo (displayBox.X + displayBox.Width, displayBox.Y + displayBox.Height);
            context.LineTo (displayBox.X + displayBox.Width, displayBox.Y + side);
            context.LineTo (displayBox.X + displayBox.Width - side, displayBox.Y);
            context.LineTo (displayBox.X, displayBox.Y);
            context.Save ();
            //Triangle
            context.MoveTo (displayBox.X + displayBox.Width - side, displayBox.Y);
            context.LineTo (displayBox.X + displayBox.Width - side, displayBox.Y + side);
            context.LineTo (displayBox.X + displayBox.Width, displayBox.Y + side);
            context.LineTo (displayBox.X + displayBox.Width - side, displayBox.Y);
            context.Restore ();

            context.Color = FillColor;
            context.FillPreserve ();
            context.Color = LineColor;
            context.Stroke ();

            DrawText (context);
        }
示例#3
0
 protected override void OnPaint(PaintEventArgs e)
 {
     base.OnPaint(e);
     using (System.Drawing.Graphics graphics = e.Graphics)
     {
         using (Win32Surface surface = new Win32Surface(graphics.GetHdc()))
         {
             using (Context context = new Context(surface))
             {
                 context.LineWidth = 2.0;
                 context.SetSourceColor(this.bugColor);
                 context.MoveTo(7.0, 64.0);
                 context.CurveTo(1.0, 47.0, 2.0, 46.0, 9.0, 51.0);
                 context.MoveTo(25.0, 80.0);
                 context.CurveTo(10.0, 73.0, 11.0, 70.0, 14.0, 63.0);
                 context.MoveTo(10.0, 41.0);
                 context.CurveTo(2.0, 36.0, 1.0, 33.0, 1.0, 26.0);
                 context.LineWidth = 1.0;
                 context.MoveTo(1.0, 26.0);
                 context.CurveTo(5.0, 23.0, 7.0, 18.0, 12.0, 17.0);
                 context.LineTo(12.0, 14.0);
                 context.Stroke();
                 context.MoveTo(30.0, 74.0);
                 context.CurveTo(14.0, 64.0, 10.0, 48.0, 11.0, 46.0);
                 context.LineTo(10.0, 45.0);
                 context.LineTo(10.0, 40.0);
                 context.CurveTo(13.0, 37.0, 15.0, 35.0, 19.0, 34.0);
                 context.Stroke();
             }
         }
     }
 }
示例#4
0
 private void Image_Loaded(object sender, RoutedEventArgs e)
 {
     Image image = (Image)sender;
     using (ImageSurface surface = new ImageSurface(Format.Argb32, (int)image.Width, (int)image.Height))
     {
         using (Context context = new Context(surface))
         {
             PointD p = new PointD(10.0, 10.0);
             PointD p2 = new PointD(100.0, 10.0);
             PointD p3 = new PointD(100.0, 100.0);
             PointD p4 = new PointD(10.0, 100.0);
             context.MoveTo(p);
             context.LineTo(p2);
             context.LineTo(p3);
             context.LineTo(p4);
             context.LineTo(p);
             context.ClosePath();
             context.Fill();
             context.MoveTo(140.0, 110.0);
             context.SetFontSize(32.0);
             context.SetSourceColor(new Color(0.0, 0.0, 0.8, 1.0));
             context.ShowText("Hello Cairo!");
             surface.Flush();
             RgbaBitmapSource source = new RgbaBitmapSource(surface.Data, surface.Width);
             image.Source = source;
         }
     }
 }
示例#5
0
        protected override void DrawGraduations(Context gr, PointD pStart, PointD pEnd)
        {
            Rectangle r = ClientRectangle;
            Foreground.SetAsSource (gr);

            gr.LineWidth = 2;
            gr.MoveTo(pStart);
            gr.LineTo(pEnd);

            gr.Stroke();
            gr.LineWidth = 1;

            double sst = unity * SmallIncrement;
            double bst = unity * LargeIncrement;

            PointD vBar = new PointD(0, sst);
            for (double x = Minimum; x <= Maximum - Minimum; x += SmallIncrement)
            {
                double lineLength = r.Height / 3;
                if (x % LargeIncrement != 0)
                    lineLength /= 3;
                PointD p = new PointD(pStart.X + x * unity, pStart.Y);
                gr.MoveTo(p);
                gr.LineTo(new PointD(p.X, p.Y + lineLength));
            }
            gr.Stroke();
        }
示例#6
0
    public void DrawGraph(Context gr)
    {
        int mag = Magnification;
        double xoffset =  (Allocation.Width/2) ;
        double yoffset =  (Allocation.Height/2) ;

        if (ForceGraph != null) {
            this.GdkWindow.Clear ();
            gr.Antialias = Antialias.Subpixel;
            foreach (var p in ForceGraph.Springs){
                gr.LineWidth = 1.5;

                if ( p.Data != null ){
                    var data = p.Data as NodeData;
                    if ( data != null )
                        gr.Color = data.Stroke;
                } else {
                    gr.Color = new Color( 0,0,0,1);
                }
                gr.MoveTo( xoffset + ( p.NodeA.Location.X * mag ), yoffset + ( p.NodeA.Location.Y * mag ) );
                gr.LineTo( xoffset + ( p.NodeB.Location.X * mag ), yoffset + ( p.NodeB.Location.Y * mag ) );
                gr.Stroke();

            }

            foreach (var n in ForceGraph.Nodes) {
                var stroke = new Color( 0.1, 0.1, 0.1, 0.8 );
                var fill   = new Color( 0.2, 0.7, 0.7, 0.8 );
                var size = 5.5;

                NodeData nd = n.Data as NodeData;
                if ( nd != null ){
                    stroke = nd.Stroke;
                    fill = nd.Fill;
                    size = nd.Size;

                }

                DrawFilledCircle (gr,
                    xoffset + (mag * n.Location.X),
                    yoffset + (mag * n.Location.Y),
                    size,
                    stroke,
                    fill
                    );

                if ( nd != null ) {
                    if ( nd.Label != null ){
                        gr.Color = new Color(0,0,0,0.7);
                        gr.SetFontSize(24);
                        gr.MoveTo( 25 + xoffset + (mag * n.Location.X), 25 + yoffset + (mag * n.Location.Y));
                        gr.ShowText( nd.Label );
                    }
                }

            }

        }
    }
		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 ();
		}
示例#8
0
  protected override FlowReturn OnTransformIp (Gst.Buffer buf) {
    if (!buf.IsWritable)
      return FlowReturn.Error;

    Cairo.ImageSurface img = new Cairo.ImageSurface (buf.Data, Cairo.Format.Rgb24, width, height, width*4);

    using (Cairo.Context context = new Cairo.Context (img)) {
      double dx = (double) ( (buf.Timestamp / Clock.MSecond) % 2180) / 5;
      context.Save ();
      context.Scale (width / 640.0, height / 480.0);
      context.MoveTo (300, 10 + dx);
      context.LineTo (500 - dx, 400);
      context.LineWidth = 4.0;
      context.Color = new Color (0, 0, 1.0);
      context.Stroke();
      context.Restore ();

      if (lastX != -1 && lastY != -1) {
        context.Color = new Color (1.0, 0, 0);
        context.Translate (lastX, lastY);
        context.Scale (Math.Min (width / 640.0, height / 480.0), Math.Min (width / 640.0, height / 480.0));
        context.Arc (0, 0, 10.0, 0.0, 2 * Math.PI);
        context.Fill();
      }
    }

    img.Destroy ();
    return base.OnTransformIp (buf);
  }
示例#9
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;
		}
        public void DrawObject(Context ctx, DrawingObject body)
        {
            if (body == null)
                return;
            ctx.Save ();
            ctx.Color = new Cairo.Color (0, 0, 0);

            ctx.LineWidth = 1;
            foreach (Tuple<PointDouble, PointDouble> line in body.lines) {
                ctx.MoveTo (line.Item1.toPointD());
                ctx.LineTo (line.Item2.toPointD());
            }

            if (body.points.Count > 1)
                ctx.Rectangle(body._centerOfMass.X - 5, body._centerOfMass.Y - 5, 10, 10);
            ctx.Stroke ();

            foreach (PointDouble point in body.points) {
                ctx.Rectangle (point.X - 5, point.Y - 5, 10, 10);
                ctx.Fill ();
            }
            foreach (Tuple<PointDouble, double, double> force in body._forces) {
                DrawForce (ctx, force);
            }

            foreach (Tuple<PointDouble, double> moment in body._moments) {
                DrawMoment (ctx, moment);
            }

            ctx.Restore ();
        }
示例#11
0
        public override void Draw(Context cr, Gdk.Rectangle clip)
        {
            base.Draw(cr, clip);

            double X      = clip.X;
            double Y      = clip.Y;
            double Width  = clip.Width;
            double Height = clip.Height;

            // Blue Rulings
            if(horizontalRule) {
                cr.Color = blue;
                for(double i = Y - (Y % ruleDistance) + ruleDistance;
                        i <= Y + Height; i += ruleDistance) {
                    cr.MoveTo(X, i);
                    cr.LineTo(X + Width, i);
                    cr.Stroke();
                }
            }
            if(verticalRule) {
                cr.Color = blue;
                for(double i = X - (X % ruleDistance) + ruleDistance;
                        i <= X + Width; i += ruleDistance) {
                    cr.MoveTo(i, Y);
                    cr.LineTo(i, Y + Height);
                    cr.Stroke();
                }
            }

            // Red Margin Line
            if(leftMargin) {
                cr.Color = red;
                cr.MoveTo(marginSize, Y);
                cr.LineTo(marginSize, Y + Height);
                cr.Stroke();
            }

            // Holes
            if(holes) {
                cr.Color = black;
                cr.Arc(ruleDistance/2, 150, 17, 0, 2 * Math.PI);
                cr.Arc(ruleDistance/2, 650, 17, 0, 2 * Math.PI);
                cr.Arc(ruleDistance/2, 1150,17, 0, 2 * Math.PI);
                cr.Fill();
            }
        }
示例#12
0
 public static void DrawPoints(List<PointD> points,Context cr)
 {
     foreach (PointD p in points){
         cr.MoveTo(p);
         cr.SetSourceRGB (0.3, 0.3, 0.3);
         cr.Arc (p.X, p.Y, 2, 0, 2 * Math.PI);
         cr.Fill ();
     }
 }
示例#13
0
 public static void DrawVertexStructure(VertexStructure vs, Context cr)
 {
     VertexStructure head = vs;
     int i = 0;
     do {
         cr.MoveTo (vs.v);
         cr.SetSourceRGB (0, 0, 0.8);
         cr.Arc (vs.v.X, vs.v.Y, 2, 0, 2 * Math.PI);
         cr.Fill ();
         cr.LineWidth = 1;
         cr.MoveTo (vs.v);
         cr.LineTo(vs.next.v);
         cr.Stroke();
         vs = vs.next;
         //Logger.Log("Meh..." + i);
         i++;
     } while(!ReferenceEquals(vs,head));
 }
示例#14
0
		public static void Draw(Context grw, Line line)
		{
			var color = AppController.Instance.Config.LineColor;
			grw.SetSourceRGB (
				color.Red, 
				color.Green, 
				color.Blue);

			var segments = AppController.Instance.Surface.Segments;

			var s1 = segments.FirstOrDefault (s => s.Position.X == line.Input.X 
				&& s.Position.Y == line.Input.Y);

			var s2 = segments.FirstOrDefault (s => s.Position.X == line.Output.X 
				&& s.Position.Y == line.Output.Y);
			
			if (s1 == null || s2 == null)
			{
				return;
			}

			//todo : use one func.
			var start = s1.Connectors
				.FirstOrDefault (p => p.Marker == line.InputMarker);

			//todo : use one func.
			var stop = s2.Connectors
				.FirstOrDefault (p => p.Marker == line.OutputMarker);
			if (start == null || stop == null)
			{
				return;
			}

			grw.MoveTo (
				start.Center.GeometryX, 
				start.Center.GeometryY);

			if (line.Input.X == line.Output.X ||
			   line.Input.Y == line.Output.Y) {
				grw.LineTo (
					stop.Center.GeometryX, 
					stop.Center.GeometryY);    
			} else {
				grw.LineTo (
					stop.Center.GeometryX, 
					start.Center.GeometryY);    

				grw.LineTo (
					stop.Center.GeometryX, 
					stop.Center.GeometryY);    
			}

			grw.Stroke();
		}
示例#15
0
        public override void LayoutOutline(Node node, Context context)
        {
            PolygonNode poly = node as PolygonNode;
            // polygons have 3 sides
            if (poly.Verticies.Count <= 2)
                return;

            var renderVerts = poly.Verticies.Select (v => new Point (v.X * node.Width, v.Y * node.Height)).ToList ();
            context.MoveTo (renderVerts.First ().ToCairo ());
            renderVerts.ForEach (v => context.LineTo (v.ToCairo ()));
        }
示例#16
0
	void OvalPath (Context cr, double xc, double yc, double xr, double yr)
	{
		Matrix m = cr.Matrix;

		cr.Translate (xc, yc);
		cr.Scale (1.0, yr / xr);
		cr.MoveTo (xr, 0.0);
		cr.Arc (0, 0, xr, 0, 2 * Math.PI);
		cr.ClosePath ();

		cr.Matrix = m;
	}
        public void draw(Context cr)
        {
            Triangle t = model.tri;
            switch (model.alignment) {
            case ActiveTriangle.TriangleAlignment.ChaoticEvil:
                cr.SetSourceRGB (0.5, 0, 0);
                break;
            case ActiveTriangle.TriangleAlignment.TrueNeutral:
                cr.SetSourceRGB (0, 0.8, 0);
                break;
            default:
                cr.SetSourceRGB (1.0, 1.0, 0);
                break;

            }
            cr.LineWidth = 1.1;
            cr.MoveTo (t.a);
            cr.LineTo (t.b);
            cr.MoveTo (t.b);
            cr.LineTo (t.c);
            cr.MoveTo (t.c);
            cr.LineTo (t.a);
            cr.Stroke ();

            cr.Fill();

            Tuple<PointD,PointD,PointD,PointD> points;

            points = model.getSharpestPointAndAssociatedMidpointAndDullestPoints ();
            PointD sharpest = points.Item1;
            PointD midPoint = points.Item2;

            cr.SetSourceRGB (1.0, 0.3, 0.3);
            cr.Arc (sharpest.X, sharpest.Y, 2, 0, 2 * Math.PI);
            cr.Fill ();

            cr.Arc (midPoint.X, midPoint.Y, 2, 0, 2 * Math.PI);
            cr.Fill ();
        }
示例#18
0
        public virtual void Render (Context cr, Gdk.Rectangle area, Color color, bool showEmptyStars, bool isHovering,
            int hoverValue, double fillOpacity, double hoverFillOpacity, double strokeOpacity)
        {
            if (Value == MinRating && !isHovering && !showEmptyStars) {
                return;
            }

            Cairo.Color fill_color = color;
            fill_color.A = fillOpacity;
            Cairo.Color stroke_color = fill_color;
            stroke_color.A = strokeOpacity;
            Cairo.Color hover_fill_color = fill_color;
            hover_fill_color.A = hoverFillOpacity;

            double x, y;
            ComputePosition (area, out x, out y);

            cr.LineWidth = 1.0;
            cr.Translate (0.5, 0.5);

            for (int i = MinRating + 1, s = isHovering || showEmptyStars ? MaxRating : Value; i <= s; i++, x += Size) {
                bool fill = i <= Value && Value > MinRating;
                bool hover_fill = i <= hoverValue && hoverValue > MinRating;
                double scale = fill || hover_fill ? Size : Size - 2;
                double ofs = fill || hover_fill ? 0 : 1;

                for (int p = 0, n = star_plot.GetLength (0); p < n; p++) {
                    double px = x + ofs + star_plot[p, 0] * scale;
                    double py = y + ofs + star_plot[p, 1] * scale;
                    if (p == 0) {
                        cr.MoveTo (px, py);
                    } else {
                        cr.LineTo (px, py);
                    }
                }
                cr.ClosePath ();

                if (fill || hover_fill) {
                    if (!isHovering || hoverValue >= Value) {
                        cr.Color = fill ? fill_color : hover_fill_color;
                    } else {
                        cr.Color = hover_fill ? fill_color : hover_fill_color;
                    }
                    cr.Fill ();
                } else {
                    cr.Color = stroke_color;
                    cr.Stroke ();
                }
            }
        }
示例#19
0
	public void CreatePng ()
	{
		const int Width = 480;
		const int Height = 160;
		const int CheckSize = 10;
		const int Spacing = 2;

		// Create an Image-based surface with data stored in ARGB32 format and a context,
		// "using" is used here to ensure that they are Disposed once we are done
		using (ImageSurface surface = new ImageSurface (Format.ARGB32, Width, Height))
		using (Context cr = new Cairo.Context (surface))
		{
			// Start drawing a checkerboard
			int i, j, xcount, ycount;
			xcount = 0;
			i = Spacing;
			while (i < Width) {
				j = Spacing;
				ycount = xcount % 2; // start with even/odd depending on row
				while (j < Height) {
					if (ycount % 2 != 0)
						cr.SetSourceRGB (1, 0, 0);
					else
						cr.SetSourceRGB (1, 1, 1);
					// If we're outside the clip, this will do nothing.
					cr.Rectangle (i, j, CheckSize, CheckSize);
					cr.Fill ();

					j += CheckSize + Spacing;
					++ycount;
				}
				i += CheckSize + Spacing;
				++xcount;
			}

			// Select a font to draw with
			cr.SelectFontFace ("serif", FontSlant.Normal, FontWeight.Bold);
			cr.SetFontSize (64.0);

			// Select a color (blue)
			cr.SetSourceRGB (0, 0, 1);

			// Draw
			cr.MoveTo (20, 100);
			cr.ShowText ("Hello, World");

			surface.WriteToPng ("test.png");
		}
	}
示例#20
0
    public static void Numbers(object sender)
    {
        DrawingArea area = (DrawingArea)sender;

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

        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();
    }
		public override PointD Draw (Context context, PointD a, PointD b) {
			PointD leftPoint = new PointD ();
			PointD middlePoint = new PointD ();
			PointD rightPoint = new PointD ();
			Geometry.GetArrowPoints (a, b, _lineDistance, _pointDistance, 
									out leftPoint, out rightPoint, out middlePoint);
			
			context.MoveTo (middlePoint);
			context.LineTo (leftPoint);
			context.LineTo (a);
			context.LineTo (rightPoint);
			context.LineTo (middlePoint);
			context.Stroke ();
			
			return middlePoint;
		}
		public override void Draw (Context context, IDrawingView view) {
			RectangleD rect = ViewDisplayBox(view);
			
			context.LineWidth = LineWidth;

			context.MoveTo (rect.Center.X, rect.Top);
			context.LineTo (rect.Right, rect.Center.Y);
			context.LineTo (rect.Center.X, rect.Bottom);
			context.LineTo (rect.Left, rect.Center.Y);
			context.LineTo (rect.Center.X, rect.Top);

			context.Color = new Cairo.Color (1.0, 0.0, 0.0, 0.8);
			context.FillPreserve ();
			context.Color = new Cairo.Color (0.0, 0.0, 0.0, 1.0);
			context.Stroke ();
		}
    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();
    }
示例#24
0
文件: AppSrc.cs 项目: jwzl/ossbuild
 // Returns a Gst.Buffer presentation of one 640x480 BGRA frame using Cairo
 static Gst.Buffer DrawData (ulong seconds) {
   Gst.Buffer buffer = new Gst.Buffer (640*480*4);
   Cairo.ImageSurface img = new Cairo.ImageSurface (buffer.Data, Cairo.Format.Argb32, 640, 480, 640*4);
   using (Cairo.Context context = new Cairo.Context (img)) {
     double dx = (double) (seconds % 2180) / 5;
     context.Color = new Color (1.0, 1.0, 0);
     context.Paint();
     context.MoveTo (300, 10 + dx);
     context.LineTo (500 - dx, 400);
     context.LineWidth = 4.0;
     context.Color = new Color (0, 0, 1.0);
     context.Stroke();
   }
   img.Destroy();
   return buffer;
 }
    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(50, 50);
        shape.LineTo(100, 50);
        shape.LineTo(100, 100); //draw triangle using lines

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

        ((IDisposable)shape).Dispose();
    }
示例#26
0
        public static void DisplayMessage(Cube c, String msg, SiftColor color)
        {
            ImageSurface sr = new ImageSurface (Format.ARGB32, 128, 128);
            Cairo.Context context = new Cairo.Context (sr);

            context.Color = new Cairo.Color (0, 0, 0, 0);
            context.Paint ();
            Pango.Layout pango = Pango.CairoHelper.CreateLayout (context);

            pango.FontDescription = Pango.FontDescription.FromString ("Arial 16");
            pango.Alignment = Alignment.Center;
            pango.Wrap = WrapMode.WordChar;
            pango.Width = 128 * 1016;
            pango.SetText (msg);

            context.Color = color.ToCairo ();
            int pWidth = 0, pHeight = 0;
            pango.GetPixelSize (out pWidth, out pHeight);
            Log.Debug ("pango Pixel size: " + pWidth + "x" + pHeight);

            context.MoveTo (0, 64 - (pHeight / 2));
            CairoHelper.ShowLayout (context, pango);
            sr.Flush ();
            byte[] data = sr.Data;

            for (int i = 0, x = 0, y = 0; i < data.Length; i += 4, x++) {
                if (x >= 128) {
                    x = 0;
                    y++;
                }
                byte b = data [i],
                g = data [i + 1],
                r = data [i + 2],
                a = data [i + 3];
                if (a != 0 || r != 0 || g != 0 || b != 0) {
                    SiftColor sc = new SiftColor (r, g, b);
                    c.FillRect (sc.ToSifteo (), x, y, 1, 1);
                } else {
                    // we ignore it
                }
            }
            ((IDisposable)context).Dispose ();
            ((IDisposable)pango).Dispose ();
            ((IDisposable)sr).Dispose ();
        }
示例#27
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 ();
		}
示例#28
0
		public static void Draw(Context grw, LineElement line)
		{
			if (line.Foregraund != null) {
				grw.SetSourceRGB (
					line.Foregraund.Red, 
					line.Foregraund.Green, 
					line.Foregraund.Blue);
			}

			grw.MoveTo(
				line.Start.GeometryX, 
				line.Start.GeometryY);
			grw.LineTo(
				line.End.GeometryX, 
				line.End.GeometryY);    

			grw.Stroke();
		}
示例#29
0
        public override void Render(Context cr)
        {
            if (!CanResize) {
                return;
            }

            var selected_color = CairoExtensions.GdkColorToCairoColor (Window.Style.Dark (StateType.Active));
            var grad = new LinearGradient (0, 0, 0, Allocation.Height);

            selected_color.A = 0.4;
            grad.AddColorStop (0, selected_color);
            selected_color.A = 1.0;
            grad.AddColorStop (1, selected_color);

            cr.Pattern = grad;
            cr.LineWidth = 1.0;
            cr.Rectangle (0.5, 0.5, Allocation.Width - 1, Allocation.Height - 1);
            cr.Stroke ();

            selected_color.A = 0.5;
            cr.Color = selected_color;

            double handle_size = 8;
            double ty = 0.5 + Allocation.Height - handle_size - 3;
            double tx = 0.5 + (Window.Direction == TextDirection.Ltr
                ? Allocation.Width - handle_size - 3
                : 3);

            cr.Translate (tx, ty);

            for (double i = 0; i < 3; i++) {
                if (Window.Direction == TextDirection.Ltr) {
                    cr.MoveTo (i * 3, handle_size);
                    cr.LineTo (handle_size, i * 3);
                } else {
                    cr.MoveTo (0, i * 3);
                    cr.LineTo (handle_size - i * 3, handle_size);
                }
            }

            cr.Stroke ();

            cr.Translate (-tx, -ty);
        }
示例#30
0
		public bool OnExpose (Context ctx, Gdk.Rectangle allocation)
		{
			if (frames == 0)
				start = DateTime.UtcNow;
			
			frames ++;
			TimeSpan elapsed = DateTime.UtcNow - start;
			double fraction = elapsed.Ticks / (double) duration.Ticks; 
			double opacity = Math.Sin (Math.Min (fraction, 1.0) * Math.PI * 0.5);
			
			ctx.Operator = Operator.Source;
			
			SurfacePattern p = new SurfacePattern (begin_buffer.Surface);
			ctx.Matrix = begin_buffer.Fill (allocation);
			p.Filter = Filter.Fast;
			ctx.Source = p;
			ctx.Paint ();
			
			ctx.Operator = Operator.Over;
			ctx.Matrix = end_buffer.Fill (allocation);
			SurfacePattern sur = new SurfacePattern (end_buffer.Surface);
			Pattern black = new SolidPattern (new Cairo.Color (0.0, 0.0, 0.0, opacity));
			//ctx.Source = black;
			//ctx.Fill ();
			sur.Filter = Filter.Fast;
			ctx.Source = sur;
			ctx.Mask (black);
			//ctx.Paint ();
			
			ctx.Matrix = new Matrix ();
			
			ctx.MoveTo (allocation.Width / 2.0, allocation.Height / 2.0);
			ctx.Source = new SolidPattern (1.0, 0, 0);	
			#if debug
			ctx.ShowText (String.Format ("{0} {1} {2} {3} {4} {5} {6} {7}", 
						     frames,
						     sur.Status,
						     p.Status,
						     opacity, fraction, elapsed, start, DateTime.UtcNow));
			#endif
			sur.Destroy ();
			p.Destroy ();
			return fraction < 1.0;
		}
示例#31
0
		public void Execute(Context ctx)
		{
			PointD point;
			var first = true;

			using (var mpath = ctx.CopyPath())
			{
				var path = mpath.GetPath();

				for (var i = 0; i < path.num_data; )
				{
					var hdr = path.GetPathHeader(i); //hdr.Dump();

					switch (hdr.type)
					{
						case NativePath.cairo_path_data_type_t.CAIRO_PATH_MOVE_TO:
							if (first)
							{
								ctx.NewPath();
								first = false;
							}
							point = path.GetPathPoint(i + 1);
							ctx.MoveTo(WarpPoint(point));
							break;
						case NativePath.cairo_path_data_type_t.CAIRO_PATH_LINE_TO:
							point = path.GetPathPoint(i + 1);
							ctx.LineTo(WarpPoint(point));
							break;
						case NativePath.cairo_path_data_type_t.CAIRO_PATH_CURVE_TO:
							var p1 = WarpPoint(path.GetPathPoint(i + 1));
							var p2 = WarpPoint(path.GetPathPoint(i + 2));
							var p3 = WarpPoint(path.GetPathPoint(i + 3));
							ctx.CurveTo(p1, p2, p3);
							break;
						case NativePath.cairo_path_data_type_t.CAIRO_PATH_CLOSE_PATH:
							ctx.ClosePath();
							break;
					}

					i += hdr.length;
				}
			}
		}
示例#32
0
		protected override Gdk.Rectangle OnMouseMove (Context g, Color strokeColor, ImageSurface surface,
		                                              int x, int y, int lastX, int lastY)
		{
			int line_width = (int)g.LineWidth;
			int size;

			// we want a minimum size of 2 for the splatter (except for when the brush width is 1), since a splatter of size 1 is very small
			if (line_width == 1)
			{
				size = 1;
			}
			else
			{
				size = Random.Next (2, line_width);
			}

			Rectangle r = new Rectangle (x - Random.Next (-15, 15), y - Random.Next (-15, 15), size, size);

			double rx = r.Width / 2;
			double ry = r.Height / 2;
			double cx = r.X + rx;
			double cy = r.Y + ry;
			double c1 = 0.552285;

			g.Save ();

			g.MoveTo (cx + rx, cy);

			g.CurveTo (cx + rx, cy - c1 * ry, cx + c1 * rx, cy - ry, cx, cy - ry);
			g.CurveTo (cx - c1 * rx, cy - ry, cx - rx, cy - c1 * ry, cx - rx, cy);
			g.CurveTo (cx - rx, cy + c1 * ry, cx - c1 * rx, cy + ry, cx, cy + ry);
			g.CurveTo (cx + c1 * rx, cy + ry, cx + rx, cy + c1 * ry, cx + rx, cy);

			g.ClosePath ();

			Rectangle dirty = g.FixedStrokeExtents ();

			g.Fill ();
			g.Restore ();

			return dirty.ToGdkRectangle ();
		}
示例#33
0
文件: GridBrush.cs 项目: msiyer/Pinta
		protected override Gdk.Rectangle OnMouseMove (Context g, Color strokeColor, ImageSurface surface,
		                                              int x, int y, int lastX, int lastY)
		{
			double cx = Math.Round (x / 100.0) * 100.0;
			double cy = Math.Round (y / 100.0) * 100.0;
			double dx = (cx - x) * 10.0;
			double dy = (cy - y) * 10.0;

			for (int i = 0; i < 50; i++) {
				g.MoveTo (cx, cy);
				g.QuadraticCurveTo (
					x + Random.NextDouble () * dx,
					y + Random.NextDouble () * dy,
					cx,
					cy);
				g.Stroke ();
			}

			return Gdk.Rectangle.Zero;
		}
示例#34
0
        void imprime_encabezado(Cairo.Context cr, Pango.Layout layout, string descripcion_almacen, string numerosolicitud,
                                string fechaenvio, string idusuario, string nombreusr,
                                string numeroatencion, string pidpaciente, string nombrepaciente, string tiposolicitud,
                                string procedimientoqx, string diagnosticoqx, string obs_solicitud)
        {
            //Console.WriteLine("entra en la impresion del encabezado");
            //Gtk.Image image5 = new Gtk.Image();
            //image5.Name = "image5";
            //image5.Pixbuf = new Gdk.Pixbuf(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "osiris.jpg"));
            //image5.Pixbuf = new Gdk.Pixbuf("/opt/osiris/bin/OSIRISLogo.jpg");   // en Linux
            //image5.Pixbuf.ScaleSimple(128, 128, Gdk.InterpType.Bilinear);
            //Gdk.CairoHelper.SetSourcePixbuf(cr,image5.Pixbuf,1,-30);
            //Gdk.CairoHelper.SetSourcePixbuf(cr,image5.Pixbuf.ScaleSimple(145, 50, Gdk.InterpType.Bilinear),1,1);
            //Gdk.CairoHelper.SetSourcePixbuf(cr,image5.Pixbuf.ScaleSimple(180, 64, Gdk.InterpType.Hyper),1,1);
            //cr.Fill();
            //cr.Paint();
            //cr.Restore();

            Pango.FontDescription desc = Pango.FontDescription.FromString("Sans");
            //cr.Rotate(90);  //Imprimir Orizontalmente rota la hoja cambian las posiciones de las lineas y columna
            fontSize  = 8.0;
            desc.Size = (int)(fontSize * pangoScale);                                       layout.FontDescription = desc;
            layout.FontDescription.Weight = Weight.Bold;                        // Letra negrita
            cr.MoveTo(05 * escala_en_linux_windows, 05 * escala_en_linux_windows);                       layout.SetText(classpublic.nombre_empresa);                     Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(05 * escala_en_linux_windows, 15 * escala_en_linux_windows);                       layout.SetText(classpublic.direccion_empresa);          Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(05 * escala_en_linux_windows, 25 * escala_en_linux_windows);                       layout.SetText(classpublic.telefonofax_empresa);        Pango.CairoHelper.ShowLayout(cr, layout);
            fontSize  = 6.0;
            desc.Size = (int)(fontSize * pangoScale);                                       layout.FontDescription = desc;
            cr.MoveTo(479 * escala_en_linux_windows, 05 * escala_en_linux_windows);                      layout.SetText("Fech.Rpt:" + (string)DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));              Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(479 * escala_en_linux_windows, 15 * escala_en_linux_windows);                      layout.SetText("N° Page :" + numpage.ToString().Trim());          Pango.CairoHelper.ShowLayout(cr, layout);

            cr.MoveTo(05 * escala_en_linux_windows, 35 * escala_en_linux_windows);                       layout.SetText("Sistema Hospitalario OSIRIS");          Pango.CairoHelper.ShowLayout(cr, layout);
            // Cambiando el tamaño de la fuente
            fontSize  = 10.0;
            desc.Size = (int)(fontSize * pangoScale);                                       layout.FontDescription = desc;
            layout.FontDescription.Weight = Weight.Bold;                        // Letra negrita
            cr.MoveTo(225 * escala_en_linux_windows, 35 * escala_en_linux_windows);                     layout.SetText("PEDIDOS DE SUB-ALMACENES");                             Pango.CairoHelper.ShowLayout(cr, layout);

            fontSize  = 8.0;
            desc.Size = (int)(fontSize * pangoScale);                                       layout.FontDescription = desc;
            layout.FontDescription.Weight = Weight.Normal;                      // Letra normal
            cr.MoveTo(05 * escala_en_linux_windows, 55 * escala_en_linux_windows);              layout.SetText("Area quien Solicito: " + descripcion_almacen);    Pango.CairoHelper.ShowLayout(cr, layout);
            //cr.MoveTo(250*escala_en_linux_windows,55*escala_en_linux_windows);		layout.SetText("N° de Solicitud: "+numerosolicitud);			Pango.CairoHelper.ShowLayout (cr, layout);
            cr.MoveTo(440 * escala_en_linux_windows, 55 * escala_en_linux_windows);              layout.SetText("Fecha Envio: " + fechaenvio);                                             Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(05 * escala_en_linux_windows, 65 * escala_en_linux_windows);               layout.SetText("Tipo de Solicitud: " + tiposolicitud);                    Pango.CairoHelper.ShowLayout(cr, layout);

            layout.FontDescription.Weight = Weight.Bold;                        // Letra negrita
            cr.MoveTo(250 * escala_en_linux_windows, 55 * escala_en_linux_windows);              layout.SetText("N° de Solicitud: " + numerosolicitud);                    Pango.CairoHelper.ShowLayout(cr, layout);

            cr.MoveTo(05 * escala_en_linux_windows, 75 * escala_en_linux_windows);               layout.SetText("N° Atencion: " + numeroatencion);                                 Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(120 * escala_en_linux_windows, 75 * escala_en_linux_windows);              layout.SetText("N° Expe.: " + pidpaciente);                                               Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(220 * escala_en_linux_windows, 75 * escala_en_linux_windows);              layout.SetText("Nombre Paciente: " + nombrepaciente);                             Pango.CairoHelper.ShowLayout(cr, layout);
            layout.FontDescription.Weight = Weight.Normal;                      // Letra normal
            cr.MoveTo(05 * escala_en_linux_windows, 85 * escala_en_linux_windows);               layout.SetText("Procedimiento: " + procedimientoqx);                              Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(300 * escala_en_linux_windows, 85 * escala_en_linux_windows);              layout.SetText("Diagnostico: " + diagnosticoqx);                          Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(05 * escala_en_linux_windows, 95 * escala_en_linux_windows);               layout.SetText("Observaciones: " + obs_solicitud);                                                        Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(05 * escala_en_linux_windows, 105 * escala_en_linux_windows);              layout.SetText("Usuario: " + idusuario);                                                  Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(200 * escala_en_linux_windows, 105 * escala_en_linux_windows);             layout.SetText("Nom. Solicitante: " + nombreusr);                                 Pango.CairoHelper.ShowLayout(cr, layout);

            fontSize  = 7.0;
            desc.Size = (int)(fontSize * pangoScale);                                       layout.FontDescription = desc;
            layout.FontDescription.Weight = Weight.Normal;                      // Letra normal
            // Creando el Cuadro de Titulos para colocar el nombre del usuario
            cr.Rectangle(05 * escala_en_linux_windows, 115 * escala_en_linux_windows, 565 * escala_en_linux_windows, 15 * escala_en_linux_windows);
            cr.FillExtents();              //. FillPreserve();
            cr.SetSourceRGB(0, 0, 0);
            cr.LineWidth = 0.5;
            cr.Stroke();
            layout.FontDescription.Weight = Weight.Bold;                        // Letra normal
            cr.MoveTo(20 * escala_en_linux_windows, 118 * escala_en_linux_windows);                     layout.SetText("Cantidad");                             Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(70 * escala_en_linux_windows, 118 * escala_en_linux_windows);                     layout.SetText("Codigo");                               Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(150 * escala_en_linux_windows, 118 * escala_en_linux_windows);                    layout.SetText("Descripción Producto"); Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(400 * escala_en_linux_windows, 118 * escala_en_linux_windows);                    layout.SetText("Cant.Surtida");         Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(460 * escala_en_linux_windows, 118 * escala_en_linux_windows);                    layout.SetText("Fech.Autorizado");              Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(530 * escala_en_linux_windows, 118 * escala_en_linux_windows);                    layout.SetText("Nota");                                 Pango.CairoHelper.ShowLayout(cr, layout);
            layout.FontDescription.Weight = Weight.Normal;                      // Letra normal
        }
示例#35
0
        public void Draw(Cairo.Context cr, Cairo.Rectangle rectangle)
        {
            if (IsSeparator)
            {
                cr.NewPath();
                double x = Math.Ceiling(rectangle.X + rectangle.Width / 2) + 0.5;
                cr.MoveTo(x, rectangle.Y + 0.5 + 2);
                cr.RelLineTo(0, rectangle.Height - 1 - 4);
                cr.ClosePath();
                cr.SetSourceColor(parent.Style.Dark(StateType.Normal).ToCairoColor());
                cr.LineWidth = 1;
                cr.Stroke();
                return;
            }

            if (Active || HoverPosition.X >= 0)
            {
                if (Active)
                {
                    cr.Rectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
                    using (var gr = new LinearGradient(rectangle.X, rectangle.Y, rectangle.X, rectangle.Y + rectangle.Height)) {
                        gr.AddColorStop(0, Tabstrip.ActiveGradientStart);
                        gr.AddColorStop(1, Tabstrip.ActiveGradientEnd);
                        cr.SetSource(gr);
                    }
                    cr.Fill();
                    cr.Rectangle(rectangle.X + 0.5, rectangle.Y + 0.5, rectangle.Width - 1, rectangle.Height - 1);
                    cr.SetSourceRGBA(1, 1, 1, 0.05);
                    cr.LineWidth = 1;
                    cr.Stroke();
                }
                else if (HoverPosition.X >= 0)
                {
                    cr.Rectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
                    using (var gr = new LinearGradient(rectangle.X, rectangle.Y, rectangle.X, rectangle.Y + rectangle.Height)) {
                        var c1 = Tabstrip.ActiveGradientStart;
                        var c2 = Tabstrip.ActiveGradientEnd;
                        c1.A = 0.2;
                        c2.A = 0.2;
                        gr.AddColorStop(0, c1);
                        gr.AddColorStop(1, c2);
                        cr.SetSource(gr);
                    }
                    cr.Fill();
                }
            }

            if (Active)
            {
                cr.SetSourceRGB(1, 1, 1);
            }
            else
            {
                cr.SetSourceColor(parent.Style.Text(StateType.Normal).ToCairoColor());
            }

            if (layout.Width != (int)rectangle.Width)
            {
                layout.Width = (int)rectangle.Width;
            }

                        #if MAC
            /* On Cocoa, Pango doesn't render text correctly using layout width/height computation.
             * For instance here we need to balance some kind of internal padding by two pixels which
             * only happens on Mac.
             */
            const int verticalOffset = -2;
                        #else
            const int verticalOffset = 0;
                        #endif

            cr.MoveTo(rectangle.X + (int)(rectangle.Width / 2), (rectangle.Height - h) / 2 + verticalOffset);
            Pango.CairoHelper.ShowLayout(cr, layout);
        }
示例#36
0
        /**********/
        //hdb drawing
        public void HdbDrawing(Cairo.Context g, Double [] partitions_hdbP, String [] partitions_hdb)
        {
            g.LineWidth = 3;
            //total space
            PointD p1, s1, p2, s2, p3, s3, p4, s4;

            p1 = new PointD(16, 28);
            s1 = new PointD(18, 26);
            p2 = new PointD(20 + partitions_hdbP[0] + 2, 26);
            s2 = new PointD(20 + partitions_hdbP[0] + 4, 28);
            p3 = new PointD(20 + partitions_hdbP[0] + 4, 78);
            s3 = new PointD(20 + partitions_hdbP[0] + 2, 80);
            p4 = new PointD(18, 80);
            s4 = new PointD(16, 78);

            g.Color = new Color(0, 0, 0, 1);
            g.MoveTo(p1); g.LineTo(s1); g.LineTo(p2); g.LineTo(s2); g.LineTo(p3); g.LineTo(s3); g.LineTo(p4); g.LineTo(s4);
            g.ClosePath(); g.Stroke();
            g.Color = new Color(1, 1, 1, 1);
            g.MoveTo(p1); g.LineTo(s1); g.LineTo(p2); g.LineTo(s2); g.LineTo(p3); g.LineTo(s3); g.LineTo(p4); g.LineTo(s4);
            g.ClosePath(); g.Fill();

            if (partitions_hdb[1] != null)
            {
                //hdb1 space
                PointD p11, p21, p31, p41;
                p11 = new PointD(20, 30);
                p21 = new PointD(20 + (partitions_hdbP[1]), 30);
                p31 = new PointD(20 + (partitions_hdbP[1]), 76);
                p41 = new PointD(20, 76);

                g.Color = new Color(0.93, 0.83, 0, 1);
                g.MoveTo(p11); g.LineTo(p21); g.LineTo(p31); g.LineTo(p41); g.LineTo(p11);
                g.ClosePath(); g.Fill();
            }

            if (partitions_hdb[2] != null)
            {
                //hdb2 space
                PointD p12, p22, p32, p42;
                p12 = new PointD(20 + (partitions_hdbP[1]), 30);
                p22 = new PointD(20 + (partitions_hdbP[1]) + (partitions_hdbP[2]), 30);
                p32 = new PointD(20 + (partitions_hdbP[1]) + (partitions_hdbP[2]), 76);
                p42 = new PointD(20 + (partitions_hdbP[1]), 76);

                g.Color = new Color(0.45, 0.82, 0.09, 1);
                g.MoveTo(p12); g.LineTo(p22); g.LineTo(p32); g.LineTo(p42);
                g.ClosePath(); g.Fill();
            }

            if (partitions_hdb[3] != null)
            {
                //hdb3 space
                PointD p13, p23, p33, p43;
                p13 = new PointD(20 + (partitions_hdbP[1]) + (partitions_hdbP[2]), 30);
                p23 = new PointD(20 + (partitions_hdbP[1]) + (partitions_hdbP[2]) + (partitions_hdbP[3]), 30);
                p33 = new PointD(20 + (partitions_hdbP[1]) + (partitions_hdbP[2]) + (partitions_hdbP[3]), 76);
                p43 = new PointD(20 + (partitions_hdbP[1]) + (partitions_hdbP[2]), 76);

                g.Color = new Color(0.8, 0, 0, 1);
                g.MoveTo(p13); g.LineTo(p23); g.LineTo(p33); g.LineTo(p43);
                g.ClosePath(); g.Fill();
            }

            if (partitions_hdb[4] != null)
            {
                //hdb4 space
                PointD p14, p24, p34, p44;
                p14 = new PointD(20 + (partitions_hdbP[1]) + (partitions_hdbP[2]) + (partitions_hdbP[3]), 30);
                p24 = new PointD(20 + (partitions_hdbP[1]) + (partitions_hdbP[2]) + (partitions_hdbP[3]) +
                                 (partitions_hdbP[4]), 30);
                p34 = new PointD(20 + (partitions_hdbP[1]) + (partitions_hdbP[2]) + (partitions_hdbP[3]) +
                                 (partitions_hdbP[4]), 76);
                p44 = new PointD(20 + (partitions_hdbP[1]) + (partitions_hdbP[2]) + (partitions_hdbP[3]), 76);

                g.Color = new Color(0.2, 0.4, 0.64, 1);
                g.MoveTo(p14); g.LineTo(p24); g.LineTo(p34); g.LineTo(p44);
                g.ClosePath(); g.Fill();
            }

            if (partitions_hdb[5] != null)
            {
                //hdb5 space
                PointD p14, p24, p34, p44;
                p14 = new PointD(20 + (partitions_hdbP[1]) + (partitions_hdbP[2]) + (partitions_hdbP[3]) +
                                 (partitions_hdbP[4]), 30);
                p24 = new PointD(20 + (partitions_hdbP[1]) + (partitions_hdbP[2]) + (partitions_hdbP[3]) +
                                 (partitions_hdbP[4]) + (partitions_hdbP[5]), 30);
                p34 = new PointD(20 + (partitions_hdbP[1]) + (partitions_hdbP[2]) + (partitions_hdbP[3]) +
                                 (partitions_hdbP[4]) + (partitions_hdbP[5]), 76);
                p44 = new PointD(20 + (partitions_hdbP[1]) + (partitions_hdbP[2]) + (partitions_hdbP[3]) +
                                 (partitions_hdbP[4]), 76);

                g.Color = new Color(0.75, 0.5, 0.07, 1);
                g.MoveTo(p14); g.LineTo(p24); g.LineTo(p34); g.LineTo(p44);
                g.ClosePath(); g.Fill();
            }

            if (partitions_hdb[6] != null)
            {
                //hdb6 space
                PointD p14, p24, p34, p44;
                p14 = new PointD(20 + (partitions_hdbP[1]) + (partitions_hdbP[2]) + (partitions_hdbP[3]) +
                                 (partitions_hdbP[4]) + (partitions_hdbP[5]), 30);
                p24 = new PointD(20 + (partitions_hdbP[1]) + (partitions_hdbP[2]) + (partitions_hdbP[3]) +
                                 (partitions_hdbP[4]) + (partitions_hdbP[5]) + (partitions_hdbP[6]), 30);
                p34 = new PointD(20 + (partitions_hdbP[1]) + (partitions_hdbP[2]) + (partitions_hdbP[3]) +
                                 (partitions_hdbP[4]) + (partitions_hdbP[5]) + (partitions_hdbP[6]), 76);
                p44 = new PointD(20 + (partitions_hdbP[1]) + (partitions_hdbP[2]) + (partitions_hdbP[3]) +
                                 (partitions_hdbP[4]) + (partitions_hdbP[5]), 76);

                g.Color = new Color(0.45, 0.31, 0.48, 1);
                g.MoveTo(p14); g.LineTo(p24); g.LineTo(p34); g.LineTo(p44);
                g.ClosePath(); g.Fill();
            }

            if (partitions_hdb[7] != null)
            {
                //hdb7 space
                PointD p14, p24, p34, p44;
                p14 = new PointD(20 + (partitions_hdbP[1]) + (partitions_hdbP[2]) + (partitions_hdbP[3]) +
                                 (partitions_hdbP[4]) + (partitions_hdbP[5]) + (partitions_hdbP[6]), 30);
                p24 = new PointD(20 + (partitions_hdbP[1]) + (partitions_hdbP[2]) + (partitions_hdbP[3]) +
                                 (partitions_hdbP[4]) + (partitions_hdbP[5]) + (partitions_hdbP[6]) + (partitions_hdbP[7]), 30);
                p34 = new PointD(20 + (partitions_hdbP[1]) + (partitions_hdbP[2]) + (partitions_hdbP[3]) +
                                 (partitions_hdbP[4]) + (partitions_hdbP[5]) + (partitions_hdbP[6]) + (partitions_hdbP[7]), 76);
                p44 = new PointD(20 + (partitions_hdbP[1]) + (partitions_hdbP[2]) + (partitions_hdbP[3]) +
                                 (partitions_hdbP[4]) + (partitions_hdbP[5]) + (partitions_hdbP[6]), 76);

                g.Color = new Color(0.96, 0.47, 0, 1);
                g.MoveTo(p14); g.LineTo(p24); g.LineTo(p34); g.LineTo(p44);
                g.ClosePath(); g.Fill();
            }

            if (partitions_hdb[8] != null)
            {
                //hdb8 space
                PointD p14, p24, p34, p44;
                p14 = new PointD(20 + (partitions_hdbP[1]) + (partitions_hdbP[2]) + (partitions_hdbP[3]) +
                                 (partitions_hdbP[4]) + (partitions_hdbP[5]) + (partitions_hdbP[6]) + (partitions_hdbP[7]), 30);
                p24 = new PointD(20 + (partitions_hdbP[1]) + (partitions_hdbP[2]) + (partitions_hdbP[3]) +
                                 (partitions_hdbP[4]) + (partitions_hdbP[5]) + (partitions_hdbP[6]) + (partitions_hdbP[7]) + (partitions_hdbP[8]), 30);
                p34 = new PointD(20 + (partitions_hdbP[1]) + (partitions_hdbP[2]) + (partitions_hdbP[3]) +
                                 (partitions_hdbP[4]) + (partitions_hdbP[5]) + (partitions_hdbP[6]) + (partitions_hdbP[7]) + (partitions_hdbP[8]), 76);
                p44 = new PointD(20 + (partitions_hdbP[1]) + (partitions_hdbP[2]) + (partitions_hdbP[3]) +
                                 (partitions_hdbP[4]) + (partitions_hdbP[5]) + (partitions_hdbP[6]) + (partitions_hdbP[7]), 76);

                g.Color = new Color(0.33, 0.34, 0.33, 1);
                g.MoveTo(p14); g.LineTo(p24); g.LineTo(p34); g.LineTo(p44);
                g.ClosePath(); g.Fill();
            }

            g.SetFontSize(12);
            g.MoveTo(new PointD((partitions_hdbP[0] - 80) / 2, 15));
            g.Color = new Color(0, 0, 0, 1);
            g.ShowText("Total space: " + partitions_hdb[0]);

            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }
示例#37
0
        protected override void DrawContents(Gdk.Drawable d)
        {
            Gdk.GC        gc = new Gdk.GC(d);
            Cairo.Context g  = Gdk.CairoHelper.Create(d);

            g.SelectFontFace("Lucida Console", FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);



            TextExtents te;

            string lvl, hp, hpm, mp, mpm, exp, next, llvl;


            #region Top Row

            d.DrawPixbuf(gc, Graphics.GetProfile(Selected.Name), 0, 0,
                         X + xpic, Y + ypic,
                         Graphics.PROFILE_WIDTH, Graphics.PROFILE_HEIGHT,
                         Gdk.RgbDither.None, 0, 0);

            g.Color = new Color(.3, .8, .8);
            g.MoveTo(X + x3, Y + ya);
            g.ShowText("LV");
            g.MoveTo(X + x3, Y + yb);
            g.ShowText("HP");
            g.MoveTo(X + x3, Y + yc);
            g.ShowText("MP");
            g.Color = new Color(1, 1, 1);

            Graphics.ShadowedText(g, Selected.Name, X + x3, Y + y);

            lvl  = Selected.Level.ToString();
            hp   = Selected.HP.ToString() + "/";
            hpm  = Selected.MaxHP.ToString();
            mp   = Selected.MP.ToString() + "/";
            mpm  = Selected.MaxMP.ToString();
            exp  = Selected.Exp.ToString();
            next = Selected.ToNextLevel.ToString();
            llvl = Selected.LimitLevel.ToString();

            te = g.TextExtents(lvl);
            Graphics.ShadowedText(g, lvl, X + x4 - te.Width, Y + ya);

            te = g.TextExtents(hp);
            Graphics.ShadowedText(g, hp, X + x5 - te.Width, Y + yb);

            te = g.TextExtents(hpm);
            Graphics.ShadowedText(g, hpm, X + x6 - te.Width, Y + yb);

            te = g.TextExtents(mp);
            Graphics.ShadowedText(g, mp, X + x5 - te.Width, Y + yc);

            te = g.TextExtents(mpm);
            Graphics.ShadowedText(g, mpm, X + x6 - te.Width, Y + yc);

            Graphics.ShadowedText(g, "Exp:", X + x8, Y + ya);
            Graphics.ShadowedText(g, "Next lvl:", X + x8, Y + yb);
            Graphics.ShadowedText(g, "Limit lvl:", X + x8, Y + yc);

            te = g.TextExtents(exp);
            Graphics.ShadowedText(g, exp, X + x12 - te.Width, Y + ya);
            te = g.TextExtents(next);
            Graphics.ShadowedText(g, next, X + x12 - te.Width, Y + yb);
            te = g.TextExtents(llvl);
            Graphics.ShadowedText(g, llvl, X + x11 - te.Width, Y + yc);

            #endregion Top


            #region Left

            string str, vit, dex, mag, spi, lck;
            string atk, atkp, def, defp, mat, mdf, mdfp;

            str = Selected.Strength.ToString();
            vit = Selected.Vitality.ToString();
            dex = Selected.Dexterity.ToString();
            mag = Selected.Magic.ToString();
            spi = Selected.Spirit.ToString();
            lck = Selected.Luck.ToString();

            atk  = Ally.Attack(Selected).ToString();
            atkp = Ally.AttackPercent(Selected).ToString();
            def  = Ally.Defense(Selected).ToString();
            defp = Ally.DefensePercent(Selected).ToString();
            mat  = Ally.MagicAttack(Selected).ToString();
            mdf  = Ally.MagicDefense(Selected).ToString();
            mdfp = Ally.MagicDefensePercent(Selected).ToString();

            Cairo.Color greenish = new Color(.3, .8, .8);

            Graphics.ShadowedText(g, greenish, "Strength", X + x0, Y + yq + (line * 0));
            Graphics.ShadowedText(g, greenish, "Vitality", X + x0, Y + yq + (line * 1));
            Graphics.ShadowedText(g, greenish, "Dexterity", X + x0, Y + yq + (line * 2));
            Graphics.ShadowedText(g, greenish, "Magic", X + x0, Y + yq + (line * 3));
            Graphics.ShadowedText(g, greenish, "Spirit", X + x0, Y + yq + (line * 4));
            Graphics.ShadowedText(g, greenish, "Luck", X + x0, Y + yq + (line * 5));

            Graphics.ShadowedText(g, greenish, "Attack", X + x0, Y + yr + (line * 0));
            Graphics.ShadowedText(g, greenish, "Attack %", X + x0, Y + yr + (line * 1));
            Graphics.ShadowedText(g, greenish, "Defense", X + x0, Y + yr + (line * 2));
            Graphics.ShadowedText(g, greenish, "Defense %", X + x0, Y + yr + (line * 3));
            Graphics.ShadowedText(g, greenish, "Magic", X + x0, Y + yr + (line * 4));
            Graphics.ShadowedText(g, greenish, "Magic def", X + x0, Y + yr + (line * 5));
            Graphics.ShadowedText(g, greenish, "Magic def %", X + x0, Y + yr + (line * 6));

            te = g.TextExtents(str);
            Graphics.ShadowedText(g, str, X + x1 - te.Width, Y + yq + (line * 0));
            te = g.TextExtents(vit);
            Graphics.ShadowedText(g, vit, X + x1 - te.Width, Y + yq + (line * 1));
            te = g.TextExtents(dex);
            Graphics.ShadowedText(g, dex, X + x1 - te.Width, Y + yq + (line * 2));
            te = g.TextExtents(mag);
            Graphics.ShadowedText(g, mag, X + x1 - te.Width, Y + yq + (line * 3));
            te = g.TextExtents(spi);
            Graphics.ShadowedText(g, spi, X + x1 - te.Width, Y + yq + (line * 4));
            te = g.TextExtents(lck);
            Graphics.ShadowedText(g, lck, X + x1 - te.Width, Y + yq + (line * 5));

            te = g.TextExtents(atk);
            Graphics.ShadowedText(g, atk, X + x1 - te.Width, Y + yr + (line * 0));
            te = g.TextExtents(atkp);
            Graphics.ShadowedText(g, atkp, X + x1 - te.Width, Y + yr + (line * 1));
            te = g.TextExtents(def);
            Graphics.ShadowedText(g, def, X + x1 - te.Width, Y + yr + (line * 2));
            te = g.TextExtents(defp);
            Graphics.ShadowedText(g, defp, X + x1 - te.Width, Y + yr + (line * 3));
            te = g.TextExtents(mat);
            Graphics.ShadowedText(g, mat, X + x1 - te.Width, Y + yr + (line * 4));
            te = g.TextExtents(mdf);
            Graphics.ShadowedText(g, mdf, X + x1 - te.Width, Y + yr + (line * 5));
            te = g.TextExtents(mdfp);
            Graphics.ShadowedText(g, mdfp, X + x1 - te.Width, Y + yr + (line * 6));

            #endregion Left


            #region Right


            g.Color = new Color(.1, .1, .2);
            g.Rectangle(x9, yi, 8 * xs, yj - yi);
            g.Fill();
            g.Rectangle(x9, yk, 8 * xs, yl - yk);
            g.Fill();

            Cairo.Color gray1 = new Color(.2, .2, .2);
            Cairo.Color gray2 = new Color(.7, .7, .8);

            int links, slots;

            slots = Selected.Weapon.Slots.Length;
            links = Selected.Weapon.Links;


            for (int j = 0; j < links; j++)
            {
                Graphics.RenderLine(g, gray2, 3,
                                    X + x9 + (xs / 2) + (j * 2 * xs), Y + yi - ys - zs,
                                    X + x9 + (xs / 2) + ((j * 2 + 1) * xs), Y + yi - ys - zs);
                Graphics.RenderLine(g, gray2, 3,
                                    X + x9 + (xs / 2) + (j * 2 * xs), Y + yi - ys,
                                    X + x9 + (xs / 2) + ((j * 2 + 1) * xs), Y + yi - ys);
                Graphics.RenderLine(g, gray2, 3,
                                    X + x9 + (xs / 2) + (j * 2 * xs), Y + yi - ys + zs,
                                    X + x9 + (xs / 2) + ((j * 2 + 1) * xs), Y + yi - ys + zs);
            }
            for (int i = 0; i < slots; i++)
            {
                Graphics.RenderCircle(g, gray2, 14,
                                      X + x9 + (i * xs) + (xs / 2), Y + yi - ys);
                if (Selected.Weapon.Slots[i] == null)
                {
                    Graphics.RenderCircle(g, gray1, 10,
                                          X + x9 + (i * xs) + (xs / 2), Y + yi - ys);
                }
                else
                {
                    Graphics.RenderCircle(g, Selected.Weapon.Slots[i].Color, 10,
                                          X + x9 + (i * xs) + (xs / 2), Y + yi - ys);
                }
            }

            slots = Selected.Armor.Slots.Length;
            links = Selected.Armor.Links;

            for (int j = 0; j < links; j++)
            {
                Graphics.RenderLine(g, gray2, 3,
                                    X + x9 + (xs / 2) + (j * 2 * xs), Y + yk - ys - zs,
                                    X + x9 + (xs / 2) + ((j * 2 + 1) * xs), Y + yk - ys - zs);
                Graphics.RenderLine(g, gray2, 3,
                                    X + x9 + (xs / 2) + (j * 2 * xs), Y + yk - ys,
                                    X + x9 + (xs / 2) + ((j * 2 + 1) * xs), Y + yk - ys);
                Graphics.RenderLine(g, gray2, 3,
                                    X + x9 + (xs / 2) + (j * 2 * xs), Y + yk - ys + zs,
                                    X + x9 + (xs / 2) + ((j * 2 + 1) * xs), Y + yk - ys + zs);
            }
            for (int i = 0; i < slots; i++)
            {
                Graphics.RenderCircle(g, gray2, 14,
                                      X + x9 + (i * xs) + (xs / 2), Y + yk - ys);

                if (Selected.Armor.Slots[i] == null)
                {
                    Graphics.RenderCircle(g, gray1, 10,
                                          X + x9 + (i * xs) + (xs / 2), Y + yk - ys);
                }
                else
                {
                    Graphics.RenderCircle(g, Selected.Armor.Slots[i].Color, 10,
                                          X + x9 + (i * xs) + (xs / 2), Y + yk - ys);
                }
            }


            g.Color = new Color(.3, .8, .8);
            g.MoveTo(X + x7, Y + yh);
            g.ShowText("Wpn.");
            g.MoveTo(X + x7, Y + yj);
            g.ShowText("Arm.");
            g.MoveTo(X + x7, Y + yl);
            g.ShowText("Acc.");
            g.Color = new Color(1, 1, 1);

            Graphics.ShadowedText(g, Selected.Weapon.Name, X + x8, Y + yh);
            Graphics.ShadowedText(g, Selected.Armor.Name, X + x8, Y + yj);
            Graphics.ShadowedText(g, Selected.Accessory.Name, X + x8, Y + yl);

            #endregion Right


            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }
示例#38
0
        const int yc = yb + 25;  // subrow 3


        public static void RenderCharacterStatus(Gdk.Drawable d, Cairo.Context g, Character c, int x, int y, bool showFurySadness = true)
        {
            TextExtents te;

            string lvl, hp, hpm, mp, mpm;

            g.SelectFontFace(Text.MONOSPACE_FONT, FontSlant.Normal, FontWeight.Normal);

            g.Color = Colors.TEXT_TEAL;
            g.MoveTo(x + x3, y + ya);
            g.ShowText("LV");
            g.MoveTo(x + x3, y + yb);
            g.ShowText("HP");
            g.MoveTo(x + x3, y + yc);
            g.ShowText("MP");
            g.Color = Colors.WHITE;

            if (showFurySadness)
            {
                if (c.Fury)
                {
                    Text.ShadowedText(g, Colors.TEXT_MAGENTA, "[Fury]", x + x7, y);
                }
                else if (c.Sadness)
                {
                    Text.ShadowedText(g, Colors.TEXT_MAGENTA, "[Sadness]", x + x7, y);
                }
            }

            Color namec = Colors.WHITE;

            if (c.Death)
            {
                namec = Colors.TEXT_RED;
            }
            else if (c.NearDeath)
            {
                namec = Colors.TEXT_YELLOW;
            }

            Text.ShadowedText(g, namec, c.Name, x + x3, y);


            lvl = c.Level.ToString();
            te  = g.TextExtents(lvl);
            Text.ShadowedText(g, lvl, x + x4 - te.Width, y + ya);

            hp = c.HP.ToString() + "/";
            te = g.TextExtents(hp);
            Text.ShadowedText(g, hp, x + x5 - te.Width, y + yb);

            hpm = c.MaxHP.ToString();
            te  = g.TextExtents(hpm);
            Text.ShadowedText(g, hpm, x + x6 - te.Width, y + yb);

            mp = c.MP.ToString() + "/";
            te = g.TextExtents(mp);
            Text.ShadowedText(g, mp, x + x5 - te.Width, y + yc);

            mpm = c.MaxMP.ToString();
            te  = g.TextExtents(mpm);
            Text.ShadowedText(g, mpm, x + x6 - te.Width, y + yc);
        }
示例#39
0
        void ejecutar_consulta_reporte(PrintContext context)
        {
            string fechas_citas;

            Cairo.Context cr     = context.CairoContext;
            Pango.Layout  layout = context.CreatePangoLayout();
            imprime_encabezado(cr, layout);
            Pango.FontDescription desc = Pango.FontDescription.FromString("Sans");
            // cr.Rotate(90)  Imprimir Orizontalmente rota la hoja cambian las posiciones de las lineas y columna
            fontSize  = 8.0;                 layout = null;                  layout = context.CreatePangoLayout();
            desc.Size = (int)(fontSize * pangoScale);               layout.FontDescription = desc;

            TreeIter iter;

            if (treeViewEngineListaCitas.GetIterFirst(out iter))
            {
                contador_numerocitas += 1;
                fechas_citas          = (string)treeview_lista_agenda.Model.GetValue(iter, 0);
                //ContextoImp.Show();
                layout.FontDescription.Weight = Weight.Bold;                            // Letra negrita
                cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                   layout.SetText("(" + (string)treeview_lista_agenda.Model.GetValue(iter, 0) + ")");                 Pango.CairoHelper.ShowLayout(cr, layout);
                comienzo_linea += separacion_linea;
                cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                   layout.SetText((string)treeview_lista_agenda.Model.GetValue(iter, 1));                 Pango.CairoHelper.ShowLayout(cr, layout);
                layout.FontDescription.Weight = Weight.Normal;                          // Letra normal
                cr.MoveTo(34 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                   layout.SetText((string)treeview_lista_agenda.Model.GetValue(iter, 2));                 Pango.CairoHelper.ShowLayout(cr, layout);
                cr.MoveTo(74 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                   layout.SetText((string)treeview_lista_agenda.Model.GetValue(iter, 3));                 Pango.CairoHelper.ShowLayout(cr, layout);
                cr.MoveTo(114 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                  layout.SetText((string)treeview_lista_agenda.Model.GetValue(iter, 4));                 Pango.CairoHelper.ShowLayout(cr, layout);
                //cr.MoveTo(114*escala_en_linux_windows,comienzo_linea*escala_en_linux_windows);			layout.SetText((string) treeview_lista_agenda.Model.GetValue (iter,5));			Pango.CairoHelper.ShowLayout (cr, layout);
                //cr.MoveTo(300*escala_en_linux_windows,comienzo_linea*escala_en_linux_windows);			layout.SetText((string) treeview_lista_agenda.Model.GetValue (iter,6));			Pango.CairoHelper.ShowLayout (cr, layout);
                //cr.MoveTo(114*escala_en_linux_windows,comienzo_linea*escala_en_linux_windows);			layout.SetText((string) treeview_lista_agenda.Model.GetValue (iter,7));			Pango.CairoHelper.ShowLayout (cr, layout);
                cr.MoveTo(300 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                  layout.SetText((string)treeview_lista_agenda.Model.GetValue(iter, 8));                 Pango.CairoHelper.ShowLayout(cr, layout);
                cr.MoveTo(400 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                  layout.SetText((string)treeview_lista_agenda.Model.GetValue(iter, 9));                 Pango.CairoHelper.ShowLayout(cr, layout);
                cr.MoveTo(480 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                  layout.SetText((string)treeview_lista_agenda.Model.GetValue(iter, 12));                        Pango.CairoHelper.ShowLayout(cr, layout);
                cr.MoveTo(570 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                  layout.SetText((string)treeview_lista_agenda.Model.GetValue(iter, 11));                        Pango.CairoHelper.ShowLayout(cr, layout);
                comienzo_linea += separacion_linea;
                cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                   layout.SetText("Motivo Consulta :" + (string)treeview_lista_agenda.Model.GetValue(iter, 13));                    Pango.CairoHelper.ShowLayout(cr, layout);
                cr.MoveTo(253 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                  layout.SetText("Observaciones :" + (string)treeview_lista_agenda.Model.GetValue(iter, 14));                      Pango.CairoHelper.ShowLayout(cr, layout);
                cr.MoveTo(501 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                  layout.SetText("Referido por:" + (string)treeview_lista_agenda.Model.GetValue(iter, 15));                        Pango.CairoHelper.ShowLayout(cr, layout);
                comienzo_linea += separacion_linea;
                cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                   layout.SetText("Telefonos :" + (string)treeview_lista_agenda.Model.GetValue(iter, 6));                   Pango.CairoHelper.ShowLayout(cr, layout);
                salto_de_pagina(cr, layout);
                comienzo_linea += separacion_linea;
                comienzo_linea += separacion_linea;
                while (treeViewEngineListaCitas.IterNext(ref iter))
                {
                    contador_numerocitas         += 1;
                    layout.FontDescription.Weight = Weight.Bold;                                // Letra negrita
                    if (fechas_citas != (string)treeview_lista_agenda.Model.GetValue(iter, 0))
                    {
                        // Creando el Cuadro de Titulos
                        cr.Rectangle(05 * escala_en_linux_windows, comienzo_linea - 5 * escala_en_linux_windows, 750 * escala_en_linux_windows, 1 * escala_en_linux_windows);
                        cr.FillPreserve();                          //. FillPreserve(); FillExtents()
                        cr.SetSourceRGB(0, 0, 0);
                        cr.LineWidth = 0.5;
                        cr.Stroke();
                        cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                   layout.SetText("(" + (string)treeview_lista_agenda.Model.GetValue(iter, 0) + ")");                 Pango.CairoHelper.ShowLayout(cr, layout);
                        comienzo_linea += separacion_linea;
                        salto_de_pagina(cr, layout);
                        fechas_citas = (string)treeview_lista_agenda.Model.GetValue(iter, 0);
                    }

                    cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                   layout.SetText((string)treeview_lista_agenda.Model.GetValue(iter, 1));                 Pango.CairoHelper.ShowLayout(cr, layout);
                    layout.FontDescription.Weight = Weight.Normal;                              // Letra normal
                    cr.MoveTo(34 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                   layout.SetText((string)treeview_lista_agenda.Model.GetValue(iter, 2));                 Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(74 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                   layout.SetText((string)treeview_lista_agenda.Model.GetValue(iter, 3));                 Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(114 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                  layout.SetText((string)treeview_lista_agenda.Model.GetValue(iter, 4));                 Pango.CairoHelper.ShowLayout(cr, layout);
                    //cr.MoveTo(114*escala_en_linux_windows,comienzo_linea*escala_en_linux_windows);			layout.SetText((string) treeview_lista_agenda.Model.GetValue (iter,5));			Pango.CairoHelper.ShowLayout (cr, layout);
                    //cr.MoveTo(300*escala_en_linux_windows,comienzo_linea*escala_en_linux_windows);			layout.SetText((string) treeview_lista_agenda.Model.GetValue (iter,6));			Pango.CairoHelper.ShowLayout (cr, layout);
                    //cr.MoveTo(114*escala_en_linux_windows,comienzo_linea*escala_en_linux_windows);			layout.SetText((string) treeview_lista_agenda.Model.GetValue (iter,7));			Pango.CairoHelper.ShowLayout (cr, layout);
                    cr.MoveTo(300 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                  layout.SetText((string)treeview_lista_agenda.Model.GetValue(iter, 8));                 Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(400 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                  layout.SetText((string)treeview_lista_agenda.Model.GetValue(iter, 9));                 Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(480 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                  layout.SetText((string)treeview_lista_agenda.Model.GetValue(iter, 12));                        Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(570 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                  layout.SetText((string)treeview_lista_agenda.Model.GetValue(iter, 11));                        Pango.CairoHelper.ShowLayout(cr, layout);
                    comienzo_linea += separacion_linea;
                    cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                   layout.SetText("Mot.Consulta:" + (string)treeview_lista_agenda.Model.GetValue(iter, 13));                        Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(253 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                  layout.SetText("Obse.:" + (string)treeview_lista_agenda.Model.GetValue(iter, 14));                       Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(501 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                  layout.SetText("Ref. por:" + (string)treeview_lista_agenda.Model.GetValue(iter, 15));                    Pango.CairoHelper.ShowLayout(cr, layout);
                    comienzo_linea += separacion_linea;
                    cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                   layout.SetText("Telefonos :" + (string)treeview_lista_agenda.Model.GetValue(iter, 6));                   Pango.CairoHelper.ShowLayout(cr, layout);
                    salto_de_pagina(cr, layout);
                    comienzo_linea += separacion_linea;
                    salto_de_pagina(cr, layout);
                    comienzo_linea += separacion_linea;
                    salto_de_pagina(cr, layout);
                }
                cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                   layout.SetText("Nro. de CITAS " + contador_numerocitas.ToString().Trim());                        Pango.CairoHelper.ShowLayout(cr, layout);
            }
            //Console.WriteLine(contador_numerocitas.ToString());
            //Console.WriteLine(comienzo_linea.ToString());
        }
示例#40
0
        protected override void onDraw(Cairo.Context gr)
        {
            base.onDraw(gr);

            Rectangle cb = new Rectangle(0, 0, designWidth, designHeight);             // ClientRectangle;

            gr.Save();

            double z = zoom / 100.0;

            gr.Scale(z, z);

            if (drawGrid)
            {
                double gridLineWidth = 0.2 / z;
                double glhw          = gridLineWidth / 2.0;
                int    nbLines       = cb.Width / gridSpacing;
                double d             = cb.Left + gridSpacing;
                for (int i = 0; i < nbLines; i++)
                {
                    gr.MoveTo(d - glhw, cb.Y);
                    gr.LineTo(d - glhw, cb.Bottom);
                    d += gridSpacing;
                }
                nbLines = cb.Height / gridSpacing;
                d       = cb.Top + gridSpacing;
                for (int i = 0; i < nbLines; i++)
                {
                    gr.MoveTo(cb.X, d - glhw);
                    gr.LineTo(cb.Right, d - glhw);
                    d += gridSpacing;
                }
                gr.LineWidth = gridLineWidth;
                Foreground.SetAsSource(gr, cb);
                gr.Stroke();
            }

            lock (imlVE.RenderMutex) {
                using (Cairo.Surface surf = new Cairo.ImageSurface(imlVE.bmp, Cairo.Format.Argb32,
                                                                   imlVE.ClientRectangle.Width, imlVE.ClientRectangle.Height, imlVE.ClientRectangle.Width * 4)) {
                    gr.SetSourceSurface(surf, cb.Left, cb.Top);
                    gr.Paint();
                }
                imlVE.IsDirty = false;
            }
            if (Error == null)
            {
                gr.SetSourceColor(Color.Black);
                gr.Rectangle(cb, 1.0 / z);
            }
            else
            {
                gr.SetSourceColor(Color.LavenderBlush);
                gr.Rectangle(cb, 2.0 / z);
                string[] lerrs = Error.ToString().Split('\n');
                Point    p     = cb.Center;
                p.Y -= lerrs.Length * 20;
                foreach (string le in lerrs)
                {
                    drawCenteredTextLine(gr, p, le);
                    p.Y += 20;
                }
            }
            gr.Stroke();

            Rectangle hr;

            if (SelectedItem?.Parent != null)
            {
                gr.SelectFontFace(Font.Name, Font.Slant, Font.Wheight);
                gr.SetFontSize(Font.Size);
                gr.FontOptions = Interface.FontRenderingOptions;
                gr.Antialias   = Interface.Antialias;

                GraphicObject g = SelectedItem;
                hr = g.ScreenCoordinates(g.getSlot());

//				Rectangle rIcons = new Rectangle (iconSize);
//				rIcons.Width *= 4;
//				rIcons.Top = hr.Bottom;
//				rIcons.Left = hr.Right - rIcons.Width + iconSize.Width;
                Rectangle rIcoMove = new Rectangle(hr.BottomRight, iconSize);
//				Rectangle rIcoStyle = rIcoMove;
//				rIcoStyle.Left += iconSize.Width + 4;

                using (Surface mask = new ImageSurface(Format.Argb32, cb.Width, cb.Height)) {
                    using (Context ctx = new Context(mask)) {
                        ctx.Save();
                        ctx.SetSourceRGBA(1.0, 1.0, 1.0, 0.4);
                        ctx.Paint();
                        ctx.Rectangle(hr);
                        ctx.Operator = Operator.Clear;
                        ctx.Fill();
                    }

                    gr.SetSourceSurface(mask, 0, 0);
                    gr.Paint();

                    using (Surface ol = new ImageSurface(Format.Argb32, cb.Width, cb.Height)) {
                        using (Context ctx = new Context(ol)) {
                            ctx.SetSourceColor(Color.Black);
                            drawDesignOverlay(ctx, g, cb, hr, 0.4 / z, 6.5);
                        }

                        gr.SetSourceSurface(ol, 0, 0);
                        gr.Paint();
                    }

                    drawIcon(gr, icoMove, rIcoMove);
                    //drawIcon (gr, icoStyle, rIcoStyle);
                }
            }
            if (HoverWidget != null)
            {
                hr = HoverWidget.ScreenCoordinates(HoverWidget.getSlot());
                gr.SetSourceColor(Color.SkyBlue);
                //gr.SetDash (new double[]{ 5.0, 3.0 }, 0.0);
                gr.Rectangle(hr, 0.4 / z);
            }
            gr.Restore();
        }
示例#41
0
        public void Draw(Cairo.Context cr, Cairo.Rectangle rectangle)
        {
            if (IsSeparator)
            {
                cr.NewPath();
                double x = Math.Ceiling(rectangle.X + rectangle.Width / 2) + 0.5;
                cr.MoveTo(x, rectangle.Y + 0.5 + 2);
                cr.RelLineTo(0, rectangle.Height - 1 - 4);
                cr.ClosePath();
                cr.SetSourceColor(Styles.SubTabBarSeparatorColor.ToCairoColor());
                cr.LineWidth = 1;
                cr.Stroke();
                return;
            }

            if (Active || HoverPosition.X >= 0)
            {
                if (Active)
                {
                    cr.Rectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
                    cr.SetSourceColor(Styles.SubTabBarActiveBackgroundColor.ToCairoColor());
                    cr.Fill();
                }
                else if (HoverPosition.X >= 0)
                {
                    cr.Rectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
                    cr.SetSourceColor(Styles.SubTabBarHoverBackgroundColor.ToCairoColor());
                    cr.Fill();
                }
            }

            if (Active)
            {
                cr.SetSourceColor(Styles.SubTabBarActiveTextColor.ToCairoColor());
                layout.FontDescription = FontService.SansFont.CopyModified(Styles.FontScale11, Pango.Weight.Bold);
            }
            else
            {
                cr.SetSourceColor(Styles.SubTabBarTextColor.ToCairoColor());
                layout.FontDescription = FontService.SansFont.CopyModified(Styles.FontScale11);
            }

            // Pango.Layout.Width is in pango units
            layout.Width = (int)rectangle.Width * (int)Pango.Scale.PangoScale;

            cr.MoveTo(rectangle.X, (rectangle.Height - h) / 2 - 1);
            Pango.CairoHelper.ShowLayout(cr, layout);

            if (parent.HasFocus && Focused)
            {
                cr.LineWidth = 1.0;
                cr.SetDash(new double[] { 1, 1 }, 0.5);
                if (Active)
                {
                    cr.SetSourceColor(Styles.SubTabBarActiveTextColor.ToCairoColor());
                }
                else
                {
                    cr.SetSourceColor(Styles.FocusColor.ToCairoColor());
                }
                cr.Rectangle(rectangle.X + 2, rectangle.Y + 2, rectangle.Width - 4, rectangle.Height - 4);
                cr.Stroke();
            }
        }
示例#42
0
        void Draw(Cairo.Context ctx, List <TableRow> rowList, int dividerX, int x, ref int y)
        {
            if (!heightMeasured)
            {
                return;
            }

            Pango.Layout layout       = new Pango.Layout(PangoContext);
            TableRow     lastCategory = null;

            foreach (var r in rowList)
            {
                int w, h;
                layout.SetText(r.Label);
                layout.GetPixelSize(out w, out h);
                int indent = 0;

                if (r.IsCategory)
                {
                    var rh = h + CategoryTopBottomPadding * 2;
                    ctx.Rectangle(0, y, Allocation.Width, rh);
                    ctx.SetSourceColor(Styles.PadCategoryBackgroundColor.ToCairoColor());
                    ctx.Fill();

                    if (lastCategory == null || lastCategory.Expanded || lastCategory.AnimatingExpand)
                    {
                        ctx.MoveTo(0, y + 0.5);
                        ctx.LineTo(Allocation.Width, y + 0.5);
                    }
                    ctx.MoveTo(0, y + rh - 0.5);
                    ctx.LineTo(Allocation.Width, y + rh - 0.5);
                    ctx.SetSourceColor(Styles.PadCategoryBorderColor.ToCairoColor());
                    ctx.Stroke();

                    ctx.MoveTo(x, y + CategoryTopBottomPadding);
                    ctx.SetSourceColor(Styles.PadCategoryLabelColor.ToCairoColor());
                    Pango.CairoHelper.ShowLayout(ctx, layout);

                    var img = r.Expanded ? discloseUp : discloseDown;
                    ctx.DrawImage(this, img, Allocation.Width - img.Width - CategoryTopBottomPadding, y + Math.Round((rh - img.Height) / 2));

                    y           += rh;
                    lastCategory = r;
                }
                else
                {
                    var cell = GetCell(r);
                    r.Enabled = !r.Property.IsReadOnly || cell.EditsReadOnlyObject;
                    var state = r.Enabled ? State : Gtk.StateType.Insensitive;
                    ctx.Save();
                    ctx.Rectangle(0, y, dividerX, h + PropertyTopBottomPadding * 2);
                    ctx.Clip();
                    ctx.MoveTo(x, y + PropertyTopBottomPadding);
                    ctx.SetSourceColor(Style.Text(state).ToCairoColor());
                    Pango.CairoHelper.ShowLayout(ctx, layout);
                    ctx.Restore();

                    if (r != currentEditorRow)
                    {
                        var bounds = GetInactiveEditorBounds(r);

                        cell.Render(GdkWindow, ctx, bounds, state);

                        if (r.IsExpandable)
                        {
                            var img = r.Expanded ? discloseUp : discloseDown;
                            ctx.DrawImage(
                                this, img,
                                Allocation.Width - img.Width - PropertyTopBottomPadding,
                                y + Math.Round((h + PropertyTopBottomPadding * 2 - img.Height) / 2)
                                );
                        }
                    }

                    y     += r.EditorBounds.Height;
                    indent = PropertyIndent;
                }

                if (r.ChildRows != null && r.ChildRows.Count > 0 && (r.Expanded || r.AnimatingExpand))
                {
                    int py = y;

                    ctx.Save();
                    if (r.AnimatingExpand)
                    {
                        ctx.Rectangle(0, y, Allocation.Width, r.AnimationHeight);
                    }
                    else
                    {
                        ctx.Rectangle(0, 0, Allocation.Width, Allocation.Height);
                    }

                    ctx.Clip();
                    Draw(ctx, r.ChildRows, dividerX, x + indent, ref y);
                    ctx.Restore();

                    if (r.AnimatingExpand)
                    {
                        y = py + r.AnimationHeight;
                        // Repaing the background because the cairo clip doesn't work for gdk primitives
                        int dx = (int)((double)Allocation.Width * dividerPosition);
                        ctx.Rectangle(0, y, dx, Allocation.Height - y);
                        ctx.SetSourceColor(Styles.PropertyPadLabelBackgroundColor.ToCairoColor());
                        ctx.Fill();
                        ctx.Rectangle(dx + 1, y, Allocation.Width - dx - 1, Allocation.Height - y);
                        ctx.SetSourceColor(Styles.BrowserPadBackground.ToCairoColor());
                        ctx.Fill();
                    }
                }
            }
            layout.Dispose();
        }
示例#43
0
        protected override void DrawContents(Gdk.Drawable d)
        {
            Gdk.GC        gc = new Gdk.GC(d);
            Cairo.Context g  = Gdk.CairoHelper.Create(d);

            g.SelectFontFace("Lucida Console", FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);

            TextExtents te;

            string lvl, hp, hpm, mp, mpm;


            #region Character 1

            if (Globals.Party[0] != null)
            {
                d.DrawPixbuf(gc, Graphics.GetProfile(Globals.Party[0].Name), 0, 0,
                             X + x1, Y + yp,
                             Graphics.PROFILE_WIDTH, Graphics.PROFILE_HEIGHT, Gdk.RgbDither.None, 0, 0);

                g.Color = new Color(.3, .8, .8);
                g.MoveTo(X + x3, Y + y0 + ya);
                g.ShowText("LV");
                g.MoveTo(X + x3, Y + y0 + yb);
                g.ShowText("HP");
                g.MoveTo(X + x3, Y + y0 + yc);
                g.ShowText("MP");
                g.Color = new Color(1, 1, 1);

                Color namec = new Color(1, 1, 1);
                if (Globals.Party[0].Death)
                {
                    namec = new Color(0.8, 0, 0);
                }
                else if (Globals.Party[0].NearDeath)
                {
                    namec = new Color(.8, .8, 0);
                }

                Graphics.ShadowedText(g, namec, Globals.Party[0].Name, X + x3, Y + y0);

                lvl = Globals.Party[0].Level.ToString();
                hp  = Globals.Party[0].HP.ToString() + "/";
                hpm = Globals.Party[0].MaxHP.ToString();
                mp  = Globals.Party[0].MP.ToString() + "/";
                mpm = Globals.Party[0].MaxMP.ToString();

                te = g.TextExtents(lvl);
                Graphics.ShadowedText(g, lvl, X + x4 - te.Width, Y + y0 + ya);
                te = g.TextExtents(hp);
                Graphics.ShadowedText(g, hp, X + x5 - te.Width, Y + y0 + yb);
                te = g.TextExtents(hpm);
                Graphics.ShadowedText(g, hpm, X + x6 - te.Width, Y + y0 + yb);
                te = g.TextExtents(mp);
                Graphics.ShadowedText(g, mp, X + x5 - te.Width, Y + y0 + yc);
                te = g.TextExtents(mpm);
                Graphics.ShadowedText(g, mpm, X + x6 - te.Width, Y + y0 + yc);
            }
            #endregion Character 1


            #region Character 2

            if (Globals.Party[1] != null)
            {
                d.DrawPixbuf(gc, Graphics.GetProfile(Globals.Party[1].Name), 0, 0,
                             X + x1, Y + yp + (y1 - y0),
                             Graphics.PROFILE_WIDTH, Graphics.PROFILE_HEIGHT, Gdk.RgbDither.None, 0, 0);

                g.Color = new Color(.3, .8, .8);
                g.MoveTo(X + x3, Y + y1 + ya);
                g.ShowText("LV");
                g.MoveTo(X + x3, Y + y1 + yb);
                g.ShowText("HP");
                g.MoveTo(X + x3, Y + y1 + yc);
                g.ShowText("MP");
                g.Color = new Color(1, 1, 1);

                Color namec = new Color(1, 1, 1);
                if (Globals.Party[1].Death)
                {
                    namec = new Color(0.8, 0, 0);
                }
                else if (Globals.Party[1].NearDeath)
                {
                    namec = new Color(.8, .8, 0);
                }

                Graphics.ShadowedText(g, namec, Globals.Party[1].Name, X + x3, Y + y1);

                lvl = Globals.Party[1].Level.ToString();
                hp  = Globals.Party[1].HP.ToString() + "/";
                hpm = Globals.Party[1].MaxHP.ToString();
                mp  = Globals.Party[1].MP.ToString() + "/";
                mpm = Globals.Party[1].MaxMP.ToString();

                te = g.TextExtents(lvl);
                Graphics.ShadowedText(g, lvl, X + x4 - te.Width, Y + y1 + ya);
                te = g.TextExtents(hp);
                Graphics.ShadowedText(g, hp, X + x5 - te.Width, Y + y1 + yb);
                te = g.TextExtents(hpm);
                Graphics.ShadowedText(g, hpm, X + x6 - te.Width, Y + y1 + yb);
                te = g.TextExtents(mp);
                Graphics.ShadowedText(g, mp, X + x5 - te.Width, Y + y1 + yc);
                te = g.TextExtents(mpm);
                Graphics.ShadowedText(g, mpm, X + x6 - te.Width, Y + y1 + yc);
            }

            #endregion Character 2


            #region Character 3

            if (Globals.Party[2] != null)
            {
                d.DrawPixbuf(gc, Graphics.GetProfile(Globals.Party[2].Name), 0, 0,
                             X + x1, Y + yp + (y2 - y0),
                             Graphics.PROFILE_WIDTH, Graphics.PROFILE_HEIGHT, Gdk.RgbDither.None, 0, 0);

                g.Color = new Color(.3, .8, .8);
                g.MoveTo(X + x3, Y + y2 + ya);
                g.ShowText("LV");
                g.MoveTo(X + x3, Y + y2 + yb);
                g.ShowText("HP");
                g.MoveTo(X + x3, Y + y2 + yc);
                g.ShowText("MP");
                g.Color = new Color(1, 1, 1);

                Color namec = new Color(1, 1, 1);
                if (Globals.Party[2].Death)
                {
                    namec = new Color(0.8, 0, 0);
                }
                else if (Globals.Party[2].NearDeath)
                {
                    namec = new Color(.8, .8, 0);
                }

                Graphics.ShadowedText(g, namec, Globals.Party[2].Name, X + x3, Y + y2);

                lvl = Globals.Party[2].Level.ToString();
                hp  = Globals.Party[2].HP.ToString() + "/";
                hpm = Globals.Party[2].MaxHP.ToString();
                mp  = Globals.Party[2].MP.ToString() + "/";
                mpm = Globals.Party[2].MaxMP.ToString();

                te = g.TextExtents(lvl);
                Graphics.ShadowedText(g, lvl, X + x4 - te.Width, Y + y2 + ya);
                te = g.TextExtents(hp);
                Graphics.ShadowedText(g, hp, X + x5 - te.Width, Y + y2 + yb);
                te = g.TextExtents(hpm);
                Graphics.ShadowedText(g, hpm, X + x6 - te.Width, Y + y2 + yb);
                te = g.TextExtents(mp);
                Graphics.ShadowedText(g, mp, X + x5 - te.Width, Y + y2 + yc);
                te = g.TextExtents(mpm);
                Graphics.ShadowedText(g, mpm, X + x6 - te.Width, Y + y2 + yc);
            }

            #endregion Character 3


            if (IsControl)
            {
                Graphics.RenderCursor(g, X + cx, Y + cy);
            }


            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }
示例#44
0
        protected override void DrawContents(Gdk.Drawable d)
        {
            Gdk.GC        gc = new Gdk.GC(d);
            Cairo.Context g  = Gdk.CairoHelper.Create(d);

            g.SelectFontFace("Lucida Console", FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);

            TextExtents te;

            string lvl, hp, hpm, mp, mpm;

            #region Character

            Character c = PHSList.Instance.Selection;

            if (c != null)
            {
                Graphics.DrawProfileSmall(d, gc, c.Name, X + x1, Y + yp);

                g.Color = new Color(.3, .8, .8);
                g.MoveTo(X + x3, Y + y0 + ya);
                g.ShowText("LV");
                g.MoveTo(X + x3, Y + y0 + yb);
                g.ShowText("HP");
                g.MoveTo(X + x3, Y + y0 + yc);
                g.ShowText("MP");
                g.Color = new Color(1, 1, 1);

                Color namec = new Color(1, 1, 1);
                if (c.Death)
                {
                    namec = new Color(0.8, 0, 0);
                }
                else if (c.NearDeath)
                {
                    namec = new Color(.8, .8, 0);
                }

                Graphics.ShadowedText(g, namec, c.Name, X + x3, Y + y0);

                lvl = c.Level.ToString();
                hp  = c.HP.ToString() + "/";
                hpm = c.MaxHP.ToString();
                mp  = c.MP.ToString() + "/";
                mpm = c.MaxMP.ToString();

                te = g.TextExtents(lvl);
                Graphics.ShadowedText(g, lvl, X + x4 - te.Width, Y + y0 + ya);
                te = g.TextExtents(hp);
                Graphics.ShadowedText(g, hp, X + x5 - te.Width, Y + y0 + yb);
                te = g.TextExtents(hpm);
                Graphics.ShadowedText(g, hpm, X + x6 - te.Width, Y + y0 + yb);
                te = g.TextExtents(mp);
                Graphics.ShadowedText(g, mp, X + x5 - te.Width, Y + y0 + yc);
                te = g.TextExtents(mpm);
                Graphics.ShadowedText(g, mpm, X + x6 - te.Width, Y + y0 + yc);
            }
            #endregion Character


            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }
示例#45
0
        public static void RoundedRectangle(this Cairo.Context cr, double x, double y, double w, double h,
                                            double r, CairoCorners corners, bool topBottomFallsThrough)
        {
            if (topBottomFallsThrough && corners == CairoCorners.None)
            {
                cr.MoveTo(x, y - r);
                cr.LineTo(x, y + h + r);
                cr.MoveTo(x + w, y - r);
                cr.LineTo(x + w, y + h + r);
                return;
            }
            else if (r < 0.0001 || corners == CairoCorners.None)
            {
                cr.Rectangle(x, y, w, h);
                return;
            }

            if ((corners & (CairoCorners.TopLeft | CairoCorners.TopRight)) == 0 && topBottomFallsThrough)
            {
                y -= r;
                h += r;
                cr.MoveTo(x + w, y);
            }
            else
            {
                if ((corners & CairoCorners.TopLeft) != 0)
                {
                    cr.MoveTo(x + r, y);
                }
                else
                {
                    cr.MoveTo(x, y);
                }

                if ((corners & CairoCorners.TopRight) != 0)
                {
                    cr.Arc(x + w - r, y + r, r, Math.PI * 1.5, Math.PI * 2);
                }
                else
                {
                    cr.LineTo(x + w, y);
                }
            }

            if ((corners & (CairoCorners.BottomLeft | CairoCorners.BottomRight)) == 0 && topBottomFallsThrough)
            {
                h += r;
                cr.LineTo(x + w, y + h);
                cr.MoveTo(x, y + h);
                cr.LineTo(x, y + r);
                cr.Arc(x + r, y + r, r, Math.PI, Math.PI * 1.5);
            }
            else
            {
                if ((corners & CairoCorners.BottomRight) != 0)
                {
                    cr.Arc(x + w - r, y + h - r, r, 0, Math.PI * 0.5);
                }
                else
                {
                    cr.LineTo(x + w, y + h);
                }

                if ((corners & CairoCorners.BottomLeft) != 0)
                {
                    cr.Arc(x + r, y + h - r, r, Math.PI * 0.5, Math.PI);
                }
                else
                {
                    cr.LineTo(x, y + h);
                }

                if ((corners & CairoCorners.TopLeft) != 0)
                {
                    cr.Arc(x + r, y + r, r, Math.PI, Math.PI * 1.5);
                }
                else
                {
                    cr.LineTo(x, y);
                }
            }
        }
示例#46
0
        void ejecutar_consulta_reporte(PrintContext context)
        {
            int    numero_solicitud;
            int    numero_almacen;
            int    contador_productos = 0;
            string toma_descrip_prod;
            string fechaautorizacion = "";
            string comentario        = "";
            string nombrepaciente    = "";
            string tiposolictud      = "SOLICITUD A PACIENTE ";

            Cairo.Context         cr     = context.CairoContext;
            Pango.Layout          layout = context.CreatePangoLayout();
            Pango.FontDescription desc   = Pango.FontDescription.FromString("Sans");
            fontSize  = 7.0;                                                                                 layout = context.CreatePangoLayout();
            desc.Size = (int)(fontSize * pangoScale);                                       layout.FontDescription = desc;

            NpgsqlConnection conexion;

            conexion = new NpgsqlConnection(connectionString + nombrebd);
            // Verifica que la base de dato s este conectada
            try{
                conexion.Open();
                NpgsqlCommand comando;
                comando             = conexion.CreateCommand();
                comando.CommandText = query_general;
                //Console.WriteLine(comando.CommandText);
                NpgsqlDataReader lector = comando.ExecuteReader();
                if (lector.Read())
                {
                    numero_solicitud  = (int)lector["folio_de_solicitud"];
                    numero_almacen    = (int)lector["idalmacen"];
                    toma_descrip_prod = (string)lector["descripcion_producto"];
                    nombrepaciente    = (string)lector["nombre1_paciente"].ToString().Trim() + " " +
                                        (string)lector["nombre2_paciente"].ToString().Trim() + " " +
                                        (string)lector["apellido_paterno_paciente"].ToString().Trim() + " " +
                                        (string)lector["apellido_materno_paciente"].ToString().Trim();
                    if (toma_descrip_prod.Length > 69)
                    {
                        toma_descrip_prod = toma_descrip_prod.Substring(0, 68);
                    }
                    if ((string)lector["fecha_autorizado"] == "02-01-2000")
                    {
                        fechaautorizacion = "";
                    }
                    else
                    {
                        fechaautorizacion = (string)lector["fecha_autorizado"];
                    }
                    if ((bool)lector["solicitud_stock"] == true)
                    {
                        tiposolictud = "SOLICITUD PARA STOCK DEL SUB-ALAMACEN";
                    }
                    else
                    {
                        tiposolictud = "SOLICITUD A PACIENTE";
                    }
                    if ((bool)lector["pre_solicitud"] == true)
                    {
                        tiposolictud   = "PRE-SOLICITUD PARA CIRUGIAS PROGRAMADAS";
                        nombrepaciente = (string)lector["nombre_paciente"].ToString().Trim();
                    }
                    else
                    {
                        tiposolictud = "SOLICITUD A PACIENTE";
                    }
                    //comprueba las notas de los resultado en el reporte
                    if ((bool)lector["sin_stock"] == true)
                    {
                        comentario = "sin stock";
                    }
                    if ((bool)lector["solicitado_erroneo"] == true)
                    {
                        comentario = "Pedido Erroneo";
                    }
                    if ((bool)lector["surtido"] == true)
                    {
                        comentario = "surtido";
                    }
                    if (float.Parse((string)lector["cantaut"]) == 0 && (bool)lector["sin_stock"] == false && (bool)lector["solicitado_erroneo"] == false && (bool)lector["surtido"] == false)
                    {
                        comentario = "No surtido";
                    }
                    imprime_encabezado(cr, layout, (string)lector["descripcion_almacen"], (string)lector["foliosol"], (string)lector["fecha_envio"],
                                       (string)lector["id_quien_solicito"], (string)lector["nombreempl"],
                                       (string)lector["foliodeatencion"].ToString().Trim(), (string)lector["pidpaciente"].ToString().Trim(), nombrepaciente,
                                       tiposolictud + " " + (string)lector["tipo_solicitud"].ToString().Trim(), (string)lector["procedimiento_qx"].ToString().Trim(), (string)lector["diagnostico_qx"].ToString().Trim(), (string)lector["observaciones_solicitud"].ToString());

                    cr.MoveTo(15 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                  layout.SetText((string)lector["cantsol"]);                             Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(60 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                  layout.SetText((string)lector["idproducto"]);                  Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(120 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                 layout.SetText(toma_descrip_prod);                                              Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(405 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                 layout.SetText((string)lector["cantaut"]);                             Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(465 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                 layout.SetText(fechaautorizacion);                              Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(520 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                 layout.SetText(comentario);                             Pango.CairoHelper.ShowLayout(cr, layout);
                    contador_productos += 1;
                    comienzo_linea     += separacion_linea;
                    while (lector.Read())
                    {
                        if (numero_solicitud != (int)lector["folio_de_solicitud"] || numero_almacen != (int)lector["idalmacen"])
                        {
                            cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                  layout.SetText("Productos Solicitados :" + contador_productos.ToString());                                Pango.CairoHelper.ShowLayout(cr, layout);
                            nombrepaciente = (string)lector["nombre1_paciente"].ToString().Trim() + " " +
                                             (string)lector["nombre2_paciente"].ToString().Trim() + " " +
                                             (string)lector["apellido_paterno_paciente"].ToString().Trim() + " " +
                                             (string)lector["apellido_materno_paciente"].ToString().Trim();
                            numero_solicitud = (int)lector["folio_de_solicitud"];
                            numero_almacen   = (int)lector["idalmacen"];
                            if ((bool)lector["solicitud_stock"] == true)
                            {
                                tiposolictud = "SOLICITUD PARA STOCK DEL SUB-ALAMACEN";
                            }
                            if ((bool)lector["pre_solicitud"] == true)
                            {
                                tiposolictud   = "PRE-SOLICITUD PARA CIRUGIAS PROGRAMADAS";
                                nombrepaciente = (string)lector["nombre_paciente"].ToString().Trim();
                            }
                            if ((bool)lector["solicitud_stock"] == false && (bool)lector["pre_solicitud"] == false)
                            {
                                tiposolictud = "SOLICITUD A PACIENTE";
                            }
                            cr.ShowPage();
                            comienzo_linea     = 135;
                            contador_productos = 0;
                            imprime_encabezado(cr, layout, (string)lector["descripcion_almacen"], (string)lector["foliosol"], (string)lector["fecha_envio"],
                                               (string)lector["id_quien_solicito"], (string)lector["nombreempl"],
                                               (string)lector["foliodeatencion"].ToString().Trim(), (string)lector["pidpaciente"].ToString().Trim(),
                                               nombrepaciente, tiposolictud + " " + (string)lector["tipo_solicitud"].ToString().Trim(), (string)lector["procedimiento_qx"].ToString().Trim(),
                                               (string)lector["diagnostico_qx"].ToString().Trim(), (string)lector["observaciones_solicitud"].ToString());
                        }
                        toma_descrip_prod = (string)lector["descripcion_producto"];
                        if (toma_descrip_prod.Length > 69)
                        {
                            toma_descrip_prod = toma_descrip_prod.Substring(0, 68);
                        }
                        if ((string)lector["fecha_autorizado"] == "02-01-2000")
                        {
                            fechaautorizacion = "";
                        }
                        else
                        {
                            fechaautorizacion = (string)lector["fecha_autorizado"];
                        }
                        //comprueba las notas de los resultado en el reporte
                        if ((bool)lector["sin_stock"] == true)
                        {
                            comentario = "sin stock";
                        }
                        if ((bool)lector["solicitado_erroneo"] == true)
                        {
                            comentario = "Pedido Erroneo";
                        }
                        if ((bool)lector["surtido"] == true)
                        {
                            comentario = "surtido";
                        }
                        if (float.Parse((string)lector["cantaut"]) == 0 && (bool)lector["sin_stock"] == false && (bool)lector["solicitado_erroneo"] == false && (bool)lector["surtido"] == false)
                        {
                            comentario = "No surtido";
                        }
                        cr.MoveTo(15 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                  layout.SetText((string)lector["cantsol"]);                     Pango.CairoHelper.ShowLayout(cr, layout);
                        cr.MoveTo(60 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                  layout.SetText((string)lector["idproducto"]);          Pango.CairoHelper.ShowLayout(cr, layout);
                        cr.MoveTo(120 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                 layout.SetText(toma_descrip_prod);                                      Pango.CairoHelper.ShowLayout(cr, layout);
                        cr.MoveTo(405 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                 layout.SetText((string)lector["cantaut"]);                     Pango.CairoHelper.ShowLayout(cr, layout);
                        cr.MoveTo(465 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                 layout.SetText(fechaautorizacion);                              Pango.CairoHelper.ShowLayout(cr, layout);
                        cr.MoveTo(520 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                 layout.SetText(comentario);                             Pango.CairoHelper.ShowLayout(cr, layout);
                        contador_productos += 1;
                        comienzo_linea     += separacion_linea;
                        salto_de_pagina(cr, layout, (string)lector["descripcion_almacen"], (string)lector["foliosol"], (string)lector["fecha_envio"], (string)lector["id_quien_solicito"], (string)lector["nombreempl"],
                                        (string)lector["foliodeatencion"].ToString().Trim(), (string)lector["pidpaciente"].ToString().Trim(), nombrepaciente, tiposolictud,
                                        (string)lector["procedimiento_qx"].ToString().Trim(), (string)lector["diagnostico_qx"].ToString().Trim(), (string)lector["observaciones_solicitud"].ToString());
                    }
                    cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                  layout.SetText("Productos Solicitados :" + contador_productos.ToString());                                Pango.CairoHelper.ShowLayout(cr, layout);
                }
            }catch (NpgsqlException ex) {
                MessageDialog msgBoxError = new MessageDialog(MyWinError, DialogFlags.DestroyWithParent,
                                                              MessageType.Warning, ButtonsType.Ok, "PostgresSQL error: {0}", ex.Message);
                msgBoxError.Run();
                msgBoxError.Destroy();
                Console.WriteLine("PostgresSQL error: {0}", ex.Message);
            }
        }
示例#47
0
        void imprime_encabezado(Cairo.Context cr, Pango.Layout layout, string numerocomprobante, string numerodeatencion, string numeroexpediente,
                                string nombrepaciente, string descripcion_empmuni, string telefono_paciente, string fechahoraregistro,
                                string conceptocomprobante, string observacionescomprobante, float tomavalortotal, string doctor_admision)
        {
            comienzo_linea = 60;
            Pango.FontDescription desc = Pango.FontDescription.FromString("Sans");
            //cr.Rotate(90);  //Imprimir Orizontalmente rota la hoja cambian las posiciones de las lineas y columna
            fontSize  = 8.0;
            desc.Size = (int)(fontSize * pangoScale);                                       layout.FontDescription = desc;
            layout.FontDescription.Weight = Weight.Bold;                        // Letra negrita
            cr.MoveTo(05 * escala_en_linux_windows, 05 * escala_en_linux_windows);                       layout.SetText(classpublic.nombre_empresa);                     Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(05 * escala_en_linux_windows, 15 * escala_en_linux_windows);                       layout.SetText(classpublic.direccion_empresa);          Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(05 * escala_en_linux_windows, 25 * escala_en_linux_windows);                       layout.SetText(classpublic.telefonofax_empresa);        Pango.CairoHelper.ShowLayout(cr, layout);
            fontSize  = 6.0;
            desc.Size = (int)(fontSize * pangoScale);                                       layout.FontDescription = desc;
            cr.MoveTo(479 * escala_en_linux_windows, 05 * escala_en_linux_windows);                      layout.SetText("Fech.Rpt:" + (string)DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));              Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(479 * escala_en_linux_windows, 15 * escala_en_linux_windows);                      layout.SetText("N° Page :" + numpage.ToString().Trim());          Pango.CairoHelper.ShowLayout(cr, layout);

            cr.MoveTo(05 * escala_en_linux_windows, 35 * escala_en_linux_windows);                       layout.SetText("Sistema Hospitalario OSIRIS");          Pango.CairoHelper.ShowLayout(cr, layout);
            // Cambiando el tamaño de la fuente
            fontSize  = 10.0;
            desc.Size = (int)(fontSize * pangoScale);                                       layout.FontDescription = desc;
            layout.FontDescription.Weight = Weight.Bold;                        // Letra negrita
            layout.Alignment = Pango.Alignment.Center;

            double width = context.Width;

            layout.Width     = (int)width;
            layout.Alignment = Pango.Alignment.Center;
            //layout.Wrap = Pango.WrapMode.Word;
            //layout.SingleParagraphMode = true;
            layout.Justify = false;
            if (tipocomprobante == "PAGARE")
            {
                cr.MoveTo(width / 2, 45 * escala_en_linux_windows);  layout.SetText(titulo_comprobante);     Pango.CairoHelper.ShowLayout(cr, layout);
            }
            else
            {
                cr.MoveTo(width / 2, 45 * escala_en_linux_windows);  layout.SetText("COMPROBANTE_" + titulo_comprobante);      Pango.CairoHelper.ShowLayout(cr, layout);
            }
            fontSize  = 9.0;                 layout = null;                  layout = context.CreatePangoLayout();
            desc.Size = (int)(fontSize * pangoScale);               layout.FontDescription = desc;
            layout.FontDescription.Weight = Weight.Bold;                        // Letra negrita
            cr.MoveTo(479 * escala_en_linux_windows, 25 * escala_en_linux_windows);                     layout.SetText("N° Folio " + numerocomprobante);                          Pango.CairoHelper.ShowLayout(cr, layout);

            fontSize  = 8.0;                 layout = null;                  layout = context.CreatePangoLayout();
            desc.Size = (int)(fontSize * pangoScale);               layout.FontDescription = desc;
            layout.FontDescription.Weight = Weight.Bold;                        // Letra negrita
            cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);           layout.SetText("N° Atencion: " + numerodeatencion);       Pango.CairoHelper.ShowLayout(cr, layout);
            layout.FontDescription.Weight = Weight.Normal;                      // Letra normal
            cr.MoveTo(120 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);          layout.SetText("N° Expe.: " + numeroexpediente);          Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(220 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);          layout.SetText("Nombre Paciente: " + nombrepaciente);     Pango.CairoHelper.ShowLayout(cr, layout);
            comienzo_linea += separacion_linea;
            cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);           layout.SetText("Telefono: " + telefono_paciente); Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(250 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);          layout.SetText("Fecha Admision: " + fechahoraregistro);   Pango.CairoHelper.ShowLayout(cr, layout);
            comienzo_linea += separacion_linea;
            cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);           layout.SetText("Tipo Paciente: " + tipo_paciente);        Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(200 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);          layout.SetText("Empr./Munic.: " + descripcion_empmuni);   Pango.CairoHelper.ShowLayout(cr, layout);
            comienzo_linea += separacion_linea;
            cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);           layout.SetText("Doctor: " + doctor_admision);     Pango.CairoHelper.ShowLayout(cr, layout);

            if (tipocomprobante == "CAJA")
            {
                fontSize  = 7.0;
                desc.Size = (int)(fontSize * pangoScale);                                       layout.FontDescription = desc;
                layout.FontDescription.Weight = Weight.Normal;
                // numeros en letras
                cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea + (separacion_linea * 22) * escala_en_linux_windows);             layout.SetText((string)class_public.ConvertirCadena(tomavalortotal.ToString(), "PESOS").ToUpper());     Pango.CairoHelper.ShowLayout(cr, layout);
                fontSize  = 8.0;
                desc.Size = (int)(fontSize * pangoScale);                                       layout.FontDescription = desc;
                layout.FontDescription.Weight = Weight.Bold;                            // Letra negrita
                cr.MoveTo(400 * escala_en_linux_windows, comienzo_linea + (separacion_linea * 22) * escala_en_linux_windows);            layout.SetText("T O T A L : " + tomavalortotal.ToString("C"));    Pango.CairoHelper.ShowLayout(cr, layout);
            }

            if (tipocomprobante == "ABONO")
            {
                fontSize  = 7.0;
                desc.Size = (int)(fontSize * pangoScale);                                       layout.FontDescription = desc;
                layout.FontDescription.Weight = Weight.Normal;
                // numeros en letras
                cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea + (separacion_linea * 22) * escala_en_linux_windows);             layout.SetText((string)class_public.ConvertirCadena(tomavalortotal.ToString(), "PESOS").ToUpper());     Pango.CairoHelper.ShowLayout(cr, layout);
                fontSize  = 8.0;
                desc.Size = (int)(fontSize * pangoScale);                                       layout.FontDescription = desc;
                layout.FontDescription.Weight = Weight.Bold;                            // Letra negrita
                cr.MoveTo(400 * escala_en_linux_windows, comienzo_linea + (separacion_linea * 22) * escala_en_linux_windows);            layout.SetText("T O T A L : " + tomavalortotal.ToString("C"));    Pango.CairoHelper.ShowLayout(cr, layout);
            }

            /*
             * if (tipocomprobante == "PAGARE"){
             *      fontSize = 7.0;
             *      desc.Size = (int)(fontSize * pangoScale);					layout.FontDescription = desc;
             *      layout.FontDescription.Weight = Weight.Normal;
             *      // numeros en letras
             *      cr.MoveTo(05*escala_en_linux_windows,comienzo_linea+(separacion_linea*22)*escala_en_linux_windows);		layout.SetText((string) class_public.ConvertirCadena(tomavalortotal.ToString(),"PESOS").ToUpper());	Pango.CairoHelper.ShowLayout (cr, layout);
             *      fontSize = 8.0;
             *      desc.Size = (int)(fontSize * pangoScale);					layout.FontDescription = desc;
             *      layout.FontDescription.Weight = Weight.Bold;		// Letra negrita
             *      cr.MoveTo(300*escala_en_linux_windows,comienzo_linea+(separacion_linea*22)*escala_en_linux_windows);		layout.SetText("VALOR TOTAL DEL PAGARE: "+tomavalortotal.ToString("C"));	Pango.CairoHelper.ShowLayout (cr, layout);
             * }*/

            if (tipocomprobante != "PAGARE")
            {
                fontSize  = 8.0;
                desc.Size = (int)(fontSize * pangoScale);                                       layout.FontDescription = desc;
                layout.FontDescription.Weight = Weight.Normal;                          // Letra normal

                cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea + (separacion_linea * 23) * escala_en_linux_windows);             layout.SetText("Concepto    : " + conceptocomprobante);   Pango.CairoHelper.ShowLayout(cr, layout);
                cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea + (separacion_linea * 24) * escala_en_linux_windows);             layout.SetText("Observacion : " + observacionescomprobante);      Pango.CairoHelper.ShowLayout(cr, layout);
                cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea + (separacion_linea * 25) * escala_en_linux_windows);             layout.SetText("Atendio por : " + nombreempleado);        Pango.CairoHelper.ShowLayout(cr, layout);

                fontSize  = 8.0;                 layout = null;                  layout = context.CreatePangoLayout();
                desc.Size = (int)(fontSize * pangoScale);               layout.FontDescription = desc;
                layout.FontDescription.Weight = Weight.Normal;                          // Letra normal
            }
        }
示例#48
0
        void imprime_encabezado(Cairo.Context cr, Pango.Layout layout)
        {
            //Gtk.Image image5 = new Gtk.Image();
            //image5.Name = "image5";
            //image5.Pixbuf = new Gdk.Pixbuf(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "osiris.jpg"));
            //image5.Pixbuf = new Gdk.Pixbuf("/opt/osiris/bin/OSIRISLogo.jpg");   // en Linux
            //image5.Pixbuf.ScaleSimple(128, 128, Gdk.InterpType.Bilinear);
            //Gdk.CairoHelper.SetSourcePixbuf(cr,image5.Pixbuf,1,-30);
            //Gdk.CairoHelper.SetSourcePixbuf(cr,image5.Pixbuf.ScaleSimple(145, 50, Gdk.InterpType.Bilinear),1,1);
            //Gdk.CairoHelper.SetSourcePixbuf(cr,image5.Pixbuf.ScaleSimple(180, 64, Gdk.InterpType.Hyper),1,1);
            //cr.Fill();
            //cr.Paint();
            //cr.Restore();

            Pango.FontDescription desc = Pango.FontDescription.FromString("Sans");
            //cr.Rotate(90);  //Imprimir Orizontalmente rota la hoja cambian las posiciones de las lineas y columna
            fontSize  = 8.0;
            desc.Size = (int)(fontSize * pangoScale);                                       layout.FontDescription = desc;
            layout.FontDescription.Weight = Weight.Bold;                        // Letra negrita
            cr.MoveTo(05 * escala_en_linux_windows, 05 * escala_en_linux_windows);                       layout.SetText(classpublic.nombre_empresa);                     Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(05 * escala_en_linux_windows, 15 * escala_en_linux_windows);                       layout.SetText(classpublic.direccion_empresa);          Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(05 * escala_en_linux_windows, 25 * escala_en_linux_windows);                       layout.SetText(classpublic.telefonofax_empresa);        Pango.CairoHelper.ShowLayout(cr, layout);
            fontSize  = 6.0;
            desc.Size = (int)(fontSize * pangoScale);                                       layout.FontDescription = desc;
            cr.MoveTo(650 * escala_en_linux_windows, 05 * escala_en_linux_windows);                      layout.SetText("Fech.Rpt:" + (string)DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));              Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(650 * escala_en_linux_windows, 15 * escala_en_linux_windows);                      layout.SetText("N° Page :" + numpage.ToString().Trim());          Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(05 * escala_en_linux_windows, 35 * escala_en_linux_windows);                       layout.SetText("Sistema Hospitalario OSIRIS");          Pango.CairoHelper.ShowLayout(cr, layout);
            // Cambiando el tamaño de la fuente
            fontSize  = 10.0;
            desc.Size = (int)(fontSize * pangoScale);                                       layout.FontDescription = desc;
            cr.MoveTo(240 * escala_en_linux_windows, 25 * escala_en_linux_windows);                     layout.SetText("CALENDARIO DE CITAS Y CIRUGIAS PROGRAMADAS");                                   Pango.CairoHelper.ShowLayout(cr, layout);

            // Creando el Cuadro de Titulos
            cr.Rectangle(05 * escala_en_linux_windows, 50 * escala_en_linux_windows, 750 * escala_en_linux_windows, 15 * escala_en_linux_windows);
            cr.FillExtents();              //. FillPreserve();
            cr.SetSourceRGB(0, 0, 0);
            cr.LineWidth = 0.5;
            cr.Stroke();

            fontSize  = 8.0;
            desc.Size = (int)(fontSize * pangoScale);                                       layout.FontDescription = desc;
            layout.FontDescription.Weight = Weight.Bold;                        // Letra negrita
            cr.MoveTo(09 * escala_en_linux_windows, 53 * escala_en_linux_windows);                       layout.SetText("Fech/Hora");                    Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(74 * escala_en_linux_windows, 53 * escala_en_linux_windows);                       layout.SetText("N° Exp.");                              Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(114 * escala_en_linux_windows, 53 * escala_en_linux_windows);                      layout.SetText("Nombre del Paciente");  Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(300 * escala_en_linux_windows, 53 * escala_en_linux_windows);                      layout.SetText("Tipo Paciente");        Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(400 * escala_en_linux_windows, 53 * escala_en_linux_windows);                      layout.SetText("Tipo Servicio");        Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(480 * escala_en_linux_windows, 53 * escala_en_linux_windows);                      layout.SetText("Especialidad ");        Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(570 * escala_en_linux_windows, 53 * escala_en_linux_windows);                      layout.SetText("Nombre del Doctor");    Pango.CairoHelper.ShowLayout(cr, layout);
            layout.FontDescription.Weight = Weight.Normal;                      // Letra Normal
        }
示例#49
0
        void ejecutar_consulta_reporte(PrintContext context)
        {
            bool  apl_desc            = false;
            bool  apl_desc_siempre    = true;
            int   toma_tipoadmisiones = 0;
            int   toma_grupoproducto  = 0;
            float toma_valor_total    = 0;

            comienzo_linea = 60;
            Cairo.Context cr     = context.CairoContext;
            Pango.Layout  layout = context.CreatePangoLayout();

            Pango.FontDescription desc = Pango.FontDescription.FromString("Sans");
            //cr.Rotate(90);  //Imprimir Orizontalmente rota la hoja cambian las posiciones de las lineas y columna
            fontSize  = 8.0;
            desc.Size = (int)(fontSize * pangoScale);                                       layout.FontDescription = desc;

            NpgsqlConnection conexion;

            conexion = new NpgsqlConnection(connectionString + nombrebd);
            // Verifica que la base de datos este conectada
            try{
                conexion.Open();
                NpgsqlCommand comando;
                comando             = conexion.CreateCommand();
                comando.CommandText = sql_compcaja + sql_numerocomprobante + sql_foliodeservicio + sql_orderquery;
                Console.WriteLine(comando.CommandText);
                NpgsqlDataReader lector = comando.ExecuteReader();
                if (lector.Read())
                {
                    switch (tipocomprobante)
                    {
                    case "CAJA":
                        toma_valor_total   = float.Parse((string)lector["montodelabono"]);
                        titulo_comprobante = tipocomprobante + "_" + (string)lector["descripcion_tipo_comprobante"];
                        break;

                    case "PAGARE":
                        toma_valor_total   = float.Parse((string)lector["montodelabono"]);
                        titulo_comprobante = tipocomprobante;
                        break;

                    case "SERVICO":
                        titulo_comprobante = tipocomprobante;
                        break;

                    case "ABONO":
                        toma_valor_total   = float.Parse((string)lector["montodelabono"]);
                        titulo_comprobante = "CAJA_" + tipocomprobante;
                        break;
                    }
                    busca_tipoadmisiones(lector["foliodeservicio"].ToString().Trim());
                    imprime_encabezado(cr, layout, numero_comprobante.ToString().Trim(), lector["foliodeservicio"].ToString().Trim(), lector["pidpaciente"].ToString().Trim(),
                                       lector["nombre_completo"].ToString().Trim(), lector["descripcion_empresa"].ToString().Trim(), lector["telefono_particular1_paciente"].ToString().Trim(),
                                       lector["fechcreacion"].ToString().Trim() + " " + lector["horacreacion"].ToString().Trim(), lector["concepto_comprobante"].ToString().Trim(), lector["observacionesvarias"].ToString().Trim(),
                                       toma_valor_total, lector["nombre_medico_encabezado"].ToString().Trim());
                    if (tipocomprobante == "CAJA" || tipocomprobante == "SERVICIO")
                    {
                        toma_tipoadmisiones           = (int)lector["idadmisiones"];
                        toma_grupoproducto            = (int)lector["id_grupo_producto"];
                        comienzo_linea               += separacion_linea;
                        comienzo_linea               += separacion_linea;
                        fontSize                      = 8.0;                 layout = null;                  layout = context.CreatePangoLayout();
                        desc.Size                     = (int)(fontSize * pangoScale);               layout.FontDescription = desc;
                        layout.FontDescription.Weight = Weight.Normal;                                  // Letra normal
                        if ((int)lector["idadmisiones"] == 300 || (int)lector["idadmisiones"] == 400 || (int)lector["idadmisiones"] == 920 || (int)lector["idadmisiones"] == 950 || (int)lector["idadmisiones"] == 960)
                        {
                            cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);           layout.SetText((string)lector["descripcion_admisiones"].ToString().Trim());    Pango.CairoHelper.ShowLayout(cr, layout);
                            comienzo_linea += separacion_linea;
                            cr.MoveTo(15 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);           layout.SetText((string)lector["descripcion_grupo_producto"].ToString().Trim());        Pango.CairoHelper.ShowLayout(cr, layout);
                            comienzo_linea += separacion_linea;
                            cr.MoveTo(25 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);           layout.SetText((string)lector["idproducto"].ToString().Trim() + " " + (string)lector["descripcion_producto"].ToString().Trim());  Pango.CairoHelper.ShowLayout(cr, layout);
                        }
                        else
                        {
                            cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);           layout.SetText((string)lector["descripcion_admisiones"].ToString().Trim());    Pango.CairoHelper.ShowLayout(cr, layout);
                            comienzo_linea += separacion_linea;
                            cr.MoveTo(15 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);           layout.SetText((string)lector["descripcion_grupo_producto"].ToString().Trim());        Pango.CairoHelper.ShowLayout(cr, layout);
                        }
                        while (lector.Read())
                        {
                            if (toma_tipoadmisiones != (int)lector["idadmisiones"])
                            {
                                comienzo_linea += separacion_linea;
                                cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);           layout.SetText((string)lector["descripcion_admisiones"].ToString().Trim());    Pango.CairoHelper.ShowLayout(cr, layout);
                                comienzo_linea += separacion_linea;
                                cr.MoveTo(15 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);           layout.SetText((string)lector["descripcion_grupo_producto"].ToString().Trim());        Pango.CairoHelper.ShowLayout(cr, layout);
                                if ((int)lector["idadmisiones"] == 300 || (int)lector["idadmisiones"] == 400 || (int)lector["idadmisiones"] == 950 || (int)lector["idadmisiones"] == 960)
                                {
                                    comienzo_linea += separacion_linea;
                                    cr.MoveTo(25 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);           layout.SetText((string)lector["idproducto"].ToString().Trim() + " " + (string)lector["descripcion_producto"].ToString().Trim());  Pango.CairoHelper.ShowLayout(cr, layout);
                                }
                                toma_tipoadmisiones = (int)lector["idadmisiones"];
                                toma_grupoproducto  = (int)lector["id_grupo_producto"];
                            }
                            else
                            {
                                if (toma_grupoproducto != (int)lector["id_grupo_producto"])
                                {
                                    comienzo_linea += separacion_linea;
                                    cr.MoveTo(15 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);           layout.SetText((string)lector["descripcion_grupo_producto"].ToString().Trim());        Pango.CairoHelper.ShowLayout(cr, layout);
                                    toma_grupoproducto = (int)lector["id_grupo_producto"];
                                }
                                if ((int)lector["idadmisiones"] == 300 || (int)lector["idadmisiones"] == 400 || (int)lector["idadmisiones"] == 950 || (int)lector["idadmisiones"] == 960)
                                {
                                    comienzo_linea += separacion_linea;
                                    cr.MoveTo(25 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);           layout.SetText((string)lector["idproducto"].ToString().Trim() + " " + (string)lector["descripcion_producto"].ToString().Trim());  Pango.CairoHelper.ShowLayout(cr, layout);
                                }
                            }
                        }
                    }
                    if (tipocomprobante == "ABONO")
                    {
                    }
                    if (tipocomprobante == "PAGARE")
                    {
                        comienzo_linea += separacion_linea;
                        comienzo_linea += separacion_linea;
                        fontSize        = 8.0;                 layout = null;                  layout = context.CreatePangoLayout();
                        desc.Size       = (int)(fontSize * pangoScale);               layout.FontDescription = desc;
                        layout.FontDescription.Weight = Weight.Bold;
                        cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);           layout.SetText("PAGARÉ");       Pango.CairoHelper.ShowLayout(cr, layout);
                        cr.MoveTo(200 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);          layout.SetText("N° 1/1");       Pango.CairoHelper.ShowLayout(cr, layout);
                        cr.MoveTo(400 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);          layout.SetText("BUENO POR " + toma_valor_total.ToString("C"));    Pango.CairoHelper.ShowLayout(cr, layout);
                        layout.FontDescription.Weight = Weight.Normal;
                        comienzo_linea += separacion_linea;
                        comienzo_linea += separacion_linea;
                        cr.MoveTo(270 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                         layout.SetText("Monterrey, Nuevo León a los " + DateTime.Now.ToString("dd") + " días del mes de " + classpublic.nom_mes(DateTime.Now.ToString("MM")) + " del año " + DateTime.Now.ToString("yyyy"));      Pango.CairoHelper.ShowLayout(cr, layout);
                        comienzo_linea += separacion_linea;
                        fontSize        = 6.0;                 layout = null;                  layout = context.CreatePangoLayout();
                        desc.Size       = (int)(fontSize * pangoScale);               layout.FontDescription = desc;
                        layout.FontDescription.Weight = Weight.Normal;
                        cr.MoveTo(370 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                         layout.SetText("Lugar y fecha de expedición");  Pango.CairoHelper.ShowLayout(cr, layout);
                        comienzo_linea += separacion_linea;
                        fontSize        = 8.0;                 layout = null;                  layout = context.CreatePangoLayout();
                        desc.Size       = (int)(fontSize * pangoScale);               layout.FontDescription = desc;
                        layout.FontDescription.Weight = Weight.Normal;
                        cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                          layout.SetText("Debo(mos) y pagaré(mos) indicionalmente por este Pagaré a la orden de :");      Pango.CairoHelper.ShowLayout(cr, layout);
                        comienzo_linea += separacion_linea;
                        cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                          layout.SetText(classpublic.nombre_empresa);     Pango.CairoHelper.ShowLayout(cr, layout);
                        comienzo_linea += separacion_linea;
                        cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                          layout.SetText("en Monterrey, Nuevo León el " + lector["vencimiento_pagare"].ToString()); Pango.CairoHelper.ShowLayout(cr, layout);
                        comienzo_linea += separacion_linea;
                        cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                          layout.SetText("La cantidad de:");      Pango.CairoHelper.ShowLayout(cr, layout);
                        comienzo_linea += separacion_linea;
                        cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);          layout.SetText((string)class_public.ConvertirCadena(toma_valor_total.ToString(), "PESOS").ToUpper());   Pango.CairoHelper.ShowLayout(cr, layout);
                        comienzo_linea += separacion_linea;
                        comienzo_linea += separacion_linea;
                        cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                          layout.SetText("Valor Recibido a mi (nuestra) entera satisfacción. Este pagaré forma parte de una serie numerada del 1 al 1 y todos están sujetos a  la");      Pango.CairoHelper.ShowLayout(cr, layout);
                        comienzo_linea += separacion_linea;
                        cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                          layout.SetText("condición de que, al no pagarse cualquiera de ellos a su vencimiento, serán exigible todos los que le sigan en número, ademas de  los");        Pango.CairoHelper.ShowLayout(cr, layout);
                        comienzo_linea += separacion_linea;
                        cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                          layout.SetText("ya vencido, desde la fecha de vencimiento a este documento hasta el día de su  liquidacion, causara intereses  moratorios  al tipo  del");      Pango.CairoHelper.ShowLayout(cr, layout);
                        comienzo_linea += separacion_linea;
                        cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                          layout.SetText("_____% mensual, pagadero en esta ciudad juntamente con el principal."); Pango.CairoHelper.ShowLayout(cr, layout);
                        comienzo_linea += separacion_linea;
                        comienzo_linea += separacion_linea;
                        layout.FontDescription.Weight = Weight.Bold;
                        cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                          layout.SetText("Datos del Deudor");     Pango.CairoHelper.ShowLayout(cr, layout);
                        layout.FontDescription.Weight = Weight.Normal;
                        comienzo_linea += separacion_linea;
                        cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                          layout.SetText("Nombre: " + lector["nombre_completo"].ToString());        Pango.CairoHelper.ShowLayout(cr, layout);
                        cr.MoveTo(400 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                         layout.SetText("Acepto(amos)"); Pango.CairoHelper.ShowLayout(cr, layout);
                        comienzo_linea += separacion_linea;
                        cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                          layout.SetText("Dirección: " + lector["direccion_paciente"].ToString().Trim() + " " + lector["numero_casa_paciente"].ToString().Trim() + lector["numero_departamento_paciente"].ToString().Trim() + " " + lector["colonia_paciente"].ToString().Trim() + " CP. " + lector["codigo_postal_paciente"].ToString().Trim()); Pango.CairoHelper.ShowLayout(cr, layout);
                        comienzo_linea += separacion_linea;
                        cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                          layout.SetText("Población: " + lector["municipio_paciente"].ToString().Trim() + ", " + lector["estado_paciente"].ToString().Trim());  Pango.CairoHelper.ShowLayout(cr, layout);
                        cr.MoveTo(400 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                         layout.SetText("Firma(s) ___________________________"); Pango.CairoHelper.ShowLayout(cr, layout);
                        comienzo_linea += separacion_linea;
                        comienzo_linea += separacion_linea;
                        layout.FontDescription.Weight = Weight.Bold;
                        cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                          layout.SetText("Datos y firma(s) del(os) Aval(es)");    Pango.CairoHelper.ShowLayout(cr, layout);
                        layout.FontDescription.Weight = Weight.Normal;
                        comienzo_linea += separacion_linea;
                        cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea + 5 * escala_en_linux_windows);                                layout.SetText("Nombre:_____________________________________________________ ");        Pango.CairoHelper.ShowLayout(cr, layout);
                        comienzo_linea += separacion_linea;
                        cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea + 5 * escala_en_linux_windows);                                layout.SetText("Dirección:___________________________________________________");        Pango.CairoHelper.ShowLayout(cr, layout);
                        comienzo_linea += separacion_linea;
                        cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea + 5 * escala_en_linux_windows);                                layout.SetText("Población:_____________________________________________ Telefono :______________");     Pango.CairoHelper.ShowLayout(cr, layout);
                        cr.MoveTo(400 * escala_en_linux_windows, comienzo_linea + 5 * escala_en_linux_windows);                               layout.SetText("Firma(s) ___________________________"); Pango.CairoHelper.ShowLayout(cr, layout);
                    }
                }
            }catch (NpgsqlException ex) {
                MessageDialog msgBoxError = new MessageDialog(MyWinError, DialogFlags.DestroyWithParent,
                                                              MessageType.Warning, ButtonsType.Ok, "PostgresSQL error: {0}", ex.Message);
                msgBoxError.Run();
                msgBoxError.Destroy();
                Console.WriteLine("PostgresSQL error: {0}", ex.Message);
                return;
            }
            conexion.Close();
        }
    static void draw(Cairo.Context gr, int width, int height)
    {
        double x0          = 0.1;
        double y0          = 0.1;
        double rect_width  = 0.8;
        double rect_height = 0.8;
        double radius      = 0.4;

        double x1, y1;

        gr.Scale(width, height);
        gr.LineWidth = 0.04;

        x1 = x0 + rect_width;
        y1 = y0 + rect_height;
        if (rect_width == 0 || rect_height == 0)
        {
            return;
        }

        if (rect_width / 2 < radius)
        {
            if (rect_height / 2 < radius)
            {
                gr.MoveTo(new PointD(x0, (y0 + y1) / 2));

                gr.CurveTo(new PointD(x0, y0),
                           new PointD(x0, y0),
                           new PointD((x0 + x1) / 2, y0)
                           );

                gr.CurveTo(new PointD(x1, y0),
                           new PointD(x1, y0),
                           new PointD(x1, (y0 + y1) / 2)
                           );

                gr.CurveTo(new PointD(x1, y1),
                           new PointD(x1, y1),
                           new PointD((x1 + x0) / 2, y1)
                           );

                gr.CurveTo(new PointD(x0, y1),
                           new PointD(x0, y1),
                           new PointD(x0, (y0 + y1) / 2)
                           );
            }
            else
            {
                gr.MoveTo(new PointD(x0, y0 + radius));

                gr.CurveTo(new PointD(x0, y0),
                           new PointD(x0, y0),
                           new PointD((x0 + x1) / 2, y0)
                           );

                gr.CurveTo(new PointD(x1, y0),
                           new PointD(x1, y0),
                           new PointD(x1, y0 + radius)
                           );

                gr.LineTo(new PointD(x1, y1 - radius));

                gr.CurveTo(new PointD(x1, y1),
                           new PointD(x1, y1),
                           new PointD((x1 + x0) / 2, y1)
                           );

                gr.CurveTo(new PointD(x0, y1),
                           new PointD(x0, y1),
                           new PointD(x0, y1 - radius)
                           );
            }
        }
        else
        {
            if (rect_height / 2 < radius)
            {
                gr.MoveTo(new PointD(x0, (y0 + y1) / 2));

                gr.CurveTo(new PointD(x0, y0),
                           new PointD(x0, y0),
                           new PointD(x0 + radius, y0)
                           );

                gr.LineTo(new PointD(x1 - radius, y0));

                gr.CurveTo(new PointD(x1, y0),
                           new PointD(x1, y0),
                           new PointD(x1, (y0 + y1) / 2)
                           );

                gr.CurveTo(new PointD(x1, y1),
                           new PointD(x1, y1),
                           new PointD(x1 - radius, y1)
                           );

                gr.LineTo(new PointD(x0 + radius, y1));

                gr.CurveTo(new PointD(x0, y1),
                           new PointD(x0, y1),
                           new PointD(x0, (y0 + y1) / 2)
                           );
            }
            else
            {
                gr.MoveTo(new PointD(x0, y0 + radius));

                gr.CurveTo(new PointD(x0, y0),
                           new PointD(x0, y0),
                           new PointD(x0 + radius, y0)
                           );

                gr.LineTo(new PointD(x1 - radius, y0));

                gr.CurveTo(new PointD(x1, y0),
                           new PointD(x1, y0),
                           new PointD(x1, y0 + radius)
                           );

                gr.LineTo(new PointD(x1, y1 - radius));

                gr.CurveTo(new PointD(x1, y1),
                           new PointD(x1, y1),
                           new PointD(x1 - radius, y1)
                           );

                gr.LineTo(new PointD(x0 + radius, y1));
                gr.CurveTo(new PointD(x0, y1),
                           new PointD(x0, y1),
                           new PointD(x0, y1 - radius)
                           );
            }
        }

        gr.Color = new Color(0.5, 0.5, 1, 1);
        gr.FillPreserve();
        gr.Color = new Color(0.5, 0, 0, 0.5);
        gr.Stroke();
    }
示例#51
0
    void draw(object source, ElapsedEventArgs e)
    {
        System.Console.WriteLine("Evaluating code");

        System.Console.WriteLine("Drawing");


        int colOffset = 0;

        using (Cairo.Context cairoContext = CairoHelper.Create(base.GdkWindow))
        {
            for (int x = 0; x < pixelValues.GetLength(0) - 1; x++)
            {
                for (int y = 0; y < pixelValues.GetLength(1) - 1; y++)
                {
                    //pixelValues[x, y] = colOffset;
                    //colOffset++;

                    if (colOffset > 8)
                    {
                        colOffset = 0;
                    }
                    //System.Console.Write(pixelValues[x, y]);
                    if (pixelValues[x, y] != 0)
                    {
                        System.Console.WriteLine("Color ID " + pixelValues[x, y].ToString() + " at point (" + x.ToString() + "," + y.ToString() + ")");
                    }


                    cairoContext.MoveTo(x * sizeMult, y * sizeMult);
                    cairoContext.SetSourceColor(GetColorVal(pixelValues[x, y]));
                    cairoContext.Rectangle(x * sizeMult, y * sizeMult, sizeMult, sizeMult);
                    cairoContext.Fill();


                    //visualBitmap.SetPixel(x, y, GetColorVal(pixelValues[x, y]));
                }
                colOffset++;
            }
        }



        //var data = visualBitmap.LockBits(new System.Drawing.Rectangle(0, 0, visualBitmap.Width, visualBitmap.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
        //Gdk.Pixmap pixmap = new Gdk.Pixmap(data.Scan0);



        currentColor++;
        if (currentColor > 1)
        {
            currentColor = 0;
        }

        //using (Cairo.Context cairoContext = CairoHelper.Create(base.GdkWindow))
        //{
        //    //cairoContext.
        //    for (int x = 0; x < pixelValues.GetLength(0); x++)
        //    {
        //        for (int y = 0; y < pixelValues.GetLength(1); y++)
        //        {

        //        }
        //    }
        //}
        //g.MoveTo(0, 0);

        //g.LineTo(10, 10);
        //Cairo.Color color = new Cairo.Color(1.0, 0.5, 0.5);
        //g.SetSourceColor(color);
        //g.Rectangle(0, 0, 10, 10);
        //g.Fill();
        //g.Stroke();
        System.Console.WriteLine("Done executing");

        interpreter.EvaluateCode(interpreter.gotos[255], true);
    }
示例#52
0
        protected override void DrawContents(Gdk.Drawable d)
        {
            Gdk.GC        gc = new Gdk.GC(d);
            Cairo.Context g  = Gdk.CairoHelper.Create(d);

            g.SelectFontFace("Lucida Console", FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);

            TextExtents te;


            Cairo.Color greenish = new Color(.3, .8, .8);
            Cairo.Color gray     = new Color(.4, .4, .4);
            Cairo.Color white    = new Color(1, 1, 1);

            string lvl, hp, hpm, mp, mpm, s;


            #region Character Status

            d.DrawPixbuf(gc, Graphics.GetProfile(Selected.Name), 0, 0,
                         X + xpic, Y + ypic,
                         Graphics.PROFILE_WIDTH, Graphics.PROFILE_HEIGHT,
                         Gdk.RgbDither.None, 0, 0);

            g.Color = new Color(.3, .8, .8);
            g.MoveTo(X + x3, Y + ya);
            g.ShowText("LV");
            g.MoveTo(X + x3, Y + yb);
            g.ShowText("HP");
            g.MoveTo(X + x3, Y + yc);
            g.ShowText("MP");
            g.Color = new Color(1, 1, 1);

            Graphics.ShadowedText(g, Selected.Name, X + x3, Y + y);

            lvl = Selected.Level.ToString();
            hp  = Selected.HP.ToString() + "/";
            hpm = Selected.MaxHP.ToString();
            mp  = Selected.MP.ToString() + "/";
            mpm = Selected.MaxMP.ToString();

            te = g.TextExtents(lvl);
            Graphics.ShadowedText(g, lvl, X + x4 - te.Width, Y + ya);

            te = g.TextExtents(hp);
            Graphics.ShadowedText(g, hp, X + x5 - te.Width, Y + yb);

            te = g.TextExtents(hpm);
            Graphics.ShadowedText(g, hpm, X + x6 - te.Width, Y + yb);

            te = g.TextExtents(mp);
            Graphics.ShadowedText(g, mp, X + x5 - te.Width, Y + yc);

            te = g.TextExtents(mpm);
            Graphics.ShadowedText(g, mpm, X + x6 - te.Width, Y + yc);

            #endregion Status



            Graphics.ShadowedText(g, greenish, "Attack", X + x0, Y + ym);
            Graphics.ShadowedText(g, greenish, "Halve", X + x0, Y + yn);
            Graphics.ShadowedText(g, greenish, "Void", X + x0, Y + yo);
            Graphics.ShadowedText(g, greenish, "Absorb", X + x0, Y + yp);

            g.SetFontSize(16);

            double x = (double)x1;
            double r = (double)(ym + ys);
            foreach (Element e in Enum.GetValues(typeof(Element)))
            {
                if (x > W - stop)
                {
                    x = x1;
                    r = r + ys;
                }

                s  = e.ToString() + " ";
                te = g.TextExtents(s);
                if (Selected.Halves(e))
                {
                    Graphics.ShadowedText(g, white, e.ToString(), X + x, Y + r);
                }
                else
                {
                    Graphics.ShadowedText(g, gray, e.ToString(), X + x, Y + r);
                }
                x += te.XAdvance;
            }

            x = (double)x1;
            r = (double)(yn + ys);
            foreach (Element e in Enum.GetValues(typeof(Element)))
            {
                if (x > W - stop)
                {
                    x = x1;
                    r = r + ys;
                }

                s  = e.ToString() + " ";
                te = g.TextExtents(s);
                if (Selected.Halves(e))
                {
                    Graphics.ShadowedText(g, white, e.ToString(), X + x, Y + r);
                }
                else
                {
                    Graphics.ShadowedText(g, gray, e.ToString(), X + x, Y + r);
                }
                x += te.XAdvance;
            }

            x = (double)x1;
            r = (double)(yo + ys);
            foreach (Element e in Enum.GetValues(typeof(Element)))
            {
                if (x > W - stop)
                {
                    x = x1;
                    r = r + ys;
                }

                s  = e.ToString() + " ";
                te = g.TextExtents(s);
                if (Selected.Voids(e))
                {
                    Graphics.ShadowedText(g, white, e.ToString(), X + x, Y + r);
                }
                else
                {
                    Graphics.ShadowedText(g, gray, e.ToString(), X + x, Y + r);
                }
                x += te.XAdvance;
            }

            x = (double)x1;
            r = (double)(yp + ys);
            foreach (Element e in Enum.GetValues(typeof(Element)))
            {
                if (x > W - stop)
                {
                    x = x1;
                    r = r + ys;
                }

                s  = e.ToString() + " ";
                te = g.TextExtents(s);
                if (Selected.Absorbs(e))
                {
                    Graphics.ShadowedText(g, white, e.ToString(), X + x, Y + r);
                }
                else
                {
                    Graphics.ShadowedText(g, gray, e.ToString(), X + x, Y + r);
                }
                x += te.XAdvance;
            }



            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }
示例#53
0
 void DrawBar(Cairo.Context gr, int b)
 {
     gr.MoveTo(barStart[b]);
     gr.LineTo(barEnd[b]);
     gr.Stroke();
 }
示例#54
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();
        }
示例#55
0
        void Draw(Cairo.Context ctx, List <TableRow> rowList, int dividerX, int x, ref int y)
        {
            if (!heightMeasured)
            {
                return;
            }

            Pango.Layout layout       = new Pango.Layout(PangoContext);
            TableRow     lastCategory = null;

            foreach (var r in rowList)
            {
                int w, h;
                layout.SetText(r.Label);
                layout.GetPixelSize(out w, out h);
                int indent = 0;

                if (r.IsCategory)
                {
                    var rh = h + CategoryTopBottomPadding * 2;
                    ctx.Rectangle(0, y, Allocation.Width, rh);
                    Cairo.LinearGradient gr = new LinearGradient(0, y, 0, rh);
                    gr.AddColorStop(0, new Cairo.Color(248d / 255d, 248d / 255d, 248d / 255d));
                    gr.AddColorStop(1, new Cairo.Color(240d / 255d, 240d / 255d, 240d / 255d));
                    ctx.SetSource(gr);
                    ctx.Fill();

                    if (lastCategory == null || lastCategory.Expanded || lastCategory.AnimatingExpand)
                    {
                        ctx.MoveTo(0, y + 0.5);
                        ctx.LineTo(Allocation.Width, y + 0.5);
                    }
                    ctx.MoveTo(0, y + rh - 0.5);
                    ctx.LineTo(Allocation.Width, y + rh - 0.5);
                    ctx.SetSourceRGBA(DividerColor.R, DividerColor.G, DividerColor.B, DividerColor.A);

                    ctx.Stroke();

                    ctx.MoveTo(x, y + CategoryTopBottomPadding);
                    ctx.SetSourceRGBA(CategoryLabelColor.R, CategoryLabelColor.G, CategoryLabelColor.B,
                                      CategoryLabelColor.A);
                    Pango.CairoHelper.ShowLayout(ctx, layout);

                    //var img = r.Expanded ? discloseUp : discloseDown;
                    //CairoHelper.SetSourcePixbuf(ctx, img, Allocation.Width - img.Width - CategoryTopBottomPadding, y +(rh - img.Height) / 2);
                    //ctx.Paint();

                    y           += rh;
                    lastCategory = r;
                }
                else
                {
                    var cell = GetCell(r);
                    r.Enabled = !r.Inspector.IsReadOnly || cell.EditsReadOnlyObject;
                    var state = r.Enabled ? State : Gtk.StateType.Insensitive;
                    ctx.Save();
                    ctx.Rectangle(0, y, dividerX, h + InspectorTopBottomPadding * 2);
                    ctx.Clip();
                    ctx.MoveTo(x, y + InspectorTopBottomPadding);
                    Gdk.Color color = Style.Text(state);
                    ctx.SetSourceRGB(color.Red, color.Green, color.Blue);
                    Pango.CairoHelper.ShowLayout(ctx, layout);
                    ctx.Restore();

                    if (r != currentEditorRow)
                    {
                        cell.Render(GdkWindow, r.EditorBounds, state);
                    }

                    y     += r.EditorBounds.Height;
                    indent = InspectorIndent;
                }

                if (r.ChildRows != null && r.ChildRows.Count > 0 && (r.Expanded || r.AnimatingExpand))
                {
                    int py = y;
                    if (r.AnimatingExpand)
                    {
                        ctx.Save();
                        ctx.Rectangle(0, y, Allocation.Width, r.AnimationHeight);
                        ctx.Clip();
                    }

                    Draw(ctx, r.ChildRows, dividerX, x + indent, ref y);

                    if (r.AnimatingExpand)
                    {
                        ctx.Restore();
                        y = py + r.AnimationHeight;
                        // Repaing the background because the cairo clip doesn't work for gdk primitives
                        int dx = (int)((double)Allocation.Width * dividerPosition);
                        ctx.Rectangle(0, y, dx, Allocation.Height - y);
                        ctx.SetSourceRGBA(LabelBackgroundColor.R, LabelBackgroundColor.G,
                                          LabelBackgroundColor.B, LabelBackgroundColor.A);
                        ctx.Fill();
                        ctx.Rectangle(dx + 1, y, Allocation.Width - dx - 1, Allocation.Height - y);
                        ctx.SetSourceRGB(1, 1, 1);
                        ctx.Fill();
                    }
                }
            }
        }