public bool AddNewTab(string tabName, bool startup, MyCommon.TabUsageType tabType, ListElement listInfo = null) { //重複チェック foreach (TabPage tb in ListTab.TabPages) { if (tb.Text == tabName) return false; } //新規タブ名チェック if (tabName == Properties.Resources.AddNewTabText1) return false; //タブタイプ重複チェック if (!startup) { if (tabType == MyCommon.TabUsageType.DirectMessage || tabType == MyCommon.TabUsageType.Favorites || tabType == MyCommon.TabUsageType.Home || tabType == MyCommon.TabUsageType.Mentions || tabType == MyCommon.TabUsageType.Related) { if (_statuses.GetTabByType(tabType) != null) return false; } } TabPage _tabPage = new TabPage(); DetailsListView _listCustom = new DetailsListView(); 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(); //ソース int cnt = ListTab.TabPages.Count; ///ToDo:Create and set controls follow tabtypes this.SplitContainer1.Panel1.SuspendLayout(); this.SplitContainer1.Panel2.SuspendLayout(); this.SplitContainer1.SuspendLayout(); this.ListTab.SuspendLayout(); this.SuspendLayout(); _tabPage.SuspendLayout(); /// UserTimeline関連 Label label = null; if (tabType == MyCommon.TabUsageType.UserTimeline || tabType == MyCommon.TabUsageType.Lists) { label = new Label(); label.Dock = DockStyle.Top; label.Name = "labelUser"; if (tabType == MyCommon.TabUsageType.Lists) { label.Text = listInfo.ToString(); } else { label.Text = _statuses.Tabs[tabName].User + "'s Timeline"; } label.TextAlign = ContentAlignment.MiddleLeft; using (ComboBox tmpComboBox = new ComboBox()) { label.Height = tmpComboBox.Height; } _tabPage.Controls.Add(label); } /// 検索関連の準備 Panel pnl = null; if (tabType == MyCommon.TabUsageType.PublicSearch) { pnl = new Panel(); Label lbl = new Label(); ComboBox cmb = new ComboBox(); Button btn = new Button(); ComboBox cmbLang = new ComboBox(); pnl.SuspendLayout(); pnl.Controls.Add(cmb); pnl.Controls.Add(cmbLang); pnl.Controls.Add(btn); pnl.Controls.Add(lbl); pnl.Name = "panelSearch"; pnl.Dock = DockStyle.Top; pnl.Height = cmb.Height; pnl.Enter += SearchControls_Enter; pnl.Leave += SearchControls_Leave; cmb.Text = ""; cmb.Anchor = AnchorStyles.Left | AnchorStyles.Right; cmb.Dock = DockStyle.Fill; cmb.Name = "comboSearch"; cmb.DropDownStyle = ComboBoxStyle.DropDown; cmb.ImeMode = ImeMode.NoControl; cmb.TabStop = false; cmb.AutoCompleteMode = AutoCompleteMode.None; cmb.KeyDown += SearchComboBox_KeyDown; if (_statuses.ContainsTab(tabName)) { cmb.Items.Add(_statuses.Tabs[tabName].SearchWords); cmb.Text = _statuses.Tabs[tabName].SearchWords; } cmbLang.Text = ""; cmbLang.Anchor = AnchorStyles.Left | AnchorStyles.Right; cmbLang.Dock = DockStyle.Right; cmbLang.Width = 50; cmbLang.Name = "comboLang"; cmbLang.DropDownStyle = ComboBoxStyle.DropDownList; cmbLang.TabStop = false; cmbLang.Items.Add(""); cmbLang.Items.Add("ja"); cmbLang.Items.Add("en"); cmbLang.Items.Add("ar"); cmbLang.Items.Add("da"); cmbLang.Items.Add("nl"); cmbLang.Items.Add("fa"); cmbLang.Items.Add("fi"); cmbLang.Items.Add("fr"); cmbLang.Items.Add("de"); cmbLang.Items.Add("hu"); cmbLang.Items.Add("is"); cmbLang.Items.Add("it"); cmbLang.Items.Add("no"); cmbLang.Items.Add("pl"); cmbLang.Items.Add("pt"); cmbLang.Items.Add("ru"); cmbLang.Items.Add("es"); cmbLang.Items.Add("sv"); cmbLang.Items.Add("th"); if (_statuses.ContainsTab(tabName)) cmbLang.Text = _statuses.Tabs[tabName].SearchLang; lbl.Text = "Search(C-S-f)"; lbl.Name = "label1"; lbl.Dock = DockStyle.Left; lbl.Width = 90; lbl.Height = cmb.Height; lbl.TextAlign = ContentAlignment.MiddleLeft; btn.Text = "Search"; btn.Name = "buttonSearch"; btn.UseVisualStyleBackColor = true; btn.Dock = DockStyle.Right; btn.TabStop = false; btn.Click += SearchButton_Click; } this.ListTab.Controls.Add(_tabPage); _tabPage.Controls.Add(_listCustom); if (tabType == MyCommon.TabUsageType.PublicSearch) _tabPage.Controls.Add(pnl); if (tabType == MyCommon.TabUsageType.UserTimeline || tabType == MyCommon.TabUsageType.Lists) _tabPage.Controls.Add(label); _tabPage.Location = new Point(4, 4); _tabPage.Name = "CTab" + cnt.ToString(); _tabPage.Size = new Size(380, 260); _tabPage.TabIndex = 2 + cnt; _tabPage.Text = tabName; _tabPage.UseVisualStyleBackColor = true; _listCustom.AllowColumnReorder = true; if (!_iconCol) { _listCustom.Columns.AddRange(new ColumnHeader[] {_colHd1, _colHd2, _colHd3, _colHd4, _colHd5, _colHd6, _colHd7, _colHd8}); } else { _listCustom.Columns.AddRange(new ColumnHeader[] {_colHd1, _colHd3}); } _listCustom.ContextMenuStrip = this.ContextMenuOperate; _listCustom.Dock = DockStyle.Fill; _listCustom.FullRowSelect = true; _listCustom.HideSelection = false; _listCustom.Location = new Point(0, 0); _listCustom.Margin = new Padding(0); _listCustom.Name = "CList" + Environment.TickCount.ToString(); _listCustom.ShowItemToolTips = true; _listCustom.Size = new Size(380, 260); _listCustom.UseCompatibleStateImageBehavior = false; _listCustom.View = View.Details; _listCustom.OwnerDraw = true; _listCustom.VirtualMode = true; _listCustom.Font = _fntReaded; _listCustom.BackColor = _clListBackcolor; _listCustom.GridLines = SettingDialog.ShowGrid; _listCustom.AllowDrop = true; _listCustom.SelectedIndexChanged += MyList_SelectedIndexChanged; _listCustom.MouseDoubleClick += MyList_MouseDoubleClick; _listCustom.ColumnClick += MyList_ColumnClick; _listCustom.DrawColumnHeader += MyList_DrawColumnHeader; _listCustom.DragDrop += TweenMain_DragDrop; _listCustom.DragOver += TweenMain_DragOver; _listCustom.DrawItem += MyList_DrawItem; _listCustom.MouseClick += MyList_MouseClick; _listCustom.ColumnReordered += MyList_ColumnReordered; _listCustom.ColumnWidthChanged += MyList_ColumnWidthChanged; _listCustom.CacheVirtualItems += MyList_CacheVirtualItems; _listCustom.RetrieveVirtualItem += MyList_RetrieveVirtualItem; _listCustom.DrawSubItem += MyList_DrawSubItem; _listCustom.HScrolled += MyList_HScrolled; 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; if (_statuses.IsDistributableTab(tabName)) TabDialog.AddTab(tabName); _listCustom.SmallImageList = new ImageList(); if (_iconSz > 0) { _listCustom.SmallImageList.ImageSize = new Size(_iconSz, _iconSz); } else { _listCustom.SmallImageList.ImageSize = new Size(1, 1); } int[] dispOrder = new int[8]; if (!startup) { for (int i = 0; i < _curList.Columns.Count; i++) { for (int j = 0; j < _curList.Columns.Count; j++) { if (_curList.Columns[j].DisplayIndex == i) { dispOrder[i] = j; break; } } } for (int i = 0; i < _curList.Columns.Count; i++) { _listCustom.Columns[i].Width = _curList.Columns[i].Width; _listCustom.Columns[dispOrder[i]].DisplayIndex = i; } } else { if (_iconCol) { _listCustom.Columns[0].Width = _cfgLocal.Width1; _listCustom.Columns[1].Width = _cfgLocal.Width3; _listCustom.Columns[0].DisplayIndex = 0; _listCustom.Columns[1].DisplayIndex = 1; } 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; } _listCustom.Columns[0].Width = _cfgLocal.Width1; _listCustom.Columns[1].Width = _cfgLocal.Width2; _listCustom.Columns[2].Width = _cfgLocal.Width3; _listCustom.Columns[3].Width = _cfgLocal.Width4; _listCustom.Columns[4].Width = _cfgLocal.Width5; _listCustom.Columns[5].Width = _cfgLocal.Width6; _listCustom.Columns[6].Width = _cfgLocal.Width7; _listCustom.Columns[7].Width = _cfgLocal.Width8; for (int i = 0; i <= 7; i++) { _listCustom.Columns[dispOrder[i]].DisplayIndex = i; } } } if (tabType == MyCommon.TabUsageType.PublicSearch) pnl.ResumeLayout(false); _tabPage.ResumeLayout(false); this.SplitContainer1.Panel1.ResumeLayout(false); this.SplitContainer1.Panel2.ResumeLayout(false); this.SplitContainer1.ResumeLayout(false); this.ListTab.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); _tabPage.Tag = _listCustom; return true; }
public bool AddNewTab(string tabName, bool startup, MyCommon.TabUsageType tabType, ListElement listInfo = null) { //重複チェック foreach (TabPage tb in ListTab.TabPages) { if (tb.Text == tabName) return false; } //新規タブ名チェック if (tabName == Properties.Resources.AddNewTabText1) return false; //タブタイプ重複チェック if (!startup) { if (tabType == MyCommon.TabUsageType.DirectMessage || tabType == MyCommon.TabUsageType.Favorites || tabType == MyCommon.TabUsageType.Home || tabType == MyCommon.TabUsageType.Mentions || tabType == MyCommon.TabUsageType.Related) { if (_statuses.GetTabByType(tabType) != null) return false; } } TabPage _tabPage = new TabPage(); DetailsListView _listCustom = new DetailsListView(); int cnt = ListTab.TabPages.Count; ///ToDo:Create and set controls follow tabtypes using (ControlTransaction.Update(_listCustom)) using (ControlTransaction.Layout(this.SplitContainer1.Panel1, false)) using (ControlTransaction.Layout(this.SplitContainer1.Panel2, false)) using (ControlTransaction.Layout(this.SplitContainer1, false)) using (ControlTransaction.Layout(this.ListTab, false)) using (ControlTransaction.Layout(this)) using (ControlTransaction.Layout(_tabPage, false)) { /// UserTimeline関連 Label label = null; if (tabType == MyCommon.TabUsageType.UserTimeline || tabType == MyCommon.TabUsageType.Lists) { label = new Label(); label.Dock = DockStyle.Top; label.Name = "labelUser"; if (tabType == MyCommon.TabUsageType.Lists) { label.Text = listInfo.ToString(); } else { label.Text = _statuses.Tabs[tabName].User + "'s Timeline"; } label.TextAlign = ContentAlignment.MiddleLeft; using (ComboBox tmpComboBox = new ComboBox()) { label.Height = tmpComboBox.Height; } _tabPage.Controls.Add(label); } /// 検索関連の準備 Panel pnl = null; if (tabType == MyCommon.TabUsageType.PublicSearch) { pnl = new Panel(); Label lbl = new Label(); ComboBox cmb = new ComboBox(); Button btn = new Button(); ComboBox cmbLang = new ComboBox(); pnl.SuspendLayout(); pnl.Controls.Add(cmb); pnl.Controls.Add(cmbLang); pnl.Controls.Add(btn); pnl.Controls.Add(lbl); pnl.Name = "panelSearch"; pnl.Dock = DockStyle.Top; pnl.Height = cmb.Height; pnl.Enter += SearchControls_Enter; pnl.Leave += SearchControls_Leave; cmb.Text = ""; cmb.Anchor = AnchorStyles.Left | AnchorStyles.Right; cmb.Dock = DockStyle.Fill; cmb.Name = "comboSearch"; cmb.DropDownStyle = ComboBoxStyle.DropDown; cmb.ImeMode = ImeMode.NoControl; cmb.TabStop = false; cmb.AutoCompleteMode = AutoCompleteMode.None; cmb.KeyDown += SearchComboBox_KeyDown; if (_statuses.ContainsTab(tabName)) { cmb.Items.Add(_statuses.Tabs[tabName].SearchWords); cmb.Text = _statuses.Tabs[tabName].SearchWords; } cmbLang.Text = ""; cmbLang.Anchor = AnchorStyles.Left | AnchorStyles.Right; cmbLang.Dock = DockStyle.Right; cmbLang.Width = 50; cmbLang.Name = "comboLang"; cmbLang.DropDownStyle = ComboBoxStyle.DropDownList; cmbLang.TabStop = false; cmbLang.Items.Add(""); cmbLang.Items.Add("ja"); cmbLang.Items.Add("en"); cmbLang.Items.Add("ar"); cmbLang.Items.Add("da"); cmbLang.Items.Add("nl"); cmbLang.Items.Add("fa"); cmbLang.Items.Add("fi"); cmbLang.Items.Add("fr"); cmbLang.Items.Add("de"); cmbLang.Items.Add("hu"); cmbLang.Items.Add("is"); cmbLang.Items.Add("it"); cmbLang.Items.Add("no"); cmbLang.Items.Add("pl"); cmbLang.Items.Add("pt"); cmbLang.Items.Add("ru"); cmbLang.Items.Add("es"); cmbLang.Items.Add("sv"); cmbLang.Items.Add("th"); if (_statuses.ContainsTab(tabName)) cmbLang.Text = _statuses.Tabs[tabName].SearchLang; lbl.Text = "Search(C-S-f)"; lbl.Name = "label1"; lbl.Dock = DockStyle.Left; lbl.Width = 90; lbl.Height = cmb.Height; lbl.TextAlign = ContentAlignment.MiddleLeft; btn.Text = "Search"; btn.Name = "buttonSearch"; btn.UseVisualStyleBackColor = true; btn.Dock = DockStyle.Right; btn.TabStop = false; btn.Click += SearchButton_Click; } this.ListTab.Controls.Add(_tabPage); _tabPage.Controls.Add(_listCustom); if (tabType == MyCommon.TabUsageType.PublicSearch) _tabPage.Controls.Add(pnl); if (tabType == MyCommon.TabUsageType.UserTimeline || tabType == MyCommon.TabUsageType.Lists) _tabPage.Controls.Add(label); _tabPage.Location = new Point(4, 4); _tabPage.Name = "CTab" + cnt.ToString(); _tabPage.Size = new Size(380, 260); _tabPage.TabIndex = 2 + cnt; _tabPage.Text = tabName; _tabPage.UseVisualStyleBackColor = true; _listCustom.AllowColumnReorder = true; _listCustom.ContextMenuStrip = this.ContextMenuOperate; _listCustom.ColumnHeaderContextMenuStrip = this.ContextMenuColumnHeader; _listCustom.Dock = DockStyle.Fill; _listCustom.FullRowSelect = true; _listCustom.HideSelection = false; _listCustom.Location = new Point(0, 0); _listCustom.Margin = new Padding(0); _listCustom.Name = "CList" + Environment.TickCount.ToString(); _listCustom.ShowItemToolTips = true; _listCustom.Size = new Size(380, 260); _listCustom.UseCompatibleStateImageBehavior = false; _listCustom.View = View.Details; _listCustom.OwnerDraw = true; _listCustom.VirtualMode = true; _listCustom.Font = _fntReaded; _listCustom.BackColor = _clListBackcolor; _listCustom.GridLines = this._cfgCommon.ShowGrid; _listCustom.AllowDrop = true; _listCustom.SmallImageList = _listViewImageList; InitColumns(_listCustom, startup); _listCustom.SelectedIndexChanged += MyList_SelectedIndexChanged; _listCustom.MouseDoubleClick += MyList_MouseDoubleClick; _listCustom.ColumnClick += MyList_ColumnClick; _listCustom.DrawColumnHeader += MyList_DrawColumnHeader; _listCustom.DragDrop += TweenMain_DragDrop; _listCustom.DragEnter += TweenMain_DragEnter; _listCustom.DragOver += TweenMain_DragOver; _listCustom.DrawItem += MyList_DrawItem; _listCustom.MouseClick += MyList_MouseClick; _listCustom.ColumnReordered += MyList_ColumnReordered; _listCustom.ColumnWidthChanged += MyList_ColumnWidthChanged; _listCustom.CacheVirtualItems += MyList_CacheVirtualItems; _listCustom.RetrieveVirtualItem += MyList_RetrieveVirtualItem; _listCustom.DrawSubItem += MyList_DrawSubItem; _listCustom.HScrolled += MyList_HScrolled; if (tabType == MyCommon.TabUsageType.PublicSearch) pnl.ResumeLayout(false); } _tabPage.Tag = _listCustom; return true; }