Пример #1
0
        // Handle download button clicked
        private void Download_Btn_Click(object sender, RoutedEventArgs e)
        {
            FileDisplay fd = ((FrameworkElement)sender).DataContext as FileDisplay;

            // Download
            using (WebClient client = new WebClient())
            {
                client.DownloadFileAsync(new Uri(fd.File), Properties.Settings.Default.DownloadLocation + fd.Filename);
            }
        }
Пример #2
0
        // Handle opening the file
        private void OpenFile_Btn_Click(object sender, RoutedEventArgs e)
        {
            FileDisplay fd = ((FrameworkElement)sender).DataContext as FileDisplay;

            currentFile   = fd;
            currentFileId = downloadedFiles.IndexOf(fd);

            BrowserWindow.Address     = fd.File;
            CloseImageView.Visibility = Visibility.Visible;
            Display_Flyout.IsOpen     = true;
        }
Пример #3
0
        // Handle keyboard shortcuts
        private void MetroWindow_KeyDown(object sender, KeyEventArgs e)
        {
            if (Display_Flyout.IsOpen)
            {
                switch (e.Key)
                {
                case Key.A:
                    BrowserWindow.Address = FilesCollection[(CurrentFileId - 1).Clamp(0, FilesCollection.Count - 1)].File;
                    CurrentFileId         = (CurrentFileId - 1).Clamp(0, FilesCollection.Count - 1);

                    CurrentFile = FilesCollection[CurrentFileId];

                    FileIndexTxt.Text = CurrentFileId + 1 + "/" + TotalFiles;

                    SetImage(CurrentFile);
                    break;

                case Key.D:
                    BrowserWindow.Address = FilesCollection[(CurrentFileId + 1).Clamp(0, FilesCollection.Count - 1)].File;
                    CurrentFileId         = (CurrentFileId + 1).Clamp(0, FilesCollection.Count - 1);

                    CurrentFile = FilesCollection[CurrentFileId];

                    // If nearing the end, fetch more
                    if (CurrentFileId >= FilesCollection.Count - 3)
                    {
                        FetchBtn_Click(sender, new RoutedEventArgs());
                    }

                    FileIndexTxt.Text = CurrentFileId + 1 + "/" + TotalFiles;

                    SetImage(CurrentFile);
                    break;

                case Key.W:
                    using (WebClient client = new WebClient())
                    {
                        client.DownloadFileAsync(new Uri(CurrentFile.File), _settings.DownloadLocation + CurrentFile.Filename);
                    }
                    break;

                case Key.E:
                    InfoGrid.Visibility = InfoGrid.Visibility == Visibility.Collapsed ? Visibility.Visible : Visibility.Collapsed;
                    break;

                case Key.Escape:
                    CloseImageView_Click(sender, new RoutedEventArgs());
                    break;
                }
            }
        }
Пример #4
0
        // Handle download button clicked
        private void Download_Btn_Click(object sender, RoutedEventArgs e)
        {
            FileDisplay fd = CurrentFile;

            // Download
            using (WebClient client = new WebClient())
            {
                if (fd != null)
                {
                    client.DownloadFileAsync(new Uri(fd.File),
                                             _settings.DownloadLocation + fd.Filename);
                }
            }
        }
Пример #5
0
        // Handle opening the file
        private void OpenFile_Btn_Click(object sender, RoutedEventArgs e)
        {
            FileDisplay fd = ((FrameworkElement)sender).DataContext as FileDisplay;

            CurrentFile       = fd;
            CurrentFileId     = FilesCollection.IndexOf(fd);
            FileIndexTxt.Text = CurrentFileId + 1 + "/" + TotalFiles;

            //Set infogrid
            SetImage(fd);

            CloseImageView.Visibility    = Visibility.Visible;
            ToggleInfogridBtn.Visibility = Visibility.Visible;
            FileIndexTxt.Visibility      = Visibility.Visible;

            Display_Flyout.IsOpen = true;
        }
Пример #6
0
        // Set Infogrid
        private void SetImage(FileDisplay fd)
        {
            //tags
            TagsCollection.Clear();
            if (fd != null)
            {
                foreach (string s in fd.Tags)
                {
                    TagsCollection.Add(s);
                }

                BrowserWindow.Address = fd.File;
            }
            else
            {
                throw new NullReferenceException("File was null!");
            }

            //artist
            Info_Artist.Text      = fd.Author;
            Info_Description.Text = fd.Description;
        }