コード例 #1
0
        public void ClearCache()
        {
            FileToIconConverter fic = this.Resources["fic"] as FileToIconConverter;

            //Clear Thumbnail only, icon is not cleared.
            fic.ClearInstanceCache();
        }
コード例 #2
0
        public Window1()
        {
            InitializeComponent();
            model       = new Model(this);
            DataContext = model;
            model.Path  = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            FileToIconConverter fic = this.Resources["fic"] as FileToIconConverter;

            fic.DefaultSize = 200;
            list.AddHandler(ListViewItem.PreviewMouseDownEvent, new MouseButtonEventHandler(list_MouseDown));
        }
コード例 #3
0
        private ImageSource GetFileIcon(Google.Apis.Drive.v2.Data.File file)
        {
            ImageSource src = null;

            if (IsFolder(file))
            {
                src = (ImageSource)App.Current.FindResource("gdriveFolder");
            }
            else
            {
                if (file.MimeType == GDOC_DOCUMENT_MIME)
                {
                    src = (BitmapImage)App.Current.FindResource("gdocWord");
                }
                else if (file.MimeType == GDOC_PRESENTATION_MIME)
                {
                    src = (BitmapImage)App.Current.FindResource("gdocPowerPoint");
                }
                else if (file.MimeType == GDOC_SPREADSHEET_MIME)
                {
                    src = (BitmapImage)App.Current.FindResource("gdocExcel");
                }
                else
                {
                    if (file.FileExtension == null)
                    {
                        file.FileExtension = "";
                        var lastDot = file.Title.LastIndexOf(".");
                        if (lastDot != -1)
                        {
                            file.FileExtension = file.Title.Substring(lastDot, file.Title.Length - lastDot);
                        }
                    }

                    FileToIconConverter conv = (FileToIconConverter)App.Current.FindResource("iconConv");
                    src = conv.GetImage(file.FileExtension, 64);
                }
            }
            return(src);
        }
コード例 #4
0
ファイル: FolderFullVM.cs プロジェクト: sevenate/nfm
        /// <summary>
        /// Fetch data from corresponding folder model and its childs folder and files.
        /// </summary>
        public override void Refresh()
        {
            base.Refresh();

            IList <IViewModel> list = new List <IViewModel>();

            foreach (DirectoryInfo folder in Model.Folders(Folder.FullName))
            {
                var vm = new FolderVM(Model)
                {
                    AbsolutePath = folder.FullName
                };

                vm.Refresh();
                list.Add(vm);
            }

            foreach (FileInfo file in Model.Files(Folder.FullName))
            {
                var vm = new FileVM(Model)
                {
                    AbsolutePath = file.FullName
                };

                vm.Refresh();
                list.Add(vm);
            }

            // Sorting by file extenshion and, then, by file name.
            // TODO: make it configurable: sorting childs
            IOrderedEnumerable <IViewModel> sortedList =
                list.OrderBy(vm => vm is FileVM)
                .ThenBy(
                    vm => (vm is FileVM)
                                                ? ((FileVM)vm).Extension.ToLowerInvariant()
                                                : string.Empty)
                .ThenBy(
                    vm => (vm is FileVM)
                                                ? ((FileVM)vm).Name.ToLowerInvariant()
                                                : string.Empty);
            // -- TODOEND --

            // TODO: remove this temporary "parent simulator" from childs collection
            // and make it separate in UI and code, but navigatable like always.
            IEnumerable <IViewModel> resultList = Enumerable.Empty <IViewModel>();

            var fullVM = NavigateOut();
            var parent = new ParentNodeVM(fullVM)
            {
                AbsolutePath = ((IViewModel)fullVM).AbsolutePath
            };

            resultList = Enumerable.Repeat((IViewModel)parent, 1);

            resultList = resultList.Concat(sortedList);
            // -- TODOEND --

            OnPropertyChanging("Childs");
            childs.Clear();
            childs = new ObservableCollection <IViewModel>(resultList);
            OnPropertyChanged("Childs");

            if (CurrentItemIndex == -1 && childs.Count > 0)
            {
                CurrentItemIndex = 0;
            }

            Header.Text = Name;

            var imageConverter = new FileToIconConverter
            {
                DefaultSize = 16
            };

            Header.Icon = imageConverter.GetImage(AbsolutePath, 16);
        }