Пример #1
0
 /// <summary>
 /// Build the message and send to the add method in the db
 /// </summary>
 /// <param name="ucRTBMessage">the message</param>
 private void AddMessageDB(UcRichTextBox ucRTBMessage)
 {
     Message = new Message();
     Message.ReplyContent  = ucRTBMessage.RichTextBox.Rtf; //.Text
     Message.Topic.TopicId = ucRTBMessage.TopicId;
     Message.Person        = _personConnected;
     Controller.AddNewTopicReply(Message);
 }
Пример #2
0
        /// <summary>
        /// Built user control message
        /// </summary>
        /// <param name="topicReply">object topicReply</param>
        /// <returns>user control message</returns>
        public UcMessage BuildMessage(Message topicReply)
        {
            UcMessage newUcMessage = new UcMessage();

            newUcMessage.Dock = DockStyle.Top;
            newUcMessage.textBoxResponseName.Text = Properties.Resources.PREFORMATTINGTITLE + topicReply.Topic.Title;
            if (topicReply.ReplyContent.Substring(0, 1) == "{")
            {
                newUcMessage.richTextBoxMessage.Rtf = topicReply.ReplyContent;
            }
            else
            {
                newUcMessage.richTextBoxMessage.Text = topicReply.ReplyContent;
            }
            newUcMessage.TopicReplyId = topicReply.TopicReplyId;
            newUcMessage.AuthorId     = topicReply.AuthorId;
            newUcMessage.Topic        = topicReply.Topic;

            newUcMessage.DeleteClick += new EventHandler(DeleteMessage_Click);
            newUcMessage.PlusClick   -= new EventHandler(AddPlusOne_Click);

            if (topicReply.Topic.TypeTopic == (int)BusinessClassPortable.Enum.TypeTopic.Classical)
            {
                newUcMessage.textBoxNbPlus.Visible  = false;
                newUcMessage.pictureBoxPlus.Visible = false;
                newUcMessage.pictureBoxBest.Visible = false;
                newUcMessage.pictureBoxPlus.Enabled = false;
            }

            if (topicReply.Topic.TypeTopic == (int)BusinessClassPortable.Enum.TypeTopic.Question)
            {
                if (_connection)
                {
                    if (Controller.CheckVoted(newUcMessage.TopicReplyId, _personConnected.PersonId))
                    {
                        newUcMessage.pictureBoxPlus.Enabled = false;
                        newUcMessage.pictureBoxPlus.Image   = Properties.Resources.happy;
                        newUcMessage.PlusClick -= new EventHandler(AddPlusOne_Click);
                    }
                    else
                    {
                        newUcMessage.pictureBoxPlus.Enabled = true;
                        newUcMessage.pictureBoxPlus.Image   = Properties.Resources.plus;
                        newUcMessage.PlusClick += new EventHandler(AddPlusOne_Click);
                        _tt.SetToolTip(newUcMessage.pictureBoxPlus, Properties.Resources.TOOLTIPVOTE);
                    }
                }

                newUcMessage.textBoxNbPlus.Visible  = true;
                newUcMessage.pictureBoxPlus.Visible = true;
                newUcMessage.textBoxNbPlus.Text     = topicReply.Vote.ToString();
                newUcMessage.PlusClick += new EventHandler(AddPlusOne_Click);
            }

            if (_connection && _personConnected.Privilege > 0)
            {
                newUcMessage.panelOption.Enabled = true;
                newUcMessage.panelOption.Visible = true;
                _tt.SetToolTip(newUcMessage.pictureBoxDelete, Properties.Resources.TOOLTIPDELETE);
            }

            string dateAdd =
                $"{newUcMessage.textBoxDateCreate.Text} {topicReply.DateAdd.Day}/{topicReply.DateAdd.Month}/{topicReply.DateAdd.Year} à {topicReply.DateAdd.Hour}h{topicReply.DateAdd.Minute}min";

            if (topicReply.DateAdd == topicReply.DateUp)
            {
                newUcMessage.textBoxDateCreate.Text = dateAdd;
            }
            else
            {
                newUcMessage.textBoxDateCreate.Text =
                    $"Mis à jour le {topicReply.DateUp.Day}/{topicReply.DateUp.Month}/{topicReply.DateUp.Year} à {topicReply.DateUp.Hour}h{topicReply.DateUp.Minute}min, {dateAdd}";
            }

            newUcMessage.textBoxName.Text =
                $"{topicReply.AuthorFirstName} {topicReply.AuthorLastName}";

            //ucMessage.pictureBoxAvatar.Image =

            //ucMessage.textBoxProject.Text = $"{ucMessage.textBoxProject.Text} ...";

            //ucMessage.textBoxTech.Text = $"{ucMessage.textBoxTech.Text} ...";
            // For Moderator Privileges
            //if (PersonConnected != null && PersonConnected.Privilege > 0)
            //{
            //    newUcMessage.flowLayoutPanelOption.Visible = true;
            //    newUcMessage.flowLayoutPanelOption.Enabled = true;
            //}
            return(newUcMessage);
        }