public ChatControl(ChatContext context) { _history = new LinkedList<string>(); this.Nicknames = new ObservableCollection<NicknameItem>(); this.Context = context; this.Header = context.Target == null ? "Server" : context.Target.ToString(); InitializeComponent(); this.SubscribeEvents(); if (!this.IsServer) { _logFile = App.OpenLogFile(context.Key); while (_logFile.Buffer.Count > 0) { var cl = _logFile.Buffer.Dequeue(); cl.Marker = _logFile.Buffer.Count == 0 ? ChatMarker.OldMarker : ChatMarker.None; boxOutput.AppendLine(cl); } } var state = App.Settings.Current.Windows.States[context.Key]; if (this.IsChannel) { this.Write("Join", string.Format("Now talking on {0}", this.Target.Name)); this.Session.AddHandler(new IrcCodeHandler(IrcCode.ChannelModes, true, (msg) => { if (msg.Parameters.Count == 3 && this.Target.Equals(new IrcTarget(msg.Parameters[1]))) { this.Invoke(() => { _channelModes = msg.Parameters[2].ToCharArray().Where((c) => c != '+').ToArray(); this.SetTitle(); }); return true; } return false; })); this.Session.Mode(this.Target); splitter.IsEnabled = true; colNickList.Width = new GridLength(state.NickListWidth); } else if (this.IsNickname) { _prefix = this.Target.Name; } boxOutput.ColumnWidth = state.ColumnWidth; this.Loaded += new RoutedEventHandler(ChatControl_Loaded); this.Unloaded += new RoutedEventHandler(ChatControl_Unloaded); this.PrepareContextMenus(); boxOutput.ContextMenu = this.GetDefaultContextMenu(); }
private void Session_Joined(object sender, IrcChannelEventArgs e) { if (e.IsSelf) { this.Invoke(() => { var context = new ChatContext((IrcSession)sender, e.Channel); var state = App.Settings.Current.Windows.States[context.Key]; if (state.IsDetached) { var window = new ChannelWindow(new ChatControl(context)); window.Show(); } else { this.AddPage(context, true); } }); } }