Exemple #1
0
        //------------------------------------------------------
        public override void DrawInterieur(CContextDessinObjetGraphique ctx)
        {
            base.DrawInterieur(ctx);
            Image image = Resources.chartSample;
            Size  sz    = CUtilImage.GetSizeAvecRatio(image, this.Size);

            ctx.Graphic.DrawImage(image,
                                  new Rectangle(new Point(Size.Width / 2 - sz.Width / 2,
                                                          Size.Height / 2 - sz.Height / 2),
                                                sz));
        }
Exemple #2
0
        private void C2iSelectImage_Paint(object sender, PaintEventArgs e)
        {
            Rectangle rct = ClientRectangle;
            Brush     br  = new SolidBrush(BackColor);

            e.Graphics.FillRectangle(br, rct);
            br.Dispose();
            if (Image != null)
            {
                Size sz = CUtilImage.GetSizeAvecRatio(Image, rct.Size);
                e.Graphics.DrawImage(Image, (rct.Width - sz.Width) / 2, (rct.Height - sz.Height) / 2,
                                     sz.Width, sz.Height);
            }
        }
Exemple #3
0
        public byte[] GetImageBytesResized(int nMaxWidth, int nMaxHeight)
        {
            byte[] btResult = null;
            Image  img      = null;

            try
            {
                img = ImageCarte;
                if (img != null)
                {
                    if (nMaxWidth > 0 && nMaxHeight > 0 && (img.Width > nMaxWidth || img.Height > nMaxHeight))
                    {
                        Size  sz   = CUtilImage.GetSizeAvecRatio(img, new Size(nMaxWidth, nMaxHeight));
                        Image img2 = CUtilImage.CreateImageImageResizeAvecRatio(img, sz, Color.White);
                        img.Dispose();
                        img = img2;
                    }
                    MemoryStream stream = new MemoryStream();
                    img.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
                    btResult = stream.GetBuffer();
                    stream.Close();
                    stream.Dispose();
                    img.Dispose();
                }
            }
            catch
            {
            }
            finally
            {
                if (img != null)
                {
                    img.Dispose();
                }
            }

            return(btResult);
        }
Exemple #4
0
            //------------------------------------------------------
            public void Draw(
                CControleMapBesoinOld controleMap,
                Color couleurFond,
                bool bSelected,
                Graphics g)
            {
                Rectangle rct = Rectangle;
                Brush     br  = new SolidBrush(Color.FromArgb(64, 0, 0, 0));

                g.FillRectangle(br,
                                rct.Left + 4,
                                rct.Bottom,
                                rct.Width, 4);
                g.FillRectangle(br, rct.Right,
                                rct.Top + 4,
                                4,
                                rct.Height - 4);
                br.Dispose();
                Color c = couleurFond;

                br = new SolidBrush(c);
                g.FillRectangle(br, rct);
                br.Dispose();
                Pen pTour = new Pen(Color.Black, bSelected ? 4 : 1);

                g.DrawRectangle(pTour, rct);
                pTour.Dispose();
                rct.Offset(1, 1);
                rct.Height = controleMap.m_nHauteurSatisfactionDefaut;
                rct.Inflate(-2, -2);

                Image img = sc2i.common.DynamicClassAttribute.GetImage(m_satisfaction.GetType());

                if (img != null)
                {
                    Rectangle rctImage = new Rectangle(rct.Left, rct.Top, 16, 16);
                    g.DrawImage(img, rctImage);
                    rct.Offset(16, 0);
                    rct.Width -= 16;
                }
                if (HasChildren)
                {
                    img = m_bIsExpanded ? Resources.blueUp32 : Resources.blueDown32;
                    Size      sz       = CUtilImage.GetSizeAvecRatio(img, new Size(2000, 16));
                    Rectangle rctImage = new Rectangle(rct.Right - sz.Width,
                                                       rct.Bottom - sz.Height,
                                                       sz.Width,
                                                       sz.Height);
                    g.DrawImage(img, rctImage, new Rectangle(0, 0, img.Width, img.Height), GraphicsUnit.Pixel);
                    Point pt = new Point(rctImage.Left, rctImage.Top);
                    pt = PointToClient(pt);
                    m_rectangleZoneExpand = new Rectangle(pt, rctImage.Size);
                }


                string       str = m_satisfaction.LibelleSatisfactionComplet;
                StringFormat sf  = new StringFormat(StringFormatFlags.FitBlackBox);

                sf.Alignment     = StringAlignment.Center;
                sf.LineAlignment = StringAlignment.Center;
                g.DrawString(str, controleMap.Font, Brushes.Black, rct, sf);
                sf.Dispose();
            }