Example #1
0
        private void SearchButton_Click(object sender, RoutedEventArgs e)
        {
            SearchViewModel searchViewModel = new SearchViewModel(SearchBox.Text);

            if (!searchViewModel.IsActive)
            {
                PictureListViewModel pictureListViewModel = new PictureListViewModel(BusinessLayer.GetAllPictures());
                ImageHolder.ItemsSource = BusinessLayer.PicturesToImages(BusinessLayer.GetAllPictures()); //TODO: Merge with above aka use ViewModel
                MainImageHolder.Content = ImageHolder.SelectedItem;
            }
            else if (!searchViewModel.IsSpecific && !searchViewModel.HasMultiple)
            {
                PictureListViewModel pictureListViewModel = new PictureListViewModel(BusinessLayer.GetPicturesOneParam(searchViewModel.Search));
                ImageHolder.ItemsSource = BusinessLayer.PicturesToImages(BusinessLayer.GetPicturesOneParam(searchViewModel.Search)); //TODO: Merge with above aka use ViewModel
                MainImageHolder.Content = ImageHolder.SelectedItem;
            }
            else if (!searchViewModel.IsSpecific && searchViewModel.HasMultiple)
            {
                PictureListViewModel pictureListViewModel = new PictureListViewModel(BusinessLayer.GetPicturesMultipleParams(searchViewModel.MultipleSearch));
                ImageHolder.ItemsSource = BusinessLayer.PicturesToImages(BusinessLayer.GetPicturesMultipleParams(searchViewModel.MultipleSearch)); //TODO: Merge with above aka use ViewModel
                MainImageHolder.Content = ImageHolder.SelectedItem;
            }
            else if (searchViewModel.IsSpecific)
            {
                throw new System.NotImplementedException();
            }
        }
Example #2
0
        private void Update_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            if (PhotographerListBox.SelectedItem != null && _photographerListViewModel.ValidBirthday && _photographerListViewModel.ValidFirstName && _photographerListViewModel.ValidSurname)
            {
                PhotographerViewModel vm = (PhotographerViewModel)PhotographerListBox.SelectedItem;

                if (BirthdayBox.SelectedDate <= DateTime.Today)
                {
                    vm.Birthday = BirthdayBox.SelectedDate;
                }
                if (SurnameBox.Text != "Surname" && SurnameBox.Text.Replace(" ", "").Length > 0)
                {
                    vm.Surname = SurnameBox.Text;
                }
                if (FirstnameBox.Text != "First Name" && FirstnameBox.Text.Replace(" ", "").Length > 0)
                {
                    vm.Name = FirstnameBox.Text;
                }
                if (_photographerListViewModel.ModifiedNotes)
                {
                    vm.Notes = NotesBox.Text;
                }

                BusinessLayer.UpdatePhotographer(vm);
                _photographerListViewModel = new PhotographerListViewModel(BusinessLayer.GetAllPhotographers());

                _photographerListViewModel.ValidBirthday  = true;
                _photographerListViewModel.ValidFirstName = true;
                _photographerListViewModel.ValidSurname   = true;

                PhotographerListBox.ItemsSource  = _photographerListViewModel.PhotographerViewModels;
                PhotographerListBox.SelectedItem = _photographerListViewModel.PhotographerViewModels[0];
            }
        }
Example #3
0
        private void Create_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            //This seems botchy, but currently you can bypass the "live" validity check with backspace, as this doesn't register as a keystroke, so we have to check it again for creation
            _photographerListViewModel.ValidFirstName = (SurnameBox.Text != "Surname" && SurnameBox.Text.Replace(" ", "").Length > 0);
            _photographerListViewModel.ValidSurname   = (FirstnameBox.Text != "First Name" && FirstnameBox.Text.Replace(" ", "").Length > 0);

            if (_photographerListViewModel.ValidBirthday && _photographerListViewModel.ValidFirstName && _photographerListViewModel.ValidSurname)
            {
                PhotographerViewModel vm = new PhotographerViewModel();

                if (BirthdayBox.SelectedDate <= DateTime.Today)
                {
                    vm.Birthday = BirthdayBox.SelectedDate;
                }

                vm.Surname = SurnameBox.Text;
                vm.Name    = FirstnameBox.Text;

                if (_photographerListViewModel.ModifiedNotes)
                {
                    vm.Notes = NotesBox.Text;
                }

                BusinessLayer.CreatePhotographer(vm);
                _photographerListViewModel       = new PhotographerListViewModel(BusinessLayer.GetAllPhotographers());
                PhotographerListBox.ItemsSource  = _photographerListViewModel.PhotographerViewModels;
                PhotographerListBox.SelectedItem = _photographerListViewModel.PhotographerViewModels[0];
            }
        }
Example #4
0
 public AdvancedSearchWindow(MainWindow sender, BusinessLayer BL)
 {
     DataContext = this;
     InitializeComponent();
     this.Sender        = sender;
     this.BL            = BL;
     this.SizeToContent = SizeToContent.WidthAndHeight;
 }
Example #5
0
        public static BusinessLayer GetInstance()
        {
            if (_instance == null)
            {
                _instance = new BusinessLayer();
            }

            return(_instance);
        }
Example #6
0
 //Events
 void changeImage(object sender, SelectionChangedEventArgs args)
 {
     if (ImageHolder.SelectedItem != null)
     {
         var image = BusinessLayer.CloneImage(ImageHolder.SelectedItem);
         MainImageHolder.Content = image;
         changeIPTC(image.Tag);
         changeEXIF(image.Tag);
     }
 }
Example #7
0
        void changeIPTC(object id)
        {
            var iptc = new IPTCViewModel(BusinessLayer.GetIPTC(id));

            LicenseBox.Text      = iptc.License ?? "Select License";
            CategoryBox.Text     = iptc.Category ?? "Category";
            KeyWordsBox.Text     = iptc.KeyWords ?? "KeyWords";
            PhotographerBox.Text = iptc.PhotographerName ?? "Select Photographer";
            NotesBox.Text        = iptc.Notes ?? "Notes...";
        }
Example #8
0
        void changeEXIF(object id)
        {
            var exif = new EXIFViewModel(BusinessLayer.GetEXIF(id));

            DateTimeBlock.Text    = exif.DateAndTime; // ?? "DD:MM:YYYY hh:mm:ss";
            OrientationBlock.Text = exif.Orientation; // ?? "XX°";
            FocalLengthBlock.Text = exif.FocalLength; // ?? "XXmm - YYmm";
            FNumberBlock.Text     = exif.FNumber;     // ?? "f/X.X";
            ExposureBlock.Text    = exif.Exposure;    // ?? "1/XXX or Y\"";
            IsoBlock.Text         = exif.Iso;         // ?? "XXX";
        }
Example #9
0
        public MainWindow()
        {
            BL = mwvmdl.Bl;
            BL.Sync();
            Watch();
            UpdatePhotographerList();
            UpdatePictureList(BL.GetPictures());

            Resources.Add("NamePart", NamePart);
            this.DataContext = mwvmdl;

            InitializeComponent();
        }
Example #10
0
        void saveIPTC(object id)
        {
            var iptc = new IPTCModel() //Skips ViewModelLayer
            {
                PictureId        = (int)id,
                License          = (string)(LicenseBox.SelectedItem ?? LicenseBox.Text),
                Category         = CategoryBox.Text,
                KeyWords         = KeyWordsBox.Text,
                PhotographerName = (string)(PhotographerBox.SelectedItem ?? PhotographerBox.Text),
                Notes            = NotesBox.Text
            };

            BusinessLayer.SaveIPTC(iptc);
        }
Example #11
0
        ///
        /// Initialization for the EditWindow
        ///
        public EditWindow()
        {
            InitializeComponent();
            _photographerListViewModel = new PhotographerListViewModel(BusinessLayer.GetAllPhotographers());

            _photographerListViewModel.ValidBirthday  = true;
            _photographerListViewModel.ValidFirstName = FirstnameBox.Text.Length <= 100;
            _photographerListViewModel.ValidSurname   = SurnameBox.Text.Length <= 50;

            FirstnameBox.Background = _photographerListViewModel.ValidFirstName ? _green : _red;
            SurnameBox.Background   = _photographerListViewModel.ValidSurname ? _green : _red;
            BirthdayBox.Background  = _photographerListViewModel.ValidBirthday ? _green : _red;
            NotesBox.Background     = _green;

            PhotographerListBox.ItemsSource = _photographerListViewModel.PhotographerViewModels;
        }
        private IEnumerable <IPictureViewModel> LoadPictureList()
        {
            BusinessLayer bl = new BusinessLayer();

            bl.Sync();
            var models = bl.GetPictures();

            List <PictureViewModel> pictureObjects = new List <PictureViewModel>();

            foreach (PictureModel model in models)
            {
                var pictureViewModelImpl = new PictureViewModel(model);
                pictureObjects.Add(pictureViewModelImpl);
            }

            return(pictureObjects);
        }
Example #13
0
        public PhotographerWindow_Edit(MainWindow sender, BusinessLayer BL)
        {
            Application curApp     = Application.Current;
            Window      mainWindow = curApp.MainWindow;

            if (mainWindow != null)
            {
                this.Left = mainWindow.Left + (mainWindow.ActualWidth - this.ActualWidth) / 2;
                this.Top  = mainWindow.Top + (mainWindow.ActualWidth - this.ActualHeight) / 2;
            }

            this.SizeToContent = SizeToContent.Height;
            this.Sender        = sender;
            this.BL            = BL;

            InitializeComponent();
        }
Example #14
0
        private void ReportsButton_Click(object sender, RoutedEventArgs e)
        {
            SearchViewModel searchViewModel = new SearchViewModel(SearchBox.Text);

            if (!searchViewModel.IsActive)
            {
                // do nothing
            }
            else if (!searchViewModel.IsSpecific && !searchViewModel.HasMultiple)
            {
                BusinessLayer.GetReportOneParam(searchViewModel.Search);
            }
            else if (!searchViewModel.IsSpecific && searchViewModel.HasMultiple)
            {
                BusinessLayer.GetReportMultipleParams(searchViewModel.MultipleSearch);
            }
            else if (searchViewModel.IsSpecific)
            {
                throw new System.NotImplementedException();
            }
        }
Example #15
0
        ///
        /// Initialization for the FileWindow
        ///
        public FileWindow()
        {
            InitializeComponent();
            Objects.ComboBox labelBoxDataContext = new Objects.ComboBox()
            {
                Name    = "Select License",
                Options = new List <string>()
                {
                    "Option 1",
                    "Option 2",
                    "Option 3",
                    "I don't have a license"
                }
            };
            LicenseBox.DataContext = labelBoxDataContext;

            PhotographerBox.Text        = "Select Photographer";
            PhotographerBox.ItemsSource = BusinessLayer.GetAllPhotographerNames();
            PictureListViewModel pictureListViewModel = new PictureListViewModel();

            ImageHolder.ItemsSource = pictureListViewModel.ImageList;
            MainImageHolder.Content = ImageHolder.SelectedItem;
        }
        /// <summary>
        /// Ladet die Photographers aus dem Configfile
        /// </summary>
        /// <returns></returns>
        private List <PhotographerViewModel> loadPhotographers()
        {
            BusinessLayer bl = new BusinessLayer();

            bl.Sync();
            var models = bl.GetPhotographers();
            List <PhotographerViewModel> list = new List <PhotographerViewModel>();

            if (models != null)
            {
                foreach (PhotographerModel model in models)
                {
                    var photographerViewModel = new PhotographerViewModel(model);
                    list.Add(photographerViewModel);
                }
            }

            //shit pfad
            string[]              lines = System.IO.File.ReadAllLines(@"C:\Users\Mausi\Desktop\SWE-PRUEFUNG\PicDB\photographers.config");
            PhotographerModel     p;
            PhotographerViewModel pvm;

            foreach (string line in lines)
            {
                string[] element = line.Split(';');
                p           = new PhotographerModel();
                p.FirstName = element[0];
                p.LastName  = element[1];
                p.Notes     = element[3];
                pvm         = new PhotographerViewModel(p);
                list.Add(pvm);
            }


            return(list);
        }
Example #17
0
        public void PdfReport(string tags)
        {
            BusinessLayer bl = new BusinessLayer();

            Dictionary <string, int> tagDict = bl.GetTagCount();

            string[] tagArray = tags.Split(';');

            for (int i = 0; i < tagArray.Length; i++)
            {
                tagArray[i] = tagArray[i].ToLower();
            }

            // Create a new PDF document
            PdfDocument document = new PdfDocument();

            document.Info.Title = tags;

            // Create an empty page
            PdfPage page = document.AddPage();

            // Get an XGraphics object for drawing
            XGraphics gfx = XGraphics.FromPdfPage(page);

            // Create a font
            XFont font = new XFont("Verdana", 10);


            gfx.DrawString("Tag: Count", font, XBrushes.Black,
                           new XRect(10, 0, page.Width, 10),
                           XStringFormats.TopLeft);

            gfx.DrawString("____________________", font, XBrushes.Black,
                           new XRect(10, 0, page.Width, 10),
                           XStringFormats.TopLeft);

            int textHeight = 20;

            if (String.IsNullOrWhiteSpace(tags))
            {
                foreach (KeyValuePair <string, int> valuePair in tagDict)
                {
                    // Draw the text
                    gfx.DrawString(valuePair.Key + ": " + valuePair.Value, font, XBrushes.Black,
                                   new XRect(10, textHeight, page.Width, 10),
                                   XStringFormats.TopLeft);

                    textHeight += 10;
                }
            }
            else
            {
                foreach (KeyValuePair <string, int> valuePair in tagDict)
                {
                    if (tagArray.Contains((valuePair.Key).ToLower()))
                    {
                        // Draw the text
                        gfx.DrawString(valuePair.Key + ": " + valuePair.Value, font, XBrushes.Black,
                                       new XRect(10, textHeight, page.Width, 10),
                                       XStringFormats.TopLeft);

                        textHeight += 10;
                    }
                }
            }



            if (String.IsNullOrWhiteSpace(tags))
            {
                document.Save(GlobalInformation.Path + "\\Reports\\reportalltags.pdf");
            }
            else
            {
                document.Save(GlobalInformation.Path + "\\Reports\\report" + tags + ".pdf");
            }
        }