FastReport

Форк
0
/
BandColumns.cs 
145 строк · 4.2 Кб
1
using System;
2
using System.ComponentModel;
3
using FastReport.Utils;
4

5
namespace FastReport
6
{
7
    /// <summary>
8
    /// The layout of the data band columns.
9
    /// </summary>
10
    public enum ColumnLayout
11
    {
12
        /// <summary>
13
        /// Print columns across then down.
14
        /// </summary>
15
        AcrossThenDown,
16

17
        /// <summary>
18
        /// Print columns down then across.
19
        /// </summary>
20
        DownThenAcross
21
    }
22

23
    /// <summary>
24
    /// This class holds the band columns settings. It is used in the <see cref="DataBand.Columns"/> property.
25
    /// </summary>
26
    [TypeConverter(typeof(FastReport.TypeConverters.FRExpandableObjectConverter))]
27
    public class BandColumns
28
    {
29
        private int count;
30
        private float width;
31
        private ColumnLayout layout;
32
        private int minRowCount;
33
        private DataBand band;
34

35
        /// <summary>
36
        /// Gets or sets the number of columns.
37
        /// </summary>
38
        /// <remarks>
39
        /// Set this property to 0 or 1 if you don't want to use columns.
40
        /// </remarks>
41
        [DefaultValue(0)]
42
        public int Count
43
        {
44
            get { return count; }
45
            set
46
            {
47
                if (value < 0)
48
                    throw new ArgumentOutOfRangeException("Count", "Value must be >= 0");
49
                count = value;
50
            }
51
        }
52

53
        /// <summary>
54
        /// The column width, in pixels.
55
        /// </summary>
56
        [DefaultValue(0f)]
57
        [TypeConverter("FastReport.TypeConverters.UnitsConverter, FastReport")]
58
        public float Width
59
        {
60
            get { return width; }
61
            set { width = value; }
62
        }
63

64
        /// <summary>
65
        /// Gets or sets the layout of the columns.
66
        /// </summary>
67
        [DefaultValue(ColumnLayout.AcrossThenDown)]
68
        public ColumnLayout Layout
69
        {
70
            get { return layout; }
71
            set { layout = value; }
72
        }
73

74
        /// <summary>
75
        /// Gets or sets the minimum row count that must be printed.
76
        /// </summary>
77
        /// <remarks>
78
        /// This property is used if the <b>Layout</b> property is set to <b>DownThenAcross</b>. 0 means that
79
        /// FastReport should calculate the optimal number of rows.
80
        /// </remarks>
81
        [DefaultValue(0)]
82
        public int MinRowCount
83
        {
84
            get { return minRowCount; }
85
            set { minRowCount = value; }
86
        }
87

88
        internal float ActualWidth
89
        {
90
            get
91
            {
92
                ReportPage page = band.Page as ReportPage;
93
                if (Width == 0 && page != null)
94
                    return (page.PaperWidth - page.LeftMargin - page.RightMargin) * Units.Millimeters / (Count == 0 ? 1 : Count);
95
                return Width;
96
            }
97
        }
98

99
        internal FloatCollection Positions
100
        {
101
            get
102
            {
103
                FloatCollection positions = new FloatCollection();
104
                float columnWidth = ActualWidth;
105
                for (int i = 0; i < Count; i++)
106
                {
107
                    positions.Add(i * columnWidth);
108
                }
109
                return positions;
110
            }
111
        }
112

113
        /// <summary>
114
        /// Assigns values from another source.
115
        /// </summary>
116
        /// <param name="source">Source to assign from.</param>
117
        public void Assign(BandColumns source)
118
        {
119
            Count = source.Count;
120
            Width = source.Width;
121
            Layout = source.Layout;
122
            MinRowCount = source.MinRowCount;
123
        }
124

125
        internal void Serialize(FRWriter writer, BandColumns c)
126
        {
127
            if (Count != c.Count)
128
                writer.WriteInt("Columns.Count", Count);
129
            if (Width != c.Width)
130
                writer.WriteFloat("Columns.Width", Width);
131
            if (Layout != c.Layout)
132
                writer.WriteValue("Columns.Layout", Layout);
133
            if (MinRowCount != c.MinRowCount)
134
                writer.WriteInt("Columns.MinRowCount", MinRowCount);
135
        }
136

137
        /// <summary>
138
        /// Initializes a new instance of the <b>BandColumns</b> class with default settings. 
139
        /// </summary>
140
        public BandColumns(DataBand band)
141
        {
142
            this.band = band;
143
        }
144
    }
145
}
146

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.