Exemplo n.º 1
0
        private void Media_MediaOpened(object sender, RoutedEventArgs e)
        {
            Media.LoadedBehavior = MediaState.Manual;
            Media.Pause();
            PlayButton.Content = "Play";
            if (Media.NaturalDuration.HasTimeSpan)
            {
                UpdateLog($"Open File Succeess\n");
                ShellFile shellFile = ShellFile.FromFilePath(Media.Source.LocalPath);
                var       width     = shellFile.Properties.System.Video.FrameWidth.Value.Value;
                var       height    = shellFile.Properties.System.Video.FrameHeight.Value.Value;
                mediaInfo = new MediaInfo((uint)Media.NaturalVideoWidth, (uint)Media.NaturalVideoHeight, Media.NaturalDuration.TimeSpan.TotalSeconds, (uint)(shellFile.Properties.System.Video.FrameRate.Value / 1000), width, height);
                rect      = new Rect(mediaInfo, Media);
                UpdateRect();
                FromTextBox.Text  = "0.0";
                ToTextBox.Text    = mediaInfo.Duration.ToString();
                ScaleTextBox.Text = "-1:-1";
                FpsTextBox.Text   = mediaInfo.FrameRate.ToString();
                Slider.Maximum    = mediaInfo.Duration;
                fpsSec            = 1.0 / mediaInfo.FrameRate;

                //Update Media Info
                var info = new StringBuilder($"File Name : {System.IO.Path.GetFileName(Media.Source.LocalPath)}\n");
                info.Append($"Width : {mediaInfo.Width}\n");
                info.Append($"Height : {mediaInfo.Height}\n");
                info.Append($"Width Factor : {mediaInfo.WidthFactor.ToString("0.000")}\n");
                info.Append($"Height Factor : {mediaInfo.HeightFactor.ToString("0.000")}\n");
                info.Append($"Duration : {TimeSpan.FromSeconds(mediaInfo.Duration).ToString(@"mm\:ss")}\n");
                info.Append($"Fps : {mediaInfo.FrameRate}\n");
                info.Append($"Frame/sec : {fpsSec.ToString("0.000")} sec\n");
                FileInfoTextBlock.Text = info.ToString();
            }
        }
Exemplo n.º 2
0
        public Object getThumbnail(string uniqueName)
        {
            FolderBAL fb           = new FolderBAL();
            FileDTO   filedto      = fb.GetFileByUniqueID(uniqueName);
            var       rootPath     = HttpContext.Current.Server.MapPath("~/UploadedFiles");
            var       fileFullPath = System.IO.Path.Combine(rootPath, uniqueName);

            ShellFile shellFile  = ShellFile.FromFilePath(fileFullPath);
            Bitmap    shellThumb = shellFile.Thumbnail.SmallBitmap;

            if (filedto != null)
            {
                HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
                byte[]       file            = ImageToBytes(shellThumb);
                MemoryStream ms = new MemoryStream(file);
                response.Content = new ByteArrayContent(file);
                response.Content.Headers.ContentDisposition          = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment");
                response.Content.Headers.ContentType                 = new System.Net.Http.Headers.MediaTypeHeaderValue(filedto.ContentTpye);
                response.Content.Headers.ContentDisposition.FileName = filedto.FileUniqueName;
                return(response);
            }
            else
            {
                HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.NotFound);
                return(response);
            }
        }
Exemplo n.º 3
0
        private void objectListView1_SelectionChanged(object sender, EventArgs e)
        {
            if (objectListView1.SelectedItem != null)
            {
                string selectedItemName = ((PartToImport)objectListView1.SelectedItem.RowObject).name;

                selectedItemName = selectedItemName + ".ipt";

                Autodesk.Connectivity.WebServices.File    webServicesFile = selectedFiles.FirstOrDefault(sel => sel.Name == selectedItemName);
                VDF.Vault.Currency.Entities.FileIteration fileIter        = new Vault.Currency.Entities.FileIteration(connection, webServicesFile);

                picBoxIpt.Image = ResizeImage(getThumbNail(fileIter), 115, 115);

                string selectedSymName = symFolder + System.IO.Path.GetFileNameWithoutExtension(selectedItemName) + ".sym";

                if (System.IO.File.Exists(selectedSymName))
                {
                    ShellFile shellFile  = ShellFile.FromFilePath(selectedSymName);
                    Bitmap    shellThumb = shellFile.Thumbnail.Bitmap;
                    this.picBoxSym.Image = ResizeImage(shellThumb, 115, 115);
                }
                else
                {
                    this.picBoxSym.Image = null;
                }

                toolStripStatusLabel.Text = "";
                progressBar.Value         = 0;

                objectListView1.Refresh();
            }
        }
Exemplo n.º 4
0
        private void Icon_OnMouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            Icon icon = sender as Icon;

            if (icon == null || icon.IsRenaming)
            {
                return;
            }

            icon.CaptureMouse();
            ShellFile file = icon.DataContext as ShellFile;

            LastIconSelected = icon;

            if (InvokeContextMenu(file, true))
            {
                e.Handled = true;

                if (LastIconSelected != null && LastIconSelected.IsRenaming)
                {
                    LastIconSelected = null;

                    // user selected rename, so keep things open
                    return;
                }

                LastIconSelected = null;

                Close();
            }
        }
Exemplo n.º 5
0
        protected override void ParseFile()
        {
            if (IsVideoFile())
            {
                Type = MediaType.Video;
            }
            else if (IsPhotoFile())
            {
                Type = MediaType.Image;
            }
            else
            {
                Type = MediaType.Unknown;
            }

            try
            {
                var file = ShellFile.FromFilePath(sourceFile.FullName);
                Taken       = file.Properties.System.Photo.DateTaken.Value ?? file.Properties.System.Media.DateEncoded.Value;
                CameraMake  = file.Properties.System.Photo.CameraManufacturer.Value;
                CameraModel = file.Properties.System.Photo.CameraModel.Value;
                if (Type == MediaType.Unknown && !string.IsNullOrEmpty(CameraMake))
                {
                    Type = MediaType.Image;
                }
            }
            catch (Exception ex)
            {
                Type = MediaType.Unknown;
                Console.WriteLine($"Error: {ex.Message}");
            }
        }
Exemplo n.º 6
0
        static void SetProps()
        {
            var    file     = ShellFile.FromFilePath(_filePath);
            string oldTitle = file.Properties.System.Title.Value;

            file.Properties.System.Title.Value = "Example Title";  //this replaces the existing title with null
        }
Exemplo n.º 7
0
        public HttpResponseMessage GetThumbnail([FromUri] FilesDTO fileDTO)
        {
            HttpResponseMessage response = null;

            fileDTO = FilesBAL.GetFileByFileIdAndUserId(fileDTO.Id, fileDTO.CreatedBy);
            if (fileDTO == null)
            {
                response = Request.CreateResponse(HttpStatusCode.NotFound);
            }
            else
            {
                string path = HttpContext.Current.Server.MapPath("~/Uploads/" + fileDTO.Name);
                if (!File.Exists(path))
                {
                    response = Request.CreateResponse(HttpStatusCode.NotFound);
                }
                ShellFile    shellFile  = ShellFile.FromFilePath(path);
                Bitmap       shellThumb = shellFile.Thumbnail.MediumBitmap;
                byte[]       file       = ImageToBytes(shellThumb);
                MemoryStream ms         = new MemoryStream(file);

                response         = Request.CreateResponse(HttpStatusCode.OK);
                response.Content = new ByteArrayContent(file);
                response.Content.Headers.ContentDisposition          = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment");
                response.Content.Headers.ContentDisposition.FileName = fileDTO.Name;
            }
            return(response);
        }
Exemplo n.º 8
0
        public static List <ExtFileInfo> GetExtendedFileInfo(string fileWithPath)
        {
            List <ExtFileInfo> retVal = new List <ExtFileInfo>();
            var fill = ShellFile.FromFilePath(fileWithPath);

            foreach (var prop in fill.Properties.DefaultPropertyCollection)
            {
                if (prop.ValueAsObject != null)
                {
                    ExtFileInfo newInfo = new ExtFileInfo();
                    newInfo.PropertyKey   = prop.PropertyKey.ToString();
                    newInfo.PropertyName  = prop.CanonicalName;
                    newInfo.PropertyValue = prop.ValueAsObject;

                    string value = string.Empty;
                    if (prop.ValueType == typeof(string[]))
                    {
                        string[] arrays = prop.ValueAsObject as string[];
                        value = string.Join(";", arrays);
                    }
                    else
                    {
                        value = string.Format("{0}", prop.ValueAsObject ?? "null");
                    }
                    newInfo.PropertyValueAsString = value;
                    m_Log.Trace("File:{0} {1}={2}", Path.GetFileName(fileWithPath), prop.CanonicalName, value);
                }
            }
            return(retVal);
        }
Exemplo n.º 9
0
 public static Bitmap GetIconFromFileOrFolder(FileSystemInfo file)
 {
     try
     {
         if (file is FileInfo f)
         {
             using (ShellFile shFile = ShellFile.FromFilePath(f.FullName))
                 return(shFile.Thumbnail.SmallBitmap);
         }
         else if (file is DirectoryInfo d)
         {
             using (ShellFileSystemFolder shFile = ShellFileSystemFolder.FromFolderPath(d.FullName))
                 return(shFile.Thumbnail.SmallBitmap);
         }
         else
         {
             throw new InvalidOperationException();
         }
     }
     catch (Exception)
     {
         Console.WriteLine("[ERROR] Could not open file for icon read");
         throw;
     }
 }
Exemplo n.º 10
0
        public Object getThumbnail(string uniqueName)
        {
            fileBA  fileBAObj    = new fileBA();
            fileDTO fileObj      = fileBAObj.getFile(uniqueName);
            var     rootPath     = HttpContext.Current.Server.MapPath("~/UploadedFiles");
            var     fileFullPath = System.IO.Path.Combine(rootPath, fileObj.uniqueName + fileObj.fileExt);

            ShellFile shellFile  = ShellFile.FromFilePath(fileFullPath);
            Bitmap    shellThumb = shellFile.Thumbnail.MediumBitmap;

            if (fileObj != null)
            {
                HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
                byte[]       file            = ImageToBytes(shellThumb);
                MemoryStream ms = new MemoryStream(file);
                response.Content = new ByteArrayContent(file);
                response.Content.Headers.ContentDisposition          = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment");
                response.Content.Headers.ContentType                 = new System.Net.Http.Headers.MediaTypeHeaderValue(fileObj.contentType);
                response.Content.Headers.ContentDisposition.FileName = fileObj.name;
                return(response);
            }
            else
            {
                HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.NotFound);
                return(response);
            }
        }
Exemplo n.º 11
0
        /// <summary>
        ///     Initialize a instance of the <see cref="ShellStream" /> class.
        /// </summary>
        /// <param name="shellFile"><See cref="ShellFile" /> in the file to read or write in the stream.</param>
        public ShellStream(ShellFile shellFile)
        {
            Contract.Requires <ArgumentNullException>(shellFile != null);

            this.ShellFile       = shellFile;
            this.StreamInterface = this.ShellFile.ShellItem.GetStream();
        }
Exemplo n.º 12
0
        private void Icon_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            Icon icon = sender as Icon;

            if (icon == null || icon.IsRenaming)
            {
                return;
            }

            e.Handled = true;

            ShellFile file = icon.DataContext as ShellFile;

            if (file == null || string.IsNullOrWhiteSpace(file.Path))
            {
                CairoMessage.Show(DisplayString.sError_FileNotFoundInfo, DisplayString.sError_OhNo, MessageBoxButton.OK,
                                  CairoMessageImage.Error);
                return;
            }

            if (!InvokeContextMenu(file, false))
            {
                CairoMessage.Show(DisplayString.sError_FileNotFoundInfo, DisplayString.sError_OhNo, MessageBoxButton.OK,
                                  CairoMessageImage.Error);
            }
        }
Exemplo n.º 13
0
        public Image icoExtReturner(string path, string sfn, bool lgIco)
        {
            if (path.Contains(".lnk") || path.Contains(".exe"))
            {
                return(checkAppPreInv(path, sfn, lgIco));
            }
            else if (path.Contains(".wav"))
            {
                return(getAlbumArtwork(path, "wav"));
            }
            else if (path.Contains(".mp3"))
            {
                return(getAlbumArtwork(path, "mp3"));
            }
            else
            {
                if (lgIco)
                {
                    ShellFile sf = ShellFile.FromFilePath(path);
                    sf.Thumbnail.FormatOption = ShellThumbnailFormatOption.IconOnly;
                    Bitmap pfmBitmap = sf.Thumbnail.LargeBitmap;
                    pfmBitmap.MakeTransparent();

                    return(pfmBitmap);
                }
                else
                {
                    /*ShellFile sf = ShellFile.FromFilePath(path);
                     * return sf.Thumbnail.SmallIcon.ToBitmap();*/

                    return(Icon.ExtractAssociatedIcon(path).ToBitmap());
                }
            }
        }
Exemplo n.º 14
0
        private void addDiscriptionToFile(string filePath, string titel, string[] tags, string comment)
        {
            var file = ShellFile.FromFilePath(filePath);

            file.Properties.System.Title.Value   = titel;
            file.Properties.System.Comment.Value = comment;

            file.Properties.System.Media.Year.Value = 2017;

            using (var writer = file.Properties.GetPropertyWriter())
            {
                writer.WriteProperty(file.Properties.System.Keywords, tags, true);
                writer.Close();
            }

            file.Properties.System.Author.Value = new string[] { "Szymon Szomiński" };


            // Read and Write:

            //foreach (var item in file.Properties.DefaultPropertyCollection)
            //{
            //    ShellProperty<uint?> porp = item as ShellProperty<uint?>;

            //    if (porp != null)
            //    {

            //        Console.WriteLine(string.Format("{0} Value: {1}", "", porp.Value.ToString()));
            //    }
            //}
        }
Exemplo n.º 15
0
        public async Task loadTitles(IProgress <int> progress, CancellationToken ct, ProgressBar prg)
        {
            ArtistNames.Clear();
            int mprogress = 0; // integer variable for progress report

            prg.Value = 0;
            int totalFiles = System.IO.Directory.EnumerateFiles(GlobalData.Config.DataPath, "*.jpg", SearchOption.AllDirectories).Count();

            foreach (string line in System.IO.Directory.EnumerateFiles(GlobalData.Config.DataPath, "*.jpg", SearchOption.AllDirectories))
            {
                if (!ct.IsCancellationRequested)
                {
                    mprogress += 1;
                    progress.Report((mprogress * 100 / totalFiles));
                    ShellFile item = ShellFile.FromFilePath(line);

                    ArtistNames.Add(new ArtistData
                    {
                        Name = item.Properties.System.Title.Value,
                        Tag  = line
                    });
                    await Task.Delay(5);
                }
            }
        }
        public Image GetThumbnail(string fullFileName)
        {
            Bitmap image = null;

            if (File.Exists(fullFileName))
            {
                ShellFile shellFile = ShellFile.FromFilePath(fullFileName);
                try
                {
                    shellFile.Thumbnail.FormatOption = ShellThumbnailFormatOption.ThumbnailOnly;
                    image = shellFile.Thumbnail.ExtraLargeBitmap;
                }
                catch (Exception ex)
                {
                    Logger.Trace("Shell Thumbnail failed " + fullFileName + " " + ex.Message);
                }

                try
                {
                    if (image == null)
                    {
                        image = shellFile.Thumbnail.LargeBitmap;
                    }
                }
                catch (Exception ex)
                {
                    Logger.Trace("Shell Thumbnail failed " + fullFileName + " " + ex.Message);
                }

                try
                {
                    if (image == null)
                    {
                        image = shellFile.Thumbnail.MediumBitmap;
                    }
                }
                catch (Exception ex)
                {
                    Logger.Trace("Shell Thumbnail failed " + fullFileName + " " + ex.Message);
                }

                try
                {
                    if (image == null)
                    {
                        image = shellFile.Thumbnail.SmallBitmap;
                    }
                }
                catch (Exception ex)
                {
                    Logger.Trace("Shell Thumbnail failed " + fullFileName + " " + ex.Message);
                }
            }
            else
            {
                Logger.Error("File doesn't exist anymore. " + fullFileName);
            }

            return(image);
        }
        public static ShellContextMenu FromShellFile(ShellFile shellFile)
        {
            Contract.Requires <ArgumentNullException>(shellFile != null);

            var shellFolder = shellFile.Folder;

            if (shellFolder == null)
            {
                return(null);
            }

            // 対象ファイルの親フォルダーからの相対PIDLを取得する。
            var filePIDL = shellFolder.ShellFolderItem.ParseDisplayName(shellFile.Name);

            // IContextMenuへのポインターを取得する。
            var contextMenuPtr = shellFolder.ShellFolderItem.GetUIObjectOf(filePIDL, ShellIID.IContextMenu);

            // IContextMenu3へのポインターを取得する。
            IntPtr contextMenuPtr3;
            var    riid3 = new Guid(ShellIID.IContextMenu2);

            Marshal.QueryInterface(contextMenuPtr, ref riid3, out contextMenuPtr3);
            var contextMenu3 = (IContextMenu3)Marshal.GetTypedObjectForIUnknown(contextMenuPtr3, typeof(IContextMenu3));

            return(new ShellContextMenu(contextMenu3));
        }
Exemplo n.º 18
0
        public IEnumerable <MatchAttach> GetAttachsByIDAndType(int id, string type)
        {
            var context = ContextHelper.CreateContext <MatchEntities>();
            var result  = new List <MatchAttach>();

            context.attaches.Where(l => l.Type == type && l.TypeID == id).ToList().ForEach(l =>
            {
                var attach = l.CopyTo <MatchAttach>();
                try
                {
                    attach.URL  = new Uri(HttpContext.Current.Request.Url, l.Path).AbsoluteUri;
                    var path    = System.IO.Path.Combine(HttpContext.Current.Server.MapPath("~"), l.Path);
                    attach.Size = new System.IO.FileInfo(path).Length;
                    var file    = ShellFile.FromFilePath(path);
                    System.IO.MemoryStream ms = new System.IO.MemoryStream();
                    file.Thumbnail.MediumBitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                    attach.Thumbnail = ms.ToArray();
                }
                catch (Exception e) { }
                finally
                {
                    result.Add(attach);
                }
            });
            return(result);
        }
Exemplo n.º 19
0
        public void NavigateToFolderOrArchive(string url)
        {
            if (string.IsNullOrEmpty(InitDirectory))
            {
                InitDirectory = url;
            }

            try
            {
                // navigate to specific folder
                this.explorerBrowser.Navigate(ShellFileSystemFolder.FromFolderPath(url));
            }
            catch
            {
                try
                {
                    // Navigates to a specified file (must be a container file to work, i.e., ZIP, CAB)
                    this.explorerBrowser.Navigate(ShellFile.FromFilePath(url));
                }
                catch (Exception)
                {
                    logError("Navigation not possible.");
                }
            }
        }
Exemplo n.º 20
0
        private void Cv_Selected(object sender, RoutedEventArgs e)
        {
            CoverViewItem    selectedCover      = sender as CoverViewItem;
            ContentPresenter myContentPresenter = FindVisualChild <ContentPresenter>(selectedCover);

            DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;
            Image        selectedImg    = (Image)myDataTemplate.FindName("ImageHeader", myContentPresenter);
            ShellFile    file           = ShellFile.FromFilePath(selectedImg.Tag.ToString());

            try
            {
                string country = string.Empty;
                if (file.Properties.System.Keywords.Value[1].Equals("Empty"))
                {
                    country = "Location Unknown";
                }
                else
                {
                    country = file.Properties.System.Keywords.Value[1];
                }

                shTitle.Status   = file.Properties.System.Title.Value;
                shSubject.Status = file.Properties.System.Subject.Value;
                shCountry.Status = country;
                shCity.Status    = file.Properties.System.Keywords.Value[0];
                shGallery.Status = file.Properties.System.Comment.Value;
                shDate.Status    = file.Properties.System.Keywords.Value[9] ?? file.Properties.System.Keywords.Value[8];
            }
            catch (IndexOutOfRangeException)
            {
            }
        }
Exemplo n.º 21
0
        private void UpdateFileRating(PlexRatingsData currentFile)
        {
            uint?fileRating     = RatingsManager.FileRating(currentFile.file);
            int? plexFileRating = RatingsManager.PlexRatingFromFile(currentFile.file);
            int? plexDbRating   = (int?)currentFile.rating;

            uint?newRating = Convert.ToUInt32(RatingsManager.FileRatingFromPlexRating(plexDbRating));

            if (newRating == 0)
            {
                newRating = null;
            }

            string message = string.Format("Updating file rating for file \"{0}\", from {1} to {2}",
                                           currentFile.file,
                                           fileRating == null ? 0 : fileRating,
                                           newRating == null ? 0 : newRating);

            ShellFile so = ShellFile.FromFilePath(currentFile.file);

#if DEBUG
            Debug.Print(message);
#else
            so.Properties.System.Rating.Value = newRating;
#endif

            MessageManager.Instance.MessageWrite(this, MessageItem.MessageLevel.Information, message);
        }
Exemplo n.º 22
0
        private static string MarkAsDuplicate(FileInfo file, List <FileInfo> files)
        {
            var index    = file.Name.IndexOf(" - ");
            var artist   = file.Name.Substring(0, index);
            var ext      = file.Name.Split('.').Last();
            var title    = file.Name.Substring(index + 3, file.Name.Length - (index + 3)).Replace($".{ext}", "");
            var filename = file.Name.Replace(ext, "");

            //TODO:

            var count      = 0;
            var localFiles = files.Where(f => !f.Equals(file)).Where(f => f.Name.StartsWith(artist)).ToList();

            foreach (var localFile in localFiles)
            {
                var localTitle = ShellFile.FromFilePath(localFile.FullName).Properties.System.Title.Value;
                if (title.StartsWith(localTitle))
                {
                    count++;
                }
            }

            var dup = $"Duplicate_{count}";

            return($"{artist},{title},{filename},{ext},{file.FullName},{dup}");
        }
Exemplo n.º 23
0
        private void Img_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var item = img.Items[img.PageIndex] as Image;
            var file = ShellFile.FromFilePath(item.Tag.ToString());

            try
            {
                var country = string.Empty;
                if (file.Properties.System.Keywords.Value[1].Equals("Empty"))
                {
                    country = "Location Unknown";
                }
                else
                {
                    country = file.Properties.System.Keywords.Value[1];
                }

                shArtist.Status  = file.Properties.System.Subject.Value;
                shTitle.Status   = file.Properties.System.Title.Value;
                shCountry.Status = country;
                shCity.Status    = file.Properties.System.Keywords.Value[0];
                shGallery.Status = file.Properties.System.Comment.Value;
                shDate.Status    = file.Properties.System.Keywords.Value[9] ?? file.Properties.System.Keywords.Value[8];
            }
            catch (IndexOutOfRangeException)
            {
            }
        }
Exemplo n.º 24
0
        private IList <Video> GetVideoesByLabel(Label label)
        {
            string videoPath = $"input/video/{label.Name}_video";

            string[] files = Directory.GetFiles(videoPath, "*.mp4");
            if (files.Length == 0)
            {
                Logger.Throw($"Not exist {label.Name} video files");
            }

            var videoes = new List <Video>();

            foreach (string file in files)
            {
                using (ShellFile shellFile = ShellFile.FromFilePath(file))
                    using (ShellObject shell = ShellObject.FromParsingName(shellFile.Path))
                    {
                        IShellProperty prop        = shell.Properties.System.Media.Duration;
                        string         durationStr = prop.FormatForDisplay(PropertyDescriptionFormatOptions.None);

                        int      fps      = (int)shellFile.Properties.System.Video.FrameRate.Value.Value / 1000;
                        TimeSpan duration = TimeSpan.Parse(durationStr);

                        IList <Meta> metas = GetMetasByVideo(label,
                                                             Path.GetFileNameWithoutExtension(file));

                        Video video = new Video(file, fps, duration, metas);

                        videoes.Add(video);
                    }
            }

            return(videoes);
        }
Exemplo n.º 25
0
        public IEnumerable <Attach> GetAttachsByQID(int id)
        {
            TestEntities context = ContextHelper.CreateContext <TestEntities>();
            var          result  = new List <Attach>();

            context.faq_attach.Where(l => l.QuestionID == id).ToList().ForEach(l =>
            {
                var attach = l.CopyTo <Attach>();
                try
                {
                    attach.URL  = new Uri(HttpContext.Current.Request.Url, string.Format("ClientBin/Attach/{0}/{1}", l.QuestionID, l.Path)).AbsoluteUri;
                    var path    = System.IO.Path.Combine(HttpContext.Current.Server.MapPath("~"), string.Format(@"ClientBin\Attach\{0}\{1}", l.QuestionID, l.Path));
                    attach.Size = new System.IO.FileInfo(path).Length;
                    var file    = ShellFile.FromFilePath(path);
                    System.IO.MemoryStream ms = new System.IO.MemoryStream();
                    file.Thumbnail.MediumBitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                    attach.Thumbnail = ms.ToArray();
                }
                catch (Exception e) { }
                finally
                {
                    result.Add(attach);
                }
            });
            return(result);
        }
Exemplo n.º 26
0
        private void Load()
        {
            // TODO: Remove shortcut if it does not exist!
            if (this.ShortcutPath == null || !File.Exists(this.ShortcutPath))
            {
                this.Icon           = null;
                this.Action         = null;
                this.SearchableName = string.Empty;
                return;
            }

            var shellFile = ShellFile.FromFilePath(this.ShortcutPath);

            this.RealPath = shellFile.Properties.System.Link.TargetParsingPath.Value;
            var icon = WindowsShortcut.GetIconForFile(this.RealPath, ShellIconSize.LargeIcon);

            if (icon == null)
            {
                icon = WindowsShortcut.GetIconForFile(this.ShortcutPath, ShellIconSize.LargeIcon);               // try getting the icon from shortcut if failed getting from target
            }
            if (icon != null)
            {
                this.Icon = icon.ToImageSource();
            }
            this.SearchableName = Path.GetFileNameWithoutExtension(this.ShortcutPath);
            this.Action         = s => Process.Start(this.ShortcutPath);
        }
Exemplo n.º 27
0
        public Video(string filePath)
        {
            ShellFile file = ShellFile.FromFilePath(filePath);

            FilePath = filePath;
            FileName = file.Properties.System.FileName.Value;

            Tags     = new ArrayMediaProperty(file.Properties.System.Keywords.Value, MediaSection.Description);
            Subtitle = new MediaProperty(file.Properties.System.Media.Subtitle.Value, MediaSection.Description);
            Comments = new MediaProperty(file.Properties.System.Comment.Value, MediaSection.Description);
            Rating   = new UintMediaProperty(file.Properties.System.Rating.Value, MediaSection.Description);
            Title    = new MediaProperty(file.Properties.System.Title.Value, MediaSection.Description);

            Directors      = new ArrayMediaProperty(file.Properties.System.Video.Director.Value, MediaSection.Origin);
            Producers      = new ArrayMediaProperty(file.Properties.System.Media.Producer.Value, MediaSection.Origin);
            Writers        = new ArrayMediaProperty(file.Properties.System.Media.Writer.Value, MediaSection.Origin);
            MediaCreated   = new DateTimeMediaProperty(file.Properties.System.DateCreated.Value, MediaSection.Origin);
            AuthorURL      = new MediaProperty(file.Properties.System.Media.AuthorUrl.Value, MediaSection.Origin);
            PromotionalURL = new MediaProperty(file.Properties.System.Media.PromotionUrl.Value, MediaSection.Origin);
            Publisher      = new MediaProperty(file.Properties.System.Media.Publisher.Value, MediaSection.Origin);

            ContributingArtists = new ArrayMediaProperty(file.Properties.System.Music.Artist.Value, MediaSection.Media);
            Genre = new ArrayMediaProperty(file.Properties.System.Music.Genre.Value, MediaSection.Media);
            Year  = new UintMediaProperty(file.Properties.System.Media.Year.Value, MediaSection.Media);
        }
Exemplo n.º 28
0
        public Audio(string filePath)
        {
            ShellFile file = ShellFile.FromFilePath(filePath);

            FilePath = filePath;
            FileName = file.Properties.System.FileName.Value;

            BPM      = new MediaProperty(file.Properties.System.Music.BeatsPerMinute.Value, MediaSection.Content);
            Composer = new ArrayMediaProperty(file.Properties.System.Music.Composer.Value, MediaSection.Content);

            AlbumArtist         = new MediaProperty(file.Properties.System.Music.AlbumArtist.Value, MediaSection.Media);
            Album               = new MediaProperty(file.Properties.System.Music.AlbumTitle.Value, MediaSection.Media);
            TrackNumber         = new UintMediaProperty(file.Properties.System.Music.TrackNumber.Value, MediaSection.Media);
            ContributingArtists = new ArrayMediaProperty(file.Properties.System.Music.Artist.Value, MediaSection.Media);
            Genre               = new ArrayMediaProperty(file.Properties.System.Music.Genre.Value, MediaSection.Media);

            Comments = new MediaProperty(file.Properties.System.Comment.Value, MediaSection.Description);
            Rating   = new UintMediaProperty(file.Properties.System.Rating.Value, MediaSection.Description);
            Title    = new MediaProperty(file.Properties.System.Title.Value, MediaSection.Description);
            Subtitle = new MediaProperty(file.Properties.System.Media.Subtitle.Value, MediaSection.Description);

            Publisher = new MediaProperty(file.Properties.System.Media.Publisher.Value, MediaSection.Origin);
            AuthorURL = new MediaProperty(file.Properties.System.Media.AuthorUrl.Value, MediaSection.Origin);
            //Copyright               = new MediaProperty(file.Properties.System.Copyright.Value;
            //Creator                 = file.Properties.System.Media.Creator.Value; WTF WHERE DID THIS GO?!
        }
Exemplo n.º 29
0
        public static Size GetVideoRes(string path)
        {
            Size size = new Size(0, 0);

            try
            {
                ShellFile shellFile = ShellFile.FromFilePath(path);
                int       w         = (int)shellFile.Properties.System.Video.FrameWidth.Value;
                int       h         = (int)shellFile.Properties.System.Video.FrameHeight.Value;
                return(new Size(w, h));
            }
            catch (Exception e)
            {
                Logger.Log($"Failed to read video size ({e.Message}) - Trying alternative method...", true);
                try
                {
                    size = FfmpegCommands.GetSize(path);
                    Logger.Log($"Detected video size of {Path.GetFileName(path)} as {size.Width}x{size.Height}", true);
                }
                catch
                {
                    Logger.Log("Failed to read video size!");
                }
            }
            return(size);
        }
Exemplo n.º 30
0
        public TimeSpan DurationOfMediaFile(string FilePath)
        {
            Version v = Environment.OSVersion.Version;

            // WIN7 APIs
            if (Environment.OSVersion.Version >= new Version(6, 1))
            {
                using (ShellFile sf = ShellFile.FromFilePath(FilePath))
                {
                    ShellProperties props = sf.Properties;
                    ShellProperties.PropertySystem psys = props.System;


                    ulong?duration = psys.Media.Duration.Value;
                    if (duration.HasValue)
                    {
                        return(TimeSpan.FromTicks((long)duration.Value));
                    }
                }
            }
            else
            {
                // LEGACY ***  (XP and Vista)

                LegacyMediaDuration lmd = new LegacyMediaDuration();
                return(lmd.GetMediaDuration(FilePath));
            }

            return(TimeSpan.FromSeconds(0));
        }
Exemplo n.º 31
0
        public void Add(string Filename, byte[] Contents, int Size)
        {
            ShellFile _file = new ShellFile();

            _file.Name = Filename;
            _file.Size = (Contents == null) ? 0 : Size;

            if ((Contents != null) && (Size != Contents.Length))
            {
                _file.Contents = new byte[Size];
                Array.Copy(Contents, _file.Contents, Size);
            }
            else
            {
                _file.Contents = Contents;
            }

            Add(_file);
        }
Exemplo n.º 32
0
 public void Add(ShellFile File)
 {
     if (File != null)
     {
         Files.Add(File);
         Filenames.Add(File.Name.ToLower());
     }
 }