Пример #1
0
        ///<summary>Constructor</summary>
        public Drawer(Gtk.Widget wid, Information inf)
        {
            widget    = wid;
            info      = inf;
            pixmapIds = new StringCollection();
            // make sure highlight colors are set
            info.SetupHighlight(wid);

            fontDescription = Pango.FontDescription.FromString(info.FontName);
            Pango.Language lang = Pango.Language.FromString(info.FontLanguage);

            Pango.Context pangoCtx = widget.PangoContext;
            pangoCtx.FontDescription = fontDescription;
            pangoCtx.Language        = lang;

            // set the font height and width
            pangoLayout = new Pango.Layout(pangoCtx);
            // we use a monospaced font, the actual character doesn't matter
            pangoLayout.SetText("X");
            pangoLayout.GetPixelSize(out width, out height);
            pangoLayout.SetText("");

            // create the font pixmaps
            InitializePixmaps();

            InitializeBackgroundGCs();
        }
Пример #2
0
	void Reload ()
	{
		layout = Layout.Copy ();

		layout.SetText (ellipsis);
		layout.GetPixelSize (out ellipsis_width, out tmp);

		layout.SetText (en_char);
		layout.GetPixelSize (out en_width, out tmp);
	}
Пример #3
0
        /// <summary>
        /// The measure text.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <param name="fontFamily">The font family.</param>
        /// <param name="fontSize">The font size.</param>
        /// <param name="fontWeight">The font weight.</param>
        /// <returns>The size of the text.</returns>
        public override OxySize MeasureText(string text, string fontFamily, double fontSize, double fontWeight)
        {
            if (text == null)
            {
                return(OxySize.Empty);
            }
            this.g.Save();
#if GTKSHARP3
            Pango.Layout layout = new Layout(this.c);
#else
            Pango.Layout layout = Pango.CairoHelper.CreateLayout(this.g);
#endif
            Pango.FontDescription font = new Pango.FontDescription();
            font.Family            = fontFamily;
            font.Weight            = (fontWeight >= 700) ? Pango.Weight.Bold : Pango.Weight.Normal;
            font.AbsoluteSize      = (int)(fontSize * Pango.Scale.PangoScale);
            layout.FontDescription = font;
            layout.SetText(text);
            Pango.Rectangle inkRect;
            Pango.Rectangle logicalRect;
            layout.GetExtents(out inkRect, out logicalRect);
            this.g.Restore();
            layout.Dispose();
            return(new OxySize(logicalRect.Width / Pango.Scale.PangoScale, logicalRect.Height / Pango.Scale.PangoScale));
        }
Пример #4
0
        void imprime_encabezado(Cairo.Context cr, Pango.Layout layout)
        {
            //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);

            fontSize  = 11.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;
            cr.MoveTo(width / 2, 45 * escala_en_linux_windows);  layout.SetText("PACIENTES_NO_INGRESADOS_A_CAJA");       Pango.CairoHelper.ShowLayout(cr, layout);
            //cr.MoveTo(225*escala_en_linux_windows, 35*escala_en_linux_windows);			layout.SetText(titulo_rpt);				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 negrita
        }
Пример #5
0
		void RotatedTextExposeEvent (object sender, ExposeEventArgs a)
		{
			DrawingArea drawingArea = sender as DrawingArea;

			int width = drawingArea.Allocation.Width;
			int height = drawingArea.Allocation.Height;

			double deviceRadius;

			// Get the default renderer for the screen, and set it up for drawing 
			Gdk.PangoRenderer renderer = Gdk.PangoRenderer.GetDefault (drawingArea.Screen);
			renderer.Drawable = drawingArea.GdkWindow;
			renderer.Gc = drawingArea.Style.BlackGC;

			// Set up a transformation matrix so that the user space coordinates for
			// the centered square where we draw are [-RADIUS, RADIUS], [-RADIUS, RADIUS]
			// We first center, then change the scale
			deviceRadius = Math.Min (width, height) / 2;
			Matrix matrix = Pango.Matrix.Identity;
			matrix.Translate (deviceRadius + (width - 2 * deviceRadius) / 2, deviceRadius + (height - 2 * deviceRadius) / 2);
			matrix.Scale (deviceRadius / RADIUS, deviceRadius / RADIUS);

			// Create a PangoLayout, set the font and text
			Context context = drawingArea.CreatePangoContext ();
			Pango.Layout layout = new Pango.Layout (context);
			layout.SetText ("Text");
			FontDescription desc = FontDescription.FromString ("Sans Bold 27");
			layout.FontDescription = desc;

			// Draw the layout N_WORDS times in a circle
			for (int i = 0; i < N_WORDS; i++)
			{
				Gdk.Color color = new Gdk.Color ();
				Matrix rotatedMatrix = matrix;
				int w, h;
				double angle = (360 * i) / N_WORDS;

				// Gradient from red at angle == 60 to blue at angle == 300
				color.Red = (ushort) (65535 * (1 + Math.Cos ((angle - 60) * Math.PI / 180)) / 2);
				color.Green = 0;
				color.Blue = (ushort) (65535 - color.Red);

				renderer.SetOverrideColor (RenderPart.Foreground, color);

				rotatedMatrix.Rotate (angle);
				context.Matrix = rotatedMatrix;

				// Inform Pango to re-layout the text with the new transformation matrix
				layout.ContextChanged ();
				layout.GetSize (out w, out h);
				renderer.DrawLayout (layout, - w / 2, (int) (- RADIUS * Pango.Scale.PangoScale));
			}

			// Clean up default renderer, since it is shared
			renderer.SetOverrideColor (RenderPart.Foreground, Gdk.Color.Zero);
			renderer.Drawable = null;
			renderer.Gc = null;
		}
Пример #6
0
 void OnRealized(object o, EventArgs args)
 {
     layout = new Pango.Layout(PangoContext);
     layout.SingleParagraphMode = false;
     layout.FontDescription     = font;
     layout.Indent = (int)(-Pango.Scale.PangoScale * 20);
     layout.SetText(text);
     Render();
 }
Пример #7
0
        /*
         *      Font drawing using Pango
         *
         * Pango does not work well with float numbers. We should work on
         *      the device unit space and then translate to our user space.
         *
         * Cairo Show.Text paints on the bottom-left of the coordinates
         *      and Pango paints on the top-left of the coordinates
         */

        void SetText(string text)
        {
            if (UseMarkup)
            {
                layout.SetMarkup(text);
            }
            else
            {
                layout.SetText(text);
            }
        }
Пример #8
0
        /// <summary>Dibuja un texto en la superficie de dibujo.</summary>
        /// <param name="c">El color del texto.</param>
        /// <param name="x">La posición x del texto.</param>
        /// <param name="y">La posición y del texto.</param>
        /// <param name="texto">El texto a dibujar en la superficie de dibujo.
        /// </param>
        /// <param name="cent">Indica si el texto está centrado (x e y se
        /// refieren al centro del texto) o no (x e y se refieren a la
        /// esquina superior del texto)</param>

        public void DibujarTexto
            (EnuColor c, int x, int y, String texto, bool cent)
        {
            int anc;
            int alt;

            lock (this)
            {
                if (pixmap != null)
                {
                    if (texto != null)
                    {
                        layout.SetText(texto);
                    }
                    else
                    {
                        layout.SetText(" ");
                    }

                    x = CoordX(x);
                    y = CoordY(y);

                    if (cent)
                    {
                        try
                        {
                            layout.GetSize(out anc, out alt);
                        }
                        catch (System.NullReferenceException)
                        {
                            this.layout = new Pango.Layout(this.PangoContext);
                            return;
                        }

                        x = x - (anc / 2200);
                        y = y - (alt / 2200);
                    }
                    pixmap.DrawLayout(GetGC(c), x, y, layout);
                }
            }
        }
Пример #9
0
 public static void DrawText(this Gtk.Widget widget, int x, int y, string text, Gdk.Color? color = null)
 {
     var layout = new Pango.Layout (widget.PangoContext);
     layout.Width = Pango.Units.FromPixels(20);
     layout.Wrap = Pango.WrapMode.Word;
     layout.Alignment = Pango.Alignment.Center;
     layout.FontDescription = Pango.FontDescription.FromString ("Sans Bold 8");
     layout.SetText(text);
     widget.GdkWindow.DrawLayout (
         widget.Style.TextGC (StateType.Normal),
         x, y, layout
     );
 }
Пример #10
0
        void imprime_encabezado(Cairo.Context cr, Pango.Layout layout)
        {
            Pango.FontDescription desc = Pango.FontDescription.FromString("Sans");
            fontSize  = 8.0;                 layout = null;                  layout = context.CreatePangoLayout();
            desc.Size = (int)(fontSize * pangoScale);               layout.FontDescription = desc;
            layout.FontDescription.Weight = Weight.Bold;                        // Letra normal
            //cr.Rotate(90);  //Imprimir Orizontalmente rota la hoja cambian las posiciones de las lineas y columna
            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;
            cr.MoveTo(width / 2, 45 * escala_en_linux_windows);  layout.SetText("DEVOLUCIONES"); Pango.CairoHelper.ShowLayout(cr, layout);
            fontSize  = 7.0;                 layout = null;                  layout = context.CreatePangoLayout();
            desc.Size = (int)(fontSize * pangoScale);               layout.FontDescription = desc;
            layout.FontDescription.Weight = Weight.Bold;                        // Letra normal
            cr.MoveTo(05 * escala_en_linux_windows, 65 * escala_en_linux_windows);               layout.SetText("N° Atencion: " + numeroatencion);                                 Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(120 * escala_en_linux_windows, 65 * escala_en_linux_windows);              layout.SetText("N° Expe.: " + pidpaciente);                                               Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(220 * escala_en_linux_windows, 65 * 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, 75 * escala_en_linux_windows);               layout.SetText("Procedimiento: ");                              Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(300 * escala_en_linux_windows, 75 * escala_en_linux_windows);              layout.SetText("Diagnostico: ");                                Pango.CairoHelper.ShowLayout(cr, layout);
            cr.Rectangle(05 * escala_en_linux_windows, 85 * 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(18 * escala_en_linux_windows, 88 * escala_en_linux_windows);                      layout.SetText("Codigo");                               Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(150 * escala_en_linux_windows, 88 * escala_en_linux_windows);                     layout.SetText("Descripción Producto"); Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(350 * escala_en_linux_windows, 88 * escala_en_linux_windows);                     layout.SetText("Cargado");      Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(390 * escala_en_linux_windows, 88 * escala_en_linux_windows);                     layout.SetText("Solicitado");           Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(435 * escala_en_linux_windows, 88 * escala_en_linux_windows);                     layout.SetText("Devolucion");           Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(500 * escala_en_linux_windows, 88 * escala_en_linux_windows);                     layout.SetText("Departamento");         Pango.CairoHelper.ShowLayout(cr, layout);
            layout.FontDescription.Weight = Weight.Normal;                      // Letra normal
        }
Пример #11
0
 void DrawTextLine(Cairo.Context g, IReadonlyTextDocument document, int lineNumber, ref int y)
 {
     using (var drawingLayout = new Pango.Layout(this.PangoContext)) {
         drawingLayout.FontDescription = fontDescription;
         var line = document.GetLine(lineNumber);
         var correctedIndentLength = CorrectIndent(document, line, indentLength);
         drawingLayout.SetText(document.GetTextAt(line.Offset + Math.Min(correctedIndentLength, line.Length), Math.Max(0, line.Length - correctedIndentLength)));
         g.Save();
         g.Translate(textBorder, y);
         g.ShowLayout(drawingLayout);
         g.Restore();
         y += lineHeight;
     }
 }
Пример #12
0
        private int GetTextPixelLength(string text, string font)
        {
            int width, height;

            Screen screen = Screen.Default;

            Pango.Layout layout = new Pango.Layout(PangoHelper.ContextGetForScreen(screen));

            layout.FontDescription = Pango.FontDescription.FromString(font);
            layout.SetText(text);
            layout.GetPixelSize(out width, out height);

            return(width);
        }
Пример #13
0
        void CalcVisibleRows()
        {
            int rowWidth;

            layout.SetText("F_B");
            layout.GetPixelSize(out rowWidth, out rowHeight);
            rowHeight = Math.Max(1, rowHeight * 3 / 2);

            int newHeight = rowHeight * CompletionTextEditorExtension.CompletionListRows;

            if (Allocation.Width != listWidth || Allocation.Height != newHeight)
            {
                this.SetSizeRequest(listWidth, newHeight);
            }
            SetAdjustments();
        }
Пример #14
0
        bool SetLayoutText(int n, bool isSelected)
        {
            bool hasMarkup = dataProvider.UseMarkup(n);

            string text = isSelected ? dataProvider.GetSelectedText(n) : dataProvider.GetText(n);

            if (hasMarkup)
            {
                layout.SetMarkup(text ?? "&lt;null&gt;");
            }
            else
            {
                layout.SetText(text ?? "<null>");
            }
            return(hasMarkup);
        }
Пример #15
0
 void MeasureLine(IReadonlyTextDocument document, int lineNumber, ref int x, ref int y)
 {
     using (var drawingLayout = new Pango.Layout(this.PangoContext)) {
         drawingLayout.FontDescription = fontDescription;
         var line          = document.GetLine(lineNumber);
         var indent        = line.GetIndentation(document);
         var curLineIndent = CalcIndentLength(indent);
         if (line.Length == curLineIndent)
         {
             y += lineHeight;
             return;
         }
         if (this.indentLength < 0 || this.indentLength > curLineIndent)
         {
             this.indentLength = curLineIndent;
         }
         drawingLayout.SetText(document.GetTextAt(line));
         int w, h;
         drawingLayout.GetPixelSize(out w, out h);
         x  = Math.Max(x, w);
         y += lineHeight;
     }
 }
Пример #16
0
        protected override void Render (Gdk.Drawable drawable, Widget widget, Gdk.Rectangle background_area,
            Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
        {
            if (source == null || source is SourceManager.GroupSource) {
                return;
            }

            view = widget as SourceView;
            bool selected = view != null && view.Selection.IterIsSelected (iter);
            StateType state = RendererStateToWidgetState (widget, flags);

            RenderSelection (drawable, background_area, selected, state);

            int title_layout_width = 0, title_layout_height = 0;
            int count_layout_width = 0, count_layout_height = 0;
            int max_title_layout_width;

            int img_padding = 6;
            int expander_icon_spacing = 3;
            int x = cell_area.X;
            bool np_etc = (source.Order + Depth * 100) < 40;
            if (!np_etc) {
                x += Depth * img_padding + (int)Xpad;
            } else {
                // Don't indent NowPlaying and Play Queue as much
                x += Math.Max (0, (int)Xpad - 2);
            }

            Gdk.GC main_gc = widget.Style.TextGC (state);

            // Draw the expander if the source has children
            double exp_h = (cell_area.Height - 2.0*Ypad) / 3.2;
            double exp_w = exp_h * 1.6;
            if (view != null && view.Cr != null && source.Children != null && source.Children.Count > 0) {
                var r = new Gdk.Rectangle (x, cell_area.Y + (int)((cell_area.Height - exp_h) / 2.0), (int)exp_w, (int)exp_h);
                view.Theme.DrawArrow (view.Cr, r, source.Expanded ? Math.PI/2.0 : 0.0);
            }

            if (!np_etc) {
                x += (int) exp_w;
                x += 2; // a little spacing after the expander
                expander_right_x = x;
            }

            // Draw icon
            Pixbuf icon = SourceIconResolver.ResolveIcon (source, RowHeight);

            bool dispose_icon = false;
            if (state == StateType.Insensitive) {
                // Code ported from gtk_cell_renderer_pixbuf_render()
                var icon_source = new IconSource () {
                    Pixbuf = icon,
                    Size = IconSize.SmallToolbar,
                    SizeWildcarded = false
                };

                icon = widget.Style.RenderIcon (icon_source, widget.Direction, state,
                    (IconSize)(-1), widget, "SourceRowRenderer");

                dispose_icon = true;
                icon_source.Dispose ();
            }

            if (icon != null) {
                x += expander_icon_spacing;
                drawable.DrawPixbuf (main_gc, icon, 0, 0,
                    x, Middle (cell_area, icon.Height),
                    icon.Width, icon.Height, RgbDither.None, 0, 0);

                x += icon.Width;

                if (dispose_icon) {
                    icon.Dispose ();
                }
            }

            // Setup font info for the title/count, and see if we should show the count
            bool hide_count = source.EnabledCount <= 0 || source.Properties.Get<bool> ("SourceView.HideCount");
            FontDescription fd = widget.PangoContext.FontDescription.Copy ();
            fd.Weight = (ISource)ServiceManager.PlaybackController.NextSource == (ISource)source
                ? Pango.Weight.Bold
                : Pango.Weight.Normal;

            if (view != null && source == view.NewPlaylistSource) {
                fd.Style = Pango.Style.Italic;
                hide_count = true;
            }

            Pango.Layout title_layout = new Pango.Layout (widget.PangoContext);
            Pango.Layout count_layout = null;

            // If we have a count to draw, setup its fonts and see how wide it is to see if we have room
            if (!hide_count) {
                count_layout = new Pango.Layout (widget.PangoContext);
                count_layout.FontDescription = fd;
                count_layout.SetMarkup (String.Format ("<span size=\"small\">{0}</span>", source.EnabledCount));
                count_layout.GetPixelSize (out count_layout_width, out count_layout_height);
            }

            // Hide the count if the title has no space
            max_title_layout_width = cell_area.Width - x - count_layout_width;//(icon == null ? 0 : icon.Width) - count_layout_width - 10;
            if (!hide_count && max_title_layout_width <= 0) {
                hide_count = true;
            }

            // Draw the source Name
            title_layout.FontDescription = fd;
            title_layout.Width = (int)(max_title_layout_width * Pango.Scale.PangoScale);
            title_layout.Ellipsize = EllipsizeMode.End;
            title_layout.SetText (source.Name);
            title_layout.GetPixelSize (out title_layout_width, out title_layout_height);

            x += img_padding;
            drawable.DrawLayout (main_gc, x, Middle (cell_area, title_layout_height), title_layout);

            title_layout.Dispose ();

            // Draw the count
            if (!hide_count) {
                if (view != null && view.Cr != null) {
                    view.Cr.Color = state == StateType.Normal || (view != null && state == StateType.Prelight)
                        ? view.Theme.TextMidColor
                        : view.Theme.Colors.GetWidgetColor (GtkColorClass.Text, state);

                    view.Cr.MoveTo (
                        cell_area.X + cell_area.Width - count_layout_width - 2,
                        cell_area.Y + 0.5 + (double)(cell_area.Height - count_layout_height) / 2.0);
                    PangoCairoHelper.ShowLayout (view.Cr, count_layout);
                }

                count_layout.Dispose ();
            }

            fd.Dispose ();
        }
Пример #17
0
        void HandleM_printDrawPage(object o, DrawPageArgs args)
        {
            // Create a Print Context from the Print Operation
            PrintContext context = args.Context;

            // Create a Cairo Context from the Print Context
            Cairo.Context cr = context.CairoContext;

            // Get the width of the Print Context
            double width = context.Width;

            // Create a rectangle to be used for the Content
            cr.Rectangle(0, 0, width, headerHeight);
            cr.SetSourceRGB(0.95, 0.95, 0.95);
            cr.FillPreserve();

            // Create a Stroke to outline the Content
            cr.SetSourceRGB(0, 0, 0);
            cr.LineWidth = 1;
            cr.Stroke();

            // Create a Pango Layout for the Text
            Pango.Layout layout = context.CreatePangoLayout();
            // Get the Text Height fromt the Height of the layout and the Height of the Page
            int layoutWidth, layoutHeight;

            layout.GetSize(out layoutWidth, out layoutHeight);
            double textHeight = (double)layoutHeight / (double)pangoScale;

            cr.MoveTo(5, (headerHeight - textHeight) / 2);

            // Set the Font and Font Size desired
            Pango.FontDescription desc = Pango.FontDescription.FromString("sans 12");
            layout.FontDescription = desc;

            // Create a Header with the FileName and center it on the page
            layout.SetText(m_cache.Name + " : " + m_cache.CacheName);
            //layout.Width = (int) width *3;
            layout.Alignment = Pango.Alignment.Left;
            Pango.CairoHelper.ShowLayout(cr, layout);


            // cr.MoveTo (width/2, (headerHeight - textHeight) / 2);


            // Set the Page Number in the Footer with a right alignment
            string pageStr = String.Format(Catalog.GetString("Page {0} of {1}"), args.PageNr + 1, m_numPages);

            layout.SetText(pageStr);
            layout.Alignment = Pango.Alignment.Right;

            cr.MoveTo(width - 75, (headerHeight - textHeight) / 2);
            Pango.CairoHelper.ShowLayout(cr, layout);

            // Create a new Pango Layout for the Content
            layout = null;
            layout = context.CreatePangoLayout();

            // Set the Description of the Content
            desc      = Pango.FontDescription.FromString("sans");
            desc.Size = (int)(m_fontSize * pangoScale);
            layout.FontDescription = desc;

            // Move to the beginning of the Content, which is after the Header Height and Gap
            cr.MoveTo(0, headerHeight + headerGap);

            int line = args.PageNr * m_linesPerPage;

            // Draw the lines on the page according to how many lines there are left and how many lines can fit on the page
            for (int i = 0; i < m_linesPerPage && line < m_numLines; i++)
            {
                layout.SetMarkup(m_Lines[line].TrimStart());
                Pango.CairoHelper.ShowLayout(cr, layout);
                cr.RelMoveTo(0, m_fontSize + 0.5);
                line++;
            }

            layout = null;
            context.Dispose();
        }
		void DrawTextLine (Cairo.Context g, IReadonlyTextDocument document, int lineNumber, ref int y)
		{
			using (var drawingLayout = new Pango.Layout (this.PangoContext)) {
				drawingLayout.FontDescription = fontDescription;
				var line = document.GetLine (lineNumber);
				var correctedIndentLength = CorrectIndent (document, line, indentLength);
				drawingLayout.SetText (document.GetTextAt (line.Offset + Math.Min (correctedIndentLength, line.Length), Math.Max (0, line.Length - correctedIndentLength)));
				g.Save ();
				g.Translate (textBorder, y);
				g.ShowLayout (drawingLayout);
				g.Restore ();
				y += lineHeight;
			}
		}
Пример #19
0
			void OnRealized (object o, EventArgs args) {
				layout = new Pango.Layout(PangoContext);
				layout.SingleParagraphMode = false;
				layout.FontDescription = font;
				layout.Indent = (int)(-Pango.Scale.PangoScale * 20);
				
				layout.SetText(text);
				Render();
			}
Пример #20
0
        protected override void OnRender(Cairo.Context cr, Widget widget, Gdk.Rectangle background_area,
                                         Gdk.Rectangle cell_area, CellRendererState flags)
        {
            if (source == null || source is SourceManager.GroupSource)
            {
                return;
            }

            view = widget as SourceView;
            bool       selected = view != null && view.Selection.IterIsSelected(iter);
            StateFlags state    = RendererStateToWidgetState(widget, flags);

            RenderBackground(cr, background_area, selected, state);

            int title_layout_width = 0, title_layout_height = 0;
            int count_layout_width = 0, count_layout_height = 0;
            int max_title_layout_width;

            int  img_padding           = 6;
            int  expander_icon_spacing = 3;
            int  x      = cell_area.X;
            bool np_etc = (source.Order + Depth * 100) < 40;

            if (!np_etc)
            {
                x += Depth * img_padding + (int)Xpad;
            }
            else
            {
                // Don't indent NowPlaying and Play Queue as much
                x += Math.Max(0, (int)Xpad - 2);
            }

            // Draw the expander if the source has children
            double exp_h = (cell_area.Height - 2.0 * Ypad) / 2.0;
            double exp_w = exp_h * 1.6;
            int    y     = Middle(cell_area, (int)exp_h);

            if (view != null && source.Children != null && source.Children.Count > 0)
            {
                var r = new Gdk.Rectangle(x, y, (int)exp_w, (int)exp_h);
                view.Theme.DrawArrow(cr, r, source.Expanded ? Math.PI / 2.0 : 0.0);
            }

            if (!np_etc)
            {
                x += (int)exp_w;
                x += 2; // a little spacing after the expander
                expander_right_x = x;
            }

            // Draw icon
            Pixbuf icon = SourceIconResolver.ResolveIcon(source, RowHeight);

            bool dispose_icon = false;

            if (state == StateFlags.Insensitive)
            {
                // Code ported from gtk_cell_renderer_pixbuf_render()
                var icon_source = new IconSource()
                {
                    Pixbuf         = icon,
                    Size           = IconSize.SmallToolbar,
                    SizeWildcarded = false
                };

                icon = widget.StyleContext.RenderIconPixbuf(icon_source, (IconSize)(-1));

                dispose_icon = true;
                icon_source.Dispose();
            }

            if (icon != null)
            {
                x += expander_icon_spacing;

                cr.Save();
                Gdk.CairoHelper.SetSourcePixbuf(cr, icon, x, Middle(cell_area, icon.Height));
                cr.Paint();
                cr.Restore();

                x += icon.Width;

                if (dispose_icon)
                {
                    icon.Dispose();
                }
            }

            // Setup font info for the title/count, and see if we should show the count
            bool            hide_count = source.EnabledCount <= 0 || source.Properties.Get <bool> ("SourceView.HideCount");
            FontDescription fd         = widget.PangoContext.FontDescription.Copy();

            fd.Weight = (ISource)ServiceManager.PlaybackController.NextSource == (ISource)source
                ? Pango.Weight.Bold
                : Pango.Weight.Normal;

            if (view != null && source == view.NewPlaylistSource)
            {
                fd.Style   = Pango.Style.Italic;
                hide_count = true;
            }

            Pango.Layout title_layout = new Pango.Layout(widget.PangoContext);
            Pango.Layout count_layout = null;

            // If we have a count to draw, setup its fonts and see how wide it is to see if we have room
            if (!hide_count)
            {
                count_layout = new Pango.Layout(widget.PangoContext);
                count_layout.FontDescription = fd;
                count_layout.SetMarkup(String.Format("<span size=\"small\">{0}</span>", source.EnabledCount));
                count_layout.GetPixelSize(out count_layout_width, out count_layout_height);
            }

            // Hide the count if the title has no space
            max_title_layout_width = cell_area.Width - x - count_layout_width;//(icon == null ? 0 : icon.Width) - count_layout_width - 10;
            if (!hide_count && max_title_layout_width <= 0)
            {
                hide_count = true;
            }

            // Draw the source Name
            title_layout.FontDescription = fd;
            title_layout.Width           = (int)(max_title_layout_width * Pango.Scale.PangoScale);
            title_layout.Ellipsize       = EllipsizeMode.End;
            title_layout.SetText(source.Name);
            title_layout.GetPixelSize(out title_layout_width, out title_layout_height);

            x += img_padding;
            widget.StyleContext.RenderLayout(cr, x, Middle(cell_area, title_layout_height), title_layout);

            title_layout.Dispose();

            // Draw the count
            if (!hide_count)
            {
                if (view != null)
                {
                    cr.SetSourceColor(state == StateFlags.Normal || (view != null && state == StateFlags.Prelight)
                        ? view.Theme.TextMidColor
                        : CairoExtensions.GdkRGBAToCairoColor(view.Theme.Widget.StyleContext.GetColor(state)));

                    cr.MoveTo(
                        cell_area.X + cell_area.Width - count_layout_width - 2,
                        cell_area.Y + 0.5 + (double)(cell_area.Height - count_layout_height) / 2.0);
                    Pango.CairoHelper.ShowLayout(cr, count_layout);
                }

                count_layout.Dispose();
            }

            fd.Dispose();
        }
Пример #21
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, comienzo_linea * escala_en_linux_windows);                   layout.SetText(classpublic.nombre_empresa);                     Pango.CairoHelper.ShowLayout(cr, layout);
            fontSize  = 6.0;
            desc.Size = (int)(fontSize * pangoScale);                                       layout.FontDescription = desc;
            layout.FontDescription.Weight = Weight.Normal;                      // Letra normal
            cr.MoveTo(479 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                  layout.SetText("Fech.Rpt:" + (string)DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));              Pango.CairoHelper.ShowLayout(cr, layout);

            comienzo_linea += separacion_linea;
            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, comienzo_linea * escala_en_linux_windows);                   layout.SetText(classpublic.direccion_empresa);          Pango.CairoHelper.ShowLayout(cr, layout);
            fontSize  = 6.0;
            desc.Size = (int)(fontSize * pangoScale);                                       layout.FontDescription = desc;
            layout.FontDescription.Weight = Weight.Normal;                      // Letra normal
            cr.MoveTo(479 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                  layout.SetText("N° Page :" + numpage.ToString().Trim());          Pango.CairoHelper.ShowLayout(cr, layout);

            comienzo_linea += separacion_linea;
            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, comienzo_linea * escala_en_linux_windows);                   layout.SetText(classpublic.telefonofax_empresa);        Pango.CairoHelper.ShowLayout(cr, layout);

            comienzo_linea += separacion_linea;
            fontSize        = 6.0;
            desc.Size       = (int)(fontSize * pangoScale);                                       layout.FontDescription = desc;
            cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                   layout.SetText("Sistema Hospitalario OSIRIS");          Pango.CairoHelper.ShowLayout(cr, layout);

            comienzo_linea += separacion_linea;
            comienzo_linea += separacion_linea;
            fontSize        = 10.0;
            desc.Size       = (int)(fontSize * pangoScale);                                       layout.FontDescription = desc;
            layout.FontDescription.Weight = Weight.Bold;                        // Letra negrita
            cr.MoveTo(200 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                 layout.SetText("RESULTADOS DE LABORATORIO");                            Pango.CairoHelper.ShowLayout(cr, layout);
            layout.FontDescription.Weight = Weight.Normal;                      // Letra normal
            // Cambiando el tamaño de la fuente
            comienzo_linea += separacion_linea;
            comienzo_linea += separacion_linea;

            cr.Rectangle(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows, 570 * escala_en_linux_windows, 70 * 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;
            cr.MoveTo(07 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);          layout.SetText("Fecha Solicitud: " + fecha_solucitud);    Pango.CairoHelper.ShowLayout(cr, layout);
            //cr.MoveTo(250*escala_en_linux_windows,comienzo_linea*escala_en_linux_windows);		layout.SetText("N° de Solicitud: ");			Pango.CairoHelper.ShowLayout (cr, layout);
            cr.MoveTo(400 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);          layout.SetText("Fecha Validacion: ");                                           Pango.CairoHelper.ShowLayout(cr, layout);
            comienzo_linea += separacion_linea;
            layout.FontDescription.Weight = Weight.Bold;                        // Letra negrita
            cr.MoveTo(07 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);           layout.SetText("N° Atencion: " + folioservicio.ToString().Trim());        Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(120 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);          layout.SetText("N° Expe.: " + PidPaciente.ToString().Trim());             Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(220 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);          layout.SetText("Nombre Paciente: " + nombre_paciente);    Pango.CairoHelper.ShowLayout(cr, layout);
            comienzo_linea += separacion_linea;
            cr.MoveTo(07 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);           layout.SetText("Fecha Nacimiento: " + fecha_nac); Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(250 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);          layout.SetText("Edad: " + edadpac + " Años");                               Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(400 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);          layout.SetText("Sexo: " + sexopaciente);                  Pango.CairoHelper.ShowLayout(cr, layout);
            layout.FontDescription.Weight = Weight.Normal;
            comienzo_linea += separacion_linea;
            cr.MoveTo(07 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);           layout.SetText("Procedimiento: ");      Pango.CairoHelper.ShowLayout(cr, layout);
            comienzo_linea += separacion_linea;
            cr.MoveTo(07 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);           layout.SetText("Diagnostico Admision: ");       Pango.CairoHelper.ShowLayout(cr, layout);
            comienzo_linea += separacion_linea;
            cr.MoveTo(07 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);           layout.SetText("Medico Tratante: " + medicotratante);     Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(400 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);          layout.SetText("Habitacion: ");         Pango.CairoHelper.ShowLayout(cr, layout);
            comienzo_linea += separacion_linea;
            cr.MoveTo(07 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);           layout.SetText("Departamento quien Solicita: " + procedencia);    Pango.CairoHelper.ShowLayout(cr, layout);
            comienzo_linea += separacion_linea;
        }
Пример #22
0
        void ejecutar_consulta_reporte(PrintContext context)
        {
            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;                 layout = null;                  layout = context.CreatePangoLayout();
            desc.Size = (int)(fontSize * pangoScale);               layout.FontDescription = desc;

            imprime_encabezado(cr, layout);
            comienzo_linea += separacion_linea;
            //cr.Rotate(90);  //Imprimir Orizontalmente rota la hoja cambian las posiciones de las lineas y columna
            fontSize  = 9.0;
            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(this.nombre_estudio);            Pango.CairoHelper.ShowLayout(cr, layout);
            layout.FontDescription.Weight = Weight.Normal;                      // Letra negrita

            cr.MoveTo(570 * escala_en_linux_windows, (comienzo_linea + separacion_linea) * escala_en_linux_windows);
            cr.LineTo(05, comienzo_linea + separacion_linea);                   // Linea Horizontal 4
            cr.Stroke();

            fontSize        = 8.0;
            desc.Size       = (int)(fontSize * pangoScale);                                       layout.FontDescription = desc;
            comienzo_linea += separacion_linea;
            comienzo_linea += separacion_linea;
            cr.MoveTo(100 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                  layout.SetText("PARAMETROS");           Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(250 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                  layout.SetText("RESULTADOS");           Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(400 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                  layout.SetText("V.R.");         Pango.CairoHelper.ShowLayout(cr, layout);
            comienzo_linea += separacion_linea;
            comienzo_linea += separacion_linea;

            int lineahorizontal = comienzo_linea;

            TreeIter iter;

            if (this.treeViewEngineresultados.GetIterFirst(out iter))
            {
                if ((bool)this.lista_de_resultados.Model.GetValue(iter, 5) == true)
                {
                    if ((string)this.lista_de_resultados.Model.GetValue(iter, 0) != "")
                    {
                        cr.MoveTo(570 * escala_en_linux_windows, (comienzo_linea) * escala_en_linux_windows);
                        cr.LineTo(05, comienzo_linea);                                  // Linea Horizontal 4
                        cr.LineWidth = 0.1;
                        cr.Stroke();
                    }
                    cr.MoveTo(25 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                   layout.SetText((string)this.lista_de_resultados.Model.GetValue(iter, 0));              Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(230 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                  layout.SetText((string)this.lista_de_resultados.Model.GetValue(iter, 1));              Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(360 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                  layout.SetText((string)this.lista_de_resultados.Model.GetValue(iter, 2));              Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(570 * escala_en_linux_windows, (comienzo_linea + separacion_linea) * escala_en_linux_windows);
                    cr.LineTo(05, comienzo_linea + separacion_linea);                           // Linea Horizontal 4
                    cr.Stroke();
                    comienzo_linea += separacion_linea;
                }
                while (treeViewEngineresultados.IterNext(ref iter))
                {
                    if ((bool)this.lista_de_resultados.Model.GetValue(iter, 5) == true)
                    {
                        if ((string)this.lista_de_resultados.Model.GetValue(iter, 0) != "")
                        {
                            cr.MoveTo(570 * escala_en_linux_windows, (comienzo_linea) * escala_en_linux_windows);
                            cr.LineTo(05, comienzo_linea);                                      // Linea Horizontal 4
                            cr.LineWidth = 0.1;
                            cr.Stroke();
                        }
                        cr.MoveTo(25 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                   layout.SetText((string)this.lista_de_resultados.Model.GetValue(iter, 0));              Pango.CairoHelper.ShowLayout(cr, layout);
                        cr.MoveTo(230 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                  layout.SetText((string)this.lista_de_resultados.Model.GetValue(iter, 1));              Pango.CairoHelper.ShowLayout(cr, layout);
                        cr.MoveTo(360 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);                  layout.SetText((string)this.lista_de_resultados.Model.GetValue(iter, 2));              Pango.CairoHelper.ShowLayout(cr, layout);
                        comienzo_linea += separacion_linea;
                    }
                }
            }
            cr.MoveTo(570 * escala_en_linux_windows, (comienzo_linea) * escala_en_linux_windows);
            cr.LineTo(05, comienzo_linea);
            cr.LineWidth = 0.1;

            cr.MoveTo(05 * escala_en_linux_windows, lineahorizontal * escala_en_linux_windows);
            cr.LineTo(05, comienzo_linea);

            cr.MoveTo(570 * escala_en_linux_windows, lineahorizontal * escala_en_linux_windows);
            cr.LineTo(570, comienzo_linea);

            cr.Stroke();
            comienzo_linea += separacion_linea;
            comienzo_linea += separacion_linea;
            cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);           layout.SetText("Observaciones: " + observa);              Pango.CairoHelper.ShowLayout(cr, layout);

            cr.MoveTo(300 * escala_en_linux_windows, 660 * escala_en_linux_windows);             layout.SetText("Quimico: ");            Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(300 * escala_en_linux_windows, 670 * escala_en_linux_windows);             layout.SetText(quimicoautorizado);      Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(300 * escala_en_linux_windows, 680 * escala_en_linux_windows);             layout.SetText("Ced.Prof. " + cedulaquimico);             Pango.CairoHelper.ShowLayout(cr, 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/firma_quimica.jpg");               // en Linux
            //image5.Pixbuf.ScaleSimple(128, 128, Gdk.InterpType.Bilinear);
            //Gdk.CairoHelper.SetSourcePixbuf(cr,image5.Pixbuf,05,comienzo_linea*escala_en_linux_windows);
            //Gdk.CairoHelper.SetSourcePixbuf(cr,image5.Pixbuf.ScaleSimple(145, 50, Gdk.InterpType.Bilinear),1,1);
            //Gdk.CairoHelper.SetSourcePixbuf(cr,image5.Pixbuf.ScaleSimple(130, 91, Gdk.InterpType.Bilinear),300*escala_en_linux_windows,570*escala_en_linux_windows);
            Gdk.CairoHelper.SetSourcePixbuf(cr, image5.Pixbuf, 300 * escala_en_linux_windows, 570 * escala_en_linux_windows);
            cr.Fill();
            cr.Paint();
            cr.Restore();
        }
Пример #23
0
        private void DrawStringTBLR(PageText pt, Cairo.Context g, Cairo.Rectangle r)
        {
            StyleInfo si = pt.SI;
            string    s  = pt.Text;

            g.Save();

            layout = CairoHelper.CreateLayout(g);

            //Pango fonts are scaled to 72dpi, Windows fonts uses 96dpi
            float fontsize = (si.FontSize * 72 / 96);
            var   font     = FontDescription.FromString($"{si.GetFontFamily().Name} {fontsize * PixelsX(1)}");

            if (si.FontStyle == FontStyleEnum.Italic)
            {
                font.Style = Style.Italic;
            }

            switch (si.FontWeight)
            {
            case FontWeightEnum.Bold:
            case FontWeightEnum.Bolder:
            case FontWeightEnum.W500:
            case FontWeightEnum.W600:
            case FontWeightEnum.W700:
            case FontWeightEnum.W800:
            case FontWeightEnum.W900:
                font.Weight = Weight.Bold;
                break;
            }

            FontDescription oldfont = layout.FontDescription;

            layout.FontDescription = font;

            switch (si.TextAlign)
            {
            case TextAlignEnum.Right:
                layout.Alignment = Alignment.Right;
                break;

            case TextAlignEnum.Center:
                layout.Alignment = Alignment.Center;
                break;

            case TextAlignEnum.Left:
            default:
                layout.Alignment = Alignment.Left;
                break;
            }

            layout.Width = Units.FromPixels((int)(r.Height - si.PaddingTop - si.PaddingBottom - 2));

            layout.Wrap = WrapMode.WordChar;
            layout.SetText(s);

            Rectangle logical;
            Rectangle ink;

            layout.GetExtents(out ink, out logical);
            double height = logical.Height / Scale.PangoScale;
            double y      = 0;
            double x      = 0;

            switch (si.VerticalAlign)
            {
            case VerticalAlignEnum.Top:
                x = r.X + si.PaddingLeft;
                break;

            case VerticalAlignEnum.Middle:
                x = r.X + (r.Width - height) / 2;
                break;

            case VerticalAlignEnum.Bottom:
                x = r.X + (r.Width - height) + si.PaddingLeft;
                break;
            }

            // draw the background
            DrawBackground(g, r, si);

            Cairo.Rectangle box = new Cairo.Rectangle(
                x,
                r.Y + r.Height - si.PaddingBottom - 1,
                r.Height - si.PaddingBottom - si.PaddingTop,
                r.Width - si.PaddingLeft + si.PaddingRight);

            g.Color = si.Color.ToCairoColor();

            g.Rotate(270 * Math.PI / 180.0);
            CairoHelper.UpdateLayout(g, layout);

            g.MoveTo(-box.Y, box.X);
            CairoHelper.ShowLayout(g, layout);

            layout.FontDescription = oldfont;
            g.Restore();
        }
		void MeasureLine (IReadonlyTextDocument document, int lineNumber, ref int x, ref int y)
		{
			using (var drawingLayout = new Pango.Layout (this.PangoContext)) {
				drawingLayout.FontDescription = fontDescription;
				var line = document.GetLine (lineNumber);
				var indent = line.GetIndentation (document);
				var curLineIndent = CalcIndentLength(indent);
				if (line.Length == curLineIndent) {
					y += lineHeight;
					return;
				}
				if (this.indentLength < 0 || this.indentLength > curLineIndent)
					this.indentLength = curLineIndent;
				drawingLayout.SetText (document.GetTextAt (line));
				int w, h;
				drawingLayout.GetPixelSize (out w, out h);
				x = Math.Max (x, w);
				y += lineHeight;
			}
		}
Пример #25
0
        void imprime_encabezado(Cairo.Context cr, Pango.Layout 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;
            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(290 * escala_en_linux_windows, 25 * escala_en_linux_windows);            layout.SetText(titulo);                    Pango.CairoHelper.ShowLayout(cr, layout);

            fontSize  = 8.0;
            desc.Size = (int)(fontSize * pangoScale);                    layout.FontDescription = desc;
            cr.MoveTo(200 * escala_en_linux_windows, 35 * escala_en_linux_windows);            layout.SetText("Departamento : ");                    Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(350 * escala_en_linux_windows, 35 * escala_en_linux_windows);            layout.SetText("Rango de Fecha : " + rango_fecha);         Pango.CairoHelper.ShowLayout(cr, layout);

            fontSize  = 6.0;
            desc.Size = (int)(fontSize * pangoScale);                    layout.FontDescription = desc;
            cr.MoveTo(10 * escala_en_linux_windows, 60 * escala_en_linux_windows);            layout.SetText("CODIGO");        Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(95 * escala_en_linux_windows, 60 * escala_en_linux_windows);            layout.SetText("DESCRIPCION PRODUCTO");        Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(19 * escala_en_linux_windows, 70 * escala_en_linux_windows);            layout.SetText("N° ATENCION");        Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(65 * escala_en_linux_windows, 70 * escala_en_linux_windows);            layout.SetText("FECHA/HORA");        Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(125 * escala_en_linux_windows, 70 * escala_en_linux_windows);            layout.SetText("CANT.");                    Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(145 * escala_en_linux_windows, 70 * escala_en_linux_windows);            layout.SetText("EXPED.");                    Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(190 * escala_en_linux_windows, 70 * escala_en_linux_windows);            layout.SetText("NOMBRE DEL PACIENTE");                    Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(360 * escala_en_linux_windows, 70 * escala_en_linux_windows);            layout.SetText("TIPO PACIENTE");                    Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(470 * escala_en_linux_windows, 70 * escala_en_linux_windows);            layout.SetText("INSTITUCION O EMPRESA");                    Pango.CairoHelper.ShowLayout(cr, layout);

            //cr.MoveTo(750*escala_en_linux_windows, 60*escala_en_linux_windows);
            //cr.LineTo(05,60);		// Linea Horizontal 1
            //cr.FillExtents();  //. FillPreserve();
            //cr.SetSourceRGB (0, 0, 0);
            //cr.LineWidth = 0.3;
            //cr.Stroke();

            // Creacion del
            cr.Rectangle(05 * escala_en_linux_windows, 55 * escala_en_linux_windows, 750 * escala_en_linux_windows, 25 * escala_en_linux_windows);
            cr.FillExtents();              //. FillPreserve();
            cr.SetSourceRGB(0, 0, 0);
            cr.LineWidth = 0.3;
            cr.Stroke();
        }
        protected override void Render (Gdk.Drawable drawable, Widget widget, Gdk.Rectangle background_area,
            Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
        {
            if (source == null) {
                return;
            }

            view = widget as SourceView;
            bool selected = view != null && view.Selection.IterIsSelected (iter);
            StateType state = RendererStateToWidgetState (widget, flags);

            RenderSelection (drawable, background_area, selected, state);

            int title_layout_width = 0, title_layout_height = 0;
            int count_layout_width = 0, count_layout_height = 0;
            int max_title_layout_width;

            bool hide_counts = source.EnabledCount <= 0;

            Pixbuf icon = SourceIconResolver.ResolveIcon (source, RowHeight);

            bool dispose_icon = false;
            if (state == StateType.Insensitive) {
                // Code ported from gtk_cell_renderer_pixbuf_render()
                var icon_source = new IconSource () {
                    Pixbuf = icon,
                    Size = IconSize.SmallToolbar,
                    SizeWildcarded = false
                };

                icon = widget.Style.RenderIcon (icon_source, widget.Direction, state,
                    (IconSize)(-1), widget, "SourceRowRenderer");

                dispose_icon = true;
                icon_source.Dispose ();
            }

            FontDescription fd = widget.PangoContext.FontDescription.Copy ();
            fd.Weight = (ISource)ServiceManager.PlaybackController.NextSource == (ISource)source
                ? Pango.Weight.Bold
                : Pango.Weight.Normal;

            if (view != null && source == view.NewPlaylistSource) {
                fd.Style = Pango.Style.Italic;
                hide_counts = true;
            }

            Pango.Layout title_layout = new Pango.Layout (widget.PangoContext);
            Pango.Layout count_layout = null;

            if (!hide_counts) {
                count_layout = new Pango.Layout (widget.PangoContext);
                count_layout.FontDescription = fd;
                count_layout.SetMarkup (String.Format ("<span size=\"small\">{0}</span>", source.EnabledCount));
                count_layout.GetPixelSize (out count_layout_width, out count_layout_height);
            }

            max_title_layout_width = cell_area.Width - (icon == null ? 0 : icon.Width) - count_layout_width - 10;

            if (!hide_counts && max_title_layout_width < 0) {
                hide_counts = true;
            }

            title_layout.FontDescription = fd;
            title_layout.Width = (int)(max_title_layout_width * Pango.Scale.PangoScale);
            title_layout.Ellipsize = EllipsizeMode.End;
            title_layout.SetText (source.Name);
            title_layout.GetPixelSize (out title_layout_width, out title_layout_height);

            Gdk.GC main_gc = widget.Style.TextGC (state);

            drawable.DrawLayout (main_gc,
                cell_area.X + (icon == null ? 0 : icon.Width) + 6,
                Middle (cell_area, title_layout_height),
                title_layout);

            title_layout.Dispose ();

            if (icon != null) {
                drawable.DrawPixbuf (main_gc, icon, 0, 0,
                    cell_area.X, Middle (cell_area, icon.Height),
                    icon.Width, icon.Height, RgbDither.None, 0, 0);

                if (dispose_icon) {
                    icon.Dispose ();
                }
            }

            if (hide_counts) {
                fd.Dispose ();
                return;
            }

            if (view != null && view.Cr != null) {
                view.Cr.Color = state == StateType.Normal || (view != null && state == StateType.Prelight)
                    ? view.Theme.TextMidColor
                    : view.Theme.Colors.GetWidgetColor (GtkColorClass.Text, state);

                view.Cr.MoveTo (
                    cell_area.X + cell_area.Width - count_layout_width - 2,
                    cell_area.Y + 0.5 + (double)(cell_area.Height - count_layout_height) / 2.0);
                PangoCairoHelper.ShowLayout (view.Cr, count_layout);
            }

            count_layout.Dispose ();
            fd.Dispose ();
        }
Пример #27
0
	// FIXME Cache the GCs?
	private void DrawCell (int thumbnail_num, Gdk.Rectangle area)
	{
		Gdk.Rectangle bounds = CellBounds (thumbnail_num);
		
		if (!bounds.Intersect (area, out area))
			return;
		
		FSpot.IBrowsableItem photo = collection [thumbnail_num];
		string thumbnail_path = FSpot.ThumbnailGenerator.ThumbnailPath (photo.DefaultVersionUri);
		
		FSpot.PixbufCache.CacheEntry entry = cache.Lookup (thumbnail_path);
		if (entry == null)
			cache.Request (thumbnail_path, thumbnail_num, ThumbnailWidth, ThumbnailHeight);
		else
			entry.Data = thumbnail_num;

		bool selected = selection.Contains (thumbnail_num);
		StateType cell_state = selected ? (HasFocus ? StateType.Selected : StateType.Active) : State;
		
		if (cell_state != State)
			Style.PaintBox (Style, BinWindow, cell_state, 
					ShadowType.Out, area, this, "IconView", 
					bounds.X, bounds.Y,
					bounds.Width - 1, bounds.Height - 1);
		
		Gdk.Rectangle focus = Gdk.Rectangle.Inflate (bounds, -3, -3);

		if (HasFocus && thumbnail_num == FocusCell) {
			Style.PaintFocus(Style, BinWindow, 
					 cell_state, area, 
					 this, null, 
					 focus.X, focus.Y, 
					 focus.Width, focus.Height);
		}

		Gdk.Rectangle region = Gdk.Rectangle.Zero;
		Gdk.Rectangle image_bounds = Gdk.Rectangle.Inflate (bounds, -cell_border_width, -cell_border_width);
		int expansion = ThrobExpansion (thumbnail_num, selected);

		Gdk.Pixbuf thumbnail = null;
		if (entry != null)
			thumbnail = entry.ShallowCopyPixbuf ();

		if (Gdk.Rectangle.Inflate (image_bounds, expansion + 1, expansion + 1).Intersect (area, out image_bounds) && thumbnail != null) {
			
			PixbufUtils.Fit (thumbnail, ThumbnailWidth, ThumbnailHeight, 
					 true, out region.Width, out region.Height);
			
			region.X = (int) (bounds.X + (bounds.Width - region.Width) / 2);
			region.Y = (int) bounds.Y + ThumbnailHeight - region.Height + cell_border_width;
			
			if (region.Width != thumbnail.Width && region.Height != thumbnail.Height)
				cache.Reload (entry, thumbnail_num, thumbnail.Width, thumbnail.Height);

			region = Gdk.Rectangle.Inflate (region, expansion, expansion);
			Pixbuf temp_thumbnail;			
			region.Width = System.Math.Max (1, region.Width);
			region.Height = System.Math.Max (1, region.Height); 

			if (region.Width != thumbnail.Width && region.Height != thumbnail.Height) {
				if (region.Width < thumbnail.Width && region.Height < thumbnail.Height) {
					/*
					temp_thumbnail = PixbufUtils.ScaleDown (thumbnail, 
										region.Width, region.Height);
					*/
					temp_thumbnail = thumbnail.ScaleSimple (region.Width, region.Height,
										InterpType.Bilinear);
									      
					
					lock (entry) {
						if (entry.Reload && expansion == 0 && !entry.IsDisposed) {
							entry.SetPixbufExtended (PixbufUtils.ShallowCopy (temp_thumbnail), false);
							entry.Reload = true;
						}
					}
				} else {
					temp_thumbnail = thumbnail.ScaleSimple (region.Width, region.Height, 
										InterpType.Bilinear);
				}

				PixbufUtils.CopyThumbnailOptions (thumbnail, temp_thumbnail);
			} else
				temp_thumbnail = thumbnail;

			// FIXME There seems to be a rounding issue between the
			// scaled thumbnail sizes, we avoid this for now by using
			// the actual thumnail sizes here.
			region.Width = temp_thumbnail.Width;
			region.Height = temp_thumbnail.Height;
			
			Gdk.Rectangle draw = Gdk.Rectangle.Inflate (region, 1, 1);
			
			if (!temp_thumbnail.HasAlpha) 
				Style.PaintShadow (Style, BinWindow, cell_state,
						   ShadowType.Out, area, this, 
						   "IconView", 
						   draw.X, draw.Y, 
						   draw.Width, draw.Height);			
			
			if (region.Intersect (area, out draw)) {
				temp_thumbnail.RenderToDrawable (BinWindow, Style.WhiteGC,
								 draw.X - region.X, 
								 draw.Y - region.Y, 
								 draw.X, draw.Y, 
								 draw.Width, draw.Height, 
								 RgbDither.None, 
								 draw.X, draw.Y);
			}
			
			if (temp_thumbnail != thumbnail) {
				temp_thumbnail.Dispose ();
			}
			
		}
		
		if (thumbnail != null) {
			thumbnail.Dispose ();
		}
		Gdk.Rectangle layout_bounds = Gdk.Rectangle.Zero;
		if (DisplayDates) {
			string date;
			if (cell_width > 200) {
				date = photo.Time.ToLocalTime ().ToString ();
			} else {
				date = photo.Time.ToLocalTime ().ToShortDateString ();
			}

			Pango.Layout layout = (Pango.Layout)date_layouts [date];
			if (layout == null) {
				layout = new Pango.Layout (this.PangoContext);
				layout.SetText (date);
				date_layouts [date] = layout;
			}
			
			layout.GetPixelSize (out layout_bounds.Width, out layout_bounds.Height);

			layout_bounds.Y = bounds.Y + bounds.Height - cell_border_width - layout_bounds.Height + tag_icon_vspacing;
			layout_bounds.X = bounds.X + (bounds.Width - layout_bounds.Width) / 2;
			
			if (DisplayTags)
				layout_bounds.Y -= tag_icon_size;

			if (DisplayFilenames) {
				Pango.FontMetrics metrics = this.PangoContext.GetMetrics (this.Style.FontDescription,
						Pango.Language.FromString ("en_US"));
				layout_bounds.Y -= PangoPixels (metrics.Ascent + metrics.Descent); 
			}

			if (layout_bounds.Intersect (area, out region)) {
				Style.PaintLayout (Style, BinWindow, cell_state,
						   true, area, this, "IconView", 
						   layout_bounds.X, layout_bounds.Y, 
						   layout);
			}
		}

		if (DisplayFilenames) {

			string filename = System.IO.Path.GetFileName (photo.DefaultVersionUri.LocalPath);
			Pango.Layout layout = new Pango.Layout (this.PangoContext);
			layout.SetText (filename);
			
			layout.GetPixelSize (out layout_bounds.Width, out layout_bounds.Height);

			layout_bounds.Y = bounds.Y + bounds.Height - cell_border_width - layout_bounds.Height + tag_icon_vspacing;
			layout_bounds.X = bounds.X + (bounds.Width - layout_bounds.Width) / 2;
			
			if (DisplayTags)
				layout_bounds.Y -= tag_icon_size;

			if (layout_bounds.Intersect (area, out region)) {
				Style.PaintLayout (Style, BinWindow, cell_state,
						   true, area, this, "IconView", 
						   layout_bounds.X, layout_bounds.Y, 
						   layout);
			}
			
		}

		if (DisplayTags) {
			Tag [] tags = photo.Tags;
			Gdk.Rectangle tag_bounds;

			tag_bounds.X = bounds.X + (bounds.Width  + tag_icon_hspacing - tags.Length * (tag_icon_size + tag_icon_hspacing)) / 2;
			tag_bounds.Y = bounds.Y + bounds.Height - cell_border_width - tag_icon_size + tag_icon_vspacing;
			tag_bounds.Width = tag_icon_size;
			tag_bounds.Height = tag_icon_size;
			
			foreach (Tag t in tags) {
				if (t == null)
					continue;

				Pixbuf icon = t.Icon;

		                Tag tag_iter = t.Category;
		                while (icon == null && tag_iter != Core.Database.Tags.RootCategory && tag_iter != null) {
		                    icon = tag_iter.Icon;
		                    tag_iter = tag_iter.Category;
		                }
		
		                if (icon == null)
		                    continue;
		
				if (tag_bounds.Intersect (area, out region)) {
					Pixbuf scaled_icon;
					if (icon.Width == tag_bounds.Width) {
						scaled_icon = icon;
					} else {
						scaled_icon = icon.ScaleSimple (tag_bounds.Width, 
										tag_bounds.Height, 
										InterpType.Bilinear);
					}
					
					scaled_icon.RenderToDrawable (BinWindow, Style.WhiteGC,
								      region.X - tag_bounds.X, 
								      region.Y - tag_bounds.Y, 
								      region.X, region.Y, 
								      region.Width, region.Height,
								      RgbDither.None, region.X, region.Y);
					if (scaled_icon != icon) {
						scaled_icon.Dispose ();
					}
				}
				tag_bounds.X += tag_bounds.Width + tag_icon_hspacing;
			}
		}

	}
Пример #28
0
        private void DrawRulers()
        {
            int x=0;
            int korr=0;
            Gdk.GC gc;
            Gdk.GC gc1 = new Gdk.GC (this.GdkWindow);
            gc1.RgbFgColor = new Gdk.Color (10, 10, 20);
            Gdk.GC gc2 = new Gdk.GC (this.GdkWindow);
            gc2.RgbFgColor = new Gdk.Color (100, 100, 120);
            Pango.Layout layout = new Pango.Layout(PangoContext);
            layout.FontDescription = Pango.FontDescription.FromString("Sans 9");
            layout.SetText("0");
            gc = gc1;

            this.GdkWindow.DrawLine(gc1,0,0,5,0);
            this.GdkWindow.DrawLine(gc1,0,150,5,150);
            this.GdkWindow.DrawLine(gc1,0,299,5,299);
            layout.SetText(Convert.ToString(maximum));
            this.GdkWindow.DrawLayout(gc1, 5, 0, layout);
            layout.SetText(Convert.ToString(maximum/2));
            this.GdkWindow.DrawLayout(gc1, 5, 150, layout);

            for (int i=0; i<numofdata ; i++) {
                x=i*(spacing+Checksize)+15;
                if (i % 5 == 0) { // Minden Ötödik
                    layout.SetText(Convert.ToString(i));
                    this.GdkWindow.DrawLayout(gc1, x, 307, layout);
                    korr=3;
                    gc = gc1;
                }
                this.GdkWindow.DrawLine(gc,x,302,x,307+korr);
                korr = 0;
                gc = gc2;
            }
        }
Пример #29
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, 1, 1);
            cr.Fill();
            //cr.Restore();
            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  = 6.0;
            desc.Size = (int)(fontSize * pangoScale);                                       layout.FontDescription = desc;
            layout.FontDescription.Weight = Weight.Bold;
            //cr.MoveTo(20*escala_en_linux_windows,10*escala_en_linux_windows);					layout.SetText(classpublic.nombre_empresa);		Pango.CairoHelper.ShowLayout (cr, layout);
            //cr.MoveTo(20*escala_en_linux_windows,20*escala_en_linux_windows);					layout.SetText(classpublic.direccion_empresa);	Pango.CairoHelper.ShowLayout (cr, layout);
            //cr.MoveTo(20*escala_en_linux_windows,30*escala_en_linux_windows);					layout.SetText(classpublic.telefonofax_empresa);		Pango.CairoHelper.ShowLayout (cr, layout);
            //cr.MoveTo(20*escala_en_linux_windows,70*escala_en_linux_windows);					layout.SetText("Sistema Hospitalario OSIRIS");		Pango.CairoHelper.ShowLayout (cr, layout);
            // Cambiando el tamaño de la fuente
            fontSize  = 12.0;
            desc.Size = (int)(fontSize * pangoScale);                                       layout.FontDescription = desc;
            cr.MoveTo(230 * escala_en_linux_windows, 55 * escala_en_linux_windows);                                                                             layout.SetText("PROTOCOLO DE ADMISION");
            Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(280 * escala_en_linux_windows, 65 * escala_en_linux_windows);                                                                     layout.SetText("REGISTRO");
            Pango.CairoHelper.ShowLayout(cr, layout);
            layout.FontDescription.Weight = Weight.Normal;                      // Letra Normal
            fontSize  = 8.0;
            desc.Size = (int)(fontSize * pangoScale);               layout.FontDescription = desc;
        }
Пример #30
0
        void DrawContent(Context cr, CObject cObject)
        {
            if (cObject is COperator cOperator)
            {
                Color?ncolor = null;
                switch (cOperator.OpCode.OpCodeName)
                {
                // Set the text font, Tf , to font and the text font size, T fs , to size. font shall be
                // the name of a font resource in the Font subdictionary of the current
                // resource dictionary; size shall be a number representing a scale factor.
                // There is no initial value for either font or size; they shall be specified
                // explicitly by using Tf before any text is shown.
                case OpCodeName.Tf:
                    if (cOperator.Operands.Count == 2)
                    {
                        if (cOperator.Operands[0] is CName font)
                        {
                            //fontDescription = FontDescription.FromString ("Sans");
                        }
                        if (cOperator.Operands[1] is CInteger i)
                        {
                            fontDescription.Size = (int)((fontSize * i.Value) * Pango.Scale.PangoScale);
                        }
                    }
                    break;

                // Move to the start of the next line, offset from the start of the current line by
                // (tx , ty ). t x and t y shall denote numbers expressed in unscaled text space
                // units. More precisely, this operator shall perform these assignments:
                //            [ 1  0  0 ]
                // Tm = Tlm = [ 0  1  1 ] x Tlm
                //            [ tx ty 1 ]
                //
                // Operands: tx ty
                case OpCodeName.Td:
                    if (cOperator.Operands.Count == 2)
                    {
                        double x = 0d, y = 0d;
                        if (cOperator.Operands[0] is CReal rx)
                        {
                            x = rx.Value;
                        }
                        else if (cOperator.Operands[0] is CInteger ix)
                        {
                            x = ix.Value;
                        }

                        if (cOperator.Operands[1] is CReal ry)
                        {
                            y = ry.Value;
                        }
                        else if (cOperator.Operands[1] is CInteger iy)
                        {
                            y = iy.Value;
                        }

                        cursor = new Tuple <double, double>(x, cursor.Item2 - y - (fontDescription.Size / Pango.Scale.PangoScale));
                    }
                    break;

                // Move to the start of the next line, offset from the start of the current line by
                // (t x , t y ). As a side effect, this operator shall set the leading parameter in
                // the text state. This operator shall have the same effect as this code:
                //    −ty TL
                //    tx ty Td
                //
                // Operands: tx ty
                case OpCodeName.TD:
                    if (cOperator.Operands.Count == 2)
                    {
                        double x = 0d, y = 0d;
                        if (cOperator.Operands[0] is CReal rx)
                        {
                            x = rx.Value;
                        }
                        else if (cOperator.Operands[0] is CInteger ix)
                        {
                            x = ix.Value;
                        }

                        if (cOperator.Operands[1] is CReal ry)
                        {
                            y = ry.Value;
                        }
                        else if (cOperator.Operands[1] is CInteger iy)
                        {
                            y = iy.Value;
                        }

                        cursor = new Tuple <double, double>(x, cursor.Item2 - y - (fontDescription.Size / Pango.Scale.PangoScale));
                    }
                    break;

                // Set the text matrix, Tm , and the text line matrix, Tlm:
                //               [ a b 0 ]
                //    Tm = Tlm = [ c d 0 ]
                //               [ e f 1 ]
                // The operands shall all be numbers, and the initial value for Tm and Tlm
                // shall be the identity matrix, [ 1 0 0 1 0 0 ]. Although the operands
                // specify a matrix, they shall be passed to Tm as six separate numbers, not
                // as an array.The matrix specified by the operands shall not be concatenated onto the current
                // text matrix, but shall replace it.
                //
                // Operands: a b c d e f
                case OpCodeName.Tm:
                    if (cOperator.Operands.Count == 6)
                    {
                        double x = 0d, y = 0d;
                        if (cOperator.Operands[4] is CReal rx)
                        {
                            x = rx.Value;
                        }
                        else if (cOperator.Operands[4] is CInteger ix)
                        {
                            x = ix.Value;
                        }

                        if (cOperator.Operands[5] is CReal ry)
                        {
                            y = ry.Value;
                        }
                        else if (cOperator.Operands[5] is CInteger iy)
                        {
                            y = iy.Value;
                        }

                        cursor = new Tuple <double, double>(cursor.Item1 + x, cursor.Item2 - y);
                    }
                    break;

                // Move to the start of the next line. This operator has the same effect as the code
                //  0 -T l Td
                // where T l denotes the current leading parameter in the text state. The
                // negative of T l is used here because T l is the text leading expressed as a
                // positive number. Going to the next line entails decreasing the y coordinate.
                //
                // Operands: none
                case OpCodeName.Tx:
                    cursor = new Tuple <double, double>(0d, cursor.Item2 - lineHeight);
                    break;

                // Move to the next line and show a text string. This operator shall have the
                // same effect as the code
                //    T*
                //    string Tj
                //
                // Operands: string
                case OpCodeName.QuoteSingle:
                    cursor = new Tuple <double, double>(0d, cursor.Item2 - lineHeight);
                    foreach (var cOperand in cOperator.Operands)
                    {
                        DrawContent(cr, cOperand);
                    }
                    break;

                // Move to the next line and show a text string, using a w as the word spacing
                // and a c as the character spacing (setting the corresponding parameters in
                // the text state). a w and a c shall be numbers expressed in unscaled text
                // space units. This operator shall have the same effect as this code:
                //    a w Tw
                //    a c Tc
                //    string '
                //
                // Opreands: a w a c string
                case OpCodeName.QuoteDbl:
                    cursor = new Tuple <double, double>(0d, cursor.Item2 - lineHeight);
                    foreach (var cOperand in cOperator.Operands)
                    {
                        DrawContent(cr, cOperand);
                    }
                    break;

                // Show a text string.
                //
                // Operands: string
                case OpCodeName.Tj:
                // Show one or more text strings, allowing individual glyph positioning. Each
                // element of array shall be either a string or a number. If the element is a
                // string, this operator shall show the string. If it is a number, the operator
                // shall adjust the text position by that amount; that is, it shall translate the
                // text matrix, T m . The number shall be expressed in thousandths of a unit
                // of text space (see 9.4.4, "Text Space Details"). This amount shall be
                // subtracted from the current horizontal or vertical coordinate, depending
                // on the writing mode. In the default coordinate system, a positive
                // adjustment has the effect of moving the next glyph painted either to the
                // left or down by the given amount. Figure 46 shows an example of the
                // effect of passing offsets to TJ.
                //
                // Operands: array
                case OpCodeName.TJ:
                    foreach (var cOperand in cOperator.Operands)
                    {
                        DrawContent(cr, cOperand);
                    }
                    break;

                // Begin a new subpath by moving the current point to coordinates (x, y), omitting any connecting
                // line segment. If the previous path construction operator in the current pathwas also m,
                // the new m overrides it; no vestige of the previous m operation remains in the path.
                case OpCodeName.m:
                    if (cOperator.Operands.Count == 2)
                    {
                        double x = 0d, y = 0d;
                        if (cOperator.Operands[0] is CReal rx)
                        {
                            x = rx.Value;
                        }
                        else if (cOperator.Operands[0] is CInteger ix)
                        {
                            x = ix.Value;
                        }

                        if (cOperator.Operands[1] is CReal ry)
                        {
                            y = ry.Value;
                        }
                        else if (cOperator.Operands[1] is CInteger iy)
                        {
                            y = iy.Value;
                        }

                        cr.MoveTo(margin + x, margin + pageHeight - y);
                    }
                    break;

                // Append a straight line segment from the current point to the point (x, y).
                // The new current point shall be (x, y).
                case OpCodeName.l:
                    if (cOperator.Operands.Count == 2)
                    {
                        double x = 0d, y = 0d;
                        if (cOperator.Operands[0] is CReal rx)
                        {
                            x = rx.Value;
                        }
                        else if (cOperator.Operands[0] is CInteger ix)
                        {
                            x = ix.Value;
                        }

                        if (cOperator.Operands[1] is CReal ry)
                        {
                            y = ry.Value;
                        }
                        else if (cOperator.Operands[1] is CInteger iy)
                        {
                            y = iy.Value;
                        }

                        //cr.LineTo(margin + x, margin + pageHeight - y);
                    }
                    break;

                // Append a cubic Bézier curve to the current path. The curve
                // shall extend from the current point to the point (x 3 , y 3 ), using
                // (x 1 , y 1 ) and (x 2 , y 2 ) as the Bézier control points (see 8.5.2.2,
                // "Cubic Bézier Curves"). The new current point shall be (x 3 , y 3 ).
                case OpCodeName.c:
                    Console.WriteLine(cOperator.OpCode.OpCodeName);
                    break;

                // Append a cubic Bézier curve to the current path. The curve shall extend from the current
                // point to the point (x 3 , y 3 ), using the current point and (x 2 , y 2 ) as the Bézier
                // control points (see 8.5.2.2, "Cubic Bézier Curves"). The new current point shall be (x 3 , y 3 ).
                case OpCodeName.v:
                    Console.WriteLine(cOperator.OpCode.OpCodeName);
                    break;

                // Append a cubic Bézier curve to the current path. The curve shall extend from the current point
                // to the point (x 3 , y 3 ), using (x 1 , y 1 ) and (x 3 , y 3 ) as the Bézier control points
                // (see 8.5.2.2, "Cubic Bézier Curves"). The new current point shall be (x 3 , y 3 ).
                case OpCodeName.y:
                    Console.WriteLine(cOperator.OpCode.OpCodeName);
                    break;

                // Close the current subpath by appending a straight line segment from the current point to the
                // starting point of the subpath. If the current subpath is already closed, h shall do nothing.
                // This operator terminates the current subpath. Appending another segment to the current path
                // shall begin a new subpath, even if the new segment begins at the endpoint reached by the h
                // operation.
                case OpCodeName.h:
                    cr.ClosePath();
                    break;

                // Append a rectangle to the current path as a complete subpath, with lower-left corner (x, y) and
                // dimensions width and height in user space. The operation
                //   x y width height re
                // is equivalent to
                //   x y m
                //   ( x + width ) y l
                //   ( x + width ) ( y + height ) l
                //   x ( y + height ) l
                //   h
                case OpCodeName.re:
                    if (cOperator.Operands.Count == 4)
                    {
                        double x = 0d, y = 0d, w = 0d, h = 0d;
                        if (cOperator.Operands[0] is CReal rx)
                        {
                            x = rx.Value;
                        }
                        else if (cOperator.Operands[0] is CInteger ix)
                        {
                            x = ix.Value;
                        }

                        if (cOperator.Operands[1] is CReal ry)
                        {
                            y = ry.Value;
                        }
                        else if (cOperator.Operands[1] is CInteger iy)
                        {
                            y = iy.Value;
                        }

                        if (cOperator.Operands[2] is CReal rw)
                        {
                            w = rw.Value;
                        }
                        else if (cOperator.Operands[2] is CInteger iw)
                        {
                            w = iw.Value;
                        }

                        if (cOperator.Operands[3] is CReal rh)
                        {
                            h = rh.Value;
                        }
                        else if (cOperator.Operands[3] is CInteger ih)
                        {
                            h = ih.Value;
                        }

                        if (h > 0 && w > 0)
                        {
                            cr.Save();
                            cr.MoveTo(margin + x, margin + pageHeight - y);
                            DrawHelper.DrawBox(cr, margin + x, margin + pageHeight - y, w, h);
                            cr.SetSourceColor(fillColor);
                            cr.FillPreserve();
                            cr.SetSourceColor(strokeColor);
                            cr.Stroke();
                            cr.Restore();
                        }
                    }
                    break;

                // The q operator shall push a copy of the entire graphics state onto the stack.
                case OpCodeName.q:
                    cr.Save();
                    break;

                // The Q operator shall restore the entire graphics state to its former value by popping it
                // from the stack.
                case OpCodeName.Q:
                    cr.Restore();
                    break;

                // Stroke the path.
                case OpCodeName.S:
                    cr.SetSourceColor(strokeColor);
                    cr.Stroke();
                    break;

                // Close and stroke the path. This operator shall have the same effect as the sequence h S.
                case OpCodeName.s:
                    cr.ClosePath();
                    cr.SetSourceColor(strokeColor);
                    cr.Stroke();
                    break;

                // Fill the path, using the nonzero winding number rule to determine the region
                // to fill (see 8.5.3.3.2, "Nonzero Winding Number Rule"). Any subpaths that
                // are open shall be implicitly closed before being filled.
                case OpCodeName.f:
                case OpCodeName.F:
                    cr.ClosePath();
                    cr.SetSourceColor(fillColor);
                    cr.Fill();
                    break;

                // Fill the path, using the even-odd rule to determine the region to fill (see
                // 8.5.3.3.3, "Even-Odd Rule").
                case OpCodeName.fx:
                    cr.SetSourceColor(fillColor);
                    cr.Fill();
                    break;

                // Fill and then stroke the path, using the nonzero winding number rule to
                // determine the region to fill. This operator shall produce the same result as
                // constructing two identical path objects, painting the first with f and the
                // second with S.
                // NOTE
                //   The filling and stroking portions of the operation consult
                //   different values of several graphics state parameters, such as
                //   the current colour. See also 11.7.4.4, "Special Path-Painting Considerations".
                case OpCodeName.B:
                    cr.SetSourceColor(fillColor);
                    cr.FillPreserve();
                    cr.SetSourceColor(strokeColor);
                    cr.Stroke();
                    break;

                // Fill and then stroke the path, using the even-odd rule to determine the region
                // to fill. This operator shall produce the same result as B, except that the path
                // is filled as if with f* instead of f. See also 11.7.4.4, "Special Path-Painting Considerations".
                case OpCodeName.Bx:
                    cr.SetSourceColor(fillColor);
                    cr.FillPreserve();
                    cr.SetSourceColor(strokeColor);
                    cr.Stroke();
                    break;

                // Close, fill, and then stroke the path, using the nonzero winding number rule
                // to determine the region to fill. This operator shall have the same effect as the
                // sequence h B. See also 11.7.4.4, "Special Path-Painting Considerations".
                case OpCodeName.b:
                    cr.ClosePath();
                    cr.SetSourceColor(fillColor);
                    cr.FillPreserve();
                    cr.SetSourceColor(strokeColor);
                    cr.Stroke();
                    break;

                // Close, fill, and then stroke the path, using the even-odd rule to determine the
                // region to fill. This operator shall have the same effect as the sequence h B*.
                // See also 11.7.4.4, "Special Path-Painting Considerations".
                case OpCodeName.bx:
                    cr.ClosePath();
                    cr.SetSourceColor(fillColor);
                    cr.FillPreserve();
                    cr.SetSourceColor(strokeColor);
                    cr.Stroke();
                    break;

                // End the path object without filling or stroking it. This operator shall be a path-
                // painting no-op, used primarily for the side effect of changing the current
                // clipping path (see 8.5.4, "Clipping Path Operators").
                case OpCodeName.n:
                    cr.ClosePath();
                    break;

                // (PDF 1.2) Same as SC but also supports Pattern, Separation, DeviceN and ICCBased colour spaces.
                // If the current stroking colour space is a Separation, DeviceN, or ICCBased colour space, the
                // operands c 1 ... c n shall be numbers. The number of operands and their interpretation depends
                // on the colour space. If the current stroking colour space is a Pattern colour space, name shall
                // be the name of an entry in the Pattern subdictionary of the current resource dictionary
                // (see 7.8.3, "Resource Dictionaries"). For an uncoloured tiling pattern (PatternType = 1 and
                // PaintType = 2), c 1 ... c n shall be component values specifying a colour in the pattern’s
                // underlying colour space. For other types of patterns, these operands shall not be specified.
                case OpCodeName.SCN:
                // (PDF 1.2) Same as SCN but used for nonstroking operations.
                case OpCodeName.scn:
                    if (cOperator.Operands.Count == 1)
                    {
                        if (cOperator.Operands[0] is CName name)
                        {
                            ncolor = new Color(0d / 255d, 172d / 255d, 140d / 255d);
                        }
                        else if (cOperator.Operands[0] is CReal rr)
                        {
                            var r = rr.Value;
                            ncolor = new Color(r, r, r);
                        }
                    }
                    else if (cOperator.Operands.Count == 3)
                    {
                        double r = 0d, g = 0d, b = 0d;
                        if (cOperator.Operands[0] is CReal rr)
                        {
                            r = rr.Value;
                        }
                        else if (cOperator.Operands[0] is CInteger ir)
                        {
                            r = ir.Value;
                        }

                        if (cOperator.Operands[1] is CReal rg)
                        {
                            g = rg.Value;
                        }
                        else if (cOperator.Operands[1] is CInteger ig)
                        {
                            g = ig.Value;
                        }

                        if (cOperator.Operands[2] is CReal rb)
                        {
                            b = rb.Value;
                        }
                        else if (cOperator.Operands[2] is CInteger ib)
                        {
                            b = ib.Value;
                        }

                        ncolor = new Color(r, g, b);
                    }

                    if (ncolor != null)
                    {
                        if (cOperator.OpCode.OpCodeName == OpCodeName.scn)
                        {
                            fillColor = ncolor.Value;
                        }
                        else
                        {
                            strokeColor = ncolor.Value;
                        }
                    }

                    break;

                // (PDF 1.1) Set the current colour space to use for stroking operations. The
                // operand name shall be a name object. If the colour space is one that can
                // be specified by a name and no additional parameters (DeviceGray,
                // DeviceRGB, DeviceCMYK, and certain cases of Pattern), the name may
                // be specified directly. Otherwise, it shall be a name defined in the
                // ColorSpace subdictionary of the current resource dictionary (see 7.8.3,
                // "Resource Dictionaries"); the associated value shall be an array
                // describing the colour space (see 8.6.3, "Colour Space Families").
                // The names DeviceGray, DeviceRGB, DeviceCMYK, and Pattern
                // always identify the corresponding colour spaces directly; they never refer
                // to resources in the ColorSpace subdictionary.
                // The CS operator shall also set the current stroking colour to its initial
                // value, which depends on the colour space:
                // In a DeviceGray, DeviceRGB, CalGray, or CalRGB colour space, the
                // initial colour shall have all components equal to 0.0.
                // In a DeviceCMYK colour space, the initial colour shall be [ 0.0 0.0 0.0 1.0 ].
                // In a Lab or ICCBased colour space, the initial colour shall have all
                // components equal to 0.0 unless that falls outside the intervals specified
                // by the space’s Range entry, in which case the nearest valid value shall be substituted.
                // In an Indexed colour space, the initial colour value shall be 0.
                // In a Separation or DeviceN colour space, the initial tint value shall be 1.0 for all colorants.
                // In a Pattern colour space, the initial colour shall be a pattern object that
                // causes nothing to be painted.
                case OpCodeName.CS:
                // (PDF 1.1) Same as CS but used for nonstroking operations.
                case OpCodeName.cs:
                    if (cOperator.Operands.Count == 1)
                    {
                        if (cOperator.Operands[0] is CName name)
                        {
                            ncolor = new Color(0d / 255d, 172d / 255d, 140d / 255d);
                        }
                        else if (cOperator.Operands[0] is CReal rr)
                        {
                            var r = rr.Value;
                            ncolor = new Color(r, r, r);
                        }
                    }

                    if (ncolor != null)
                    {
                        if (cOperator.OpCode.OpCodeName == OpCodeName.cs)
                        {
                            fillColor = ncolor.Value;
                        }
                        else
                        {
                            strokeColor = ncolor.Value;
                        }
                    }

                    break;

                // (PDF 1.1) Set the colour to use for stroking operations in a device, CIE-
                // based (other than ICCBased), or Indexed colour space. The number of
                // operands required and their interpretation depends on the current
                // stroking colour space:
                // For DeviceGray, CalGray, and Indexed colour spaces, one operand
                // shall be required (n = 1).
                // For DeviceRGB, CalRGB, and Lab colour spaces, three operands shall be required (n = 3).
                // For DeviceCMYK, four operands shall be required (n = 4).
                case OpCodeName.SC:
                // (PDF 1.1) Same as SC but used for nonstroking operations.
                case OpCodeName.sc:
                    if (cOperator.Operands.Count == 3)
                    {
                        double r = 0d, g = 0d, b = 0d;
                        if (cOperator.Operands[0] is CReal rr)
                        {
                            r = rr.Value;
                        }
                        else if (cOperator.Operands[0] is CInteger ir)
                        {
                            r = ir.Value;
                        }

                        if (cOperator.Operands[1] is CReal rg)
                        {
                            g = rg.Value;
                        }
                        else if (cOperator.Operands[1] is CInteger ig)
                        {
                            g = ig.Value;
                        }

                        if (cOperator.Operands[2] is CReal rb)
                        {
                            b = rb.Value;
                        }
                        else if (cOperator.Operands[2] is CInteger ib)
                        {
                            b = ib.Value;
                        }

                        ncolor = new Color(r, g, b);
                        if (cOperator.OpCode.OpCodeName == OpCodeName.sc)
                        {
                            fillColor = ncolor.Value;
                        }
                        else
                        {
                            strokeColor = ncolor.Value;
                        }
                    }
                    break;

                // Set the stroking colour space to DeviceGray (or the DefaultGray colour
                // space; see 8.6.5.6, "Default Colour Spaces") and set the gray level to use
                // for stroking operations. gray shall be a number between 0.0 (black) and 1.0 (white).
                case OpCodeName.G:
                // Same as G but used for nonstroking operations.
                case OpCodeName.g:
                    Console.WriteLine(cOperator.OpCode.OpCodeName);
                    break;

                // Set the stroking colour space to DeviceRGB (or the DefaultRGB colour
                // space; see 8.6.5.6, "Default Colour Spaces") and set the colour to use for
                // stroking operations. Each operand shall be a number between 0.0
                // (minimum intensity) and 1.0 (maximum intensity).
                //
                // Operands: r g b
                case OpCodeName.RG:
                // Same as RG but used for nonstroking operations.
                case OpCodeName.rg:
                    if (cOperator.Operands.Count == 3)
                    {
                        double r = 0d, g = 0d, b = 0d;
                        if (cOperator.Operands[0] is CReal rr)
                        {
                            r = rr.Value;
                        }
                        else if (cOperator.Operands[0] is CInteger ir)
                        {
                            r = ir.Value;
                        }

                        if (cOperator.Operands[1] is CReal rg)
                        {
                            g = rg.Value;
                        }
                        else if (cOperator.Operands[1] is CInteger ig)
                        {
                            g = ig.Value;
                        }

                        if (cOperator.Operands[2] is CReal rb)
                        {
                            b = rb.Value;
                        }
                        else if (cOperator.Operands[2] is CInteger ib)
                        {
                            b = ib.Value;
                        }

                        var color = new Color(r, g, b);
                        if (cOperator.OpCode.OpCodeName == OpCodeName.rg)
                        {
                            fillColor = color;
                        }
                        else
                        {
                            strokeColor = color;
                        }
                    }
                    break;

                // Set the stroking colour space to DeviceCMYK (or the DefaultCMYK
                // colour space; see 8.6.5.6, "Default Colour Spaces") and set the colour to
                // use for stroking operations. Each operand shall be a number between 0.0
                // (zero concentration) and 1.0 (maximum concentration). The behaviour of
                // this operator is affected by the overprint mode (see 8.6.7, "Overprint Control").
                //
                // Operand: c m y k
                case OpCodeName.K:
                // Same as K but used for nonstroking operations.
                case OpCodeName.k:
                    if (cOperator.Operands.Count == 4)
                    {
                        double c = 0d, m = 0d, y = 0d, k = 0d;
                        if (cOperator.Operands[0] is CReal cc)
                        {
                            c = cc.Value;
                        }
                        if (cOperator.Operands[1] is CReal cm)
                        {
                            m = cm.Value;
                        }
                        if (cOperator.Operands[2] is CReal cy)
                        {
                            y = cy.Value;
                        }
                        if (cOperator.Operands[3] is CReal ck)
                        {
                            k = ck.Value;
                        }

                        //cr.SetSourceColor(new Cairo.Color(r, g, b));
                    }
                    break;

                default:
                    Console.WriteLine(cOperator.OpCode.OpCodeName);
                    break;
                }
            }
            else if (cObject is CSequence cSequence)
            {
                foreach (var element in cSequence)
                {
                    DrawContent(cr, element);
                }
            }
            else if (cObject is CString cString)
            {
                layout.FontDescription = fontDescription;
                layout.Wrap            = Pango.WrapMode.WordChar;

                cr.MoveTo(cursor.Item1, cursor.Item2 - (fontDescription.Size / Pango.Scale.PangoScale));
                cr.SetSourceColor(strokeColor);

                layout.Width = ((int)(((fontDescription.Size / Pango.Scale.PangoScale) * cString.Value.Length) * Pango.Scale.PangoScale));
                layout.SetText(cString.Value);

                Pango.CairoHelper.ShowLayout(cr, layout);

                cursor = new Tuple <double, double>(cursor.Item1 + ((fontDescription.Size / Pango.Scale.PangoScale) * cString.Value.Length), cursor.Item2);
            }
        }
Пример #31
0
        protected override bool OnExposeEvent(Gdk.EventExpose e)
        {
            Cairo.Context cr = Gdk.CairoHelper.Create(e.Window);

            Gdk.Rectangle area = e.Area;

            if (this.categories.Count == 0 || !string.IsNullOrEmpty(CustomMessage))
            {
                Pango.Layout messageLayout = new Pango.Layout(this.PangoContext);
                messageLayout.Alignment = Pango.Alignment.Center;
                messageLayout.Width     = (int)(Allocation.Width * 2 / 3 * Pango.Scale.PangoScale);
                if (!string.IsNullOrEmpty(CustomMessage))
                {
                    messageLayout.SetText(CustomMessage);
                }
                else
                {
                    messageLayout.SetText(MonoDevelop.Core.GettextCatalog.GetString("There are no tools available for the current document."));
                }
                cr.MoveTo(Allocation.Width * 1 / 6, 12);
                cr.SetSourceColor(Style.Text(StateType.Normal).ToCairoColor());
                Pango.CairoHelper.ShowLayout(cr, messageLayout);
                messageLayout.Dispose();
                ((IDisposable)cr).Dispose();
                return(true);
            }

            var backColor = Style.Base(StateType.Normal).ToCairoColor();

            cr.SetSourceColor(backColor);
            cr.Rectangle(area.X, area.Y, area.Width, area.Height);
            cr.Fill();

            int xpos        = (this.hAdjustement != null ? (int)this.hAdjustement.Value : 0);
            int vadjustment = (this.vAdjustement != null ? (int)this.vAdjustement.Value : 0);
            int ypos        = -vadjustment;
            ToolboxWidgetCategory lastCategory = null;
            int lastCategoryYpos = 0;

            cr.LineWidth = 1;

            Iterate(ref xpos, ref ypos, (category, itemDimension) => {
                ProcessExpandAnimation(cr, lastCategory, lastCategoryYpos, backColor, area, ref ypos);

                if (!area.IntersectsWith(new Gdk.Rectangle(new Gdk.Point(xpos, ypos), itemDimension)))
                {
                    return(true);
                }
                cr.Rectangle(xpos, ypos, itemDimension.Width, itemDimension.Height);
                cr.SetSourceColor(Ide.Gui.Styles.PadCategoryBackgroundColor.ToCairoColor());
                cr.Fill();

                if (lastCategory == null || lastCategory.IsExpanded || lastCategory.AnimatingExpand)
                {
                    cr.MoveTo(xpos, ypos + 0.5);
                    cr.LineTo(itemDimension.Width, ypos + 0.5);
                }
                cr.MoveTo(0, ypos + itemDimension.Height - 0.5);
                cr.LineTo(xpos + Allocation.Width, ypos + itemDimension.Height - 0.5);
                cr.SetSourceColor(MonoDevelop.Ide.Gui.Styles.PadCategoryBorderColor.ToCairoColor());
                cr.Stroke();

                headerLayout.SetMarkup(category.Text);
                int width, height;
                cr.SetSourceColor(MonoDevelop.Ide.Gui.Styles.PadCategoryLabelColor.ToCairoColor());
                headerLayout.GetPixelSize(out width, out height);
                cr.MoveTo(xpos + CategoryLeftPadding, ypos + (double)(Math.Round((double)(itemDimension.Height - height) / 2)));
                Pango.CairoHelper.ShowLayout(cr, headerLayout);

                var img = category.IsExpanded ? discloseUp : discloseDown;
                cr.DrawImage(this, img, Allocation.Width - img.Width - CategoryRightPadding, ypos + Math.Round((itemDimension.Height - img.Height) / 2));

                lastCategory     = category;
                lastCategoryYpos = ypos + itemDimension.Height;

                return(true);
            }, (curCategory, item, itemDimension) => {
                if (!area.IntersectsWith(new Gdk.Rectangle(new Gdk.Point(xpos, ypos), itemDimension)))
                {
                    return(true);
                }

                var icon = item.Icon;
                if (!icon.HasFixedSize)
                {
                    var maxIconSize     = Math.Min(itemDimension.Width, itemDimension.Height);
                    var fittingIconSize = maxIconSize > 32 ? Xwt.IconSize.Large : maxIconSize > 16 ? Xwt.IconSize.Medium : Xwt.IconSize.Small;
                    icon = item.Icon.WithSize(fittingIconSize);
                }
                if (item == SelectedItem)
                {
                    icon = icon.WithStyles("sel");
                    cr.SetSourceColor(Style.Base(StateType.Selected).ToCairoColor());
                    cr.Rectangle(xpos, ypos, itemDimension.Width, itemDimension.Height);
                    cr.Fill();
                }
                if (listMode || !curCategory.CanIconizeItems)
                {
                    cr.DrawImage(this, icon, xpos + ItemLeftPadding, ypos + Math.Round((itemDimension.Height - icon.Height) / 2));
                    layout.SetMarkup(item.Text);
                    layout.Width = (int)((itemDimension.Width - ItemIconTextItemSpacing - iconSize.Width - ItemLeftPadding * 2) * Pango.Scale.PangoScale);
                    layout.GetPixelSize(out var width, out var height);
                    cr.SetSourceColor(Style.Text(item != SelectedItem ? StateType.Normal : StateType.Selected).ToCairoColor());
                    cr.MoveTo(xpos + ItemLeftPadding + iconSize.Width + ItemIconTextItemSpacing, ypos + Math.Round((double)(itemDimension.Height - height) / 2));
                    Pango.CairoHelper.ShowLayout(cr, layout);
                }
                else
                {
                    cr.DrawImage(this, icon, xpos + Math.Round((itemDimension.Width - icon.Width) / 2), ypos + Math.Round((itemDimension.Height - icon.Height) / 2));
                }

                if (item == mouseOverItem)
                {
                    cr.SetSourceColor(Style.Dark(StateType.Prelight).ToCairoColor());
                    cr.Rectangle(xpos + 0.5, ypos + 0.5, itemDimension.Width - 1, itemDimension.Height - 1);
                    cr.Stroke();
                }

                return(true);
            });

            ProcessExpandAnimation(cr, lastCategory, lastCategoryYpos, backColor, area, ref ypos);

            if (lastCategory != null && lastCategory.AnimatingExpand)
            {
                // Closing line when animating the last group of the toolbox
                cr.MoveTo(area.X, ypos + 0.5);
                cr.RelLineTo(area.Width, 0);
                cr.SetSourceColor(MonoDevelop.Ide.Gui.Styles.PadCategoryBorderColor.ToCairoColor());
                cr.Stroke();
            }

            ((IDisposable)cr).Dispose();
            return(true);
        }
Пример #32
0
        void ejecutar_consulta_reporte(PrintContext context)
        {
            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 = "SELECT " +
                                      "osiris_erp_cobros_enca.folio_de_servicio,osiris_erp_cobros_enca.pid_paciente, osiris_erp_cobros_enca.id_empleado_admision,osiris_erp_cobros_enca.nombre_medico_encabezado,osiris_erp_cobros_enca.id_medico," +
                                      "osiris_his_paciente.nombre1_paciente,osiris_his_paciente.nombre2_paciente,osiris_his_paciente.apellido_paterno_paciente,osiris_his_paciente.apellido_materno_paciente, " +
                                      "to_char(fecha_nacimiento_paciente, 'dd-MM-yyyy') AS fecha_nac_pa,osiris_his_paciente.sexo_paciente,osiris_his_paciente.direccion_paciente,osiris_his_paciente.numero_casa_paciente, " +
                                      "osiris_his_paciente.numero_departamento_paciente,osiris_his_paciente.colonia_paciente,osiris_his_paciente.municipio_paciente,osiris_his_paciente.codigo_postal_paciente,osiris_his_paciente.estado_paciente, " +
                                      "osiris_his_paciente.estado_civil_paciente,osiris_his_paciente.ocupacion_paciente,osiris_his_paciente.telefono_particular1_paciente, " +
                                      "to_char(to_number(to_char(age('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',fecha_nacimiento_paciente),'yyyy') ,'9999'),'9999') AS edad, " +
                                      "to_char(to_number(to_char(age('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',osiris_his_paciente.fecha_nacimiento_paciente),'MM'),'99'),'99') AS mesesedad," +
                                      "osiris_empresas.descripcion_empresa,osiris_empresas.direccion_empresa,osiris_empresas.telefono1_empresa,osiris_empresas.numero_direccion_empresa,osiris_empresas.colonia_empresa,osiris_his_tipo_pacientes.descripcion_tipo_paciente, " +
                                      "osiris_erp_cobros_enca.responsable_cuenta,osiris_erp_cobros_enca.direccion_responsable_cuenta,osiris_erp_cobros_enca.telefono1_responsable_cuenta, " +
                                      "osiris_erp_cobros_enca.ocupacion_responsable,osiris_erp_cobros_enca.parentezco,osiris_erp_cobros_enca.empresa_labora_responsable, " +
                                      "osiris_erp_cobros_enca.direccion_emp_responsable,osiris_erp_cobros_enca.telefono_emp_responsable,osiris_erp_cobros_enca.paciente_asegurado, " +
                                      "osiris_erp_cobros_enca.numero_poliza,osiris_his_medicos.nombre_medico,osiris_his_medicos.id_especialidad,osiris_his_tipo_especialidad.descripcion_especialidad, osiris_his_medicos.cedula_medico, " +
                                      "osiris_erp_movcargos.folio_de_servicio,to_char(osiris_erp_movcargos.fechahora_admision_registro,'dd-MM-yyyy') AS fecha_reg_adm, " +
                                      "osiris_erp_cobros_enca.nombre_medico_tratante," +
                                      "to_char(fechahora_admision_registro,'HH24:mi:ss') AS hora_reg_adm,osiris_his_tipo_admisiones.descripcion_admisiones, " +
                                      "osiris_his_tipo_cirugias.descripcion_cirugia,osiris_his_tipo_diagnosticos.id_diagnostico, " +
                                      "osiris_his_tipo_diagnosticos.descripcion_diagnostico,descripcion_diagnostico_movcargos,descripcion_aseguradora," +
                                      "osiris_erp_cobros_enca.nombre_empresa_encabezado,observacion_ingreso,osiris_his_paciente.alegias_paciente,osiris_his_paciente.religion_paciente," +
                                      "osiris_erp_cobros_enca.id_empresa AS idempresa_enca,curp_paciente,rfc_paciente,lugar_nacimiento_paciente " +
                                      "FROM osiris_erp_cobros_enca,osiris_his_medicos,osiris_empresas,osiris_erp_movcargos,osiris_his_paciente,osiris_his_tipo_pacientes,osiris_his_tipo_cirugias,osiris_his_tipo_diagnosticos,osiris_his_tipo_admisiones,osiris_his_tipo_especialidad,osiris_aseguradoras " +
                                      "WHERE osiris_erp_cobros_enca.id_medico = osiris_his_medicos.id_medico " +
                                      "AND osiris_erp_cobros_enca.folio_de_servicio = osiris_erp_movcargos.folio_de_servicio " +
                                      "AND osiris_erp_cobros_enca.pid_paciente = osiris_erp_movcargos.pid_paciente " +
                                      "AND osiris_erp_movcargos.pid_paciente = osiris_his_paciente.pid_paciente " +
                                      "AND osiris_his_tipo_cirugias.id_tipo_cirugia = osiris_erp_movcargos.id_tipo_cirugia " +
                                      "AND osiris_his_tipo_diagnosticos.id_diagnostico = osiris_erp_movcargos.id_diagnostico " +
                                      "AND osiris_empresas.id_empresa = osiris_erp_cobros_enca.id_empresa " +
                                      "AND osiris_his_medicos.id_especialidad = osiris_his_tipo_especialidad.id_especialidad " +
                                      "AND osiris_his_tipo_pacientes.id_tipo_paciente = osiris_erp_movcargos.id_tipo_paciente " +
                                      "AND osiris_erp_movcargos.id_tipo_admisiones = osiris_his_tipo_admisiones.id_tipo_admisiones " +
                                      "AND osiris_aseguradoras.id_aseguradora = osiris_erp_cobros_enca.id_aseguradora " +
                                      "AND osiris_his_paciente.pid_paciente = '" + PidPaciente.ToString() + "' " +
                                      "AND osiris_erp_movcargos.folio_de_servicio = '" + folioservicio.ToString() + "'";

                NpgsqlDataReader lector = comando.ExecuteReader();

                if ((bool)lector.Read())
                {
                    medico_tratante = (string)lector["nombre_medico_tratante"];
                    string edadpac  = (string)lector["edad"];
                    string mesespac = (string)lector["mesesedad"];
                    //string varpaso = (string) lector["descripcion_admisiones"];
                    imprime_encabezado(cr, layout);
                    fontSize  = 8.0;
                    desc.Size = (int)(fontSize * pangoScale);               layout.FontDescription = desc;
                    /////////COMIENZA IMPRESION DE CUERPO DE DOCUMENTO//////////////////
                    layout.FontDescription.Weight = Weight.Bold;                       // Letra Negrita
                    cr.MoveTo(489.5 * escala_en_linux_windows, 20 * escala_en_linux_windows);                                   layout.SetText("Nº Expediente");
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(509.5 * escala_en_linux_windows, 30 * escala_en_linux_windows);                                   layout.SetText(" " + PidPaciente.ToString());
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(509.5 * escala_en_linux_windows, 40 * escala_en_linux_windows);                                   layout.SetText("PID");
                    cr.MoveTo(240 * escala_en_linux_windows, 100 * escala_en_linux_windows);                            layout.SetText("DATOS GENERALES DEL PACIENTE");
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    layout.FontDescription.Weight = Weight.Normal;                       // Letra Normal
                    int numero_linea = 120;
                    cr.MoveTo(20 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                            layout.SetText("Nombre: " + (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());                                        Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(56 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                            layout.SetText("_________________________________________________");
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(290 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                   layout.SetText("F. de Nac: " + (string)lector["fecha_nac_pa"]);                                  Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(329 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                   layout.SetText("________________");                                     Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(410 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                   layout.SetText("Edad: " + edadpac + " años " + mesespac + " Meses");                            Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(430 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                   layout.SetText("______________________");                                       Pango.CairoHelper.ShowLayout(cr, layout);

                    numero_linea += separacionlineas;
                    cr.MoveTo(20 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                    layout.SetText("C.U.R.P.: " + (string)lector["curp_paciente"].ToString().Trim());        Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(170 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                   layout.SetText("R.F.C.: " + (string)lector["rfc_paciente"].ToString().Trim());           Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(310 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                   layout.SetText("Lugar Nac.: " + (string)lector["lugar_nacimiento_paciente"].ToString().Trim());          Pango.CairoHelper.ShowLayout(cr, layout);

                    numero_linea += separacionlineas;

                    cr.MoveTo(20 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                            layout.SetText("Dirección: " + (string)lector["direccion_paciente"] + "  " +
                                                                                                                                                               (string)lector["numero_casa_paciente"] + " " + (string)lector["numero_departamento_paciente"] + ", Col. " +
                                                                                                                                                               (string)lector["colonia_paciente"] + ", CP. " + (string)lector["codigo_postal_paciente"] + ", " + (string)lector["municipio_paciente"] + ", " + (string)lector["estado_paciente"]);                                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(58 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                            layout.SetText("________________________________________________________________________________________________");                                     Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(460 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                           layout.SetText("Telefono :" + (string)lector["telefono_particular1_paciente"].ToString().Trim());                                        Pango.CairoHelper.ShowLayout(cr, layout);
                    numero_linea += separacionlineas;

                    cr.MoveTo(20 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                            layout.SetText("Ocupación: " + (string)lector["ocupacion_paciente"]);                                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(58 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                            layout.SetText("________________________________");                                     Pango.CairoHelper.ShowLayout(cr, layout);

                    if ((int)lector["idempresa_enca"] == 1)
                    {
                        cr.MoveTo(310 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                           layout.SetText("Labora en:  " + (string)lector["nombre_empresa_encabezado"]);            Pango.CairoHelper.ShowLayout(cr, layout);
                    }
                    else
                    {
                        cr.MoveTo(310 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                           layout.SetText("Labora en:  " + (string)lector["descripcion_empresa"]);                  Pango.CairoHelper.ShowLayout(cr, layout);
                    }

                    cr.MoveTo(360 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                   layout.SetText("___________________________________");
                    Pango.CairoHelper.ShowLayout(cr, layout);

                    numero_linea += separacionlineas;
                    //cr.MoveTo(20*escala_en_linux_windows, numero_linea*escala_en_linux_windows);						layout.SetText("Dirección Empresa:  "+(string) lector["direccion_empresa"]);
                    //Pango.CairoHelper.ShowLayout (cr, layout);
                    //cr.MoveTo(90*escala_en_linux_windows, numero_linea*escala_en_linux_windows);						layout.SetText("______________________________________");
                    //Pango.CairoHelper.ShowLayout (cr, layout);
                    //cr.MoveTo(310*escala_en_linux_windows, numero_linea*escala_en_linux_windows);					layout.SetText("Tel. de la Empresa:  "+(string) lector["telefono1_empresa"]);
                    //Pango.CairoHelper.ShowLayout (cr, layout);
                    //cr.MoveTo(380*escala_en_linux_windows, numero_linea*escala_en_linux_windows);					layout.SetText("_________________________");
                    //Pango.CairoHelper.ShowLayout (cr, layout);
                    //numero_linea += separacionlineas;
                    layout.FontDescription.Weight = Weight.Bold;
                    //layout.FontDescription.
                    cr.MoveTo(20 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                            layout.SetText("Tipo de paciente:  " + (string)lector["descripcion_tipo_paciente"]);
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(90 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                            layout.SetText("______________________________");
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    layout.FontDescription.Weight = Weight.Normal;
                    cr.MoveTo(310 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                   layout.SetText("Estado Civil:" + " " + (string)lector["estado_civil_paciente"]);
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(357 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                   layout.SetText("_______________");
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    string sexo_paciente = "";
                    if ((string)lector["sexo_paciente"] == "H")
                    {
                        sexo_paciente = "Masculino";
                    }
                    else
                    {
                        sexo_paciente = "Femenino";
                    }

                    cr.MoveTo(500 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                   layout.SetText("Sexo: " + sexo_paciente);                 Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(521 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                   layout.SetText("____________");                                 Pango.CairoHelper.ShowLayout(cr, layout);
                    numero_linea += separacionlineas;
                    cr.MoveTo(20 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                    layout.SetText("Religion: " + (string)lector["religion_paciente"]);                                      Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(310 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                   layout.SetText("Alergias: " + (string)lector["alegias_paciente"]);                                       Pango.CairoHelper.ShowLayout(cr, layout);
                    numero_linea += separacionlineas;
                    //cr.MoveTo(20*escala_en_linux_windows, numero_linea*escala_en_linux_windows);					layout.SetText("Referido por: ");					Pango.CairoHelper.ShowLayout (cr, layout);
                    //numero_linea += separacionlineas;
                    cr.MoveTo(20 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                    layout.SetText("Serv. Medico: " + (string)lector["observacion_ingreso"]);                                        Pango.CairoHelper.ShowLayout(cr, layout);
                    numero_linea += separacionlineas;
                    numero_linea += separacionlineas;
                    layout.FontDescription.Weight = Weight.Bold;
                    cr.MoveTo(260 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                   layout.SetText("DATOS DEL RESPONSABLE");
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    layout.FontDescription.Weight = Weight.Normal;
                    numero_linea += separacionlineas;
                    numero_linea += separacionlineas;
                    cr.MoveTo(20 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                            layout.SetText("Nombre de la persona responsable del paciente:  " + (string)lector["responsable_cuenta"]);
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(193 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                   layout.SetText("___________________________________________________________");
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    numero_linea += separacionlineas;
                    cr.MoveTo(20 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                            layout.SetText("Dirección:  " + (string)lector["direccion_responsable_cuenta"]);
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(56 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                            layout.SetText("___________________________________________________________________________________________");
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    numero_linea += separacionlineas;
                    cr.MoveTo(20 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                            layout.SetText("Tel:  " + (string)lector["telefono1_responsable_cuenta"]);
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(37 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                            layout.SetText("_________________");
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    numero_linea += separacionlineas;
                    //cr.MoveTo(20*escala_en_linux_windows, numero_linea*escala_en_linux_windows);						layout.SetText("Ocupación del responsable:  "+(string) lector["ocupacion_responsable"]);
                    //Pango.CairoHelper.ShowLayout (cr, layout);
                    //cr.MoveTo(126*escala_en_linux_windows, numero_linea*escala_en_linux_windows);					layout.SetText("__________________________________");
                    //Pango.CairoHelper.ShowLayout (cr, layout);
                    cr.MoveTo(20 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                    layout.SetText("Parentesco:  " + (string)lector["parentezco"]);
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(393 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                   layout.SetText("________________________");
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    numero_linea += separacionlineas;
                    cr.MoveTo(20 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                            layout.SetText("Empresa donde labora:  " + (string)lector["empresa_labora_responsable"]);
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(103 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                   layout.SetText("_______________________________________");
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(345 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                   layout.SetText("Tel. de Empresa:  " + (string)lector["telefono_emp_responsable"]);
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(406 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                   layout.SetText("________________________");
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    //numero_linea += separacionlineas;
                    //cr.MoveTo(20*escala_en_linux_windows, numero_linea*escala_en_linux_windows);						layout.SetText("Responsable de la cuenta(Aseguradora y/o membresia):  "+(string) lector["descripcion_aseguradora"]);
                    //Pango.CairoHelper.ShowLayout (cr, layout);
                    //cr.MoveTo(224*escala_en_linux_windows, numero_linea*escala_en_linux_windows);					layout.SetText("__________________________________________");
                    //Pango.CairoHelper.ShowLayout (cr, layout);
                    //cr.MoveTo(450*escala_en_linux_windows, numero_linea*escala_en_linux_windows);					layout.SetText("Nº de poliza:  "+(string) lector["numero_poliza"]);
                    //Pango.CairoHelper.ShowLayout (cr, layout);
                    //cr.MoveTo(498*escala_en_linux_windows, numero_linea*escala_en_linux_windows);					layout.SetText("____________________");
                    //Pango.CairoHelper.ShowLayout (cr, layout);
                    numero_linea += separacionlineas;
                    cr.MoveTo(20 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                            layout.SetText("Dirección:  " + (string)lector["direccion_emp_responsable"]);
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(60 * escala_en_linux_windows, numero_linea * escala_en_linux_windows);                                            layout.SetText("___________________________________________________________________________");
                    Pango.CairoHelper.ShowLayout(cr, layout);

                    layout.FontDescription.Weight = Weight.Bold;
                    cr.MoveTo(270 * escala_en_linux_windows, 350 * escala_en_linux_windows);                                    layout.SetText("DATOS DE ADMISION");
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(20 * escala_en_linux_windows, 375 * escala_en_linux_windows);                                         layout.SetText("Nº de Ingreso:  " + folioservicio.ToString());
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    layout.FontDescription.Weight = Weight.Normal;
                    cr.MoveTo(79 * escala_en_linux_windows, 375 * escala_en_linux_windows);                                             layout.SetText("__________");
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(140 * escala_en_linux_windows, 375 * escala_en_linux_windows);                            layout.SetText("Nº de habitacion:  ");
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(200 * escala_en_linux_windows, 375 * escala_en_linux_windows);                                    layout.SetText("____________");
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(280 * escala_en_linux_windows, 375 * escala_en_linux_windows);                            layout.SetText("Fecha de Admision:  " + (string)lector["fecha_reg_adm"]);
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(350 * escala_en_linux_windows, 375 * escala_en_linux_windows);                                    layout.SetText("_____________");
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(430 * escala_en_linux_windows, 375 * escala_en_linux_windows);                            layout.SetText("Hora de admision:" + " " + (string)lector["hora_reg_adm"]);       //DateTime.Now.ToString("HH:mm"));
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(495 * escala_en_linux_windows, 375 * escala_en_linux_windows);                                    layout.SetText("_____________");
                    Pango.CairoHelper.ShowLayout(cr, layout);

                    if ((int)lector["id_medico"] > 1)
                    {
                        cr.MoveTo(20 * escala_en_linux_windows, 390 * escala_en_linux_windows);                                     layout.SetText("Medico 1º Diag.:  " + (string)lector["nombre_medico"]);
                        Pango.CairoHelper.ShowLayout(cr, layout);
                        cr.MoveTo(80 * escala_en_linux_windows, 390 * escala_en_linux_windows);                                     layout.SetText("_____________________________________________");
                        Pango.CairoHelper.ShowLayout(cr, layout);
                    }
                    else
                    {
                        cr.MoveTo(20 * escala_en_linux_windows, 390 * escala_en_linux_windows);                                     layout.SetText("Medico 1º Diag.:  " + (string)lector["nombre_medico_encabezado"]);
                        Pango.CairoHelper.ShowLayout(cr, layout);
                        cr.MoveTo(80 * escala_en_linux_windows, 390 * escala_en_linux_windows);                                     layout.SetText("_____________________________________________");
                        Pango.CairoHelper.ShowLayout(cr, layout);
                    }

                    cr.MoveTo(350 * escala_en_linux_windows, 390 * escala_en_linux_windows);                                    layout.SetText("Especialidad:  " + (string)lector["descripcion_especialidad"]);
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(400 * escala_en_linux_windows, 390 * escala_en_linux_windows);                                    layout.SetText("____________________________________");
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(383 * escala_en_linux_windows, 439 * escala_en_linux_windows);                                    layout.SetText("Firma:");
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(408 * escala_en_linux_windows, 439 * escala_en_linux_windows);                                    layout.SetText("_______________________");
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(383 * escala_en_linux_windows, 422 * escala_en_linux_windows);                                    layout.SetText("Ced. Prof.:  " + (string)lector["cedula_medico"]);
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(424 * escala_en_linux_windows, 422 * escala_en_linux_windows);                                    layout.SetText("______________________________");
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(20 * escala_en_linux_windows, 406 * escala_en_linux_windows);                                             layout.SetText("Cirugia: " + (string)lector["descripcion_cirugia"]);
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(50 * escala_en_linux_windows, 406 * escala_en_linux_windows);                                             layout.SetText("___________________________________________________________________________________________________");
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(20 * escala_en_linux_windows, 422 * escala_en_linux_windows);                                             layout.SetText("Ingresado por: " + (string)lector["id_empleado_admision"]);
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(75 * escala_en_linux_windows, 422 * escala_en_linux_windows);                                             layout.SetText("________________________________");
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(20 * escala_en_linux_windows, 444 * escala_en_linux_windows);                                             layout.SetText("Motivo de Ingreso: " + (string)lector["descripcion_diagnostico_movcargos"]);
                    Pango.CairoHelper.ShowLayout(cr, layout);


                    /*
                     * layout.FontDescription.Weight = Weight.Bold;
                     * cr.MoveTo(220*escala_en_linux_windows, 453*escala_en_linux_windows);					layout.SetText("PARA SER LLENADO POR EL MEDICO TRATANTE");
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     * layout.FontDescription.Weight = Weight.Normal;
                     * cr.MoveTo(20*escala_en_linux_windows, 465*escala_en_linux_windows);						layout.SetText("Medico Tratante: "+medico_tratante);
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     * cr.MoveTo(82*escala_en_linux_windows, 465*escala_en_linux_windows);						layout.SetText("__________________________________");
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     * cr.MoveTo(20*escala_en_linux_windows, 477*escala_en_linux_windows);						layout.SetText("Diagnostico:  "+(string) lector["descripcion_diagnostico_movcargos"]);
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     * cr.MoveTo(70*escala_en_linux_windows, 477*escala_en_linux_windows);						layout.SetText("__________________________________________________________________________________________________________");
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     * cr.MoveTo(20*escala_en_linux_windows, 489*escala_en_linux_windows);						layout.SetText("Observaciones: ");
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     * cr.MoveTo(82*escala_en_linux_windows, 489*escala_en_linux_windows);						layout.SetText("_____________________________________________________");
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     * cr.MoveTo(20*escala_en_linux_windows, 501*escala_en_linux_windows);						layout.SetText("Diagnostico provisional (Para ser llenado dentro de las primeras 24 Hrs):");
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     * cr.MoveTo(20*escala_en_linux_windows, 513*escala_en_linux_windows);						layout.SetText("____________________________________________________________________________________________________________________________");
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     * cr.MoveTo(20*escala_en_linux_windows, 525*escala_en_linux_windows);						layout.SetText("____________________________________________________________________________________________________________________________");
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     * cr.MoveTo(20*escala_en_linux_windows, 537*escala_en_linux_windows);						layout.SetText("____________________________________________________________________________________________________________________________");
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     * cr.MoveTo(20*escala_en_linux_windows, 549*escala_en_linux_windows);						layout.SetText("Diagnostico Final:");
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     * cr.MoveTo(20*escala_en_linux_windows, 561*escala_en_linux_windows);						layout.SetText("____________________________________________________________________________________________________________________________");
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     * cr.MoveTo(20*escala_en_linux_windows, 573*escala_en_linux_windows);						layout.SetText("____________________________________________________________________________________________________________________________");
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     * cr.MoveTo(20*escala_en_linux_windows, 585*escala_en_linux_windows);						layout.SetText("____________________________________________________________________________________________________________________________");
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     * cr.MoveTo(20*escala_en_linux_windows, 597*escala_en_linux_windows);						layout.SetText("____________________________________________________________________________________________________________________________");
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     * layout.FontDescription.Weight = Weight.Bold;
                     * cr.MoveTo(270*escala_en_linux_windows, 609*escala_en_linux_windows);					layout.SetText("CAUSA DE EGRESO");
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     * layout.FontDescription.Weight = Weight.Normal;
                     * cr.MoveTo(20*escala_en_linux_windows, 621*escala_en_linux_windows);						layout.SetText("Por Mejoria:");
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     * cr.MoveTo(60*escala_en_linux_windows, 621*escala_en_linux_windows);						layout.SetText("______________________");
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     * cr.MoveTo(20*escala_en_linux_windows, 633*escala_en_linux_windows);						layout.SetText("Evolucion:");
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     * cr.MoveTo(60*escala_en_linux_windows, 633*escala_en_linux_windows);						layout.SetText("______________________");
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     * cr.MoveTo(200*escala_en_linux_windows, 633*escala_en_linux_windows);						layout.SetText("Por traslado:");
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     * cr.MoveTo(245*escala_en_linux_windows, 633*escala_en_linux_windows);						layout.SetText("______________________");
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     * cr.MoveTo(200*escala_en_linux_windows, 621*escala_en_linux_windows);					layout.SetText("Alta Voluntaria:");
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     * cr.MoveTo(260*escala_en_linux_windows, 621*escala_en_linux_windows);					layout.SetText("______________________");
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     * cr.MoveTo(383*escala_en_linux_windows, 621*escala_en_linux_windows);					layout.SetText("Por no Mejoria:");
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     * cr.MoveTo(444*escala_en_linux_windows, 621*escala_en_linux_windows);					layout.SetText("______________________");
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     * cr.MoveTo(383*escala_en_linux_windows, 633*escala_en_linux_windows);					layout.SetText("Por Defunción:");
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     * cr.MoveTo(444*escala_en_linux_windows, 633*escala_en_linux_windows);					layout.SetText("______________________");
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     * cr.MoveTo(20*escala_en_linux_windows, 668*escala_en_linux_windows);					layout.SetText("______________________________");
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     * cr.MoveTo(40*escala_en_linux_windows, 677*escala_en_linux_windows);					layout.SetText("medico_tratante");
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     * cr.MoveTo(435*escala_en_linux_windows, 677*escala_en_linux_windows);					layout.SetText("FIRMA DE MEDICO TRATANTE");
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     * cr.MoveTo(400*escala_en_linux_windows, 668*escala_en_linux_windows);						layout.SetText("____________________________________");
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     *
                     * cr.MoveTo(220*escala_en_linux_windows, 735*escala_en_linux_windows);						layout.SetText("Nombre y Firma Paciente o responsable");
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     * //cr.MoveTo(250*escala_en_linux_windows, 700*escala_en_linux_windows);			            layout.SetText("verificacion de datos");
                     * //Pango.CairoHelper.ShowLayout (cr, layout);
                     * cr.MoveTo(20*escala_en_linux_windows, 724*escala_en_linux_windows);						layout.SetText("____________________________________________________________________________________________________________________________");
                     * Pango.CairoHelper.ShowLayout (cr, layout);
                     */



                    cr.MoveTo(20 * escala_en_linux_windows, 760 * escala_en_linux_windows);                                    layout.SetText("REV.00");
                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(480 * escala_en_linux_windows, 760 * escala_en_linux_windows);                                   layout.SetText("FI-7.5.1/01");
                    Pango.CairoHelper.ShowLayout(cr, layout);


                    //string varpaso = (string) lector["descripcion_admisiones"];
                    //while ((bool) lector.Read()){
                    //		varpaso = varpaso +", "+(string) lector["descripcion_admisiones"];
                    //}
                    //cr.MoveTo(20*escala_en_linux_windows, 410*escala_en_linux_windows);						layout.SetText("Admisión:  "+(string) varpaso);
                    //cr.MoveTo(60*escala_en_linux_windows, 410*escala_en_linux_windows);						layout.SetText("__________________________________________________________________");
                }

                lector.Close();
                conexion.Close();
                //cr.ShowPage();
            }catch (NpgsqlException ex) {
                Console.WriteLine("PostgresSQL error: {0}", ex.Message);
                MessageDialog msgBoxError = new MessageDialog(MyWinError, DialogFlags.DestroyWithParent, MessageType.Info, ButtonsType.Close, "PostgresSQL error: {0}", ex.Message);
                msgBoxError.Run();     msgBoxError.Destroy();
                return;
            }
        }
Пример #33
0
        void imprime_encabezado(Cairo.Context cr, Pango.Layout layout)
        {
            //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(480 * escala_en_linux_windows, 15 * escala_en_linux_windows);                      layout.SetText("FOLIO DE ATENCION");                            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);
            cr.MoveTo(510 * escala_en_linux_windows, 25 * escala_en_linux_windows);                      layout.SetText(folioservicio.ToString());                       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(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, 25 * escala_en_linux_windows);                     layout.SetText("HOJA REGISTROS DE " + area);                              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(220 * escala_en_linux_windows, 45 * escala_en_linux_windows);                      layout.SetText("DATOS GENERALES DEL PACIENTE");                 Pango.CairoHelper.ShowLayout(cr, layout);
            fontSize  = 7.0;
            desc.Size = (int)(fontSize * pangoScale);                                       layout.FontDescription = desc;
            layout.FontDescription.Weight = Weight.Normal;                      // Letra negrita
            cr.MoveTo(05 * escala_en_linux_windows, 55 * escala_en_linux_windows);                       layout.SetText("INGRESO:" + fecha_admision.Trim());       Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(465 * escala_en_linux_windows, 55 * escala_en_linux_windows);                      layout.SetText("EGRESO:" + fechahora_alta.Trim());        Pango.CairoHelper.ShowLayout(cr, layout);
            layout.FontDescription.Weight = Weight.Bold;                        // Letra negrita
            cr.MoveTo(05 * escala_en_linux_windows, 65 * escala_en_linux_windows);                       layout.SetText("EXP.: " + PidPaciente.ToString() + "	Nombre Paciente:"+ nombre_paciente.ToString());  Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(340 * escala_en_linux_windows, 65 * escala_en_linux_windows);                      layout.SetText("Fecha de Nacimiento: " + fecha_nacimiento.ToString());    Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(500 * escala_en_linux_windows, 65 * escala_en_linux_windows);                      layout.SetText("Edad: " + edadpac.ToString());                                                    Pango.CairoHelper.ShowLayout(cr, layout);
            layout.FontDescription.Weight = Weight.Normal;                      // Letra normal
            cr.MoveTo(05 * escala_en_linux_windows, 75 * escala_en_linux_windows);                       layout.SetText("Direccion: " + dir_pac.ToString());                                                       Pango.CairoHelper.ShowLayout(cr, layout);
            cr.MoveTo(05 * escala_en_linux_windows, 85 * escala_en_linux_windows);                       layout.SetText("Tel. Pac.: " + telefono_paciente.ToString());                                     Pango.CairoHelper.ShowLayout(cr, layout);
            //cr.MoveTo(400*escala_en_linux_windows,85*escala_en_linux_windows);			layout.SetText("Nº Hab/Sala: "+entry_id_habitacion.Trim());					Pango.CairoHelper.ShowLayout (cr, layout);
            layout.FontDescription.Weight = Weight.Bold;                        // Letra negrita
            if ((string)aseguradora == "Asegurado")
            {
                cr.MoveTo(05 * escala_en_linux_windows, 95 * escala_en_linux_windows);                       layout.SetText("Tipo de paciente: " + tipo_paciente.ToString() + "	Aseguradora: " + aseguradora.ToString() + "	Poliza: ");                                     Pango.CairoHelper.ShowLayout(cr, layout);
            }
            else
            {
                cr.MoveTo(05 * escala_en_linux_windows, 95 * escala_en_linux_windows);                       layout.SetText("Tipo de paciente: " + tipo_paciente.ToString() + "	Empresa: " + empresapac.ToString());                                      Pango.CairoHelper.ShowLayout(cr, layout);
            }
            layout.FontDescription.Weight = Weight.Normal;                      // Letra normal
            cr.MoveTo(05 * escala_en_linux_windows, 105 * escala_en_linux_windows);                      layout.SetText("Medico: " + doctor.ToString());                                   Pango.CairoHelper.ShowLayout(cr, layout);
            //cr.MoveTo(250*escala_en_linux_windows,105*escala_en_linux_windows);			layout.SetText("Especialidad: "+entry_especialidad.ToString());	Pango.CairoHelper.ShowLayout (cr, layout);
            cr.MoveTo(05 * escala_en_linux_windows, 115 * escala_en_linux_windows);                      layout.SetText("Cirugia/Diagnostico: " + cirugia.ToString());             Pango.CairoHelper.ShowLayout(cr, layout);
            // Creando el Cuadro de Titulos para colocar el nombre del usuario
            cr.Rectangle(05 * escala_en_linux_windows, 125 * 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();
            cr.MoveTo(08 * escala_en_linux_windows, 128 * escala_en_linux_windows);                      layout.SetText("Usuario que realizo los cargos: " + LoginEmpleado + " -- " + NomEmpleado.Trim() + " " + AppEmpleado.Trim() + " " + ApmEmpleado.Trim());               Pango.CairoHelper.ShowLayout(cr, layout);
        }
Пример #34
0
        protected override bool OnExposeEvent(Gdk.EventExpose e)
        {
            Gdk.Drawable  draw = e.Window;
            Gdk.Rectangle area = e.Area;
            if (this.categories.Count == 0 || !string.IsNullOrEmpty(CustomMessage))
            {
                Pango.Layout messageLayout = new Pango.Layout(this.PangoContext);
                messageLayout.Alignment = Pango.Alignment.Center;
                messageLayout.Width     = (int)(Allocation.Width * 2 / 3 * Pango.Scale.PangoScale);
                if (!string.IsNullOrEmpty(CustomMessage))
                {
                    messageLayout.SetText(CustomMessage);
                }
                else
                {
                    messageLayout.SetText(MonoDevelop.Core.GettextCatalog.GetString("There are no tools available for the current document."));
                }
                draw.DrawLayout(Style.TextGC(StateType.Normal), Allocation.Width * 1 / 6, 12, messageLayout);
                messageLayout.Dispose();
                return(true);
            }

            Cairo.Context cr = Gdk.CairoHelper.Create(e.Window);
            draw.DrawRectangle(Style.BaseGC(StateType.Normal), true, area);
            int xpos        = (this.hAdjustement != null ? (int)this.hAdjustement.Value : 0);
            int vadjustment = (this.vAdjustement != null ? (int)this.vAdjustement.Value : 0);
            int ypos        = -vadjustment;

            Iterate(ref xpos, ref ypos, delegate(Category category, Gdk.Size itemDimension) {
                const int foldSegmentHeight = 8;

                if (category == SelectedItem)
                {
                    draw.DrawRectangle(Style.BaseGC(StateType.Selected),
                                       true,
                                       new Gdk.Rectangle(xpos,
                                                         ypos,
                                                         itemDimension.Width,
                                                         itemDimension.Height));
                }
                else
                {
                    cr.NewPath();
                    cr.MoveTo(xpos, ypos);
                    cr.RelLineTo(itemDimension.Width, 0);
                    cr.RelLineTo(0, itemDimension.Height);
                    cr.RelLineTo(-itemDimension.Width, 0);
                    cr.RelLineTo(0, -itemDimension.Height);
                    cr.ClosePath();
                    using (var pat = new Cairo.LinearGradient(xpos, ypos, xpos, ypos + itemDimension.Height)) {
                        Cairo.Color ccol = Convert(Style.Mid(StateType.Normal));
                        ccol.A           = 0.2;
                        pat.AddColorStop(0, ccol);
                        ccol.A = 1;
                        pat.AddColorStop(1, ccol);
                        cr.Pattern = pat;
                        cr.FillPreserve();
                    }
                }
                DrawFoldSegment(draw, xpos + 2, ypos + (itemDimension.Height - foldSegmentHeight) / 2, foldSegmentHeight, foldSegmentHeight, category.IsExpanded, category == mouseOverItem && mouseX < xpos + 2 + 12);
                headerLayout.SetText(category.Text);
                int width, height;
                layout.GetPixelSize(out width, out height);
                draw.DrawLayout(Style.TextGC(category != this.SelectedItem ? StateType.Normal : StateType.Selected), xpos + 2 + 12, ypos + (itemDimension.Height - height) / 2, headerLayout);
                if (category == mouseOverItem)
                {
                    draw.DrawRectangle(Style.DarkGC(StateType.Prelight),
                                       false,
                                       new Gdk.Rectangle(xpos,
                                                         ypos,
                                                         itemDimension.Width - 1,
                                                         itemDimension.Height - 1));
                }
            }, delegate(Category curCategory, Item item, Gdk.Size itemDimension) {
                if (item == SelectedItem)
                {
                    draw.DrawRectangle(Style.BaseGC(StateType.Selected),
                                       true,
                                       new Gdk.Rectangle(xpos,
                                                         ypos,
                                                         itemDimension.Width,
                                                         itemDimension.Height));
                }
                if (listMode || !curCategory.CanIconizeItems)
                {
                    draw.DrawPixbuf(this.Style.ForegroundGC(StateType.Normal),
                                    item.Icon, 0, 0,
                                    xpos + 4,
                                    ypos + 1 + (itemDimension.Height - item.Icon.Height) / 2,
                                    item.Icon.Width, item.Icon.Height, Gdk.RgbDither.None, 0, 0);
                    layout.SetText(item.Text);
                    int width, height;
                    layout.GetPixelSize(out width, out height);
                    draw.DrawLayout(Style.TextGC(item != this.SelectedItem ? StateType.Normal : StateType.Selected), xpos + IconSize.Width + 4, ypos + (itemDimension.Height - height) / 2, layout);
                }
                else
                {
                    draw.DrawPixbuf(this.Style.ForegroundGC(StateType.Normal),
                                    item.Icon, 0, 0,
                                    xpos + (itemDimension.Width - item.Icon.Width) / 2,
                                    ypos + (itemDimension.Height - item.Icon.Height) / 2,
                                    item.Icon.Width, item.Icon.Height, Gdk.RgbDither.None, 0, 0);
                }

                if (item == mouseOverItem)
                {
                    draw.DrawRectangle(Style.DarkGC(StateType.Prelight),
                                       false,
                                       new Gdk.Rectangle(xpos,
                                                         ypos,
                                                         itemDimension.Width,
                                                         itemDimension.Height));
                }
            });
            ((IDisposable)cr).Dispose();
            return(true);
        }
Пример #35
0
        protected override bool OnExposeEvent(Gdk.EventExpose args)
        {
            Gdk.Window window = args.Window;
            var        alloc  = Allocation;
            int        width  = alloc.Width;
            int        height = alloc.Height;

            int lineWidth = width - margin * 2;
            int xpos      = margin + padding;
            int yPos      = margin;

            if (PreviewCompletionString)
            {
                layout.SetText(string.IsNullOrEmpty(CompletionString) ? MonoDevelop.Core.GettextCatalog.GetString("Select template") : CompletionString);
                int wi, he;
                layout.GetPixelSize(out wi, out he);
                window.DrawRectangle(this.Style.BaseGC(StateType.Insensitive), true, margin, yPos, lineWidth, he + padding);
                window.DrawLayout(string.IsNullOrEmpty(CompletionString) ? this.Style.TextGC(StateType.Insensitive) : this.Style.TextGC(StateType.Normal), xpos, yPos, layout);
                yPos += rowHeight;
            }

            //when there are no matches, display a message to indicate that the completion list is still handling input
            if (filteredItems.Count == 0)
            {
                Gdk.GC gc = new Gdk.GC(window);
                gc.RgbFgColor = new Gdk.Color(0xff, 0xbc, 0xc1);
                window.DrawRectangle(gc, true, 0, yPos, width, height - yPos);
                gc.Dispose();
                layout.SetText(win.DataProvider.ItemCount == 0? NoSuggestionsMsg : NoMatchesMsg);
                int lWidth, lHeight;
                layout.GetPixelSize(out lWidth, out lHeight);
                window.DrawLayout(this.Style.TextGC(StateType.Normal), (width - lWidth) / 2, yPos + (height - lHeight - yPos) / 2, layout);
                return(true);
            }

            var textGCInsensitive = this.Style.TextGC(StateType.Insensitive);
            var textGCNormal      = this.Style.TextGC(StateType.Normal);
            var fgGCNormal        = this.Style.ForegroundGC(StateType.Normal);

            Iterate(true, ref yPos, delegate(Category category, int ypos) {
                if (ypos >= height - margin)
                {
                    return;
                }

                //	window.DrawRectangle (this.Style.BackgroundGC (StateType.Insensitive), true, 0, yPos, width, rowHeight);

                Gdk.Pixbuf icon = ImageService.GetPixbuf(category.CompletionCategory.Icon, IconSize.Menu);
                window.DrawPixbuf(fgGCNormal, icon, 0, 0, margin, ypos, icon.Width, icon.Height, Gdk.RgbDither.None, 0, 0);

                layout.SetMarkup("<span weight='bold'>" + category.CompletionCategory.DisplayText + "</span>");
                window.DrawLayout(textGCInsensitive, icon.Width + 4, ypos, layout);
                layout.SetMarkup("");
            }, delegate(Category curCategory, int item, int ypos) {
                if (ypos >= height - margin)
                {
                    return(false);
                }
                int itemIndex = filteredItems[item];
                if (InCategoryMode && curCategory != null && curCategory.CompletionCategory != null)
                {
                    xpos = margin + padding + 8;
                }
                else
                {
                    xpos = margin + padding;
                }
                string markup      = win.DataProvider.HasMarkup(itemIndex) ? (win.DataProvider.GetMarkup(itemIndex) ?? "&lt;null&gt;") : GLib.Markup.EscapeText(win.DataProvider.GetText(itemIndex) ?? "<null>");
                string description = win.DataProvider.GetDescription(itemIndex);

                if (string.IsNullOrEmpty(description))
                {
                    layout.SetMarkup(markup);
                }
                else
                {
                    if (item == selection)
                    {
                        layout.SetMarkup(markup + " " + description);
                    }
                    else
                    {
                        layout.SetMarkup(markup + " <span foreground=\"darkgray\">" + description + "</span>");
                    }
                }
                int mw, mh;
                layout.GetPixelSize(out mw, out mh);
                if (mw > listWidth)
                {
                    WidthRequest     = listWidth = mw;
                    win.WidthRequest = win.Allocation.Width + mw - width;
                    win.QueueResize();
                }

                string text = win.DataProvider.GetText(itemIndex);

                if ((!SelectionEnabled || item != selection) && !string.IsNullOrEmpty(text))
                {
                    int[] matchIndices = Match(CompletionString, text);
                    if (matchIndices != null)
                    {
                        Pango.AttrList attrList = layout.Attributes ?? new Pango.AttrList();
                        for (int newSelection = 0; newSelection < matchIndices.Length; newSelection++)
                        {
                            int idx = matchIndices[newSelection];
                            Pango.AttrForeground fg = new Pango.AttrForeground(0, 0, ushort.MaxValue);
                            fg.StartIndex           = (uint)idx;
                            fg.EndIndex             = (uint)(idx + 1);
                            attrList.Insert(fg);
                        }
                        layout.Attributes = attrList;
                    }
                }

                Gdk.Pixbuf icon = win.DataProvider.GetIcon(itemIndex);
                int iconHeight, iconWidth;
                if (icon != null)
                {
                    iconWidth  = icon.Width;
                    iconHeight = icon.Height;
                }
                else if (!Gtk.Icon.SizeLookup(Gtk.IconSize.Menu, out iconWidth, out iconHeight))
                {
                    iconHeight = iconWidth = 24;
                }

                int wi, he, typos, iypos;
                layout.GetPixelSize(out wi, out he);
                typos = he < rowHeight ? ypos + (rowHeight - he) / 2 : ypos;
                iypos = iconHeight < rowHeight ? ypos + (rowHeight - iconHeight) / 2 : ypos;
                if (item == selection)
                {
                    if (SelectionEnabled)
                    {
                        window.DrawRectangle(this.Style.BaseGC(StateType.Selected), true, margin, ypos, lineWidth, he + padding);
                        window.DrawLayout(this.Style.TextGC(StateType.Selected), xpos + iconWidth + 2, typos, layout);
                    }
                    else
                    {
                        window.DrawRectangle(this.Style.DarkGC(StateType.Prelight), false, margin, ypos, lineWidth - 1, he + padding - 1);
                        window.DrawLayout(textGCNormal, xpos + iconWidth + 2, typos, layout);
                    }
                }
                else
                {
                    window.DrawLayout(textGCNormal, xpos + iconWidth + 2, typos, layout);
                }
                if (icon != null)
                {
                    window.DrawPixbuf(fgGCNormal, icon, 0, 0, xpos, iypos, iconWidth, iconHeight, Gdk.RgbDither.None, 0, 0);
                }

                layout.SetMarkup("");
                if (layout.Attributes != null)
                {
                    layout.Attributes.Dispose();
                    layout.Attributes = null;
                }
                return(true);
            });

            /*
             * int n = 0;
             * while (ypos < winHeight - margin && (page + n) < filteredItems.Count) {
             *
             *      bool hasMarkup = win.DataProvider.HasMarkup (filteredItems[page + n]);
             *      if (hasMarkup) {
             *              layout.SetMarkup (win.DataProvider.GetMarkup (filteredItems[page + n]) ?? "&lt;null&gt;");
             *      } else {
             *              layout.SetText (win.DataProvider.GetText (filteredItems[page + n]) ?? "<null>");
             *      }
             *      string text = win.DataProvider.GetText (filteredItems[page + n]);
             *      if ((!SelectionEnabled || page + n != selection) && !string.IsNullOrEmpty (text)) {
             *              int[] matchIndices = Match (CompletionString, text);
             *              if (matchIndices != null) {
             *                      Pango.AttrList attrList = layout.Attributes ?? new Pango.AttrList ();
             *                      for (int newSelection = 0; newSelection < matchIndices.Length; newSelection++) {
             *                              int idx = matchIndices[newSelection];
             *                              Pango.AttrForeground fg = new Pango.AttrForeground (0, 0, ushort.MaxValue);
             *                              fg.StartIndex = (uint)idx;
             *                              fg.EndIndex = (uint)(idx + 1);
             *                              attrList.Insert (fg);
             *                      }
             *                      layout.Attributes = attrList;
             *              }
             *      }
             *
             *      Gdk.Pixbuf icon = win.DataProvider.GetIcon (filteredItems[page + n]);
             *      int iconHeight, iconWidth;
             *      if (icon != null) {
             *              iconWidth = icon.Width;
             *              iconHeight = icon.Height;
             *      } else if (!Gtk.Icon.SizeLookup (Gtk.IconSize.Menu, out iconWidth, out iconHeight)) {
             *              iconHeight = iconWidth = 24;
             *      }
             *
             *      int wi, he, typos, iypos;
             *      layout.GetPixelSize (out wi, out he);
             *      typos = he < rowHeight ? ypos + (rowHeight - he) / 2 : ypos;
             *      iypos = iconHeight < rowHeight ? ypos + (rowHeight - iconHeight) / 2 : ypos;
             *      if (page + n == selection) {
             *              if (SelectionEnabled) {
             *                      window.DrawRectangle (this.Style.BaseGC (StateType.Selected), true, margin, ypos, lineWidth, he + padding);
             *                      window.DrawLayout (this.Style.TextGC (StateType.Selected), xpos + iconWidth + 2, typos, layout);
             *              } else {
             *                      window.DrawRectangle (this.Style.DarkGC (StateType.Prelight), false, margin, ypos, lineWidth - 1, he + padding - 1);
             *                      window.DrawLayout (this.Style.TextGC (StateType.Normal), xpos + iconWidth + 2, typos, layout);
             *              }
             *      } else
             *              window.DrawLayout (this.Style.TextGC (StateType.Normal), xpos + iconWidth + 2, typos, layout);
             *      if (icon != null)
             *              window.DrawPixbuf (this.Style.ForegroundGC (StateType.Normal), icon, 0, 0, xpos, iypos, iconWidth, iconHeight, Gdk.RgbDither.None, 0, 0);
             *      ypos += rowHeight;
             *      n++;
             *      if (hasMarkup)
             *              layout.SetMarkup (string.Empty);
             *      if (layout.Attributes != null) {
             *              layout.Attributes.Dispose ();
             *              layout.Attributes = null;
             *      }
             * }
             */
            return(true);
        }
Пример #36
0
        /// <summary>
        /// Draws the text.
        /// </summary>
        /// <param name="p">The p.</param>
        /// <param name="text">The text.</param>
        /// <param name="fill">The fill color.</param>
        /// <param name="fontFamily">The font family.</param>
        /// <param name="fontSize">Size of the font.</param>
        /// <param name="fontWeight">The font weight.</param>
        /// <param name="rotate">The rotation angle.</param>
        /// <param name="halign">The horizontal alignment.</param>
        /// <param name="valign">The vertical alignment.</param>
        /// <param name="maxSize">The maximum size of the text.</param>
        public override void DrawText(
            ScreenPoint p,
            string text,
            OxyColor fill,
            string fontFamily,
            double fontSize,
            double fontWeight,
            double rotate,
            HorizontalAlignment halign,
            VerticalAlignment valign,
            OxySize?maxSize)
        {
            Pango.Layout          layout = Pango.CairoHelper.CreateLayout(this.g);
            Pango.FontDescription font   = new Pango.FontDescription();
            font.Family            = fontFamily;
            font.Weight            = (fontWeight >= 700) ? Pango.Weight.Bold : Pango.Weight.Normal;
            font.AbsoluteSize      = (int)(fontSize * Pango.Scale.PangoScale);
            layout.FontDescription = font;
            layout.SetText(text);
            Pango.Rectangle inkRect;
            Pango.Rectangle size;
            layout.GetExtents(out inkRect, out size);
            size.Width  /= (int)Pango.Scale.PangoScale;
            size.Height /= (int)Pango.Scale.PangoScale;
            if (maxSize != null)
            {
                int maxWidth  = (int)Math.Min((Double)Int32.MaxValue, maxSize.Value.Width);
                int maxHeight = (int)Math.Min((Double)Int32.MaxValue, maxSize.Value.Height);
                size.Width  = Math.Min(size.Width, maxWidth);
                size.Height = Math.Min(size.Height, maxHeight);
            }
            this.g.Save();
            double dx = 0;

            if (halign == HorizontalAlignment.Center)
            {
                dx = -size.Width / 2;
            }

            if (halign == HorizontalAlignment.Right)
            {
                dx = -size.Width;
            }

            double dy = 0;

            if (valign == VerticalAlignment.Middle)
            {
                dy = -size.Height / 2;
            }

            if (valign == VerticalAlignment.Bottom)
            {
                dy = -size.Height;
            }

            this.g.Translate(p.X, p.Y);
            if (Math.Abs(rotate) > double.Epsilon)
            {
                this.g.Rotate(rotate * Math.PI / 180.0);
            }

            this.g.Translate(dx, dy);

            g.Rectangle(0, 0, size.Width + 0.1f, size.Height + 0.1f);
            g.Clip();
            this.g.SetSourceColor(fill);
            Pango.CairoHelper.ShowLayout(this.g, layout);
            this.g.Restore();
        }
Пример #37
0
        protected override bool OnExposeEvent(Gdk.EventExpose e)
        {
            Cairo.Context cr = Gdk.CairoHelper.Create(e.Window);

            Gdk.Rectangle area = e.Area;

            if (this.categories.Count == 0 || !string.IsNullOrEmpty(CustomMessage))
            {
                Pango.Layout messageLayout = new Pango.Layout(this.PangoContext);
                messageLayout.Alignment = Pango.Alignment.Center;
                messageLayout.Width     = (int)(Allocation.Width * 2 / 3 * Pango.Scale.PangoScale);
                if (!string.IsNullOrEmpty(CustomMessage))
                {
                    messageLayout.SetText(CustomMessage);
                }
                else
                {
                    messageLayout.SetText(MonoDevelop.Core.GettextCatalog.GetString("There are no tools available for the current document."));
                }
                cr.MoveTo(Allocation.Width * 1 / 6, 12);
                cr.SetSourceColor(Style.Text(StateType.Normal).ToCairoColor());
                Pango.CairoHelper.ShowLayout(cr, messageLayout);
                messageLayout.Dispose();
                ((IDisposable)cr).Dispose();
                return(true);
            }

            var backColor = Style.Base(StateType.Normal).ToCairoColor();

            cr.SetSourceColor(backColor);
            cr.Rectangle(area.X, area.Y, area.Width, area.Height);
            cr.Fill();

            int      xpos             = (this.hAdjustement != null ? (int)this.hAdjustement.Value : 0);
            int      vadjustment      = (this.vAdjustement != null ? (int)this.vAdjustement.Value : 0);
            int      ypos             = -vadjustment;
            Category lastCategory     = null;
            int      lastCategoryYpos = 0;

            Iterate(ref xpos, ref ypos, delegate(Category category, Gdk.Size itemDimension) {
                const int foldSegmentHeight = 8;

                ProcessExpandAnimation(cr, lastCategory, lastCategoryYpos, backColor, area, ref ypos);

                cr.Rectangle(xpos, ypos, itemDimension.Width, itemDimension.Height);
                using (var pat = new Cairo.LinearGradient(xpos, ypos, xpos, ypos + itemDimension.Height)) {
                    pat.AddColorStop(0, CategoryBackgroundGradientStartColor);
                    pat.AddColorStop(1, CategoryBackgroundGradientEndColor);
                    cr.SetSource(pat);
                    cr.Fill();
                }
                if (lastCategory == null || lastCategory.IsExpanded || lastCategory.AnimatingExpand)
                {
                    cr.MoveTo(xpos, ypos + 0.5);
                    cr.LineTo(itemDimension.Width, ypos + 0.5);
                }
                cr.MoveTo(0, ypos + itemDimension.Height - 0.5);
                cr.LineTo(xpos + Allocation.Width, ypos + itemDimension.Height - 0.5);
                cr.SetSourceColor(CategoryBorderColor);
                cr.LineWidth = 1;
                cr.Stroke();

                headerLayout.SetText(category.Text);
                int width, height;
                cr.SetSourceColor(CategoryLabelColor);
                layout.GetPixelSize(out width, out height);
                cr.MoveTo(xpos + CategoryLeftPadding, ypos + (double)(Math.Round((double)(itemDimension.Height - height) / 2)));
                Pango.CairoHelper.ShowLayout(cr, headerLayout);

                var img = category.IsExpanded ? discloseUp : discloseDown;
                cr.DrawImage(this, img, Allocation.Width - img.Width - CategoryRightPadding, ypos + Math.Round((itemDimension.Height - img.Height) / 2));

                lastCategory     = category;
                lastCategoryYpos = ypos + itemDimension.Height;
            }, delegate(Category curCategory, Item item, Gdk.Size itemDimension) {
                if (item == SelectedItem)
                {
                    cr.SetSourceColor(Style.Base(StateType.Selected).ToCairoColor());
                    cr.Rectangle(xpos, ypos, itemDimension.Width, itemDimension.Height);
                    cr.Fill();
                }
                if (listMode || !curCategory.CanIconizeItems)
                {
                    cr.DrawImage(this, item.Icon, xpos + ItemLeftPadding, ypos + Math.Round((itemDimension.Height - item.Icon.Height) / 2));
                    layout.SetText(item.Text);
                    int width, height;
                    layout.GetPixelSize(out width, out height);
                    cr.SetSourceColor(Style.Text(item != this.SelectedItem ? StateType.Normal : StateType.Selected).ToCairoColor());
                    cr.MoveTo(xpos + ItemLeftPadding + IconSize.Width + ItemIconTextItemSpacing, ypos + (double)(Math.Round((double)(itemDimension.Height - height) / 2)));
                    Pango.CairoHelper.ShowLayout(cr, layout);
                }
                else
                {
                    cr.DrawImage(this, item.Icon, xpos + Math.Round((itemDimension.Width - item.Icon.Width) / 2), ypos + Math.Round((itemDimension.Height - item.Icon.Height) / 2));
                }

                if (item == mouseOverItem)
                {
                    cr.SetSourceColor(Style.Dark(StateType.Prelight).ToCairoColor());
                    cr.Rectangle(xpos + 0.5, ypos + 0.5, itemDimension.Width - 1, itemDimension.Height - 1);
                    cr.Stroke();
                }
            });

            ProcessExpandAnimation(cr, lastCategory, lastCategoryYpos, backColor, area, ref ypos);

            if (lastCategory != null && lastCategory.AnimatingExpand)
            {
                // Closing line when animating the last group of the toolbox
                cr.MoveTo(area.X, ypos + 0.5);
                cr.RelLineTo(area.Width, 0);
                cr.SetSourceColor(CategoryBorderColor);
                cr.Stroke();
            }

            ((IDisposable)cr).Dispose();
            return(true);
        }
Пример #38
0
        void ejecutar_consulta_reporte(PrintContext context)
        {
            Cairo.Context cr               = context.CairoContext;
            Pango.Layout  layout           = context.CreatePangoLayout();
            float         subtota_por_prod = 0;

            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;
            NpgsqlConnection conexion;

            conexion = new NpgsqlConnection(connectionString + nombrebd);
            // Verifica que la base de datos este conectada
            try{
                imprime_encabezado(cr, layout);
                fontSize  = 6.0;            layout = null;            layout = context.CreatePangoLayout();
                desc.Size = (int)(fontSize * pangoScale);        layout.FontDescription = desc;
                conexion.Open();
                NpgsqlCommand comando;
                comando             = conexion.CreateCommand();
                comando.CommandText = query1;
                //Console.WriteLine(comando.CommandText.ToString());
                NpgsqlDataReader lector     = comando.ExecuteReader();
                string           codigoprod = "";
                if (lector.Read())
                {
                    codigoprod = (string)lector["idproducto"];
                    cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);            layout.SetText((string)lector["idproducto"]);                    Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(75 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);            layout.SetText((string)lector["descripcion_producto"]);        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["foliodeservicio"]);        Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(55 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);            layout.SetText((string)lector["fechahoracreacion"]);        Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(105 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);            layout.SetText(lector ["cantidadaplicada"].ToString());        Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(135 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);            layout.SetText((string)lector["pidpaciente"]);        Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(180 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);            layout.SetText((string)lector["nombre_paciente"]);        Pango.CairoHelper.ShowLayout(cr, layout);
                    busca_tipoadmisiones(lector["foliodeservicio"].ToString().Trim());
                    cr.MoveTo(350 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);            layout.SetText(tipo_paciente);        Pango.CairoHelper.ShowLayout(cr, layout);
                    cr.MoveTo(460 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);            layout.SetText((string)lector["descripcion_empresa"]);        Pango.CairoHelper.ShowLayout(cr, layout);     comienzo_linea += separacion_linea;
                    salto_de_pagina(cr, layout);
                    subtota_por_prod = float.Parse(lector ["cantidadaplicada"].ToString());
                    busca_tipoadmisiones(lector["foliodeservicio"].ToString().Trim());
                    while (lector.Read())
                    {
                        if (codigoprod != (string)lector["idproducto"])
                        {
                            cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);            layout.SetText(subtota_por_prod.ToString());                    Pango.CairoHelper.ShowLayout(cr, layout);

                            comienzo_linea += separacion_linea;
                            salto_de_pagina(cr, layout);
                            codigoprod = (string)lector["idproducto"];
                            cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);            layout.SetText((string)lector["idproducto"]);                    Pango.CairoHelper.ShowLayout(cr, layout);
                            cr.MoveTo(75 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);            layout.SetText((string)lector["descripcion_producto"]);        Pango.CairoHelper.ShowLayout(cr, layout);
                            comienzo_linea += separacion_linea;
                            salto_de_pagina(cr, layout);
                            cr.MoveTo(15 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);            layout.SetText((string)lector["foliodeservicio"]);        Pango.CairoHelper.ShowLayout(cr, layout);
                            cr.MoveTo(55 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);            layout.SetText((string)lector["fechahoracreacion"]);        Pango.CairoHelper.ShowLayout(cr, layout);
                            cr.MoveTo(105 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);            layout.SetText(lector ["cantidadaplicada"].ToString());        Pango.CairoHelper.ShowLayout(cr, layout);
                            cr.MoveTo(135 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);            layout.SetText((string)lector["pidpaciente"]);        Pango.CairoHelper.ShowLayout(cr, layout);
                            cr.MoveTo(180 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);            layout.SetText((string)lector["nombre_paciente"]);        Pango.CairoHelper.ShowLayout(cr, layout);
                            busca_tipoadmisiones(lector["foliodeservicio"].ToString().Trim());
                            cr.MoveTo(350 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);            layout.SetText(tipo_paciente);        Pango.CairoHelper.ShowLayout(cr, layout);
                            cr.MoveTo(460 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);            layout.SetText((string)lector["descripcion_empresa"]);        Pango.CairoHelper.ShowLayout(cr, layout);
                            comienzo_linea += separacion_linea;
                            salto_de_pagina(cr, layout);
                            subtota_por_prod = float.Parse(lector ["cantidadaplicada"].ToString());
                        }
                        else
                        {
                            cr.MoveTo(15 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);            layout.SetText((string)lector["foliodeservicio"]);        Pango.CairoHelper.ShowLayout(cr, layout);
                            cr.MoveTo(55 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);            layout.SetText((string)lector["fechahoracreacion"]);        Pango.CairoHelper.ShowLayout(cr, layout);
                            cr.MoveTo(105 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);            layout.SetText(lector ["cantidadaplicada"].ToString());        Pango.CairoHelper.ShowLayout(cr, layout);
                            cr.MoveTo(135 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);            layout.SetText((string)lector["pidpaciente"]);        Pango.CairoHelper.ShowLayout(cr, layout);
                            cr.MoveTo(180 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);            layout.SetText((string)lector["nombre_paciente"]);        Pango.CairoHelper.ShowLayout(cr, layout);
                            busca_tipoadmisiones(lector["foliodeservicio"].ToString().Trim());
                            cr.MoveTo(350 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);            layout.SetText(tipo_paciente);        Pango.CairoHelper.ShowLayout(cr, layout);
                            cr.MoveTo(460 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);            layout.SetText((string)lector["descripcion_empresa"]);        Pango.CairoHelper.ShowLayout(cr, layout);
                            comienzo_linea += separacion_linea;
                            salto_de_pagina(cr, layout);
                            subtota_por_prod += float.Parse(lector ["cantidadaplicada"].ToString());
                        }
                    }
                }
                comienzo_linea += separacion_linea;
                salto_de_pagina(cr, layout);
                cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows);            layout.SetText(subtota_por_prod.ToString());                    Pango.CairoHelper.ShowLayout(cr, layout);
            }catch (NpgsqlException ex) {
                MessageDialog msgBoxError = new MessageDialog(MyWinError, DialogFlags.DestroyWithParent,
                                                              MessageType.Error,
                                                              ButtonsType.Close, "PostgresSQL error: {0}", ex.Message);
                msgBoxError.Run();        msgBoxError.Destroy();
            }
        }
Пример #39
0
        private void DrawStringHorizontal(PageText pt, Cairo.Context g, Cairo.Rectangle r)
        {
            StyleInfo si = pt.SI;
            string    s  = pt.Text;

            g.Save();

            layout = CairoHelper.CreateLayout(g);

            float fontsize = si.FontSize * 72f / 96f;
            var   font     = FontDescription.FromString(string.Format("{0} {1}", si.GetFontFamily().Name,
                                                                      fontsize * PixelsX(1)));

            if (si.FontStyle == FontStyleEnum.Italic)
            {
                font.Style = Style.Italic;
            }

            switch (si.FontWeight)
            {
            case FontWeightEnum.Bold:
            case FontWeightEnum.Bolder:
            case FontWeightEnum.W500:
            case FontWeightEnum.W600:
            case FontWeightEnum.W700:
            case FontWeightEnum.W800:
            case FontWeightEnum.W900:
                font.Weight = Weight.Bold;
                break;
            }

            FontDescription oldfont = layout.FontDescription;

            layout.FontDescription = font;

            switch (si.TextAlign)
            {
            case TextAlignEnum.Right:
                layout.Alignment = Alignment.Right;
                break;

            case TextAlignEnum.Center:
                layout.Alignment = Alignment.Center;
                break;

            case TextAlignEnum.Left:
            default:
                layout.Alignment = Alignment.Left;
                break;
            }

            layout.Width = Units.FromPixels((int)(r.Width - si.PaddingLeft - si.PaddingRight - 2));
            layout.Wrap  = WrapMode.WordChar;
            layout.SetText(s);

            Rectangle logical;
            Rectangle ink;

            layout.GetExtents(out ink, out logical);
            double height = logical.Height / Scale.PangoScale;
            double y      = 0;

            switch (si.VerticalAlign)
            {
            case VerticalAlignEnum.Top:
                y = r.Y + si.PaddingTop;
                break;

            case VerticalAlignEnum.Middle:
                y = r.Y + (r.Height - height) / 2;
                break;

            case VerticalAlignEnum.Bottom:
                y = r.Y + (r.Height - height) - si.PaddingBottom;
                break;
            }

            // draw the background
            DrawBackground(g, r, si);

            Cairo.Rectangle box = new Cairo.Rectangle(
                r.X + si.PaddingLeft + 1,
                y,
                r.Width,
                r.Height);

            g.Color = si.Color.ToCairoColor();

            g.MoveTo(box.X, box.Y);

            CairoHelper.ShowLayout(g, layout);

            layout.FontDescription = oldfont;
            g.Restore();
        }
Пример #40
0
    public static string Ellipsize(Pango.Layout layout, string newtext, int bound, int ellipsis_width, int en_width, int hAdjust)
    {
        int width, tmp;

        layout.SetText(newtext);
        layout.GetPixelSize(out width, out tmp);

        if (bound <= ellipsis_width)
        {
            return(ellipsis);
        }

        string ellipsized = "";
        int    i          = 0;


        if (hAdjust != 0)
        {
            i += hAdjust;
            while (i < newtext.Length)
            {
                ellipsized = ellipsized + newtext[i];
                layout.SetText(ellipsized);
                layout.GetPixelSize(out width, out tmp);
                if (width > bound - ellipsis_width)
                {
                    break;
                }
                i++;
            }
            return(ellipsized);
        }


        if (width < bound)
        {
            return(newtext);
        }
        //make a guess of where to start
        i = (bound - ellipsis_width) / (en_width);
        if (i >= newtext.Length)
        {
            i = 0;
        }
        ellipsized = newtext.Substring(hAdjust, i);

        //add chars one by one to determine how many are allowed
        while (true)
        {
            ellipsized = ellipsized + newtext[i];
            layout.SetText(ellipsized);
            layout.GetPixelSize(out width, out tmp);

            if (i == newtext.Length - 1)
            {
                //bad guess, start from the beginning
                ellipsized = "";
                i          = 0;
                continue;
            }

            if (width > bound - ellipsis_width)
            {
                break;
            }

            i++;
        }

        ellipsized  = ellipsized.Remove(ellipsized.Length - 1, 1);
        ellipsized += ellipsis;

        return(ellipsized);
    }
Пример #41
0
    protected override void Render(Gdk.Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
    {
        // Don't call base Render method of CellRendererProgress (it's looking badly on Windows)

            Gdk.GC gc = new Gdk.GC (window);

            gc.RgbFgColor = new Gdk.Color (0, 0, 0);
            window.DrawRectangle (gc, true, cell_area.X, cell_area.Y, cell_area.Width, cell_area.Height);

            gc.RgbFgColor = new Gdk.Color (255, 255, 255);
            window.DrawRectangle (gc, true, cell_area.X + 1, cell_area.Y + 1, cell_area.Width - 2, cell_area.Height - 2);

            gc.RgbFgColor = new Gdk.Color (130, 0, 200);
            window.DrawRectangle (gc, true, cell_area.X + 2, cell_area.Y + 2, (cell_area.Width - 4) * Value / 100, cell_area.Height - 4);

            Pango.Layout layout = new Pango.Layout (widget.PangoContext);
            gc.RgbFgColor = new Gdk.Color (0, 0, 0);
            layout.Wrap = Pango.WrapMode.Word;
            layout.FontDescription = FontDescription.FromString ("Arial 8");
            layout.SetText (Value.ToString () + "%");
            window.DrawLayout (gc, expose_area.X + expose_area.Width / 2 - (layout.Text.Length * 6 / 2), cell_area.Y + (int)((float)cell_area.Height / 2) - 6, layout);
    }