public bool Execute(FileItem item, AutoExportPluginConfig configData)
        {
            configData.IsRedy  = false;
            configData.IsError = false;
            var filename = item.FileName;
            var conf     = new ExecuteFilePluginViewModel(configData);

            if (string.IsNullOrEmpty(conf.PathToExe) || !File.Exists(conf.PathToExe))
            {
                configData.IsRedy  = true;
                configData.IsError = true;
                configData.Error   = "No executable path was set or executable not found";
                return(false);
            }
            var outfile = Path.Combine(Path.GetTempPath(), Path.GetFileName(filename));
            var tp      = ServiceProvider.PluginManager.GetImageTransformPlugin(conf.TransformPlugin);

            outfile = tp != null && conf.TransformPlugin != BasePluginViewModel.EmptyTransformFilter
                ? tp.Execute(item, outfile, configData.ConfigData)
                : filename;

            if (File.Exists(outfile))
            {
                PhotoUtils.Run(conf.PathToExe,
                               string.IsNullOrEmpty(conf.Params) ? outfile : conf.Params.Replace("%1", outfile), ProcessWindowStyle.Normal);
            }
            else
            {
                configData.IsError = true;
                configData.Error   = "Output file not found !";
            }
            configData.IsRedy = true;
            return(true);
        }
Esempio n. 2
0
        public bool Execute(FileItem item, AutoExportPluginConfig configData)
        {
            configData.IsRedy  = false;
            configData.IsError = false;
            var filename = item.FileName;
            var conf     = new ExecuteFilePluginViewModel(configData);

            if (string.IsNullOrEmpty(conf.PathToExe) || !File.Exists(conf.PathToExe))
            {
                configData.IsRedy  = true;
                configData.IsError = true;
                configData.Error   = "No executable path was set or executable not found";
                return(false);
            }
            var outfile = Path.Combine(Path.GetTempPath(), Path.GetFileName(filename));

            outfile = AutoExportPluginHelper.ExecuteTransformPlugins(item, configData, outfile);

            if (File.Exists(outfile))
            {
                PhotoUtils.Run(conf.PathToExe,
                               string.IsNullOrEmpty(conf.Params) ? outfile : conf.Params.Replace("%1", outfile), ProcessWindowStyle.Normal);
            }
            else
            {
                configData.IsError = true;
                configData.Error   = "Output file not found !";
            }

            configData.IsRedy = true;
            return(true);
        }
Esempio n. 3
0
        public MainMenuViewModel()
        {
            SendCommand         = new GalaSoft.MvvmLight.Command.RelayCommand <string>(Send);
            SettingsCommand     = new RelayCommand(EditSettings);
            ThumbSizeCommand    = new GalaSoft.MvvmLight.Command.RelayCommand <int>(ThumbSize);
            SetLayoutCommand    = new GalaSoft.MvvmLight.Command.RelayCommand <string>(SetLayout);
            SelectAllCommand    = new RelayCommand(delegate { ServiceProvider.Settings.DefaultSession.SelectAll(); });
            SelectNoneCommand   = new RelayCommand(delegate { ServiceProvider.Settings.DefaultSession.SelectNone(); });
            SelectLiked         = new RelayCommand(delegate { ServiceProvider.Settings.DefaultSession.SelectLiked(); });
            SelectUnLiked       = new RelayCommand(delegate { ServiceProvider.Settings.DefaultSession.SelectUnLiked(); });
            SelectInvertCommand = new RelayCommand(delegate { ServiceProvider.Settings.DefaultSession.SelectInver(); });
            SelectSeries        =
                new RelayCommand(delegate
            {
                try
                {
                    ServiceProvider.Settings.DefaultSession.SelectSameSeries(
                        ServiceProvider.Settings.SelectedBitmap.FileItem.Series);
                }
                catch (Exception ex)
                {
                    Log.Error("SelectSeries", ex);
                }
            });
            NewSessionCommand     = new RelayCommand(NewSession);
            EditSessionCommand    = new RelayCommand(EditSession);
            DelSessionCommand     = new RelayCommand(DelSession);
            RefreshSessionCommand = new RelayCommand(RefreshSession);
            ShowSessionCommand    = new RelayCommand(ShowSession);
            RefreshCommand        = new RelayCommand(Refresh);
            CameraPropertyCommand =
                new RelayCommand(
                    () => ServiceProvider.WindowsManager.ExecuteCommand(WindowsCmdConsts.CameraPropertyWnd_Show,
                                                                        ServiceProvider.DeviceManager.SelectedCameraDevice));
            UseAsMasterCommand = new RelayCommand(UseAsMaster);

            ToggleFocusCommand    = new RelayCommand(() => ShowFocusPoints = !ShowFocusPoints);
            FlipPreviewCommand    = new RelayCommand(() => FlipPreview = !FlipPreview);
            EnhancedThumbsCommand = new RelayCommand(() => EnhancedThumbs = !EnhancedThumbs);
            ShowThumbInfoCommand  = new RelayCommand(() => ShowThumbInfo = !ShowThumbInfo);

            HomePageCommand      = new RelayCommand(() => PhotoUtils.Run("http://www.digicamcontrol.com/", ""));
            CheckUpdateCommand   = new RelayCommand(() => NewVersionWnd.CheckForUpdate(true));
            ForumCommand         = new RelayCommand(() => PhotoUtils.Run("http://digicamcontrol.com/phpbb/index.php", ""));
            SendLogFileCommand   = new RelayCommand(() => new ErrorReportWnd("Log file").ShowDialog());
            ShowChangeLogCommand = new RelayCommand(NewVersionWnd.ShowChangeLog);
            AboutCommand         = new RelayCommand(() => new AboutWnd().ShowDialog());
            ManualPageCommand    = new RelayCommand(() => HelpProvider.Run(HelpSections.MainMenu));

            ExecuteExportPluginCommand = new GalaSoft.MvvmLight.Command.RelayCommand <IExportPlugin>(ExecuteExportPlugin);
            ExecuteToolPluginCommand   = new GalaSoft.MvvmLight.Command.RelayCommand <IToolPlugin>(ExecuteToolPlugin);
            if (ServiceProvider.DeviceManager != null)
            {
                ServiceProvider.DeviceManager.CameraConnected    += DeviceManager_CameraConnected;
                ServiceProvider.DeviceManager.CameraDisconnected += DeviceManager_CameraConnected;
                ServiceProvider.DeviceManager.CameraSelected     += DeviceManager_CameraSelected;
            }
            ExportSessionCommand = new RelayCommand(ExportSession);
            ImportSessionCommand = new RelayCommand(ImportSession);
        }
Esempio n. 4
0
        public bool Execute()
        {
            SaveFileDialog dialog = new SaveFileDialog();

            dialog.FileName = "export.csv";
            dialog.Filter   = "*.csv|*.csv|All files|*.*";
            if (dialog.ShowDialog() == true)
            {
                try
                {
                    using (TextWriter writer = File.CreateText(dialog.FileName))
                    {
                        writer.WriteLine("File,Time,TimeDif");
                        for (int i = 0; i < ServiceProvider.Settings.DefaultSession.Files.Count; i++)
                        {
                            var file = ServiceProvider.Settings.DefaultSession.Files[i];
                            writer.WriteLine("{0},{1},{2}", file.FileName, file.FileDate.ToString("O"),
                                             (i > 0
                                    ? Math.Round(
                                                  (file.FileDate - ServiceProvider.Settings.DefaultSession.Files[i - 1].FileDate)
                                                  .TotalMilliseconds, 0)
                                    : 0));
                        }
                        PhotoUtils.Run(dialog.FileName);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error to export " + ex.Message);
                    Log.Error("Error to export ", ex);
                }
            }
            return(true);
        }
 private void button5_Click(object sender, RoutedEventArgs e)
 {
     if (!Directory.Exists(ServiceProvider.Settings.OverlayFolder))
     {
         Directory.CreateDirectory(ServiceProvider.Settings.OverlayFolder);
     }
     PhotoUtils.Run("explorer", ServiceProvider.Settings.OverlayFolder, ProcessWindowStyle.Normal);
 }
        private void Login()
        {
            FacebookClient client = new FacebookClient();

            client.AppId     = "1389684908024720";
            client.AppSecret = "20a29131265de09bf1421ed1284ca23e";
            PhotoUtils.Run(GenerateLoginUrl(client.AppId, "publish_actions,manage_pages").ToString());
        }
Esempio n. 7
0
 public static void Run(HelpSections sections)
 {
     if (_helpData == null)
     {
         Init();
     }
     PhotoUtils.Run(_helpData[sections], "");
 }
Esempio n. 8
0
 private void ShowAlbum()
 {
     if (!string.IsNullOrEmpty(SelectedAlbum) && SelectedAlbum.Contains("||"))
     {
         string id = SelectedAlbum.Split(new[] { "||" }, StringSplitOptions.RemoveEmptyEntries)[0];
         PhotoUtils.Run("https://www.facebook.com/" + id);
     }
 }
Esempio n. 9
0
 private void PlayVideo()
 {
     if (!File.Exists(OutPutFile))
     {
         MessageBox.Show("Video file not found !");
         return;
     }
     PhotoUtils.Run(OutPutFile);
 }
 private void ShowSession()
 {
     try
     {
         PhotoUtils.Run(ServiceProvider.Settings.DefaultSession.Folder);
     }
     catch (Exception ex)
     {
         Log.Error("Error refresh session ", ex);
         ServiceProvider.WindowsManager.ExecuteCommand(WindowsCmdConsts.MainWnd_Message, ex.Message);
     }
 }
 public void Open()
 {
     try
     {
         var file = Path.Combine(Settings.ApplicationFolder, "Data", "msl", SelectedScript + ".msl");
         PhotoUtils.Run("notepad.exe", file);
     }
     catch (Exception ex)
     {
         Log.Error("Error", ex);
     }
 }
Esempio n. 12
0
        private void Login()
        {
            FacebookClient client = new FacebookClient();

            client.AppId     = ClientId;
            client.AppSecret = ClientSecret;
            //PhotoUtils.Run(GenerateLoginUrl(client.AppId,"publish_actions,manage_pages").ToString());
            _miniWebServer = new MiniWebServer(SendResponse, Server);
            _miniWebServer.Run();
            PhotoUtils.Run(
                GenerateLoginUrl(client.AppId, "publish_actions,manage_pages,user_photos,publish_pages").ToString());
        }
Esempio n. 13
0
 private void OpenViewer()
 {
     if (ServiceProvider.Settings.SelectedBitmap == null ||
         ServiceProvider.Settings.SelectedBitmap.FileItem == null)
     {
         return;
     }
     if (!string.IsNullOrWhiteSpace(ServiceProvider.Settings.ExternalViewer) &&
         File.Exists(ServiceProvider.Settings.ExternalViewer))
     {
         PhotoUtils.Run(ServiceProvider.Settings.ExternalViewer,
                        ServiceProvider.Settings.SelectedBitmap.FileItem.FileName, ProcessWindowStyle.Maximized);
     }
     else
     {
         PhotoUtils.Run(ServiceProvider.Settings.SelectedBitmap.FileItem.FileName, "",
                        ProcessWindowStyle.Maximized);
     }
 }
Esempio n. 14
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (ServiceProvider.Settings.SelectedBitmap == null ||
         ServiceProvider.Settings.SelectedBitmap.FileItem == null)
     {
         return;
     }
     if (!string.IsNullOrWhiteSpace(ServiceProvider.Settings.ExternalViewer) &&
         File.Exists(ServiceProvider.Settings.ExternalViewer))
     {
         PhotoUtils.Run(ServiceProvider.Settings.ExternalViewer,
                        "\"" + ServiceProvider.Settings.SelectedBitmap.FileItem.FileName + "\"", ProcessWindowStyle.Maximized);
     }
     else
     {
         PhotoUtils.Run("\"" + ServiceProvider.Settings.SelectedBitmap.FileItem.FileName + "\"", "",
                        ProcessWindowStyle.Maximized);
     }
 }
 private void Login()
 {
     try
     {
         if (_client == null)
         {
             _client = new DropNetClient(AppKey, AppSecret);
             _client.GetToken();
         }
         var url = _client.BuildAuthorizeUrl(Server);
         _miniWebServer = new MiniWebServer(SendResponse, Server);
         _miniWebServer.Run();
         PhotoUtils.Run(url);
     }
     catch (Exception)
     {
         Log.Error("Unable to login");
     }
 }
 private void btn_getRaw_Click(object sender, RoutedEventArgs e)
 {
     PhotoUtils.Run("http://www.microsoft.com/en-us/download/details.aspx?id=26829", "");
 }
Esempio n. 17
0
 private void qrcode_MouseDown(object sender, MouseButtonEventArgs e)
 {
     PhotoUtils.Run(ServiceProvider.Settings.Webaddress);
     //Close();
 }
        void PhotoCaptured(object o)
        {
            PhotoCapturedEventArgs eventArgs = o as PhotoCapturedEventArgs;

            if (eventArgs == null)
            {
                return;
            }
            try
            {
                Log.Debug("Photo transfer begin.");
                eventArgs.CameraDevice.IsBusy = true;
                CameraProperty property = eventArgs.CameraDevice.LoadProperties();
                PhotoSession   session  = (PhotoSession)eventArgs.CameraDevice.AttachedPhotoSession ??
                                          ServiceProvider.Settings.DefaultSession;
                StaticHelper.Instance.SystemMessage = "";
                if (!eventArgs.CameraDevice.CaptureInSdRam)
                {
                    if (property.NoDownload)
                    {
                        eventArgs.CameraDevice.IsBusy = false;
                        return;
                    }
                    var extension = Path.GetExtension(eventArgs.FileName);
                    if (extension != null && (session.DownloadOnlyJpg && extension.ToLower() != ".jpg"))
                    {
                        eventArgs.CameraDevice.IsBusy = false;
                        return;
                    }
                }
                StaticHelper.Instance.SystemMessage = TranslationStrings.MsgPhotoTransferBegin;
                string fileName = "";
                if (!session.UseOriginalFilename || eventArgs.CameraDevice.CaptureInSdRam)
                {
                    fileName =
                        session.GetNextFileName(Path.GetExtension(eventArgs.FileName),
                                                eventArgs.CameraDevice);
                }
                else
                {
                    fileName = Path.Combine(session.Folder, eventArgs.FileName);
                    if (File.Exists(fileName) && !session.AllowOverWrite)
                    {
                        fileName =
                            StaticHelper.GetUniqueFilename(
                                Path.GetDirectoryName(fileName) + "\\" + Path.GetFileNameWithoutExtension(fileName) + "_", 0,
                                Path.GetExtension(fileName));
                    }
                }

                if (session.AllowOverWrite && File.Exists(fileName))
                {
                    File.Delete(fileName);
                }

                if (!Directory.Exists(Path.GetDirectoryName(fileName)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(fileName));
                }
                Log.Debug("Transfer started :" + fileName);
                //DateTime startTIme = DateTime.Now;
                eventArgs.CameraDevice.TransferFile(eventArgs.Handle, fileName);
                //Log.Debug("Transfer done :" + fileName);
                //Log.Debug("[BENCHMARK]Speed :" +
                //          (new FileInfo(fileName).Length / (DateTime.Now - startTIme).TotalSeconds / 1024 / 1024).ToString("0000.00"));
                //Log.Debug("[BENCHMARK]Transfer time :" + ((DateTime.Now - startTIme).TotalSeconds).ToString("0000.000"));

                // write comment and tags directly in transferred file
                if (ServiceProvider.Settings.DefaultSession.WriteComment)
                {
                    if (!string.IsNullOrEmpty(ServiceProvider.Settings.DefaultSession.Comment))
                    {
                        Exiv2Helper.SaveComment(fileName, ServiceProvider.Settings.DefaultSession.Comment);
                    }
                    if (ServiceProvider.Settings.DefaultSession.SelectedTag1 != null && !string.IsNullOrEmpty(ServiceProvider.Settings.DefaultSession.SelectedTag1.Value))
                    {
                        Exiv2Helper.AddKeyword(fileName, ServiceProvider.Settings.DefaultSession.SelectedTag1.Value);
                    }
                    if (ServiceProvider.Settings.DefaultSession.SelectedTag2 != null && !string.IsNullOrEmpty(ServiceProvider.Settings.DefaultSession.SelectedTag2.Value))
                    {
                        Exiv2Helper.AddKeyword(fileName, ServiceProvider.Settings.DefaultSession.SelectedTag2.Value);
                    }
                    if (ServiceProvider.Settings.DefaultSession.SelectedTag3 != null && !string.IsNullOrEmpty(ServiceProvider.Settings.DefaultSession.SelectedTag3.Value))
                    {
                        Exiv2Helper.AddKeyword(fileName, ServiceProvider.Settings.DefaultSession.SelectedTag3.Value);
                    }
                    if (ServiceProvider.Settings.DefaultSession.SelectedTag4 != null && !string.IsNullOrEmpty(ServiceProvider.Settings.DefaultSession.SelectedTag4.Value))
                    {
                        Exiv2Helper.AddKeyword(fileName, ServiceProvider.Settings.DefaultSession.SelectedTag4.Value);
                    }
                }
                _selectedItem = session.AddFile(fileName);
                //select the new file only when the multiple camera support isn't used to prevent high CPU usage on raw files
                if (ServiceProvider.Settings.AutoPreview &&
                    !ServiceProvider.WindowsManager.Get(typeof(MultipleCameraWnd)).IsVisible&&
                    !ServiceProvider.Settings.UseExternalViewer)
                {
                    if ((Path.GetExtension(fileName).ToLower() == ".jpg" && ServiceProvider.Settings.AutoPreviewJpgOnly) || !ServiceProvider.Settings.AutoPreviewJpgOnly)
                    {
                        if (ServiceProvider.Settings.DelayImageLoading &&
                            (DateTime.Now - _lastLoadTime).TotalSeconds < 4)
                        {
                            _selectiontimer.Stop();
                            _selectiontimer.Start();
                        }
                        else
                        {
                            ServiceProvider.WindowsManager.ExecuteCommand(WindowsCmdConsts.Select_Image, _selectedItem);
                        }
                    }
                }
                _lastLoadTime = DateTime.Now;
                //ServiceProvider.Settings.Save(session);
                StaticHelper.Instance.SystemMessage = TranslationStrings.MsgPhotoTransferDone;
                eventArgs.CameraDevice.IsBusy       = false;
                //show fullscreen only when the multiple camera support isn't used
                if (ServiceProvider.Settings.Preview &&
                    !ServiceProvider.WindowsManager.Get(typeof(MultipleCameraWnd)).IsVisible&&
                    !ServiceProvider.Settings.UseExternalViewer)
                {
                    ServiceProvider.WindowsManager.ExecuteCommand(WindowsCmdConsts.FullScreenWnd_ShowTimed);
                }
                if (ServiceProvider.Settings.UseExternalViewer && File.Exists(ServiceProvider.Settings.ExternalViewerPath))
                {
                    string arg = ServiceProvider.Settings.ExternalViewerArgs;
                    arg = arg.Contains("%1") ? arg.Replace("%1", fileName) : arg + " " + fileName;
                    PhotoUtils.Run(ServiceProvider.Settings.ExternalViewerPath, arg, ProcessWindowStyle.Normal);
                }
                if (ServiceProvider.Settings.PlaySound)
                {
                    PhotoUtils.PlayCaptureSound();
                }
            }
            catch (Exception ex)
            {
                eventArgs.CameraDevice.IsBusy       = false;
                StaticHelper.Instance.SystemMessage = string.Format(TranslationStrings.MsgPhotoTransferError, ex.Message);
                Log.Error("Transfer error !", ex);
            }
            Log.Debug("Photo transfer done.");
            // not indicated to be used
            GC.Collect();
            //GC.WaitForPendingFinalizers();
        }
 private void mnu_forum_Click(object sender, RoutedEventArgs e)
 {
     PhotoUtils.Run("http://www.digicamcontrol.com/forum/", "");
 }
Esempio n. 20
0
 private void btn_twitter_Click(object sender, RoutedEventArgs e)
 {
     PhotoUtils.Run("https://twitter.com/digiCamControl");
     Close();
 }
Esempio n. 21
0
 private void btn_donate_Click(object sender, RoutedEventArgs e)
 {
     PhotoUtils.Run("http://digicamcontrol.com/donate");
     Close();
 }
        /// <summary>
        /// Photoes the captured.
        /// </summary>
        /// <param name="o">The o.</param>
        private void PhotoCaptured(object o)
        {
            PhotoCapturedEventArgs eventArgs = o as PhotoCapturedEventArgs;

            if (eventArgs == null)
            {
                return;
            }
            try
            {
                Log.Debug("Photo transfer begin.");
                eventArgs.CameraDevice.IsBusy = true;
                CameraProperty property = eventArgs.CameraDevice.LoadProperties();
                PhotoSession   session  = (PhotoSession)eventArgs.CameraDevice.AttachedPhotoSession ??
                                          ServiceProvider.Settings.DefaultSession;
                StaticHelper.Instance.SystemMessage = "";

                var extension = Path.GetExtension(eventArgs.FileName);

                if (!eventArgs.CameraDevice.CaptureInSdRam || (extension != null && extension.ToLower() == ".mov"))
                {
                    if (property.NoDownload)
                    {
                        eventArgs.CameraDevice.IsBusy = false;
                        return;
                    }
                    if (extension != null && (session.DownloadOnlyJpg && extension.ToLower() != ".jpg"))
                    {
                        eventArgs.CameraDevice.IsBusy = false;
                        return;
                    }
                }

                StaticHelper.Instance.SystemMessage = TranslationStrings.MsgPhotoTransferBegin;

                string tempFile = Path.GetTempFileName();

                if (File.Exists(tempFile))
                {
                    File.Delete(tempFile);
                }

                if (!eventArgs.CameraDevice.CaptureInSdRam && session.DownloadThumbOnly)
                {
                    eventArgs.CameraDevice.TransferFileThumb(eventArgs.Handle, tempFile);
                }
                else
                {
                    eventArgs.CameraDevice.TransferFile(eventArgs.Handle, tempFile);
                }

                string fileName = "";
                if (!session.UseOriginalFilename || eventArgs.CameraDevice.CaptureInSdRam)
                {
                    fileName =
                        session.GetNextFileName(eventArgs.FileName, eventArgs.CameraDevice, tempFile);
                }
                else
                {
                    fileName = Path.Combine(session.Folder, eventArgs.FileName);
                    if (File.Exists(fileName) && !session.AllowOverWrite)
                    {
                        fileName =
                            StaticHelper.GetUniqueFilename(
                                Path.GetDirectoryName(fileName) + "\\" + Path.GetFileNameWithoutExtension(fileName) +
                                "_", 0,
                                Path.GetExtension(fileName));
                    }
                }

                if (session.AllowOverWrite && File.Exists(fileName))
                {
                    PhotoUtils.WaitForFile(fileName);
                    File.Delete(fileName);
                }

                // make lower case extension
                if (session.LowerCaseExtension && !string.IsNullOrEmpty(Path.GetExtension(fileName)))
                {
                    fileName = Path.Combine(Path.GetDirectoryName(fileName),
                                            Path.GetFileNameWithoutExtension(fileName) + Path.GetExtension(fileName).ToLower());
                }


                if (session.AskSavePath)
                {
                    SaveFileDialog dialog = new SaveFileDialog();
                    dialog.Filter           = "All files|*.*";
                    dialog.Title            = "Save captured photo";
                    dialog.FileName         = fileName;
                    dialog.InitialDirectory = Path.GetDirectoryName(fileName);
                    if (dialog.ShowDialog() == true)
                    {
                        fileName = dialog.FileName;
                    }
                    else
                    {
                        eventArgs.CameraDevice.IsBusy = false;
                        if (File.Exists(tempFile))
                        {
                            File.Delete(tempFile);
                        }
                        return;
                    }
                }

                if (!Directory.Exists(Path.GetDirectoryName(fileName)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(fileName));
                }

                File.Copy(tempFile, fileName);

                string backupfile = null;
                if (session.BackUp)
                {
                    backupfile = session.CopyBackUp(tempFile, fileName);
                    if (string.IsNullOrEmpty(backupfile))
                    {
                        StaticHelper.Instance.SystemMessage = "Unable to save the backup";
                    }
                }

                if (!eventArgs.CameraDevice.CaptureInSdRam && session.DeleteFileAfterTransfer)
                {
                    eventArgs.CameraDevice.DeleteObject(new DeviceObject()
                    {
                        Handle = eventArgs.Handle
                    });
                }


                if (File.Exists(tempFile))
                {
                    File.Delete(tempFile);
                }

                if (session.WriteComment)
                {
                    if (!string.IsNullOrEmpty(session.Comment))
                    {
                        Exiv2Helper.SaveComment(fileName, session.Comment);
                    }
                    if (session.SelectedTag1 != null && !string.IsNullOrEmpty(session.SelectedTag1.Value))
                    {
                        Exiv2Helper.AddKeyword(fileName, session.SelectedTag1.Value);
                    }
                    if (session.SelectedTag2 != null && !string.IsNullOrEmpty(session.SelectedTag2.Value))
                    {
                        Exiv2Helper.AddKeyword(fileName, session.SelectedTag2.Value);
                    }
                    if (session.SelectedTag3 != null && !string.IsNullOrEmpty(session.SelectedTag3.Value))
                    {
                        Exiv2Helper.AddKeyword(fileName, session.SelectedTag3.Value);
                    }
                    if (session.SelectedTag4 != null && !string.IsNullOrEmpty(session.SelectedTag4.Value))
                    {
                        Exiv2Helper.AddKeyword(fileName, session.SelectedTag4.Value);
                    }
                }

                if (session.ExternalData != null)
                {
                    session.ExternalData.FileName = fileName;
                }

                // prevent crash og GUI when item count updated
                Dispatcher.Invoke(new Action(delegate
                {
                    try
                    {
                        _selectedItem = session.GetNewFileItem(fileName);
                        _selectedItem.BackupFileName = backupfile;
                        _selectedItem.Series         = session.Series;
                        _selectedItem.AddTemplates(eventArgs.CameraDevice, session);
                        ServiceProvider.Database.Add(new DbFile(_selectedItem, eventArgs.CameraDevice.SerialNumber, eventArgs.CameraDevice.DisplayName, session.Name));
                    }
                    catch (Exception ex)
                    {
                    }
                }));

                foreach (AutoExportPluginConfig plugin in ServiceProvider.Settings.DefaultSession.AutoExportPluginConfigs)
                {
                    if (!plugin.IsEnabled)
                    {
                        continue;
                    }
                    var pl = ServiceProvider.PluginManager.GetAutoExportPlugin(plugin.Type);
                    try
                    {
                        pl.Execute(_selectedItem, plugin);
                        ServiceProvider.Analytics.PluginExecute(plugin.Type);
                        Log.Debug("AutoexportPlugin executed " + plugin.Type);
                    }
                    catch (Exception ex)
                    {
                        plugin.IsError = true;
                        plugin.Error   = ex.Message;
                        plugin.IsRedy  = true;
                        Log.Error("Error to apply plugin", ex);
                    }
                }

                Dispatcher.Invoke(() =>
                {
                    _selectedItem.RemoveThumbs();
                    session.Add(_selectedItem);
                    ServiceProvider.OnFileTransfered(_selectedItem);
                });

                if (ServiceProvider.Settings.MinimizeToTrayIcon && !IsVisible && !ServiceProvider.Settings.HideTrayNotifications)
                {
                    MyNotifyIcon.HideBalloonTip();
                    MyNotifyIcon.ShowBalloonTip("Photo transfered", fileName, BalloonIcon.Info);
                }

                ServiceProvider.DeviceManager.LastCapturedImage[eventArgs.CameraDevice] = fileName;

                //select the new file only when the multiple camera support isn't used to prevent high CPU usage on raw files
                if (ServiceProvider.Settings.AutoPreview &&
                    !ServiceProvider.WindowsManager.Get(typeof(MultipleCameraWnd)).IsVisible&&
                    !ServiceProvider.Settings.UseExternalViewer)
                {
                    if ((Path.GetExtension(fileName).ToLower() == ".jpg" && ServiceProvider.Settings.AutoPreviewJpgOnly) ||
                        !ServiceProvider.Settings.AutoPreviewJpgOnly)
                    {
                        if ((DateTime.Now - _lastLoadTime).TotalSeconds < 4)
                        {
                            _selectiontimer.Stop();
                            _selectiontimer.Start();
                        }
                        else
                        {
                            ServiceProvider.WindowsManager.ExecuteCommand(WindowsCmdConsts.Select_Image, _selectedItem);
                        }
                    }
                }
                _lastLoadTime = DateTime.Now;
                //ServiceProvider.Settings.Save(session);
                StaticHelper.Instance.SystemMessage = TranslationStrings.MsgPhotoTransferDone;
                eventArgs.CameraDevice.IsBusy       = false;
                //show fullscreen only when the multiple camera support isn't used
                if (ServiceProvider.Settings.Preview &&
                    !ServiceProvider.WindowsManager.Get(typeof(MultipleCameraWnd)).IsVisible&&
                    !ServiceProvider.Settings.UseExternalViewer)
                {
                    ServiceProvider.WindowsManager.ExecuteCommand(WindowsCmdConsts.FullScreenWnd_ShowTimed);
                }
                if (ServiceProvider.Settings.UseExternalViewer &&
                    File.Exists(ServiceProvider.Settings.ExternalViewerPath))
                {
                    string arg = ServiceProvider.Settings.ExternalViewerArgs;
                    arg = arg.Contains("%1") ? arg.Replace("%1", fileName) : arg + " " + fileName;
                    PhotoUtils.Run(ServiceProvider.Settings.ExternalViewerPath, arg, ProcessWindowStyle.Normal);
                }
                if (ServiceProvider.Settings.PlaySound)
                {
                    PhotoUtils.PlayCaptureSound();
                }
                Log.Debug("Photo transfer done.");
            }
            catch (Exception ex)
            {
                eventArgs.CameraDevice.IsBusy       = false;
                StaticHelper.Instance.SystemMessage = TranslationStrings.MsgPhotoTransferError + " " + ex.Message;
                Log.Error("Transfer error !", ex);
            }
            // not indicated to be used
            GC.Collect();
            //GC.WaitForPendingFinalizers();
        }
 private void TextBlock_MouseDown(object sender, MouseButtonEventArgs e)
 {
     PhotoUtils.Run("https://www.transifex.com/projects/p/digicamcontrol/");
 }
 private void ShowFolder()
 {
     PhotoUtils.Run("https://www.dropbox.com/home/Apps/digiCamControl");
 }
Esempio n. 25
0
        void PhotoCaptured(object o)
        {
            PhotoCapturedEventArgs eventArgs = o as PhotoCapturedEventArgs;

            if (eventArgs == null)
            {
                return;
            }

            if (!BarcodeVerified)
            {
                ServiceProvider.WindowsManager.ExecuteCommand(WindowsCmdConsts.Select_Image, new FileItem(""));
                ShowWarning("Invalid Barcode; Image not transfered!");
                return;
            }

            try
            {
                Log.Debug("Photo transfer begin.");
                eventArgs.CameraDevice.IsBusy = true;
                CameraProperty property = ServiceProvider.Settings.CameraProperties.Get(eventArgs.CameraDevice);
                PhotoSession   session  = (PhotoSession)eventArgs.CameraDevice.AttachedPhotoSession ??
                                          ServiceProvider.Settings.DefaultSession;
                StaticHelper.Instance.SystemMessage = "";
                if (!eventArgs.CameraDevice.CaptureInSdRam)
                {
                    if (property.NoDownload)
                    {
                        eventArgs.CameraDevice.IsBusy = false;
                        return;
                    }
                    var extension = Path.GetExtension(eventArgs.FileName);
                    if (extension != null && (session.DownloadOnlyJpg && extension.ToLower() != ".jpg"))
                    {
                        eventArgs.CameraDevice.IsBusy = false;
                        return;
                    }
                }
                StaticHelper.Instance.SystemMessage = TranslationStrings.MsgPhotoTransferBegin;
                string fileName = "";
                if (!session.UseOriginalFilename || eventArgs.CameraDevice.CaptureInSdRam)
                {
                    fileName =
                        session.GetNextFileName(Path.GetExtension(eventArgs.FileName),
                                                eventArgs.CameraDevice);
                }
                else
                {
                    fileName = Path.Combine(session.Folder, eventArgs.FileName);
                    if (File.Exists(fileName))
                    {
                        fileName =
                            StaticHelper.GetUniqueFilename(
                                Path.GetDirectoryName(fileName) + "\\" + Path.GetFileNameWithoutExtension(fileName) + "_", 0,
                                Path.GetExtension(fileName));
                    }
                }
                if (!Directory.Exists(Path.GetDirectoryName(fileName)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(fileName));
                }

                var tmpFileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), Settings.AppName,
                                               "Cache", Path.GetFileName(fileName));
                if (!Directory.Exists(Path.GetDirectoryName(tmpFileName)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(tmpFileName));
                }

                Log.Debug("Transfer started :" + tmpFileName);
                DateTime startTIme = DateTime.Now;
                eventArgs.CameraDevice.TransferFile(eventArgs.Handle, tmpFileName);
                Log.Debug("Transfer done :" + tmpFileName);
                Log.Debug("[BENCHMARK]Speed :" +
                          (new System.IO.FileInfo(tmpFileName).Length / (DateTime.Now - startTIme).TotalSeconds / 1024 / 1024).ToString("0000.00"));
                Log.Debug("[BENCHMARK]Transfer time :" + ((DateTime.Now - startTIme).TotalSeconds).ToString("0000.000"));

                //select the new file only when the multiple camera support isn't used to prevent high CPU usage on raw files
                if (ServiceProvider.Settings.AutoPreview &&
                    !ServiceProvider.WindowsManager.Get(typeof(MultipleCameraWnd)).IsVisible&&
                    !ServiceProvider.Settings.UseExternalViewer)
                {
                    var fileItem = session.AddFile(tmpFileName);
                    fileItem.DestinationFilename = fileName;
                    ServiceProvider.WindowsManager.ExecuteCommand(WindowsCmdConsts.Select_Image, fileItem);
                }
                else
                {
                    System.IO.File.Move(tmpFileName, fileName);
                    session.AddFile(fileName);
                }
                //ServiceProvider.Settings.Save(session);
                StaticHelper.Instance.SystemMessage = TranslationStrings.MsgPhotoTransferDone;
                BarcodeUsed = true;
                eventArgs.CameraDevice.IsBusy = false;
                //show fullscreen only when the multiple camera support isn't used
                if (ServiceProvider.Settings.Preview &&
                    !ServiceProvider.WindowsManager.Get(typeof(MultipleCameraWnd)).IsVisible&&
                    !ServiceProvider.Settings.UseExternalViewer)
                {
                    ServiceProvider.WindowsManager.ExecuteCommand(WindowsCmdConsts.FullScreenWnd_ShowTimed);
                }
                if (ServiceProvider.Settings.UseExternalViewer && File.Exists(ServiceProvider.Settings.ExternalViewerPath))
                {
                    string arg = ServiceProvider.Settings.ExternalViewerArgs;
                    arg = arg.Contains("%1") ? arg.Replace("%1", fileName) : arg + " " + fileName;
                    PhotoUtils.Run(ServiceProvider.Settings.ExternalViewerPath, arg, ProcessWindowStyle.Normal);
                }
                if (ServiceProvider.Settings.PlaySound)
                {
                    PhotoUtils.PlayCaptureSound();
                }
            }
            catch (Exception ex)
            {
                eventArgs.CameraDevice.IsBusy       = false;
                StaticHelper.Instance.SystemMessage = string.Format(TranslationStrings.MsgPhotoTransferError, ex.Message);
                Log.Error("Transfer error !", ex);
            }
            Log.Debug("Photo transfer done.");
            // not indicated to be used
            GC.Collect();
            //GC.WaitForPendingFinalizers();
        }
Esempio n. 26
0
 private void button1_Click(object sender, RoutedEventArgs e)
 {
     PhotoUtils.Run("https://us.orangemonkie.com/");
 }
Esempio n. 27
0
 private void button3_Click(object sender, RoutedEventArgs e)
 {
     PhotoUtils.Run("http://www.gnu.org/licenses/gpl-3.0.txt");
 }
Esempio n. 28
0
 private void btn_open_folder_Sesion_Click(object sender, RoutedEventArgs e)
 {
     PhotoUtils.Run(ServiceProvider.Settings.DefaultSession.Folder);
 }
Esempio n. 29
0
        /// <summary>
        /// Photoes the captured.
        /// </summary>
        /// <param name="o">The o.</param>
        private void PhotoCaptured(object o)
        {
            PhotoCapturedEventArgs eventArgs = o as PhotoCapturedEventArgs;

            if (eventArgs == null)
            {
                return;
            }
            try
            {
                Log.Debug("Photo transfer begin.");
                eventArgs.CameraDevice.IsBusy = true;
                var extension = Path.GetExtension(eventArgs.FileName);

                // the capture is for live view preview
                if (LiveViewManager.PreviewRequest.ContainsKey(eventArgs.CameraDevice) &&
                    LiveViewManager.PreviewRequest[eventArgs.CameraDevice])
                {
                    LiveViewManager.PreviewRequest[eventArgs.CameraDevice] = false;
                    var file = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + extension);
                    eventArgs.CameraDevice.TransferFile(eventArgs.Handle, file);
                    eventArgs.CameraDevice.IsBusy           = false;
                    eventArgs.CameraDevice.TransferProgress = 0;
                    eventArgs.CameraDevice.ReleaseResurce(eventArgs.Handle);
                    LiveViewManager.Preview[eventArgs.CameraDevice] = file;
                    LiveViewManager.OnPreviewCaptured(eventArgs.CameraDevice, file);
                    return;
                }

                CameraProperty property = eventArgs.CameraDevice.LoadProperties();
                PhotoSession   session  = (PhotoSession)eventArgs.CameraDevice.AttachedPhotoSession ??
                                          ServiceProvider.Settings.DefaultSession;
                StaticHelper.Instance.SystemMessage = "";


                if (!eventArgs.CameraDevice.CaptureInSdRam || PhotoUtils.IsMovie(eventArgs.FileName))
                {
                    if (property.NoDownload)
                    {
                        eventArgs.CameraDevice.IsBusy = false;
                        eventArgs.CameraDevice.ReleaseResurce(eventArgs.Handle);
                        return;
                    }
                    if (extension != null && (session.DownloadOnlyJpg && extension.ToLower() != ".jpg"))
                    {
                        eventArgs.CameraDevice.IsBusy = false;
                        eventArgs.CameraDevice.ReleaseResurce(eventArgs.Handle);
                        return;
                    }
                }

                StaticHelper.Instance.SystemMessage = TranslationStrings.MsgPhotoTransferBegin;

                string tempFile = Path.GetTempFileName();

                if (File.Exists(tempFile))
                {
                    File.Delete(tempFile);
                }

                Stopwatch stopWatch = new Stopwatch();
                // transfer file from camera to temporary folder
                // in this way if the session folder is used as hot folder will prevent write errors
                stopWatch.Start();
                if (!eventArgs.CameraDevice.CaptureInSdRam && session.DownloadThumbOnly)
                {
                    eventArgs.CameraDevice.TransferFileThumb(eventArgs.Handle, tempFile);
                }
                else
                {
                    eventArgs.CameraDevice.TransferFile(eventArgs.Handle, tempFile);
                }
                eventArgs.CameraDevice.TransferProgress = 0;
                eventArgs.CameraDevice.IsBusy           = false;
                stopWatch.Stop();
                string strTransfer = "Transfer time : " + stopWatch.Elapsed.TotalSeconds.ToString("##.###") + " Speed :" +
                                     Math.Round(
                    new System.IO.FileInfo(tempFile).Length / 1024.0 / 1024 /
                    stopWatch.Elapsed.TotalSeconds, 2) + " Mb/s";
                Log.Debug(strTransfer);

                string fileName = "";
                if (!session.UseOriginalFilename || eventArgs.CameraDevice.CaptureInSdRam)
                {
                    fileName =
                        session.GetNextFileName(eventArgs.FileName, eventArgs.CameraDevice, tempFile);
                }
                else
                {
                    fileName = Path.Combine(session.Folder, eventArgs.FileName);
                    if (File.Exists(fileName) && !session.AllowOverWrite)
                    {
                        fileName =
                            StaticHelper.GetUniqueFilename(
                                Path.GetDirectoryName(fileName) + "\\" + Path.GetFileNameWithoutExtension(fileName) +
                                "_", 0,
                                Path.GetExtension(fileName));
                    }
                }

                if (session.AllowOverWrite && File.Exists(fileName))
                {
                    PhotoUtils.WaitForFile(fileName);
                    File.Delete(fileName);
                }

                // make lower case extension
                if (session.LowerCaseExtension && !string.IsNullOrEmpty(Path.GetExtension(fileName)))
                {
                    fileName = Path.Combine(Path.GetDirectoryName(fileName),
                                            Path.GetFileNameWithoutExtension(fileName) + Path.GetExtension(fileName).ToLower());
                }


                if (session.AskSavePath)
                {
                    SaveFileDialog dialog = new SaveFileDialog();
                    dialog.Filter           = "All files|*.*";
                    dialog.Title            = "Save captured photo";
                    dialog.FileName         = fileName;
                    dialog.InitialDirectory = Path.GetDirectoryName(fileName);
                    if (dialog.ShowDialog() == true)
                    {
                        fileName = dialog.FileName;
                    }
                    else
                    {
                        eventArgs.CameraDevice.IsBusy = false;
                        if (File.Exists(tempFile))
                        {
                            File.Delete(tempFile);
                        }
                        return;
                    }
                }

                if (!Directory.Exists(Path.GetDirectoryName(fileName)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(fileName));
                }


                string backupfile = null;
                if (session.BackUp)
                {
                    backupfile = session.CopyBackUp(tempFile, fileName);
                    if (string.IsNullOrEmpty(backupfile))
                    {
                        StaticHelper.Instance.SystemMessage = "Unable to save the backup";
                    }
                }

                // execute plugins which are executed before transfer
                if (ServiceProvider.Settings.DefaultSession.AutoExportPluginConfigs.Count((x) => !x.RunAfterTransfer) > 0)
                {
                    FileItem tempitem = new FileItem(tempFile);
                    tempitem.Name           = Path.GetFileName(fileName);
                    tempitem.BackupFileName = backupfile;
                    tempitem.Series         = session.Series;
                    tempitem.AddTemplates(eventArgs.CameraDevice, session);
                    ExecuteAutoexportPlugins(eventArgs.CameraDevice, tempitem, false);
                }


                if ((!eventArgs.CameraDevice.CaptureInSdRam || PhotoUtils.IsMovie(fileName)) && session.DeleteFileAfterTransfer)
                {
                    eventArgs.CameraDevice.DeleteObject(new DeviceObject()
                    {
                        Handle = eventArgs.Handle
                    });
                }

                File.Copy(tempFile, fileName);

                if (File.Exists(tempFile))
                {
                    PhotoUtils.WaitForFile(tempFile);
                    File.Delete(tempFile);
                }

                if (session.WriteComment)
                {
                    if (!string.IsNullOrEmpty(session.Comment))
                    {
                        Exiv2Helper.SaveComment(fileName, session.Comment);
                    }
                    if (session.SelectedTag1 != null && !string.IsNullOrEmpty(session.SelectedTag1.Value))
                    {
                        Exiv2Helper.AddKeyword(fileName, session.SelectedTag1.Value);
                    }
                    if (session.SelectedTag2 != null && !string.IsNullOrEmpty(session.SelectedTag2.Value))
                    {
                        Exiv2Helper.AddKeyword(fileName, session.SelectedTag2.Value);
                    }
                    if (session.SelectedTag3 != null && !string.IsNullOrEmpty(session.SelectedTag3.Value))
                    {
                        Exiv2Helper.AddKeyword(fileName, session.SelectedTag3.Value);
                    }
                    if (session.SelectedTag4 != null && !string.IsNullOrEmpty(session.SelectedTag4.Value))
                    {
                        Exiv2Helper.AddKeyword(fileName, session.SelectedTag4.Value);
                    }
                }

                if (session.ExternalData != null)
                {
                    session.ExternalData.FileName = fileName;
                }

                // prevent crash og GUI when item count updated
                Dispatcher.Invoke(new Action(delegate
                {
                    try
                    {
                        _selectedItem = session.GetNewFileItem(fileName);
                        _selectedItem.BackupFileName = backupfile;
                        _selectedItem.Series         = session.Series;
                        // _selectedItem.Transformed = tempitem.Transformed;
                        _selectedItem.AddTemplates(eventArgs.CameraDevice, session);
                        ServiceProvider.Database.Add(new DbFile(_selectedItem, eventArgs.CameraDevice.SerialNumber, eventArgs.CameraDevice.DisplayName, session.Name));
                    }
                    catch (Exception ex)
                    {
                    }
                }));

                // execute plugins which are executed after transfer
                ExecuteAutoexportPlugins(eventArgs.CameraDevice, _selectedItem, true);

                Dispatcher.Invoke(() =>
                {
                    _selectedItem.RemoveThumbs();
                    session.Add(_selectedItem);
                    ServiceProvider.OnFileTransfered(_selectedItem);
                });


                if (ServiceProvider.Settings.MinimizeToTrayIcon && !IsVisible && !ServiceProvider.Settings.HideTrayNotifications)
                {
                    MyNotifyIcon.HideBalloonTip();
                    MyNotifyIcon.ShowBalloonTip("Photo transfered", fileName, BalloonIcon.Info);
                }

                ServiceProvider.DeviceManager.LastCapturedImage[eventArgs.CameraDevice] = fileName;

                //select the new file only when the multiple camera support isn't used to prevent high CPU usage on raw files
                if (ServiceProvider.Settings.AutoPreview &&
                    !ServiceProvider.WindowsManager.Get(typeof(MultipleCameraWnd)).IsVisible&&
                    !ServiceProvider.Settings.UseExternalViewer)
                {
                    if ((Path.GetExtension(fileName).ToLower() == ".jpg" && ServiceProvider.Settings.AutoPreviewJpgOnly) ||
                        !ServiceProvider.Settings.AutoPreviewJpgOnly)
                    {
                        if ((DateTime.Now - _lastLoadTime).TotalSeconds < 4)
                        {
                            _selectiontimer.Stop();
                            _selectiontimer.Start();
                        }
                        else
                        {
                            ServiceProvider.WindowsManager.ExecuteCommand(WindowsCmdConsts.Select_Image, _selectedItem);
                        }
                    }
                }
                _lastLoadTime = DateTime.Now;
                //ServiceProvider.Settings.Save(session);
                StaticHelper.Instance.SystemMessage = TranslationStrings.MsgPhotoTransferDone + " " + strTransfer;

                if (ServiceProvider.Settings.UseExternalViewer &&
                    File.Exists(ServiceProvider.Settings.ExternalViewerPath))
                {
                    string arg = ServiceProvider.Settings.ExternalViewerArgs;
                    arg = arg.Contains("%1") ? arg.Replace("%1", fileName) : arg + " " + fileName;
                    PhotoUtils.Run(ServiceProvider.Settings.ExternalViewerPath, arg, ProcessWindowStyle.Normal);
                }
                if (ServiceProvider.Settings.PlaySound)
                {
                    PhotoUtils.PlayCaptureSound();
                }
                eventArgs.CameraDevice.ReleaseResurce(eventArgs.Handle);

                //show fullscreen only when the multiple camera support isn't used
                if (ServiceProvider.Settings.Preview &&
                    !ServiceProvider.WindowsManager.Get(typeof(MultipleCameraWnd)).IsVisible&&
                    !ServiceProvider.Settings.UseExternalViewer)
                {
                    ServiceProvider.WindowsManager.ExecuteCommand(WindowsCmdConsts.FullScreenWnd_ShowTimed);
                }

                Log.Debug("Photo transfer done.");
            }
            catch (Exception ex)
            {
                eventArgs.CameraDevice.IsBusy       = false;
                StaticHelper.Instance.SystemMessage = TranslationStrings.MsgPhotoTransferError + " " + ex.Message;
                Log.Error("Transfer error !", ex);
            }
            // not indicated to be used
            GC.Collect();
            //GC.WaitForPendingFinalizers();
        }
Esempio n. 30
0
 private void button1_Click(object sender, RoutedEventArgs e)
 {
     PhotoUtils.Run("http://www.digicamcontrol.com/");
 }