Exemplo n.º 1
0
 private string FormatBigRateItem(
     MessageRates rateType,
     int rateMultiplier,
     DateTime rateDate,
     string forumName,
     string forumDesc,
     bool forumInTop,
     int msgID,
     string msgSubj,
     bool msgIsRead,
     bool msgIsMarked,
     int?msgArticleID,
     int userID,
     UserClass userClass,
     string userDisplayName,
     bool even)
 {
     return(string.Format(_templateBigRateItem,
                          FormatForum(forumName, forumDesc),
                          FormatSubject(
                              msgID,
                              msgSubj,
                              msgIsRead,
                              msgIsMarked,
                              msgArticleID,
                              true),
                          FormatRate(rateType, rateMultiplier, forumInTop),
                          FormatAuthor(
                              userID,
                              userClass,
                              userDisplayName,
                              false),
                          FormatDate(rateDate),
                          even ? _selectorEven : _selectorUneven));
 }
Exemplo n.º 2
0
		public void Add(int mid, MessageRates rate)
		{
			using (var db = _provider.CreateDBContext())
			{
				if (rate == MessageRates.DeleteLocally)
					db
						.OutboxRates(r => r.MessageID == mid)
						.Delete();
				else
				{
					var id =
						db
							.OutboxRates(r => r.RateType == rate && r.MessageID == mid)
							.Select(r => (int?)r.ID)
							.SingleOrDefault();

					if (id == null)
						db
							.OutboxRates()
								.Value(_ => _.RateType,  rate)
								.Value(_ => _.MessageID, mid)
							.Insert();
					else
						db
							.OutboxRates(r => r.ID == id)
							.Set(_ => _.RateType, _ => rate)
							.Update();
				}
			}

			Refresh();
		}
Exemplo n.º 3
0
        private void CustomInitializeComponents(MessageRates rate)
        {
            _lblInfo.Text = SR.Forum.RateForm.AddRate;

            var styler = _provider.GetRequiredService <IStyleImageManager>();

            switch (rate)
            {
            case MessageRates.Plus1:
                _pbxRateImage.Image = styler.GetImage(
                    "MessageViewer\\RatePlus1", StyleImageType.Small);
                break;

            case MessageRates.Agree:
                _pbxRateImage.Image = styler.GetImage(
                    "MessageViewer\\RateAgree", StyleImageType.Small);
                break;

            case MessageRates.DisAgree:
                _pbxRateImage.Image = styler.GetImage(
                    "MessageViewer\\RateDisagree", StyleImageType.Small);
                break;

            case MessageRates.Rate1:
                _pbxRateImage.Image = styler.GetImage(
                    "MessageViewer\\Rate1", StyleImageType.Small);
                break;

            case MessageRates.Rate2:
                _pbxRateImage.Image = styler.GetImage(
                    "MessageViewer\\Rate2", StyleImageType.Small);
                break;

            case MessageRates.Rate3:
                _pbxRateImage.Image = styler.GetImage(
                    "MessageViewer\\Rate3", StyleImageType.Small);
                break;

            case MessageRates.Smile:
                _pbxRateImage.Image = styler.GetImage(
                    "MessageViewer\\RateSmile", StyleImageType.Small);
                break;

            case MessageRates.DeleteRate:
                _pbxRateImage.Image = styler.GetImage(
                    "MessageViewer\\RateX", StyleImageType.Small);
                _lblInfo.Text = SR.Forum.RateForm.DeleteRate;
                break;

            case MessageRates.DeleteLocally:
                _lblInfo.Text = SR.Forum.RateForm.DeleteRateLocally;
                break;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Возвращает путь к иконке с оценкой.
        /// </summary>
        /// <param name="provider"></param>
        /// <param name="rate">Оценка.</param>
        /// <returns>Путь к иконке с оценкой.</returns>
        public static string GetRateImagePath(
            IServiceProvider provider,
            MessageRates rate)
        {
            switch (rate)
            {
            case MessageRates.Rate1:
            case MessageRates.Rate2:
            case MessageRates.Rate3:
                return(GetImageUri(provider, @"MessageViewer\" + rate, StyleImageType.Small));
            }

            return(GetImageUri(provider, @"MessageViewer\Rate" + rate, StyleImageType.Small) ?? string.Empty);
        }
Exemplo n.º 5
0
		public RateMark(
			RateMarkCollection parent,
			int id,
			MessageRates rateType,
			string userNick,
			string subject,
			string forumName)
		{
			_parent = parent;
			_id = id;
			_rateType = rateType;
			_userNick = userNick;
			_subject = subject;
			_forumName = forumName;
		}
Exemplo n.º 6
0
 public RateMark(
     RateMarkCollection parent,
     int id,
     MessageRates rateType,
     string userNick,
     string subject,
     string forumName)
 {
     _parent    = parent;
     _id        = id;
     _rateType  = rateType;
     _userNick  = userNick;
     _subject   = subject;
     _forumName = forumName;
 }
Exemplo n.º 7
0
 private string FormatRateItemWithDate(
     MessageRates rateType,
     int multiplier,
     bool forumInTop,
     int userId,
     UserClass userClass,
     string userDisplayName,
     DateTime rateDate,
     bool even)
 {
     return(string.Format(_templateRateItemWithDate,
                          FormatRate(rateType, multiplier, forumInTop),
                          FormatAuthor(userId, userClass, userDisplayName, false),
                          FormatDate(rateDate),
                          even ? _selectorEven : _selectorUneven));
 }
Exemplo n.º 8
0
        private void CustomInitializeComponents(MessageRates rate)
        {
            _lblInfo.Text = SR.Forum.RateForm.AddRate;

            var styler = _provider.GetRequiredService<IStyleImageManager>();
            switch (rate)
            {
                case MessageRates.Plus1:
                    _pbxRateImage.Image = styler.GetImage(
                        "MessageViewer\\RatePlus1", StyleImageType.Small);
                    break;
                case MessageRates.Agree:
                    _pbxRateImage.Image = styler.GetImage(
                        "MessageViewer\\RateAgree", StyleImageType.Small);
                    break;
                case MessageRates.DisAgree:
                    _pbxRateImage.Image = styler.GetImage(
                        "MessageViewer\\RateDisagree", StyleImageType.Small);
                    break;
                case MessageRates.Rate1:
                    _pbxRateImage.Image = styler.GetImage(
                        "MessageViewer\\Rate1", StyleImageType.Small);
                    break;
                case MessageRates.Rate2:
                    _pbxRateImage.Image = styler.GetImage(
                        "MessageViewer\\Rate2", StyleImageType.Small);
                    break;
                case MessageRates.Rate3:
                    _pbxRateImage.Image = styler.GetImage(
                        "MessageViewer\\Rate3", StyleImageType.Small);
                    break;
                case MessageRates.Smile:
                    _pbxRateImage.Image = styler.GetImage(
                        "MessageViewer\\RateSmile", StyleImageType.Small);
                    break;
                case MessageRates.DeleteRate:
                    _pbxRateImage.Image = styler.GetImage(
                        "MessageViewer\\RateX", StyleImageType.Small);
                    _lblInfo.Text = SR.Forum.RateForm.DeleteRate;
                    break;
                case MessageRates.DeleteLocally:
                    _lblInfo.Text = SR.Forum.RateForm.DeleteRateLocally;
                    break;
            }
        }
Exemplo n.º 9
0
 public void ExecuteRateMessage(ICommandContext context, int[] messageIds, MessageRates rate)
 {
     using (var rateForm = new RateForm(context, rate))
         if (rateForm.ShowDialog(
                 context
                 .GetRequiredService <IUIShell>()
                 .GetMainWindowParent()) == DialogResult.Yes)
         {
             ForumCommandHelper
             .GetMessageIds(context, messageIds)
             .ForEach(
                 msgId =>
                 context
                 .GetRequiredService <IOutboxManager>()
                 .RateMarks
                 .Add(msgId, rate));
         }
 }
        public void Add(int mid, MessageRates rate)
        {
            using (var db = _provider.CreateDBContext())
            {
                if (rate == MessageRates.DeleteLocally)
                {
                    db
                    .OutboxRates(r => r.MessageID == mid)
                    .Delete();
                }
                else
                {
                    var id =
                        db
                        .OutboxRates(r => r.RateType == rate && r.MessageID == mid)
                        .Select(r => (int?)r.ID)
                        .SingleOrDefault();

                    if (id == null)
                    {
                        db
                        .OutboxRates()
                        .Value(_ => _.RateType, rate)
                        .Value(_ => _.MessageID, mid)
                        .Insert();
                    }
                    else
                    {
                        db
                        .OutboxRates(r => r.ID == id)
                        .Set(_ => _.RateType, _ => rate)
                        .Update();
                    }
                }
            }

            Refresh();
        }
Exemplo n.º 11
0
        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 += @"&nbsp;x&nbsp;";
            }

            //	0 - rate text, 1 - path to rate icon
            return(string.Format(_templateRatePart, rt,
                                 JanusFormatMessage.GetRateImagePath(_serviceProvider, rateType)));
        }
Exemplo n.º 12
0
		public string GetRateImagePath(MessageRates rate)
		{
			return JanusFormatMessage.GetRateImagePath(_serviceProvider, rate);
		}
Exemplo n.º 13
0
		/// <summary>
		/// Возвращает путь к иконке с оценкой.
		/// </summary>
		/// <param name="provider"></param>
		/// <param name="rate">Оценка.</param>
		/// <returns>Путь к иконке с оценкой.</returns>
		public static string GetRateImagePath(
			IServiceProvider provider,
			MessageRates rate)
		{
			switch (rate)
			{
				case MessageRates.Rate1:
				case MessageRates.Rate2:
				case MessageRates.Rate3:
					return GetImageUri(provider, @"MessageViewer\" + rate, StyleImageType.Small);
			}

			return GetImageUri(provider, @"MessageViewer\Rate" + rate, StyleImageType.Small) ?? string.Empty;
		}
Exemplo n.º 14
0
 public RatesWindow(MessageRates rates)
 {
     InitializeComponent();
     DataContext = rates;
 }
Exemplo n.º 15
0
 public RateForm(IServiceProvider provider, MessageRates rate)
 {
     _provider = provider;
     InitializeComponent();
     CustomInitializeComponents(rate);
 }
Exemplo n.º 16
0
 public RateForm(IServiceProvider provider, MessageRates rate)
 {
     _provider = provider;
     InitializeComponent();
     CustomInitializeComponents(rate);
 }
Exemplo n.º 17
0
		public void ExecuteRateMessage(ICommandContext context, int[] messageIds, MessageRates rate)
		{
			using (var rateForm = new RateForm(context, rate))
				if (rateForm.ShowDialog(
						context
							.GetRequiredService<IUIShell>()
							.GetMainWindowParent()) == DialogResult.Yes)
					foreach (var msgId in ForumCommandHelper.GetMessageIds(context, messageIds))
						context
							.GetRequiredService<IOutboxManager>()
							.RateMarks
							.Add(msgId, rate);
		}
 public string GetRateImagePath(MessageRates rate)
 {
     return(JanusFormatMessage.GetRateImagePath(_serviceProvider, rate));
 }
Exemplo n.º 19
0
 private string FormatRateItemWithDate(
     MessageRates rateType,
     int multiplier,
     bool forumInTop,
     int userId,
     UserClass userClass,
     string userDisplayName,
     DateTime rateDate,
     bool even)
 {
     return string.Format(_templateRateItemWithDate,
         FormatRate(rateType, multiplier, forumInTop),
         FormatAuthor(userId, userClass, userDisplayName, false),
         FormatDate(rateDate),
         even ? _selectorEven : _selectorUneven);
 }
Exemplo n.º 20
0
        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 += @"&nbsp;x&nbsp;";
            }

            //	0 - rate text, 1 - path to rate icon
            return string.Format(_templateRatePart, rt,
                JanusFormatMessage.GetRateImagePath(_serviceProvider, rateType));
        }
Exemplo n.º 21
0
 private string FormatBigRateItem(
     MessageRates rateType,
     int rateMultiplier,
     DateTime rateDate,
     string forumName,
     string forumDesc,
     bool forumInTop,
     int msgID,
     string msgSubj,
     bool msgIsRead,
     bool msgIsMarked,
     int? msgArticleID,
     int userID,
     UserClass userClass,
     string userDisplayName,
     bool even)
 {
     return string.Format(_templateBigRateItem,
         FormatForum(forumName, forumDesc),
         FormatSubject(
             msgID,
             msgSubj,
             msgIsRead,
             msgIsMarked,
             msgArticleID,
             true),
         FormatRate(rateType, rateMultiplier, forumInTop),
         FormatAuthor(
             userID,
             userClass,
             userDisplayName,
             false),
         FormatDate(rateDate),
         even ? _selectorEven : _selectorUneven);
 }