/// <summary> /// ���X�g�Ƀ`�����l����lj����� /// </summary> /// <param name="ch"></param> private void addChannel(Channel ch) { ListViewItem item = new ListViewItem(ch.Name); item.Tag = ch; if (ch.IsChannel) { item.ImageIndex = ch.IsJoin ? IMAGE_ONLINE_CHANNEL : IMAGE_OFFLINE_CHANNEL; } else { item.ImageIndex = IMAGE_NORMAL_MEMBER; } openedChannelListview.Items.Add(item); // �I�����Ă����烁���o�[�ꗗ��o���ō쐬 if (((Owner as EbIrcMainForm).CurrentChannel == ch)) { item.Selected = true; LoadMemberList(); } }
/// <summary> /// �n�C���C�g��������s���܂� /// </summary> private void DoHighlight() { if (highlightFlag && (highlightChannel != null)) { if ((SettingManager.Data.HighlightMethod == EbIRCHighlightMethod.Vibration) || (SettingManager.Data.HighlightMethod == EbIRCHighlightMethod.VibrationAndLed)) { if (Led.AvailableLed(LedType.Vibrartion)) { Led.SetLedStatus(SettingManager.Data.LedIdLight, LedStatus.On); clearHighlightTimer.Enabled = true; } } if ((SettingManager.Data.HighlightMethod == EbIRCHighlightMethod.Led) || (SettingManager.Data.HighlightMethod == EbIRCHighlightMethod.VibrationAndLed)) { if (Led.AvailableLed(LedType.Yellow)) { Led.SetLedStatus(SettingManager.Data.LedIdVibration, LedStatus.On); clearHighlightTimer.Enabled = true; } } if (SettingManager.Data.HighlightChannelChange) { LoadChannel(highlightChannel); } } highlightFlag = false; highlightChannel = null; }
/// <summary> /// ���O���b�Z�[�W�̒~�ς�J�n /// </summary> private void BeginStoreLog() { highlightFlag = false; highlightChannel = null; m_storedLog = new StringBuilder(); m_storeFlag = true; }
/// <summary> /// ���O�̒lj� /// </summary> /// <param name="targetCh">�Ώۂ̃`�����l��</param> /// <param name="message">���b�Z�[�W</param> /// <returns>�lj��������O���b�Z�[�W</returns> string AddLog(Channel channel, string message) { // ���݂̎����e�L�X�g string time = string.Format(Resources.TimeFormat, DateTime.Now.Hour, DateTime.Now.Minute); // �������X�V message = string.Format(Resources.LogFormat, time, message); // ���O��lj����� channel.AddLogs(message); // ���݂̃`�����l���ɏo�͂��ꂽ��̂Ȃ�A�o�͂��� if (channel == m_currentCh) { if (m_storeFlag) { // �~�σ��[�h�̎��͒~�ς��� if (m_storedLog.Length > 0) m_storedLog.Append("\r\n"); m_storedLog.Append(message); } else { // �~�σ��[�h�łȂ���Ώo�͂��� PrintLog(message); } } return message; }
/// <summary> /// �`�����l����lj����� /// </summary> /// <param name="name">�lj�����`�����l����</param> /// <param name="defaultChannel">�f�t�H���g�`�����l�����ǂ���</param> /// <param name="password">�p�X���[�h</param> /// <returns>�lj����ꂽ�`�����l��</returns> internal Channel AddChannel(string name, bool defaultChannel, string password, bool isSortTarget) { // ����Ȃ甲���� if (string.IsNullOrEmpty(name.Trim())) { return null; } // ��������悤�Ƃ��ꂽ�ꍇ�͔����� if (name == "-") { return null; } // ���ɑ��݂��Ă���A���̃`�����l����Ԃ� if (m_channel.ContainsKey(name)) { return m_channel[name]; } Channel channel = new Channel(name, defaultChannel, password, isSortTarget); // �`�����l����쐬 m_channel.Add(name, channel); // ���X�g�ɒlj� // ���j���[�ւ̒lj��p ChannelMenuItem menu; // �`�����l���ꗗ���j���[�ɒlj� menu = new ChannelMenuItem(channel); menu.Click += new EventHandler(menuChannelListChannelsMenuItem_Click); menuChannelListMenuItem.MenuItems.Add(menu); // ���j���[�ɒlj� // �|�b�v�A�b�v���j���[�ɒlj� menu = new ChannelMenuItem(channel); menu.Click += new EventHandler(menuChannelListChannelsMenuItem_Click); m_channelPopupMenus.Add(menu); return channel; }
/// <summary> /// �w�肳�ꂽ�`�����l���ł̃n�C���C�g��Z�b�g���܂� /// </summary> /// <param name="channel">�n�C���C�g����`�����l��</param> private void SetHighlight(Channel channel, string sender, string message) { highlightFlag = true; highlightChannel = channel; string formattedMessage = string.Format(Resources.PrivmsgLogFormat, sender, message); // �n�C���C�g���b�Z�[�W�ꗗ�ɒlj� ChannelMenuItem mesMenu = new ChannelMenuItem(channel); mesMenu.Text = formattedMessage; mesMenu.Click += new EventHandler(menuChannelListChannelsMenuItem_Click); menuHighlightedMessages.MenuItems.Add(mesMenu); AddLog(m_highlightsCh, string.Format(Resources.WholePrivmsgLogFormat, channel.Name, sender, message)); // �Y���`�����l����n�C���C�g�`�F�b�N���� foreach (ChannelMenuItem menu in m_channelPopupMenus) { if (menu.Channel == channel) { menu.Checked = true; break; } } // �g�[�X�g if (SettingManager.Data.HighlightToast) { if (m_toastQueue == null) { m_toastQueue = new Queue<ToastItem>(); } lock (notification) { if (notification.Visible) { m_toastQueue.Enqueue(new ToastItem() { Caption = channel.Name, Text = formattedMessage }); } else { notification.Caption = channel.Name; notification.Text = formattedMessage; notification.Visible = true; } } } if (!m_storeFlag) DoHighlight(); }
/// <summary> /// ���݂̃`�����l����ύX���� /// </summary> /// <param name="ch">�`�����l��</param> void LoadChannel(Channel channel) { if (channel == m_serverCh) { // �^�C�g���o�[�ݒ� this.Text = Resources.ServerMessageTitlebar; // �g�s�b�N�o�[�ݒ� topicLabel.Text = Resources.ServerMessageTopicbar; } else if (channel == m_wholeCh) { // �^�C�g���o�[�ݒ� this.Text = Resources.WholeTitlebar; // �g�s�b�N�o�[�ݒ� topicLabel.Text = Resources.WholeTopicbar; } else if (channel == m_highlightsCh) { // �^�C�g���o�[�ݒ� this.Text = Resources.HighlightTitlebar; // �g�s�b�N�o�[�ݒ� topicLabel.Text = Resources.HighlightTopicbar; } else { // �^�C�g���o�[�ݒ� this.Text = string.Format(Resources.TitlebarFormat, channel.Name, channel.Members.Length); // �g�s�b�N�o�[�ݒ� topicLabel.Text = string.Format(Resources.TopicbarFormat, channel.Name, channel.Topic); } // & �� && �ɒu������(�A�N�Z�X�L�[���h�~) topicLabel.Text = topicLabel.Text.Replace("&", "&&"); // �`�����l�����ύX�����Ƃ��̂݃��O��ǂݍ��� if (m_currentCh != channel) { ClearStoredLog(); IntPtr eventMask = IntPtr.Zero; try { // Stop redrawing: SendMessage(logTextBox.Handle, WM_SETREDRAW, 0, IntPtr.Zero); // Stop sending of events: eventMask = SendMessage(logTextBox.Handle, EM_GETEVENTMASK, 0, IntPtr.Zero); logTextBox.Text = channel.GetLogs(); LogMoveLastLine(); // �������N���A channel.UnreadCount = 0; } finally { // turn on events SendMessage(logTextBox.Handle, EM_SETEVENTMASK, 0, eventMask); // turn on redrawing SendMessage(logTextBox.Handle, WM_SETREDRAW, 1, IntPtr.Zero); } } // ���̃`�����l���̃n�C���C�g���b�Z�[�W����� for (int i = (menuHighlightedMessages.MenuItems.Count - 1); i >= 0; i--) { ChannelMenuItem menu = menuHighlightedMessages.MenuItems[i] as ChannelMenuItem; if (menu.Channel == channel) { menuHighlightedMessages.MenuItems.RemoveAt(i); } } // �n�C���C�g�`�F�b�N��� foreach (ChannelMenuItem menu in m_channelPopupMenus) { if (menu.Channel == channel) { menu.Checked = false; break; } } // �J�����g�`�����l���X�V m_currentCh = channel; }
/// <summary> /// �R���X�g���N�^ /// </summary> public EbIrcMainForm() { InitializeComponent(); logTextBox.BackColor = SystemColors.Window; // �萔���[�h CONNMGR_URL_FORMAT = "http://{0}:{1}/"; LOG_KEY_SERVER = Resources.ChannelSelecterServerCaption; LOG_KEY_WHOLE = Resources.ChannelSelecterWholeCaption; LOG_KEY_HIGHLIGHTS = Resources.ChannelSelecterHighlightsCaption; // IRC�N���C�A���g�������A�C�x���g�n���h������ ircClient = new IRCClient(); ircClient.OwnerControl = this; ircClient.ChangedMyNickname += new NickNameChangeEventHandler(ircClient_ChangeMyNickname); ircClient.Connected += new EventHandler(ircClient_Connected); ircClient.ConnectionFailed += new EventHandler(ircClient_ConnectionFailed); ircClient.Disconnected += new EventHandler(ircClient_Disconnected); ircClient.Kick += new KickEventHandler(ircClient_Kick); ircClient.ProcessedConnection += new EventHandler(ircClient_ProcessedConnection); ircClient.ReceiveCtcpQuery += new CtcpEventHandler(ircClient_ReceiveCtcpQuery); ircClient.ReceiveCtcpReply += new CtcpEventHandler(ircClient_ReceiveCtcpReply); ircClient.ReceiveMessage += new ReceiveMessageEventHandler(ircClient_ReceiveMessage); ircClient.ReceiveNames += new ReceiveNamesEventHandler(ircClient_ReceiveNames); ircClient.ReceiveNotice += new ReceiveMessageEventHandler(ircClient_ReceiveNotice); ircClient.ReceiveServerReply += new ReceiveServerReplyEventHandler(ircClient_ReceiveServerReply); ircClient.UserInOut += new UserInOutEventHandler(ircClient_UserInOut); ircClient.TopicChange += new TopicChangeEventDelegate(ircClient_TopicChange); ircClient.ChangedNickname += new NickNameChangeEventHandler(ircClient_ChangedNickname); ircClient.ModeChange += new ModeChangeEventHandler(ircClient_ModeChange); ircClient.StartMessageEvents += new EventHandler(ircClient_StartMessageEvents); ircClient.FinishMessageEvents += new EventHandler(ircClient_FinishMessageEvents); // �ݒ��ǂݍ��� SettingManager.ReadSetting(); // �`�����l�����X�g������ m_channel = new Dictionary<string, Channel>(new ChannelNameEqualityComparer()); m_channelPopupMenus = new List<ChannelMenuItem>(); // �T�[�o�[�`�����l����p�ӂ��� m_serverCh = new Channel(LOG_KEY_SERVER, false, null, true); m_highlightsCh = new Channel(LOG_KEY_HIGHLIGHTS, false, null, true); m_wholeCh = new Channel(LOG_KEY_WHOLE, false, null, true); // �o�[�W�������o�� Assembly asm = Assembly.GetExecutingAssembly(); AssemblyName asmName = asm.GetName(); AddLog(m_serverCh, string.Format(Resources.VersionInfomation, asmName.Version.Major, asmName.Version.Minor, asmName.Version.Build)); // �e�L�X�g���O������ m_inputlog = new List<string>(SettingManager.Data.InputLogBufferSize); m_inputlogPtr = 0; // ���b�Z�[�W�t�B���^�ݒ� m_inputBoxFilter = new InputBoxInputFilter(inputTextBox); m_inputBoxFilter.EndComposition += new EventHandler(m_inputBoxFilter_EndComposition); m_inputBoxFilter.MouseWheelMoveDown += new EventHandler(m_inputBoxFilter_MouseWheelMoveDown); m_inputBoxFilter.MouseWheelMoveUp += new EventHandler(m_inputBoxFilter_MouseWheelMoveUp); m_logBoxFilter = new LogBoxInputFilter(logTextBox); m_logBoxFilter.TapUp += new EventHandler(m_logBoxFilter_TapUp); m_logBoxFilter.Resize += new EventHandler(m_logBoxFilter_Resize); // UI�ݒ��A�b�v�f�[�g���� SetConnectionMenuText(); // �ڑ����j���[ SetDefaultChannel(); // �f�t�H���g�ڑ��`�����l���̓ǂݍ��� LoadChannel(m_serverCh); // �T�[�o�[���b�Z�[�W�ɐ�ւ� UpdateUISettings(); // ���̑���UI�ݒ�̃A�b�v�f�[�g // �\�t�g�L�[�̓���ւ� if (SettingManager.Data.ReverseSoftKey) { mainMenu1.MenuItems.Remove(connectionMenuItem); mainMenu1.MenuItems.Add(connectionMenuItem); } }
/// <summary> /// �`�����l����w�肵�ă��j���[����������܂��B /// </summary> /// <param name="channel">���̃��j���[�ɑΉ�����`�����l��</param> public ChannelMenuItem(Channel channel) : base() { Channel = channel; }