コード例 #1
0
 protected override void Init(ResourceFileProperty property, ResourceFileAttribute resourceFileAttribute)
 {
     try
     {
         if (string.IsNullOrEmpty(property.ResourceFullFileName)) return;
         using (PowerPoint powerPoint = PowerPoint.OpenFile(property.ResourceFullFileName))
         {
             NumberOfSlides = powerPoint.NumberOfSlides;
         }
     }
     catch(Exception ex)
     {
         throw new InvalidResourceException(string.Format("Файл {0} не является презентацией PowerPoint", Path.GetFileName(property.ResourceFullFileName)), ex);
     }
 }
コード例 #2
0
 protected override void Init(ResourceFileProperty property, ResourceFileAttribute resourceFileAttribute)
 {
     try
     {
         if (string.IsNullOrEmpty(property.ResourceFullFileName)) return;
         using (Hosts.Plugins.WordDocument.Common.WordDocument Word = Hosts.Plugins.WordDocument.Common.WordDocument.OpenFile(property.ResourceFullFileName))
         {
             NumberOfPages = Word.NumberOfPages;
         }
     }
     catch(Exception ex)
     {
         throw new InvalidResourceException(string.Format("Файл {0} не является документом Word", Path.GetFileName(property.ResourceFullFileName)), ex);
     }
 }
コード例 #3
0
 protected override void Init(ResourceFileProperty property, ResourceFileAttribute resourceFileAttribute)
 {
     //AutoResetEvent ready = new AutoResetEvent(false); 
     // инициализируем доп параметры
     if (string.IsNullOrEmpty(property.ResourceFullFileName))
     {
         Width = 0;
         Height = 0;
         Duration = 0;
     }
     else
     {
         try
         {
             using (WMPlayerForm form = new WMPlayerForm())
             {
                 //form.Show(new WindowWrapper(ptr));
                 form.FileName = property.ResourceFullFileName;
                 form.ShowDialog();
                 //form.StartPlay(resourceFullFileName);
                 //Thread.Sleep(10000);
                 Width = form.VideoWidth;
                 Height = form.VideoHeight;
                 Duration = form.Duration;
                 form.Close();
             }
             if (Width == 0 || Height == 0 || Duration == 0)
                 throw new InvalidResourceException(
                     "Файл не распознан как видео-файл, нет необходимого кодека или не установлен WMP 10 версии и выше");
         }
         catch (Exception)
         {
             throw new InvalidResourceException("Файл не распознан как видео-файл или нет необходимого кодека");
         }
         //using (WMPlayer wmPlayer = WMPlayer.Create(resourceFullFileName))
         //{
         //    Width = wmPlayer.Width;
         //    Height = wmPlayer.Height;
         //    Duration = wmPlayer.Duration;
         //}
     }
 }
コード例 #4
0
 protected override void Init(ResourceFileProperty property, ResourceFileAttribute resourceFileAttribute)
 {
     // инициализируем разрешение
     if (string.IsNullOrEmpty(property.ResourceFullFileName))
     {
         Width = 0;
         Height = 0;
     }
     else
     {
         try
         {
             using (System.Drawing.Image image = System.Drawing.Image.FromFile(property.ResourceFullFileName))
             {
                 Width = image.Width;
                 Height = image.Height;
             }
         }
         catch (OutOfMemoryException ex)
         {
             throw new InvalidResourceException("Файл не распознан как изображение", ex);
         }
     }
 }