コード例 #1
0
ファイル: ActionMargin.cs プロジェクト: radtek/datawf
 void DrawMarginBackground(Xwt.Drawing.Context cr, int line, double x, double y, double lineHeight)
 {
     if (editor.Caret.Line == line)
     {
         editor.TextViewMargin.DrawCaretLineMarker(cr, x, y, Width, lineHeight);
         return;
     }
     cr.Rectangle(x, y, Width, lineHeight);
     cr.SetSourceColor(editor.ColorStyle.LineNumbers.Background);
     cr.Fill();
 }
コード例 #2
0
        private void DrawImageSized(PageImage pi, Xwt.Drawing.Image im, Xwt.Drawing.Context g, Xwt.Rectangle r)
        {
            double    height, width;   // some work variables
            StyleInfo si = pi.SI;

            Xwt.Rectangle r2 = new Xwt.Rectangle(r.X + PixelsX(si.PaddingLeft),
                                                 r.Y + PixelsY(si.PaddingTop),
                                                 r.Width - PixelsX(si.PaddingLeft + si.PaddingRight),
                                                 r.Height - PixelsY(si.PaddingTop + si.PaddingBottom));

            Xwt.Rectangle ir;   // int work rectangle
            switch (pi.Sizing)
            {
            case ImageSizingEnum.AutoSize:

                float imwidth  = PixelsX((float)im.Size.Width);
                float imheight = PixelsX((float)im.Size.Height);
                ir = new Xwt.Rectangle(Convert.ToInt32(r2.X), Convert.ToInt32(r2.Y),
                                       imwidth, imheight);

                im.Scale((int)r2.Width, (int)r2.Height);
                g.DrawImage(im, ir);

                break;

            case ImageSizingEnum.Clip:
                g.Save();
                g.Rectangle(r2);
                g.Clip();


                ir = new Xwt.Rectangle(Convert.ToInt32(r2.X), Convert.ToInt32(r2.Y),
                                       im.Size.Width, im.Size.Height);

                g.DrawImage(im, ir);
                g.Restore();
                break;

            case ImageSizingEnum.FitProportional:
                double ratioIm = (float)im.Size.Height / (float)im.Size.Width;
                double ratioR  = r2.Height / r2.Width;
                height = r2.Height;
                width  = r2.Width;
                if (ratioIm > ratioR)
                {
                    // this means the rectangle width must be corrected
                    width = height * (1 / ratioIm);
                }
                else if (ratioIm < ratioR)
                {
                    // this means the ractangle height must be corrected
                    height = width * ratioIm;
                }
                r2 = new Xwt.Rectangle(r2.X, r2.Y, width, height);
                g.DrawImage(im, r2);
                break;

            case ImageSizingEnum.Fit:
            default:
                g.DrawImage(im, r2);
                break;
            }
        }