private void ResetColumns(DetailsListView list) { using (ControlTransaction.Update(list)) using (ControlTransaction.Layout(list, false)) { // カラムヘッダの再設定 list.ColumnClick -= MyList_ColumnClick; list.DrawColumnHeader -= MyList_DrawColumnHeader; list.ColumnReordered -= MyList_ColumnReordered; list.ColumnWidthChanged -= MyList_ColumnWidthChanged; var cols = list.Columns.Cast<ColumnHeader>().ToList(); list.Columns.Clear(); cols.ForEach(col => col.Dispose()); cols.Clear(); InitColumns(list, true); list.ColumnClick += MyList_ColumnClick; list.DrawColumnHeader += MyList_DrawColumnHeader; list.ColumnReordered += MyList_ColumnReordered; list.ColumnWidthChanged += MyList_ColumnWidthChanged; } }
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; }
private void ListTabSelect(TabPage _tab) { SetListProperty(); _itemCache = null; _itemCacheIndex = -1; _postCache = null; _curTab = _tab; _curList = (DetailsListView)_tab.Tag; if (_curList.SelectedIndices.Count > 0) { _curItemIndex = _curList.SelectedIndices[0]; _curPost = GetCurTabPost(_curItemIndex); } else { _curItemIndex = -1; _curPost = null; } _anchorPost = null; _anchorFlag = false; if (_iconCol) { ((DetailsListView)_tab.Tag).Columns[1].Text = ColumnText[2]; } else { for (int i = 0; i < _curList.Columns.Count; i++) { ((DetailsListView)_tab.Tag).Columns[i].Text = ColumnText[i]; } } }
/// <summary> /// <see cref="SaveListViewStatus"/> によって保存された選択状態を復元します /// </summary> private void RestoreListViewSelection(DetailsListView listView, TabClass tab, ListViewSelection listSelection) { // status_id から ListView 上のインデックスに変換 int[] selectedIndices = null; if (listSelection.SelectedStatusIds != null) selectedIndices = tab.IndexOf(listSelection.SelectedStatusIds).Where(x => x != -1).ToArray(); var focusedIndex = -1; if (listSelection.FocusedStatusId != null) focusedIndex = tab.IndexOf(listSelection.FocusedStatusId.Value); var selectionMarkIndex = -1; if (listSelection.SelectionMarkStatusId != null) selectionMarkIndex = tab.IndexOf(listSelection.SelectionMarkStatusId.Value); listView.SelectedIndexChanged -= this.MyList_SelectedIndexChanged; try { this.SelectListItem(listView, selectedIndices, focusedIndex, selectionMarkIndex); } finally { listView.SelectedIndexChanged += this.MyList_SelectedIndexChanged; } }
private void SelectListItem(DetailsListView LView , int[] Index, int FocusedIndex) { //複数 Rectangle bnd = new Rectangle(); bool flg = false; if (LView.FocusedItem != null) { bnd = LView.FocusedItem.Bounds; flg = true; } int fIdx = -1; if (Index != null && !(Index.Length == 1 && Index[0] == -1)) { do { LView.SelectedIndices.Clear(); } while (LView.SelectedIndices.Count > 0); foreach (int idx in Index) { if (idx > -1 && LView.VirtualListSize > idx) { LView.SelectedIndices.Add(idx); if (fIdx == -1) fIdx = idx; } } } if (FocusedIndex > -1 && LView.VirtualListSize > FocusedIndex) { LView.Items[FocusedIndex].Focused = true; } else if (fIdx > -1) { LView.Items[fIdx].Focused = true; } if (flg) LView.Invalidate(bnd); }
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; }
private long? GetSelectionMarkStatusId(DetailsListView listView, TabModel tab) { var selectionMarkIndex = listView.SelectionMark; return selectionMarkIndex != -1 ? tab.GetStatusIdAt(selectionMarkIndex) : (long?)null; }
private void ChangeItemStyleRead(bool Read, ListViewItem Item, PostClass Post, DetailsListView DList) { Font fnt; //フォント if (Read) { fnt = _fntReaded; Item.SubItems[5].Text = ""; } else { fnt = _fntUnread; Item.SubItems[5].Text = "★"; } //文字色 Color cl; if (Post.IsFav) cl = _clFav; else if (Post.RetweetedId > 0) cl = _clRetweet; else if (Post.IsOwl && (Post.IsDm || SettingDialog.OneWayLove)) cl = _clOWL; else if (Read || !SettingDialog.UseUnreadStyle) cl = _clReaded; else cl = _clUnread; var conv = new Func<string, string>(str => Regex.Replace(str, @"[ \r\n\t]", "")); var newp = conv(Post.TextFromApi); if (_cfgCommon.ShowStolenTweetWithColor && !(Post.RetweetedId > 0) && _statuses._statuses.Any(_ => conv(_.Value.TextFromApi) == newp && _.Value.CreatedAt.CompareTo(Post.CreatedAt) < 0)) { cl = _clStolen; } if (DList == null || Item.Index == -1) { Item.ForeColor = cl; if (SettingDialog.UseUnreadStyle) Item.Font = fnt; } else { DList.Update(); if (SettingDialog.UseUnreadStyle) DList.ChangeItemFontAndColor(Item.Index, cl, fnt); else DList.ChangeItemForeColor(Item.Index, cl); //if (_itemCache != null) DList.RedrawItems(_itemCacheIndex, _itemCacheIndex + _itemCache.Length - 1, false); } }
private long[] GetSelectedStatusIds(DetailsListView listView, TabModel tab) { var selectedIndices = listView.SelectedIndices; if (selectedIndices.Count > 0 && selectedIndices.Count < 61) return tab.GetStatusIdAt(selectedIndices.Cast<int>()); else return null; }
private long? GetFocusedStatusId(DetailsListView listView, TabModel tab) { var focusedItem = listView.FocusedItem; return focusedItem != null ? tab.GetStatusIdAt(focusedItem.Index) : (long?)null; }
/// <summary> /// <see cref="ListView"/> の選択状態を <see cref="ListViewSelection"/> として返します /// </summary> private ListViewSelection SaveListViewSelection(DetailsListView listView, TabModel tab) { if (listView.VirtualListSize == 0) { return new ListViewSelection { SelectedStatusIds = new long[0], SelectionMarkStatusId = null, FocusedStatusId = null, }; } return new ListViewSelection { SelectedStatusIds = this.GetSelectedStatusIds(listView, tab), FocusedStatusId = this.GetFocusedStatusId(listView, tab), SelectionMarkStatusId = this.GetSelectionMarkStatusId(listView, tab), }; }
private ScrollLockMode GetScrollLockMode(DetailsListView listView) { if (this._statuses.SortMode == ComparerMode.Id) { if (this._statuses.SortOrder == SortOrder.Ascending) { // Id昇順 if (this.ListLockMenuItem.Checked) return ScrollLockMode.None; // 最下行が表示されていたら、最下行へ強制スクロール。最下行が表示されていなかったら制御しない // 一番下に表示されているアイテム var bottomItem = listView.GetItemAt(0, listView.ClientSize.Height - 1); if (bottomItem == null || bottomItem.Index == listView.VirtualListSize - 1) return ScrollLockMode.FixedToBottom; else return ScrollLockMode.None; } else { // Id降順 if (this.ListLockMenuItem.Checked) return ScrollLockMode.FixedToItem; // 最上行が表示されていたら、制御しない。最上行が表示されていなかったら、現在表示位置へ強制スクロール var topItem = listView.TopItem; if (topItem == null || topItem.Index == 0) return ScrollLockMode.FixedToTop; else return ScrollLockMode.FixedToItem; } } else { return ScrollLockMode.FixedToItem; } }
/// <summary> /// <see cref="ListView"/> のスクロール位置に関する情報を <see cref="ListViewScroll"/> として返します /// </summary> private ListViewScroll SaveListViewScroll(DetailsListView listView, TabModel tab) { var listScroll = new ListViewScroll { ScrollLockMode = this.GetScrollLockMode(listView), }; if (listScroll.ScrollLockMode == ScrollLockMode.FixedToItem) { var topItem = listView.TopItem; if (topItem != null) listScroll.TopItemStatusId = tab.GetStatusIdAt(topItem.Index); } return listScroll; }
public bool RemoveSpecifiedTab(string TabName, bool confirm) { if (_statuses.IsDefaultTab(TabName) || _statuses.Tabs[TabName].Protected) return false; if (confirm) { string tmp = string.Format(Properties.Resources.RemoveSpecifiedTabText1, Environment.NewLine); if (MessageBox.Show(tmp, TabName + " " + Properties.Resources.RemoveSpecifiedTabText2, MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Cancel) { return false; } } var _tabPage = ListTab.TabPages.Cast<TabPage>().FirstOrDefault<TabPage>(tp => tp.Text == TabName); if (_tabPage == null) return false; SetListProperty(); //他のタブに列幅等を反映 MyCommon.TabUsageType tabType = _statuses.Tabs[TabName].TabType; //オブジェクトインスタンスの削除 DetailsListView _listCustom = (DetailsListView)_tabPage.Tag; _tabPage.Tag = null; 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)) { if (this.ListTab.SelectedTab == _tabPage) { this.ListTab.SelectTab((this._beforeSelectedTab != null && this.ListTab.TabPages.Contains(this._beforeSelectedTab)) ? this._beforeSelectedTab : this.ListTab.TabPages[0]); this._beforeSelectedTab = null; } this.ListTab.Controls.Remove(_tabPage); // 後付けのコントロールを破棄 if (tabType == MyCommon.TabUsageType.UserTimeline || tabType == MyCommon.TabUsageType.Lists) { using (Control label = _tabPage.Controls["labelUser"]) { _tabPage.Controls.Remove(label); } } else if (tabType == MyCommon.TabUsageType.PublicSearch) { using (Control pnl = _tabPage.Controls["panelSearch"]) { pnl.Enter -= SearchControls_Enter; pnl.Leave -= SearchControls_Leave; _tabPage.Controls.Remove(pnl); foreach (Control ctrl in pnl.Controls) { if (ctrl.Name == "buttonSearch") { ctrl.Click -= SearchButton_Click; } else if (ctrl.Name == "comboSearch") { ctrl.KeyDown -= SearchComboBox_KeyDown; } pnl.Controls.Remove(ctrl); ctrl.Dispose(); } } } _tabPage.Controls.Remove(_listCustom); _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; var cols = _listCustom.Columns.Cast<ColumnHeader>().ToList<ColumnHeader>(); _listCustom.Columns.Clear(); cols.ForEach(col => col.Dispose()); cols.Clear(); _listCustom.ContextMenuStrip = null; _listCustom.ColumnHeaderContextMenuStrip = null; _listCustom.Font = null; _listCustom.SmallImageList = null; _listCustom.ListViewItemSorter = null; //キャッシュのクリア if (_curTab.Equals(_tabPage)) { _curTab = null; _curItemIndex = -1; _curList = null; _curPost = null; } this.PurgeListViewItemCache(); } _tabPage.Dispose(); _listCustom.Dispose(); _statuses.RemoveTab(TabName); foreach (TabPage tp in ListTab.TabPages) { DetailsListView lst = (DetailsListView)tp.Tag; var count = _statuses.Tabs[tp.Text].AllCount; if (lst.VirtualListSize != count) { lst.VirtualListSize = count; } } return true; }
/// <summary> /// <see cref="SaveListViewScroll"/> によって保存されたスクロール位置を復元します /// </summary> private void RestoreListViewScroll(DetailsListView listView, TabModel tab, ListViewScroll listScroll) { if (listView.VirtualListSize == 0) return; switch (listScroll.ScrollLockMode) { case ScrollLockMode.FixedToTop: listView.EnsureVisible(0); break; case ScrollLockMode.FixedToBottom: listView.EnsureVisible(listView.VirtualListSize - 1); break; case ScrollLockMode.FixedToItem: var topIndex = listScroll.TopItemStatusId != null ? tab.IndexOf(listScroll.TopItemStatusId.Value) : -1; if (topIndex != -1) listView.TopItem = listView.Items[topIndex]; break; case ScrollLockMode.None: default: break; } }
private void TweenMain_Load(object sender, EventArgs e) { _ignoreConfigSave = true; this.Visible = false; //Win32Api.SetProxy(HttpConnection.ProxyType.Specified, "127.0.0.1", 8080, "user", "pass") new InternetSecurityManager(PostBrowser); this.PostBrowser.AllowWebBrowserDrop = false; // COMException を回避するため、ActiveX の初期化が終わってから設定する MyCommon.TwitterApiInfo.AccessLimitUpdated += TwitterApiStatus_AccessLimitUpdated; Microsoft.Win32.SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged; if (MyApplication.StartupOptions.ContainsKey("d")) MyCommon.TraceFlag = true; Regex.CacheSize = 100; InitializeTraceFrag(); LoadIcons(); // アイコン読み込み //発言保持クラス _statuses = TabInformations.GetInstance(); //アイコン設定 this.Icon = MainIcon; //メインフォーム(TweenMain) NotifyIcon1.Icon = NIconAt; //タスクトレイ TabImage.Images.Add(TabIcon); //タブ見出し SettingDialog.Owner = this;; SearchDialog.Owner = this; fltDialog.Owner = this; UrlDialog.Owner = this; _history.Add(new PostingStatus()); _hisIdx = 0; _reply_to_id = null; _reply_to_name = null; //<<<<<<<<<設定関連>>>>>>>>> //設定コンバージョン //ConvertConfig(); ////設定読み出し LoadConfig(); ThumbnailGenerator.InitializeGenerator(); var imgazyobizinet = ThumbnailGenerator.ImgAzyobuziNetInstance; imgazyobizinet.Enabled = this._cfgCommon.EnableImgAzyobuziNet; imgazyobizinet.DisabledInDM = this._cfgCommon.ImgAzyobuziNetDisabledInDM; Thumbnail.Services.TonTwitterCom.InitializeOAuthToken = x => x.Initialize(ApplicationSettings.TwitterConsumerKey, ApplicationSettings.TwitterConsumerSecret, this.tw.AccessToken, this.tw.AccessTokenSecret, "", ""); //新着バルーン通知のチェック状態設定 NewPostPopMenuItem.Checked = _cfgCommon.NewAllPop; this.NotifyFileMenuItem.Checked = NewPostPopMenuItem.Checked; //フォント&文字色&背景色保持 _fntUnread = _cfgLocal.FontUnread; _clUnread = _cfgLocal.ColorUnread; _fntReaded = _cfgLocal.FontRead; _clReaded = _cfgLocal.ColorRead; _clFav = _cfgLocal.ColorFav; _clOWL = _cfgLocal.ColorOWL; _clRetweet = _cfgLocal.ColorRetweet; _fntDetail = _cfgLocal.FontDetail; _clDetail = _cfgLocal.ColorDetail; _clDetailLink = _cfgLocal.ColorDetailLink; _clDetailBackcolor = _cfgLocal.ColorDetailBackcolor; _clSelf = _cfgLocal.ColorSelf; _clAtSelf = _cfgLocal.ColorAtSelf; _clTarget = _cfgLocal.ColorTarget; _clAtTarget = _cfgLocal.ColorAtTarget; _clAtFromTarget = _cfgLocal.ColorAtFromTarget; _clAtTo = _cfgLocal.ColorAtTo; _clListBackcolor = _cfgLocal.ColorListBackcolor; _clInputBackcolor = _cfgLocal.ColorInputBackcolor; _clInputFont = _cfgLocal.ColorInputFont; _fntInputFont = _cfgLocal.FontInputFont; var fontUIGlobal = this._cfgLocal.FontUIGlobal; if (fontUIGlobal != null) { OTBaseForm.GlobalFont = fontUIGlobal; this.Font = fontUIGlobal; } // StringFormatオブジェクトへの事前設定 //sf.Alignment = StringAlignment.Near; // Textを近くへ配置(左から右の場合は左寄せ) //sf.LineAlignment = StringAlignment.Near; // Textを近くへ配置(上寄せ) //sf.FormatFlags = StringFormatFlags.LineLimit; // sfTab.Alignment = StringAlignment.Center; sfTab.LineAlignment = StringAlignment.Center; //不正値チェック if (!MyApplication.StartupOptions.ContainsKey("nolimit")) { if (this._cfgCommon.TimelinePeriod < 15 && this._cfgCommon.TimelinePeriod > 0) this._cfgCommon.TimelinePeriod = 15; if (this._cfgCommon.ReplyPeriod < 15 && this._cfgCommon.ReplyPeriod > 0) this._cfgCommon.ReplyPeriod = 15; if (this._cfgCommon.DMPeriod < 15 && this._cfgCommon.DMPeriod > 0) this._cfgCommon.DMPeriod = 15; if (this._cfgCommon.PubSearchPeriod < 30 && this._cfgCommon.PubSearchPeriod > 0) this._cfgCommon.PubSearchPeriod = 30; if (this._cfgCommon.UserTimelinePeriod < 15 && this._cfgCommon.UserTimelinePeriod > 0) this._cfgCommon.UserTimelinePeriod = 15; if (this._cfgCommon.ListsPeriod < 15 && this._cfgCommon.ListsPeriod > 0) this._cfgCommon.ListsPeriod = 15; } if (this._cfgCommon.CountApi < 20 || this._cfgCommon.CountApi > 200) this._cfgCommon.CountApi = 60; if (this._cfgCommon.CountApiReply < 20 || this._cfgCommon.CountApiReply > 200) this._cfgCommon.CountApiReply = 40; HttpTwitter.TwitterUrl = _cfgCommon.TwitterUrl; //認証関連 if (string.IsNullOrEmpty(_cfgCommon.Token)) _cfgCommon.UserName = ""; tw.Initialize(_cfgCommon.Token, _cfgCommon.TokenSecret, _cfgCommon.UserName, _cfgCommon.UserId); //新着取得時のリストスクロールをするか。trueならスクロールしない ListLockMenuItem.Checked = _cfgCommon.ListLock; this.LockListFileMenuItem.Checked = _cfgCommon.ListLock; //サウンド再生(タブ別設定より優先) this.PlaySoundMenuItem.Checked = this._cfgCommon.PlaySound; this.PlaySoundFileMenuItem.Checked = this._cfgCommon.PlaySound; //廃止サービスが選択されていた場合bit.lyへ読み替え if (_cfgCommon.AutoShortUrlFirst < 0) _cfgCommon.AutoShortUrlFirst = MyCommon.UrlConverter.Uxnu; AtIdSupl = new AtIdSupplement(SettingAtIdList.Load().AtIdList, "@"); this.IdeographicSpaceToSpaceToolStripMenuItem.Checked = _cfgCommon.WideSpaceConvert; this.ToolStripFocusLockMenuItem.Checked = _cfgCommon.FocusLockToStatusText; //Regex statregex = new Regex("^0*"); this.recommendedStatusFooter = " [TWNv" + Regex.Replace(MyCommon.FileVersion.Replace(".", ""), "^0*", "") + "]"; //ハッシュタグ関連 HashSupl = new AtIdSupplement(_cfgCommon.HashTags, "#"); HashMgr = new HashtagManage(HashSupl, _cfgCommon.HashTags.ToArray(), _cfgCommon.HashSelected, _cfgCommon.HashIsPermanent, _cfgCommon.HashIsHead, _cfgCommon.HashIsNotAddToAtReply); if (!string.IsNullOrEmpty(HashMgr.UseHash) && HashMgr.IsPermanent) HashStripSplitButton.Text = HashMgr.UseHash; _initial = true; Networking.Initialize(); //アイコンリスト作成 this.IconCache = new ImageCache(); bool saveRequired = false; bool firstRun = false; //ユーザー名、パスワードが未設定なら設定画面を表示(初回起動時など) if (string.IsNullOrEmpty(tw.Username)) { saveRequired = true; firstRun = true; SettingDialog.ShowInTaskbar = true; this.SettingDialog.tw = this.tw; this.SettingDialog.LoadConfig(this._cfgCommon, this._cfgLocal); //設定せずにキャンセルされた場合はプログラム終了 if (SettingDialog.ShowDialog(this) == DialogResult.Cancel) { Application.Exit(); //強制終了 return; } //設定されたが、依然ユーザー名とパスワードが未設定ならプログラム終了 if (string.IsNullOrEmpty(tw.Username)) { Application.Exit(); //強制終了 return; } SettingDialog.ShowInTaskbar = false; //新しい設定を反映 //フォント&文字色&背景色保持 _fntUnread = this._cfgLocal.FontUnread; _clUnread = this._cfgLocal.ColorUnread; _fntReaded = this._cfgLocal.FontRead; _clReaded = this._cfgLocal.ColorRead; _clFav = this._cfgLocal.ColorFav; _clOWL = this._cfgLocal.ColorOWL; _clRetweet = this._cfgLocal.ColorRetweet; _fntDetail = this._cfgLocal.FontDetail; _clDetail = this._cfgLocal.ColorDetail; _clDetailLink = this._cfgLocal.ColorDetailLink; _clDetailBackcolor = this._cfgLocal.ColorDetailBackcolor; _clSelf = this._cfgLocal.ColorSelf; _clAtSelf = this._cfgLocal.ColorAtSelf; _clTarget = this._cfgLocal.ColorTarget; _clAtTarget = this._cfgLocal.ColorAtTarget; _clAtFromTarget = this._cfgLocal.ColorAtFromTarget; _clAtTo = this._cfgLocal.ColorAtTo; _clListBackcolor = this._cfgLocal.ColorListBackcolor; _clInputBackcolor = this._cfgLocal.ColorInputBackcolor; _clInputFont = this._cfgLocal.ColorInputFont; _fntInputFont = this._cfgLocal.FontInputFont; } _brsBackColorMine = new SolidBrush(_clSelf); _brsBackColorAt = new SolidBrush(_clAtSelf); _brsBackColorYou = new SolidBrush(_clTarget); _brsBackColorAtYou = new SolidBrush(_clAtTarget); _brsBackColorAtFromTarget = new SolidBrush(_clAtFromTarget); _brsBackColorAtTo = new SolidBrush(_clAtTo); //_brsBackColorNone = new SolidBrush(Color.FromKnownColor(KnownColor.Window)); _brsBackColorNone = new SolidBrush(_clListBackcolor); InitDetailHtmlFormat(); if (this._cfgCommon.HotkeyEnabled) { //////グローバルホットキーの登録 HookGlobalHotkey.ModKeys modKey = HookGlobalHotkey.ModKeys.None; if ((this._cfgCommon.HotkeyModifier & Keys.Alt) == Keys.Alt) modKey |= HookGlobalHotkey.ModKeys.Alt; if ((this._cfgCommon.HotkeyModifier & Keys.Control) == Keys.Control) modKey |= HookGlobalHotkey.ModKeys.Ctrl; if ((this._cfgCommon.HotkeyModifier & Keys.Shift) == Keys.Shift) modKey |= HookGlobalHotkey.ModKeys.Shift; if ((this._cfgCommon.HotkeyModifier & Keys.LWin) == Keys.LWin) modKey |= HookGlobalHotkey.ModKeys.Win; _hookGlobalHotkey.RegisterOriginalHotkey(this._cfgCommon.HotkeyKey, this._cfgCommon.HotkeyValue, modKey); } //Twitter用通信クラス初期化 Networking.DefaultTimeout = TimeSpan.FromSeconds(this._cfgCommon.DefaultTimeOut); Networking.SetWebProxy(this._cfgLocal.ProxyType, this._cfgLocal.ProxyAddress, this._cfgLocal.ProxyPort, this._cfgLocal.ProxyUser, this._cfgLocal.ProxyPassword); tw.RestrictFavCheck = this._cfgCommon.RestrictFavCheck; tw.ReadOwnPost = this._cfgCommon.ReadOwnPost; ShortUrl.Instance.DisableExpanding = !this._cfgCommon.TinyUrlResolve; ShortUrl.Instance.BitlyId = this._cfgCommon.BilyUser; ShortUrl.Instance.BitlyKey = this._cfgCommon.BitlyPwd; HttpTwitter.TwitterUrl = _cfgCommon.TwitterUrl; tw.TrackWord = _cfgCommon.TrackWord; TrackToolStripMenuItem.Checked = !String.IsNullOrEmpty(tw.TrackWord); tw.AllAtReply = _cfgCommon.AllAtReply; AllrepliesToolStripMenuItem.Checked = tw.AllAtReply; //画像投稿サービス ImageSelector.Initialize(tw, this.tw.Configuration, _cfgCommon.UseImageServiceName, _cfgCommon.UseImageService); //ウィンドウ設定 this.ClientSize = _cfgLocal.FormSize; _mySize = _cfgLocal.FormSize; //サイズ保持(最小化・最大化されたまま終了した場合の対応用) _myLoc = _cfgLocal.FormLocation; //タイトルバー領域 if (this.WindowState != FormWindowState.Minimized) { this.DesktopLocation = _cfgLocal.FormLocation; Rectangle tbarRect = new Rectangle(this.Location, new Size(_mySize.Width, SystemInformation.CaptionHeight)); bool outOfScreen = true; if (Screen.AllScreens.Length == 1) //ハングするとの報告 { foreach (Screen scr in Screen.AllScreens) { if (!Rectangle.Intersect(tbarRect, scr.Bounds).IsEmpty) { outOfScreen = false; break; } } if (outOfScreen) { this.DesktopLocation = new Point(0, 0); _myLoc = this.DesktopLocation; } } } this.TopMost = this._cfgCommon.AlwaysTop; _mySpDis = _cfgLocal.SplitterDistance; _mySpDis2 = _cfgLocal.StatusTextHeight; _mySpDis3 = _cfgLocal.PreviewDistance; if (_mySpDis3 == -1) { _mySpDis3 = _mySize.Width - 150; if (_mySpDis3 < 1) _mySpDis3 = 50; _cfgLocal.PreviewDistance = _mySpDis3; } MultiLineMenuItem.Checked = _cfgLocal.StatusMultiline; //this.Tween_ClientSizeChanged(this, null); this.PlaySoundMenuItem.Checked = this._cfgCommon.PlaySound; this.PlaySoundFileMenuItem.Checked = this._cfgCommon.PlaySound; //入力欄 StatusText.Font = _fntInputFont; StatusText.ForeColor = _clInputFont; // NameLabel のフォントを OTBaseForm.GlobalFont に変更 this.NameLabel.Font = this.ReplaceToGlobalFont(this.NameLabel.Font); // 必要であれば、発言一覧と発言詳細部・入力欄の上下を入れ替える SplitContainer1.IsPanelInverted = !this._cfgCommon.StatusAreaAtBottom; //全新着通知のチェック状態により、Reply&DMの新着通知有効無効切り替え(タブ別設定にするため削除予定) if (this._cfgCommon.UnreadManage == false) { ReadedStripMenuItem.Enabled = false; UnreadStripMenuItem.Enabled = false; } if (this._cfgCommon.IsUseNotifyGrowl) gh.RegisterGrowl(); //タイマー設定 TimerTimeline.AutoReset = true; TimerTimeline.SynchronizingObject = this; //Recent取得間隔 TimerTimeline.Interval = 1000; TimerTimeline.Enabled = true; //更新中アイコンアニメーション間隔 TimerRefreshIcon.Interval = 200; TimerRefreshIcon.Enabled = true; //状態表示部の初期化(画面右下) StatusLabel.Text = ""; StatusLabel.AutoToolTip = false; StatusLabel.ToolTipText = ""; //文字カウンタ初期化 lblLen.Text = GetRestStatusCount(true, false).ToString(); //////////////////////////////////////////////////////////////////////////////// _statuses.SortOrder = (SortOrder)_cfgCommon.SortOrder; IdComparerClass.ComparerMode mode = IdComparerClass.ComparerMode.Id; switch (_cfgCommon.SortColumn) { case 0: //0:アイコン,5:未読マーク,6:プロテクト・フィルターマーク case 5: case 6: //ソートしない mode = IdComparerClass.ComparerMode.Id; //Idソートに読み替え break; case 1: //ニックネーム mode = IdComparerClass.ComparerMode.Nickname; break; case 2: //本文 mode = IdComparerClass.ComparerMode.Data; break; case 3: //時刻=発言Id mode = IdComparerClass.ComparerMode.Id; break; case 4: //名前 mode = IdComparerClass.ComparerMode.Name; break; case 7: //Source mode = IdComparerClass.ComparerMode.Source; break; } _statuses.SortMode = mode; //////////////////////////////////////////////////////////////////////////////// ApplyListViewIconSize(this._cfgCommon.IconSize); StatusLabel.Text = Properties.Resources.Form1_LoadText1; //画面右下の状態表示を変更 StatusLabelUrl.Text = ""; //画面左下のリンク先URL表示部を初期化 NameLabel.Text = ""; //発言詳細部名前ラベル初期化 DateTimeLabel.Text = ""; //発言詳細部日時ラベル初期化 SourceLinkLabel.Text = ""; //Source部分初期化 //<<<<<<<<タブ関連>>>>>>> //デフォルトタブの存在チェック、ない場合には追加 if (_statuses.GetTabByType(MyCommon.TabUsageType.Home) == null) { TabClass tab; if (!_statuses.Tabs.TryGetValue(MyCommon.DEFAULTTAB.RECENT, out tab)) { _statuses.AddTab(MyCommon.DEFAULTTAB.RECENT, MyCommon.TabUsageType.Home, null); } else { tab.TabType = MyCommon.TabUsageType.Home; } } if (_statuses.GetTabByType(MyCommon.TabUsageType.Mentions) == null) { TabClass tab; if (!_statuses.Tabs.TryGetValue(MyCommon.DEFAULTTAB.REPLY, out tab)) { _statuses.AddTab(MyCommon.DEFAULTTAB.REPLY, MyCommon.TabUsageType.Mentions, null); } else { tab.TabType = MyCommon.TabUsageType.Mentions; } } if (_statuses.GetTabByType(MyCommon.TabUsageType.DirectMessage) == null) { TabClass tab; if (!_statuses.Tabs.TryGetValue(MyCommon.DEFAULTTAB.DM, out tab)) { _statuses.AddTab(MyCommon.DEFAULTTAB.DM, MyCommon.TabUsageType.DirectMessage, null); } else { tab.TabType = MyCommon.TabUsageType.DirectMessage; } } if (_statuses.GetTabByType(MyCommon.TabUsageType.Favorites) == null) { TabClass tab; if (!_statuses.Tabs.TryGetValue(MyCommon.DEFAULTTAB.FAV, out tab)) { _statuses.AddTab(MyCommon.DEFAULTTAB.FAV, MyCommon.TabUsageType.Favorites, null); } else { tab.TabType = MyCommon.TabUsageType.Favorites; } } foreach (var tab in _statuses.Tabs.Values) { if (tab.TabType == MyCommon.TabUsageType.Undefined) { tab.TabType = MyCommon.TabUsageType.UserDefined; } if (!AddNewTab(tab.TabName, true, tab.TabType, tab.ListInfo)) throw new TabException(Properties.Resources.TweenMain_LoadText1); } this.JumpReadOpMenuItem.ShortcutKeyDisplayString = "Space"; CopySTOTMenuItem.ShortcutKeyDisplayString = "Ctrl+C"; CopyURLMenuItem.ShortcutKeyDisplayString = "Ctrl+Shift+C"; CopyUserIdStripMenuItem.ShortcutKeyDisplayString = "Shift+Alt+C"; if (!this._cfgCommon.MinimizeToTray || this.WindowState != FormWindowState.Minimized) { this.Visible = true; } _curTab = ListTab.SelectedTab; _curItemIndex = -1; _curList = (DetailsListView)_curTab.Tag; SetMainWindowTitle(); SetNotifyIconText(); if (this._cfgCommon.TabIconDisp) { ListTab.DrawMode = TabDrawMode.Normal; } else { ListTab.DrawMode = TabDrawMode.OwnerDrawFixed; ListTab.DrawItem += ListTab_DrawItem; ListTab.ImageList = null; } _ignoreConfigSave = false; this.TweenMain_Resize(null, null); if (saveRequired) SaveConfigsAll(false); if (tw.UserId == 0) tw.VerifyCredentials(); foreach (var ua in this._cfgCommon.UserAccounts) { if (ua.UserId == 0 && ua.Username.ToLower() == tw.Username.ToLower()) { ua.UserId = tw.UserId; break; } } if (firstRun) { // 初回起動時だけ右下のメニューを目立たせる HashStripSplitButton.ShowDropDown(); } // タブの位置を調整する SetTabAlignment(); }
/// <summary> /// <see cref="SaveListViewSelection"/> によって保存された選択状態を復元します /// </summary> private void RestoreListViewSelection(DetailsListView listView, TabModel tab, ListViewSelection listSelection) { // status_id から ListView 上のインデックスに変換 int[] selectedIndices = null; if (listSelection.SelectedStatusIds != null) selectedIndices = tab.IndexOf(listSelection.SelectedStatusIds).Where(x => x != -1).ToArray(); var focusedIndex = -1; if (listSelection.FocusedStatusId != null) focusedIndex = tab.IndexOf(listSelection.FocusedStatusId.Value); var selectionMarkIndex = -1; if (listSelection.SelectionMarkStatusId != null) selectionMarkIndex = tab.IndexOf(listSelection.SelectionMarkStatusId.Value); this.SelectListItem(listView, selectedIndices, focusedIndex, selectionMarkIndex); }
private void SelectListItem(DetailsListView LView, int Index) { //単一 Rectangle bnd = new Rectangle(); bool flg = false; if (LView.FocusedItem != null) { bnd = LView.FocusedItem.Bounds; flg = true; } do { LView.SelectedIndices.Clear(); } while (LView.SelectedIndices.Count > 0); LView.Items[Index].Selected = true; //LView.SelectedIndices.Add(Index); LView.Items[Index].Focused = true; if (flg) LView.Invalidate(bnd); }
public bool AddNewTab(TabModel tab, bool startup) { //重複チェック foreach (TabPage tb in ListTab.TabPages) { if (tb.Text == tab.TabName) return false; } //新規タブ名チェック if (tab.TabName == Properties.Resources.AddNewTabText1) return false; var _tabPage = new TabPage(); var _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)) { _tabPage.Controls.Add(_listCustom); /// UserTimeline関連 var userTab = tab as UserTimelineTabModel; var listTab = tab as ListTimelineTabModel; var searchTab = tab as PublicSearchTabModel; if (userTab != null || listTab != null) { var label = new Label(); label.Dock = DockStyle.Top; label.Name = "labelUser"; label.TabIndex = 0; if (listTab != null) { label.Text = listTab.ListInfo.ToString(); } else if (userTab != null) { label.Text = userTab.ScreenName + "'s Timeline"; } label.TextAlign = ContentAlignment.MiddleLeft; using (ComboBox tmpComboBox = new ComboBox()) { label.Height = tmpComboBox.Height; } _tabPage.Controls.Add(label); } /// 検索関連の準備 else if (searchTab != null) { var pnl = new Panel(); var lbl = new Label(); var cmb = new ComboBox(); var btn = new Button(); var cmbLang = new ComboBox(); using (ControlTransaction.Layout(pnl, false)) { pnl.Controls.Add(cmb); pnl.Controls.Add(cmbLang); pnl.Controls.Add(btn); pnl.Controls.Add(lbl); pnl.Name = "panelSearch"; pnl.TabIndex = 0; 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.TabIndex = 1; cmb.AutoCompleteMode = AutoCompleteMode.None; cmb.KeyDown += SearchComboBox_KeyDown; 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.TabIndex = 2; 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"); lbl.Text = "Search(C-S-f)"; lbl.Name = "label1"; lbl.Dock = DockStyle.Left; lbl.Width = 90; lbl.Height = cmb.Height; lbl.TextAlign = ContentAlignment.MiddleLeft; lbl.TabIndex = 0; btn.Text = "Search"; btn.Name = "buttonSearch"; btn.UseVisualStyleBackColor = true; btn.Dock = DockStyle.Right; btn.TabStop = false; btn.TabIndex = 3; btn.Click += SearchButton_Click; if (!string.IsNullOrEmpty(searchTab.SearchWords)) { cmb.Items.Add(searchTab.SearchWords); cmb.Text = searchTab.SearchWords; } cmbLang.Text = searchTab.SearchLang; _tabPage.Controls.Add(pnl); } } _tabPage.Tag = _listCustom; this.ListTab.Controls.Add(_tabPage); _tabPage.Location = new Point(4, 4); _tabPage.Name = "CTab" + cnt; _tabPage.Size = new Size(380, 260); _tabPage.TabIndex = 2 + cnt; _tabPage.Text = tab.TabName; _tabPage.UseVisualStyleBackColor = true; _tabPage.AccessibleRole = AccessibleRole.PageTab; _listCustom.AccessibleName = Properties.Resources.AddNewTab_ListView_AccessibleName; _listCustom.TabIndex = 1; _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; _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; } return true; }
private void ChangeItemStyleRead(bool Read, ListViewItem Item, PostClass Post, DetailsListView DList) { Font fnt; //フォント if (Read) { fnt = _fntReaded; Item.SubItems[5].Text = ""; } else { fnt = _fntUnread; Item.SubItems[5].Text = "★"; } //文字色 Color cl; if (Post.IsFav) cl = _clFav; else if (Post.RetweetedId > 0) cl = _clRetweet; else if (Post.IsOwl && (Post.IsDm || SettingDialog.OneWayLove)) cl = _clOWL; else if (Read || !SettingDialog.UseUnreadStyle) cl = _clReaded; else cl = _clUnread; if (DList == null || Item.Index == -1) { Item.ForeColor = cl; if (SettingDialog.UseUnreadStyle) Item.Font = fnt; } else { DList.Update(); if (SettingDialog.UseUnreadStyle) DList.ChangeItemFontAndColor(Item.Index, cl, fnt); else DList.ChangeItemForeColor(Item.Index, cl); //if (_itemCache != null) DList.RedrawItems(_itemCacheIndex, _itemCacheIndex + _itemCache.Length - 1, false); } }
private void TweenMain_Load(object sender, EventArgs e) { _ignoreConfigSave = true; this.Visible = false; if (MyApplication.StartupOptions.ContainsKey("d")) MyCommon.TraceFlag = true; InitializeTraceFrag(); //Win32Api.SetProxy(HttpConnection.ProxyType.Specified, "127.0.0.1", 8080, "user", "pass") MyCommon.TwitterApiInfo.AccessLimitUpdated += TwitterApiStatus_AccessLimitUpdated; Microsoft.Win32.SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged; Regex.CacheSize = 100; //発言保持クラス _statuses = TabInformations.GetInstance(); //アイコン設定 LoadIcons(); this.Icon = MainIcon; //メインフォーム(TweenMain) NotifyIcon1.Icon = NIconAt; //タスクトレイ TabImage.Images.Add(TabIcon); //タブ見出し //<<<<<<<<<設定関連>>>>>>>>> ////設定読み出し LoadConfig(); // 現在の DPI と設定保存時の DPI との比を取得する var configScaleFactor = this._cfgLocal.GetConfigScaleFactor(this.CurrentAutoScaleDimensions); // UIフォント設定 var fontUIGlobal = this._cfgLocal.FontUIGlobal; if (fontUIGlobal != null) { OTBaseForm.GlobalFont = fontUIGlobal; this.Font = fontUIGlobal; } //不正値チェック if (!MyApplication.StartupOptions.ContainsKey("nolimit")) { if (this._cfgCommon.TimelinePeriod < 15 && this._cfgCommon.TimelinePeriod > 0) this._cfgCommon.TimelinePeriod = 15; if (this._cfgCommon.ReplyPeriod < 15 && this._cfgCommon.ReplyPeriod > 0) this._cfgCommon.ReplyPeriod = 15; if (this._cfgCommon.DMPeriod < 15 && this._cfgCommon.DMPeriod > 0) this._cfgCommon.DMPeriod = 15; if (this._cfgCommon.PubSearchPeriod < 30 && this._cfgCommon.PubSearchPeriod > 0) this._cfgCommon.PubSearchPeriod = 30; if (this._cfgCommon.UserTimelinePeriod < 15 && this._cfgCommon.UserTimelinePeriod > 0) this._cfgCommon.UserTimelinePeriod = 15; if (this._cfgCommon.ListsPeriod < 15 && this._cfgCommon.ListsPeriod > 0) this._cfgCommon.ListsPeriod = 15; } if (!Twitter.VerifyApiResultCount(MyCommon.WORKERTYPE.Timeline, this._cfgCommon.CountApi)) this._cfgCommon.CountApi = 60; if (!Twitter.VerifyApiResultCount(MyCommon.WORKERTYPE.Reply, this._cfgCommon.CountApiReply)) this._cfgCommon.CountApiReply = 40; if (this._cfgCommon.MoreCountApi != 0 && !Twitter.VerifyMoreApiResultCount(this._cfgCommon.MoreCountApi)) this._cfgCommon.MoreCountApi = 200; if (this._cfgCommon.FirstCountApi != 0 && !Twitter.VerifyFirstApiResultCount(this._cfgCommon.FirstCountApi)) this._cfgCommon.FirstCountApi = 100; if (this._cfgCommon.FavoritesCountApi != 0 && !Twitter.VerifyApiResultCount(MyCommon.WORKERTYPE.Favorites, this._cfgCommon.FavoritesCountApi)) this._cfgCommon.FavoritesCountApi = 40; if (this._cfgCommon.ListCountApi != 0 && !Twitter.VerifyApiResultCount(MyCommon.WORKERTYPE.List, this._cfgCommon.ListCountApi)) this._cfgCommon.ListCountApi = 100; if (this._cfgCommon.SearchCountApi != 0 && !Twitter.VerifyApiResultCount(MyCommon.WORKERTYPE.PublicSearch, this._cfgCommon.SearchCountApi)) this._cfgCommon.SearchCountApi = 100; if (this._cfgCommon.UserTimelineCountApi != 0 && !Twitter.VerifyApiResultCount(MyCommon.WORKERTYPE.UserTimeline, this._cfgCommon.UserTimelineCountApi)) this._cfgCommon.UserTimelineCountApi = 20; //廃止サービスが選択されていた場合ux.nuへ読み替え if (this._cfgCommon.AutoShortUrlFirst < 0) this._cfgCommon.AutoShortUrlFirst = MyCommon.UrlConverter.Uxnu; TwitterApiConnection.RestApiHost = this._cfgCommon.TwitterApiHost; this.tw = new Twitter(this.twitterApi); //認証関連 if (string.IsNullOrEmpty(this._cfgCommon.Token)) this._cfgCommon.UserName = ""; tw.Initialize(this._cfgCommon.Token, this._cfgCommon.TokenSecret, this._cfgCommon.UserName, this._cfgCommon.UserId); _initial = true; Networking.Initialize(); bool saveRequired = false; bool firstRun = false; //ユーザー名、パスワードが未設定なら設定画面を表示(初回起動時など) if (string.IsNullOrEmpty(tw.Username)) { saveRequired = true; firstRun = true; //設定せずにキャンセルされたか、設定されたが依然ユーザー名が未設定ならプログラム終了 if (ShowSettingDialog(showTaskbarIcon: true) != DialogResult.OK || string.IsNullOrEmpty(tw.Username)) { Application.Exit(); //強制終了 return; } } //Twitter用通信クラス初期化 Networking.DefaultTimeout = TimeSpan.FromSeconds(this._cfgCommon.DefaultTimeOut); Networking.UploadImageTimeout = TimeSpan.FromSeconds(this._cfgCommon.UploadImageTimeout); Networking.SetWebProxy(this._cfgLocal.ProxyType, this._cfgLocal.ProxyAddress, this._cfgLocal.ProxyPort, this._cfgLocal.ProxyUser, this._cfgLocal.ProxyPassword); Networking.ForceIPv4 = this._cfgCommon.ForceIPv4; TwitterApiConnection.RestApiHost = this._cfgCommon.TwitterApiHost; tw.RestrictFavCheck = this._cfgCommon.RestrictFavCheck; tw.ReadOwnPost = this._cfgCommon.ReadOwnPost; tw.TrackWord = this._cfgCommon.TrackWord; TrackToolStripMenuItem.Checked = !String.IsNullOrEmpty(tw.TrackWord); tw.AllAtReply = this._cfgCommon.AllAtReply; AllrepliesToolStripMenuItem.Checked = tw.AllAtReply; ShortUrl.Instance.DisableExpanding = !this._cfgCommon.TinyUrlResolve; ShortUrl.Instance.BitlyId = this._cfgCommon.BilyUser; ShortUrl.Instance.BitlyKey = this._cfgCommon.BitlyPwd; // アクセストークンが有効であるか確認する // ここが Twitter API への最初のアクセスになるようにすること try { this.tw.VerifyCredentials(); } catch (WebApiException ex) { MessageBox.Show(this, string.Format(Properties.Resources.StartupAuthError_Text, ex.Message), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); } //サムネイル関連の初期化 //プロキシ設定等の通信まわりの初期化が済んでから処理する ThumbnailGenerator.InitializeGenerator(); var imgazyobizinet = ThumbnailGenerator.ImgAzyobuziNetInstance; imgazyobizinet.Enabled = this._cfgCommon.EnableImgAzyobuziNet; imgazyobizinet.DisabledInDM = this._cfgCommon.ImgAzyobuziNetDisabledInDM; Thumbnail.Services.TonTwitterCom.GetApiConnection = () => this.twitterApi.Connection; //画像投稿サービス ImageSelector.Initialize(tw, this.tw.Configuration, _cfgCommon.UseImageServiceName, _cfgCommon.UseImageService); //ハッシュタグ/@id関連 AtIdSupl = new AtIdSupplement(SettingAtIdList.Load().AtIdList, "@"); HashSupl = new AtIdSupplement(_cfgCommon.HashTags, "#"); HashMgr = new HashtagManage(HashSupl, _cfgCommon.HashTags.ToArray(), _cfgCommon.HashSelected, _cfgCommon.HashIsPermanent, _cfgCommon.HashIsHead, _cfgCommon.HashIsNotAddToAtReply); if (!string.IsNullOrEmpty(HashMgr.UseHash) && HashMgr.IsPermanent) HashStripSplitButton.Text = HashMgr.UseHash; //アイコンリスト作成 this.IconCache = new ImageCache(); this.tweetDetailsView.IconCache = this.IconCache; //フォント&文字色&背景色保持 _fntUnread = this._cfgLocal.FontUnread; _clUnread = this._cfgLocal.ColorUnread; _fntReaded = this._cfgLocal.FontRead; _clReaded = this._cfgLocal.ColorRead; _clFav = this._cfgLocal.ColorFav; _clOWL = this._cfgLocal.ColorOWL; _clRetweet = this._cfgLocal.ColorRetweet; _fntDetail = this._cfgLocal.FontDetail; _clDetail = this._cfgLocal.ColorDetail; _clDetailLink = this._cfgLocal.ColorDetailLink; _clDetailBackcolor = this._cfgLocal.ColorDetailBackcolor; _clSelf = this._cfgLocal.ColorSelf; _clAtSelf = this._cfgLocal.ColorAtSelf; _clTarget = this._cfgLocal.ColorTarget; _clAtTarget = this._cfgLocal.ColorAtTarget; _clAtFromTarget = this._cfgLocal.ColorAtFromTarget; _clAtTo = this._cfgLocal.ColorAtTo; _clListBackcolor = this._cfgLocal.ColorListBackcolor; _clInputBackcolor = this._cfgLocal.ColorInputBackcolor; _clInputFont = this._cfgLocal.ColorInputFont; _fntInputFont = this._cfgLocal.FontInputFont; _brsBackColorMine = new SolidBrush(_clSelf); _brsBackColorAt = new SolidBrush(_clAtSelf); _brsBackColorYou = new SolidBrush(_clTarget); _brsBackColorAtYou = new SolidBrush(_clAtTarget); _brsBackColorAtFromTarget = new SolidBrush(_clAtFromTarget); _brsBackColorAtTo = new SolidBrush(_clAtTo); //_brsBackColorNone = new SolidBrush(Color.FromKnownColor(KnownColor.Window)); _brsBackColorNone = new SolidBrush(_clListBackcolor); // StringFormatオブジェクトへの事前設定 //sf.Alignment = StringAlignment.Near; // Textを近くへ配置(左から右の場合は左寄せ) //sf.LineAlignment = StringAlignment.Near; // Textを近くへ配置(上寄せ) //sf.FormatFlags = StringFormatFlags.LineLimit; // sfTab.Alignment = StringAlignment.Center; sfTab.LineAlignment = StringAlignment.Center; InitDetailHtmlFormat(); //Regex statregex = new Regex("^0*"); this.recommendedStatusFooter = " [TWNv" + Regex.Replace(MyCommon.FileVersion.Replace(".", ""), "^0*", "") + "]"; _history.Add(new PostingStatus()); _hisIdx = 0; this.inReplyTo = null; //各種ダイアログ設定 SearchDialog.Owner = this; UrlDialog.Owner = this; //新着バルーン通知のチェック状態設定 NewPostPopMenuItem.Checked = _cfgCommon.NewAllPop; this.NotifyFileMenuItem.Checked = NewPostPopMenuItem.Checked; //新着取得時のリストスクロールをするか。trueならスクロールしない ListLockMenuItem.Checked = _cfgCommon.ListLock; this.LockListFileMenuItem.Checked = _cfgCommon.ListLock; //サウンド再生(タブ別設定より優先) this.PlaySoundMenuItem.Checked = this._cfgCommon.PlaySound; this.PlaySoundFileMenuItem.Checked = this._cfgCommon.PlaySound; this.IdeographicSpaceToSpaceToolStripMenuItem.Checked = _cfgCommon.WideSpaceConvert; this.ToolStripFocusLockMenuItem.Checked = _cfgCommon.FocusLockToStatusText; //ウィンドウ設定 this.ClientSize = ScaleBy(configScaleFactor, _cfgLocal.FormSize); _mySize = this.ClientSize; // サイズ保持(最小化・最大化されたまま終了した場合の対応用) _myLoc = _cfgLocal.FormLocation; //タイトルバー領域 if (this.WindowState != FormWindowState.Minimized) { this.DesktopLocation = _cfgLocal.FormLocation; Rectangle tbarRect = new Rectangle(this.Location, new Size(_mySize.Width, SystemInformation.CaptionHeight)); bool outOfScreen = true; if (Screen.AllScreens.Length == 1) //ハングするとの報告 { foreach (Screen scr in Screen.AllScreens) { if (!Rectangle.Intersect(tbarRect, scr.Bounds).IsEmpty) { outOfScreen = false; break; } } if (outOfScreen) { this.DesktopLocation = new Point(0, 0); _myLoc = this.DesktopLocation; } } } this.TopMost = this._cfgCommon.AlwaysTop; _mySpDis = ScaleBy(configScaleFactor.Height, _cfgLocal.SplitterDistance); _mySpDis2 = ScaleBy(configScaleFactor.Height, _cfgLocal.StatusTextHeight); if (_cfgLocal.PreviewDistance == -1) { _mySpDis3 = _mySize.Width - ScaleBy(this.CurrentScaleFactor.Width, 150); if (_mySpDis3 < 1) _mySpDis3 = ScaleBy(this.CurrentScaleFactor.Width, 50); _cfgLocal.PreviewDistance = _mySpDis3; } else { _mySpDis3 = ScaleBy(configScaleFactor.Width, _cfgLocal.PreviewDistance); } MultiLineMenuItem.Checked = _cfgLocal.StatusMultiline; //this.Tween_ClientSizeChanged(this, null); this.PlaySoundMenuItem.Checked = this._cfgCommon.PlaySound; this.PlaySoundFileMenuItem.Checked = this._cfgCommon.PlaySound; //入力欄 StatusText.Font = _fntInputFont; StatusText.ForeColor = _clInputFont; // SplitContainer2.Panel2MinSize を一行表示の入力欄の高さに合わせる (MS UI Gothic 12pt (96dpi) の場合は 19px) this.StatusText.Multiline = false; // _cfgLocal.StatusMultiline の設定は後で反映される this.SplitContainer2.Panel2MinSize = this.StatusText.Height; // 必要であれば、発言一覧と発言詳細部・入力欄の上下を入れ替える SplitContainer1.IsPanelInverted = !this._cfgCommon.StatusAreaAtBottom; //全新着通知のチェック状態により、Reply&DMの新着通知有効無効切り替え(タブ別設定にするため削除予定) if (this._cfgCommon.UnreadManage == false) { ReadedStripMenuItem.Enabled = false; UnreadStripMenuItem.Enabled = false; } //リンク先URL表示部の初期化(画面左下) StatusLabelUrl.Text = ""; //状態表示部の初期化(画面右下) StatusLabel.Text = ""; StatusLabel.AutoToolTip = false; StatusLabel.ToolTipText = ""; //文字カウンタ初期化 lblLen.Text = this.GetRestStatusCount(this.FormatStatusText("")).ToString(); this.JumpReadOpMenuItem.ShortcutKeyDisplayString = "Space"; CopySTOTMenuItem.ShortcutKeyDisplayString = "Ctrl+C"; CopyURLMenuItem.ShortcutKeyDisplayString = "Ctrl+Shift+C"; CopyUserIdStripMenuItem.ShortcutKeyDisplayString = "Shift+Alt+C"; // SourceLinkLabel のテキストが SplitContainer2.Panel2.AccessibleName にセットされるのを防ぐ // (タブオーダー順で SourceLinkLabel の次にある PostBrowser が TabStop = false となっているため、 // さらに次のコントロールである SplitContainer2.Panel2 の AccessibleName がデフォルトで SourceLinkLabel のテキストになってしまう) this.SplitContainer2.Panel2.AccessibleName = ""; //////////////////////////////////////////////////////////////////////////////// var sortOrder = (SortOrder)_cfgCommon.SortOrder; var mode = ComparerMode.Id; switch (_cfgCommon.SortColumn) { case 0: //0:アイコン,5:未読マーク,6:プロテクト・フィルターマーク case 5: case 6: //ソートしない mode = ComparerMode.Id; //Idソートに読み替え break; case 1: //ニックネーム mode = ComparerMode.Nickname; break; case 2: //本文 mode = ComparerMode.Data; break; case 3: //時刻=発言Id mode = ComparerMode.Id; break; case 4: //名前 mode = ComparerMode.Name; break; case 7: //Source mode = ComparerMode.Source; break; } _statuses.SetSortMode(mode, sortOrder); //////////////////////////////////////////////////////////////////////////////// ApplyListViewIconSize(this._cfgCommon.IconSize); //<<<<<<<<タブ関連>>>>>>> // タブの位置を調整する SetTabAlignment(); //デフォルトタブの存在チェック、ない場合には追加 if (this._statuses.GetTabByType<HomeTabModel>() == null) this._statuses.AddTab(new HomeTabModel()); if (this._statuses.GetTabByType<MentionsTabModel>() == null) this._statuses.AddTab(new MentionsTabModel()); if (this._statuses.GetTabByType<DirectMessagesTabModel>() == null) this._statuses.AddTab(new DirectMessagesTabModel()); if (this._statuses.GetTabByType<FavoritesTabModel>() == null) this._statuses.AddTab(new FavoritesTabModel()); if (this._statuses.GetTabByType<MuteTabModel>() == null) this._statuses.AddTab(new MuteTabModel()); foreach (var tab in _statuses.Tabs.Values) { // ミュートタブは表示しない if (tab.TabType == MyCommon.TabUsageType.Mute) continue; if (!AddNewTab(tab, startup: true)) throw new TabException(Properties.Resources.TweenMain_LoadText1); } _curTab = ListTab.SelectedTab; _curItemIndex = -1; _curList = (DetailsListView)_curTab.Tag; if (this._cfgCommon.TabIconDisp) { ListTab.DrawMode = TabDrawMode.Normal; } else { ListTab.DrawMode = TabDrawMode.OwnerDrawFixed; ListTab.DrawItem += ListTab_DrawItem; ListTab.ImageList = null; } if (this._cfgCommon.HotkeyEnabled) { //////グローバルホットキーの登録 HookGlobalHotkey.ModKeys modKey = HookGlobalHotkey.ModKeys.None; if ((this._cfgCommon.HotkeyModifier & Keys.Alt) == Keys.Alt) modKey |= HookGlobalHotkey.ModKeys.Alt; if ((this._cfgCommon.HotkeyModifier & Keys.Control) == Keys.Control) modKey |= HookGlobalHotkey.ModKeys.Ctrl; if ((this._cfgCommon.HotkeyModifier & Keys.Shift) == Keys.Shift) modKey |= HookGlobalHotkey.ModKeys.Shift; if ((this._cfgCommon.HotkeyModifier & Keys.LWin) == Keys.LWin) modKey |= HookGlobalHotkey.ModKeys.Win; _hookGlobalHotkey.RegisterOriginalHotkey(this._cfgCommon.HotkeyKey, this._cfgCommon.HotkeyValue, modKey); } if (this._cfgCommon.IsUseNotifyGrowl) gh.RegisterGrowl(); StatusLabel.Text = Properties.Resources.Form1_LoadText1; //画面右下の状態表示を変更 SetMainWindowTitle(); SetNotifyIconText(); if (!this._cfgCommon.MinimizeToTray || this.WindowState != FormWindowState.Minimized) { this.Visible = true; } //タイマー設定 TimerTimeline.AutoReset = true; TimerTimeline.SynchronizingObject = this; //Recent取得間隔 TimerTimeline.Interval = 1000; TimerTimeline.Enabled = true; //更新中アイコンアニメーション間隔 TimerRefreshIcon.Interval = 200; TimerRefreshIcon.Enabled = true; _ignoreConfigSave = false; this.TweenMain_Resize(null, null); if (saveRequired) SaveConfigsAll(false); foreach (var ua in this._cfgCommon.UserAccounts) { if (ua.UserId == 0 && ua.Username.ToLowerInvariant() == tw.Username.ToLowerInvariant()) { ua.UserId = tw.UserId; break; } } if (firstRun) { // 初回起動時だけ右下のメニューを目立たせる HashStripSplitButton.ShowDropDown(); } }
private void Form1_Load(object sender, EventArgs e) { _ignoreConfigSave = true; this.Visible = false; //Win32Api.SetProxy(HttpConnection.ProxyType.Specified, "127.0.0.1", 8080, "user", "pass") SecurityManager = new InternetSecurityManager(PostBrowser); Thumbnail = new Thumbnail(this); MyCommon.TwitterApiInfo.Changed += SetStatusLabelApiHandler; Microsoft.Win32.SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged; VerUpMenuItem.Image = shield.Icon; string[] cmdArgs = Environment.GetCommandLineArgs(); if (cmdArgs.Length != 0 && cmdArgs.Contains("/d")) MyCommon.TraceFlag = true; this._spaceKeyCanceler = new SpaceKeyCanceler(this.PostButton); this._spaceKeyCanceler.SpaceCancel += spaceKeyCanceler_SpaceCancel; Regex.CacheSize = 100; MyCommon.fileVersion = ((AssemblyFileVersionAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false)[0]).Version; InitializeTraceFrag(); LoadIcons(); // アイコン読み込み //発言保持クラス _statuses = TabInformations.GetInstance(); //アイコン設定 this.Icon = MainIcon; //メインフォーム(TweenMain) NotifyIcon1.Icon = NIconAt; //タスクトレイ TabImage.Images.Add(TabIcon); //タブ見出し SettingDialog.Owner = this;; SearchDialog.Owner = this; fltDialog.Owner = this; TabDialog.Owner = this; UrlDialog.Owner = this; _history.Add(new PostingStatus()); _hisIdx = 0; _reply_to_id = 0; _reply_to_name = ""; //<<<<<<<<<設定関連>>>>>>>>> //設定コンバージョン //ConvertConfig(); ////設定読み出し LoadConfig(); //新着バルーン通知のチェック状態設定 NewPostPopMenuItem.Checked = _cfgCommon.NewAllPop; this.NotifyFileMenuItem.Checked = NewPostPopMenuItem.Checked; //フォント&文字色&背景色保持 _fntUnread = _cfgLocal.FontUnread; _clUnread = _cfgLocal.ColorUnread; _fntReaded = _cfgLocal.FontRead; _clReaded = _cfgLocal.ColorRead; _clFav = _cfgLocal.ColorFav; _clOWL = _cfgLocal.ColorOWL; _clRetweet = _cfgLocal.ColorRetweet; _fntDetail = _cfgLocal.FontDetail; _clDetail = _cfgLocal.ColorDetail; _clDetailLink = _cfgLocal.ColorDetailLink; _clDetailBackcolor = _cfgLocal.ColorDetailBackcolor; _clSelf = _cfgLocal.ColorSelf; _clAtSelf = _cfgLocal.ColorAtSelf; _clTarget = _cfgLocal.ColorTarget; _clAtTarget = _cfgLocal.ColorAtTarget; _clAtFromTarget = _cfgLocal.ColorAtFromTarget; _clAtTo = _cfgLocal.ColorAtTo; _clListBackcolor = _cfgLocal.ColorListBackcolor; _clInputBackcolor = _cfgLocal.ColorInputBackcolor; _clInputFont = _cfgLocal.ColorInputFont; _fntInputFont = _cfgLocal.FontInputFont; _brsForeColorUnread = new SolidBrush(_clUnread); _brsForeColorReaded = new SolidBrush(_clReaded); _brsForeColorFav = new SolidBrush(_clFav); _brsForeColorOWL = new SolidBrush(_clOWL); _brsForeColorRetweet = new SolidBrush(_clRetweet); _brsBackColorMine = new SolidBrush(_clSelf); _brsBackColorAt = new SolidBrush(_clAtSelf); _brsBackColorYou = new SolidBrush(_clTarget); _brsBackColorAtYou = new SolidBrush(_clAtTarget); _brsBackColorAtFromTarget = new SolidBrush(_clAtFromTarget); _brsBackColorAtTo = new SolidBrush(_clAtTo); //_brsBackColorNone = new SolidBrush(Color.FromKnownColor(KnownColor.Window)); _brsBackColorNone = new SolidBrush(_clListBackcolor); // StringFormatオブジェクトへの事前設定 //sf.Alignment = StringAlignment.Near; // Textを近くへ配置(左から右の場合は左寄せ) //sf.LineAlignment = StringAlignment.Near; // Textを近くへ配置(上寄せ) //sf.FormatFlags = StringFormatFlags.LineLimit; // sfTab.Alignment = StringAlignment.Center; sfTab.LineAlignment = StringAlignment.Center; //設定画面への反映 HttpTwitter.TwitterUrl = _cfgCommon.TwitterUrl; HttpTwitter.TwitterSearchUrl = _cfgCommon.TwitterSearchUrl; SettingDialog.TwitterApiUrl = _cfgCommon.TwitterUrl; SettingDialog.TwitterSearchApiUrl = _cfgCommon.TwitterSearchUrl; //認証関連 if (string.IsNullOrEmpty(_cfgCommon.Token)) _cfgCommon.UserName = ""; tw.Initialize(_cfgCommon.Token, _cfgCommon.TokenSecret, _cfgCommon.UserName, _cfgCommon.UserId); SettingDialog.UserAccounts = _cfgCommon.UserAccounts; SettingDialog.TimelinePeriodInt = _cfgCommon.TimelinePeriod; SettingDialog.ReplyPeriodInt = _cfgCommon.ReplyPeriod; SettingDialog.DMPeriodInt = _cfgCommon.DMPeriod; SettingDialog.PubSearchPeriodInt = _cfgCommon.PubSearchPeriod; SettingDialog.UserTimelinePeriodInt = _cfgCommon.UserTimelinePeriod; SettingDialog.ListsPeriodInt = _cfgCommon.ListsPeriod; //不正値チェック if (!cmdArgs.Contains("nolimit")) { if (SettingDialog.TimelinePeriodInt < 15 && SettingDialog.TimelinePeriodInt > 0) SettingDialog.TimelinePeriodInt = 15; if (SettingDialog.ReplyPeriodInt < 15 && SettingDialog.ReplyPeriodInt > 0) SettingDialog.ReplyPeriodInt = 15; if (SettingDialog.DMPeriodInt < 15 && SettingDialog.DMPeriodInt > 0) SettingDialog.DMPeriodInt = 15; if (SettingDialog.PubSearchPeriodInt < 30 && SettingDialog.PubSearchPeriodInt > 0) SettingDialog.PubSearchPeriodInt = 30; if (SettingDialog.UserTimelinePeriodInt < 15 && SettingDialog.UserTimelinePeriodInt > 0) SettingDialog.UserTimelinePeriodInt = 15; if (SettingDialog.ListsPeriodInt < 15 && SettingDialog.ListsPeriodInt > 0) SettingDialog.ListsPeriodInt = 15; } //起動時読み込み分を既読にするか。trueなら既読として処理 SettingDialog.Readed = _cfgCommon.Read; //新着取得時のリストスクロールをするか。trueならスクロールしない ListLockMenuItem.Checked = _cfgCommon.ListLock; this.LockListFileMenuItem.Checked = _cfgCommon.ListLock; SettingDialog.IconSz = _cfgCommon.IconSize; //文末ステータス SettingDialog.Status = _cfgLocal.StatusText; //未読管理。trueなら未読管理する SettingDialog.UnreadManage = _cfgCommon.UnreadManage; //サウンド再生(タブ別設定より優先) SettingDialog.PlaySound = _cfgCommon.PlaySound; PlaySoundMenuItem.Checked = SettingDialog.PlaySound; this.PlaySoundFileMenuItem.Checked = SettingDialog.PlaySound; //片思い表示。trueなら片思い表示する SettingDialog.OneWayLove = _cfgCommon.OneWayLove; //フォント&文字色&背景色 SettingDialog.FontUnread = _fntUnread; SettingDialog.ColorUnread = _clUnread; SettingDialog.FontReaded = _fntReaded; SettingDialog.ColorReaded = _clReaded; SettingDialog.ColorFav = _clFav; SettingDialog.ColorOWL = _clOWL; SettingDialog.ColorRetweet = _clRetweet; SettingDialog.FontDetail = _fntDetail; SettingDialog.ColorDetail = _clDetail; SettingDialog.ColorDetailLink = _clDetailLink; SettingDialog.ColorDetailBackcolor = _clDetailBackcolor; SettingDialog.ColorSelf = _clSelf; SettingDialog.ColorAtSelf = _clAtSelf; SettingDialog.ColorTarget = _clTarget; SettingDialog.ColorAtTarget = _clAtTarget; SettingDialog.ColorAtFromTarget = _clAtFromTarget; SettingDialog.ColorAtTo = _clAtTo; SettingDialog.ColorListBackcolor = _clListBackcolor; SettingDialog.ColorInputBackcolor = _clInputBackcolor; SettingDialog.ColorInputFont = _clInputFont; SettingDialog.FontInputFont = _fntInputFont; SettingDialog.NameBalloon = _cfgCommon.NameBalloon; SettingDialog.PostCtrlEnter = _cfgCommon.PostCtrlEnter; SettingDialog.PostShiftEnter = _cfgCommon.PostShiftEnter; SettingDialog.CountApi = _cfgCommon.CountApi; SettingDialog.CountApiReply = _cfgCommon.CountApiReply; if (SettingDialog.CountApi < 20 || SettingDialog.CountApi > 200) SettingDialog.CountApi = 60; if (SettingDialog.CountApiReply < 20 || SettingDialog.CountApiReply > 200) SettingDialog.CountApiReply = 40; SettingDialog.BrowserPath = _cfgLocal.BrowserPath; SettingDialog.PostAndGet = _cfgCommon.PostAndGet; SettingDialog.UseRecommendStatus = _cfgLocal.UseRecommendStatus; SettingDialog.DispUsername = _cfgCommon.DispUsername; SettingDialog.CloseToExit = _cfgCommon.CloseToExit; SettingDialog.MinimizeToTray = _cfgCommon.MinimizeToTray; SettingDialog.DispLatestPost = _cfgCommon.DispLatestPost; SettingDialog.SortOrderLock = _cfgCommon.SortOrderLock; SettingDialog.TinyUrlResolve = _cfgCommon.TinyUrlResolve; SettingDialog.ShortUrlForceResolve = _cfgCommon.ShortUrlForceResolve; SettingDialog.SelectedProxyType = _cfgLocal.ProxyType; SettingDialog.ProxyAddress = _cfgLocal.ProxyAddress; SettingDialog.ProxyPort = _cfgLocal.ProxyPort; SettingDialog.ProxyUser = _cfgLocal.ProxyUser; SettingDialog.ProxyPassword = _cfgLocal.ProxyPassword; SettingDialog.PeriodAdjust = _cfgCommon.PeriodAdjust; SettingDialog.StartupVersion = _cfgCommon.StartupVersion; SettingDialog.StartupFollowers = _cfgCommon.StartupFollowers; SettingDialog.RestrictFavCheck = _cfgCommon.RestrictFavCheck; SettingDialog.AlwaysTop = _cfgCommon.AlwaysTop; SettingDialog.UrlConvertAuto = false; //SettingDialog.UrlConvertAuto = _cfgCommon.UrlConvertAuto; SettingDialog.OutputzEnabled = _cfgCommon.Outputz; SettingDialog.OutputzKey = _cfgCommon.OutputzKey; SettingDialog.OutputzUrlmode = _cfgCommon.OutputzUrlMode; SettingDialog.UseUnreadStyle = _cfgCommon.UseUnreadStyle; SettingDialog.DefaultTimeOut = _cfgCommon.DefaultTimeOut; SettingDialog.RetweetNoConfirm = _cfgCommon.RetweetNoConfirm; SettingDialog.PlaySound = _cfgCommon.PlaySound; SettingDialog.DateTimeFormat = _cfgCommon.DateTimeFormat; SettingDialog.LimitBalloon = _cfgCommon.LimitBalloon; SettingDialog.EventNotifyEnabled = _cfgCommon.EventNotifyEnabled; SettingDialog.EventNotifyFlag = _cfgCommon.EventNotifyFlag; SettingDialog.IsMyEventNotifyFlag = _cfgCommon.IsMyEventNotifyFlag; SettingDialog.ForceEventNotify = _cfgCommon.ForceEventNotify; SettingDialog.FavEventUnread = _cfgCommon.FavEventUnread; SettingDialog.TranslateLanguage = _cfgCommon.TranslateLanguage; SettingDialog.EventSoundFile = _cfgCommon.EventSoundFile; //廃止サービスが選択されていた場合bit.lyへ読み替え if (_cfgCommon.AutoShortUrlFirst < 0) _cfgCommon.AutoShortUrlFirst = MyCommon.UrlConverter.Uxnu; SettingDialog.AutoShortUrlFirst = _cfgCommon.AutoShortUrlFirst; SettingDialog.TabIconDisp = _cfgCommon.TabIconDisp; SettingDialog.ReplyIconState = _cfgCommon.ReplyIconState; SettingDialog.ReadOwnPost = _cfgCommon.ReadOwnPost; SettingDialog.GetFav = _cfgCommon.GetFav; SettingDialog.ReadOldPosts = _cfgCommon.ReadOldPosts; SettingDialog.UseSsl = _cfgCommon.UseSsl; SettingDialog.BitlyUser = _cfgCommon.BilyUser; SettingDialog.BitlyPwd = _cfgCommon.BitlyPwd; SettingDialog.ShowGrid = _cfgCommon.ShowGrid; SettingDialog.Language = _cfgCommon.Language; SettingDialog.UseAtIdSupplement = _cfgCommon.UseAtIdSupplement; SettingDialog.UseHashSupplement = _cfgCommon.UseHashSupplement; SettingDialog.PreviewEnable = _cfgCommon.PreviewEnable; AtIdSupl = new AtIdSupplement(SettingAtIdList.Load().AtIdList, "@"); SettingDialog.IsMonospace = _cfgCommon.IsMonospace; if (SettingDialog.IsMonospace) { detailHtmlFormatHeader = detailHtmlFormatMono1; detailHtmlFormatFooter = detailHtmlFormatMono7; } else { detailHtmlFormatHeader = detailHtmlFormat1; detailHtmlFormatFooter = detailHtmlFormat7; } detailHtmlFormatHeader += _fntDetail.Name + detailHtmlFormat2 + _fntDetail.Size.ToString() + detailHtmlFormat3 + _clDetail.R.ToString() + "," + _clDetail.G.ToString() + "," + _clDetail.B.ToString() + detailHtmlFormat4 + _clDetailLink.R.ToString() + "," + _clDetailLink.G.ToString() + "," + _clDetailLink.B.ToString() + detailHtmlFormat5 + _clDetailBackcolor.R.ToString() + "," + _clDetailBackcolor.G.ToString() + "," + _clDetailBackcolor.B.ToString(); if (SettingDialog.IsMonospace) { detailHtmlFormatHeader += detailHtmlFormatMono6; } else { detailHtmlFormatHeader += detailHtmlFormat6; } this.IdeographicSpaceToSpaceToolStripMenuItem.Checked = _cfgCommon.WideSpaceConvert; this.ToolStripFocusLockMenuItem.Checked = _cfgCommon.FocusLockToStatusText; //Regex statregex = new Regex("^0*"); SettingDialog.RecommendStatusText = " [TWNv" + Regex.Replace(MyCommon.fileVersion.Replace(".", ""), "^0*", "") + "]"; //書式指定文字列エラーチェック try { if (DateTime.Now.ToString(SettingDialog.DateTimeFormat).Length == 0) { // このブロックは絶対に実行されないはず // 変換が成功した場合にLengthが0にならない SettingDialog.DateTimeFormat = "yyyy/MM/dd H:mm:ss"; } } catch (FormatException) { // FormatExceptionが発生したら初期値を設定 (=yyyy/MM/dd H:mm:ssとみなされる) SettingDialog.DateTimeFormat = "yyyy/MM/dd H:mm:ss"; } SettingDialog.Nicoms = _cfgCommon.Nicoms; SettingDialog.HotkeyEnabled = _cfgCommon.HotkeyEnabled; SettingDialog.HotkeyMod = _cfgCommon.HotkeyModifier; SettingDialog.HotkeyKey = _cfgCommon.HotkeyKey; SettingDialog.HotkeyValue = _cfgCommon.HotkeyValue; SettingDialog.BlinkNewMentions = _cfgCommon.BlinkNewMentions; SettingDialog.UseAdditionalCount = _cfgCommon.UseAdditionalCount; SettingDialog.MoreCountApi = _cfgCommon.MoreCountApi; SettingDialog.FirstCountApi = _cfgCommon.FirstCountApi; SettingDialog.SearchCountApi = _cfgCommon.SearchCountApi; SettingDialog.FavoritesCountApi = _cfgCommon.FavoritesCountApi; SettingDialog.UserTimelineCountApi = _cfgCommon.UserTimelineCountApi; SettingDialog.ListCountApi = _cfgCommon.ListCountApi; SettingDialog.UserstreamStartup = _cfgCommon.UserstreamStartup; SettingDialog.UserstreamPeriodInt = _cfgCommon.UserstreamPeriod; SettingDialog.OpenUserTimeline = _cfgCommon.OpenUserTimeline; SettingDialog.ListDoubleClickAction = _cfgCommon.ListDoubleClickAction; SettingDialog.UserAppointUrl = _cfgCommon.UserAppointUrl; SettingDialog.HideDuplicatedRetweets = _cfgCommon.HideDuplicatedRetweets; SettingDialog.IsPreviewFoursquare = _cfgCommon.IsPreviewFoursquare; SettingDialog.FoursquarePreviewHeight = _cfgCommon.FoursquarePreviewHeight; SettingDialog.FoursquarePreviewWidth = _cfgCommon.FoursquarePreviewWidth; SettingDialog.FoursquarePreviewZoom = _cfgCommon.FoursquarePreviewZoom; SettingDialog.IsListStatusesIncludeRts = _cfgCommon.IsListsIncludeRts; SettingDialog.TabMouseLock = _cfgCommon.TabMouseLock; SettingDialog.IsRemoveSameEvent = _cfgCommon.IsRemoveSameEvent; SettingDialog.IsNotifyUseGrowl = _cfgCommon.IsUseNotifyGrowl; //ハッシュタグ関連 HashSupl = new AtIdSupplement(_cfgCommon.HashTags, "#"); HashMgr = new HashtagManage(HashSupl, _cfgCommon.HashTags.ToArray(), _cfgCommon.HashSelected, _cfgCommon.HashIsPermanent, _cfgCommon.HashIsHead, _cfgCommon.HashIsNotAddToAtReply); if (!string.IsNullOrEmpty(HashMgr.UseHash) && HashMgr.IsPermanent) HashStripSplitButton.Text = HashMgr.UseHash; _initial = true; //アイコンリスト作成 try { TIconDic = new ImageDictionary(5); } catch (Exception) { MessageBox.Show("Please install [.NET Framework 4 (Full)]."); Application.Exit(); return; } ((ImageDictionary)this.TIconDic).PauseGetImage = false; bool saveRequired = false; //ユーザー名、パスワードが未設定なら設定画面を表示(初回起動時など) if (string.IsNullOrEmpty(tw.Username)) { saveRequired = true; //設定せずにキャンセルされた場合はプログラム終了 if (SettingDialog.ShowDialog(this) == DialogResult.Cancel) { Application.Exit(); //強制終了 return; } //設定されたが、依然ユーザー名とパスワードが未設定ならプログラム終了 if (string.IsNullOrEmpty(tw.Username)) { Application.Exit(); //強制終了 return; } //新しい設定を反映 //フォント&文字色&背景色保持 _fntUnread = SettingDialog.FontUnread; _clUnread = SettingDialog.ColorUnread; _fntReaded = SettingDialog.FontReaded; _clReaded = SettingDialog.ColorReaded; _clFav = SettingDialog.ColorFav; _clOWL = SettingDialog.ColorOWL; _clRetweet = SettingDialog.ColorRetweet; _fntDetail = SettingDialog.FontDetail; _clDetail = SettingDialog.ColorDetail; _clDetailLink = SettingDialog.ColorDetailLink; _clDetailBackcolor = SettingDialog.ColorDetailBackcolor; _clSelf = SettingDialog.ColorSelf; _clAtSelf = SettingDialog.ColorAtSelf; _clTarget = SettingDialog.ColorTarget; _clAtTarget = SettingDialog.ColorAtTarget; _clAtFromTarget = SettingDialog.ColorAtFromTarget; _clAtTo = SettingDialog.ColorAtTo; _clListBackcolor = SettingDialog.ColorListBackcolor; _clInputBackcolor = SettingDialog.ColorInputBackcolor; _clInputFont = SettingDialog.ColorInputFont; _fntInputFont = SettingDialog.FontInputFont; _brsForeColorUnread.Dispose(); _brsForeColorReaded.Dispose(); _brsForeColorFav.Dispose(); _brsForeColorOWL.Dispose(); _brsForeColorRetweet.Dispose(); _brsForeColorUnread = new SolidBrush(_clUnread); _brsForeColorReaded = new SolidBrush(_clReaded); _brsForeColorFav = new SolidBrush(_clFav); _brsForeColorOWL = new SolidBrush(_clOWL); _brsForeColorRetweet = new SolidBrush(_clRetweet); _brsBackColorMine.Dispose(); _brsBackColorAt.Dispose(); _brsBackColorYou.Dispose(); _brsBackColorAtYou.Dispose(); _brsBackColorAtFromTarget.Dispose(); _brsBackColorAtTo.Dispose(); _brsBackColorNone.Dispose(); _brsBackColorMine = new SolidBrush(_clSelf); _brsBackColorAt = new SolidBrush(_clAtSelf); _brsBackColorYou = new SolidBrush(_clTarget); _brsBackColorAtYou = new SolidBrush(_clAtTarget); _brsBackColorAtFromTarget = new SolidBrush(_clAtFromTarget); _brsBackColorAtTo = new SolidBrush(_clAtTo); _brsBackColorNone = new SolidBrush(_clListBackcolor); if (SettingDialog.IsMonospace) { detailHtmlFormatHeader = detailHtmlFormatMono1; detailHtmlFormatFooter = detailHtmlFormatMono7; } else { detailHtmlFormatHeader = detailHtmlFormat1; detailHtmlFormatFooter = detailHtmlFormat7; } detailHtmlFormatHeader += _fntDetail.Name + detailHtmlFormat2 + _fntDetail.Size.ToString() + detailHtmlFormat3 + _clDetail.R.ToString() + "," + _clDetail.G.ToString() + "," + _clDetail.B.ToString() + detailHtmlFormat4 + _clDetailLink.R.ToString() + "," + _clDetailLink.G.ToString() + "," + _clDetailLink.B.ToString() + detailHtmlFormat5 + _clDetailBackcolor.R.ToString() + "," + _clDetailBackcolor.G.ToString() + "," + _clDetailBackcolor.B.ToString(); if (SettingDialog.IsMonospace) { detailHtmlFormatHeader += detailHtmlFormatMono6; } else { detailHtmlFormatHeader += detailHtmlFormat6; } //他の設定項目は、随時設定画面で保持している値を読み出して使用 } if (SettingDialog.HotkeyEnabled) { //////グローバルホットキーの登録 HookGlobalHotkey.ModKeys modKey = HookGlobalHotkey.ModKeys.None; if ((SettingDialog.HotkeyMod & Keys.Alt) == Keys.Alt) modKey = modKey | HookGlobalHotkey.ModKeys.Alt; if ((SettingDialog.HotkeyMod & Keys.Control) == Keys.Control) modKey = modKey | HookGlobalHotkey.ModKeys.Ctrl; if ((SettingDialog.HotkeyMod & Keys.Shift) == Keys.Shift) modKey = modKey | HookGlobalHotkey.ModKeys.Shift; if ((SettingDialog.HotkeyMod & Keys.LWin) == Keys.LWin) modKey = modKey | HookGlobalHotkey.ModKeys.Win; _hookGlobalHotkey.RegisterOriginalHotkey(SettingDialog.HotkeyKey, SettingDialog.HotkeyValue, modKey); } //Twitter用通信クラス初期化 HttpConnection.InitializeConnection(SettingDialog.DefaultTimeOut, SettingDialog.SelectedProxyType, SettingDialog.ProxyAddress, SettingDialog.ProxyPort, SettingDialog.ProxyUser, SettingDialog.ProxyPassword); tw.RestrictFavCheck = SettingDialog.RestrictFavCheck; tw.ReadOwnPost = SettingDialog.ReadOwnPost; tw.UseSsl = SettingDialog.UseSsl; ShortUrl.IsResolve = SettingDialog.TinyUrlResolve; ShortUrl.IsForceResolve = SettingDialog.ShortUrlForceResolve; ShortUrl.BitlyId = SettingDialog.BitlyUser; ShortUrl.BitlyKey = SettingDialog.BitlyPwd; HttpTwitter.TwitterUrl = _cfgCommon.TwitterUrl; HttpTwitter.TwitterSearchUrl = _cfgCommon.TwitterSearchUrl; tw.TrackWord = _cfgCommon.TrackWord; TrackToolStripMenuItem.Checked = !String.IsNullOrEmpty(tw.TrackWord); tw.AllAtReply = _cfgCommon.AllAtReply; AllrepliesToolStripMenuItem.Checked = tw.AllAtReply; Outputz.Key = SettingDialog.OutputzKey; Outputz.Enabled = SettingDialog.OutputzEnabled; switch (SettingDialog.OutputzUrlmode) { case MyCommon.OutputzUrlmode.twittercom: Outputz.OutUrl = "http://twitter.com/"; break; case MyCommon.OutputzUrlmode.twittercomWithUsername: Outputz.OutUrl = "http://twitter.com/" + tw.Username; break; } //画像投稿サービス this.CreatePictureServices(); SetImageServiceCombo(); ImageSelectionPanel.Enabled = false; ImageServiceCombo.SelectedIndex = _cfgCommon.UseImageService; //ウィンドウ設定 this.ClientSize = _cfgLocal.FormSize; _mySize = _cfgLocal.FormSize; //サイズ保持(最小化・最大化されたまま終了した場合の対応用) _myLoc = _cfgLocal.FormLocation; //タイトルバー領域 if (this.WindowState != FormWindowState.Minimized) { this.DesktopLocation = _cfgLocal.FormLocation; Rectangle tbarRect = new Rectangle(this.Location, new Size(_mySize.Width, SystemInformation.CaptionHeight)); bool outOfScreen = true; if (Screen.AllScreens.Length == 1) //ハングするとの報告 { foreach (Screen scr in Screen.AllScreens) { if (!Rectangle.Intersect(tbarRect, scr.Bounds).IsEmpty) { outOfScreen = false; break; } } if (outOfScreen) { this.DesktopLocation = new Point(0, 0); _myLoc = this.DesktopLocation; } } } this.TopMost = SettingDialog.AlwaysTop; _mySpDis = _cfgLocal.SplitterDistance; _mySpDis2 = _cfgLocal.StatusTextHeight; _mySpDis3 = _cfgLocal.PreviewDistance; if (_mySpDis3 == -1) { _mySpDis3 = _mySize.Width - 150; if (_mySpDis3 < 1) _mySpDis3 = 50; _cfgLocal.PreviewDistance = _mySpDis3; } _myAdSpDis = _cfgLocal.AdSplitterDistance; MultiLineMenuItem.Checked = _cfgLocal.StatusMultiline; //this.Tween_ClientSizeChanged(this, null); PlaySoundMenuItem.Checked = SettingDialog.PlaySound; this.PlaySoundFileMenuItem.Checked = SettingDialog.PlaySound; //入力欄 StatusText.Font = _fntInputFont; StatusText.ForeColor = _clInputFont; //全新着通知のチェック状態により、Reply&DMの新着通知有効無効切り替え(タブ別設定にするため削除予定) if (SettingDialog.UnreadManage == false) { ReadedStripMenuItem.Enabled = false; UnreadStripMenuItem.Enabled = false; } if (SettingDialog.IsNotifyUseGrowl) gh.RegisterGrowl(); //タイマー設定 TimerTimeline.AutoReset = true; TimerTimeline.SynchronizingObject = this; //Recent取得間隔 TimerTimeline.Interval = 1000; TimerTimeline.Enabled = true; //更新中アイコンアニメーション間隔 TimerRefreshIcon.Interval = 200; TimerRefreshIcon.Enabled = true; //状態表示部の初期化(画面右下) StatusLabel.Text = ""; StatusLabel.AutoToolTip = false; StatusLabel.ToolTipText = ""; //文字カウンタ初期化 lblLen.Text = GetRestStatusCount(true, false).ToString(); //////////////////////////////////////////////////////////////////////////////// _statuses.SortOrder = (SortOrder)_cfgCommon.SortOrder; IdComparerClass.ComparerMode mode = IdComparerClass.ComparerMode.Id; switch (_cfgCommon.SortColumn) { case 0: //0:アイコン,5:未読マーク,6:プロテクト・フィルターマーク case 5: case 6: //ソートしない mode = IdComparerClass.ComparerMode.Id; //Idソートに読み替え break; case 1: //ニックネーム mode = IdComparerClass.ComparerMode.Nickname; break; case 2: //本文 mode = IdComparerClass.ComparerMode.Data; break; case 3: //時刻=発言Id mode = IdComparerClass.ComparerMode.Id; break; case 4: //名前 mode = IdComparerClass.ComparerMode.Name; break; case 7: //Source mode = IdComparerClass.ComparerMode.Source; break; } _statuses.SortMode = mode; //////////////////////////////////////////////////////////////////////////////// switch (SettingDialog.IconSz) { case MyCommon.IconSizes.IconNone: _iconSz = 0; break; case MyCommon.IconSizes.Icon16: _iconSz = 16; break; case MyCommon.IconSizes.Icon24: _iconSz = 26; break; case MyCommon.IconSizes.Icon48: _iconSz = 48; break; case MyCommon.IconSizes.Icon48_2: _iconSz = 48; _iconCol = true; break; } if (_iconSz == 0) { tw.GetIcon = false; } else { tw.GetIcon = true; tw.IconSize = _iconSz; } tw.TinyUrlResolve = SettingDialog.TinyUrlResolve; ShortUrl.IsForceResolve = SettingDialog.ShortUrlForceResolve; //発言詳細部アイコンをリストアイコンにサイズ変更 int sz = _iconSz; if (_iconSz == 0) { sz = 16; } tw.DetailIcon = TIconDic; StatusLabel.Text = Properties.Resources.Form1_LoadText1; //画面右下の状態表示を変更 StatusLabelUrl.Text = ""; //画面左下のリンク先URL表示部を初期化 NameLabel.Text = ""; //発言詳細部名前ラベル初期化 DateTimeLabel.Text = ""; //発言詳細部日時ラベル初期化 SourceLinkLabel.Text = ""; //Source部分初期化 //<<<<<<<<タブ関連>>>>>>> //デフォルトタブの存在チェック、ない場合には追加 if (_statuses.GetTabByType(MyCommon.TabUsageType.Home) == null) { if (!_statuses.Tabs.ContainsKey(MyCommon.DEFAULTTAB.RECENT)) { _statuses.AddTab(MyCommon.DEFAULTTAB.RECENT, MyCommon.TabUsageType.Home, null); } else { _statuses.Tabs[MyCommon.DEFAULTTAB.RECENT].TabType = MyCommon.TabUsageType.Home; } } if (_statuses.GetTabByType(MyCommon.TabUsageType.Mentions) == null) { if (!_statuses.Tabs.ContainsKey(MyCommon.DEFAULTTAB.REPLY)) { _statuses.AddTab(MyCommon.DEFAULTTAB.REPLY, MyCommon.TabUsageType.Mentions, null); } else { _statuses.Tabs[MyCommon.DEFAULTTAB.REPLY].TabType = MyCommon.TabUsageType.Mentions; } } if (_statuses.GetTabByType(MyCommon.TabUsageType.DirectMessage) == null) { if (!_statuses.Tabs.ContainsKey(MyCommon.DEFAULTTAB.DM)) { _statuses.AddTab(MyCommon.DEFAULTTAB.DM, MyCommon.TabUsageType.DirectMessage, null); } else { _statuses.Tabs[MyCommon.DEFAULTTAB.DM].TabType = MyCommon.TabUsageType.DirectMessage; } } if (_statuses.GetTabByType(MyCommon.TabUsageType.Favorites) == null) { if (!_statuses.Tabs.ContainsKey(MyCommon.DEFAULTTAB.FAV)) { _statuses.AddTab(MyCommon.DEFAULTTAB.FAV, MyCommon.TabUsageType.Favorites, null); } else { _statuses.Tabs[MyCommon.DEFAULTTAB.FAV].TabType = MyCommon.TabUsageType.Favorites; } } foreach (string tn in _statuses.Tabs.Keys) { if (_statuses.Tabs[tn].TabType == MyCommon.TabUsageType.Undefined) { _statuses.Tabs[tn].TabType = MyCommon.TabUsageType.UserDefined; } if (!AddNewTab(tn, true, _statuses.Tabs[tn].TabType, _statuses.Tabs[tn].ListInfo)) throw new Exception(Properties.Resources.TweenMain_LoadText1); } this.JumpReadOpMenuItem.ShortcutKeyDisplayString = "Space"; CopySTOTMenuItem.ShortcutKeyDisplayString = "Ctrl+C"; CopyURLMenuItem.ShortcutKeyDisplayString = "Ctrl+Shift+C"; CopyUserIdStripMenuItem.ShortcutKeyDisplayString = "Shift+Alt+C"; if (SettingDialog.MinimizeToTray = false || this.WindowState != FormWindowState.Minimized) { this.Visible = true; } _curTab = ListTab.SelectedTab; _curItemIndex = -1; _curList = (DetailsListView)_curTab.Tag; SetMainWindowTitle(); SetNotifyIconText(); if (SettingDialog.TabIconDisp) { ListTab.DrawMode = TabDrawMode.Normal; } else { ListTab.DrawMode = TabDrawMode.OwnerDrawFixed; ListTab.DrawItem += ListTab_DrawItem; ListTab.ImageList = null; } #if UA ab = new AdsBrowser(); this.SplitContainer4.Panel2.Controls.Add(ab); #else SplitContainer4.Panel2Collapsed = true; #endif _ignoreConfigSave = false; this.TweenMain_Resize(null, null); if (saveRequired) SaveConfigsAll(false); if (tw.UserId == 0) { tw.VerifyCredentials(); foreach (UserAccount ua in _cfgCommon.UserAccounts) { if (ua.Username.ToLower() == tw.Username.ToLower()) { ua.UserId = tw.UserId; break; } } } foreach (UserAccount ua in SettingDialog.UserAccounts) { if (ua.UserId == 0 && ua.Username.ToLower() == tw.Username.ToLower()) { ua.UserId = tw.UserId; break; } } }
private void SelectListItem(DetailsListView LView , int[] Index, int focusedIndex, int selectionMarkIndex) { //複数 Rectangle bnd = new Rectangle(); bool flg = false; var item = LView.FocusedItem; if (item != null) { bnd = item.Bounds; flg = true; } if (Index != null) { do { LView.SelectedIndices.Clear(); } while (LView.SelectedIndices.Count > 0); LView.SelectItems(Index); } if (selectionMarkIndex > -1 && LView.VirtualListSize > selectionMarkIndex) { LView.SelectionMark = selectionMarkIndex; } if (focusedIndex > -1 && LView.VirtualListSize > focusedIndex) { LView.Items[focusedIndex].Focused = true; } else if (Index != null && Index.Length != 0) { LView.Items[Index.Last()].Focused = true; } if (flg) LView.Invalidate(bnd); }
public bool RemoveSpecifiedTab(string TabName, bool confirm) { int idx = 0; for (idx = 0; idx < ListTab.TabPages.Count; idx++) { if (ListTab.TabPages[idx].Text == TabName) break; } if (_statuses.IsDefaultTab(TabName)) return false; if (confirm) { string tmp = string.Format(Properties.Resources.RemoveSpecifiedTabText1, Environment.NewLine); if (MessageBox.Show(tmp, TabName + " " + Properties.Resources.RemoveSpecifiedTabText2, MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Cancel) { return false; } } SetListProperty(); //他のタブに列幅等を反映 MyCommon.TabUsageType tabType = _statuses.Tabs[TabName].TabType; //オブジェクトインスタンスの削除 this.SplitContainer1.Panel1.SuspendLayout(); this.SplitContainer1.Panel2.SuspendLayout(); this.SplitContainer1.SuspendLayout(); this.ListTab.SuspendLayout(); this.SuspendLayout(); TabPage _tabPage = ListTab.TabPages[idx]; DetailsListView _listCustom = (DetailsListView)_tabPage.Tag; _tabPage.Tag = null; _tabPage.SuspendLayout(); if (this.ListTab.SelectedTab == this.ListTab.TabPages[idx]) { this.ListTab.SelectTab((this._beforeSelectedTab != null && this.ListTab.TabPages.Contains(this._beforeSelectedTab)) ? this._beforeSelectedTab : this.ListTab.TabPages[0]); } this.ListTab.Controls.Remove(_tabPage); Control pnl = null; if (tabType == MyCommon.TabUsageType.PublicSearch) { pnl = _tabPage.Controls["panelSearch"]; foreach (Control ctrl in pnl.Controls) { if (ctrl.Name == "buttonSearch") { ctrl.Click -= SearchButton_Click; } ctrl.Enter -= SearchControls_Enter; ctrl.Leave -= SearchControls_Leave; pnl.Controls.Remove(ctrl); ctrl.Dispose(); } _tabPage.Controls.Remove(pnl); } _tabPage.Controls.Remove(_listCustom); _listCustom.Columns.Clear(); _listCustom.ContextMenuStrip = null; _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; TabDialog.RemoveTab(TabName); _listCustom.SmallImageList = null; _listCustom.ListViewItemSorter = null; //キャッシュのクリア if (_curTab.Equals(_tabPage)) { _curTab = null; _curItemIndex = -1; _curList = null; _curPost = null; } _itemCache = null; _itemCacheIndex = -1; _postCache = null; _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.Dispose(); _listCustom.Dispose(); _statuses.RemoveTab(TabName); foreach (TabPage tp in ListTab.TabPages) { DetailsListView lst = (DetailsListView)tp.Tag; if (lst.VirtualListSize != _statuses.Tabs[tp.Text].AllCount) { lst.VirtualListSize = _statuses.Tabs[tp.Text].AllCount; } } return true; }
private long[] GetSelectedStatusIds(DetailsListView listView, TabClass tab) { var selectedIndices = listView.SelectedIndices; if (selectedIndices.Count > 0 && selectedIndices.Count < 61) return tab.GetId(selectedIndices); else return null; }