/// <summary> /// Display this view with the specified folder and options /// </summary> public override bool ViewFromFolder(FolderBase folder, Address address, FolderOptions flags) { if (_welcomePage == null) { FillCanvas(); } CIX.RefreshOnlineUsers(); FolderCollection.RefreshInterestingThreads(); return true; }
/// <summary> /// Display this view with the specified folder and options /// </summary> public virtual bool ViewFromFolder(FolderBase folder, Address address, FolderOptions flags) { return true; }
/// <summary> /// Walks the TreeView looking for the node which has the specified folder /// associated with it. /// </summary> /// <param name="folder">The folder to locate</param> /// <param name="nodes">The nodes to search</param> /// <returns>The TreeNode of the folder, or null if not found</returns> private static TreeNode NodeForFolder(FolderBase folder, IEnumerable nodes) { foreach (TreeNode node in nodes) { if (node.Tag == folder) { return node; } if (node.Nodes.Count > 0) { TreeNode subNode = NodeForFolder(folder, node.Nodes); if (subNode != null) { return subNode; } } } return null; }
/// <summary> /// Given a folder, return the name of the scope of this folder in a /// search. /// </summary> private static string ScopeFromFolder(FolderBase folder) { if (folder == null) { return _allForumsSearchButton; } if (folder is TopicFolder && ((TopicFolder)folder).Folder.IsRootFolder) { return _currentForumSearchButton; } return _currentTopicSearchButton; }
/// <summary> /// Display the selected view with the given folder, passing through the address and options. /// </summary> /// <param name="requestedView">The ID of the type of the view requested</param> /// <param name="folder">The folder to be displayed in the view</param> /// <param name="address">The address of the item within the folder to be selected</param> /// <param name="options">Options controlling the folder selection</param> /// <returns>True if the view was successfully selected, false otherwise</returns> private bool SelectView(AppView requestedView, FolderBase folder, Address address, FolderOptions options) { ViewBaseView newView = _allViews[requestedView]; if (newView != _currentView) { if (_currentView != null) { _currentView.Visible = false; frmSplitContainer.Panel2.Controls.Remove(_currentView); } if (newView != null) { frmSplitContainer.Panel2.Controls.Add(newView); _currentView = newView; SetSubviewSize(); newView.Visible = true; newView.Update(); } } ShowSearchBar(SearchBarVisibility.FastHide); if (folder != null) { string placeholder = folder.AllowsScopedSearch ? string.Format(Resources.SearchForTextIn, folder.Name) : Resources.Search; MainForm.SetSearchFieldPlaceholder(placeholder); SetTopicName(folder.FullName); } return (_currentView != null) && _currentView.ViewFromFolder(folder, address, options); }
/// <summary> /// Find the specified folder in the tree and if found, select it. If it is /// already selected, invoke the view with the specified address. /// </summary> /// <param name="folder">The folder to select</param> /// <param name="address">The address to pass to the view</param> private void SetSelection(FolderBase folder, Address address) { if (folder != null) { TreeNode node = NodeForFolder(folder, frmList.Nodes); if (node != null && node.IsSelected) { SelectViewForFolder(node, address, 0); } else { _lastAddress = address; SelectFolder(node, 0); } } }
/// <summary> /// Reload the list of topics under the given forum folder. /// </summary> private void ReloadForumTreeFromNode(FolderBase forumFolder) { TreeNode parent = FindFolder(_forumsTree.Nodes, forumFolder.Name); bool showAllTopics = Preferences.StandardPreferences.ShowAllTopics; if (parent != null) { TopicFolder folder = (TopicFolder) forumFolder; parent.Nodes.Clear(); foreach (Folder topic in folder.Folder.Children.OrderBy(nm => nm.Index)) { bool showArchivedTopic = showAllTopics || !topic.IsRecent && topic.Unread > 0; if (showArchivedTopic || topic.IsRecent) { TopicFolder topicFolder = new TopicFolder(topic) {Name = topic.Name}; TreeNode subNode = new TreeNode(topicFolder.Name) {Tag = topicFolder}; parent.Nodes.Add(subNode); } } } }
/// <summary> /// Search for the given text in the selected folder and update the UI to reflect /// the search scope. /// </summary> private void SearchForStringInFolder(FolderBase folder, string searchText) { string scopeName = ScopeFromFolder(folder); foreach (var roundButton in _searchBar.Controls.OfType<CRRoundButton>()) { roundButton.Active = (roundButton.Name == scopeName); } if (folder != null) { _currentView.FilterViewByString(searchText); } }
/// <summary> /// Display the specified topic folder in the thread list. /// </summary> /// <param name="folder">The folder whose topic is to be displayed</param> /// <param name="address"></param> /// <param name="options">Folder display flags</param> public override bool ViewFromFolder(FolderBase folder, Address address, FolderOptions options) { if (folder.ViewForFolder == AppView.AppViewTopic) { if ((_currentFolder != folder) || options.HasFlag(FolderOptions.ClearFilter)) { _currentFolder = folder; _currentFilterString = null; _isFiltering = false; _isTopicFolder = IsTopicFolder(); tsvMessages.SelectedIndices.Clear(); ShowMessage(null); if (FoldersTree.MainForm.RunEvent(EventID.FolderSelected, _isTopicFolder ? ((TopicFolder) folder).Folder : null)) { if (_isTopicFolder) { // Attempt to make topic switches cleaner by removing the old messages from display // when switching to a new topic will involve a delay caused by loading the messages // from the DB, sorting, etc. if (!((TopicFolder)_currentFolder).Folder.HasMessages && _messages != null && _messages.Count > 0) { _messages = new List<CIXMessage>(); InitialiseList(); RedrawAllItems(); } } SortConversations(); } UpdateFromFlags(); } // Load this topic from the server only if we're empty. if (_messages != null && _messages.Count == 0) { if (address != null && address.Scheme == "cix") { Int32.TryParse(address.Data, out _lastIndex); } folder.Refresh(); return false; } if (options.HasFlag(FolderOptions.ClearFilter)) { options &= ~FolderOptions.ClearFilter; _currentFilterString = null; _isFiltering = false; } if (address != null && address.Scheme == "cix") { int selectedID; Int32.TryParse(address.Data, out selectedID); if (!GoToMessage(selectedID)) { SetInitialSelection(); } if (address.Unread) { SelectedMessage.MarkUnread(); } } else if (options == 0) { SetInitialSelection(); } else { int row = SelectedRow; if (row < 0 || options.HasFlag(FolderOptions.Reset)) { row = -1; } else { CIXMessage selectedMessage = SelectedMessage; if (selectedMessage != null && selectedMessage.Unread) { selectedMessage.MarkRead(); } } if (!FirstUnreadAfterRow(row, options)) { return false; } } ActiveControl = tsvMessages; } return true; }
/// <summary> /// Return a list of all messages ordered by the current folder ordering. /// </summary> private IEnumerable<CIXMessage> MessagesByOrder(FolderBase folder) { CRSortOrder.SortOrder sortOrder = OrderForFolder(); if (CanGroupByConversation()) { TopicFolder topicFolder = (TopicFolder)folder; List<CIXMessage> messages; switch (sortOrder) { case CRSortOrder.SortOrder.Author: messages = SortOrderBase.Ascending ? topicFolder.Folder.Messages.Roots.OrderBy(rt => rt.Author).ToList() : topicFolder.Folder.Messages.Roots.OrderByDescending(rt => rt.Author).ToList(); break; case CRSortOrder.SortOrder.Subject: messages = SortOrderBase.Ascending ? topicFolder.Folder.Messages.Roots.OrderBy(rt => rt.Subject).ToList() : topicFolder.Folder.Messages.Roots.OrderByDescending(rt => rt.Subject).ToList(); break; case CRSortOrder.SortOrder.Date: messages = SortOrderBase.Ascending ? topicFolder.Folder.Messages.Roots.OrderBy(rt => rt.LatestDate).ToList() : topicFolder.Folder.Messages.Roots.OrderByDescending(rt => rt.LatestDate).ToList(); break; default: return null; } if (!_collapseConv) { for (int index = messages.Count - 1; index >= 0; index--) { CIXMessage message = messages[index]; messages.InsertRange(index + 1, topicFolder.Folder.Messages.Children(message)); } } return messages; } switch (sortOrder) { case CRSortOrder.SortOrder.Author: return SortOrderBase.Ascending ? folder.Items.OrderBy(rt => rt.Author).ToList() : folder.Items.OrderByDescending(rt => rt.Author).ToList(); case CRSortOrder.SortOrder.Subject: return SortOrderBase.Ascending ? folder.Items.OrderBy(rt => rt.Body.FirstUnquotedLine()).ToList() : folder.Items.OrderByDescending(rt => rt.Body.FirstUnquotedLine()).ToList(); case CRSortOrder.SortOrder.Date: return SortOrderBase.Ascending ? folder.Items.OrderBy(rt => rt.Date).ToList() : folder.Items.OrderByDescending(rt => rt.Date).ToList(); } return null; }
/// <summary> /// Display the directory for the specified CategoryFolder /// </summary> public override bool ViewFromFolder(FolderBase folder, Address address, FolderOptions options) { if (folder != _currentFolder) { _currentFolder = folder; SortConversations(); } // If an address is specified then it refers to a conversation ID that // needs to be selected. If it is not found, the first message is selected // instead. if (address != null && address.Scheme == "cixmailbox") { int selectedID; Int32.TryParse(address.Data, out selectedID); int selectedIndex; for (selectedIndex = 0; selectedIndex < _conversations.Count; ++selectedIndex) { InboxConversation conversation = _conversations[selectedIndex]; if (conversation.RemoteID == selectedID) break; } if (selectedIndex == _conversations.Count) { selectedIndex = 0; } SelectedRow = selectedIndex; if (address.Unread) { SelectedMessage.MarkUnread(); } return true; } // If options are specified then search for the next unread // in the list otherwise set the initial selection to something // useful. if (options == 0 && SelectedRow == -1) { SetInitialSelection(); } else { int row = inboxConversations.SearchRow; if (row < 0 || options.HasFlag(FolderOptions.Reset)) { row = 0; } else if (_conversations.Count > 0) { InboxConversation conversation = _conversations[row]; if (conversation.UnreadCount > 0) { conversation.MarkRead(); } } if (!FirstUnreadAfterRow(row, options)) { inboxConversations.SearchRow = 0; return false; } } FoldersTree.SetTopicName(_currentFolder.FullName); ActiveControl = inboxConversations; inboxConversations.Focus(); return true; }
/// <summary> /// Display the page for the specified forum. /// </summary> public override bool ViewFromFolder(FolderBase folder, Address address, FolderOptions flags) { if (folder is TopicFolder) { _currentFolder = folder as TopicFolder; _thisForum = CIX.DirectoryCollection.ForumByName(_currentFolder.Name); FoldersTree.SetTopicName(folder.Name); CIX.DirectoryCollection.RefreshForum(folder.Name); FillCanvas(); } return true; }
/// <summary> /// Display the directory for the specified CategoryFolder /// </summary> public override bool ViewFromFolder(FolderBase folder, Address address, FolderOptions flags) { CategoryFolder category = folder as CategoryFolder; if (category != null) { if (flags.HasFlag(FolderOptions.ClearFilter)) { _currentFilterString = null; } _currentCategory = category; _items = ItemsForView(); SortItems(); } return true; }