public static VideoFolder SortList(SortType sorttype, VideoFolder parent)
        {
            if (parent.OtherFiles == null)
            {
                return(parent);
            }

            ObservableCollection <VideoFolder> asd = new ObservableCollection <VideoFolder>();

            if (sorttype == SortType.Date)
            {
                var de = (parent.OtherFiles).OrderBy(x => x, new SortByDate()).ToList();
                asd.AddRange(de);
                // parent.OtherFiles.Sort(new SortByDate());
            }
            else if (sorttype == SortType.Extension)
            {
                var de = parent.OtherFiles.OrderBy(x => x, new SortByExtension()).ToList();
                //ParentDir.ChildFiles.Sort();

                asd.AddRange(de);
            }
            else
            {
                var de = parent.OtherFiles.OrderBy(x => x, new SortByNames()).ToList();
                //ParentDir.ChildFiles.Sort();

                asd.AddRange(de);
            }
            parent.OtherFiles.Clear();
            parent.OtherFiles = asd;
            parent.SortedBy   = sorttype;
            return(parent);
        }
Example #2
0
 private void btnImportVideosTo_Click(object sender, EventArgs e)
 {
     if (VideoFolder.ShowDialog() == DialogResult.OK)
     {
         tbImportVideosTo.Text = VideoFolder.SelectedPath;
     }
 }
Example #3
0
        public VideoFolder SortList(SortType sorttype, VideoFolder parent)
        {
            lock (_lock)
            {
                if (parent.OtherFiles == null)
                {
                    return(parent);
                }

                ObservableCollection <VideoFolder> asd = new ObservableCollection <VideoFolder>();
                if (sorttype == SortType.Date)
                {
                    IEnumerable <VideoFolder> de = (parent.OtherFiles).OrderBy(x => x, new SortByDate());
                    asd.AddRange(de);
                }
                else if (sorttype == SortType.Extension)
                {
                    IEnumerable <VideoFolder> de = parent.OtherFiles.OrderBy(x => x, new SortByExtension());
                    asd.AddRange(de);
                }
                else
                {
                    IEnumerable <VideoFolder> de = parent.OtherFiles.OrderBy(x => x, new SortByNames());
                    asd.AddRange(de);
                }
                parent.OtherFiles.Clear();
                parent.OtherFiles = asd;
                //parent.SortedBy = sorttype;
                return(parent);
            }
        }
Example #4
0
        public VideoFolder LoadParentFiles(VideoFolder ParentDir, SortType sorttype)
        {
            if (ParentDir.HasCompleteLoad == true)
            {
                return(ParentDir);
            }

            ObservableCollection <VideoFolder> children;
            List <DirectoryInfo> ParentSubDir =
                filecommonhelper.GetParentSubDirectory(ParentDir.Directory, applicationService.Formats);

            if (ParentSubDir == null)
            {
                return(new VideoFolder(ParentDir, ""));
            }

            ParentDir.MediaFileWatcher = new MediaFileWatcher(ParentDir);

            children = new ObservableCollection <VideoFolder>();
            children = LoadChildrenFiles(ParentDir);

            LoadParentSubDirectories(ParentSubDir, children, ParentDir);

            if (ParentDir.OtherFiles == null || children.Count > ParentDir.OtherFiles.Count)
            {
                ParentDir.OtherFiles = new ObservableCollection <VideoFolder>();
                ParentDir.OtherFiles.AddRange(children);
                GetRootDetails(sorttype, ref ParentDir);
            }

            ParentDir.OnFileNameChangedChanged += ParentDir_OnFileNameChangedChanged;
            ParentDir.HasCompleteLoad           = true;
            return(ParentDir);
        }
Example #5
0
        private IEnumerable <BasicContent> CreateFoldersFromChannels(VideoFolder entryPoint)
        {
            var          type   = ContentTypeRepository.Service.Load <VideoFolder>();
            List <Album> albums = TwentyThreeVideoRepository.GetChannelList();

            foreach (var album in albums)
            {
                var folder = ContentFactory.Service.CreateContent(type, new BuildingContext(type)
                {
                    Parent            = entryPoint,
                    LanguageSelector  = LanguageSelector.AutoDetect(),
                    SetPropertyValues = true
                }) as VideoFolder;
                if (folder == null)
                {
                    continue;
                }
                if (album.AlbumId != null)
                {
                    var id = (int)album.AlbumId;
                    folder.ContentLink = new ContentReference(id, Constants.ProviderKey);
                    folder.Name        = album.Title;

                    var editorGroup = new EditorGroupChannelMappingRepository().GetEditorGroupForChannel(folder.Name);
                    if (!string.IsNullOrWhiteSpace(editorGroup))
                    {
                        folder.EditorGroup = editorGroup;
                    }

                    _log.Information("23Video: Channel {0} created.", album.Title);
                    yield return(folder);
                }
            }
        }
 public override void Delete()
 {
     if (DownloadState == DownloadState.Error || DownloadState == DownloadState.Ready)
     {
         return;
     }
     try {
         var title     = DownloadHelper.GetLegalPath(Title);
         var videoFile = VideoFolder.CreateFile(title + VideoExtension);
         if (videoFile.Exists())
         {
             videoFile.Delete();
         }
         if (MediaType == MediaType.Audio)
         {
             var audioFile = DownloadFolder.CreateFile(title + ".mp3");
             if (audioFile.Exists())
             {
                 audioFile.Delete();
             }
         }
     } catch { }
     base.Delete();
     UpdateStatus(DownloadState.Deleted);
 }
Example #7
0
        private void LoadOtherFileDetails(VideoFolder item, Dispatcher dispatcherunit)
        {
            if (item.FileType == FileType.Folder)
            {
                if (item.HasCompleteLoad)
                {
                    return;
                }
                var task = Task.Factory.StartNew(() => GetItems(item))
                           .ContinueWith(t => item = t.Result,
                                         TaskScheduler.Current);
                task.Wait();
            }
            else
            {
                var  itemchild = (VideoFolderChild)item;
                Task task      = Task.Factory.StartNew(() => {
                    dispatcherService.BeginInvokeDispatchAction(dispatcherunit, new Action(delegate
                    {
                        //itemchild.IsLoading = true;
                        FileLoader.GetShellInfo(itemchild);
                    }));
                })
                                 .ContinueWith(t =>
                {
                    //itemchild.IsLoading = false;
                    itemchild.UpdateProperties();
                }, TaskScheduler.Current);

                task.Wait();
                itemchild.IsLoading = false;
            }
        }
        private void MergeChanges(ObservableCollection <VideoFolder> folderlist)
        {
            if (UsbDrives == null || folderlist.Count == 0)
            {
                UsbDrives = new ObservableCollection <VideoFolder>();
            }

            foreach (var item in folderlist)
            {
                VideoFolder videoFolder = item;
                if (UsbDrives.Contains(videoFolder))
                {
                    continue;
                }
                var existingfolder = MovieDataStore.GetExistingCopy(videoFolder);
                if (existingfolder != null)
                {
                    UsbDrives.Add(existingfolder);
                }
                else
                {
                    UsbDrives.Add(videoFolder);
                }

                //videoFolder.IsLoading = true;
            }
            if (UsbDrives.Count == 0)
            {
                HasNoFolderAction();
                return;
            }
            //StartFileLoading();
        }
        protected override void OnContextMenuOpening(ContextMenuEventArgs e)
        {
            base.OnContextMenuOpening(e);
            FrameworkElement uIElement = e.OriginalSource as FrameworkElement;

            this.VideoFolder = uIElement.DataContext as VideoFolder;
        }
        private void OpenFolderCommandAction(object obj)
        {
            VideoFolder videoFolder = (VideoFolder)obj;

            if (videoFolder.Exists)
            {
                if (videoFolder.FileType == FileType.Folder)
                {
                    this.navigationService.Navigate(new FilePageView(this.navigationService), obj);
                }
                else
                {
                    openFileCaller.Open(videoFolder as IVideoData);
                }
            }
            else
            {
                while (this.navigationService.CanGoBack)
                {
                    if (navigationService.Content is IMainPage)
                    {
                        break;
                    }
                    this.navigationService.GoBack();
                }
            }
        }
Example #11
0
 private void ParentDir_OnFileNameChangedChanged(string oldname, VideoFolder videoItem)
 {
     if (MovieDataSource.DataSource != null && MovieDataSource.DataSource.ContainsKey(oldname))
     {
         MovieDataSource.DataSource.Remove(oldname);
         MovieDataSource.DataSource.Add(videoItem.FullName, videoItem);
     }
 }
 public void Add(VideoFolder vfc)
 {
     if (!this.PlayList.Contains(vfc))
     {
         this.PlayList.Add(vfc);
         HasChanges = true;
     }
 }
 public void Remove(VideoFolder vfc)
 {
     if (this.PlayList.Contains(vfc))
     {
         this.PlayList.Remove(vfc);
         HasChanges = true;
     }
 }
 private VideoFolder GetVideoFolder(VideoFolder obj)
 {
     if (obj.HasCompleteLoad)
     {
         return(obj);
     }
     return(fileLoader.LoadParentFiles(obj, ActiveSortType));
 }
Example #15
0
        public VideoFolder GetFolderItems(VideoFolder item)
        {
            item.IsLoading = true;
            List <Task> Tasks   = new List <Task>();
            object      padlock = new object();

            lock (item)
            {
                int taskcount = 0;
                if (item.OtherFiles == null)
                {
                    var s = LoadParentFiles(item, item.SortedBy);
                    if (s.OtherFiles == null)
                    {
                        return(s);
                    }
                }
                try
                {
                    Parallel.ForEach(item.OtherFiles, (s) =>
                    {
                        var temp = s;
                        if (temp.FileType == FileType.Folder)
                        {
                            var task = Task.Factory.StartNew(() =>
                            {
                                temp.IsLoading = true;
                                GetFolderItemsExtended(temp);
                                temp.IsLoading = false;
                            });
                            taskcount++;
                            AddTask(Tasks, task, padlock);
                        }
                        //else
                        //{
                        //    var task = Task.Factory.StartNew(() =>
                        //    {
                        //        RunShellFunction(temp as VideoFolderChild);
                        //    });
                        //    taskcount++;
                        //    AddTask(Tasks, task, padlock);
                        //}
                        if (taskcount % 5 == 0 && taskcount != 0)
                        {
                            Task.WaitAll(Tasks.ToArray());
                            taskcount = 0;
                            Tasks.Clear();
                        }
                    });
                }
                catch (Exception ex)
                {
                }
            }
            item.IsLoading = false;
            return(item);
        }
        private static VideoFolder LoadDirInfo(IFolder parent, DirectoryInfo directoryInfo)
        {
            VideoFolder vd = new VideoFolder(parent, directoryInfo.FullName)
            {
                FileType = FileType.Folder
            };

            return(vd);
        }
Example #17
0
        public VideoFolder GetExistingVideoFolderIfAny(VideoFolder videoFolder)
        {
            VideoFolder folder = null;

            if (MovieDataSource.DataSource != null)
            {
                MovieDataSource.DataSource.TryGetValue(videoFolder.FullName, out folder);
            }
            return(folder);
        }
Example #18
0
        public VideoFolder DeepCopy(VideoFolder existing, VideoFolder videoFoldercopy)
        {
            var newcopy = new VideoFolder(videoFoldercopy, videoFoldercopy.FullName)
            {
                OtherFiles      = videoFoldercopy.OtherFiles,
                HasCompleteLoad = videoFoldercopy.HasCompleteLoad,
                SortedBy        = videoFoldercopy.SortedBy
            };

            return(newcopy);
        }
Example #19
0
        public VideoFolder LoadParentFiles(VideoFolder Parentdir, IList <DirectoryInfo> SubDirectory, SortType sorttype)
        {
            VideoFolder videoFolder = new VideoFolder(Parentdir, SubDirectory[0].Parent.FullName);
            var         children    = new ObservableCollection <VideoFolder>();

            LoadParentSubDirectories(SubDirectory, children, videoFolder);
            videoFolder.OtherFiles = children;
            GetFolderItems(videoFolder);
            MovieDataSource.InitFileLoading();
            return(videoFolder);
        }
Example #20
0
        private void OpenFolderCommandAction(object obj)
        {
            VideoFolder videoFolder = (VideoFolder)obj;

            if (videoFolder.FileType == FileType.Folder)
            {
                this.navigationService.Navigate(new FilePageView(this.navigationService), obj);
            }
            else
            {
                openFileCaller.Open(videoFolder as IVideoData, searchresults.OfType <VideoFolderChild>());
            }
        }
Example #21
0
        public void FinishCollectionLoadProcess(ObservableCollection <VideoFolder> itemsSource, bool IsMovieFolder)
        {
            dispatcherService.InvokeDispatchAction(new Action(delegate
            {
                for (int i = 0; i < itemsSource.Count(); i++)
                {
                    VideoFolder VideoFolder = itemsSource[i];
                    if (VideoFolder.HasCompleteLoad)
                    {
                        continue;
                    }

                    if (!VideoFolder.HasCompleteLoad && fileloader.HasDataSource)
                    {
                        var videofolder = fileloader.GetExistingVideoFolderIfAny(VideoFolder);
                        if (videofolder != null)
                        {
                            itemsSource[i].SetParentDirectory(videofolder.ParentDirectory);
                            itemsSource.Remove(VideoFolder);
                            itemsSource.Insert(i, videofolder);
                            continue;
                        }
                    }

                    if (VideoFolder.ParentDirectory != null)
                    {
                        VideoFolder videoFoldercopy = null;
                        VideoFolder ExistingParent  =
                            MovieDataSource.GetExistingCopy((VideoFolder)VideoFolder.ParentDirectory);
                        if (ExistingParent != null && ExistingParent.OtherFiles != null)
                        {
                            videoFoldercopy =
                                ExistingParent.OtherFiles.Where(j => j.Equals(VideoFolder)).FirstOrDefault();
                        }

                        if (videoFoldercopy == null)
                        {
                            VideoFolder.IsLoading = true;
                        }
                        else
                        {
                            itemsSource.Remove(VideoFolder);
                            itemsSource.Insert(i, videoFoldercopy);
                            //MergeSameVideoData(ref videoFolder, videoFoldercopy);
                        }
                    }
                    //SearchSubtitleFile(list[i]);
                }
            }));
        }
Example #22
0
        public VideoFolder LoadParentFiles(VideoFolder Parentdir, IList <FileInfo> SubFiles, SortType sorttype)
        {
            VideoFolder videoFolder = new VideoFolder(Parentdir, SubFiles[0].Directory.FullName);

            var children = new ObservableCollection <VideoFolder>();

            children = LoadChildrenFiles(videoFolder, SubFiles);
            videoFolder.OtherFiles    = children;
            videoFolder.HasSubFolders = false;
            GetFolderItems(videoFolder);
            MovieDataSource.InitFileLoading();

            return(videoFolder);
        }
        private List <string> GetListPath(VideoFolder vfc)
        {
            var listpath = new List <string>();
            var padlock  = new object();

            Parallel.ForEach(vfc.OtherFiles.Where(s => s is VideoFolderChild), (s) => {
                lock (padlock)
                {
                    listpath.Add(s.FullName);
                }
            });

            return(listpath);
        }
        private void AddTo_executed(object sender, ExecutedRoutedEventArgs e)
        {
            var         selectedplaylist = e.Parameter as PlaylistModel;
            VideoFolder vf = ((e.OriginalSource as Button).DataContext as VideoFolder);

            if (selectedplaylist.IsActive && vf != null)
            {
                IPlayFile.AddFiletoPlayList(vf);
            }
            else
            {
                selectedplaylist.Add(vf.FullName);
            }
        }
Example #25
0
        private VideoFolder GetSubFolderItems(VideoFolder videoFolder)
        {
            List <Task> Tasks = new List <Task>();

            Console.WriteLine("------Starting to Load {0} item-----", videoFolder);

            var s = LoadParentFiles(videoFolder, videoFolder.SortedBy);

            if (s.OtherFiles == null)
            {
                return(s);
            }
            int taskcount = 0;

            Parallel.ForEach(s.OtherFiles, (k) =>
            {
                try
                {
                    var temp = k;
                    if (temp.FileType == FileType.Folder)
                    {
                        temp.IsLoading = true;
                        GetSubFolderItems(temp);
                        temp.IsLoading = false;
                    }
                    //else
                    //{
                    //    taskcount++;
                    //    var task = Task.Factory.StartNew(() =>
                    //    {
                    //        RunShellFunction(temp as VideoFolderChild);
                    //    }).ContinueWith(t => { }, TaskScheduler.Default);
                    //    Tasks.Add(task);
                    //}
                    //if (taskcount % 3 == 0)
                    //{
                    //    Task.WaitAll(Tasks.ToArray());
                    //    taskcount = 0;
                    //    Tasks.Clear();
                    //}
                }
                catch (Exception ex)
                {
                }
            });
            Console.WriteLine("------Finished loading {0} item-----", videoFolder);

            return(s);
        }
Example #26
0
        private void AddTo_executed(object sender, ExecutedRoutedEventArgs e)
        {
            var         selectedplaylist = e.Parameter as PlaylistModel;
            VideoFolder vf = ((e.Source as IFileViewer).FileExplorer as IFileExplorer)
                             .ContextMenuObject as VideoFolder;

            if (selectedplaylist.IsActive)
            {
                IPlayFile.AddFiletoPlayList(vf);
            }
            else
            {
                selectedplaylist.Add(vf.Directory.FullName);
            }
        }
        private ObservableCollection <VideoFolder> GetObservableCollection(PlaylistModel plm)
        {
            ObservableCollection <VideoFolder> list = new ObservableCollection <VideoFolder>();

            foreach (var item in plm.ItemsPaths)
            {
                //Dispatcher.Invoke(new Action(delegate
                //{
                DirectoryInfo directoryInfo = new DirectoryInfo(item);
                VideoFolder   vfc           = FileLoader.LoadChildrenFiles(directoryInfo);
                list.Add(vfc);
                //}));
            }
            return(list);
        }
 private static void DeleteFile(object sender, string fullPath)
 {
     DispatcherService.InvokeDispatchAction(new Action(() =>
     {
         var Mediafolder         = ((MediaFileWatcher)sender).MediaFolder;
         VideoFolder videoFolder = new VideoFolder(fullPath);
         var existingVideoFolder = Mediafolder.OtherFiles.Where(x => x.Equals(videoFolder)).FirstOrDefault();
         if (Mediafolder.OtherFiles.Contains(videoFolder))
         {
             Mediafolder.OtherFiles.Remove(existingVideoFolder);
         }
         FileLoader.RemoveFromDataSource(existingVideoFolder);
         RefreshMediaFolder(sender);
     }));
 }
        public void OnDrop(DragEventArgs e)
        {
            //base.OnDrop(e);
            VideoFolder vf = (VideoFolder)e.Data.GetData(typeof(VideoFolder));

            if (vf == null)
            {
                vf = (VideoFolder)e.Data.GetData(typeof(VideoFolderChild));
            }
            if (vf == null)
            {
                if (MediaControllerVM.CurrentVideoItem != null)
                {
                    String[] filePathInfo = (String[])e.Data.GetData("FileName", false);
                    for (int i = 0; i < filePathInfo.Length; i++)
                    {
                        FileInfo file = new FileInfo(filePathInfo[i]);
                        if (file.Extension == ".srt")
                        {
                            SubtitleFilesModel.Add(MediaControllerVM.CurrentVideoItem.SubPath,
                                                   file.FullName);
                        }
                    }
                    ISubtitleMediaController.Subtitle.LoadSub(MediaControllerVM.CurrentVideoItem.SubPath.First());
                    return;
                }
            }
            if (vf.FileType == FileType.Folder)
            {
                VideoFolder vfc = null;
                foreach (VideoFolder item in vf.OtherFiles)
                {
                    if (item.FileType == FileType.File)
                    {
                        vfc = item;
                        break;
                    }
                }
                if (vfc == null)
                {
                    return;
                }
                MediaControllerVM.GetVideoItem(vfc as VideoFolderChild);
                return;
            }
            MediaControllerVM.GetVideoItem(vf as VideoFolderChild);
            CommandManager.InvalidateRequerySuggested();
        }
Example #30
0
 private void AddToNav(VideoFolder obj)
 {
     if (Search != null)
     {
         CancelSearchAction();
     }
     TrimNav();
     activeindex++;
     this.DirectoryPosition = obj.Directory;
     this.VideoDataAccess   = obj;
     Navigation.Add(new NavigationModel {
         Dir = DirectoryPosition, VideoData = VideoDataAccess
     });
     CheckCanExecut();
     CheckSort();
 }