Example #1
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);
             }
         }
     }
 }
 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 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());
            }
        }
Example #5
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);
        }
Example #6
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);
        }
        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; };
                        }
                    }
                }
            }
        }
        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;
                }
            }
        }