Exemplo n.º 1
0
        protected Location(InfoGatherTask infoGatherTask, MediaFileState state)
        {
            MediaFileState = state;
            this.infoGatherTask = infoGatherTask;

            //state.NrImportedItemsChanged += new EventHandler<MediaStateChangedEventArgs>(importStateChanged);
                     
        }
        public MediaFileGridViewModel(MediaFileState mediaState, IEventAggregator eventAggregator)             
        {
            EventAggregator = eventAggregator;
            NrColumns = 4;

            MediaStateCollectionView = new MediaFileStateCollectionView(mediaState);       
            
            
            ViewCommand = new Command<SelectableMediaItem>((selectableItem) =>
            {
                MediaItem item = selectableItem.Item;

                if (item.Metadata is ImageMetadata)
                {
                    Shell.ShellViewModel.navigateToImageView(item);
                }
                else if (item.Metadata is VideoMetadata ||
                    item.Metadata is AudioMetadata)
                {
                    Shell.ShellViewModel.navigateToVideoView(item);
                }
            });

            SelectAllCommand = new Command(() =>
            {
                MediaStateCollectionView.selectAll();
            }, false);

            DeselectAllCommand = new Command(() =>
            {
                MediaStateCollectionView.deselectAll();
            });

            BrowseLocationCommand = new Command<SelectableMediaItem>((selectableItem) =>
                {
                    MediaItem item = selectableItem.Item;

                    String location = FileUtils.getPathWithoutFileName(item.Location);

                    EventAggregator.GetEvent<MediaBrowserPathChangedEvent>().Publish(location);
                });

            OpenLocationCommand = new Command<SelectableMediaItem>((selectableItem) =>
                {
                    MediaItem item = selectableItem.Item;

                    String location = FileUtils.getPathWithoutFileName(item.Location);

                    Process.Start(location);
                });

            WeakEventManager<MediaLockedCollection, EventArgs>.AddHandler(MediaStateCollectionView.MediaState.UIMediaCollection, "IsLoadingChanged", mediaCollection_IsLoadingChanged);

            PrevFilterMode = MediaFilterMode.None;
        }
        public ExportProgressViewModel(MediaFileState mediaFileState)
        {
            MediaFileState = mediaFileState;

            WindowTitle = "Exporting Media";
            WindowIcon = "pack://application:,,,/Resources/Icons/export.ico";
         
            ItemInfo = "";

            OkCommand.IsExecutable = false;
            CancelCommand.IsExecutable = true;
        }
Exemplo n.º 4
0
        public DirectoryLocation(DirectoryInfo info, InfoGatherTask infoGatherTask, MediaFileState mediaFileState)
            : base(infoGatherTask, mediaFileState)
        {        
            Name = info.Name;
            CreationDate = info.CreationTime;
                     
            VolumeLabel = "";

            //ImageUrl = "pack://application:,,,/Resources/Icons/mediafolder.ico";
            NrImported = 0;                    
                                           
            LazyLoading = true;
           
            PropertyChanged += propertyChanged;
        }
        public MediaFileStackPanelViewModel(MediaFileState mediaState, IEventAggregator eventAggregator)
        {
            MediaStateCollectionView = new MediaFileStateCollectionView(mediaState);

            initialize(eventAggregator);
        }
Exemplo n.º 6
0
 public RootLocation(InfoGatherTask infoGatherTask, MediaFileState mediaFileState) : base(infoGatherTask, mediaFileState)
 {            
     LazyLoading = true;
               
     mediaFileState.NrImportedItemsChanged += mediaFileState_NrImportedItemsChanged;
 }
Exemplo n.º 7
0
        public MediaFileStateCollectionView(MediaFileState mediaState = null) :
            base(mediaState)
        {
            Filter         = filterFunc;
            InfoIconsCache = InfoIconsCacheStatic;

            MediaFilter = MediaFilterMode.None;

            SortFunc = MediaFileSortFunctions.getSortFunction(MediaFileSortMode.Name);
            SortMode = MediaFileSortMode.Name;

            FilterModes = new ListCollectionView(Enum.GetValues(typeof(MediaFilterMode)));

            SortItemCollection <MediaFileSortItem, MediaFileSortMode> mediaFileSortItemCollection = new SortItemCollection <MediaFileSortItem, MediaFileSortMode>();

            mediaFileSortItemCollection.ItemSortDirectionChanged += mediaFileSortItemCollection_ItemSortDirectionChanged;

            foreach (MediaFileSortMode mode in Enum.GetValues(typeof(MediaFileSortMode)))
            {
                mediaFileSortItemCollection.Add(new MediaFileSortItem(mode));
            }

            SortModes = new ListCollectionView(mediaFileSortItemCollection);

            SortModes.CurrentChanged += (s, e) =>
            {
                MediaFileSortItem sortItem = (MediaFileSortItem)SortModes.CurrentItem;

                SortMode      = sortItem.SortMode;
                SortDirection = sortItem.SortDirection;

                SortFunc = MediaFileSortFunctions.getSortFunction(SortMode);

                refresh();
            };

            SortModes.Filter = mediaStateSortModeCollectionViewFilter;

            FilterModes.CurrentChanged += (s, e) =>
            {
                MediaFilter = (MediaFilterMode)FilterModes.CurrentItem;

                SortModes.Refresh();

                bool isRefreshed = false;

                switch (MediaFilter)
                {
                case MediaFilterMode.None:
                    if (!MediaFileSortFunctions.isAllSortMode(SortMode))
                    {
                        SortModes.MoveCurrentToFirst();
                        isRefreshed = true;
                    }
                    break;

                case MediaFilterMode.Video:
                    if (!MediaFileSortFunctions.isVideoSortMode(SortMode))
                    {
                        SortModes.MoveCurrentToFirst();
                        isRefreshed = true;
                    }
                    break;

                case MediaFilterMode.Images:
                    if (!MediaFileSortFunctions.isImageSortMode(SortMode))
                    {
                        SortModes.MoveCurrentToFirst();
                        isRefreshed = true;
                    }
                    break;

                case MediaFilterMode.Audio:
                    if (!MediaFileSortFunctions.isAudioSortMode(SortMode))
                    {
                        SortModes.MoveCurrentToFirst();
                        isRefreshed = true;
                    }
                    break;

                default:
                    break;
                }

                if (!isRefreshed)
                {
                    refresh();
                }
            };

            FilterModes.MoveCurrentTo(MediaFilterMode.None);
        }
        public MediaFileStateCollectionView(MediaFileState mediaState = null) :
            base(mediaState)
        {           
            Filter = filterFunc;
            InfoIconsCache = InfoIconsCacheStatic;

            MediaFilter = MediaFilterMode.None;           

            SortFunc = MediaFileSortFunctions.getSortFunction(MediaFileSortMode.Name);
            SortMode = MediaFileSortMode.Name;
            
            FilterModes = new ListCollectionView(Enum.GetValues(typeof(MediaFilterMode)));

            SortItemCollection<MediaFileSortItem, MediaFileSortMode> mediaFileSortItemCollection = new SortItemCollection<MediaFileSortItem,MediaFileSortMode>();
            mediaFileSortItemCollection.ItemSortDirectionChanged += mediaFileSortItemCollection_ItemSortDirectionChanged;

            foreach(MediaFileSortMode mode in Enum.GetValues(typeof(MediaFileSortMode))) {

                mediaFileSortItemCollection.Add(new MediaFileSortItem(mode));
            }

            SortModes = new ListCollectionView(mediaFileSortItemCollection);
         
            SortModes.CurrentChanged += (s, e) =>
            {
                MediaFileSortItem sortItem = (MediaFileSortItem)SortModes.CurrentItem;

                SortMode = sortItem.SortMode;
                SortDirection = sortItem.SortDirection;

                SortFunc = MediaFileSortFunctions.getSortFunction(SortMode);

                refresh();
            };

            SortModes.Filter = mediaStateSortModeCollectionViewFilter;

            FilterModes.CurrentChanged += (s, e) =>
            {
                MediaFilter = (MediaFilterMode)FilterModes.CurrentItem;
                              
                SortModes.Refresh();

                bool isRefreshed = false;

                switch (MediaFilter)
                {
                    case MediaFilterMode.None:
                        if (!MediaFileSortFunctions.isAllSortMode(SortMode))
                        {
                            SortModes.MoveCurrentToFirst();
                            isRefreshed = true;
                        }
                        break;
                    case MediaFilterMode.Video:
                        if (!MediaFileSortFunctions.isVideoSortMode(SortMode))
                        {
                            SortModes.MoveCurrentToFirst();
                            isRefreshed = true;
                        }
                        break;
                    case MediaFilterMode.Images:
                        if (!MediaFileSortFunctions.isImageSortMode(SortMode))
                        {
                            SortModes.MoveCurrentToFirst();
                            isRefreshed = true;
                        }
                        break;
                    case MediaFilterMode.Audio:
                        if (!MediaFileSortFunctions.isAudioSortMode(SortMode))
                        {
                            SortModes.MoveCurrentToFirst();
                            isRefreshed = true;
                        }
                        break;
                    default:
                        break;
                }

                if (!isRefreshed)
                {
                    refresh();
                }
       
            };
                                    
            FilterModes.MoveCurrentTo(MediaFilterMode.None);
            
        }
Exemplo n.º 9
0
        public DriveLocation(DriveInfo info, InfoGatherTask infoGatherTask, MediaFileState mediaFileState)
            : base(infoGatherTask, mediaFileState)
        {
           
            switch (info.DriveType)
            {
                case DriveType.CDRom:
                    {
                        ImageUrl = "pack://application:,,,/Resources/Icons/CD_Drive.ico";
                        VolumeLabel = "CD ROM";
                        break;
                    }
                case DriveType.Fixed:
                    {
                        ImageUrl = "pack://application:,,,/Resources/Icons/Hard_Drive.ico";

                        try
                        {
                            VolumeLabel = !String.IsNullOrEmpty(info.VolumeLabel) ? info.VolumeLabel : "Local Disk";
                        }
                        catch (Exception)
                        {

                        }

                        break;
                    }
                case DriveType.Network:
                    {
                        ImageUrl = "pack://application:,,,/Resources/Icons/Network_Drive.ico";
                        VolumeLabel = "Network Drive";
                        break;
                    }
                case DriveType.NoRootDirectory:
                    {
                        break;
                    }
                case DriveType.Ram:
                    {
                        ImageUrl = "pack://application:,,,/Resources/Icons/ram.ico";
                        VolumeLabel = "Ram Drive";
                        break;
                    }
                case DriveType.Removable:
                    {
                        ImageUrl = "pack://application:,,,/Resources/Icons/Removable_Drive.ico";
                        VolumeLabel = "Removable Drive";
                        break;
                    }
                case DriveType.Unknown:
                    {
                        ImageUrl = "pack://application:,,,/Resources/Icons/UnknownDrive.ico";
                        VolumeLabel = "Unknown Drive";
                        break;
                    }
            }

            Name = info.Name.TrimEnd(new char[] { '\\' });
          
            if (driveIdleMonitor.DrivesMonitored.Contains(Name))
            {
                FreeSpaceBytes = info.TotalFreeSpace;
                driveIdleMonitor.DriveInUse += new EventHandler<string>(driveIdleMonitor_driveInUse);
            }
            else
            {
                FreeSpaceBytes = 0;
            }

            infoGatherTask.addLocation(this);
          
            LazyLoading = true;


        }