private void SetPreset(CameraPreset c = null) { if (c == null) c = presets[presetsSwitch[currentPreset % presetsSwitch.Length]]; curPreset = c; camera.transform.localPosition = c.pos; camera.transform.localRotation = Quaternion.Euler(c.rot); camera.fieldOfView = c.fov; camera.farClipPlane = spec ? 30 : 1000; camT.rotation = Quaternion.identity; RenderSettings.fog = spec && _Dark.night; foreach (var a in topDownOnly) a.SetActive(!c.spec); if (spec) RenderSettings.ambientLight = Color.white * .5f; else RenderSettings.ambientLight = ambient; //if (light == 1 && spec) //{ // light *= .5f; // foreach (var a in lights) // a.intensity *= light; //} //if (light != 1 && !spec) //{ // foreach (var a in lights) // a.intensity /= light; // light = 1; //} }
public SavePresetWnd(CameraPreset cameraPreset) { InitializeComponent(); CameraPreset = cameraPreset; CameraPreset.BeginEdit(); ServiceProvider.Settings.ApplyTheme(this); }
/// <summary> /// Helper method to update the full status of the camera /// </summary> void SendCameraFullMessageObject() { var presetList = new List <CameraPreset>(); // Build a list of camera presets based on the names and count if (EISC.GetBool(JoinMap.SupportsPresets.JoinNumber)) { var presetStart = JoinMap.PresetLabelStart.JoinNumber; var presetEnd = JoinMap.PresetLabelStart.JoinNumber + JoinMap.NumberOfPresets.JoinNumber; var presetId = 1; for (uint i = presetStart; i < presetEnd; i++) { var presetName = EISC.GetString(i); var preset = new CameraPreset(presetId, presetName, string.IsNullOrEmpty(presetName), true); presetList.Add(preset); presetId++; } } PostStatusMessage(new { cameraMode = GetCameraMode(), hasPresets = EISC.GetBool(JoinMap.SupportsPresets.JoinNumber), presets = presetList }); }
private void DeletePreset(CameraPreset obj) { if (obj == null) { return; } ServiceProvider.Settings.CameraPresets.Remove(obj); }
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); }
private void SelectPreset(CameraPreset preset) { if (preset == null) { return; } try { preset.Set(ServiceProvider.DeviceManager.SelectedCameraDevice); } catch (Exception exception) { Log.Error("Error set preset", exception); } }
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); } } } }
private void DeletePreset(CameraPreset obj) { if (obj == null) { return; } ServiceProvider.Settings.CameraPresets.Remove(obj); try { File.Delete(obj.FileName); } catch (Exception) { } }
private void VerifyPreset(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.Verify(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(); }
private void SetPreset(CameraPreset c = null) { if (c == null) { c = presets[presetsSwitch[currentPreset % presetsSwitch.Length]]; } curPreset = c; camera.transform.localPosition = c.pos; camera.transform.localRotation = Quaternion.Euler(c.rot); camera.fieldOfView = c.fov; camera.farClipPlane = spec ? 30 : 1000; camT.rotation = Quaternion.identity; RenderSettings.fog = spec && _Dark.night; foreach (var a in topDownOnly) { a.SetActive(!c.spec); } if (spec) { RenderSettings.ambientLight = Color.white * .5f; } else { RenderSettings.ambientLight = ambient; } //if (light == 1 && spec) //{ // light *= .5f; // foreach (var a in lights) // a.intensity *= light; //} //if (light != 1 && !spec) //{ // foreach (var a in lights) // a.intensity /= light; // light = 1; //} }
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)); }
private void MenuItem_Click_4(object sender, RoutedEventArgs e) { CameraPreset cameraPreset = new CameraPreset(); SavePresetWnd wnd = new SavePresetWnd(cameraPreset); if (wnd.ShowDialog() == true) { foreach (CameraPreset preset in ServiceProvider.Settings.CameraPresets) { if (preset.Name == cameraPreset.Name) { cameraPreset = preset; break; } } cameraPreset.Get(ServiceProvider.DeviceManager.SelectedCameraDevice); if (!ServiceProvider.Settings.CameraPresets.Contains(cameraPreset)) { ServiceProvider.Settings.CameraPresets.Add(cameraPreset); } ServiceProvider.Settings.Save(); } }
public void SetCamera(int id) { CameraPreset preset = cameraPresets[id]; if (preset != null) { presetId = id; customCamera.mycamera = preset.cameraType; customCamera.target = preset.target; customCamera.mtarget = preset.parent; customCamera.distance = preset.distance; customCamera.pitchAngle = preset.pitchAngle; customCamera.yawAngle = preset.yawAngle; customCamera.height = preset.height; customCamera.rotationDamping = preset.rotationDamping; customCamera.heightDamping = preset.heightDamping; customCamera.dampFixedCamera = preset.dampFixedCamera; customCamera.mouseOrbitFixedCamera = preset.mouseOrbitFixedCamera; customCamera.x = preset.x; customCamera.y = preset.y; customCamera.driverView = preset.driverView; } }
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); } } }
public void ToPreset(CameraPreset preset, TextureParam textureParam, TransformParam transformParam, MeshParam meshParam) { float aspecct = (float)textureParam.width / (float)textureParam.height; Bounds bounds; if (meshParam.TryGetBoundingBox(out bounds) != false) { if (orthographic == false) { switch (preset) { case CameraPreset.kFit: { float length; float fov; if (bounds.extents.x < bounds.extents.y) { length = bounds.extents.y; fov = fieldOfView; } else { length = bounds.extents.x; fov = Camera.VerticalToHorizontalFieldOfView(fieldOfView, aspecct); } float distance = length / Mathf.Tan(fov * 0.5f * Mathf.Deg2Rad) + bounds.extents.z; if (distance <= 0.0f) { return; } Vector3 direction = lookAtPosition - localPosition; if (Mathf.Approximately(direction.magnitude, 0.0f) != false) { return; } lookAtPosition = bounds.center; direction = Vector3.Normalize(direction); localPosition = lookAtPosition - direction * distance; localRotation = Quaternion.LookRotation(direction).eulerAngles; nearClipPlane = distance - 0.01f; farClipPlane = nearClipPlane + bounds.size.z + 0.02f; break; } case CameraPreset.kFront: { float length; float fov; if (bounds.extents.x < bounds.extents.y) { length = bounds.extents.y; fov = fieldOfView; } else { length = bounds.extents.x; fov = Camera.VerticalToHorizontalFieldOfView(fieldOfView, aspecct); } float distance = length / Mathf.Tan(fov * 0.5f * Mathf.Deg2Rad); float z = -(distance + bounds.extents.z - bounds.center.z); localPosition = new Vector3(bounds.center.x, bounds.center.y, z); localRotation = Vector3.zero; lookAtPosition = bounds.center; nearClipPlane = distance - 0.01f; farClipPlane = nearClipPlane + bounds.size.z + 0.02f; break; } case CameraPreset.kBack: { float length; float fov; if (bounds.extents.x < bounds.extents.y) { length = bounds.extents.y; fov = fieldOfView; } else { length = bounds.extents.x; fov = Camera.VerticalToHorizontalFieldOfView(fieldOfView, aspecct); } float distance = length / Mathf.Tan(fov * 0.5f * Mathf.Deg2Rad); float z = distance + bounds.extents.z + bounds.center.z; localPosition = new Vector3(bounds.center.x, bounds.center.y, z); localRotation = new Vector3(0, 180, 0); lookAtPosition = bounds.center; nearClipPlane = distance - 0.01f; farClipPlane = nearClipPlane + bounds.size.z + 0.02f; break; } case CameraPreset.kTop: { float length; float fov; if (bounds.extents.x < bounds.extents.z) { length = bounds.extents.z; fov = fieldOfView; } else { length = bounds.extents.x; fov = Camera.VerticalToHorizontalFieldOfView(fieldOfView, aspecct); } float distance = length / Mathf.Tan(fov * 0.5f * Mathf.Deg2Rad); float y = distance + bounds.extents.y + bounds.center.y; localPosition = new Vector3(bounds.center.x, y, bounds.center.z); localRotation = new Vector3(90, 0, 0); lookAtPosition = bounds.center; nearClipPlane = distance - 0.01f; farClipPlane = nearClipPlane + bounds.size.y + 0.02f; break; } case CameraPreset.kBottom: { float length; float fov; if (bounds.extents.x < bounds.extents.z) { length = bounds.extents.z; fov = fieldOfView; } else { length = bounds.extents.x; fov = Camera.VerticalToHorizontalFieldOfView(fieldOfView, aspecct); } float distance = length / Mathf.Tan(fov * 0.5f * Mathf.Deg2Rad); float y = -(distance + bounds.extents.y - bounds.center.y); localPosition = new Vector3(bounds.center.x, y, bounds.center.z); localRotation = new Vector3(-90, 0, 0); lookAtPosition = bounds.center; nearClipPlane = distance - 0.01f; farClipPlane = nearClipPlane + bounds.size.y + 0.02f; break; } case CameraPreset.kLeft: { float length; float fov; if (bounds.extents.z < bounds.extents.y) { length = bounds.extents.y; fov = fieldOfView; } else { length = bounds.extents.z; fov = Camera.VerticalToHorizontalFieldOfView(fieldOfView, aspecct); } float distance = length / Mathf.Tan(fov * 0.5f * Mathf.Deg2Rad); float x = -(distance + bounds.extents.x - bounds.center.x); localPosition = new Vector3(x, bounds.center.y, bounds.center.z); localRotation = new Vector3(0, 90, 0); lookAtPosition = bounds.center; nearClipPlane = distance - 0.01f; farClipPlane = nearClipPlane + bounds.size.x + 0.02f; break; } case CameraPreset.kRight: { float length; float fov; if (bounds.extents.z < bounds.extents.y) { length = bounds.extents.y; fov = fieldOfView; } else { length = bounds.extents.z; fov = Camera.VerticalToHorizontalFieldOfView(fieldOfView, aspecct); } float distance = length / Mathf.Tan(fov * 0.5f * Mathf.Deg2Rad); float x = distance + bounds.extents.x + bounds.center.x; localPosition = new Vector3(x, bounds.center.y, bounds.center.z); localRotation = new Vector3(0, -90, 0); lookAtPosition = bounds.center; nearClipPlane = distance - 0.01f; farClipPlane = nearClipPlane + bounds.size.x + 0.02f; break; } } } else { const float nearLength = 1.00f; switch (preset) { case CameraPreset.kFront: { localPosition = new Vector3(bounds.center.x, bounds.center.y, -(bounds.extents.z - bounds.center.z + nearLength)); localRotation = Vector3.zero; lookAtPosition = bounds.center; orthographicSize = Mathf.Max(Camera.HorizontalToVerticalFieldOfView(bounds.extents.x, aspecct), bounds.extents.y) * 1.005f; nearClipPlane = nearLength; farClipPlane = nearClipPlane + bounds.size.z + 0.001f; break; } case CameraPreset.kBack: { localPosition = new Vector3(bounds.center.x, bounds.center.y, bounds.extents.z + bounds.center.z + nearLength); localRotation = new Vector3(0, 180, 0); lookAtPosition = bounds.center; orthographicSize = Mathf.Max(Camera.HorizontalToVerticalFieldOfView(bounds.extents.x, aspecct), bounds.extents.y) * 1.005f; nearClipPlane = nearLength; farClipPlane = nearClipPlane + bounds.size.z + 0.001f; break; } case CameraPreset.kTop: { localPosition = new Vector3(bounds.center.x, bounds.extents.y + bounds.center.y + nearLength, bounds.center.z); localRotation = new Vector3(90, 0, 0); lookAtPosition = bounds.center; orthographicSize = Mathf.Max(Camera.HorizontalToVerticalFieldOfView(bounds.extents.x, aspecct), bounds.extents.z) * 1.005f; nearClipPlane = nearLength; farClipPlane = nearClipPlane + bounds.size.y + 0.001f + 100; break; } case CameraPreset.kBottom: { localPosition = new Vector3(bounds.center.x, -(bounds.extents.y - bounds.center.y + nearLength), bounds.center.z); localRotation = new Vector3(-90, 0, 0); lookAtPosition = bounds.center; orthographicSize = Mathf.Max(Camera.HorizontalToVerticalFieldOfView(bounds.extents.x, aspecct), bounds.extents.z) * 1.005f; nearClipPlane = nearLength; farClipPlane = nearClipPlane + bounds.size.y + 0.001f; break; } case CameraPreset.kLeft: { localPosition = new Vector3(-(bounds.extents.x - bounds.center.x + nearLength), bounds.center.y, bounds.center.z); localRotation = new Vector3(0, 90, 0); lookAtPosition = bounds.center; orthographicSize = Mathf.Max(Camera.HorizontalToVerticalFieldOfView(bounds.extents.z, aspecct), bounds.extents.y) * 1.005f; nearClipPlane = nearLength; farClipPlane = nearClipPlane + bounds.size.y + 0.001f; break; } case CameraPreset.kRight: { localPosition = new Vector3(bounds.extents.x - bounds.center.x + nearLength, bounds.center.y, bounds.center.z); localRotation = new Vector3(0, -90, 0); lookAtPosition = bounds.center; orthographicSize = Mathf.Max(Camera.HorizontalToVerticalFieldOfView(bounds.extents.z, aspecct), bounds.extents.y) * 1.005f; nearClipPlane = nearLength; farClipPlane = nearClipPlane + bounds.size.y + 0.001f; break; } } } transformParam.localPosition = Vector3.zero; transformParam.localRotation = Vector3.zero; transformParam.localScale = Vector3.one; nearClipPlane -= 10.0f; farClipPlane += 100.0f; if (nearClipPlane < 0.1f) { nearClipPlane = 0.1f; } if (nearClipPlane >= 3.402823e+37f) { nearClipPlane = 3.402823e+37f; } if (farClipPlane < nearClipPlane) { farClipPlane = nearClipPlane + 0.01f; } } }
public string ParseString(string input) { if (string.IsNullOrEmpty(input)) { return(""); } StringBuilder output = new StringBuilder(input); int offset = 0; Regex variablePattern = new Regex(@"\${([^:{}]+)(?::([^}\(]+))?(?:\(([^\)]+)\))?}"); MatchCollection matches = variablePattern.Matches(input); foreach (Match currMatch in matches) { string varName = ""; string modifier = string.Empty; string value = string.Empty; string options = string.Empty; // get rid of the escaped variable string output.Remove(currMatch.Index + offset, currMatch.Length); // grab details for this parse varName = currMatch.Groups[1].Value; if (varName.StartsWith("session.")) { IList <PropertyInfo> props = new List <PropertyInfo>(typeof(PhotoSession).GetProperties()); foreach (PropertyInfo prop in props) { //object propValue = prop.GetValue(myObject, null); if (prop.PropertyType == typeof(string) || prop.PropertyType == typeof(int) || prop.PropertyType == typeof(bool)) { if (varName.Split('.')[1].ToLower() == prop.Name.ToLower()) { value = prop.GetValue(ServiceProvider.Settings.DefaultSession, null).ToString(); } } // Do something with propValue } } if (varName.StartsWith("camera.")) { if (ServiceProvider.DeviceManager.SelectedCameraDevice != null) { CameraPreset preset = new CameraPreset(); preset.Get(ServiceProvider.DeviceManager.SelectedCameraDevice); foreach (ValuePair pair in preset.Values) { if (varName.Split('.')[1].ToLower() == pair.Name.Replace(" ", "").ToLower()) { value = pair.Value; } } } } else { value = Variabiles[varName]; } if (currMatch.Groups.Count >= 3) { modifier = currMatch.Groups[2].Value.ToLower(); } if (currMatch.Groups.Count >= 4) { options = currMatch.Groups[3].Value; } // if there is no variable for what was passed in we are done if (string.IsNullOrEmpty(value)) { offset -= currMatch.Length; continue; } //// handle any modifiers //if (!modifier.IsNullOrWhiteSpace()) //{ // IValueModifier handler = Load(modifier); // if (handler != null) // { // value = handler.Parse(this.Context, value, options); // } //} output.Insert(currMatch.Index + offset, value); offset = offset - currMatch.Length + value.Length; } // if we did some replacements search again to check for embedded variables if (matches.Count > 0) { return(ParseString(output.ToString())); } else { return(output.ToString()); } }
public SavePresetWnd(CameraPreset cameraPreset) { InitializeComponent(); CameraPreset = cameraPreset; CameraPreset.BeginEdit(); }
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); }
private void textEditor_TextArea_TextEntered(object sender, TextCompositionEventArgs e) { if (e.Text == "<") { // open code completion after the user has pressed dot: completionWindow = new CompletionWindow(textEditor.TextArea); // provide AvalonEdit with the data: IList <ICompletionData> data = completionWindow.CompletionList.CompletionData; foreach (IScriptCommand command in ServiceProvider.ScriptManager.AvaiableCommands) { data.Add(new MyCompletionData(command.DefaultValue, command.Description, command.Name.ToLower())); } completionWindow.Show(); completionWindow.Closed += delegate { completionWindow = null; }; } if (e.Text == ".") { string word = textEditor.GetWordBeforeDot(); if (word == "{session" || word == "session") { IList <PropertyInfo> props = new List <PropertyInfo>(typeof(PhotoSession).GetProperties()); completionWindow = new CompletionWindow(textEditor.TextArea); // provide AvalonEdit with the data: IList <ICompletionData> data = completionWindow.CompletionList.CompletionData; foreach (PropertyInfo prop in props) { //object propValue = prop.GetValue(myObject, null); if (prop.PropertyType == typeof(string) || prop.PropertyType == typeof(int) || prop.PropertyType == typeof(bool)) { data.Add(new MyCompletionData(prop.Name.ToLower(), "", prop.Name.ToLower())); } // Do something with propValue } completionWindow.Show(); completionWindow.Closed += delegate { completionWindow = null; }; } if (word == "{camera" && ServiceProvider.DeviceManager.SelectedCameraDevice != null) { completionWindow = new CompletionWindow(textEditor.TextArea); IList <ICompletionData> data = completionWindow.CompletionList.CompletionData; CameraPreset preset = new CameraPreset(); preset.Get(ServiceProvider.DeviceManager.SelectedCameraDevice); foreach (ValuePair value in preset.Values) { data.Add(new MyCompletionData(value.Name.Replace(" ", "").ToLower(), "Current value :" + value.Value, value.Name.Replace(" ", "").ToLower())); } completionWindow.Show(); completionWindow.Closed += delegate { completionWindow = null; }; } } if (e.Text == " ") { string line = textEditor.GetLine(); if (line.StartsWith("setcamera")) { if (!line.Contains("property") && !line.Contains("value")) { completionWindow = new CompletionWindow(textEditor.TextArea); IList <ICompletionData> data = completionWindow.CompletionList.CompletionData; data.Add(new MyCompletionData("property", "", "property")); completionWindow.Show(); completionWindow.Closed += delegate { completionWindow = null; }; } if (line.Contains("property") && !line.Contains("value")) { completionWindow = new CompletionWindow(textEditor.TextArea); IList <ICompletionData> data = completionWindow.CompletionList.CompletionData; data.Add(new MyCompletionData("value", "", "value")); completionWindow.Show(); completionWindow.Closed += delegate { completionWindow = null; }; } } } if (e.Text == "=" && ServiceProvider.DeviceManager.SelectedCameraDevice != null) { string line = textEditor.GetLine(); string word = textEditor.GetWordBeforeDot(); if (line.StartsWith("setcamera")) { if (word == "property") { completionWindow = new CompletionWindow(textEditor.TextArea); IList <ICompletionData> data = completionWindow.CompletionList.CompletionData; data.Add(new MyCompletionData("\"" + "aperture" + "\"", "", "aperture")); data.Add(new MyCompletionData("\"" + "iso" + "\"", "", "iso")); data.Add(new MyCompletionData("\"" + "shutter" + "\"", "", "shutter")); data.Add(new MyCompletionData("\"" + "ec" + "\"", "Exposure Compensation", "ec")); data.Add(new MyCompletionData("\"" + "wb" + "\"", "White Balance", "wb")); data.Add(new MyCompletionData("\"" + "cs" + "\"", "Compression Setting", "cs")); completionWindow.Show(); completionWindow.Closed += delegate { completionWindow = null; }; } if (word == "value") { if (line.Contains("property=\"aperture\"") && ServiceProvider.DeviceManager.SelectedCameraDevice.FNumber != null) { completionWindow = new CompletionWindow(textEditor.TextArea); IList <ICompletionData> data = completionWindow.CompletionList.CompletionData; foreach (string value in ServiceProvider.DeviceManager.SelectedCameraDevice.FNumber.Values) { data.Add(new MyCompletionData("\"" + value + "\"", value, value)); } completionWindow.Show(); completionWindow.Closed += delegate { completionWindow = null; }; } if (line.Contains("property=\"iso\"") && ServiceProvider.DeviceManager.SelectedCameraDevice.IsoNumber != null) { completionWindow = new CompletionWindow(textEditor.TextArea); IList <ICompletionData> data = completionWindow.CompletionList.CompletionData; foreach (string value in ServiceProvider.DeviceManager.SelectedCameraDevice.IsoNumber.Values ) { data.Add(new MyCompletionData("\"" + value + "\"", value, value)); } completionWindow.Show(); completionWindow.Closed += delegate { completionWindow = null; }; } if (line.Contains("property=\"shutter\"") && ServiceProvider.DeviceManager.SelectedCameraDevice.ShutterSpeed != null) { completionWindow = new CompletionWindow(textEditor.TextArea); IList <ICompletionData> data = completionWindow.CompletionList.CompletionData; foreach ( string value in ServiceProvider.DeviceManager.SelectedCameraDevice.ShutterSpeed.Values) { data.Add(new MyCompletionData("\"" + value + "\"", value, value)); } completionWindow.Show(); completionWindow.Closed += delegate { completionWindow = null; }; } if (line.Contains("property=\"ec\"") && ServiceProvider.DeviceManager.SelectedCameraDevice.ExposureCompensation != null) { completionWindow = new CompletionWindow(textEditor.TextArea); IList <ICompletionData> data = completionWindow.CompletionList.CompletionData; foreach ( string value in ServiceProvider.DeviceManager.SelectedCameraDevice.ExposureCompensation.Values) { data.Add(new MyCompletionData("\"" + value + "\"", value, value)); } completionWindow.Show(); completionWindow.Closed += delegate { completionWindow = null; }; } if (line.Contains("property=\"wb\"") && ServiceProvider.DeviceManager.SelectedCameraDevice.WhiteBalance != null) { completionWindow = new CompletionWindow(textEditor.TextArea); IList <ICompletionData> data = completionWindow.CompletionList.CompletionData; foreach ( string value in ServiceProvider.DeviceManager.SelectedCameraDevice.WhiteBalance.Values) { data.Add(new MyCompletionData("\"" + value + "\"", value, value)); } completionWindow.Show(); completionWindow.Closed += delegate { completionWindow = null; }; } if (line.Contains("property=\"cs\"") && ServiceProvider.DeviceManager.SelectedCameraDevice.CompressionSetting != null) { completionWindow = new CompletionWindow(textEditor.TextArea); IList <ICompletionData> data = completionWindow.CompletionList.CompletionData; foreach ( string value in ServiceProvider.DeviceManager.SelectedCameraDevice.CompressionSetting.Values) { data.Add(new MyCompletionData("\"" + value + "\"", value, value)); } completionWindow.Show(); completionWindow.Closed += delegate { completionWindow = null; }; } } } } }
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); }
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); }
public void ExecuteCommand(string cmd, object param) { if (param == null) { param = ServiceProvider.DeviceManager.SelectedCameraDevice; } lock (_locker) { switch (cmd) { case WindowsCmdConsts.LiveViewWnd_Show: { if (!_register.ContainsKey(param)) { Application.Current.Dispatcher.Invoke(new Action(delegate { LiveViewWnd wnd = new LiveViewWnd(); ServiceProvider.Settings.ApplyTheme(wnd); _register.Add(param, wnd); wnd.Owner = ServiceProvider.PluginManager.SelectedWindow as Window; })); } NikonBase nikonBase = param as NikonBase; if (nikonBase != null && ServiceProvider.Settings.EasyLiveViewControl) { CameraPreset preset = new CameraPreset(); preset.Get(nikonBase); if (!_presets.ContainsKey(nikonBase)) { _presets.Add(nikonBase, preset); } else { _presets[nikonBase] = preset; } if (nikonBase.ShutterSpeed.Value == "Bulb") { nikonBase.ShutterSpeed.Value = nikonBase.ShutterSpeed.Values[nikonBase.ShutterSpeed.Values.Count / 2]; } nikonBase.FocusMode.Value = nikonBase.FocusMode.Values[0]; nikonBase.FNumber.Value = nikonBase.FNumber.Values[0]; } _register[param].ExecuteCommand(cmd, param); } break; case WindowsCmdConsts.LiveViewWnd_Hide: { if (_register.ContainsKey(param)) { _register[param].ExecuteCommand(cmd, param); } var nikonBase = param as NikonBase; if (ServiceProvider.Settings.EasyLiveViewControl) { if (nikonBase != null && _presets.ContainsKey(nikonBase)) { nikonBase.ShutterSpeed.Value = _presets[nikonBase].GetValue("ShutterSpeed"); nikonBase.FNumber.Value = _presets[nikonBase].GetValue("FNumber"); nikonBase.FocusMode.Value = _presets[nikonBase].GetValue("FocusMode"); } } } break; case CmdConsts.All_Minimize: case CmdConsts.All_Close: foreach (var liveViewWnd in _register) { liveViewWnd.Value.ExecuteCommand(cmd, param); } break; default: if (cmd.StartsWith("LiveView")) { foreach (var liveViewWnd in _register) { liveViewWnd.Value.ExecuteCommand(cmd, param); } } break; } } }