Exemple #1
0
        private void cmdExisting_Click(object sender, EventArgs e)
        {
            FileBrowseResult res = Dialogs.ShowOpenCalidusProjectFileDialog(this);

            if (res.IsOk)
            {
                SelectedProjectFile = res.SelectedFile;
                DisplayMainWindow(res.SelectedFile, false);
            }
        }
Exemple #2
0
        private void cmdNew_Click(object sender, EventArgs e)
        {
            FileBrowseResult res = Dialogs.ShowSaveCalidusProjectFileDialog(this);

            if (res.IsOk)
            {
                SelectedProjectFile = res.SelectedFile;
                IsNewProject        = true;

                File.Delete(res.SelectedFile);
                CalidusProjectManager projectManager = new CalidusProjectManager();
                projectManager.Write(new CalidusProject(res.SelectedFile));

                DisplayMainWindow(res.SelectedFile, true);
            }
        }
Exemple #3
0
        /// <summary>
        /// Retrieve the files in all registered 7MC movie library folders, with extensions from Settings.Default.VideoFileExtensions
        /// </summary>
        /// <returns></returns>
        static FileBrowseResult GetMoviesInMovieLibrary()
        {
            FileBrowseResult output = new FileBrowseResult();

            CreateShellHelperIfNull();

            output.Directories = new List <BrowseItem>();

            MCLibraryFolderHelper fHelper      = new MCLibraryFolderHelper();
            List <string>         movieFolders = fHelper.MediaCenterLibraryFolders(MCLibraryFolderHelper.Libraries.Movie);

            List <string>     VideoFilters = filtersForMediaType(MediaFileTypes.Video);
            List <BrowseItem> filesFound   = new List <BrowseItem>();

            foreach (string movieFolder in movieFolders)
            {
                browseFolderForFiles(movieFolder, ref filesFound, VideoFilters, true);
            }

            // Now add recorded TV shows that are movies
            foreach (TVProgramme tvp in RecTV.Default.RecordedTVProgrammes.Values)
            {
                if (tvp.ProgramType != TVProgrammeType.Movie)
                {
                    continue;                                            // movies only
                }
                FileInfo   fi      = new FileInfo(tvp.Filename);
                BrowseItem newItem = fileInfoToBrowseItem(fi, true, true);
                filesFound.Add(newItem);
            }

            // Sort the list of movies alphabetically by filename (NAME not file path, path is stripped away by the comparer)
            CommonEPG.Comparers.BrowseItemComparer bComparer = new CommonEPG.Comparers.BrowseItemComparer();
            filesFound.Sort(bComparer);
            output.Files = filesFound;

            // Set base directory flag
            output.BaseDirectory = "MOVIE_LIBRARY";
            output.Success       = true;

            sHelper = null;

            return(output);
        }
Exemple #4
0
        static string HTMLTableForPicturesLibrary(FileBrowseResult fbrs, int numberOfColumns, int pageNumber, int itemsPerPage, bool showThumbnails)
        {
            List <string> content = new List <string>();

            foreach (BrowseItem strFolder in fbrs.Directories)
            {
                string cellContent = "";

                // Link
                string folderPath = Path.Combine(fbrs.BaseDirectory, strFolder.Name);
                folderPath = Functions.EncodeToBase64(folderPath);

                string    folderImageSource = "/static/images/imgFolder150x75.png";
                HTMLImage image             = new HTMLImage(folderImageSource, "folderpic");
                cellContent += image.ToString();
                cellContent += "<br />";
                cellContent += Path.GetFileName(strFolder.Name);


                HTMLLink lnk = new HTMLLink("browsepics?PATH=" + folderPath, cellContent);

                content.Add(lnk.ToString());
            }
            foreach (BrowseItem strFile in fbrs.Files)
            {
                // Assemble path to file
                string filePath = Path.Combine(fbrs.BaseDirectory, strFile.Name);
                filePath = Functions.EncodeToBase64(filePath);

                string    imgSrc = "getfilethumbnail64?filename=" + filePath + "&size=medium";
                HTMLImage image  = new HTMLImage(imgSrc, "thumbnail");


                // Link
                HTMLLink lnk = new HTMLLink("viewpic?FN=" + filePath + "&size=extralarge", image.ToString());

                content.Add(lnk.ToString());
            }

            return(HTMLTable.HTMLTableWithCellContents("picturelibrarytable", numberOfColumns, content));
        }
Exemple #5
0
        static FileBrowseResult GetFoldersForLibrary(string libraryName, List <string> Filters) // music, videos, pictures, documents
        {
            FileBrowseResult output = new FileBrowseResult();

            CreateShellHelperIfNull();

            try
            {
                List <String> folders = new List <string>();
                folders = FoldersForLibrary(libraryName);

                foreach (string folder in folders)
                {
                    BrowseItem folderItem = stringToBrowseItem(folder, true, Filters);
                    if (folderItem != null)
                    {
                        output.Directories.Add(folderItem);
                    }
                }

                output.ErrorText = "OK";
                output.Success   = true;
            }
            catch (ArgumentException)
            {
                output.Success   = false;
                output.ErrorText = "NO LIBRARY";
            }
            catch (Exception ex)
            {
                output.Success   = false;
                output.ErrorText = ex.Message;
            }

            sHelper = null;
            return(output);
        }
Exemple #6
0
        public static bool SendFolderFilesAsZipFile(FileBrowseResult fbResult, ref BrowserSender bSender)
        {
            // We'll need a shell helper
            CreateShellHelperIfNull();

            // Set up temp directory
            string tempFolderName = Path.GetRandomFileName();
            string tempPath       = Path.Combine(Functions.ZipTempFolder, tempFolderName);

            Directory.CreateDirectory(tempPath);

            // Any files?
            if (fbResult.Files.Count < 1)
            {
                return(false);
            }

            List <string> outputFiles = new List <string>();

            foreach (BrowseItem bItem in fbResult.Files)
            {
                string strFullPath = Path.Combine(fbResult.BaseDirectory, bItem.Name);
                outputFiles.Add(strFullPath);
            }

            // Now zip up the files
            string strOutputZipFile = Path.Combine(Functions.ZipTempFolder, (Path.GetFileNameWithoutExtension(Path.GetRandomFileName()) + ".zip"));
            bool   result           = ZipHelper.CreateZipFileFromFiles(outputFiles, strOutputZipFile);

            // And send the zip file to the browser
            result &= (bSender.SendFileToBrowser(strOutputZipFile, false, false, true));
            File.Delete(strOutputZipFile);
            Directory.Delete(tempPath, true);

            return(result);
        }
Exemple #7
0
        private void _view_Open(object sender, EventArgs e)
        {
            if (HasChanges)
            {
                Confirm confirm = _view.ConfirmSaveChanges();
                if (confirm == Confirm.Yes)
                {
                    SaveProject();
                }

                if (confirm == Confirm.Cancel)
                {
                    return;
                }
            }

            FileBrowseResult openResult = _view.OpenProjectFile();

            if (openResult.IsOk && !String.IsNullOrEmpty(openResult.SelectedFile))
            {
                _project.SetProject(_projectManager.ReadFrom(openResult.SelectedFile));
                HasChanges = false;
            }
        }
Exemple #8
0
        public static FileBrowseResult BrowsePath(string FullPath, List <string> Filters, bool getMediaDuration)
        {
            // Libraries
            if (FullPath.Equals("VIDEO_LIBRARY"))
            {
                return(GetFoldersForLibrary("videos", Filters));
            }
            if (FullPath.Equals("DOCUMENTS_LIBRARY"))
            {
                return(GetFoldersForLibrary("documents", Filters));
            }
            if (FullPath.Equals("MUSIC_LIBRARY"))
            {
                return(GetFoldersForLibrary("music", Filters));
            }
            if (FullPath.Equals("PICTURES_LIBRARY"))
            {
                return(GetFoldersForLibrary("pictures", Filters));
            }

            // 'Faux' library (collection)
            if (FullPath.Equals("MOVIE_LIBRARY"))
            {
                return(GetMoviesInMovieLibrary());
            }

            FileBrowseResult output = new FileBrowseResult();

            output.BaseDirectory = FullPath;

            // Exists
            if (!Directory.Exists(FullPath))
            {
                output.ErrorText = "Directory not found.";
                output.Success   = false;
                return(output);
            }

            if (Filters.Count < 1)
            {
                Filters = new List <string>()
                {
                    "*.*"
                }
            }
            ;

            DirectoryInfo masterDi = new DirectoryInfo(FullPath);

            // 1. Files
            List <FileInfo> tempOutputFiles = new List <FileInfo>();

            foreach (string filter in Filters)
            {
                tempOutputFiles.AddRange(masterDi.GetFiles(filter));
            }

            // Sort by name
            var orderedFiles = tempOutputFiles.OrderBy(f => f.Name);

            if (getMediaDuration)
            {
                CreateShellHelperIfNull();                    // use a shell helper to get duration of media files
            }
            foreach (FileInfo fi in orderedFiles)
            {
                output.Files.Add(fileInfoToBrowseItem(fi, getMediaDuration, false));
            }
            sHelper = null;

            // 2. Directories
            DirectoryInfo[] directoryInfos     = masterDi.GetDirectories();
            var             orderedDirectories = directoryInfos.OrderBy(d => d.Name);

            foreach (DirectoryInfo di in orderedDirectories)
            {
                output.Directories.Add(directoryInfoToBrowseItem(di, Filters));
            }

            // Success
            output.Success   = true;
            output.ErrorText = "OK";
            return(output);
        }
Exemple #9
0
        // VIDS library
        public static string HTMLTableForVideoLibrary(string strPath, int numberOfColumns)
        {
            FileBrowseResult fbrs = BrowsePath(strPath, MediaFileTypes.Video, false); // no need to get duration in HTML

            return(HTMLTableForVideoLibrary(fbrs, numberOfColumns, 0, 50, true));
        }
Exemple #10
0
        // PICS library
        public static string HTMLTableForPicturesLibrary(string strPath, int numberOfColumns)
        {
            FileBrowseResult fbrs = BrowsePath(strPath, MediaFileTypes.Image);

            return(HTMLTableForPicturesLibrary(fbrs, numberOfColumns, 0, 50, true));
        }
Exemple #11
0
        public static bool SendThumbnailsAsZipFile(FileBrowseRequest request, ThumbnailSizes thumbSize, ref BrowserSender bSender)
        {
            // We'll need a shell helper
            FatAttitude.ShellHelper sh = new FatAttitude.ShellHelper();

            // Set up temp directory
            string tempFolderName = Path.GetRandomFileName();
            string tempPath       = Path.Combine(Functions.ZipTempFolder, tempFolderName);

            Directory.CreateDirectory(tempPath);

            // Go through the thumbnails (filter already applied, so these are pic files)
            FileBrowseResult fbResult = FileBrowseExporter.BrowsePath(request.FullPath, request.Filters);

            // Any files?
            if (fbResult.Files.Count < 1)
            {
                return(false);
            }

            int           SkipCounter   = 0;
            int           OutputCounter = 0;
            List <string> outputFiles   = new List <string>();

            foreach (BrowseItem bItem in fbResult.Files)
            {
                // Skip items before batch
                if (request.ThumbnailsLimitToBatch)
                {
                    if (request.ThumbnailsBatch > 0)
                    {
                        if (SkipCounter++ < (request.ThumbnailsBatchSize * request.ThumbnailsBatch))
                        {
                            continue;
                        }
                    }
                }

                string strFullPath = Path.Combine(fbResult.BaseDirectory, bItem.Name);
                string strLog      = ""; // ignore log
                Bitmap bmp         = sh.ThumbnailForFile(strFullPath, thumbSize, ref strLog);

                string fnSansExtension       = Path.GetFileNameWithoutExtension(bItem.Name);
                string strOutputFileFullPath = Path.Combine(tempPath, (fnSansExtension + "_thumb.jpg"));
                bmp.Save(strOutputFileFullPath, ImageFormat.Jpeg);

                outputFiles.Add(strOutputFileFullPath);

                // End of batch?
                if (request.ThumbnailsLimitToBatch)
                {
                    if (OutputCounter++ >= request.ThumbnailsBatchSize)
                    {
                        break;
                    }
                }
            }

            // Now zip up the files
            string strOutputZipFile = Path.Combine(Functions.ZipTempFolder, (Path.GetFileNameWithoutExtension(Path.GetRandomFileName()) + ".zip"));
            bool   result           = ZipHelper.CreateZipFileFromFiles(outputFiles, strOutputZipFile);

            // And send the zip file to the browser
            result &= (bSender.SendFileToBrowser(strOutputZipFile));
            File.Delete(strOutputZipFile);
            Directory.Delete(tempPath, true);

            return(result);
        }