public static void Create(IrcSession session, ChatPage page, bool makeActive) { if (App.Settings.Current.Windows.States.Exists(page.Id) ? App.Settings.Current.Windows.States[page.Id].IsDetached : App.Settings.Current.Windows.DefaultQueryDetached) { var newWin = new ChannelWindow(page); if (!makeActive) { newWin.ShowActivated = false; newWin.WindowState = WindowState.Minimized; } newWin.Show(); if (makeActive) { newWin.Activate(); } else { Interop.WindowHelper.FlashWindow(newWin); } } else { var window = App.Current.MainWindow as ChatWindow; window.AddPage(page, makeActive); if (!window.IsActive) { Interop.WindowHelper.FlashWindow(window); } } }
public void AddPage(ChatPage page, bool switchToPage) { var item = new ChatTabItem(page); if (page.Type == ChatPageType.Server) { this.Items.Add(item); this.SubscribeEvents(page.Session); } else { for (int i = this.Items.Count - 1; i >= 0; --i) { if (this.Items[i].Page.Session == page.Session) { this.Items.Insert(i + 1, item); break; } } } if (switchToPage) { var oldItem = tabsChat.SelectedItem as TabItem; if (oldItem != null) { oldItem.IsSelected = false; } item.IsSelected = true; } }
public void RemovePage(ChatPage page) { if (page.Type == ChatPageType.Server) { this.UnsubscribeEvents(page.Session); } page.Dispose(); this.Items.Remove(this.Items.Where((i) => i.Page == page).FirstOrDefault()); }
public ChannelWindow(ChatPage page) { this.Page = page; this.DataContext = this; InitializeComponent(); page.SetValue(Grid.RowProperty, 1); page.SetValue(Grid.ColumnSpanProperty, 2); grdRoot.Children.Add((Control)page); page.Session.StateChanged += new EventHandler <EventArgs>(Session_StateChanged); page.Session.SelfParted += new EventHandler <IrcPartEventArgs>(Session_SelfParted); page.Session.SelfKicked += new EventHandler <IrcKickEventArgs>(Session_SelfKicked); }
public static void ClosePage(ChatPage page) { var window = Window.GetWindow(page); if (window is ChannelWindow) { window.Close(); } else { App.ChatWindow.RemovePage(page); } }
public ChannelWindow(ChatPage page) { this.Page = page; this.DataContext = this; InitializeComponent(); page.SetValue(Grid.RowProperty, 1); page.SetValue(Grid.ColumnSpanProperty, 2); grdRoot.Children.Add((Control)page); page.Session.StateChanged += new EventHandler<EventArgs>(Session_StateChanged); page.Session.SelfParted += new EventHandler<IrcPartEventArgs>(Session_SelfParted); page.Session.SelfKicked += new EventHandler<IrcKickEventArgs>(Session_SelfKicked); }
public void Attach(ChatPage page) { for (int i = this.Items.Count - 1; i >= 0; --i) { if (this.Items[i].Page.Session == page.Session) { this.Items.Insert(++i, new ChatTabItem(page)); tabsChat.SelectedIndex = i; break; } } this.SwitchToPage(page); }
public void SwitchToPage(ChatPage page) { var index = this.Items.Where((tab) => tab.Page == page).Select((t,i) => i).FirstOrDefault(); tabsChat.SelectedIndex = index; }
public ChatTabItem(ChatPage page) { _content = page; this.Content = page; }
public void SwitchToPage(ChatPage page) { var index = this.Items.Where((tab) => tab.Page == page).Select((t, i) => i).FirstOrDefault(); tabsChat.SelectedIndex = index; }