示例#1
0
        public void display()
        {
            keepImageNumberInsideRange();

            string imagePath = imageFolder + System.IO.Path.GetFileName(filesInFolder[imageNumber]);

            try
            {
                var uri = new Uri(imagePath);
                // if the image is found (name is correct)
                var bitmap = new BitmapImage(uri);
                image.Source = bitmap;
            }
            catch (FileNotFoundException)
            {
                notificationsWindow notificationsWindow = new notificationsWindow();
                notificationsWindow.textBlockMessage.Text = "Oops! No images in this Folder!";
                notificationsWindow.Show();

                variables.currentWindow = variables.previousCurrentWindow;
                this.Close();
            }
            catch (IndexOutOfRangeException)
            {
                notificationsWindow notificationsWindow = new notificationsWindow();
                notificationsWindow.textBlockMessage.Text = "Oops! No images in this Folder!";
                notificationsWindow.Show();

                variables.currentWindow = variables.previousCurrentWindow;
                this.Close();
            }
        }
示例#2
0
        public folderOfImagesWindow()
        {
            InitializeComponent();

            imageFolder = variables.currentSubDirectorySelected + "//";


            filesInFolder = Directory.GetFiles(variables.currentSubDirectorySelected);
            numberOfFiles = filesInFolder.Length;


            imageNumber = 5;
            try
            {
                display();
            }
            catch (IndexOutOfRangeException)
            {
                notificationsWindow notificationsWindow = new notificationsWindow();
                notificationsWindow.textBlockMessage.Text = "Oops! No images in this Folder!";
                notificationsWindow.Show();

                // this was causing the problem in the following scenario
                // 1) open empty folder 2) go out of range 3) control is retained normally but not going to main screen
                // 1) open empty folder 2) open another folder 3) control not retained and not going to main screen
                //variables.currentWindow = variables.previousCurrentWindow;
                this.Close();
            }
        }