Пример #1
0
        private void cameraDevice_CameraInitDone(ICameraDevice cameraDevice)
        {
            Log.Debug("cameraDevice_CameraInitDone 1");
            var          property = cameraDevice.LoadProperties();
            CameraPreset preset   = ServiceProvider.Settings.GetPreset(property.DefaultPresetName);

            // multiple canon cameras block with this settings
            Console.WriteLine(ServiceProvider.DeviceManager.ConnectedDevices.Count);

            if ((cameraDevice is CanonSDKBase && ServiceProvider.Settings.LoadCanonTransferMode) || !(cameraDevice is CanonSDKBase))
            {
                cameraDevice.CaptureInSdRam = property.CaptureInSdRam;
            }

            Log.Debug("cameraDevice_CameraInitDone 1a");
            if (ServiceProvider.Settings.SyncCameraDateTime)
            {
                try
                {
                    Log.Debug("set time 1");
                    cameraDevice.DateTime = DateTime.Now;
                    Log.Debug("set time 2");
                }
                catch (Exception exception)
                {
                    Log.Error("Unable to sysnc date time", exception);
                }
            }
            Log.Debug("cameraDevice_CameraInitDone 2");
            if (preset != null)
            {
                var thread = new Thread(delegate()
                {
                    try
                    {
                        Thread.Sleep(1500);
                        cameraDevice.WaitForCamera(5000);
                        preset.Set(cameraDevice);
                    }
                    catch (Exception e)
                    {
                        Log.Error("Unable to load default preset", e);
                    }
                });
                thread.Start();
            }
            Log.Debug("cameraDevice_CameraInitDone 3");
            ServiceProvider.Analytics.CameraConnected(cameraDevice);
        }
Пример #2
0
 private void SelectPreset(CameraPreset preset)
 {
     if (preset == null)
     {
         return;
     }
     try
     {
         preset.Set(ServiceProvider.DeviceManager.SelectedCameraDevice);
     }
     catch (Exception exception)
     {
         Log.Error("Error set preset", exception);
     }
 }
Пример #3
0
 private void MenuItem_Click_1(object sender, RoutedEventArgs e)
 {
     if (listBox1.SelectedItem != null)
     {
         CameraPreset preset = new CameraPreset();
         preset.Get((ICameraDevice)listBox1.SelectedItem);
         foreach (ICameraDevice connectedDevice in ServiceProvider.DeviceManager.ConnectedDevices)
         {
             if (connectedDevice.IsConnected && connectedDevice.IsChecked)
             {
                 preset.Set(connectedDevice);
             }
         }
     }
 }
Пример #4
0
        private void LoadInAllPreset(CameraPreset preset)
        {
            if (preset == null)
            {
                return;
            }
            var dlg = new ProgressWindow();

            dlg.Show();
            try
            {
                int i = 0;
                dlg.MaxValue = ServiceProvider.DeviceManager.ConnectedDevices.Count;
                foreach (ICameraDevice connectedDevice in ServiceProvider.DeviceManager.ConnectedDevices)
                {
                    if (connectedDevice == null || !connectedDevice.IsConnected)
                    {
                        continue;
                    }
                    try
                    {
                        dlg.Label    = connectedDevice.DisplayName;
                        dlg.Progress = i;
                        i++;
                        preset.Set(connectedDevice);
                    }
                    catch (Exception exception)
                    {
                        Log.Error("Unable to set property ", exception);
                    }
                    Thread.Sleep(250);
                }
            }
            catch (Exception exception)
            {
                Log.Error("Unable to set property ", exception);
            }
            dlg.Hide();
        }
Пример #5
0
 public void SetAsMaster()
 {
     try
     {
         int i = 0;
         dlg.MaxValue = ServiceProvider.DeviceManager.ConnectedDevices.Count;
         var preset = new CameraPreset();
         preset.Get(ServiceProvider.DeviceManager.SelectedCameraDevice);
         foreach (ICameraDevice connectedDevice in ServiceProvider.DeviceManager.ConnectedDevices)
         {
             if (connectedDevice == null || !connectedDevice.IsConnected)
             {
                 continue;
             }
             try
             {
                 if (connectedDevice != ServiceProvider.DeviceManager.SelectedCameraDevice)
                 {
                     dlg.Label    = connectedDevice.DisplayName;
                     dlg.Progress = i;
                     i++;
                     preset.Set(connectedDevice);
                 }
             }
             catch (Exception exception)
             {
                 Log.Error("Unable to set property ", exception);
             }
             Thread.Sleep(250);
         }
     }
     catch (Exception exception)
     {
         Log.Error("Unable to set as master ", exception);
     }
     dlg.Hide();
     Dispatcher.Invoke(new Action(() => btn_useasmaster.IsEnabled = true));
 }
        void cameraDevice_CameraInitDone(ICameraDevice cameraDevice)
        {
            var property = cameraDevice.LoadProperties();

            CameraPreset preset = ServiceProvider.Settings.GetPreset(property.DefaultPresetName);

            if (preset != null)
            {
                var thread = new Thread(delegate()
                {
                    try
                    {
                        Thread.Sleep(1500);
                        cameraDevice.WaitForCamera(5000);
                        preset.Set(cameraDevice);
                    }
                    catch (Exception e)
                    {
                        Log.Error("Unable to load default preset", e);
                    }
                });
                thread.Start();
            }

            if (ServiceProvider.Settings.SyncCameraDateTime)
            {
                try
                {
                    cameraDevice.DateTime = DateTime.Now;
                }
                catch (Exception exception)
                {
                    Log.Error("Unable to sysnc date time", exception);
                }
            }
        }
Пример #7
0
        private void StartupThread()
        {
            foreach (var cameraDevice in ServiceProvider.DeviceManager.ConnectedDevices)
            {
                Log.Debug("cameraDevice_CameraInitDone 1");
                var          property = cameraDevice.LoadProperties();
                CameraPreset preset   = ServiceProvider.Settings.GetPreset(property.DefaultPresetName);
                // multiple canon cameras block with this settings

                if ((cameraDevice is CanonSDKBase && ServiceProvider.Settings.LoadCanonTransferMode) || !(cameraDevice is CanonSDKBase))
                {
                    cameraDevice.CaptureInSdRam = property.CaptureInSdRam;
                }

                Log.Debug("cameraDevice_CameraInitDone 1a");
                if (ServiceProvider.Settings.SyncCameraDateTime)
                {
                    try
                    {
                        cameraDevice.DateTime = DateTime.Now;
                    }
                    catch (Exception exception)
                    {
                        Log.Error("Unable to sysnc date time", exception);
                    }
                }
                if (preset != null)
                {
                    try
                    {
                        Thread.Sleep(500);
                        cameraDevice.WaitForCamera(5000);
                        preset.Set(cameraDevice);
                    }
                    catch (Exception e)
                    {
                        Log.Error("Unable to load default preset", e);
                    }
                }
            }
            var scriptFile = ServiceProvider.Settings.StartupScript;

            if (scriptFile != null && File.Exists(scriptFile))
            {
                if (Path.GetExtension(scriptFile.ToLower()) == ".tcl")
                {
                    try
                    {
                        var manager = new TclScripManager();
                        manager.Execute(File.ReadAllText(scriptFile));
                    }
                    catch (Exception exception)
                    {
                        Log.Error("Script error", exception);
                        StaticHelper.Instance.SystemMessage = "Script error :" + exception.Message;
                    }
                }
                else
                {
                    var script = ServiceProvider.ScriptManager.Load(scriptFile);
                    script.CameraDevice = ServiceProvider.DeviceManager.SelectedCameraDevice;
                    ServiceProvider.ScriptManager.Execute(script);
                }
            }
            if ((DateTime.Now - ServiceProvider.Settings.LastUpdateCheckDate).TotalDays > 7)
            {
                if (!ServiceProvider.Branding.CheckForUpdate)
                {
                    return;
                }

                Thread.Sleep(2000);
                ServiceProvider.Settings.LastUpdateCheckDate = DateTime.Now;
                ServiceProvider.Settings.Save();
                Dispatcher.Invoke(new Action(() => NewVersionWnd.CheckForUpdate(false)));
            }
            else
            {
                if (!ServiceProvider.Branding.ShowWelcomeScreen || !ServiceProvider.Branding.OnlineReference)
                {
                    return;
                }

                // show welcome screen only if not start minimized
                if (!ServiceProvider.Settings.StartMinimized)
                {
                    Dispatcher.Invoke(() =>
                    {
                        try
                        {
                            var wnd = new Welcome();
                            wnd.ShowDialog();
                        }
                        catch
                        {
                        }
                    });
                }
            }
        }
 private void SelectPreset(CameraPreset preset)
 {
     preset.Set(ServiceProvider.DeviceManager.SelectedCameraDevice);
 }
Пример #9
0
        static int ExecuteArgs()
        {
            try
            {
                if (_arguments.Contains("export"))
                {
                    if (string.IsNullOrEmpty(_arguments["export"]))
                    {
                        Console.WriteLine("No export file is specified");
                    }
                    else
                    {
                        using (StreamWriter writer = File.CreateText(_arguments["export"]))
                        {
                            Console.WriteLine("Exporting properties to: " + _arguments["export"]);
                            CameraPreset preset = new CameraPreset();
                            preset.Get(ServiceProvider.DeviceManager.SelectedCameraDevice);
                            foreach (ValuePair valuePair in preset.Values)
                            {
                                writer.WriteLine("\"{0}\",\"{1}\"", valuePair.Name, valuePair.Value);
                            }
                            writer.Close();
                        }
                    }
                }
                if (_arguments.Contains("session"))
                {
                    PhotoSession session = ServiceProvider.Settings.GetSession(_arguments["session"]);
                    if (session != null)
                    {
                        Console.WriteLine("Using session {0}", _arguments["session"]);
                        ServiceProvider.Settings.DefaultSession = session;
                    }
                    else
                    {
                        Console.WriteLine("Session not found {0}! Using default session", _arguments["session"]);
                    }
                }
                if (_arguments.Contains("preset"))
                {
                    CameraPreset preset = ServiceProvider.Settings.GetPreset(_arguments["preset"]);
                    if (preset != null)
                    {
                        Console.WriteLine("Using preset {0}", _arguments["preset"]);
                        foreach (ICameraDevice cameraDevice in ServiceProvider.DeviceManager.ConnectedDevices)
                        {
                            preset.Set(cameraDevice);
                        }
                    }
                    else
                    {
                        Console.WriteLine("Preset not found {0}!", _arguments["preset"]);
                    }
                }
                if (_arguments.Contains("folder"))
                {
                    if (string.IsNullOrEmpty(_arguments["folder"]))
                    {
                        Console.WriteLine("No folder !!!");
                    }
                    else
                    {
                        ServiceProvider.Settings.DefaultSession.Folder = _arguments["folder"];
                    }
                }
                if (_arguments.Contains("filenametemplate"))
                {
                    if (string.IsNullOrEmpty(_arguments["filenametemplate"]))
                    {
                        Console.WriteLine("Wrong filename !!!");
                    }
                    else
                    {
                        ServiceProvider.Settings.DefaultSession.FileNameTemplate = _arguments["filenametemplate"];
                    }
                }
                if (_arguments.Contains("counter"))
                {
                    int    i   = 0;
                    string val = _arguments["counter"];
                    if (string.IsNullOrEmpty(_arguments["counter"]) || !int.TryParse(val, out i))
                    {
                        Console.WriteLine("Wrong counter !!!");
                    }
                    else
                    {
                        ServiceProvider.Settings.DefaultSession.Counter = i;
                    }
                }
                if (_arguments.Contains("filename"))
                {
                    _outFilename = _arguments["filename"];
                    //if(string.IsNullOrEmpty(_outFilename))
                    //{
                    //    SaveFileDialog dlg = new SaveFileDialog();
                    //    dlg.Filter = "Jpg file (*.jpg)|*.jpg|All files|*.*";
                    //    if(dlg.ShowDialog()==DialogResult.OK)
                    //    {
                    //        _outFilename = dlg.FileName;
                    //    }
                    //}
                }
                if (_arguments.Contains("iso"))
                {
                    if (string.IsNullOrEmpty(_arguments["iso"]))
                    {
                        Console.WriteLine("No iso number !!!");
                    }
                    else
                    {
                        Thread.Sleep(200);
                        ServiceProvider.DeviceManager.SelectedCameraDevice.IsoNumber.SetValue(_arguments["iso"]);
                    }
                }
                if (_arguments.Contains("aperture"))
                {
                    if (string.IsNullOrEmpty(_arguments["aperture"]))
                    {
                        Console.WriteLine("No aperture number !!!");
                    }
                    else
                    {
                        Thread.Sleep(200);
                        ServiceProvider.DeviceManager.SelectedCameraDevice.FNumber.SetValue("ƒ/" + _arguments["aperture"]);
                    }
                }
                if (_arguments.Contains("shutter"))
                {
                    if (string.IsNullOrEmpty(_arguments["shutter"]))
                    {
                        Console.WriteLine("No shutter number !!!");
                    }
                    else
                    {
                        Thread.Sleep(200);
                        ServiceProvider.DeviceManager.SelectedCameraDevice.ShutterSpeed.SetValue(_arguments["shutter"]);
                    }
                }
                if (_arguments.Contains("ec"))
                {
                    if (string.IsNullOrEmpty(_arguments["ec"]))
                    {
                        Console.WriteLine("No ec number !!!");
                    }
                    else
                    {
                        Thread.Sleep(200);
                        ServiceProvider.DeviceManager.SelectedCameraDevice.ExposureCompensation.SetValue(_arguments["ec"]);
                    }
                }

                if (_arguments.Contains("comment"))
                {
                    Thread.Sleep(200);
                    ServiceProvider.DeviceManager.SelectedCameraDevice.SetCameraField(CameraFieldType.Comment, _arguments["comment"]);
                    Console.WriteLine("Comment was set");
                }
                if (_arguments.Contains("artist"))
                {
                    Thread.Sleep(200);
                    ServiceProvider.DeviceManager.SelectedCameraDevice.SetCameraField(CameraFieldType.Artist, _arguments["artist"]);
                    Console.WriteLine("Artist was set");
                }
                if (_arguments.Contains("copyright"))
                {
                    Thread.Sleep(200);
                    ServiceProvider.DeviceManager.SelectedCameraDevice.SetCameraField(CameraFieldType.Copyright, _arguments["copyright"]);
                    Console.WriteLine("Copyright was set");
                }

                if (_arguments.Contains("capture"))
                {
                    new Thread(Capture).Start();
                    Thread.Sleep(200);
                    return(0);
                }

                if (_arguments.Contains("capturenoaf"))
                {
                    try
                    {
                        ServiceProvider.DeviceManager.SelectedCameraDevice.CapturePhotoNoAf();
                    }
                    catch (Exception exception)
                    {
                        Console.WriteLine("Error occurred while capturing photo " + exception);
                        ServiceProvider.DeviceManager.SelectedCameraDevice.IsBusy = false;
                        return(1);
                    }

                    return(0);
                }
                if (_arguments.Contains("captureall"))
                {
                    foreach (ICameraDevice cameraDevice in ServiceProvider.DeviceManager.ConnectedDevices)
                    {
                        ICameraDevice device = cameraDevice;
                        new Thread(device.CapturePhoto).Start();
                    }
                }
                if (_arguments.Contains("captureallnoaf"))
                {
                    foreach (ICameraDevice cameraDevice in ServiceProvider.DeviceManager.ConnectedDevices)
                    {
                        ICameraDevice device = cameraDevice;
                        new Thread(device.CapturePhotoNoAf).Start();
                    }
                }
            }
            catch (Exception exception)
            {
                Log.Error(exception);
                Console.WriteLine(exception.Message);
                return(1);
            }
            return(0);
        }
Пример #10
0
        private static int ExecuteArgs()
        {
            try
            {
                if (_arguments.Contains("verbose"))
                {
                    /*  /verbose is processed in main() to set the flag and has nothing to do here */
                }
#if DEBUG
                if (_arguments.Contains("nop"))
                {
                    /* nop - return to caller w/o processing any other parameters
                     *    although: help is processed out of line in main() (so /nop in /help /nop is ignored)
                     *    Several things such as InitApplication() and all of the camera related functions in there */
                    return(0);
                }
#endif

                if (_arguments.Contains("export"))
                {
                    if (string.IsNullOrEmpty(_arguments["export"]))
                    {
                        Console.WriteLine("No export file is specified");
                    }
                    else
                    {
                        using (StreamWriter writer = File.CreateText(_arguments["export"]))
                        {
                            Console.WriteLine("Exporting properties to: " + _arguments["export"]);
                            CameraPreset preset = new CameraPreset();
                            preset.Get(ServiceProvider.DeviceManager.SelectedCameraDevice);
                            foreach (ValuePair valuePair in preset.Values)
                            {
                                writer.WriteLine("\"{0}\",\"{1}\"", valuePair.Name, valuePair.Value);
                            }
                            writer.Close();
                        }
                    }
                }
                if (_arguments.Contains("session"))
                {
                    PhotoSession session = ServiceProvider.Settings.GetSession(_arguments["session"]);
                    if (session != null)
                    {
                        Console.WriteLine("Using session {0}", _arguments["session"]);
                        ServiceProvider.Settings.DefaultSession = session;
                    }
                    else
                    {
                        Console.WriteLine("Session not found {0}! Using default session", _arguments["session"]);
                    }
                }
                if (_arguments.Contains("preset"))
                {
                    CameraPreset preset = ServiceProvider.Settings.GetPreset(_arguments["preset"]);
                    if (preset != null)
                    {
                        Console.WriteLine("Using preset {0}", _arguments["preset"]);
                        foreach (ICameraDevice cameraDevice in ServiceProvider.DeviceManager.ConnectedDevices)
                        {
                            preset.Set(cameraDevice);
                        }
                    }
                    else
                    {
                        Console.WriteLine("Preset not found {0}!", _arguments["preset"]);
                    }
                }
                if (_arguments.Contains("folder"))
                {
                    if (string.IsNullOrEmpty(_arguments["folder"]))
                    {
                        Console.WriteLine("No folder !!!");
                    }
                    else
                    {
                        ServiceProvider.Settings.DefaultSession.Folder = _arguments["folder"];
                    }
                }
                if (_arguments.Contains("filenametemplate"))
                {
                    if (string.IsNullOrEmpty(_arguments["filenametemplate"]))
                    {
                        Console.WriteLine("Wrong filename !!!");
                    }
                    else
                    {
                        ServiceProvider.Settings.DefaultSession.FileNameTemplate = _arguments["filenametemplate"];
                    }
                }
                if (_arguments.Contains("counter"))
                {
                    int    i   = 0;
                    string val = _arguments["counter"];
                    if (string.IsNullOrEmpty(_arguments["counter"]) || !int.TryParse(val, out i))
                    {
                        Console.WriteLine("Wrong counter !!!");
                    }
                    else
                    {
                        ServiceProvider.Settings.DefaultSession.Counter = i;
                    }
                }
                if (_arguments.Contains("filename"))
                {
                    _outFilename = _arguments["filename"];
                    //if(string.IsNullOrEmpty(_outFilename))
                    //{
                    //    SaveFileDialog dlg = new SaveFileDialog();
                    //    dlg.Filter = "Jpg file (*.jpg)|*.jpg|All files|*.*";
                    //    if(dlg.ShowDialog()==DialogResult.OK)
                    //    {
                    //        _outFilename = dlg.FileName;
                    //    }
                    //}
                }
                if (_arguments.Contains("iso"))
                {
                    if (string.IsNullOrEmpty(_arguments["iso"]))
                    {
                        Console.WriteLine("No iso number !!!");
                    }
                    else
                    {
                        Thread.Sleep(200);
                        ServiceProvider.DeviceManager.SelectedCameraDevice.IsoNumber.SetValue(_arguments["iso"]);
                    }
                }
                if (_arguments.Contains("aperture"))
                {
                    if (string.IsNullOrEmpty(_arguments["aperture"]))
                    {
                        Console.WriteLine("No aperture number !!!");
                    }
                    else
                    {
                        Thread.Sleep(200);
                        ServiceProvider.DeviceManager.SelectedCameraDevice.FNumber.SetValue(_arguments["aperture"]);
                    }
                }
                if (_arguments.Contains("shutter"))
                {
                    if (string.IsNullOrEmpty(_arguments["shutter"]))
                    {
                        Console.WriteLine("No shutter number !!!");
                    }
                    else
                    {
                        Thread.Sleep(200);
                        ServiceProvider.DeviceManager.SelectedCameraDevice.ShutterSpeed.SetValue(_arguments["shutter"]);
                    }
                }

                if (_arguments.Contains("compression"))
                {
                    if (string.IsNullOrEmpty(_arguments["compression"]))
                    {
                        Console.WriteLine("No compression !!!");
                    }
                    else
                    {
                        Thread.Sleep(200);
                        ServiceProvider.DeviceManager.SelectedCameraDevice.CompressionSetting.SetValue(
                            _arguments["compression"].Replace('_', ' '));
                    }
                }

                if (_arguments.Contains("ec"))
                {
                    if (string.IsNullOrEmpty(_arguments["ec"]))
                    {
                        Console.WriteLine("No ec number !!!");
                    }
                    else
                    {
                        Thread.Sleep(200);
                        ServiceProvider.DeviceManager.SelectedCameraDevice.ExposureCompensation.SetValue(
                            _arguments["ec"]);
                    }
                }

                if (_arguments.Contains("comment"))
                {
                    Thread.Sleep(200);
                    ServiceProvider.DeviceManager.SelectedCameraDevice.SetCameraField(CameraFieldType.Comment,
                                                                                      _arguments["comment"]);
                    Console.WriteLine("Comment was set");
                }
                if (_arguments.Contains("artist"))
                {
                    Thread.Sleep(200);
                    ServiceProvider.DeviceManager.SelectedCameraDevice.SetCameraField(CameraFieldType.Artist,
                                                                                      _arguments["artist"]);
                    Console.WriteLine("Artist was set");
                }
                if (_arguments.Contains("copyright"))
                {
                    Thread.Sleep(200);
                    ServiceProvider.DeviceManager.SelectedCameraDevice.SetCameraField(CameraFieldType.Copyright,
                                                                                      _arguments["copyright"]);
                    Console.WriteLine("Copyright was set");
                }

                if (_arguments.Contains("capture"))
                {
                    new Thread(Capture).Start();
                    Thread.Sleep(200);
                    return(0);
                }

                if (_arguments.Contains("format"))
                {
                    Console.WriteLine("Card format in progress...");
                    ServiceProvider.DeviceManager.SelectedCameraDevice.FormatStorage(null);
                    Thread.Sleep(200);
                    Console.WriteLine("Card format done");
                    return(0);
                }

                if (_arguments.Contains("capturenoaf"))
                {
                    try
                    {
                        ServiceProvider.DeviceManager.SelectedCameraDevice.CapturePhotoNoAf();
                    }
                    catch (Exception exception)
                    {
                        Console.WriteLine("Error occurred while capturing photo " + exception);
                        ServiceProvider.DeviceManager.SelectedCameraDevice.IsBusy = false;
                        return(1);
                    }

                    return(0);
                }
                if (_arguments.Contains("captureall"))
                {
                    foreach (ICameraDevice cameraDevice in ServiceProvider.DeviceManager.ConnectedDevices)
                    {
                        ICameraDevice device = cameraDevice;
                        new Thread(device.CapturePhoto).Start();
                    }
                }
                if (_arguments.Contains("captureallnoaf"))
                {
                    foreach (ICameraDevice cameraDevice in ServiceProvider.DeviceManager.ConnectedDevices)
                    {
                        ICameraDevice device = cameraDevice;
                        new Thread(device.CapturePhotoNoAf).Start();
                    }
                }
            }
            catch (Exception exception)
            {
                Log.Error(exception);
                Console.WriteLine(exception.Message);
                return(1);
            }
            return(0);
        }