OpenTween.TweenMain.InitColumns C# (CSharp) Method

InitColumns() private method

private InitColumns ( ListView list, bool startup ) : void
list ListView
startup bool
return void
        private void InitColumns(ListView list, bool startup)
        {
            this.InitColumnText();

            ColumnHeader[] columns = null;
            try
            {
                if (this._iconCol)
                {
                    columns = new[]
                    {
                        new ColumnHeader(), // アイコン
                        new ColumnHeader(), // 本文
                    };

                    columns[0].Text = this.ColumnText[0];
                    columns[1].Text = this.ColumnText[2];

                    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;
                    }
                    else
                    {
                        var idx = 0;
                        foreach (var curListColumn in this._curList.Columns.Cast<ColumnHeader>())
                        {
                            columns[idx].Width = curListColumn.Width;
                            columns[idx].DisplayIndex = curListColumn.DisplayIndex;
                            idx++;
                        }
                    }
                }
                else
                {
                    columns = new[]
                    {
                        new ColumnHeader(), // アイコン
                        new ColumnHeader(), // ニックネーム
                        new ColumnHeader(), // 本文
                        new ColumnHeader(), // 日付
                        new ColumnHeader(), // ユーザID
                        new ColumnHeader(), // 未読
                        new ColumnHeader(), // マーク&プロテクト
                        new ColumnHeader(), // ソース
                    };

                    foreach (var i in Enumerable.Range(0, columns.Length))
                        columns[i].Text = this.ColumnText[i];

                    if (startup)
                    {
                        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, this._cfgLocal.DisplayIndex8
                        };

                        foreach (var i in Enumerable.Range(0, displayIndex.Length))
                        {
                            columns[i].DisplayIndex = displayIndex[i];
                        }
                    }
                    else
                    {
                        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);

                columns = null;
            }
            finally
            {
                if (columns != null)
                {
                    foreach (var column in columns)
                        column?.Dispose();
                }
            }
        }
TweenMain