Esempio n. 1
0
        private void NewSortButtonClick(object sender, RoutedEventArgs e)
        {
            var sorted = elements.OrderBy(x => x.CreationDate).ToList();

            listItem.Items.Clear();
            for (int i = sorted.Count - 1; i >= 0; i--)
            {
                listItem.Items.Add(new ItemModel(ImageConvert.LoadImage(sorted[i].Image), sorted[i].Name, sorted[i].CreationDate.ToShortDateString(), sorted[i].Id, sorted[i].IsWatched));
            }
        }
Esempio n. 2
0
 private void NotWatchedButtonClick(object sender, RoutedEventArgs e)
 {
     listItem.Items.Clear();
     for (int i = 0; i < elements.Count; i++)
     {
         if (!elements[i].IsWatched)
         {
             listItem.Items.Add(new ItemModel(ImageConvert.LoadImage(elements[i].Image), elements[i].Name, elements[i].CreationDate.ToShortDateString(), elements[i].Id, elements[i].IsWatched));
         }
     }
 }
Esempio n. 3
0
        public RedactPage(Window window, int id)
        {
            InitializeComponent();
            this.window = window;
            this.id     = id;
            comboBoxType.Items.Add("Книга");
            comboBoxType.Items.Add("Фильм");
            comboBoxType.Items.Add("Сериал");
            comboBoxType.Items.Add("Аниме");
            comboBoxType.Items.Add("Другое...");

            comboBoxIsWatched.Items.Add("Да");
            comboBoxIsWatched.Items.Add("Нет");
            filePath = "";
            for (int i = 1; i <= 10; i++)
            {
                RateComboBox.Items.Add(i);
            }
            OtherTextBox.Visibility   = Visibility.Hidden;
            OtherTextBlock.Visibility = Visibility.Hidden;
            RateComboBox.Visibility   = Visibility.Hidden;
            RateText.Visibility       = Visibility.Hidden;
            using (var context = new CollectionContext())
            {
                for (int i = 0; i < context.Elements.Count(); i++)
                {
                    if (context.Elements.ToList()[i].Id == id)
                    {
                        imageContainer.Source     = ImageConvert.LoadImage(context.Elements.ToList()[i].Image);
                        comboBoxType.SelectedItem = context.Elements.ToList()[i].ElementType;
                        comboBoxType.Items.Add(context.Elements.ToList()[i].ElementType);

                        if (context.Elements.ToList()[i].IsWatched)
                        {
                            comboBoxIsWatched.SelectedItem = "Да";
                        }
                        else
                        {
                            comboBoxIsWatched.SelectedItem = "Нет";
                        }
                        LinkText.Text = context.Elements.ToList()[i].Link;
                        if (context.Elements.ToList()[i].Rate != null)
                        {
                            RateComboBox.SelectedItem = context.Elements.ToList()[i].Rate;
                        }
                        nameText.Text = context.Elements.ToList()[i].Name;
                    }
                }
                context.SaveChanges();
            }
        }
Esempio n. 4
0
 public OneElementPage(Window window, int id)
 {
     InitializeComponent();
     this.window = window;
     this.id     = id;
     using (var context = new CollectionContext())
     {
         for (int i = 0; i < context.Elements.Count(); i++)
         {
             if (context.Elements.ToList()[i].Id == id)
             {
                 image.Source     = ImageConvert.LoadImage(context.Elements.ToList()[i].Image);
                 nameElement.Text = context.Elements.ToList()[i].Name;
                 if (context.Elements.ToList()[i].Rate != null)
                 {
                     rateText.Text = "Оценка:" + context.Elements.ToList()[i].Rate.ToString();
                 }
                 else
                 {
                     rateText.Text = "Оценка:-";
                 }
                 if (context.Elements.ToList()[i].IsWatched)
                 {
                     watchedElement.Text = "Просмотрено";
                 }
                 else
                 {
                     watchedElement.Text = "Не просмотрено";
                 }
                 typeElement.Text = context.Elements.ToList()[i].ElementType;
                 linkElement.Text = context.Elements.ToList()[i].Link;
                 try
                 {
                     Uri myUri = new Uri(context.Elements.ToList()[i].Link, UriKind.Absolute);
                     hyperLink.NavigateUri = myUri;
                 }
                 catch
                 {
                 }
             }
         }
         context.SaveChanges();
     }
 }
Esempio n. 5
0
        private void SearchButtonClick(object sender, RoutedEventArgs e)
        {
            bool iFound = false;

            listItem.Items.Clear();
            for (int i = 0; i < elements.Count; i++)
            {
                if (searchName.Text.ToLower() == elements[i].Name.ToLower())
                {
                    iFound = true;
                    listItem.Items.Add(new ItemModel(ImageConvert.LoadImage(elements[i].Image), elements[i].Name, elements[i].CreationDate.ToShortDateString(), elements[i].Id, elements[i].IsWatched));
                }
            }
            if (!iFound)
            {
                listItem.Items.Clear();
                for (int i = 0; i < elements.Count; i++)
                {
                    listItem.Items.Add(new ItemModel(ImageConvert.LoadImage(elements[i].Image), elements[i].Name, elements[i].CreationDate.ToShortDateString(), elements[i].Id, elements[i].IsWatched));
                }
            }
        }
Esempio n. 6
0
 public ListItemsPage(Window window)
 {
     InitializeComponent();
     this.window = window;
     elements    = new List <CollectionElement>();
     using (var context = new CollectionContext())
     {
         for (int i = 0; i < context.Elements.Count(); i++)
         {
             ItemModel item = new ItemModel(ImageConvert.LoadImage(context.Elements.ToList()[i].Image), context.Elements.ToList()[i].Name, context.Elements.ToList()[i].CreationDate.ToShortDateString(), context.Elements.ToList()[i].Id, context.Elements.ToList()[i].IsWatched);
             listItem.Items.Add(item);
             CollectionElement el = new CollectionElement();
             el.Id           = context.Elements.ToList()[i].Id;
             el.Name         = context.Elements.ToList()[i].Name;
             el.CreationDate = context.Elements.ToList()[i].CreationDate;
             el.Image        = context.Elements.ToList()[i].Image;
             el.IsWatched    = context.Elements.ToList()[i].IsWatched;
             elements.Add(el);
         }
         context.SaveChanges();
     }
 }