Esempio n. 1
0
        public async void RefreshView()
        {
            try
            {
                // Show nothing if fileindex is outside what should be possible
                if (model.FileIndex < 0 || model.FileIndex > model.LoadedFiles.Count)
                {
                    view.window.imgMainContent = null;
                    return;
                }

                view.window.RefreshFolderList();
                StorageFile storageFile = model.LoadedFiles[model.FileIndex].file;

                // Prefix with =
                await SetFileIsSorted(storageFile);

                view.window.SetTitle("ReFiler - (" +
                                     (model.FileIndex + 1) + "/" + model.LoadedFiles.Count + ") - "
                                     + storageFile.Name);

                if (FilerModel.IsImageExtension(storageFile.Name))
                {
                    // Image
                    var bitmapImage = new BitmapImage();
                    bitmapImage.SetSource(await storageFile.OpenAsync(FileAccessMode.Read));
                    bitmapImage.DecodePixelHeight = (int)view.window.ContentGrid.ActualHeight;

                    // Set the image on the main page to the dropped image
                    view.window.imgMainContent.Source = bitmapImage;
                }
                else
                {
                    // Thumbnail

                    StorageItemThumbnail thumb =
                        await storageFile.GetScaledImageAsThumbnailAsync(ThumbnailMode.SingleItem);

                    if (thumb != null)
                    {
                        BitmapImage img = new BitmapImage();
                        await img.SetSourceAsync(thumb);

                        view.window.imgMainContent.Source = img;
                    }
                }

                UpdateInfobar();
            }
            catch (Exception e)
            {
                view.window.imgMainContent.Source = null;
                Debug.WriteLine("Error loading file\n" + e);
            }
        }
Esempio n. 2
0
        public MainPage()
        {
            this.InitializeComponent();
            Window.Current.CoreWindow.KeyDown += Page_KeyDown;

            model = new FilerModel();
            FilerView view = new FilerView(model, this);

            controller = new FilerController(model, view);

            SetTitle("ReFiler");

            model.UnloadAll();
            MostRecentlyOpened();
        }
Esempio n. 3
0
        public async void UpdateInfobar()
        {
            try
            {
                StorageFile file = model.LoadedFiles[model.FileIndex].file;
                string      info = "(" + (model.FileIndex + 1) + "/" + model.LoadedFiles.Count + ")";

                BasicProperties basicProperties = await file.GetBasicPropertiesAsync();

                info += " - " + FilerModel.BytesToString((long)basicProperties.Size);

                view.window.Infobar.FontStyle  = FontStyle.Normal;
                view.window.Infobar.Foreground = new SolidColorBrush(Colors.White);

                if (FilerModel.IsImageExtension(file.Name) && file.FileType.ToLower() != ".gif")
                {
                    BitmapImage dimensions = (BitmapImage)view.window.imgMainContent.Source;
                    int         height     = dimensions.PixelHeight;
                    int         width      = dimensions.PixelWidth;
                    info += " - ( " + width + " x " + height + " )";

                    if (height < 1000)
                    {
                        view.window.Infobar.FontStyle  = FontStyle.Italic;
                        view.window.Infobar.Foreground = new SolidColorBrush(Colors.Coral);
                    }
                }

                string location = file.Path.Replace(model.RootFolder.folder.Path, model.RootFolder.folder.Name);
                view.window.SetInfobar(info + "\n" + location);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Esempio n. 4
0
 public FilerView(FilerModel model, MainPage window)
 {
     this.model  = model;
     this.window = window;
 }
Esempio n. 5
0
 public FilerController(FilerModel model, FilerView view)
 {
     this.model = model;
     this.view  = view;
 }