コード例 #1
0
 public virtual void Paint(Graphics gr, Rectangle bounds, TileList list)
 {
     // If only one item is provided it fills the tile; otherwise the image is on the left and the text on the right, unless the tile is
     // not very wide in which case both are superimposed
     if (Image != null)
     {
         Rectangle imageRect = bounds;
         if (!string.IsNullOrEmpty(Text) && bounds.Width > bounds.Height * 2)
         {
             imageRect.Width = imageRect.Height;                         // just uses the left-hand part
         }
         GUIUtilities.CalcDestRect(Image.Size, ref imageRect);
         gr.DrawImage(Image, imageRect);
     }
     if (!string.IsNullOrEmpty(Text))
     {
         Rectangle textRect = bounds;
         if (Image != null && bounds.Width > bounds.Height * 2)
         {
             textRect.X     += bounds.Height;
             textRect.Width -= bounds.Height;
         }
         var format = GUIUtilities.StringFormatCentreLeft;
         if (bounds.Width <= bounds.Height * 2)
         {
             format = GUIUtilities.StringFormatCentreCentre;
         }
         gr.DrawString(Text, list.Font, Brushes.Black, textRect.ToRectangleF(), format);
     }
 }
コード例 #2
0
        public void pnlPreview_Paint(object sender, PaintEventArgs e)
        {
            Rectangle rect = new Rectangle(0, 0, pnlPreview.Width, pnlPreview.Height);

            GUIUtilities.CalcDestRect(m_OriginalImage.Size, ref rect);
            m_OriginalImage.Draw(e.Graphics, rect);
        }
コード例 #3
0
ファイル: frmSAWItem.cs プロジェクト: stuart2w/SAW
        private void pnlGraphic_Paint(object sender, PaintEventArgs e)
        {
            if (m_Items.First().Image == null)
            {
                return;
            }
            Rectangle rct = new Rectangle(0, 0, pnlGraphic.Width, pnlGraphic.Height);

            GUIUtilities.CalcDestRect(m_Items.First().Image.Content.GetSize(), ref rct);
            m_Items.First().Image.Content.MemoryImage.Draw(e.Graphics, rct);
            //e.Graphics.DrawImage(m_Items.First().Image.Content.GetNetImage(), rct);
        }
コード例 #4
0
        public void pnlPreview_Paint(object sender, PaintEventArgs e)
        {
            Rectangle rct = new Rectangle(0, 0, pnlPreview.Width, pnlPreview.Height);

            if (m_Current != null)
            {
                GUIUtilities.CalcDestRect(m_Current.Size, ref rct);
                e.Graphics.DrawImage(m_Current, rct);
            }
            else
            {
                e.Graphics.DrawString(Strings.Item("ChoosePage_Failed"), Font, Brushes.Red, rct, GUIUtilities.StringFormatCentreCentre);
            }
        }
コード例 #5
0
ファイル: CustomOpenFile.cs プロジェクト: stuart2w/SAW
 private void FilePreviewPanel_Paint(object sender, PaintEventArgs e)
 {
     if (!string.IsNullOrEmpty(m_File))             // is no file has been selected yet, then we don't display anything
     {
         if (m_Preview == null)
         {
             e.Graphics.DrawString(Strings.Item("Preview_Unavailable"), Font, Brushes.LightGray, new RectangleF(0, 0, Width, Height), GUIUtilities.StringFormatCentreCentre);
         }
         else
         {
             Rectangle imageRect = new Rectangle(0, 0, Width, Height);
             GUIUtilities.CalcDestRect(m_Preview.Width, m_Preview.Height, ref imageRect);
             e.Graphics.DrawImage(m_Preview, imageRect);
         }
     }
 }
コード例 #6
0
        public void lstImages_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            if (m_Filling)
            {
                return;
            }
            Rectangle rct = e.Bounds;

            rct.Inflate(-1, -1);
            GUIUtilities.CalcDestRect(m_Images[e.ItemIndex].Size, ref rct);
            e.Graphics.DrawImage(m_Images[e.ItemIndex], rct);
            if (e.Item.Selected)
            {
                e.DrawFocusRectangle();
            }
        }
コード例 #7
0
        public void lstDocument_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            SharedImage texture = (SharedImage)e.Item.Tag;
            var         rct     = e.Bounds;

            rct.Inflate(-6, -6);             // area to draw image in
            GUIUtilities.CalcDestRect(texture.GetSize(rct.Width), ref rct);
            texture.MemoryImage.Draw(e.Graphics, rct);
            Debug.WriteLine(e.State.ToString());
            if ((e.State & ListViewItemStates.Focused) > 0)
            {
                rct = e.Bounds;
                rct.Inflate(-3, -3);
                using (Pen pn = new Pen(Color.Orange, 3))
                {
                    e.Graphics.DrawRectangle(pn, rct);
                }
            }
        }
コード例 #8
0
        private void pnlPreview_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
        {
            Rectangle rctPreview = new Rectangle(0, 0, Width, Height);

            if (this.DesignMode)
            {
                e.Graphics.DrawString("Preview goes here", Font, Brushes.DarkGray, rctPreview, GUIUtilities.StringFormatCentreCentre);
            }
            else
            {
                if (m_img == null)
                {
                    e.Graphics.DrawString(Strings.Translate(NoImageString), Font, Brushes.DarkGray, rctPreview, GUIUtilities.StringFormatCentreCentre);
                }
                else
                {
                    GUIUtilities.CalcDestRect(m_img.Width, m_img.Height, ref rctPreview);
                    e.Graphics.DrawImage(m_img, rctPreview);
                }
            }
        }
コード例 #9
0
ファイル: frmPaper.cs プロジェクト: stuart2w/SAW
        public void pnlSample_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.Clear(m_Page.Colour);
            using (var canvas = new NetCanvas(e.Graphics))
            {
                // if locking page to image AR, then show the page colour in the correct proportions, with a dead grey area outside
                if (m_Page.BackgroundImage != null && m_Page.BackgroundImageMode == Page.BackgroundImageModes.LockAR)
                {
                    e.Graphics.Clear(Color.Gray);
                    Size imageSize = m_Page.BackgroundImage.GetSize();
                    imageSize.Width *= 100; imageSize.Height *= 100;                      // ensures image is too large, and therefore ScaleDestRect will fill the rectangle in one direction
                    Rectangle bounds = new Rectangle(0, 0, pnlSample.Width, pnlSample.Height);
                    GUIUtilities.CalcDestRect(imageSize, ref bounds);
                    e.Graphics.FillRectangle(new SolidBrush(m_Page.Colour), bounds);
                }

                if (m_Page.BackgroundImage != null)
                {
                    Page.DrawBackgroundImage(canvas, m_Page.BackgroundImage, m_Page.BackgroundImageMode, new RectangleF(0, 0, pnlSample.Width, pnlSample.Height), 1);
                }
                e.Graphics.TranslateTransform(0, pnlSample.Height);
                //e.Graphics.PageUnit = GraphicsUnit.Millimeter
                e.Graphics.ScaleTransform(e.Graphics.DpiX / Geometry.INCH, e.Graphics.DpiY / Geometry.INCH);
                // if the grid is not drawn, just draw it very faintly
                Color colReal = m_Paper.GridColour;
                if (!m_Paper.GridVisible)
                {
                    m_Paper.GridColour = Color.FromArgb(50, m_Paper.GridColour);
                }
                m_Paper.GridVisible = true;
                m_Paper.Dotted      = chkDotted.Checked && chkDraw.Checked;            // dotted is not compatible with transparent
                m_Paper.Draw(canvas, m_Page, 1);

                m_Paper.GridVisible = chkDraw.Checked;
                m_Paper.Dotted      = chkDotted.Checked;
                m_Paper.GridColour  = colReal;
            }
        }
コード例 #10
0
        /// <summary>Creates a bitmap from the data (if it was WMF or SVG)</summary>
        private Bitmap GenerateBitmap(Size sz)
        {
            Debug.Assert(IsSVG || !(GetNetImage() is Bitmap));             // if it already is the code below will work, but there's something wrong (and it's inefficient!)
            if (IsSVG)
            {
                GUIUtilities.CalcDestSize(Size, ref sz);
                // we don't rely on Draw maintaining aspect:ratio, since we can only fix one coord.  if we fixed width and the image happened to be very tall it would result in a huge image
                var x = m_SVG.Draw(sz.Width, sz.Height);
                //#if DEBUG
                //				x.Save(@"d:\temp\svg draw.png");
                //#endif
                return(x);
            }
            Bitmap bmp = new Bitmap(sz.Width, sz.Height, PixelFormat.Format32bppArgb);

            using (Graphics gr = Graphics.FromImage(bmp))
            {
                gr.Clear(Color.Transparent);
                Rectangle rect = new Rectangle(Point.Empty, sz);
                GUIUtilities.CalcDestRect(sz, ref rect);
                gr.DrawImage(m_Image, rect);
            }
            return(bmp);
        }