private IceTabPage setSelectedByClickLocation(Point pClickLocation) { if (_tabSizeRects.Count == 0) return null; for (int i = 0; i < _tabSizeRects.Count; i++) { Rectangle rectTab = _tabSizeRects[i]; if ((pClickLocation.X > rectTab.X && pClickLocation.X < rectTab.X + rectTab.Width) && (pClickLocation.Y > rectTab.Y && pClickLocation.Y < rectTab.Bottom)) { if (this._selectedIndex != i) { this._selectedIndex = i; checkTabLocation(i); } break; } } if (GetTabPage(_selectedIndex) != null) { if (this.SelectedIndexChanged != null) { _parent.TabMain.BringFront(_TabPages[_selectedIndex]); TabEventArgs e = new TabEventArgs(); SelectedIndexChanged(this, e); } } this.Invalidate(); return GetTabPage(_selectedIndex); }
private void OnMouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left && singleRow && showScrollItems) { //check if we have clicked next or previous if (e.X >= (this.Width - 44)) { if (e.X > (this.Width - 22)) { //right/next button if (_selectedIndex == _TabPages.Count-1) return; _selectedIndex++; SelectTab(GetTabPage(_selectedIndex)); } else { //left/prev button //what position are we if (_selectedIndex == 0) return; //no need to scroll left -all the way there _selectedIndex--; SelectTab(GetTabPage(_selectedIndex)); } TabEventArgs te = new TabEventArgs(); te.IsHandled = false; SelectedIndexChanged(this, te); return; } } _dragStartPosition = new Point(e.X, e.Y); _dragTab = setSelectedByClickLocation(e.Location); if (e.Button == MouseButtons.Middle) { if (_dragTab != null) { if (this.OnTabClosed != null) OnTabClosed(SelectedIndex); } } }
/// <summary> /// A New Tab was Selected for the Main Tab Control /// Update the Input Panel with the Current Connection /// Change the Status text for the Status Bar /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnTabSelectedIndexChanged(object sender, TabEventArgs e) { if (!this.IsHandleCreated && !this.IsDisposed) return; this.Invoke((MethodInvoker)delegate() { if (mainChannelBar.CurrentTab.WindowStyle != IceTabPage.WindowType.Console) { if (mainChannelBar.CurrentTab != null) { IceTabPage t = mainChannelBar.CurrentTab; nickList.RefreshList(t); inputPanel.CurrentConnection = t.Connection; string network = ""; if (CurrentWindowStyle != IceTabPage.WindowType.Debug && CurrentWindowStyle != IceTabPage.WindowType.DCCFile && CurrentWindowStyle != IceTabPage.WindowType.Window && t.Connection.ServerSetting.NetworkName.Length > 0) network = " (" + t.Connection.ServerSetting.NetworkName + ")"; string away = ""; if (inputPanel.CurrentConnection != null && inputPanel.CurrentConnection.ServerSetting.Away == true) away = " {AWAY}"; if (CurrentWindowStyle == IceTabPage.WindowType.Channel) { //get the current user status mode for the channel User u = t.GetNick(t.Connection.ServerSetting.CurrentNickName); if (u != null) StatusText(u.ToString() + " in channel " + t.TabCaption + " [" + t.ChannelModes + "] {" + t.Connection.ServerSetting.RealServerName + "}" + network + away); else StatusText(t.Connection.ServerSetting.CurrentNickName + " in channel " + t.TabCaption + " [" + t.ChannelModes + "] {" + t.Connection.ServerSetting.RealServerName + "}" + network + away); } else if (CurrentWindowStyle == IceTabPage.WindowType.Query) StatusText(t.Connection.ServerSetting.CurrentNickName + " in private chat with " + t.TabCaption + " {" + t.Connection.ServerSetting.RealServerName + "}" + network + away); else if (CurrentWindowStyle == IceTabPage.WindowType.DCCChat) StatusText(t.Connection.ServerSetting.CurrentNickName + " in DCC chat with " + t.TabCaption + " {" + t.Connection.ServerSetting.RealServerName + "}" + network); else if (CurrentWindowStyle == IceTabPage.WindowType.ChannelList) StatusText(t.Connection.ServerSetting.CurrentNickName + " in Channel List for {" + t.Connection.ServerSetting.RealServerName + "}" + network); CurrentWindow.LastMessageType = ServerMessageType.Default; t = null; if (e.IsHandled == false) { serverTree.SelectTab(mainChannelBar.CurrentTab, false); } } } else { //make sure the 1st tab is not selected nickList.RefreshList(); nickList.Header = iceChatLanguage.consoleTabTitle; if (mainChannelBar.GetTabPage("Console").ConsoleTab.SelectedIndex != 0) { inputPanel.CurrentConnection = mainChannelBar.GetTabPage("Console").CurrentConnection; string network = ""; if (inputPanel.CurrentConnection.ServerSetting.NetworkName.Length > 0) network = " (" + inputPanel.CurrentConnection.ServerSetting.NetworkName + ")"; if (inputPanel.CurrentConnection.IsConnected) { string ssl = ""; if (inputPanel.CurrentConnection.ServerSetting.UseSSL) ssl = " {SSL}"; string away = ""; if (inputPanel.CurrentConnection.ServerSetting.Away == true) away = " {AWAY}"; if (inputPanel.CurrentConnection.ServerSetting.UseBNC) StatusText(inputPanel.CurrentConnection.ServerSetting.CurrentNickName + " connected to " + inputPanel.CurrentConnection.ServerSetting.RealServerName + " {BNC " + inputPanel.CurrentConnection.ServerSetting.BNCIP + "}" + away); else StatusText(inputPanel.CurrentConnection.ServerSetting.CurrentNickName + " connected to " + inputPanel.CurrentConnection.ServerSetting.RealServerName + ssl + network + away); } else { if (inputPanel.CurrentConnection.ServerSetting.UseBNC) StatusText(inputPanel.CurrentConnection.ServerSetting.CurrentNickName + " disconnected from " + inputPanel.CurrentConnection.ServerSetting.BNCIP); else StatusText(inputPanel.CurrentConnection.ServerSetting.CurrentNickName + " disconnected from " + inputPanel.CurrentConnection.ServerSetting.ServerName + network); } //what is the current server - reset the color foreach (ConsoleTab t in mainChannelBar.GetTabPage("Console").ConsoleTab.TabPages) { if (t.Connection != null && t.Connection.ServerSetting == inputPanel.CurrentConnection.ServerSetting) t.LastMessageType = ServerMessageType.Default; } if (e.IsHandled == false) { serverTree.SelectTab(mainChannelBar.GetTabPage("Console").CurrentConnection.ServerSetting, false); } } else { inputPanel.CurrentConnection = null; StatusText("Welcome to " + ProgramID + " " + VersionID); } } this.FocusInputBox(); }); }