Пример #1
0
 private void AddToFavoris(object sender, RoutedEventArgs e)
 {
     if (!UserConnected.VerifyHabilitation("100_1xFVS"))
     {
         MessageHabilitation.MessageNoHabilitatePersonnalized("ajouter un élément à vos favoris !");
     }
     else
     {
         Favoris isFavoris = dataUtils.GetListFavoris().Find(x =>
                                                             (x.IdTarget == ec.Id) &&
                                                             (x.IdUser == UserConnected.GetUserConnected().Id) &&
                                                             (x.TypeTarget.Equals("ExtraitCode"))
                                                             );
         if (isFavoris != null)
         {
             dataUtils.RemoveFavoris(ec.Id, "ExtraitCode", UserConnected.GetUserConnected().Id);
             this.FavorisExtraitCodeIcon.Icon = FontAwesome.WPF.FontAwesomeIcon.HeartOutline;
         }
         else
         {
             dataUtils.AddFavoris(ec.Id, "ExtraitCode", UserConnected.GetUserConnected().Id);
             this.FavorisExtraitCodeIcon.Icon = FontAwesome.WPF.FontAwesomeIcon.Heart;
         }
     }
 }
Пример #2
0
 private void ConfirmVote(int note)
 {
     if (!UserConnected.VerifyHabilitation("100_5xCD0"))
     {
         MessageHabilitation.MessageNoHabilitatePersonnalized("à noter un extrait de code !");
     }
     else
     {
         Vote ExistingVote = dataUtils.GetListVote().Find(x =>
                                                          (x.IdTarget == ec.Id) &&
                                                          (x.TypeTarget.Equals("ExtraitCode")) &&
                                                          (x.IdVoter == UserConnected.GetUserConnected().Id)
                                                          );
         if (ExistingVote == null)
         {
             dataUtils.AddVote(ec.Id, "ExtraitCode", UserConnected.GetUserConnected().Id, note);
         }
         else
         {
             ExistingVote.Note = note;
         }
         ec.CalculNote();
         this.ExtraitCode_Note.Text = ec.Note.ToString();
         DisplayTotalVote(dataUtils.GetListVote().Where(x => (x.IdTarget == ec.Id) && (x.TypeTarget.Equals("ExtraitCode"))).ToList().Count);
     }
 }
Пример #3
0
 private void HoverStarNote5(object sender, MouseEventArgs e)
 {
     if (UserConnected.VerifyHabilitation("100_5xCD0"))
     {
         if (this.StarNote5.Foreground == new SolidColorBrush((Color)ColorConverter.ConvertFromString("#515151")))
         {
             this.StarNote1.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#BFBFBF"));
             this.StarNote2.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#BFBFBF"));
             this.StarNote3.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#BFBFBF"));
             this.StarNote4.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#BFBFBF"));
             this.StarNote5.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#BFBFBF"));
             this.StarNote1.Icon       = FontAwesome.WPF.FontAwesomeIcon.Star;
             this.StarNote2.Icon       = FontAwesome.WPF.FontAwesomeIcon.Star;
             this.StarNote3.Icon       = FontAwesome.WPF.FontAwesomeIcon.Star;
             this.StarNote4.Icon       = FontAwesome.WPF.FontAwesomeIcon.Star;
             this.StarNote5.Icon       = FontAwesome.WPF.FontAwesomeIcon.Star;
         }
         else
         {
             this.StarNote1.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#BFBFBF"));
             this.StarNote2.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#BFBFBF"));
             this.StarNote3.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#BFBFBF"));
             this.StarNote4.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#BFBFBF"));
             this.StarNote5.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#BFBFBF"));
             this.StarNote1.Icon       = FontAwesome.WPF.FontAwesomeIcon.Star;
             this.StarNote2.Icon       = FontAwesome.WPF.FontAwesomeIcon.Star;
             this.StarNote3.Icon       = FontAwesome.WPF.FontAwesomeIcon.Star;
             this.StarNote4.Icon       = FontAwesome.WPF.FontAwesomeIcon.Star;
             this.StarNote5.Icon       = FontAwesome.WPF.FontAwesomeIcon.Star;
         }
     }
 }
Пример #4
0
 public Chat(Conversation conversation)
 {
     InitializeComponent();
     if (!UserConnected.VerifyHabilitation("100_1xMSE"))
     {
         TextBox_Comment.IsReadOnly = true;
         TextBox_Comment.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#EB4034"));
         TextBox_Comment.Cursor     = Cursors.No;
     }
     if (!UserConnected.VerifyHabilitation("100_4xCVN"))
     {
         BtnDeleteConversation.Cursor     = Cursors.No;
         BtnDeleteConversationText.Cursor = Cursors.No;
     }
     conv = conversation;
     OrganizeListMessage();
     this.TextBox_Comment.AcceptsTab = true;
     _correspondant = dataUtils.GetListUsers().Find(x => (x.Id == conversation.Users.Find(y => y != UserConnected.GetUserConnected().Id)));
     this.Nom_Correspondant.Text = _correspondant.Prenom + " " + _correspondant.Nom;
     if (_correspondant.Picture == null || _correspondant.Picture.Equals(""))
     {
         _correspondant.Picture = "Images/unnamed.png";
     }
     this.Picture_Correspondant.ImageSource = new BitmapImage(new Uri(String.Format("../../Resources/" + _correspondant.Picture), UriKind.Relative));
     this.ListMessages.ItemsSource          = _listItemMessage;
 }
Пример #5
0
 private void AddNewConversation(object sender, RoutedEventArgs e)
 {
     if (!UserConnected.VerifyHabilitation("100_4xCVN"))
     {
         MessageHabilitation.MessageNoHabilitatePersonnalized("créer une nouvelle conversation !");
     }
     else
     {
         this.Body_Conversation.Children.Clear();
         this.Body_Conversation.Children.Add(new AddChat());
     }
 }
Пример #6
0
 private void ClickNewExtraitCode(object sender, MouseButtonEventArgs e)
 {
     if (!UserConnected.VerifyHabilitation("100_1xCD0"))
     {
         MessageHabilitation.MessageNoHabilitatePersonnalized("créer un nouvel extrait de code !");
     }
     else
     {
         this.Body_Extrait.Children.Remove(NoExtraitText);
         this.Body_Extrait.Children.Add(new AddExtraitCode());
     }
 }
Пример #7
0
 private void SendComment(object sender, MouseButtonEventArgs e)
 {
     if (!UserConnected.VerifyHabilitation("100_1xCMT"))
     {
         MessageHabilitation.MessageNoHabilitatePersonnalized("ajouter un commentaire !");
     }
     else
     {
         if (this.AddComment.Text.Equals("") || this.AddComment.Text.Equals("Écrire un commentaire..."))
         {
             MessageBox.Show("Veuillez écrire un commentaire !", "Espi Community", MessageBoxButton.OK, MessageBoxImage.Error);
         }
         else
         {
             DateTime fullDate = DateTime.Now;
             String   date     = (fullDate.Day < 10 ? "0" + fullDate.Day.ToString() : fullDate.Day.ToString()) + "/" +
                                 (fullDate.Month < 10 ? "0" + fullDate.Month.ToString() : fullDate.Month.ToString()) + "/" +
                                 fullDate.Year.ToString();
             String hour = (fullDate.Hour < 10 ? "0" + fullDate.Hour.ToString() : fullDate.Hour.ToString()) + ":" +
                           (fullDate.Minute < 10 ? "0" + fullDate.Minute.ToString() : fullDate.Minute.ToString()) + ":" +
                           (fullDate.Second < 10 ? "0" + fullDate.Second.ToString() : fullDate.Second.ToString());
             String dateComment = date + " " + hour;
             if ((this.TextBlock_ReponseName.Text != null || !this.TextBlock_ReponseName.Text.Equals("")) &&
                 this.TextBlock_Reponse.Visibility == Visibility.Collapsed && this.TextBlock_ReponseName.Visibility == Visibility.Collapsed)
             {
                 dataUtils.AddComment(
                     UserConnected.GetUserConnected().Id,
                     UserConnected.GetUserConnected().Nom,
                     UserConnected.GetUserConnected().Prenom,
                     ec.Id,
                     "ExtraitCode",
                     this.AddComment.Text,
                     dateComment
                     );
             }
             else
             {
                 dataUtils.AddComment(
                     UserConnected.GetUserConnected().Id,
                     UserConnected.GetUserConnected().Nom,
                     UserConnected.GetUserConnected().Prenom,
                     IdCommentToResponse,
                     "Comment",
                     this.AddComment.Text,
                     dateComment
                     );
             }
             this.AddComment.Text = "Écrire un commentaire...";
             OrganizeListComment();
             this.ListComments.ItemsSource = _listItemComment;
         }
     }
 }
Пример #8
0
 private void ApprouveExtraitCode(object sender, MouseButtonEventArgs e)
 {
     if (!UserConnected.VerifyHabilitation("100_6xCD0"))
     {
         MessageHabilitation.MessageNoHabilitatePersonnalized("approuver l'extrait de code !");
     }
     else
     {
         if (_listApprouvedUser.Contains(UserConnected.GetUserConnected()))
         {
             _listApprouvedUser.Remove(UserConnected.GetUserConnected());
         }
     }
 }
Пример #9
0
        public ExtraitCodeHome()
        {
            InitializeComponent();
            _codeViewModel = new CodeViewModel();

            this.ListView_ExtraitsCode.Style = null;

            if (!UserConnected.VerifyHabilitation("100_1xCD0"))
            {
                BtnAddExtrait.Cursor = Cursors.No;
            }

            ICollectionView lesExtraitsCode = _codeViewModel.ExtraitsCode;

            this.ListView_ExtraitsCode.ItemsSource = lesExtraitsCode.Cast <ExtraitCode>().OrderBy(x => x.Date_Creation).ToList();
        }
Пример #10
0
        public MessagerieHome()
        {
            InitializeComponent();
            _messageViewModel = new MessageViewModel();

            this.ListView_Messages.Style = null;

            if (!UserConnected.VerifyHabilitation("100_4xCVN"))
            {
                BtnAddConversation.Cursor = Cursors.No;
            }

            _lastsMessages = OrganiseLastMessageInContactList(_messageViewModel.Conversations);
            ICollectionView _lastMessageViewModel = CollectionViewSource.GetDefaultView(_lastsMessages);

            this.ListView_Messages.ItemsSource = _lastMessageViewModel;
        }
Пример #11
0
 private void DeleteExtraitCode(object sender, RoutedEventArgs e)
 {
     if (!UserConnected.VerifyHabilitation("100_4xCD0"))
     {
         MessageHabilitation.MessageNoHabilitatePersonnalized("supprimer l'extrait de code !");
     }
     else
     {
         dataUtils.RemoveExtraitCode(ec.Id);
         TextBlock NoExtraitText = new TextBlock
         {
             Text                = "Aucun extrait à afficher...",
             Foreground          = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#515151")),
             VerticalAlignment   = VerticalAlignment.Center,
             HorizontalAlignment = HorizontalAlignment.Center,
             Name                = "NoExtraitText"
         };
         ((ListView)((Grid)((Grid)((Grid)this.Parent).Parent).Children[0]).Children[3]).ItemsSource = dataUtils.GetListExtraitsCode().Cast <ExtraitCode>().OrderBy(x => x.Date_Creation).ToList();
         ((Grid)this.Parent).Children.Add(NoExtraitText);
         ((Grid)this.Parent).Children.Remove(this);
     }
 }
Пример #12
0
 private void DeleteConversation(object sender, MouseButtonEventArgs e)
 {
     if (!UserConnected.VerifyHabilitation("100_4xCVN"))
     {
         MessageHabilitation.MessageNoHabilitatePersonnalized("supprimer la conversation !");
     }
     else
     {
         dataUtils.DeleteMessages(dataUtils.GetMessagesOfConversation(conv.Id));
         dataUtils.DeleteConversation(conv.Id);
         TextBlock NoChatText = new TextBlock
         {
             Text                = "Aucun message à afficher...",
             Foreground          = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#515151")),
             VerticalAlignment   = VerticalAlignment.Center,
             HorizontalAlignment = HorizontalAlignment.Center,
             Name                = "NoChatText"
         };
         ReOrganiseLastMessageInContactList();
         ((Grid)this.Parent).Children.Add(NoChatText);
         ((Grid)this.Parent).Children.Remove(this);
     }
 }
Пример #13
0
        public ExtraitCodeItem(ExtraitCode extraitCode)
        {
            InitializeComponent();
            if (!UserConnected.VerifyHabilitation("100_4xCD0"))
            {
                DeleteExtraitCodeIcon.Cursor = Cursors.No;
            }
            if (!UserConnected.VerifyHabilitation("100_1xCMT"))
            {
                AddComment.Cursor     = Cursors.No;
                AddComment.Text       = "";
                AddComment.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#EB4034"));
            }
            if (!UserConnected.VerifyHabilitation("100_5xCD0"))
            {
                StarNote1.Cursor = Cursors.No;
                StarNote2.Cursor = Cursors.No;
                StarNote3.Cursor = Cursors.No;
                StarNote4.Cursor = Cursors.No;
                StarNote5.Cursor = Cursors.No;
            }
            ec = extraitCode;
            _listApprouvedUser = new List <User>();
            OrganizeListComment();
            if (_listComments.Count == 0 || _listComments == null)
            {
                this.CommentBlock.Children.Remove(ListComments);
                TextBlock NoComments = new TextBlock
                {
                    Text                = "Pas de commentaire...",
                    Foreground          = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#BFBFBF")),
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center
                };
                this.CommentBlock.Children.Add(NoComments);
            }
            ExtraitCodeApprouved extraitCodeApprouved = dataUtils.GetListExtraitsCodeApprouved().Find(x => x.IdExtraitCode == extraitCode.Id);

            if (extraitCodeApprouved == null)
            {
                this.ApprouvedBlock.Visibility = Visibility.Hidden;
            }
            else
            {
                foreach (int i in extraitCodeApprouved.ListApprouver)
                {
                    _listApprouvedUser.Add(dataUtils.GetListUsers().Find(x => x.Id == i));
                }
                if (!UserConnected.GetUserConnected().GetIdRoles().Contains(1) || !UserConnected.GetUserConnected().GetIdRoles().Contains(2) || !UserConnected.GetUserConnected().GetIdRoles().Contains(5))
                {
                    this.ApprouveExtraitCodeIcon.Visibility = Visibility.Hidden;
                }
                else
                {
                    if (_listApprouvedUser.Contains(UserConnected.GetUserConnected()))
                    {
                        this.ApprouveExtraitCodeIcon.Icon       = FontAwesome.WPF.FontAwesomeIcon.CheckCircle;
                        this.ApprouveExtraitCodeIcon.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#2F528F"));
                    }
                    else
                    {
                        this.ApprouveExtraitCodeIcon.Icon       = FontAwesome.WPF.FontAwesomeIcon.CheckCircleOutline;
                        this.ApprouveExtraitCodeIcon.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#BFBFBF"));
                    }
                }
            }
            Binding binding = new Binding
            {
                Mode = BindingMode.OneWay
            };

            this.ExtraitCode_Creator.Text = dataUtils.GetListUsers().Find(x => x.Id == extraitCode.IdCreator).Nom + " " +
                                            dataUtils.GetListUsers().Find(x => x.Id == extraitCode.IdCreator).Prenom;
            this.ListComments.ItemsSource     = _listItemComment;
            this.ExtraitCode_Title.Text       = extraitCode.Title;
            this.ExtraitCode_Description.Text = extraitCode.Description;
            List <int> idRoles = UserConnected.GetUserConnected().GetIdRoles();

            if (UserConnected.GetUserConnected().Id == ec.IdCreator || idRoles.Contains(1) || idRoles.Contains(2) || idRoles.Contains(3) || idRoles.Contains(4) || idRoles.Contains(5))
            {
                this.DeleteExtraitCodeIcon.Visibility = Visibility.Visible;
            }
            else
            {
                this.DeleteExtraitCodeIcon.Visibility = Visibility.Collapsed;
            }
            Favoris isFavoris = dataUtils.GetListFavoris().Find(x =>
                                                                (x.IdTarget == ec.Id) &&
                                                                (x.IdUser == UserConnected.GetUserConnected().Id) &&
                                                                (x.TypeTarget.Equals("ExtraitCode"))
                                                                );

            if (isFavoris != null)
            {
                this.FavorisExtraitCodeIcon.Icon = FontAwesome.WPF.FontAwesomeIcon.Heart;
            }
            else
            {
                this.FavorisExtraitCodeIcon.Icon = FontAwesome.WPF.FontAwesomeIcon.HeartOutline;
            }
            this.ExtraitCode_Code.Text = TextEncoder.DecodeText(extraitCode.Code);
            this.ExtraitCode_Note.Text = extraitCode.Note.ToString();
            DisplayTotalVote(dataUtils.GetListVote().Where(x => (x.IdTarget == extraitCode.Id) && (x.TypeTarget.Equals("ExtraitCode"))).ToList().Count);
            ChangePersonalVote(extraitCode);
            ChangeApprouverList(_listApprouvedUser);
            this.Picture_Creator.ImageSource = new BitmapImage
                                               (
                new Uri(String.Format("pack://application:,,,/Resources/" + dataUtils.GetListUsers().Find(x => x.Id == extraitCode.IdCreator).Picture))
                                               );
            this.ExtraitCode_DateCreation.Text = RebuildDateCreation(extraitCode.Date_Creation);
        }