예제 #1
0
        private void ShowExtraitCode(Object sender, RoutedEventArgs e)
        {
            DependencyObject dep = (DependencyObject)e.OriginalSource;

            while ((dep != null) && !(dep is ListViewItem))
            {
                dep = VisualTreeHelper.GetParent(dep);
            }
            ExtraitCode extraitCode = (ExtraitCode)ListView_ExtraitsCode.ItemContainerGenerator.ItemFromContainer(dep);

            if (extraitCode != null)
            {
                this.Body_Extrait.Children.Remove(NoExtraitText);
                this.Body_Extrait.Children.Add(new ExtraitCodeItem(extraitCode));
            }
        }
예제 #2
0
        public static void AddExtraitCode(int IdCreator, String Nom, String Prenom, String Title, String Description, String Code, String Date_Creation, String Horaire_Creation)
        {
            ExtraitCode newExtraitCode = new ExtraitCode(listExtraitsCodes[listExtraitsCodes.Count - 1].Id + 1, IdCreator, Nom, Prenom, Title, Description, Code, Date_Creation, Horaire_Creation, 0);

            listExtraitsCodes.Add(newExtraitCode);
        }
예제 #3
0
        public static void RemoveExtraitCode(int idExtraitCode)
        {
            ExtraitCode extraitCodeToRemove = dataUtils.GetListExtraitsCode().Find(x => x.Id == idExtraitCode);

            listExtraitsCodes.Remove(extraitCodeToRemove);
        }
예제 #4
0
        private void ChangePersonalVote(ExtraitCode extraitCode)
        {
            Vote MyVote = dataUtils.GetListVote().Find(x =>
                                                       (x.IdTarget == extraitCode.Id) &&
                                                       (x.TypeTarget == "ExtraitCode") &&
                                                       (x.IdVoter == UserConnected.GetUserConnected().Id)
                                                       );

            if (MyVote != null)
            {
                if (MyVote.Note > 0)
                {
                    if (MyVote.Note == 1)
                    {
                        this.StarNote1.Icon       = FontAwesome.WPF.FontAwesomeIcon.Star;
                        this.StarNote2.Icon       = FontAwesome.WPF.FontAwesomeIcon.StarOutline;
                        this.StarNote3.Icon       = FontAwesome.WPF.FontAwesomeIcon.StarOutline;
                        this.StarNote4.Icon       = FontAwesome.WPF.FontAwesomeIcon.StarOutline;
                        this.StarNote5.Icon       = FontAwesome.WPF.FontAwesomeIcon.StarOutline;
                        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"));
                    }
                    else if (MyVote.Note == 2)
                    {
                        this.StarNote1.Icon       = FontAwesome.WPF.FontAwesomeIcon.Star;
                        this.StarNote2.Icon       = FontAwesome.WPF.FontAwesomeIcon.Star;
                        this.StarNote3.Icon       = FontAwesome.WPF.FontAwesomeIcon.StarOutline;
                        this.StarNote4.Icon       = FontAwesome.WPF.FontAwesomeIcon.StarOutline;
                        this.StarNote5.Icon       = FontAwesome.WPF.FontAwesomeIcon.StarOutline;
                        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"));
                    }
                    else if (MyVote.Note == 3)
                    {
                        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.StarOutline;
                        this.StarNote5.Icon       = FontAwesome.WPF.FontAwesomeIcon.StarOutline;
                        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"));
                    }
                    else if (MyVote.Note == 4)
                    {
                        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.StarOutline;
                        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"));
                    }
                    else if (MyVote.Note == 5)
                    {
                        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;
                        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"));
                    }
                }
                else
                {
                    this.StarNote1.Icon       = FontAwesome.WPF.FontAwesomeIcon.StarOutline;
                    this.StarNote2.Icon       = FontAwesome.WPF.FontAwesomeIcon.StarOutline;
                    this.StarNote3.Icon       = FontAwesome.WPF.FontAwesomeIcon.StarOutline;
                    this.StarNote4.Icon       = FontAwesome.WPF.FontAwesomeIcon.StarOutline;
                    this.StarNote5.Icon       = FontAwesome.WPF.FontAwesomeIcon.StarOutline;
                    this.StarNote1.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#515151"));
                    this.StarNote2.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#515151"));
                    this.StarNote3.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#515151"));
                    this.StarNote4.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#515151"));
                    this.StarNote5.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#515151"));
                }
            }
            else
            {
                this.StarNote1.Icon       = FontAwesome.WPF.FontAwesomeIcon.StarOutline;
                this.StarNote2.Icon       = FontAwesome.WPF.FontAwesomeIcon.StarOutline;
                this.StarNote3.Icon       = FontAwesome.WPF.FontAwesomeIcon.StarOutline;
                this.StarNote4.Icon       = FontAwesome.WPF.FontAwesomeIcon.StarOutline;
                this.StarNote5.Icon       = FontAwesome.WPF.FontAwesomeIcon.StarOutline;
                this.StarNote1.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#515151"));
                this.StarNote2.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#515151"));
                this.StarNote3.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#515151"));
                this.StarNote4.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#515151"));
                this.StarNote5.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#515151"));
            }
        }
예제 #5
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);
        }