예제 #1
0
        private void AddTopicInList(List <Topic> TopicsList)
        {
            UcTopicList = new List <UcTopic>();
            UcTopicList.Add(TopicHeader());
            foreach (Topic topic in TopicsList)
            {
                UcTopic tile = new UcTopic();
                tile.RubricPictContent.Image = BuildRubricPicture(topic.Rubric.RubricId);
                tile.ContentText.Text        = topic.Title;
                tile.Description.Text        = topic.Description;
                tile.AuthorDateCreate.Text   = $"écrit par {topic.Person.PersonFirstName} {topic.Person.PersonLastName} le {topic.DateAdd.Day}/{topic.DateAdd.Month}/{topic.DateAdd.Year} à {topic.DateAdd.Hour}:{topic.DateAdd.Minute}";
                tile.Id                 = topic.TopicId;
                tile.RubricId           = topic.Rubric.RubricId;
                tile.ButtonClickTiles  += new EventHandler(Topic_Click);
                tile.ButtonDeleteTiles += new EventHandler(DeleteTopic_Click);
                tile.ButtonEditTiles   += new EventHandler(EditTopic_Click);

                if (PersonConnect != null && PersonConnect.Privilege > 0)
                {
                    tile.pictureBoxEdit.Visible   = true;
                    tile.pictureBoxEdit.Enabled   = true;
                    tile.pictureBoxDelete.Visible = true;
                    tile.pictureBoxDelete.Enabled = true;
                }
                UcTopicList.Add(tile);
            }
        }
예제 #2
0
        private void EditTopic_Click(object sender, EventArgs e)
        {
            //if (TopicEdit != null)
            //    TopicEdit(this, e);

            //Header
            //TopicHeader();

            UcTopic tile = (UcTopic)sender;

            tile.ButtonClickTiles -= new EventHandler(Topic_Click);

            tile.pictureBoxDelete.Enabled = false;
            tile.pictureBoxDelete.Visible = false;
            tile.pictureBoxEdit.Enabled   = false;
            tile.pictureBoxEdit.Visible   = false;

            tile.ButtonValidate          += new EventHandler(AcceptEdit_Click);
            tile.pictureBoxAccept.Enabled = true;
            tile.pictureBoxAccept.Visible = true;
            tile.ButtonCanceled          += new EventHandler(CancelEdit_Click);
            tile.pictureBoxCancel.Enabled = true;
            tile.pictureBoxCancel.Visible = true;

            tile.ContentText.BackColor = Color.Aquamarine;
            tile.ContentText.ReadOnly  = false;

            tile.Description.BackColor = Color.Aquamarine;
            tile.Description.ReadOnly  = false;

            new ManagerTopic(tile.RubricId);
        }
예제 #3
0
        private void DeleteTopic_Click(object sender, EventArgs e)
        {
            //if (TopicDelete != null)
            //    TopicDelete(this, e);

            UcTopic tile = (UcTopic)sender;

            Controller.DeleteTopicInDb(tile.Id);
            new ManagerTopic(tile.RubricId);
        }
예제 #4
0
        /// <summary>
        /// Use the tab creation method to display topics discussions
        /// </summary>
        /// <param name="sender">user control topic</param>
        /// <param name="e"></param>
        public void Topic_Click(object sender, EventArgs e)
        {
            UcTopic UcTopic = (UcTopic)sender;

            if (TopicClick != null)
            {
                TopicClick(this, new LoadTopicEventArgs {
                    UcTopic = UcTopic
                });
            }
        }
예제 #5
0
        private SplitContainer CreateSplitContainer(UcTopic tile)
        {
            SplitContainer splitContainer = new SplitContainer();

            splitContainer.Orientation      = Orientation.Horizontal;
            splitContainer.Dock             = DockStyle.Fill;
            splitContainer.SplitterDistance = 300;
            splitContainer.Tag = tile.Id;

            splitContainer.Panel1.AutoScroll = true;

            return(splitContainer);
        }
예제 #6
0
        /// <summary>
        /// Build a new tab with the topics of a topic
        /// </summary>
        /// <param name="sender">Represents the activated tile</param>
        private void MakeTabTopicResponse(object sender)
        {
            UcTopic tiles = (UcTopic)sender;

            SplitContainer splitContainer = CreateSplitContainer(tiles);

            splitContainersList.Add(splitContainer);

            splitContainer.Panel2.Controls.Add(ObjManagerRichTextBox.BuildRTB(tiles.Id));

            foreach (UcMessage messageTopic in ObjManagerMessage.BuildMessageList(tiles.Id))
            {
                splitContainer.Panel1.Controls.Add(messageTopic);
            }

            BuildTabPage(splitContainer, tiles.ContentText.Text);
        }
예제 #7
0
        /// <summary>
        /// Uses the method of deleting a topic in db
        /// </summary>
        /// <param name="sender">user control topic</param>
        /// <param name="e"></param>
        public void DeleteTopic_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show(Properties.Resources.VALIDDELETE, Properties.Resources.CAPTIONDELETE, MessageBoxButtons.OKCancel) == DialogResult.Cancel)
            {
                return;
            }

            UcTopic tile = (UcTopic)sender;

            Controller.DeleteTopicInDb(tile.Id);
            if (TopicDelete != null)
            {
                TopicDelete(this, new LoadTopicEventArgs {
                    UcTopic = tile
                });
            }
        }
예제 #8
0
        /// <summary>
        /// Check the edited topic, add it to the db and restore the initial state
        /// </summary>
        /// <param name="sender">user control topic</param>
        /// <param name="e"></param>
        public void AcceptEdit_Click(object sender, EventArgs e)
        {
            UcTopic tile = (UcTopic)sender;

            if (tile.ContentText.Text == Properties.Resources.EMPTY || tile.Description.Text == Properties.Resources.EMPTY)
            {
                MessageBox.Show(Properties.Resources.EMPTYFIELDS, Properties.Resources.CAPTIONEMPTYFIELDS, MessageBoxButtons.OK);
            }
            else
            {
                Topic newTopic = new Topic(Controller.GetTopicById(tile.Id));
                newTopic.DateUp      = DateTime.Now;
                newTopic.Description = tile.Description.Text;
                newTopic.Title       = tile.ContentText.Text;
                Controller.EditTopicInDb(newTopic);

                RestoreInitialState_Click(sender, e);
            }
        }
예제 #9
0
        private UcTopic TopicHeader()
        {
            UcTopic TopicHeader = new UcTopic();

            TopicHeader.RubricPictContent.Image  = new Bitmap(Properties.Resources.logoForDevjpg);
            TopicHeader.ContentText.Text         = "Titre du topic";
            TopicHeader.ContentText.Font         = new Font(TopicHeader.ContentText.Font, FontStyle.Bold);
            TopicHeader.ContentText.Font         = new Font(TopicHeader.Font.FontFamily, 20);
            TopicHeader.Description.Enabled      = true;
            TopicHeader.Description.Visible      = true;
            TopicHeader.Description.Text         = "Description en quelques mots...";
            TopicHeader.Description.Font         = new Font(TopicHeader.ContentText.Font, FontStyle.Bold);
            TopicHeader.AuthorDateCreate.Enabled = true;
            TopicHeader.AuthorDateCreate.Visible = true;
            TopicHeader.AuthorDateCreate.Text    = "Auteur du topic";
            TopicHeader.AuthorDateCreate.Font    = new Font(TopicHeader.ContentText.Font, FontStyle.Bold);

            return(TopicHeader);
        }
예제 #10
0
        /// <summary>
        /// Restored the initial state of the topic
        /// </summary>
        /// <param name="sender">user control topic</param>
        /// <param name="e"></param>
        private void RestoreInitialState_Click(object sender, EventArgs e)
        {
            UcTopic tile = (UcTopic)sender;

            tile.ButtonClickTiles        += new EventHandler(Topic_Click);
            tile.pictureBoxDelete.Enabled = true;
            tile.pictureBoxDelete.Visible = true;
            tile.pictureBoxEdit.Enabled   = true;
            tile.pictureBoxEdit.Visible   = true;
            tile.ButtonValidate          -= new EventHandler(AcceptEdit_Click);
            tile.pictureBoxAccept.Enabled = false;
            tile.pictureBoxAccept.Visible = false;
            tile.ButtonCanceled          -= new EventHandler(RestoreInitialState_Click);
            tile.pictureBoxCancel.Enabled = false;
            tile.pictureBoxCancel.Visible = false;
            tile.ContentText.BackColor    = Color.White;
            tile.ContentText.ReadOnly     = true;
            tile.Description.BackColor    = Color.White;
            tile.Description.ReadOnly     = true;
        }
예제 #11
0
        /// <summary>
        /// Build topic header
        /// </summary>
        /// <returns>user control topic</returns>
        public UcTopic TopicHeader()
        {
            UcTopic TopicHeader = new UcTopic();

            TopicHeader.RubricPictContent.Image  = new Bitmap(Properties.Resources.IconForDev);
            TopicHeader.ContentText.Text         = "Titre";
            TopicHeader.ContentText.Font         = new Font(TopicHeader.ContentText.Font, FontStyle.Bold);
            TopicHeader.ContentText.Font         = new Font(TopicHeader.Font.FontFamily, 20);
            TopicHeader.ContentText.Margin       = new Padding(0, 0, 0, 0);
            TopicHeader.Description.Enabled      = true;
            TopicHeader.Description.Visible      = true;
            TopicHeader.Description.Text         = "Description";
            TopicHeader.Description.Font         = new Font(TopicHeader.ContentText.Font, FontStyle.Bold);
            TopicHeader.Description.Margin       = new Padding(0, 0, 0, 0);
            TopicHeader.AuthorDateCreate.Enabled = true;
            TopicHeader.AuthorDateCreate.Visible = true;
            TopicHeader.AuthorDateCreate.Text    = "Auteur";
            TopicHeader.AuthorDateCreate.Font    = new Font(TopicHeader.ContentText.Font, FontStyle.Bold);
            TopicHeader.AuthorDateCreate.Margin  = new Padding(0, 0, 0, 0);
            return(TopicHeader);
        }
예제 #12
0
        private void AcceptEdit_Click(object sender, EventArgs e)
        {
            UcTopic tile = (UcTopic)sender;

            if (tile.ContentText.Text == "" || tile.Description.Text == "")
            {
                MessageBox.Show("Tout les champs doivent être renseigné", "Erreur de saisie", MessageBoxButtons.OK);
                return;
            }
            else
            {
                Topic newTopic = new Topic(Controller.GetTopicById(tile.Id));
                newTopic.DateUp      = DateTime.Now;
                newTopic.Description = tile.Description.Text;
                newTopic.Title       = tile.ContentText.Text;

                Controller.EditTopicInDb(newTopic);

                new ManagerTopic(tile.RubricId);
            }
        }
예제 #13
0
        /// <summary>
        /// builds and adds the user control topic to the list
        /// </summary>
        /// <param name="TopicsList">topic list from db</param>
        /// <param name="scheduler">Used to parry the inter thread call</param>
        /// <returns>list user control topic</returns>
        private List <UcTopic> AddTopicInList(List <Topic> TopicsList, TaskScheduler scheduler)
        {
            UcTopicList = new List <UcTopic>();
            foreach (Topic topic in TopicsList)
            {
                UcTopic tile = new UcTopic();
                tile.RubricPictContent.Image = BuildRubricPicture(topic.Rubric.RubricId);
                tile.ContentText.Text        = topic.Title;
                tile.Description.Text        = topic.Description;
                tile.AuthorDateCreate.Text   = $"écrit par {topic.Person.PersonFirstName} {topic.Person.PersonLastName} le {topic.DateAdd.Day}/{topic.DateAdd.Month}/{topic.DateAdd.Year} à {topic.DateAdd.Hour}:{topic.DateAdd.Minute}";
                tile.Id                 = topic.TopicId;
                tile.RubricId           = topic.Rubric.RubricId;
                tile.ButtonClickTiles  += new EventHandler(Topic_Click);
                tile.ButtonDeleteTiles += new EventHandler(DeleteTopic_Click);
                tile.ButtonEditTiles   += new EventHandler(EditTopic_Click);
                tile.ButtonValidate    += new EventHandler(AcceptEdit_Click);

                //tile.MouseHover += Hover;

                if (scheduler != null)
                {
                    Task.Factory.StartNew(() =>
                    {
                        if (_connection && _personConnect.Privilege > 0)
                        {
                            tile.pictureBoxEdit.Visible   = true;
                            tile.pictureBoxEdit.Enabled   = true;
                            tile.pictureBoxDelete.Visible = true;
                            tile.pictureBoxDelete.Enabled = true;
                        }
                    }, CancellationToken.None, TaskCreationOptions.None, scheduler);
                }

                UcTopicList.Add(tile);
            }
            return(UcTopicList);
        }
예제 #14
0
        private void CancelEdit_Click(object sender, EventArgs e)
        {
            UcTopic tile = (UcTopic)sender;

            new ManagerTopic(tile.RubricId);
        }