public ChatPopupForm(Context context, MessageTarget target) : base(context, "ChatPopup") { InitializeComponent(); base.Initialize(); this.Text += target.Target; this._target = target; this._context = context; this._context.MessageEvent += new Handler <MessageEventArgs>(_context_MessageEvent); this._context.Options.SavedEvent += new Handler <Options>(_context_SavedEvent); // Setup output control this._contextMenu = new ChatContextMenu(this, context); this._outputBox.ContextMenu = this._contextMenu; this._outputBox.Context = context; this._outputBox.BackgroundColor = this.BackColor; this._outputBox.ForegroundColor = this.ForeColor; this._outputBox.Initialize(context.Configuration.OutputMode); // Force options update manually this._context_SavedEvent(this._context, this._context.Options); // Preload output window with messages MessageEventArgs[] messages = context.GetHistory(target); foreach (MessageEventArgs message in messages) { _context_MessageEvent(context, message); } }
public ChatForm(Context context) : base(context, "Chat") { InitializeComponent(); base.Initialize(); this._context = context; this._context.Options.SavedEvent += new Handler <Options>(_context_SavedEvent); this._context.StateEvent += new Handler <StateEventArgs>(_context_StateEvent); this._context.MessageEvent += new Handler <MessageEventArgs>(_context_MessageEvent); this._context.ChannelJoinEvent += new Handler <ChannelEventArgs>(_context_ChannelJoinEvent); this._context.ChannelUpdatedEvent += new Handler <ChannelEventArgs>(_context_ChannelUpdatedEvent); this._context.PrivateChannelInviteEvent += new Handler <PrivateChannelInviteEventArgs>(_context_PrivateChannelInviteEvent); this._context.PrivateChannelJoinEvent += new Handler <PrivateChannelEventArgs>(_context_PrivateChannelJoinEvent); this._context.PrivateChannelLeaveEvent += new Handler <PrivateChannelEventArgs>(_context_PrivateChannelLeaveEvent); this._context.CharacterJoinEvent += new Handler <PrivateChannelEventArgs>(_context_CharacterJoinEvent); this._context.CharacterLeaveEvent += new Handler <PrivateChannelEventArgs>(_context_CharacterLeaveEvent); this._context.FriendAddedEvent += new Handler <FriendEventArgs>(_context_FriendAddedEvent); this._context.FriendRemovedEvent += new Handler <FriendEventArgs>(_context_FriendRemovedEvent); this._context.FriendUpdatedEvent += new Handler <FriendEventArgs>(_context_FriendUpdatedEvent); this._tree.Nodes.Add(this._onlineFriends); this._tree.Nodes.Add(this._offlineFriends); this._tree.Nodes.Add(this._recentFriends); this._tree.Nodes.Add(this._channels); this._tree.Nodes.Add(this._privateChannels); this._tree.Nodes.Add(this._guests); this._contextMenu = new ChatContextMenu(this, context, this); this._outputBox.ContextMenu = this._contextMenu; this._outputBox.Context = context; this._outputBox.BackgroundColor = this.BackColor; this._outputBox.ForegroundColor = this.ForeColor; this._outputBox.ClickedEvent += new OutputControlHandler <OutputControlClickedEventArgs>(_outputBox_ClickedEvent); this._outputBox.Initialize(context.Configuration.OutputMode); // Update buttons to reflect the state of chat. switch (this._context.State) { case ContextState.Disconnected: this._connect.Visible = this._connect.Enabled = true; this._disconnect.Visible = this._disconnect.Enabled = false; break; default: this._connect.Visible = this._connect.Enabled = false; this._disconnect.Visible = this._disconnect.Enabled = true; break; } // A gentle welcome message this._context.Write(MessageClass.Internal, "Type /help to view all available commands"); // Enable commands this._context.Input.RegisterCommand(new UI.Commands.OpenCommand(this)); this._context.Input.RegisterCommand(new UI.Commands.StartCommand()); // Wait for load event this.Load += new EventHandler(ChatForm_Load); }