public ComponentManager(IComponentConfiguration configuration, IImageProvider imageProvider, ICameraDevice cameraDevice) { device = cameraDevice; provider = imageProvider; componentConfiguration = configuration; }
public void Verify(ICameraDevice camera) { try { camera.Mode.HaveError = camera.Mode.Value != GetValue("Mode"); camera.CompressionSetting.HaveError = camera.CompressionSetting.Value != GetValue("CompressionSetting"); camera.ExposureCompensation.HaveError = camera.ExposureCompensation.Value != GetValue("ExposureCompensation"); camera.ExposureMeteringMode.HaveError = camera.ExposureMeteringMode.Value != GetValue("ExposureMeteringMode"); camera.FNumber.HaveError = camera.FNumber.Value != GetValue("FNumber"); camera.IsoNumber.HaveError = camera.IsoNumber.Value != GetValue("IsoNumber"); camera.ShutterSpeed.HaveError = camera.ShutterSpeed.Value != GetValue("ShutterSpeed"); camera.WhiteBalance.HaveError = camera.WhiteBalance.Value != GetValue("WhiteBalance"); camera.FocusMode.HaveError = camera.FocusMode.Value != GetValue("FocusMode"); if (camera.AdvancedProperties != null) { foreach (PropertyValue<long> propertyValue in camera.AdvancedProperties) { propertyValue.HaveError = propertyValue.Value != GetValue(propertyValue.Name); } } } catch (Exception ex) { Log.Error("Unable to verify the preset " + Name, ex); } }
private void ExecuteAutoexportPlugins(ICameraDevice cameraDevice, FileItem fileItem, bool runOnTransfered) { foreach (AutoExportPluginConfig plugin in ServiceProvider.Settings.DefaultSession.AutoExportPluginConfigs) { if (plugin.RunAfterTransfer != runOnTransfered) { continue; } if (!plugin.IsEnabled) { continue; } if (!plugin.Evaluate(cameraDevice)) { continue; } var pl = ServiceProvider.PluginManager.GetAutoExportPlugin(plugin.Type); try { pl.Execute(fileItem, 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); } } }
public AstroLiveViewViewModel(ICameraDevice device, Window window) : base(device, window) { ZoomFactor = 1; StarWindowSize = 30; StarSize = 123.11; }
private void DeviceManager_CameraDisconnected(ICameraDevice cameraDevice) { if (this.CameraDisconnected != null) { this.CameraDisconnected(this, EventArgs.Empty); } }
public FileItem(DeviceObject deviceObject, ICameraDevice device) { Device = device; DeviceObject = deviceObject; ItemType = FileItemType.CameraObject; FileName = deviceObject.FileName; FileDate = deviceObject.FileDate; IsChecked = true; IsLiked = false; IsUnLiked = false; if (deviceObject.ThumbData != null && deviceObject.ThumbData.Length > 4) { try { var stream = new MemoryStream(deviceObject.ThumbData, 0, deviceObject.ThumbData.Length); using (var bmp = new Bitmap(stream)) { Thumbnail = BitmapSourceConvert.ToBitmapSource(bmp); } stream.Close(); } catch (Exception exception) { Log.Debug("Error loading device thumb ", exception); } } }
static void DeviceManagerCameraConnected(ICameraDevice cameraDevice) { CameraProperty property = ServiceProvider.Settings.CameraProperties.Get(cameraDevice); cameraDevice.DisplayName = property.DeviceName; cameraDevice.AttachedPhotoSession = ServiceProvider.Settings.GetSession(property.PhotoSessionName); }
public string Pharse(string template, PhotoSession session, ICameraDevice device, string fileName, string tempfileName) { if (!File.Exists(tempfileName)) { return(""); } try { _sp.PortName = Port; _sp.BaudRate = 9600; _sp.WriteTimeout = 3500; _sp.ReadTimeout = 3500; _sp.Open(); _sp.WriteLine(ArduinoLabelCommand); Thread.Sleep(500); return(_sp.ReadLine()); } catch (Exception ex) { Log.Debug("ArduinoLabel error", ex); StaticHelper.Instance.SystemMessage = ex.Message; } finally { if (_sp != null && _sp.IsOpen) { _sp.Close(); } } return(template); }
private void DeviceManager_CameraSelected(ICameraDevice oldcameraDevice, ICameraDevice newcameraDevice) { if (newcameraDevice != null && newcameraDevice.IsConnected) { StartLiveView(); } }
void DeviceManager_CameraConnected(ICameraDevice cameraDevice) { if (CurrentScript != null) { CurrentScript.Variabiles["cameraccount"] = ServiceProvider.DeviceManager.ConnectedDevices.Count.ToString(); } }
/// <summary> /// Captures with all connected cameras. /// </summary> /// <param name="delay">The delay between camera captures in milli sec</param> public static void CaptureAll(int delay) { foreach ( ICameraDevice connectedDevice in ServiceProvider.DeviceManager.ConnectedDevices.Where( connectedDevice => connectedDevice.IsConnected && connectedDevice.IsChecked)) { Thread.Sleep(delay); ICameraDevice device = connectedDevice; Thread threadcamera = new Thread(new ThreadStart(delegate { try { Capture(device); } catch (Exception exception) { Log.Error(exception); StaticHelper.Instance. SystemMessage = exception.Message; } })); threadcamera.Start(); } }
public static void StartLiveView(ICameraDevice device) { // some nikon cameras can set af to manual //force to capture in ram if (device is NikonBase) { if (!_recordtoRam.ContainsKey(device)) { _recordtoRam.Add(device, device.CaptureInSdRam); } else { _recordtoRam[device] = device.CaptureInSdRam; } device.CaptureInSdRam = true; if (!_hostMode.ContainsKey(device)) { _hostMode.Add(device, device.HostMode); } else { _hostMode[device] = device.HostMode; } device.HostMode = true; } device.StartLiveView(); }
public string GetExample(string res, PhotoSession session, ICameraDevice device, string fileName) { string file = ""; if (session.Files.Count > 0) { file = session.Files[0].FileName; } Regex regPattern = new Regex(@"\[(.*?)\]", RegexOptions.Singleline); MatchCollection matchX = regPattern.Matches(res); foreach (Match match in matchX) { if (ServiceProvider.FilenameTemplateManager.Templates.ContainsKey(match.Value)) { res = res.Replace(match.Value, ServiceProvider.FilenameTemplateManager.Templates[match.Value].Pharse(match.Value, session, device, fileName, file)); } } //prevent multiple \ if a tag is empty while (res.Contains(@"\\")) { res = res.Replace(@"\\", @"\"); } // if the file name start with \ the Path.Combine isn't work right if (res.StartsWith("\\")) { res = res.Substring(1); } return(res); }
/// <summary> /// Raise CameraDisconnected event. /// </summary> /// <param name="cameraDevice">The camera device.</param> public void OnCameraDisconnected(ICameraDevice cameraDevice) { if (CameraDisconnected != null) { CameraDisconnected(cameraDevice); } }
public void Get(ICameraDevice camera) { Add(GetFrom(camera.Mode, "Mode")); Add(GetFrom(camera.CompressionSetting, "CompressionSetting")); Add(GetFrom(camera.ExposureCompensation, "ExposureCompensation")); Add(GetFrom(camera.ExposureMeteringMode, "ExposureMeteringMode")); Add(GetFrom(camera.FNumber, "FNumber")); Add(GetFrom(camera.IsoNumber, "IsoNumber")); Add(GetFrom(camera.ShutterSpeed, "ShutterSpeed")); Add(GetFrom(camera.WhiteBalance, "WhiteBalance")); Add(GetFrom(camera.FocusMode, "FocusMode")); Add(GetFrom(camera.LiveViewImageZoomRatio, "LiveViewImageZoomRatio")); Add(new ValuePair { Name = "CaptureInSdRam", Value = camera.CaptureInSdRam.ToString() }); var property = camera.LoadProperties(); Add(new ValuePair { Name = "NoDownload", Value = property.NoDownload.ToString() }); if (camera.AdvancedProperties != null) { foreach (PropertyValue <long> propertyValue in camera.AdvancedProperties) { Add(GetFrom(propertyValue, propertyValue.Name)); } } }
public bool Evaluate(ICameraDevice device) { if (Conditions.Count == 0) { return(true); } var res = Conditions[0].Evaluate(device); if (Conditions.Count == 1) { return(res); } for (int i = 1; i < Conditions.Count; i++) { var cond = Conditions[i]; if (cond.Operator == "AND") { res = res && cond.Evaluate(device); } else { res = res || cond.Evaluate(device); } } return(res); }
public void AddTemplates(ICameraDevice device, PhotoSession session) { string[] skipItems = { "[Session Name]", "[Counter 3 digit]", "[Counter 4 digit]", "[Counter 5 digit]", "[Counter 6 digit]", "[Counter 7 digit]", "[Counter 8 digit]", "[Counter 9 digit]", "[Camera Counter 3 digit]", "[Camera Counter 4 digit]", "[Camera Counter 5 digit]", "[Camera Counter 6 digit]", "[Camera Counter 7 digit]", "[Camera Counter 8 digit]", "[Camera Counter 9 digit]" }; foreach (var template in ServiceProvider.FilenameTemplateManager.Templates) { if (skipItems.Contains(template.Key)) { continue; } var val = template.Value.Pharse(template.Key, session, device, FileName); if (!string.IsNullOrWhiteSpace(val)) { FileNameTemplates.Add(new ValuePair() { Name = template.Key, Value = val }); } } }
private void DeviceManager_CameraSelected(ICameraDevice oldcameraDevice, ICameraDevice newcameraDevice) { if (newcameraDevice == null) { return; } Log.Debug("DeviceManager_CameraSelected 1"); var thread = new Thread(delegate() { CameraProperty property = newcameraDevice.LoadProperties(); // load session data only if not session attached to the selected camera if (newcameraDevice.AttachedPhotoSession == null) { newcameraDevice.AttachedPhotoSession = ServiceProvider.Settings.GetSession(property.PhotoSessionName); } if (newcameraDevice.AttachedPhotoSession != null) { ServiceProvider.Settings.DefaultSession = (PhotoSession)newcameraDevice.AttachedPhotoSession; } }); thread.Start(); Log.Debug("DeviceManager_CameraSelected 2"); }
public AstroLiveViewViewModel(ICameraDevice device) :base(device) { ZoomFactor = 1; StarWindowSize = 30; StarSize = 123.11; }
public void Get(ICameraDevice camera) { Add(GetFrom(camera.Mode, "Mode")); Add(GetFrom(camera.CompressionSetting, "CompressionSetting")); Add(GetFrom(camera.ExposureCompensation, "ExposureCompensation")); Add(GetFrom(camera.ExposureMeteringMode, "ExposureMeteringMode")); Add(GetFrom(camera.FNumber, "FNumber")); Add(GetFrom(camera.IsoNumber, "IsoNumber")); Add(GetFrom(camera.ShutterSpeed, "ShutterSpeed")); Add(GetFrom(camera.WhiteBalance, "WhiteBalance")); Add(GetFrom(camera.FocusMode, "FocusMode")); Add(GetFrom(camera.LiveViewImageZoomRatio, "LiveViewImageZoomRatio")); Add(new ValuePair { Name = "CaptureInSdRam", Value = camera.CaptureInSdRam.ToString() }); Add(new ValuePair { Name = "HostMode", Value = camera.HostMode.ToString() }); var property = ServiceProvider.Settings.CameraProperties.Get(camera); CameraProperty.NoDownload = property.NoDownload; CameraProperty.CaptureInSdRam = property.CaptureInSdRam; if(camera.AdvancedProperties!=null) { foreach (PropertyValue<long> propertyValue in camera.AdvancedProperties) { Add(GetFrom(propertyValue, propertyValue.Name)); } } }
private PropertyValue <long> GetProperty(string name, ICameraDevice device) { switch (name) { case "Mode": return(device.Mode); case "CompressionSetting": return(device.CompressionSetting); case "ExposureCompensation": return(device.ExposureCompensation); case "ExposureMeteringMode": return(device.ExposureCompensation); case "FNumber": return(device.FNumber); case "IsoNumber": return(device.IsoNumber); case "ShutterSpeed": return(device.ShutterSpeed); case "WhiteBalance": return(device.WhiteBalance); case "FocusMode": return(device.FocusMode); } return(null); }
public void Verify(ICameraDevice camera) { try { camera.Mode.HaveError = camera.Mode.Value != GetValue("Mode"); camera.CompressionSetting.HaveError = camera.CompressionSetting.Value != GetValue("CompressionSetting"); camera.ExposureCompensation.HaveError = camera.ExposureCompensation.Value != GetValue("ExposureCompensation"); camera.ExposureMeteringMode.HaveError = camera.ExposureMeteringMode.Value != GetValue("ExposureMeteringMode"); camera.FNumber.HaveError = camera.FNumber.Value != GetValue("FNumber"); camera.IsoNumber.HaveError = camera.IsoNumber.Value != GetValue("IsoNumber"); camera.ShutterSpeed.HaveError = camera.ShutterSpeed.Value != GetValue("ShutterSpeed"); camera.WhiteBalance.HaveError = camera.WhiteBalance.Value != GetValue("WhiteBalance"); camera.FocusMode.HaveError = camera.FocusMode.Value != GetValue("FocusMode"); if (camera.AdvancedProperties != null) { foreach (PropertyValue <long> propertyValue in camera.AdvancedProperties) { propertyValue.HaveError = propertyValue.Value != GetValue(propertyValue.Name); } } } catch (Exception ex) { Log.Error("Unable to verify the preset " + Name, ex); } }
public static LiveViewData GetLiveViewImage(ICameraDevice device) { lock (_locker) { return(device.GetLiveViewImage()); } }
public FileItem(DeviceObject deviceObject, ICameraDevice device) { Device = device; DeviceObject = deviceObject; ItemType = FileItemType.CameraObject; FileName = deviceObject.FileName; FileDate = deviceObject.FileDate; IsChecked = true; if (deviceObject.ThumbData != null && deviceObject.ThumbData.Length > 4) { try { var stream = new MemoryStream(deviceObject.ThumbData, 0, deviceObject.ThumbData.Length); using (var bmp = new Bitmap(stream)) { Thumbnail = BitmapSourceConvert.ToBitmapSource(bmp); } stream.Close(); } catch (Exception exception) { Log.Debug("Error loading device thumb ", exception); } } }
public string GetNextFileName(string ext, ICameraDevice device) { lock (_locker) { if (string.IsNullOrEmpty(ext)) { ext = ".nef"; } if (!string.IsNullOrEmpty(_lastFilename) && RawExtensions.Contains(ext.ToLower()) && !RawExtensions.Contains(Path.GetExtension(_lastFilename).ToLower())) { string rawfile = Path.Combine(Folder, FormatFileName(device, ext, false) + (!ext.StartsWith(".") ? "." : "") + ext); if (!File.Exists(rawfile)) { return(rawfile); } } string fileName = Path.Combine(Folder, FormatFileName(device, ext) + (!ext.StartsWith(".") ? "." : "") + ext); if (File.Exists(fileName) && !AllowOverWrite) { return(GetNextFileName(ext, device)); } _lastFilename = fileName; return(fileName); } }
public string Pharse(string template, PhotoSession session, ICameraDevice device, string fileName, string tempfileName) { if (!File.Exists(tempfileName)) { return(""); } // load a bitmap PhotoUtils.WaitForFile(tempfileName); var file = tempfileName; if (Path.GetExtension(fileName).ToLower() == ".cr2" || Path.GetExtension(fileName).ToLower() == ".nef") { string dcraw_exe = Path.Combine(Settings.ApplicationFolder, "dcraw.exe"); if (File.Exists(dcraw_exe)) { string thumb = Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(tempfileName) + ".thumb.jpg"); PhotoUtils.RunAndWait(dcraw_exe, string.Format(" -e -O \"{0}\" \"{1}\"", thumb, tempfileName)); if (File.Exists(thumb)) { var res = GetBarcode(thumb, template); File.Delete(thumb); return(res); } } } else { return(GetBarcode(tempfileName, template)); } return(template); }
private void LiveViewManager_PreviewLoaded(ICameraDevice cameraDevice, string file) { Task.Factory.StartNew(() => { Thread.Sleep(500); App.Current.BeginInvoke(zoomAndPanControl.ScaleToFit); }); }
private string FormatFileName(ICameraDevice device, string ext, bool incremetCounter = true) { CameraProperty property = ServiceProvider.Settings.CameraProperties.Get(device); string res = FileNameTemplate; if (!res.Contains("$C") && !AllowOverWrite) { res += "$C"; } if (UseCameraCounter) { if (incremetCounter) { property.Counter = property.Counter + property.CounterInc; } res = res.Replace("$C", property.Counter.ToString(new string('0', LeadingZeros))); } else { if (incremetCounter) { Counter++; } res = res.Replace("$C", Counter.ToString(new string('0', LeadingZeros))); } res = res.Replace("$N", Name.Trim()); if (device.ExposureCompensation != null) { res = res.Replace("$E", device.ExposureCompensation.Value != "0" ? device.ExposureCompensation.Value : ""); } res = res.Replace("$D", DateTime.Now.ToString("yyyy-MM-dd")); res = res.Replace("$B", Barcode ?? ""); var date = new DateTime(1970, 1, 1, 0, 0, 0, DateTime.Now.Kind); var unixTimestamp = System.Convert.ToInt64((DateTime.Now - date).TotalSeconds); res = res.Replace("$UTime", unixTimestamp.ToString()); res = res.Replace("$Type", GetType(ext)); res = res.Replace("$X", property.DeviceName.Replace(":", "_").Replace("?", "_").Replace("*", "_")); res = res.Replace("$Tag1", SelectedTag1 != null ? SelectedTag1.Value.Trim() : ""); res = res.Replace("$Tag2", SelectedTag1 != null ? SelectedTag2.Value.Trim() : ""); res = res.Replace("$Tag3", SelectedTag1 != null ? SelectedTag3.Value.Trim() : ""); res = res.Replace("$Tag4", SelectedTag1 != null ? SelectedTag4.Value.Trim() : ""); //prevent multiple \ if a tag is empty while (res.Contains(@"\\")) { res = res.Replace(@"\\", @"\"); } // if the file name start with \ the Path.Combine isn't work right if (res.StartsWith("\\")) { res = res.Substring(1); } return(res); }
private string FormatFileName(ICameraDevice device, string ext, bool incremetCounter = true) { CameraProperty property = ServiceProvider.Settings.CameraProperties.Get(device); string res = FileNameTemplate; if (!res.Contains("$C")) { res += "$C"; } if (UseCameraCounter) { if (incremetCounter) { property.Counter = property.Counter + property.CounterInc; } res = res.Replace("$C", property.Counter.ToString(new string('0', LeadingZeros))); } else { if (incremetCounter) { Counter++; } res = res.Replace("$C", Counter.ToString(new string('0', LeadingZeros))); } res = res.Replace("$N", Name.Trim()); if (device.ExposureCompensation != null) { res = res.Replace("$E", device.ExposureCompensation.Value != "0" ? device.ExposureCompensation.Value : ""); } res = res.Replace("$D", DateTime.Now.ToString("yyyy-MM-dd")); res = res.Replace("$Type", GetType(ext)); res = res.Replace("$UTime", ((long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds).ToString()); res = res.Replace("$Qt", (String.IsNullOrWhiteSpace(QuickTag) || ServiceProvider.Settings.DefaultSession.QuickTagOption == QuickTagOptions.None) ? "" : QuickTag + "_"); res = res.Replace("$B", LastBarcode); res = res.Replace("$-", BarcodeDelimiter.ToString()); res = res.Replace("$X", property.DeviceName.Replace(":", "_").Replace("?", "_").Replace("*", "_")); res = res.Replace("$Tag1", SelectedTag1 != null ? SelectedTag1.Value.Trim() : ""); res = res.Replace("$Tag2", SelectedTag1 != null ? SelectedTag2.Value.Trim() : ""); res = res.Replace("$Tag3", SelectedTag1 != null ? SelectedTag3.Value.Trim() : ""); res = res.Replace("$Tag4", SelectedTag1 != null ? SelectedTag4.Value.Trim() : ""); //prevent multiple \ if a tag is empty while (res.Contains(@"\\")) { res = res.Replace(@"\\", @"\"); } // if the file name start with \ the Path.Combine isn't work right if (res.StartsWith("\\")) { res = res.Substring(1); } return(res); }
public override bool Execute(ScriptObject scriptObject) { foreach (ICameraDevice cameraDevice in ServiceProvider.DeviceManager.ConnectedDevices) { ICameraDevice device = cameraDevice; new Thread(() => Capture(device)).Start(); } return(true); }
public static void OnPreviewLoaded(ICameraDevice cameradevice, string file) { var handler = PreviewLoaded; if (handler != null) { handler(cameradevice, file); } }
public void CameraConnected(ICameraDevice device) { if (device is FakeCameraDevice) { return; } SendEvent("Camera", "Connected", device.DeviceName, ServiceProvider.DeviceManager.ConnectedDevices.Count - (ServiceProvider.Settings.AddFakeCamera ? 1 : 0)); }
public FileItem(ICameraDevice device, DateTime time) { Device = device; ItemType = FileItemType.CameraObject; IsChecked = true; ItemType = FileItemType.Missing; FileName = "Missing"; FileDate = time; }
private void CapturePhotos() { _photocounter++; StaticHelper.Instance.SystemMessage = string.Format("Capture started multiple cameras {0}", _photocounter); Thread thread = new Thread(new ThreadStart(delegate { while (CamerasAreBusy()) { } try { foreach (ICameraDevice connectedDevice in ServiceProvider.DeviceManager.ConnectedDevices.Where(connectedDevice => connectedDevice.IsConnected && connectedDevice.IsChecked)) { Thread.Sleep(DelaySec); ICameraDevice device = connectedDevice; Thread threadcamera = new Thread(new ThreadStart(delegate { try { if (DisbleAutofocus && device.GetCapability(CapabilityEnum.CaptureNoAf)) { device.CapturePhotoNoAf(); } else { CameraHelper.Capture(device); } } catch (Exception exception) { Log.Error(exception); StaticHelper.Instance.SystemMessage = exception.Message; } })); threadcamera.Start(); } } catch (Exception exception) { Log.Error(exception); } Thread.Sleep(DelaySec); if (_photocounter < NumOfPhotos) { _timer.Start(); } else { StopCapture(); } })); thread.Start(); }
public LiveViewForm(ICameraDevice cameraDevice) { //set live view default frame rate to 15 _liveViewTimer.Interval = 1000 / 15; _liveViewTimer.Tick += _liveViewTimer_Tick; CameraDevice = cameraDevice; CameraDevice.CameraDisconnected += CameraDevice_CameraDisconnected; InitializeComponent(); }
public void CameraConnected(ICameraDevice device) { if (device is FakeCameraDevice) return; var cameracount = ServiceProvider.DeviceManager.ConnectedDevices.Count - (ServiceProvider.Settings.AddFakeCamera ? 1 : 0); SendEvent("Camera", "Connected" , device.DeviceName, cameracount); if (cameracount > 1) SendEvent("MultipleCamera", "Connected_" + cameracount, device.DeviceName); }
public LiveViewForm(ICameraDevice cameraDevice) { //set live view default frame rate to 15 _liveViewTimer.Interval = 1000 / 15; _liveViewTimer.Stop(); _liveViewTimer.Tick += _liveViewTimer_Tick; CameraDevice = cameraDevice; CameraDevice.CameraDisconnected += CameraDevice_CameraDisconnected; InitializeComponent(); }
public string Pharse(string template, PhotoSession session, ICameraDevice device, string fileName, string tempfileName) { if (!File.Exists(tempfileName)) return ""; FileItem item = new FileItem(tempfileName); BitmapLoader.Instance.GetMetadata(item); string tag = template.Replace("[", "").Replace("]", ""); if (item.FileInfo.ExifTags.ContainName(tag)) return item.FileInfo.ExifTags[tag].Replace(":", "_").Replace("?", "_").Replace("*", "_").Replace("\\", "_"); ; return template; }
public static void StopLiveView(ICameraDevice device) { device.StopLiveView(); if (device is NikonBase) { if (_recordtoRam.ContainsKey(device)) device.CaptureInSdRam = _recordtoRam[device]; if (_hostMode.ContainsKey(device)) device.HostMode = _hostMode[device]; } }
private void Capture(ICameraDevice device) { try { CameraHelper.Capture(device); } catch (Exception e) { StaticHelper.Instance.SystemMessage = e.Message; } }
public BraketingWnd(ICameraDevice device, PhotoSession session) { InitializeComponent(); _device = device; _photoSession = session; _photoSession.Braketing.IsBusy = false; backgroundWorker.DoWork += delegate { _photoSession.Braketing.TakePhoto(ServiceProvider.DeviceManager.SelectedCameraDevice); }; _photoSession.Braketing.IsBusyChanged += Braketing_IsBusyChanged; _photoSession.Braketing.PhotoCaptured += Braketing_PhotoCaptured; _photoSession.Braketing.BracketingDone += Braketing_BracketingDone; ServiceProvider.Settings.ApplyTheme(this); }
public void SetCamera(string camera) { if (string.IsNullOrEmpty(camera)) return; foreach (var cameraDevice in ServiceProvider.DeviceManager.ConnectedDevices) { if ((PhotoUtils.IsNumeric(camera) && cameraDevice.SerialNumber == camera.Trim()) || cameraDevice.DeviceName.Replace(" ", "_") == camera.Replace(" ", "_")) { TargetDevice = cameraDevice; break; } } }
public CameraProperty Get(ICameraDevice device) { if (device == null) return new CameraProperty(); foreach (CameraProperty cameraProperty in Items) { if (cameraProperty.SerialNumber == device.SerialNumber) return cameraProperty; } var c = new CameraProperty() {SerialNumber = device.SerialNumber, DeviceName = device.DisplayName}; Items.Add(c); return c; }
public void ExecuteCommand(string cmd, object param) { switch (cmd) { case WindowsCmdConsts.CameraPropertyWnd_Show: PhotoSessionNames.Clear(); PhotoSessionNames.Add("(None)"); foreach (PhotoSession photoSession in ServiceProvider.Settings.PhotoSessions) { PhotoSessionNames.Add(photoSession.Name); } CameraPresets.Clear(); CameraPresets.Add("(None)"); foreach (var cameraPresets in ServiceProvider.Settings.CameraPresets) { CameraPresets.Add(cameraPresets.Name); } _cameraDevice = param as ICameraDevice; if (_cameraDevice == null) return; CameraProperty = _cameraDevice.LoadProperties(); CameraProperty.BeginEdit(); Dispatcher.Invoke(new Action(delegate { Show(); Activate(); Topmost = true; //Topmost = false; Focus(); })); break; case WindowsCmdConsts.CameraPropertyWnd_Hide: CameraProperty = null; Hide(); break; case CmdConsts.All_Close: Dispatcher.Invoke(new Action(delegate { Hide(); Close(); })); break; } }
public static void StartLiveView(ICameraDevice device) { // some nikon cameras can set af to manual //force to capture in ram if (device is NikonBase) { if (!_recordtoRam.ContainsKey(device)) _recordtoRam.Add(device, device.CaptureInSdRam); else _recordtoRam[device] = device.CaptureInSdRam; device.CaptureInSdRam = true; if (!_hostMode.ContainsKey(device)) _hostMode.Add(device, device.HostMode); else _hostMode[device] = device.HostMode; device.HostMode = true; } device.StartLiveView(); }
public static void DownLoadFileByWebRequest(string urlAddress, string filePath, ICameraDevice device) { try { HttpWebRequest request = null; HttpWebResponse response = null; request = (HttpWebRequest)WebRequest.Create(urlAddress); request.Timeout = 30000; //8000 Not work response = (HttpWebResponse)request.GetResponse(); Stream s = response.GetResponseStream(); if (File.Exists(filePath)) { File.Delete(filePath); } FileStream os = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write); byte[] buff = new byte[102400]; int c = 0; while ((c = s.Read(buff, 0, 102400)) > 0) { os.Write(buff, 0, c); os.Flush(); device.TransferProgress += 1; } os.Close(); s.Close(); device.TransferProgress = 100; } catch { return; } finally { } }
public string GetExample(string res, PhotoSession session, ICameraDevice device, string fileName) { Regex regPattern = new Regex(@"\[(.*?)\]", RegexOptions.Singleline); MatchCollection matchX = regPattern.Matches(res); foreach (Match match in matchX) { if (ServiceProvider.FilenameTemplateManager.Templates.ContainsKey(match.Value)) { res = res.Replace(match.Value, ServiceProvider.FilenameTemplateManager.Templates[match.Value].Pharse(match.Value, session, device, fileName)); } } //prevent multiple \ if a tag is empty while (res.Contains(@"\\")) { res = res.Replace(@"\\", @"\"); } // if the file name start with \ the Path.Combine isn't work right if (res.StartsWith("\\")) res = res.Substring(1); return res; }
private void DeviceManager_CameraSelected(ICameraDevice oldcameraDevice, ICameraDevice newcameraDevice) { if (newcameraDevice == null) return; Log.Debug("DeviceManager_CameraSelected 1"); var thread = new Thread(delegate() { CameraProperty property = newcameraDevice.LoadProperties(); // load session data only if not session attached to the selected camera if (newcameraDevice.AttachedPhotoSession == null) { newcameraDevice.AttachedPhotoSession = ServiceProvider.Settings.GetSession(property.PhotoSessionName); } if (newcameraDevice.AttachedPhotoSession != null) ServiceProvider.Settings.DefaultSession = (PhotoSession)newcameraDevice.AttachedPhotoSession; }); thread.Start(); Log.Debug("DeviceManager_CameraSelected 2"); }
private void DeviceManager_CameraDisconnected(ICameraDevice cameraDevice) { cameraDevice.CameraInitDone -= cameraDevice_CameraInitDone; }
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); }
void DeviceManager_CameraConnected(ICameraDevice cameraDevice) { RaisePropertyChanged(() => CameraConnected); }
public string Pharse(string template, PhotoSession session, ICameraDevice device, string fileName) { CameraProperty property = device.LoadProperties(); switch (template) { case "[Counter 3 digit]": case "[Counter 4 digit]": case "[Counter 5 digit]": case "[Counter 6 digit]": case "[Counter 7 digit]": case "[Counter 8 digit]": case "[Counter 9 digit]": return session.Counter.ToString(new string('0', Convert.ToInt16(template.Substring(9, 1)))); case "[Series 4 digit]": return session.Series.ToString(new string('0', 4)); case "[Camera Counter 3 digit]": case "[Camera Counter 4 digit]": case "[Camera Counter 5 digit]": case "[Camera Counter 6 digit]": case "[Camera Counter 7 digit]": case "[Camera Counter 8 digit]": case "[Camera Counter 9 digit]": return property.Counter.ToString(new string('0', Convert.ToInt16(template.Substring(16, 1)))); case "[Session Name]": return session.Name; case "[Capture Name]": return session.CaptureName; case "[Exposure Compensation]": if (device!=null && device.ExposureCompensation != null) return device.ExposureCompensation.Value != "0" ? device.ExposureCompensation.Value : ""; return ""; case "[FNumber]": if (device != null && device.FNumber != null) return device.FNumber.Value ?? ""; return ""; case "[Date yyyy-MM-dd]": return DateTime.Now.ToString("yyyy-MM-dd"); case "[Date yyyy]": return DateTime.Now.ToString("yyyy"); case "[Date yyyy-MM]": return DateTime.Now.ToString("yyyy-MM"); case "[Date MMM]": return DateTime.Now.ToString("MMM"); case "[Date yyyy-MM-dd-hh-mm-ss]": return DateTime.Now.ToString("yyyy-MM-dd-hh-mm-ss"); case "[Time hh-mm-ss]": return DateTime.Now.ToString("hh-mm-ss"); case "[Time hh-mm]": return DateTime.Now.ToString("hh-mm"); case "[Time hh]": return DateTime.Now.ToString("hh"); case "[Barcode]": return session.Barcode; case "[File format]": return GetType(fileName); case "[Original Filename]": return Path.GetFileNameWithoutExtension(fileName); case "[Camera Name]": return property.DeviceName.Replace(":", "_").Replace("?", "_").Replace("*", "_"); case "[Selected Tag1]": return session.SelectedTag1 != null ? session.SelectedTag1.Value.Trim() : ""; case "[Selected Tag2]": return session.SelectedTag2 != null ? session.SelectedTag2.Value.Trim() : ""; case "[Selected Tag3]": return session.SelectedTag3 != null ? session.SelectedTag3.Value.Trim() : ""; case "[Selected Tag4]": return session.SelectedTag4 != null ? session.SelectedTag4.Value.Trim() : ""; case "[Unix Time]": var date = new DateTime(1970, 1, 1, 0, 0, 0, DateTime.Now.Kind); var unixTimestamp = System.Convert.ToInt64((DateTime.Now - date).TotalSeconds); return unixTimestamp.ToString(); case "[DB Row 1]": return (session.ExternalData != null && session.ExternalData.Row1 != null) ? session.ExternalData.Row1 : ""; case "[DB Row 2]": return (session.ExternalData != null && session.ExternalData.Row2 != null) ? session.ExternalData.Row2 : ""; case "[DB Row 3]": return (session.ExternalData != null && session.ExternalData.Row3 != null) ? session.ExternalData.Row3 : ""; case "[DB Row 4]": return (session.ExternalData != null && session.ExternalData.Row4 != null) ? session.ExternalData.Row4 : ""; case "[DB Row 5]": return (session.ExternalData != null && session.ExternalData.Row5 != null) ? session.ExternalData.Row5 : ""; case "[DB Row 6]": return (session.ExternalData != null && session.ExternalData.Row6 != null) ? session.ExternalData.Row6 : ""; case "[DB Row 7]": return (session.ExternalData != null && session.ExternalData.Row7 != null) ? session.ExternalData.Row7 : ""; case "[DB Row 8]": return (session.ExternalData != null && session.ExternalData.Row8 != null) ? session.ExternalData.Row8 : ""; case "[DB Row 9]": return (session.ExternalData != null && session.ExternalData.Row9 != null) ? session.ExternalData.Row9 : ""; } return ""; }
public void TakePhoto(ICameraDevice device) { _cameraDevice = device; Log.Debug("Bracketing started"); _cameraDevice.CaptureCompleted += _cameraDevice_CaptureCompleted; IsBusy = true; switch (Mode) { case 0: { if (ExposureValues.Count == 0) { Stop(); return; } Index = 0; try { _defec = _cameraDevice.ExposureCompensation.Value; Thread.Sleep(100); _cameraDevice.ExposureCompensation.SetValue(ExposureValues[Index]); Thread.Sleep(100); CameraHelper.Capture(_cameraDevice); Index++; } catch (DeviceException exception) { Log.Error(exception); StaticHelper.Instance.SystemMessage = exception.Message; } } break; case 1: { if (ShutterValues.Count == 0) { Stop(); return; } Index = 0; try { _defec = _cameraDevice.ShutterSpeed.Value; Thread.Sleep(100); _cameraDevice.ShutterSpeed.SetValue(ShutterValues[Index]); Thread.Sleep(100); CameraHelper.Capture(_cameraDevice); Index++; } catch (DeviceException exception) { Log.Error(exception); StaticHelper.Instance.SystemMessage = exception.Message; } } break; case 2: { if (PresetValues.Count == 0) { Stop(); return; } Index = 0; try { _cameraPreset.Get(_cameraDevice); Thread.Sleep(100); CameraPreset preset = ServiceProvider.Settings.GetPreset(PresetValues[Index]); if (preset != null) preset.Set(_cameraDevice); Thread.Sleep(100); CameraHelper.Capture(_cameraDevice); Index++; } catch (DeviceException exception) { Log.Error(exception); StaticHelper.Instance.SystemMessage = exception.Message; } } break; case 3: { if (ApertureValues.Count == 0) { Stop(); return; } Index = 0; try { _defec = _cameraDevice.FNumber.Value; Thread.Sleep(100); _cameraDevice.FNumber.SetValue(ApertureValues[Index]); Thread.Sleep(100); CameraHelper.Capture(_cameraDevice); Index++; } catch (DeviceException exception) { Log.Error(exception); StaticHelper.Instance.SystemMessage = exception.Message; } } break; } }
/// <summary> /// Raise CameraDisconnected event. /// </summary> /// <param name="cameraDevice">The camera device.</param> public void OnCameraDisconnected(ICameraDevice cameraDevice) { if (CameraDisconnected != null) CameraDisconnected(cameraDevice); }
private void NewCameraConnected(ICameraDevice cameraDevice) { StaticHelper.Instance.SystemMessage = "New Camera is connected ! Driver :" + cameraDevice.DeviceName; Log.Debug("===========Camera is connected=============="); Log.Debug("Driver :" + cameraDevice.GetType().Name); Log.Debug("Name :" + cameraDevice.DeviceName); Log.Debug("Manufacturer :" + cameraDevice.Manufacturer); if (CameraConnected != null) CameraConnected(cameraDevice); SelectedCameraDevice = cameraDevice; cameraDevice.PhotoCaptured += cameraDevice_PhotoCaptured; cameraDevice.CameraDisconnected += cameraDevice_CameraDisconnected; }
private void WaitForReady(ICameraDevice device) { while (device.IsBusy) { } }
private void DeviceManager_CameraSelected(ICameraDevice oldcameraDevice, ICameraDevice newcameraDevice) { Dispatcher.BeginInvoke( new Action( delegate { //btn_capture_noaf.IsEnabled = newcameraDevice != null && newcameraDevice.GetCapability(CapabilityEnum.CaptureNoAf); ((Flyout) Flyouts.Items[0]).IsOpen = false; ((Flyout) Flyouts.Items[1]).IsOpen = false; Title = (ServiceProvider.Branding.ApplicationTitle ?? "digiCamControl") + " - " + (newcameraDevice == null ? "" : newcameraDevice.DisplayName); })); }
private void DeviceManager_CameraConnected(ICameraDevice cameraDevice) { if (CurrentScript != null) { CurrentScript.Variabiles["cameraccount"] = ServiceProvider.DeviceManager.ConnectedDevices.Count.ToString(); } }
private void DeviceManager_CameraSelected(ICameraDevice oldcameraDevice, ICameraDevice newcameraDevice) { Dispatcher.BeginInvoke( new Action( delegate { Title = (ServiceProvider.Branding.ApplicationTitle ?? "digiCamControl") + " - " + (newcameraDevice == null ? "" : newcameraDevice.DisplayName); })); }
void DeviceManager_CameraDisconnected(ICameraDevice cameraDevice) { Dispatcher.BeginInvoke(new Action(() => { if (!ServiceProvider.Settings.HideTrayNotifications) { MyNotifyIcon.HideBalloonTip(); MyNotifyIcon.ShowBalloonTip("Camera disconnected", cameraDevice.LoadProperties().DeviceName, BalloonIcon.Info); } })); }