private void BuildDevelopersPage() { var sb = new StringBuilder(); var columnsCount = 0; var userIds = new[] { 12284, 2962, 15309, 5743, 5161, 28760, 19717, 73, 3242, 6921, 343, 2668, 7107, 1938, 3655, 3655, 10596, 16874, 1, 20712, 21120, 4964, 8546, 11709, 5623, 9088, 33647, 61389, 44901, 507, 52960 }; using (var db = _provider.CreateDBContext()) { var users = db .Users(u => userIds.Contains(u.ID)) .OrderBy(u => u.Name) .Select( u => new { u.ID, Name = u.DisplayName(), u.HomePage, u.UserClass }); foreach (var user in users) { columnsCount++; var userHomePage = string.Format( user.HomePage.StartsWith("http://") ? "{0}'>{1}" : "http://{0}'>{1}", user.HomePage, user.HomePage); sb.AppendFormat( _devTableRow, columnsCount % 2 == 0 ? "#F4FFF4" : "#E4FFF4", user.ID, user.Name, JanusFormatMessage.FormatUserClass(user.UserClass, true), "", userHomePage); } } _webBrowser.DocumentText = string.Format( GetTemplate(), SR.About.DevelopersList, string.Format(_tableHeader, SR.UserInfoName, SR.UserInfoStatus, "e-mail", SR.UserInfoHomePage), sb); }
public string FormatUserClass(UserClass userClass) { var uc = JanusFormatMessage .FormatUserClass(userClass, true); return(uc.Length != 0 ? " " + uc : string.Empty); }
private string FormatRateSummary( int mid, int rating, int smiles, int agrees, int disagrees) { // Rate // rate calc for headers and rate frame var text = JanusFormatMessage.FormatRates( rating, smiles, agrees, disagrees); if (text.Length == 0) { return(string.Empty); } var styleImageManager = _serviceProvider.GetRequiredService <IStyleImageManager>(); return(string.Format(_templateHeaderItemAnchorBold, styleImageManager.GetImageUri("RateGroup", StyleImageType.ConstSize), string.Format(_templateAlt, SR.TGColumnRate, text), text, FormatUri(JanusProtocolResourceType.MessageRate, mid.ToString()))); }
private string FormatSubject() { var text = HttpUtility.HtmlEncode(_subjectTextBox.Text); return(string.Format(_templateHeaderItem, JanusFormatMessage.GetMessageImagePath(_serviceManager, true, false, false), string.Format(_templateAlt, SR.TGColumnSubject, text), text)); }
public string GetMessageImagePath( bool isRead, bool isMarked, bool isArticle, int violationPenaltyType, string violationReason) { return(JanusFormatMessage .GetMessageImagePath(_serviceProvider, isRead, isMarked, isArticle, (PenaltyType)violationPenaltyType, violationReason)); }
private string FormatForum( string forumName, string forumDescription) { return (string.Format( _templateHeaderItem, JanusFormatMessage.GetForumImagePath(_serviceProvider, false), string.Empty, FormatForumName(forumName, forumDescription, false))); }
private string FormatDate(DateTime dt) { var isOutdate = DateTime.Now.AddDays(-Config.Instance.ForumDisplayConfig.DaysToOutdate) > dt && Config.Instance.ForumDisplayConfig.DaysToOutdate != 0; var text = dt.ToString(Config.Instance.ForumDisplayConfig.DateFormat); return (string.Format( _templateHeaderItemForDate, JanusFormatMessage.GetWeekDayImagePath( _serviceProvider, Convert.ToInt32(dt.DayOfWeek), isOutdate), string.Format(_templateAlt, SR.TGColumnDate, text), text, isOutdate ? _selectorOutdate : _selectorNormaldate)); }
private string FormatAuthor( int userId, UserClass userClass, string showName, bool bold) { // From : uri, icon, alt, text // Аноним - это когда uid == 0 и usernick == string.Empty. // Именованный аноним с ГДН - это когда uid == 0, но имя (usernick) отлично от string.Empty. // Лучше бы дали именованным анонимам с ГДН отдельный класс... string template; if (userId == 0) { template = bold ? _templateHeaderItemBold : _templateHeaderItem; if (showName.Length == 0) { showName = SR.Forum.UserNickAnonymous; } } else { template = bold ? _templateHeaderItemAnchorBold : _templateHeaderItemAnchor; } // добавим класс пользователя template += " {4}"; var userInfoUri = FormatUri( JanusProtocolResourceType.UserInfo, userId.ToString()); return(string.Format(template, JanusFormatMessage.GetUserImagePath(_serviceProvider, userClass), string.Format(_templateAlt, SR.TGColumnAuthor, showName), showName, userInfoUri, JanusFormatMessage.FormatUserClass(userClass, true))); }
private void ModeratorialsList_RetrieveVirtualItem( object sender, RetrieveVirtualItemEventArgs e) { var mod = _moderatorials[e.ItemIndex]; e.Item = new ListViewItem( new[] { mod.UserName, mod.ActionDesc, JanusFormatMessage.GetDateString(mod.Create) }) { BackColor = _lastModerated == null || mod.Create > _lastModerated ? SystemColors.Window : SystemColors.ControlDark, ImageIndex = GetModImageIndex(mod.ForumId, _forumID) }; }
private string FormatSubject( int messageId, string subject, bool isRead, bool isMarked, int?articleId, bool anchor) { var text = HttpUtility.HtmlEncode(subject); return (string.Format( anchor ? _templateHeaderItemAnchor : _templateHeaderItem, JanusFormatMessage.GetMessageImagePath( _serviceProvider, isRead, isMarked, articleId > 0), string.Format(_templateAlt, SR.TGColumnSubject, text), text, FormatUri(JanusProtocolResourceType.Message, messageId.ToString()))); }
private string FormatRate( MessageRates rateType, int multiplier, bool forumInTop) { // Считается, что оценка обязательно есть, и она корректна var rt = string.Empty; if ((int)rateType > 0) { rt = (multiplier * (int)rateType).ToString(); if (forumInTop) // учёт специфичных форумов { rt = string.Format(@"<b>{0}</b>", rt); } rt += @" x "; } // 0 - rate text, 1 - path to rate icon return(string.Format(_templateRatePart, rt, JanusFormatMessage.GetRateImagePath(_serviceProvider, rateType))); }
/// <summary>Количество помеченных (очками) в дочерних сообщениях.</summary> public string GetFormattedRating() { return(JanusFormatMessage.FormatRates(Rating, Smiles, Agrees, Disagrees)); }
public string GetRateImagePath(MessageRates rate) { return(JanusFormatMessage.GetRateImagePath(_serviceProvider, rate)); }
private void CustomInitializeComponent() { // init data _forumsComboBox.InitForumsComboBox(_messageInfo.ForumId); if (_formMode == MessageFormMode.Add || _formMode == MessageFormMode.Reply) { if (_formMode == MessageFormMode.Add) { _subjectTextBox.Text = _messageInfo.Subject; ActiveControl = _subjectTextBox; } if (_formMode == MessageFormMode.Reply) { _forumsComboBox.Enabled = false; _quoteAnalyzer = new QuoteAnalyzer(_messageInfo.Message); _subjectTextBox.Text = JanusFormatMessage.ReSubj(_messageInfo.Subject); ActiveControl = _messageEditor; } _messageEditor.Text = _messageInfo.Message; } if (_formMode == MessageFormMode.Edit) { _subjectTextBox.Text = _messageInfo.Subject; _messageEditor.Text = _messageInfo.Message; ActiveControl = _messageEditor; } _fromUserLabel.Text = Config.Instance.Login; Bounds = Config.Instance.MessageFormBounds.Bounds; if (Config.Instance.MessageFormBounds.Maximized) { WindowState = FormWindowState.Maximized; } // style var font = new Font("Courier New", 9F); _messageEditor.TextStyles.AddRange(new[] { new TextStyle("Default", 0, font, Color.Black, Color.White, false, CaseMode.Mixed, true, false, PredefinedStyle.None), new TextStyle("Quoted text level 1", 1, font, Color.FromArgb(0, 92, 0), Color.White, false, CaseMode.Mixed, true, false, PredefinedStyle.None), new TextStyle("Quotes prefix", 2, font, Color.FromArgb(0, 64, 96), Color.White, false, CaseMode.Mixed, true, false, PredefinedStyle.None), new TextStyle("Known tags", 3, font, Color.DarkGreen, Color.LightGray, false, CaseMode.Mixed, true, false, PredefinedStyle.None), new TextStyle("Smiles", 4, font, Color.DarkBlue, Color.LightGray, false, CaseMode.Mixed, true, false, PredefinedStyle.None), new TextStyle("Unknown tag", 5, font, Color.DarkRed, Color.LightGray, false, CaseMode.Mixed, true, false, PredefinedStyle.None), new TextStyle("TagContent", 6, font, Color.Black, Color.LemonChiffon, true, CaseMode.Mixed, true, false, PredefinedStyle.None), new TextStyle("PredefinedBraceLight", 34, font, Color.Blue, Color.White, false, CaseMode.Mixed, true, false, PredefinedStyle.BraceLight), new TextStyle("PredefinedBraceBad", 35, font, Color.Red, Color.White, false, CaseMode.Mixed, true, false, PredefinedStyle.BraceBad), new TextStyle("PredefinedDefault", 32, font, Color.Black, Color.White, false, CaseMode.Mixed, true, false, PredefinedStyle.Default), new TextStyle("Quoted text level 2", 10, font, Color.Green, Color.White, false, CaseMode.Mixed, true, false, PredefinedStyle.None), new TextStyle("Quoted text level 3", 11, font, Color.FromArgb(0, 160, 0), Color.White, false, CaseMode.Mixed, true, false, PredefinedStyle.None) }); foreach (var style in _messageEditor.TextStyles.Cast <TextStyle>()) { _messageEditor.SetStyleCharset(style.Number, ScintillaCharset.Russian); } _subjectTextBox.Modified = false; _messageEditor.ClearUndoBuffer(); // Savepoint also set by this call OnIsModifiedChanged(); _messageEditor.MultipleSelection = true; _messageEditor.AdditionalSelectionTyping = true; StyleConfig.StyleChange += OnStyleChanged; UpdateStyle(); }
public ModeratingForm([NotNull] IServiceProvider provider, int msgId) { if (provider == null) { throw new ArgumentNullException("provider"); } var styleMgr = provider.GetRequiredService <IStyleImageManager>(); _mdrExtractImage = styleMgr.AppendImage( @"MessageViewer\MdrExtract", StyleImageType.ConstSize, _images); _mdrMoveImage = styleMgr.AppendImage( @"MessageViewer\MdrMove", StyleImageType.ConstSize, _images); _mdrDelImage = styleMgr.AppendImage( "del", StyleImageType.Small, _images); _mdrLeaveImage = styleMgr.AppendImage( @"MessageViewer\MdrLeave", StyleImageType.ConstSize, _images); _mdrCloseTopicImage = styleMgr.AppendImage( @"MessageViewer\MdrCloseTopic", StyleImageType.ConstSize, _images); _mdrOpenTopicImage = styleMgr.AppendImage( @"MessageViewer\MdrOpenTopic", StyleImageType.ConstSize, _images); //_msg = DatabaseManager.GetMessagesList(new[] { msgId })[0]; InitializeComponent(); _moderatorialsList.SmallImageList = _images; using (var db = provider.CreateDBContext()) { var msg = db.Message(msgId, m => new { m.ForumID, m.LastModerated }); _forumID = msg.ForumID; _lastModerated = msg.LastModerated; _moderatorials = db .Moderatorials() .Where(m => m.MessageID == msgId) .OrderByDescending(m => m.Create) .Select( m => new ModInfo( m.ForumID, JanusFormatMessage.GetModeratorialActionName( m.ForumID, _forumID, m.ServerForum.Name, m.ServerForum.Descript), m.User.DisplayName(), m.Create)) .ToArray(); } _moderatorialsList.VirtualListSize = _moderatorials.Length; _userCol.Width = _actionCol.Width = _createCol.Width = -1; }
public static XmlMessage BuildMessage( IServiceProvider provider, IJanusDatabaseManager dbMgr, int mid, [CanBeNull] Func <string, string> sourceFormatter) { using (var db = dbMgr.CreateDBContext()) { var msg = db .Message( mid, m => new { m.UserID, m.UserClass, UserNick = m.UserNick.ToUserDisplayName(m.UserClass), m.Date, m.IsRead, m.IsMarked, m.ArticleId, m.Name, m.Subject, m.Message, m.User.Origin, Rating = m.Rating(), Smiles = m.SmileCount(), Agrees = m.AgreeCount(), Disagrees = m.DisagreeCount(), PenaltyType = m.Violation != null ? m.Violation.PenaltyType : 0, Reason = m.Violation != null ? m.Violation.Reason : null, ViolationDate = m.Violation != null ? (DateTime?)m.Violation.Create : null }); var body = sourceFormatter != null?sourceFormatter(msg.Message) : msg.Message; var formatter = provider.GetFormatter(); var dateFormat = Config.Instance.ForumDisplayConfig.DateFormat; var xmlMessage = new XmlMessage { FormattingOptions = { ShowHeader = Config.Instance.ForumDisplayConfig.Envelope.ShowHeader, ShowRateFrame = Config.Instance.ForumDisplayConfig.Envelope.ShowRateFrame }, ID = mid, Author = { ID = msg.UserID, UserClass = (int)msg.UserClass, DisplayName = msg.UserNick }, Date = { Value = msg.Date.ToString(dateFormat), IsOutdate = DateTime.Now.AddDays(-Config.Instance.ForumDisplayConfig.DaysToOutdate) > msg.Date && Config.Instance.ForumDisplayConfig.DaysToOutdate != 0, DayOfWeek = Convert.ToInt32(msg.Date.DayOfWeek) }, IsUnread = !msg.IsRead, IsMarked = msg.IsMarked, ArticleID = msg.ArticleId.GetValueOrDefault(), Name = msg.Name, Subject = msg.Subject, Content = formatter.Format(body, true), Origin = formatter.Format(msg.Origin, true), Rate = { Summary = JanusFormatMessage.FormatRates(msg.Rating, msg.Smiles, msg.Agrees, msg.Disagrees) }, ViolationPenaltyType = (int)msg.PenaltyType, ViolationReason = msg.Reason.IsNullOrEmpty() ? null : msg.ViolationDate.GetValueOrDefault().ToString(dateFormat) + " " + msg.Reason }; if (Config.Instance.ForumDisplayConfig.Envelope.ShowRateFrame) { var rateList = db .Rates(r => r.MessageID == mid) .OrderByDescending(r => r.Date) .Select( r => new { r.RateType, r.Multiplier, r.Message.ServerForum.InTop, r.UserID, r.User.UserClass, DisplayName = r.User.DisplayName() }); foreach (var rate in rateList) { var rateItem = new XmlMessage.MessageRateItem(); var rateString = string.Empty; var intType = (int)rate.RateType; if (intType > 0) { rateString = (rate.Multiplier * intType).ToString(); } rateItem.Value = rateString; rateItem.ForumInTop = rate.InTop; rateItem.Type = (int)rate.RateType; rateItem.Author.ID = rate.UserID; rateItem.Author.UserClass = (int)rate.UserClass; rateItem.Author.DisplayName = rate.DisplayName; xmlMessage.Rate.List.Add(rateItem); } } return(xmlMessage); } }
//private const string _templatePrefixImage = "<img>"; public string GetUserInfoText(int uid) { using (var db = _dbManager.CreateDBContext()) { var user = db .Users(u => u.ID == uid) .Select( u => new { u.ID, u.UserClass, u.Origin, u.Name, u.Nick, u.RealName, u.WhereFrom, u.Spec, u.HomePage }) .FirstOrDefault(); var parameter = Convert.ToString(uid); if (user == null) { return (string.Format( GetStringTemplate(_templateUserInfoNotFound), FormatExternalUri(JanusProtocolResourceType.UserInfo, parameter), FormatUri(JanusProtocolResourceType.UserRating, parameter), FormatUri(JanusProtocolResourceType.UserOutrating, parameter), FormatUri(JanusProtocolResourceType.UserMessages, parameter))); } var origin = _serviceProvider.GetFormatter().Format(user.Origin, true); if (origin.Length != 0) { origin = string.Format(_templateOrigin, origin); } var firstInfo = string.Empty; var lastInfo = string.Empty; var msgs = db .Messages(m => m.UserID == uid) .Select( m => new { m.ID, m.Date, m.Subject, m.IsRead, m.IsMarked, m.ArticleId }); var msgFirst = msgs .OrderBy(m => m.Date) .FirstOrDefault(); if (msgFirst != null) { firstInfo = string.Format( _templateMessageInfo, FormatDate(msgFirst.Date), FormatSubject( msgFirst.ID, msgFirst.Subject, msgFirst.IsRead, msgFirst.IsMarked, msgFirst.ArticleId, true)); var msgLast = msgs .OrderByDescending(m => m.Date) .First(); lastInfo = string.Format( _templateMessageInfo, FormatDate(msgLast.Date), FormatSubject( msgLast.ID, msgLast.Subject, msgLast.IsRead, msgLast.IsMarked, msgLast.ArticleId, true)); } return (string.Format( GetStringTemplate(_templateUserInfo), FormatAuthor( user.ID, user.UserClass, JanusFormatMessage.GetUserDisplayName(user.Nick, user.RealName, user.Name), true), user.Name, user.Nick, user.RealName, user.WhereFrom, user.Spec, _serviceProvider.GetFormatter().Format(user.HomePage, true), origin, FormatExternalUri(JanusProtocolResourceType.UserInfo, parameter), FormatUri(JanusProtocolResourceType.UserRating, parameter), FormatUri(JanusProtocolResourceType.UserOutrating, parameter), FormatUri(JanusProtocolResourceType.UserMessages, parameter), FormatUri(JanusProtocolResourceType.UserMessagesStat, parameter), firstInfo, lastInfo, JanusFormatMessage.GetResourceImagePath(_serviceProvider, JanusProtocolResourceType.UserInfo), JanusFormatMessage.GetResourceImagePath(_serviceProvider, JanusProtocolResourceType.UserRating), JanusFormatMessage.GetResourceImagePath(_serviceProvider, JanusProtocolResourceType.UserOutrating), JanusFormatMessage.GetResourceImagePath(_serviceProvider, JanusProtocolResourceType.UserMessages), JanusFormatMessage.GetResourceImagePath(_serviceProvider, JanusProtocolResourceType.UserMessagesStat))); } }
public static string GetTeamList(IServiceProvider provider) { var usersCount = 0; // счетчик пользователей таблицы по форумам var forumDescript = string.Empty; var forumName = string.Empty; var sb = new StringBuilder(); // конечный результат таблицы по форумам var sbSubtotal = new StringBuilder(); // Строка таблицы по форумам var colCount = 0; using (var db = provider.CreateDBContext()) { var users = db .Messages( m => m.UserClass == UserClass.Admin || m.UserClass == UserClass.Moderator || m.UserClass == UserClass.Team) .OrderBy(u => u.ID) .Select( m => new { ForumName = m.ServerForum.Name, ForumDesc = m.ServerForum.Descript, m.UserClass, m.UserID, UserName = m.User.DisplayName() }); foreach (var user in users) { if (forumName != user.ForumName) { if (!string.IsNullOrEmpty(forumName)) { colCount++; sb.AppendFormat(_tlTableRow, (colCount % 2 == 0 ? _evenColor : _oddColor), forumDescript, forumName, sbSubtotal, usersCount); sbSubtotal.Length = 0; usersCount = 0; } forumDescript = user.ForumDesc; forumName = user.ForumName; } sbSubtotal.AppendFormat( _tlUsersList, JanusFormatMessage.GetUserImagePath(provider, user.UserClass), user.UserID, user.UserName, JanusFormatMessage.FormatUserClass(user.UserClass, true)); usersCount++; } } return(String.Format(GetStringTemplate("StandartPage.html"), SR.ForumTeamList, "80%", SR.ForumTeam, SR.ForumTeamList, sb, Path.Combine(ApplicationManager.HomeDirectoryPath, "styles/"))); }
/// <summary> /// Преобразовывает userclass число в строку с подсветкой или без. /// </summary> private static string FormatUserClass(UserClass userClass, bool isHtml) { return(JanusFormatMessage.FormatUserClass(userClass, isHtml)); }
public string GetWeekDayImagePath(int weekDay, bool isOutdated) { return(JanusFormatMessage .GetWeekDayImagePath(_serviceProvider, weekDay, isOutdated)); }
protected string GetFormattedRatingForReplies() { return(JanusFormatMessage.FormatRates(RepliesRate, RepliesSmiles, RepliesAgree, RepliesDisagree)); }
public virtual void GetData(NodeInfo nodeInfo, CellInfo[] cellData) { var cnfg = Config.Instance; var style = cnfg.StyleConfig; nodeInfo.Highlight = IsUnread; cellData[_idColumn].Text = Config.Instance.ForumDisplayConfig.ShowMessageId ? ID.ToString() : ""; if (ReadReplies) { cellData[_idColumn].CellImageType = CellImageType.Image; cellData[_idColumn].Image = _imgManager.GetAutoReadImage(MessageFlagExistence.OnMessage); } cellData[_markColumn].CellImageType = CellImageType.Image; cellData[_markColumn].Image = _imgManager.GetMarkImage( IsMarked ? MessageFlagExistence.OnMessage : RepliesMarked > 0 ? MessageFlagExistence.OnChildren : MessageFlagExistence.None); cellData[_subjColumn].Text = DisplaySubject; if (UserID == cnfg.SelfId) { nodeInfo.ForeColor = style.SelfMessageColor; } else if (Parent != null && Parent.UserID == cnfg.SelfId) { nodeInfo.ForeColor = style.RepliesToSelfMessageColor; } else if (_favManager.IsFavorite(ID)) { nodeInfo.ForeColor = style.FavoriteMessageColor; } else { nodeInfo.ForeColor = UserID == -1 ? style.MissingTopicColor : style.MessageColor; } cellData[_subjColumn].CellImageType = CellImageType.Image; cellData[_subjColumn].Image = _imgManager .GetMessageImage( ArticleId > 0 ? MessageType.Article : MessageType.Ordinal, IsUnread ? MessageFlagExistence.OnMessage : RepliesUnread > 0 ? MessageFlagExistence.OnChildren : MessageFlagExistence.None, RepliesToMeUnread > 0, Moderatorials > 0 ? MessageFlagExistence.OnMessage : RepliesModeratorials > 0 ? MessageFlagExistence.OnChildren : MessageFlagExistence.None, Closed); cellData[_userNameColumn].Text = UserNick; cellData[_userNameColumn].CellImageType = CellImageType.Image; cellData[_userNameColumn].Image = _imgManager.GetUserImage((UserClass)UserClass); var corrReplUnread = IsUnread ? RepliesUnread - 1 : RepliesUnread; var replUnreadStr = corrReplUnread > 0 ? string.Format("({0})", corrReplUnread) : string.Empty; var repliesStr = RepliesCount > 0 ? RepliesCount.ToString() : string.Empty; cellData[_replCountColumn].Text = repliesStr + replUnreadStr; cellData[_rateThisColumn].Text = GetFormattedRating(); cellData[_dateColumn].Text = JanusFormatMessage.GetDateString(Date); cellData[_dateColumn].CellImageType = CellImageType.Image; cellData[_dateColumn].Image = _imgManager.GetMessageDateImage(Date); GetDataExt(cellData); }
public string GetUserImagePath(UserClass userClass) { return(JanusFormatMessage .GetUserImagePath(_serviceProvider, userClass)); }