示例#1
0
 protected virtual void ArrangeLabels()
 {
     if (!this.AutoSizeLabels)
     {
         foreach (KeyValuePair <int, List <RadLabel> > keyValuePair in this.controlsInEachColumn)
         {
             float num = 0.0f;
             MeasurementGraphics measurementGraphics = MeasurementGraphics.CreateMeasurementGraphics();
             foreach (RadLabel radLabel in keyValuePair.Value)
             {
                 SizeF sizeF = measurementGraphics.Graphics.MeasureString(radLabel.Text, radLabel.Font);
                 if ((double)sizeF.Width > (double)num)
                 {
                     num = (float)((double)sizeF.Width + (double)this.itemSpace + 2.0);
                 }
             }
             foreach (RadLabel radLabel in keyValuePair.Value)
             {
                 radLabel.Size = new Size((int)Math.Floor((double)num), radLabel.Size.Height);
             }
         }
     }
     else
     {
         foreach (KeyValuePair <int, List <RadLabel> > keyValuePair in this.controlsInEachColumn)
         {
             foreach (Control control in keyValuePair.Value)
             {
                 control.AutoSize = true;
             }
         }
     }
 }
        protected virtual void ArrangeLabels()
        {
            if (!this.AutoSizeLabels)
            {
                return;
            }
            Dictionary <int, List <DataLayoutControlItem> > dictionary = new Dictionary <int, List <DataLayoutControlItem> >();

            foreach (LayoutControlItemBase layoutControlItemBase in (RadItemCollection)this.DataLayoutControl.LayoutControl.Items)
            {
                DataLayoutControlItem layoutControlItem = layoutControlItemBase as DataLayoutControlItem;
                if (layoutControlItem != null)
                {
                    if (!dictionary.ContainsKey(layoutControlItem.Bounds.X))
                    {
                        dictionary.Add(layoutControlItem.Bounds.X, new List <DataLayoutControlItem>());
                    }
                    dictionary[layoutControlItem.Bounds.X].Add(layoutControlItem);
                }
            }
            foreach (KeyValuePair <int, List <DataLayoutControlItem> > keyValuePair in dictionary)
            {
                float num = 0.0f;
                MeasurementGraphics measurementGraphics = MeasurementGraphics.CreateMeasurementGraphics();
                foreach (DataLayoutControlItem layoutControlItem in keyValuePair.Value)
                {
                    SizeF sizeF = measurementGraphics.Graphics.MeasureString(layoutControlItem.Text, layoutControlItem.Font);
                    if ((double)sizeF.Width > (double)num)
                    {
                        num = (float)((double)sizeF.Width + (double)layoutControlItem.Padding.Horizontal + 2.0);
                    }
                }
                foreach (DataLayoutControlItem layoutControlItem in keyValuePair.Value)
                {
                    if (this.changeService != null)
                    {
                        this.changeService.OnComponentChanging((object)layoutControlItem, (MemberDescriptor)null);
                    }
                    layoutControlItem.TextSizeMode  = LayoutItemTextSizeMode.Fixed;
                    layoutControlItem.TextFixedSize = (int)num;
                    if (this.changeService != null)
                    {
                        this.changeService.OnComponentChanged((object)layoutControlItem, (MemberDescriptor)null, (object)null, (object)null);
                    }
                }
            }
        }