RelMoveTo() public method

public RelMoveTo ( Distance d ) : void
d Distance
return void
示例#1
0
        private void DrawOutputndicator(Cairo.Context context)
        {
            context.Save();
            RelativeLocator locator = new RelativeLocator(-0.04, 1.2);
            PointD          point   = locator.Locate(this);

            context.MoveTo(point);
            context.LineCap = LineCap.Round;
            context.Color   = s_ioIndicatorColor;

            double l = 4;   //arm lenght of indicator icon
            double s = 0.4; //spacing between arms in the indicator icon

            //draw <<
            //up
            context.RelLineTo(new Distance(-s, -l));
            context.RelMoveTo(new Distance(s, l));   //back

            //right
            context.RelLineTo(new Distance(l, s));
            context.RelMoveTo(new Distance(-l, -s));   //back

            context.RelMoveTo(new Distance(3, -3));

            //repeat above for second arrow
            context.RelLineTo(new Distance(-s, -l));
            context.RelMoveTo(new Distance(s, l));   //back
            context.RelLineTo(new Distance(l, s));
            context.RelMoveTo(new Distance(-l, -s)); //back

            context.Stroke();

            context.Restore();
        }
示例#2
0
        private void OnDrawPage(object obj, Gtk.DrawPageArgs args)
        {
            PrintContext context = args.Context;

            Cairo.Context cr    = context.CairoContext;
            double        width = context.Width;

            cr.Rectangle(0, 0, width, headerHeight);
            cr.SetSourceRGB(0.8, 0.8, 0.8);
            cr.FillPreserve();

            cr.SetSourceRGB(0, 0, 0);
            cr.LineWidth = 1;
            cr.Stroke();

            Pango.Layout layout = context.CreatePangoLayout();

            Pango.FontDescription desc = Pango.FontDescription.FromString("sans 14");
            layout.FontDescription = desc;

            layout.SetText(fileName);
            layout.Width     = (int)width;
            layout.Alignment = Pango.Alignment.Center;

            int layoutWidth, layoutHeight;

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

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

            string pageStr = String.Format("{0}/{1}", args.PageNr + 1, numPages);

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

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

            layout = null;
            layout = context.CreatePangoLayout();

            desc      = Pango.FontDescription.FromString("mono");
            desc.Size = (int)(fontSize * pangoScale);
            layout.FontDescription = desc;

            cr.MoveTo(0, headerHeight + headerGap);
            int line = args.PageNr * linesPerPage;

            for (int i = 0; i < linesPerPage && line < numLines; i++)
            {
                layout.SetText(lines[line]);
                Pango.CairoHelper.ShowLayout(cr, layout);
                cr.RelMoveTo(0, fontSize);
                line++;
            }
            (cr as IDisposable).Dispose();
            layout = null;
        }
示例#3
0
			void DrawTriangle (Context ctx)
			{
				var halfSide = arrowPadding;
				var verticalModifier = arrowPosition == Xwt.Popover.Position.Top ? -1 : 1;
				// Move to the left
				ctx.RelMoveTo (-halfSide, 0);
				ctx.RelLineTo (halfSide, verticalModifier * arrowPadding);
				ctx.RelLineTo (halfSide, verticalModifier * -arrowPadding);
			}
示例#4
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();
        }
示例#5
0
文件: helpers.cs 项目: kig/filezoo
 public static void DrawText(Context cr, string family, double fontSize, string text, Pango.Alignment alignment)
 {
     //   return;
       lock (FontCache) {
     //   LogError("DrawText {0}", text);
     Profiler p = new Profiler ("DrawText");
     double w,h;
     Pango.Layout layout = GetLayout (cr, family, QuantizeFontSize(fontSize));
     layout.SetText (text);
     layout.Alignment = alignment;
     layout.GetExtents(out pe, out le);
     p.Time ("GetExtents {0}", pe);
     w = (double)le.Width / (double)Pango.Scale.PangoScale;
     h = (double)le.Height / (double)Pango.Scale.PangoScale;
     if (alignment == Pango.Alignment.Right) {
       cr.RelMoveTo (-w, 0);
     } else if (alignment == Pango.Alignment.Center) {
       cr.RelMoveTo (-w/2, 0);
     }
     Pango.CairoHelper.ShowLayout (cr, layout);
     p.Time ("ShowLayout");
     if (ShowTextExtents) {
       cr.Save ();
     PointD pt = cr.CurrentPoint;
     cr.MoveTo (pt.X, pt.Y);
     cr.RelLineTo(w, 0);
     cr.RelLineTo(0, h);
     cr.Operator = Operator.Over;
     cr.Color = new Color (1,0.5,1,0.5);
     cr.LineWidth = 0.5;
     cr.Stroke ();
     cr.MoveTo (pt.X, pt.Y);
       cr.Restore ();
     }
     cr.RelMoveTo (w, 0);
       }
 }
 public void Text(Context context,  string txt, HorizontalTextAlignment horizontal = HorizontalTextAlignment.Center, VerticalTextAlignment vertical = VerticalTextAlignment.Middle)
 {
     context.SelectFontFace ("Sans", FontSlant.Normal, FontWeight.Normal);
     //context.SetFontSize (_surface.Height / 10);
     context.SetFontSize (14);
     var extends = context.TextExtents (txt);
     double x, y;
     x = -(((double)horizontal) / 2 * extends.Width + extends.XBearing);
     y = -(((double)vertical) / 2 * extends.Height + extends.YBearing);
     context.RelMoveTo (x, y);
     context.ShowText (txt);
 }
示例#7
0
文件: filezoo.cs 项目: kig/filezoo
 /** FAST */
 bool ClickSortBar(Context cr, double x, double y)
 {
     cr.NewPath ();
     cr.MoveTo (0.0, 0.0);
     TextExtents te;
     cr.Color = ActiveColor;
     cr.RelMoveTo ( 0.0, ToolbarLabelFontSize * 0.4 );
     Helpers.DrawText (cr, ToolbarTitleFontFamily, ToolbarTitleFontSize, SortLabel);
     cr.RelMoveTo ( 0.0, ToolbarLabelFontSize * -0.4 );
     foreach (SortHandler sf in SortFields) {
       cr.Color = (SortField == sf) ? ActiveColor : InActiveColor;
       te = Helpers.GetTextExtents (
     cr, ToolbarLabelFontFamily, ToolbarLabelFontSize, sf.Name);
       if (Helpers.CheckTextExtents(cr, te, x, y)) {
     SortField = sf;
     ResetZoom ();
     UpdateLayout ();
     return true;
       }
       Helpers.DrawText (cr, ToolbarLabelFontFamily, ToolbarLabelFontSize, sf.Name);
       Helpers.DrawText (cr, ToolbarLabelFontFamily, ToolbarLabelFontSize, " ");
     }
     return false;
 }
示例#8
0
文件: filezoo.cs 项目: kig/filezoo
 /** FAST */
 bool ClickBreadcrumb(Context cr, uint width, double x, double y)
 {
     if (CurrentDirPath == Helpers.RootDir) return false;
     TextExtents te1 = Helpers.GetTextExtents (cr, BreadcrumbFontFamily, BreadcrumbFontSize, String.Join(dirSep, CurrentDirPath.Split(Helpers.DirSepC)) + dirSep);
     cr.Save ();
       double areaWidth = width-BreadcrumbMarginLeft-BreadcrumbMarginRight;
       cr.Rectangle (0,0,areaWidth, te1.Height);
       cr.Clip ();
       cr.Translate (Math.Min(0,areaWidth-te1.Width), -BreadcrumbMarginTop);
       if (areaWidth - te1.Width >= 0)
     cr.Translate(-(BreadcrumbMarginLeft+1), 0);
       cr.MoveTo (0.0, 0.0);
       int hitIndex = 0;
       string[] segments = CurrentDirPath.Split(Helpers.DirSepC);
       foreach (string s in segments) {
     string name = (s == "") ? rootChar : s+dirSep;
     TextExtents te = Helpers.GetTextExtents (cr, BreadcrumbFontFamily, BreadcrumbFontSize, name);
     te.Height += BreadcrumbMarginTop;
     if (s == "" && (areaWidth - te1.Width >= 0))
       te.Width += BreadcrumbMarginLeft+1;
     if (Helpers.CheckTextExtents(cr, te, x, y)) {
       string newDir = String.Join(Helpers.DirSepS, segments, 0, hitIndex+1);
       if (newDir == "") newDir = Helpers.RootDir;
       if (newDir != CurrentDirPath) {
         SetCurrentDir (newDir);
       } else {
         ResetZoom ();
         UpdateLayout ();
       }
       cr.Restore ();
       return true;
     }
     cr.RelMoveTo( te.Width, 0 );
     hitIndex += 1;
       }
       cr.IdentityMatrix ();
       cr.Rectangle (0,-1,width,2);
       if (cr.InFill(x,y)) {
     ResetZoom ();
     UpdateLayout ();
       }
     cr.Restore ();
     return false;
 }
示例#9
0
文件: filezoo.cs 项目: kig/filezoo
 /** FAST */
 void DrawSortBar(Context cr)
 {
     cr.NewPath ();
     cr.MoveTo (0.0, 0.0);
     cr.Color = ActiveColor;
     cr.RelMoveTo ( 0.0, ToolbarLabelFontSize * 0.4 );
     Helpers.DrawText (cr, ToolbarTitleFontFamily, ToolbarTitleFontSize, SortLabel);
     cr.RelMoveTo ( 0.0, ToolbarLabelFontSize * -0.4 );
     foreach (SortHandler sf in SortFields) {
       cr.Color = (SortField == sf) ? ActiveColor : InActiveColor;
       Helpers.DrawText (cr, ToolbarLabelFontFamily, ToolbarLabelFontSize, sf.Name);
       Helpers.DrawText (cr, ToolbarLabelFontFamily, ToolbarLabelFontSize, " ");
     }
 }