private void InitColumns(ListView list, bool startup)
{
- ColumnHeader _colHd1 = new ColumnHeader(); //アイコン
- ColumnHeader _colHd2 = new ColumnHeader(); //ニックネーム
- ColumnHeader _colHd3 = new ColumnHeader(); //本文
- ColumnHeader _colHd4 = new ColumnHeader(); //日付
- ColumnHeader _colHd5 = new ColumnHeader(); //ユーザID
- ColumnHeader _colHd6 = new ColumnHeader(); //未読
- ColumnHeader _colHd7 = new ColumnHeader(); //マーク&プロテクト
- ColumnHeader _colHd8 = new ColumnHeader(); //ソース
+ this.InitColumnText();
- if (!_iconCol)
- {
- list.Columns.AddRange(new ColumnHeader[] { _colHd1, _colHd2, _colHd3, _colHd4, _colHd5, _colHd6, _colHd7, _colHd8 });
- }
- else
- {
- list.Columns.AddRange(new ColumnHeader[] { _colHd1, _colHd3 });
- }
-
- InitColumnText();
- _colHd1.Text = ColumnText[0];
- _colHd1.Width = 48;
- _colHd2.Text = ColumnText[1];
- _colHd2.Width = 80;
- _colHd3.Text = ColumnText[2];
- _colHd3.Width = 300;
- _colHd4.Text = ColumnText[3];
- _colHd4.Width = 50;
- _colHd5.Text = ColumnText[4];
- _colHd5.Width = 50;
- _colHd6.Text = ColumnText[5];
- _colHd6.Width = 16;
- _colHd7.Text = ColumnText[6];
- _colHd7.Width = 16;
- _colHd8.Text = ColumnText[7];
- _colHd8.Width = 50;
-
- int[] dispOrder = new int[8];
- if (!startup)
+ ColumnHeader[] columns;
+ if (this._iconCol)
{
- for (int i = 0; i < _curList.Columns.Count; i++)
+ columns = new[]
{
- for (int j = 0; j < _curList.Columns.Count; j++)
- {
- if (_curList.Columns[j].DisplayIndex == i)
- {
- dispOrder[i] = j;
- break;
- }
- }
+ new ColumnHeader { Text = this.ColumnText[0], Width = 48 }, // アイコン
+ new ColumnHeader { Text = this.ColumnText[2], Width = 300 }, // 本文
+ };
+
+ if (startup)
+ {
+ var widthScaleFactor = this.CurrentAutoScaleDimensions.Width / this._cfgLocal.ScaleDimension.Width;
+
+ columns[0].Width = ScaleBy(widthScaleFactor, _cfgLocal.Width1);
+ columns[1].Width = ScaleBy(widthScaleFactor, _cfgLocal.Width3);
+ columns[0].DisplayIndex = 0;
+ columns[1].DisplayIndex = 1;
}
- for (int i = 0; i < _curList.Columns.Count; i++)
+ else
{
- list.Columns[i].Width = _curList.Columns[i].Width;
- list.Columns[dispOrder[i]].DisplayIndex = i;
+ var idx = 0;
+ foreach (var curListColumn in this._curList.Columns.Cast<ColumnHeader>())
+ {
+ columns[idx].Width = curListColumn.Width;
+ columns[idx].DisplayIndex = curListColumn.DisplayIndex;
+ idx++;
+ }
}
}
else
{
- var widthScaleFactor = this.CurrentAutoScaleDimensions.Width / this._cfgLocal.ScaleDimension.Width;
+ columns = new[]
+ {
+ new ColumnHeader { Text = this.ColumnText[0], Width = 48 }, // アイコン
+ new ColumnHeader { Text = this.ColumnText[1], Width = 80 }, // ニックネーム
+ new ColumnHeader { Text = this.ColumnText[2], Width = 300 }, // 本文
+ new ColumnHeader { Text = this.ColumnText[3], Width = 50 }, // 日付
+ new ColumnHeader { Text = this.ColumnText[4], Width = 50 }, // ユーザID
+ new ColumnHeader { Text = this.ColumnText[5], Width = 16 }, // 未読
+ new ColumnHeader { Text = this.ColumnText[6], Width = 16 }, // マーク&プロテクト
+ new ColumnHeader { Text = this.ColumnText[7], Width = 50 }, // ソース
+ };
- if (_iconCol)
+ if (startup)
{
- list.Columns[0].Width = ScaleBy(widthScaleFactor, _cfgLocal.Width1);
- list.Columns[1].Width = ScaleBy(widthScaleFactor, _cfgLocal.Width3);
- list.Columns[0].DisplayIndex = 0;
- list.Columns[1].DisplayIndex = 1;
+ var widthScaleFactor = this.CurrentAutoScaleDimensions.Width / this._cfgLocal.ScaleDimension.Width;
+
+ columns[0].Width = ScaleBy(widthScaleFactor, _cfgLocal.Width1);
+ columns[1].Width = ScaleBy(widthScaleFactor, _cfgLocal.Width2);
+ columns[2].Width = ScaleBy(widthScaleFactor, _cfgLocal.Width3);
+ columns[3].Width = ScaleBy(widthScaleFactor, _cfgLocal.Width4);
+ columns[4].Width = ScaleBy(widthScaleFactor, _cfgLocal.Width5);
+ columns[5].Width = ScaleBy(widthScaleFactor, _cfgLocal.Width6);
+ columns[6].Width = ScaleBy(widthScaleFactor, _cfgLocal.Width7);
+ columns[7].Width = ScaleBy(widthScaleFactor, _cfgLocal.Width8);
+
+ var displayIndex = new[] {
+ this._cfgLocal.DisplayIndex1, this._cfgLocal.DisplayIndex2,
+ this._cfgLocal.DisplayIndex3, this._cfgLocal.DisplayIndex4,
+ this._cfgLocal.DisplayIndex5, this._cfgLocal.DisplayIndex6,
+ this._cfgLocal.DisplayIndex7
+ };
+
+ foreach (var i in Enumerable.Range(0, displayIndex.Length))
+ {
+ columns[i].DisplayIndex = displayIndex[i];
+ }
}
else
{
- for (int i = 0; i <= 7; i++)
- {
- if (_cfgLocal.DisplayIndex1 == i)
- dispOrder[i] = 0;
- else if (_cfgLocal.DisplayIndex2 == i)
- dispOrder[i] = 1;
- else if (_cfgLocal.DisplayIndex3 == i)
- dispOrder[i] = 2;
- else if (_cfgLocal.DisplayIndex4 == i)
- dispOrder[i] = 3;
- else if (_cfgLocal.DisplayIndex5 == i)
- dispOrder[i] = 4;
- else if (_cfgLocal.DisplayIndex6 == i)
- dispOrder[i] = 5;
- else if (_cfgLocal.DisplayIndex7 == i)
- dispOrder[i] = 6;
- else if (_cfgLocal.DisplayIndex8 == i)
- dispOrder[i] = 7;
- }
- list.Columns[0].Width = ScaleBy(widthScaleFactor, _cfgLocal.Width1);
- list.Columns[1].Width = ScaleBy(widthScaleFactor, _cfgLocal.Width2);
- list.Columns[2].Width = ScaleBy(widthScaleFactor, _cfgLocal.Width3);
- list.Columns[3].Width = ScaleBy(widthScaleFactor, _cfgLocal.Width4);
- list.Columns[4].Width = ScaleBy(widthScaleFactor, _cfgLocal.Width5);
- list.Columns[5].Width = ScaleBy(widthScaleFactor, _cfgLocal.Width6);
- list.Columns[6].Width = ScaleBy(widthScaleFactor, _cfgLocal.Width7);
- list.Columns[7].Width = ScaleBy(widthScaleFactor, _cfgLocal.Width8);
- for (int i = 0; i <= 7; i++)
- {
- list.Columns[dispOrder[i]].DisplayIndex = i;
+ var idx = 0;
+ foreach (var curListColumn in this._curList.Columns.Cast<ColumnHeader>())
+ {
+ columns[idx].Width = curListColumn.Width;
+ columns[idx].DisplayIndex = curListColumn.DisplayIndex;
+ idx++;
}
}
}
+
+ list.Columns.AddRange(columns);
}
private void InitColumnText()