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> /// Build the layout for this item from the message. /// </summary> protected override CanvasItemLayout BuildLayout() { CanvasItemLayout newLayout = new CanvasItemLayout(this, DrawRectangle); if (Folder != null) { // Forum category icon, if one is present. At some point we should // replace this with an actual forum icon. Image categoryImage = null; if (Forum != null) { categoryImage = CategoryFolder.IconForCategory(Forum.Cat); } if (categoryImage == null) { categoryImage = Resources.Categories; } if (categoryImage != null) { newLayout.Add(new CanvasImage { ID = ActionID.None, Image = categoryImage, ImageWidth = 50, ImageHeight = 50 }); newLayout.AddNewColumn(); } // Forum name newLayout.Add(new CanvasText { ID = ActionID.None, Text = Folder.Name, Font = NameFont, LineHeight = NameFont.Height + 10, ForeColour = UI.System.ForegroundColour }); newLayout.AddNewLine(); // Forum title. if (Forum != null && !string.IsNullOrEmpty(Forum.Title)) { newLayout.Add(new CanvasHTMLText { ID = ActionID.None, Text = Forum.Title, Font = TitleFont, ForeColour = UI.System.ForegroundColour, SpaceAfter = 15 }); newLayout.AddNewLine(); } // Forum description. if (Forum != null && !string.IsNullOrEmpty(Forum.Desc)) { newLayout.Add(new CanvasHTMLText { ID = ActionID.None, HTMLText = Forum.Desc, Font = DescriptionFont, ForeColour = UI.System.ForegroundColour, SpaceAfter = 15 }); newLayout.AddNewLine(); } // If the Join is pending, say so. if (Forum != null && Forum.JoinPending) { newLayout.Add(new CanvasImage { Image = Resources.Warning, ImageWidth = 16, ImageHeight = 16 }); newLayout.Add(new CanvasText { ID = ActionID.None, Text = Resources.JoinPending, LineHeight = 16, Margin = new Rectangle(0, 0, 0, 15), Font = Font }); newLayout.AddNewLine(); } // If a Resign is pending, say so. if (Folder.ResignPending) { newLayout.Add(new CanvasImage { Image = Resources.Warning, ImageWidth = 16, ImageHeight = 16 }); newLayout.Add(new CanvasText { ID = ActionID.None, Text = Resources.ResignPending, LineHeight = 16, Margin = new Rectangle(0, 0, 0, 15), Font = Font, }); newLayout.AddNewLine(); } // If the Join failed, say so too. if (Folder.Flags.HasFlag(FolderFlags.JoinFailed)) { newLayout.Add(new CanvasImage { Image = Resources.Error1, ImageWidth = 16, ImageHeight = 16 }); newLayout.Add(new CanvasText { ID = ActionID.None, Text = Resources.JoinFailure, LineHeight = 16, Font = Font, Margin = new Rectangle(0, 0, 0, 15) }); newLayout.AddNewLine(); } // Resign/Join button // Don't display if the forum doesn't permit the user to resign it. if (Folder.CanResign) { if (Folder.IsResigned || Folder.Flags.HasFlag(FolderFlags.JoinFailed) || Folder.ResignPending) { newLayout.Add(new CanvasButton { ID = ActionID.JoinForum, Text = Resources.JoinForum, Font = DescriptionFont, ForeColour = UI.System.ForegroundColour, SpaceAfter = 15 }); } else { newLayout.Add(new CanvasButton { ID = ActionID.ResignForum, Text = Resources.ResignForum, Font = DescriptionFont, ForeColour = UI.System.ForegroundColour, SpaceAfter = 15 }); } } // Delete button // Offer the option to delete the folder if we're not joined to it newLayout.Add(new CanvasButton { ID = ActionID.Delete, Text = Resources.DeleteFolder, Font = DescriptionFont, ForeColour = UI.System.ForegroundColour, SpaceAfter = 15 }); // Add Participants button newLayout.Add(new CanvasButton { ID = ActionID.Participants, Text = Resources.Participants, Font = DescriptionFont, ForeColour = UI.System.ForegroundColour, SpaceAfter = 15 }); // Refresh button newLayout.Add(new CanvasButton { ID = ActionID.Refresh, Text = Resources.RefreshText, Font = DescriptionFont, ForeColour = UI.System.ForegroundColour, SpaceAfter = 15 }); // Manage Forum button if (Forum != null && Forum.IsModerator) { newLayout.Add(new CanvasButton { ID = ActionID.ManageForum, Text = Resources.ManageForum, Font = DescriptionFont, ForeColour = UI.System.ForegroundColour, SpaceAfter = 15 }); } } return(newLayout); }