/// <summary> /// Process the specified Action ID. /// </summary> public override void Action(ActionID id) { switch (id) { case ActionID.JoinForum: { ListView.SelectedIndexCollection selectedItems = dvForumsList.SelectedIndices; if (selectedItems.Count == 1) { DirForum selectedForum = _items[selectedItems[0]]; string forumName = selectedForum.Name; JoinForum joinForum = new JoinForum(forumName); if (joinForum.ShowDialog() == DialogResult.OK) { FoldersTree.MainForm.Address = string.Format("cix:{0}", forumName); } } break; } case ActionID.Refresh: _currentCategory.Refresh(); break; } }
private void dvForumsList_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e) { DirForum forum = _items[e.ItemIndex]; e.Item = new ListViewItem(forum.Name); if (forum.IsClosed) { e.Item.ImageIndex = 0; } int popularityValue = Math.Min((forum.Recent + 100) / 100, 5); string popularity = string.Empty; switch (popularityValue) { case 1: popularity = "*"; break; case 2: popularity = "**"; break; case 3: popularity = "***"; break; case 4: popularity = "****"; break; case 5: popularity = "*****"; break; } e.Item.SubItems.Add(new ListViewItem.ListViewSubItem(e.Item, popularity)); e.Item.SubItems.Add(new ListViewItem.ListViewSubItem(e.Item, forum.Title)); e.Item.SubItems.Add(new ListViewItem.ListViewSubItem(e.Item, forum.Sub)); }
/// <summary> /// Callback after the forum details are refreshed from the server, whether or not they /// succeed. The e.Forum parameter is null if the forum doesn't exist. /// </summary> private void OnForumUpdated(object sender, DirForum forum) { if (forum != null) { _forum = forum; LoadList(); } }
public ManageForum(DirForum forum) { InitializeComponent(); _forum = forum; _general = new ManageForumGeneral(forum); _moderators = new ManageModerators(forum); _participants = new ManageParticipants(forum); }
private void OnParticipantsUpdated(object sender, DirForum forum) { Platform.UIThread(this, delegate { if (forum == _forum) { LoadList(); } }); }
private void OnParticipantsUpdated(object sender, DirForum forum) { Platform.UIThread(this, delegate { UserList = _forum.Participants(); AddList = new List <string>(_forum.AddedParticipants); RemoveList = new List <string>(_forum.RemovedParticipants); UpdateList(); }); }
/// <summary> /// Handle double-click to do a Join /// </summary> private void dvForumsList_DoubleClick(object sender, EventArgs e) { ListView.SelectedIndexCollection selectedItems = dvForumsList.SelectedIndices; if (selectedItems.Count == 1) { DirForum selectedForum = _items[selectedItems[0]]; string forumName = selectedForum.Name; FoldersTree.MainForm.Address = string.Format("cix:{0}", forumName); } }
private void OnModeratorsUpdated(object sender, DirForum forum) { Platform.UIThread(this, delegate { UserList = _forum.Moderators(); AddList = new List <string>(_forum.AddedModerators); RemoveList = new List <string>(_forum.RemovedModerators); UpdateList(); }); }
public Participants(MainForm mainForm, string forumName) { InitializeComponent(); CIX.DirectoryCollection.ForumUpdated += OnForumUpdated; CIX.DirectoryCollection.ParticipantsUpdated += OnParticipantsUpdated; _forum = CIX.DirectoryCollection.ForumByName(forumName); _mainForm = mainForm; _showMugshots = false; if (_forum == null) { CIX.DirectoryCollection.RefreshForum(forumName); } }
/// <summary> /// Display the page for the specified forum. /// </summary> public override bool ViewFromFolder(FolderBase folder, Address address, FolderOptions flags) { if (folder is TopicFolder) { _currentFolder = (TopicFolder)folder; _thisForum = CIX.DirectoryCollection.ForumByName(_currentFolder.Name); FoldersTree.SetTopicName(folder.Name); if (CIX.Online) { CIX.DirectoryCollection.RefreshForum(folder.Name); } FillCanvas(); } return(true); }
/// <summary> /// Event invoked when a forum's details are refreshed from the server. /// </summary> private void OnDirForumUpdated(object sender, DirForum forum) { if (forum == null || forum.Name != _currentFolder.Name) { return; } Platform.UIThread(this, delegate { _thisForum = forum; if (frmCanvas.Items.Count > 0) { ForumPage forumFolderItem = (ForumPage)frmCanvas.Items[0]; forumFolderItem.Forum = _thisForum; forumFolderItem.InvalidateItem(); } }); }
/// <summary> /// Update the list of moderators /// </summary> private void OnModeratorsUpdated(object sender, DirForum forum) { Platform.UIThread(this, delegate { if (forum == _thisForum && frmCanvas.Items.Count > 1) { ForumPage forumFolderItem = (ForumPage)frmCanvas.Items[0]; forumFolderItem.Forum = _thisForum; forumFolderItem.InvalidateItem(); ProfileGroupItem moderatorsItem = (ProfileGroupItem)frmCanvas.Items[1]; moderatorsItem.Items = new StringCollection(); if (_thisForum != null) { moderatorsItem.Items.AddRange(_thisForum.Moderators()); } moderatorsItem.InvalidateItem(); } }); }
private void RefreshForum(DirForum forum) { if (forum != null) { forumName.Text = forum.Name; forumImage.Image = CategoryFolder.IconForCategory(forum.Cat); forumTitle.Text = forum.Title; string descText = string.Format("<font face=\"Arial\" size=\"11px\"><div style=\"color:rgb({0});\">{1}</div></font>", UI.ToString(SystemColors.ControlText), forum.Desc); descText = descText.Replace("\n", "<br/>"); forumDescription.Text = descText; if (forum.IsClosed) { statusField.Text = Resources.JoinClosedForum; joinButton.Text = Resources.RequestAdmittance; } ResizeForm(); } }
/// <summary> /// Callback after the forum details are refreshed from the server, whether or not they /// succeed. The e.Forum parameter is null if the forum doesn't exist. /// </summary> private void OnForumUpdated(object sender, DirForum forum) { Platform.UIThread(this, delegate { _forum = forum; if (_forum != null) { RefreshForum(_forum); } else { forumName.Text = _forumName; forumImage.Image = CategoryFolder.IconForCategory("CIX"); statusField.Text = Resources.JoinNoSuchForum; cancelButton.Text = Resources.Close; joinButton.Visible = false; joinButton.Enabled = false; ResizeForm(); } }); }
private void JoinForum_Load(object sender, EventArgs e) { CIX.DirectoryCollection.ForumUpdated += OnForumUpdated; statusField.Text = Resources.JoinForumStatusText; _forum = CIX.DirectoryCollection.ForumByName(_forumName); if (_forum != null && !string.IsNullOrEmpty(_forum.Desc)) { RefreshForum(_forum); } else { if (_forum != null) { forumTitle.Text = _forum.Title; } forumName.Text = _forumName; forumImage.Image = CategoryFolder.IconForCategory("CIX"); CIX.DirectoryCollection.RefreshForum(_forumName); } ResizeForm(); }
/// <summary> /// Notify that the moderator list has been updated. /// </summary> /// <param name="dirForum">The forum for which the list was updated</param> internal void NotifyModeratorsUpdated(DirForum dirForum) { ModeratorsUpdated?.Invoke(this, dirForum); }
/// <summary> /// Notify that a forum details has been updated. /// </summary> /// <param name="dirForum">The forum for which the list was updated</param> internal void NotifyForumUpdated(DirForum dirForum) { ForumUpdated?.Invoke(this, dirForum); }
/// <summary> /// Refresh the details of the forum, including title and description. /// </summary> /// <param name="forumName">The forum name</param> public void RefreshForum(string forumName) { Thread t = new Thread(() => { DirForum forum = null; try { string encodedForumName = FolderCollection.EncodeForumName(forumName); LogFile.WriteLine("Updating directory for {0}", forumName); HttpWebRequest wrGeturl = APIRequest.Get("forums/" + encodedForumName + "/details", APIRequest.APIFormat.XML); Stream objStream = APIRequest.ReadResponse(wrGeturl); if (objStream != null) { using (XmlReader reader = XmlReader.Create(objStream)) { XmlSerializer serializer = new XmlSerializer(typeof(ForumDetails)); ForumDetails forumDetails = (ForumDetails)serializer.Deserialize(reader); bool isNewForum = false; forum = ForumByName(forumDetails.Name); if (forum == null) { forum = new DirForum(); isNewForum = true; } forum.Name = forumDetails.Name; forum.Title = forumDetails.Title; forum.Desc = forumDetails.Description; forum.Cat = forumDetails.Category; forum.Sub = forumDetails.SubCategory; forum.Recent = forumDetails.Recent; forum.Type = forumDetails.Type; lock (CIX.DBLock) { if (isNewForum) { CIX.DB.Insert(forum); _allForums[forum.ID] = forum; } else { CIX.DB.Update(forum); } } LogFile.WriteLine("Directory for {0} updated", forum.Name); } } } catch (Exception e) { CIX.ReportServerExceptions("DirectoryCollection.RefreshForum", e); } NotifyForumUpdated(forum); }); t.Start(); }
public ManageParticipants(DirForum forum) { InitializeComponent(); _forum = forum; }
public ManageModerators(DirForum forum) { InitializeComponent(); _forum = forum; }
/// <summary> /// Build the layout for a full message. /// </summary> private CanvasItemLayout BuildFullLayout(CanvasItemLayout newLayout, bool canExpandRoot) { bool isWithdrawn = Message.IsWithdrawn; if (Image != null) { newLayout.Add(new CanvasImage { ID = ActionID.AuthorImage, Image = Image, ImageWidth = 50, ImageHeight = 50, Margin = new Rectangle(0, 0, 7, 0) }); newLayout.AddNewColumn(); } if (canExpandRoot) { if (Message.IsRoot && Message.ChildCount > 0) { newLayout.Add(new CanvasImage { ID = ActionID.Expand, Image = Resources.CollapseArrow }); } newLayout.Add(new CanvasImage { ID = ActionID.Read, Image = ReadImageForMessage(), LineHeight = _headerLineHeight }); } newLayout.Add(new CanvasText { ID = ActionID.Profile, Text = Message.Author, Font = _headerFont, LineHeight = _headerLineHeight, ForeColour = ReadColourForMessage(), }); AddSeparatorItem(newLayout, _headerLineHeight); newLayout.Add(new CanvasText { Text = DateForMessage(), Font = _headerFont, LineHeight = _headerLineHeight, ForeColour = HeaderFooterColour(), }); newLayout.Add(new CanvasImage { ID = ActionID.Star, Image = Message.Starred ? Resources.ActiveStar : Resources.InactiveStar, LineHeight = _headerLineHeight }); if (Message.IsDraft) { newLayout.Add(new CanvasImage { ID = ActionID.Edit, Image = Resources.Draft, LineHeight = _headerLineHeight }); } newLayout.Add(new CanvasText { ID = ActionID.Link, Text = string.Format(" {0}", !Message.IsPseudo ? Message.RemoteID.ToString(CultureInfo.InvariantCulture) : Resources.DraftText), Font = _headerFont, ToolTipString = (ShowTooltips) ? Resources.LinkTooltip : null, LineHeight = _headerLineHeight, ForeColour = HeaderFooterColour(), }); if (!Message.IsRoot) { AddSeparatorItem(newLayout, _headerLineHeight); newLayout.Add(new CanvasText { ID = ActionID.Original, Text = string.Format(Resources.ReplyToMessage, Message.CommentID), Font = _headerFont, LineHeight = _headerLineHeight, ForeColour = HeaderFooterColour(), }); } newLayout.AddNewLine(); if (ShowFolder) { newLayout.Add(new CanvasImage { ID = ActionID.GoToSource, Image = Resources.Topic, LineHeight = _headerLineHeight }); Folder topic = Message.Topic; Folder forum = topic.ParentFolder; newLayout.Add(new CanvasText { Text = string.Format("{0}/{1}", forum.Name, topic.Name), Font = _font, ID = ActionID.GoToSource, LineHeight = _headerLineHeight, ForeColour = HeaderFooterColour(), }); newLayout.AddNewLine(); } string bodyText = Message.Body ?? string.Empty; newLayout.Add(new CanvasHTMLText { Text = bodyText, Font = _font, ExpandInlineImages = _view.ExpandInlineImages, Highlight = Highlight, DisableMarkup = _view.DisableMarkup, LineHeight = (Level == 0 || Selected) ? 0 : _compactHeight, BackColor = Color.Transparent, ForeColour = (Message.Ignored || isWithdrawn) ? HeaderFooterColour() : ForeColor, SpaceAfter = 5 }); newLayout.AddNewLine(); // Add an e-mail link to contact the author newLayout.Add(new CanvasImage { ID = ActionID.Email, Image = Resources.Mail, LineHeight = _footerLineHeight }); // The user can only comment on messages which have been synced with the server. // Otherwise for draft messages that are not pending, they can edit them as long // as the network is offline as otherwise the transition from draft to sync will // be too quick. Folder folder = Message.Topic; Folder forumFolder = folder.ParentFolder; DirForum dirforum = CIX.DirectoryCollection.ForumByName(forumFolder.Name); bool isModerator = dirforum != null && dirforum.IsModerator; bool canReply = !(folder.Flags.HasFlag(FolderFlags.OwnerCommentsOnly) && !Message.IsMine); if (folder.IsReadOnly && !isModerator) { canReply = false; } if (canReply) { if (!Message.IsPseudo) { AddSeparatorItem(newLayout, _footerLineHeight); newLayout.Add(new CanvasText { ID = ActionID.Reply, Text = Resources.Comment, Font = _footerFont, LineHeight = _footerLineHeight, ForeColour = HeaderFooterColour(), }); } else if (Message.IsDraft) { AddSeparatorItem(newLayout, _footerLineHeight); newLayout.Add(new CanvasText { ID = ActionID.Edit, Text = Resources.Edit, Font = _footerFont, LineHeight = _footerLineHeight, ForeColour = HeaderFooterColour(), }); } } // Ignore if (!Message.IsPseudo) { AddSeparatorItem(newLayout, _footerLineHeight); newLayout.Add(new CanvasText { ID = ActionID.Ignore, Text = Message.Ignored ? Resources.Unignore : Resources.Ignore, Font = _footerFont, LineHeight = _footerLineHeight, ForeColour = HeaderFooterColour(), }); AddSeparatorItem(newLayout, _footerLineHeight); newLayout.Add(new CanvasText { ID = ActionID.Priority, Text = Message.Priority ? Resources.Normal : Resources.Priority, Font = _footerFont, LineHeight = _footerLineHeight, ForeColour = HeaderFooterColour(), }); } // Allow withdraw if we own this message or we are a moderator // of the forum. if ((Message.IsMine || isModerator) && !Message.IsPseudo && !isWithdrawn) { AddSeparatorItem(newLayout, _footerLineHeight); newLayout.Add(new CanvasText { ID = ActionID.Withdraw, Text = Resources.Withdraw, Font = _footerFont, LineHeight = _footerLineHeight, ForeColour = HeaderFooterColour(), }); } // Allow delete if this is a local draft if (Message.IsPseudo) { AddSeparatorItem(newLayout, _footerLineHeight); newLayout.Add(new CanvasText { ID = ActionID.Delete, Text = Resources.Delete, Font = _footerFont, LineHeight = _footerLineHeight, ForeColour = HeaderFooterColour(), }); } return(newLayout); }
/// <summary> /// Notify that the participants list has been updated. /// </summary> /// <param name="dirForum">The forum for which the list was updated</param> internal void NotifyParticipantsUpdated(DirForum dirForum) { ParticipantsUpdated?.Invoke(this, dirForum); }
private void RefreshCategories() { foreach (string categoryName in _allCategories.Keys) { string safeCategoryName = categoryName.Replace("&", "+and+"); HttpWebRequest request = APIRequest.Get("directory/" + safeCategoryName + "/forums", APIRequest.APIFormat.XML); Stream objStream = APIRequest.ReadResponse(request); if (objStream != null) { using (XmlReader reader = XmlReader.Create(objStream)) { XmlSerializer serializer = new XmlSerializer(typeof(DirListings)); DirListings inboxSet = (DirListings)serializer.Deserialize(reader); int countOfNewForums = 0; lock (CIX.DBLock) { CIX.DB.RunInTransaction(() => { foreach (DirListing conv in inboxSet.Forums) { // Forums can appear in multiple categories, and forum names are unique so see if this // forum is already known. DirForum forum = ForumByName(conv.Forum) ?? new DirForum { Name = conv.Forum }; // Find the ID of the category and sub-category to which this belongs. // At this point, both will be in the AllCategories table. If not then something // has corrupted on the remote end. forum.Title = conv.Title; forum.Type = conv.Type; forum.Recent = conv.Recent; forum.Cat = conv.Cat; forum.Sub = conv.Sub; forum.DetailsPending = false; if (forum.ID == 0) { CIX.DB.Insert(forum); } else { CIX.DB.Update(forum); } _allForums[forum.ID] = forum; ++countOfNewForums; } }); } if (countOfNewForums > 0) { LogFile.WriteLine("{0} new forums added to category {1}", countOfNewForums, categoryName); if (DirectoryChanged != null) { DirectoryChanged(this, new DirectoryEventArgs { CategoryName = categoryName }); } } } } } }
public ManageForumGeneral(DirForum forum) { InitializeComponent(); _forum = forum; }