Example #1
0
 protected override Size CalculateSize(Graphics g)
 {
     FImg = null;
     if (this.Node != null)
     {
         DataNodeImage data = this.Node.Data as DataNodeImage;
         if (data != null)
         {
             using (Bitmap bmp = new Bitmap(data.FileName))
             {
                 double ratio = 300.0f / bmp.Size.Height;
                 FImg = bmp.GetThumbnailImage((int)(bmp.Size.Width * ratio), 300,
                                              new System.Drawing.Image.GetThumbnailImageAbort(OnGetThumbnail), IntPtr.Zero);
                 return(FImg.Size);
             }
         }
         else
         {
             return(base.CalculateSize(g));
         }
     }
     else
     {
         return(base.CalculateSize(g));
     }
 }
Example #2
0
        protected override void DoPaint(Graphics g)
        {
            DataNodeImage data = this.Node.Data as DataNodeImage;

            if (FImg != null)
            {
                Rectangle destRect = this.ClientRectangle;
                g.DrawImage(FImg, destRect, 0, 0, FImg.Size.Width, FImg.Size.Height, GraphicsUnit.Pixel);
            }
        }
Example #3
0
 private void geniusTreeView1_OnGetNodeText(Genius.Controls.TreeView.GeniusTreeView Sender, Genius.Controls.TreeView.NodeTextEventArgs e)
 {
     if (geniusTreeView1.Header.DisplayIndexToIndex(e.DisplayColumn) == 2)
     {
         DataNodeImage data = e.Node.Data as DataNodeImage;
         if (data != null)
         {
             LoadBitmap(data);
             if (data.Bmp != null)
             {
                 e.Text = data.size.ToString();
             }
         }
     }
 }
Example #4
0
 private void LoadBitmap(DataNodeImage data)
 {
     if (data.Bmp == null && File.Exists(data.FileName))
     {
         Cursor = Cursors.WaitCursor;
         try
         {
             using (Bitmap bmp = new Bitmap(data.FileName))
             {
                 double ratio = 105.0f / bmp.Size.Height;
                 data.Bmp = bmp.GetThumbnailImage((int)(bmp.Size.Width * ratio), 105,
                                                  new System.Drawing.Image.GetThumbnailImageAbort(OnGetThumbnail), IntPtr.Zero);
                 data.size = bmp.Size;
             }
         }
         finally
         {
             Cursor = Cursors.Default;
         }
     }
 }
Example #5
0
        private void geniusTreeView1_OnDrawCellNode(Genius.Controls.TreeView.GeniusTreeView Sender, Genius.Controls.TreeView.PaintNodeEventArgs e)
        {
            int colindex;

            colindex = Sender.Header.DisplayIndexToIndex(e.Info.DisplayColumn);
            DataNodeImage data = e.Node.Data as DataNodeImage;

            if (data != null)
            {
                if (colindex == 1)
                {
                    e.Info.DefaultDrawing = false;
                    LoadBitmap(data);
                    //e.graphics.DrawImage(data.Bmp, e.CellRect);

                    Rectangle destRect = new Rectangle(e.Info.NodeRect.Location, data.Bmp.Size);
                    int       offsetx  = (e.Info.NodeRect.Width - data.Bmp.Size.Width) / 2;
                    destRect.Offset(offsetx, 0);
                    e.Info.graphics.DrawImage(data.Bmp, destRect, 0, 0, data.Bmp.Size.Width, data.Bmp.Size.Height, GraphicsUnit.Pixel);
                }
            }
            else if (colindex == 1)
            {
                bool selected = false;
                e.Info.DefaultDrawing = false;
                System.Random rnd = new Random();
                Rectangle     r   = e.Info.NodeRect;
                if ((e.Node.State & NodeState.Selected) == NodeState.Selected && geniusTreeView1.SelectedColumn == 1)
                {
                    selected = true;
                    geniusTreeView1.DrawSelectedRectangle(e.Info.graphics, e.Info.NodeRect, true, e.Info);
                }
                r.Y      += 1;
                r.Height -= 1;
                r.Inflate(-2, -5);
                r.Width = rnd.Next(r.Width) + 1;                 //car je ne veux pas de zéro
                int pourcent = (int)(((double)r.Width / (double)(e.Info.NodeRect.Width - 4)) * 100);
                using (GeniusLinearGradientBrush br = new GeniusLinearGradientBrush(Color.Blue, Color.LightBlue, 90))
                {
                    using (Brush b = br.GetBrush(r))
                    {
                        /*
                         * Pen p = new Pen(b, r.Height);
                         * p.DashCap = DashCap.Flat;
                         * p.DashStyle = DashStyle.Custom;
                         * p.DashPattern = new float[]{0,10,11,20};
                         * e.graphics.DrawLine(p, r.Left+1, r.Top + r.Height / 2, r.Right, r.Top + r.Height / 2);
                         */

                        e.Info.graphics.FillRectangle(b, r);
                        r.Width = e.Info.NodeRect.Width - 4;
                        if (r.Width == 0)
                        {
                            r.Width = 1;
                        }
                        e.Info.graphics.DrawRectangle(selected ? Pens.White : Pens.Black, r);
                        StringFormat sf = new StringFormat(StringFormatFlags.NoWrap);
                        sf.LineAlignment = StringAlignment.Center;
                        sf.Alignment     = StringAlignment.Center;
                        sf.Trimming      = StringTrimming.EllipsisCharacter;
                        e.Info.graphics.DrawString(String.Format("{0} %", pourcent), this.Font,
                                                   pourcent >= 55 || selected ? Brushes.White : Brushes.Black,
                                                   e.Info.NodeRect, sf);
                    }
                }
            }
        }