Esempio n. 1
0
 private void geniusTreeView1_OnBeforeNodePainting(Genius.Controls.TreeView.GeniusTreeView Sender, Genius.Controls.TreeView.PaintNodeEventArgs e)
 {
     if (e.Node.Data is Group)
     {
         Graphics g = e.Info.graphics;
         using (Font f = new Font(this.Font.Name, this.Font.Size, FontStyle.Bold))
         {
             StringFormat sf = new StringFormat(StringFormatFlags.NoWrap);
             sf.LineAlignment = StringAlignment.Center;
             g.DrawString(e.Node.Text, f, Brushes.Black, e.Info.NodeRect, sf);
         }
         Rectangle r = e.Info.NodeRect;
         r.Width /= 2;
         GeniusLinearGradientBrush glb = new GeniusLinearGradientBrush(Color.LightBlue, Color.White);
         using (Brush br = glb.GetBrush(r))
         {
             using (Pen p = new Pen(br, 1))
             {
                 g.DrawLine(p, r.X, r.Bottom - 1, r.Right - 1, r.Bottom - 1);
             }
         }
         e.Info.Font           = null;
         e.Info.DefaultDrawing = false;
     }
     else
     {
         if (e.Node.Data is GroupTotal)
         {
             e.Info.DrawingOptions &= ~DrawingOption.ShowGridLines;
             e.Info.Font            = new Font(this.geniusTreeView1.Font.Name, this.geniusTreeView1.Font.Size, FontStyle.Bold);
         }
         e.Info.DefaultDrawing = true;
     }
 }
Esempio n. 2
0
 private void DrawRoundRect(GeniusLinearGradientBrush geniusBr, Pen pen, Rectangle r, Graphics g)
 {
     using (Brush br = geniusBr.GetBrush(r))
     {
         DrawingHelper.FillRoundRect(g, br, r, 5, 5);
     }
     DrawingHelper.DrawRoundRect(g, pen, r, 5, 5);
 }
Esempio n. 3
0
 /// <summary>
 /// constructeur par défaut
 /// </summary>
 public GenuisTreeViewColors()
 {
     LinesColor                       = new Pen(Color.Gray, 1);
     LinesColor.DashStyle             = DashStyle.Dot;
     GridLinesColor                   = new Pen(Color.Gray, 1);
     HeaderColor                      = new GeniusLinearGradientBrush(Color.White, Color.LightGray, 90);
     TextColor                        = Color.Black;
     SelectedTextColor                = ((SolidBrush)SystemBrushes.HighlightText).Color;
     SelectedColor                    = new GeniusLinearGradientBrush(((SolidBrush)SystemBrushes.Highlight).Color);
     SignaledColor                    = (Pen)Pens.Orange.Clone();
     SignaledColor.Width              = 2;
     SignaledColor.EndCap             = LineCap.Round;
     FSelectedUnfocusedColor          = new GeniusLinearGradientBrush((SystemBrushes.InactiveCaption as SolidBrush).Color);
     FFocusedRectangleColor           = new Pen(SelectedTextColor, 1);
     FFocusedRectangleColor.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
     FUnFocusedRectangleColor         = (Pen)(FFocusedRectangleColor).Clone();
 }
Esempio n. 4
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);
                    }
                }
            }
        }
        /// <summary>
        /// Convertit un <see cref="GeniusLinearGradientBrush"/> en string ou en <see cref="InstanceDescriptor"/>
        /// </summary>
        /// <param name="context"></param>
        /// <param name="culture"></param>
        /// <param name="value"></param>
        /// <param name="destinationType"></param>
        /// <returns></returns>
        public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType)
        {
            if (destinationType == null)
            {
                throw new ArgumentNullException("destinationType");
            }
            if (value == null)
            {
                return(string.Empty);
            }
            if ((destinationType == typeof(string)) && (value is GeniusLinearGradientBrush))
            {
                GeniusLinearGradientBrush br = (GeniusLinearGradientBrush)value;
                if (culture == null)
                {
                    culture = CultureInfo.CurrentCulture;
                }

                TypeConverter floatConverter = TypeDescriptor.GetConverter(typeof(float));
                TypeConverter colorConverter = TypeDescriptor.GetConverter(typeof(Color));
                string        text1          = culture.TextInfo.ListSeparator + " ";
                string[]      properties     = new string[4];
                int           index          = 0;
                properties[index++] = floatConverter.ConvertToString(context, culture, br.Angle);
                properties[index++] = colorConverter.ConvertToString(context, culture, br.BeginColor);
                properties[index++] = colorConverter.ConvertToString(context, culture, br.EndColor);
                return(string.Join(text1, properties));
            }
            if ((destinationType == typeof(Color)) && (value is GeniusLinearGradientBrush))
            {
                return(((GeniusLinearGradientBrush)value).Color);
            }

            if ((destinationType != typeof(InstanceDescriptor)) || !(value is GeniusLinearGradientBrush))
            {
                return(base.CanConvertTo(context, destinationType));
            }

            Type[]          array       = new Type[] { typeof(Color), typeof(Color), typeof(float) };
            ConstructorInfo constructor = typeof(GeniusLinearGradientBrush).GetConstructor(array);

            if (constructor != null)
            {
                GeniusLinearGradientBrush br = (GeniusLinearGradientBrush)value;
                object[] objArray            = new object[] { br.BeginColor, br.EndColor, br.Angle };
                return(new InstanceDescriptor(constructor, objArray));
            }

            /*
             * if ((destinationType == typeof(InstanceDescriptor)) && (value is Point))
             * {
             *      Point point2 = (Point) value;
             *      Type[] typeArray1 = new Type[2] { typeof(int), typeof(int) } ;
             *      ConstructorInfo info1 = typeof(Point).GetConstructor(typeArray1);
             *      if (info1 != null)
             *      {
             *              object[] objArray1 = new object[2] { point2.X, point2.Y } ;
             *              return new InstanceDescriptor(info1, objArray1);
             *      }
             * }
             */

            return(base.CanConvertTo(context, destinationType));
        }