├── lib └── DirectShowLib-2005.dll ├── CameraController ├── Icons │ ├── blank.png │ ├── Rename_6779.png │ ├── folder_Open_16xMD.png │ ├── SliderElement_10728.png │ ├── folder_Closed_16xMD.png │ └── NewSolutionFolder_6289.png ├── Resources │ ├── Rename_6779.png │ └── NewSolutionFolder_6289.png ├── packages.config ├── App.config ├── Properties │ ├── Settings.settings │ ├── Settings.Designer.cs │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ └── Resources.resx ├── CameraSelectDialog.cs ├── NameEntryDialog.cs ├── Program.cs ├── Settings.cs ├── Preset.cs ├── CameraControlSlider.cs ├── OptionsDialog.cs ├── CameraSelectDialog.Designer.cs ├── CameraControlSlider.Designer.cs ├── NameEntryDialog.Designer.cs ├── NameEntryDialog.resx ├── OptionsDialog.resx ├── CameraControlSlider.resx ├── CameraSelectDialog.resx ├── MainWindow.resx ├── OptionsDialog.Designer.cs ├── MainWindow.cs ├── CameraController.csproj ├── PresetSelectorControl.resx ├── PresetSelectorControl.cs ├── MainWindow.Designer.cs └── PresetSelectorControl.Designer.cs ├── README.md ├── LICENSE ├── CameraControlLib ├── Properties │ └── AssemblyInfo.cs ├── CameraControlLib.csproj ├── CameraProperty.cs └── Camera.cs ├── CameraControlLib.sln ├── .gitattributes └── .gitignore /lib/DirectShowLib-2005.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcellarius/CameraControlLib/HEAD/lib/DirectShowLib-2005.dll -------------------------------------------------------------------------------- /CameraController/Icons/blank.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcellarius/CameraControlLib/HEAD/CameraController/Icons/blank.png -------------------------------------------------------------------------------- /CameraController/Icons/Rename_6779.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcellarius/CameraControlLib/HEAD/CameraController/Icons/Rename_6779.png -------------------------------------------------------------------------------- /CameraController/Icons/folder_Open_16xMD.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcellarius/CameraControlLib/HEAD/CameraController/Icons/folder_Open_16xMD.png -------------------------------------------------------------------------------- /CameraController/Resources/Rename_6779.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcellarius/CameraControlLib/HEAD/CameraController/Resources/Rename_6779.png -------------------------------------------------------------------------------- /CameraController/Icons/SliderElement_10728.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcellarius/CameraControlLib/HEAD/CameraController/Icons/SliderElement_10728.png -------------------------------------------------------------------------------- /CameraController/Icons/folder_Closed_16xMD.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcellarius/CameraControlLib/HEAD/CameraController/Icons/folder_Closed_16xMD.png -------------------------------------------------------------------------------- /CameraController/Icons/NewSolutionFolder_6289.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcellarius/CameraControlLib/HEAD/CameraController/Icons/NewSolutionFolder_6289.png -------------------------------------------------------------------------------- /CameraController/Resources/NewSolutionFolder_6289.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcellarius/CameraControlLib/HEAD/CameraController/Resources/NewSolutionFolder_6289.png -------------------------------------------------------------------------------- /CameraController/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /CameraController/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /CameraController/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | CameraControlLib 2 | ================ 3 | 4 | This is a small library for controlling webcam properties such as focus, zoom 5 | and exposure. It's intended for use with the Logitech C920, but it will work 6 | with other USB cameras too. 7 | 8 | Also included is a Windows application for controlling the camera properties. 9 | This is similar to the advanced settings page of the Logitech camera control 10 | utility but supports storing presets and customising which settings get 11 | displayed. 12 | 13 | This project was built using Visual Studio 2015 Community, and depends on 14 | Directshow.net. 15 | -------------------------------------------------------------------------------- /CameraController/CameraSelectDialog.cs: -------------------------------------------------------------------------------- 1 | using CameraControlLib; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel; 5 | using System.Data; 6 | using System.Drawing; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | using System.Windows.Forms; 11 | 12 | namespace CameraController 13 | { 14 | public partial class CameraSelectDialog : Form 15 | { 16 | List _availableCameras; 17 | 18 | public CameraDescriptor SelectedCamera 19 | { 20 | get 21 | { 22 | return availableCameraComboBox.SelectedItem as CameraDescriptor; 23 | } 24 | } 25 | 26 | public CameraSelectDialog() 27 | { 28 | InitializeComponent(); 29 | _availableCameras = CameraDescriptor.GetAll(); 30 | availableCameraComboBox.DisplayMember = "Name"; 31 | availableCameraComboBox.DataSource = _availableCameras; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Sam Douglas 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /CameraController/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace CameraController.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /CameraController/NameEntryDialog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Text.RegularExpressions; 9 | using System.Threading.Tasks; 10 | using System.Windows.Forms; 11 | 12 | namespace CameraController 13 | { 14 | public partial class NameEntryDialog : Form 15 | { 16 | public string GroupName 17 | { 18 | get { return groupNameTextbox.Text; } 19 | set { groupNameTextbox.Text = value; } 20 | } 21 | 22 | public NameEntryDialog(string dialogTitle) 23 | { 24 | InitializeComponent(); 25 | this.Text = dialogTitle; 26 | } 27 | 28 | private void groupNameTextbox_Validating(object sender, CancelEventArgs e) 29 | { 30 | //Group name must contain at least one word character 31 | var match = Regex.Match(GroupName, @".*\w.*"); 32 | if (!match.Success) 33 | { 34 | e.Cancel = true; 35 | } 36 | } 37 | 38 | private void PresetGroupNameDialog_Shown(object sender, EventArgs e) 39 | { 40 | groupNameTextbox.SelectAll(); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /CameraController/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows.Forms; 8 | 9 | namespace CameraController 10 | { 11 | static class Program 12 | { 13 | /// 14 | /// The main entry point for the application. 15 | /// 16 | [STAThread] 17 | static void Main() 18 | { 19 | Application.EnableVisualStyles(); 20 | Application.SetCompatibleTextRenderingDefault(false); 21 | 22 | string settingsFilename = Path.Combine(Application.UserAppDataPath, "settings.json"); 23 | Settings settings = LoadSettings(settingsFilename); 24 | settings.Filename = settingsFilename; 25 | 26 | Application.Run(new MainWindow(settings)); 27 | } 28 | 29 | private static Settings LoadSettings(string settingsFilename) 30 | { 31 | Settings settings = null; 32 | if (File.Exists(settingsFilename)) 33 | { 34 | using (var reader = new StreamReader(settingsFilename, Encoding.UTF8)) 35 | { 36 | settings = Settings.Load(reader); 37 | } 38 | } 39 | 40 | if (settings == null) 41 | settings = new Settings(); 42 | 43 | return settings; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /CameraControlLib/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("CameraControlLib")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("CameraControlLib")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("76fa62d4-eb0c-40ef-949e-51a3a556504c")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /CameraController/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("CameraController")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("CameraController")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("42b92cb0-1307-4339-a10f-cccf823a4252")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /CameraControlLib.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CameraControlLib", "CameraControlLib\CameraControlLib.csproj", "{76FA62D4-EB0C-40EF-949E-51A3A556504C}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CameraController", "CameraController\CameraController.csproj", "{42B92CB0-1307-4339-A10F-CCCF823A4252}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {76FA62D4-EB0C-40EF-949E-51A3A556504C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {76FA62D4-EB0C-40EF-949E-51A3A556504C}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {76FA62D4-EB0C-40EF-949E-51A3A556504C}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {76FA62D4-EB0C-40EF-949E-51A3A556504C}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {42B92CB0-1307-4339-A10F-CCCF823A4252}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {42B92CB0-1307-4339-A10F-CCCF823A4252}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {42B92CB0-1307-4339-A10F-CCCF823A4252}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {42B92CB0-1307-4339-A10F-CCCF823A4252}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /CameraController/Settings.cs: -------------------------------------------------------------------------------- 1 | using CameraControlLib; 2 | using Newtonsoft.Json; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace CameraController 11 | { 12 | public class Settings 13 | { 14 | /// 15 | /// Gets or sets the filename for the JSON settings file. 16 | /// 17 | [JsonIgnore] 18 | public string Filename { get; set; } 19 | 20 | public CameraReference DefaultCamera = null; 21 | public bool OverrideCameraRanges = false; 22 | public List HiddenProperties = new List(); 23 | public List PresetGroups { get; } = new List(); 24 | 25 | public static Settings Load(StreamReader reader) 26 | { 27 | var jsonString = reader.ReadToEnd(); 28 | return JsonConvert.DeserializeObject(jsonString); 29 | } 30 | 31 | public void Save() 32 | { 33 | if (Filename == null) 34 | throw new InvalidOperationException("Settings filename not set"); 35 | 36 | using (var writer = new StreamWriter(Filename, false, Encoding.UTF8)) 37 | { 38 | writer.Write(JsonConvert.SerializeObject(this, Formatting.Indented)); 39 | } 40 | 41 | OnSaved(); 42 | } 43 | 44 | public event EventHandler Saved; 45 | protected void OnSaved() 46 | { 47 | Saved?.Invoke(this, new EventArgs()); 48 | } 49 | } 50 | 51 | public class CameraReference : ICameraDescriptor 52 | { 53 | public string DevicePath { get; set; } 54 | public string Name { get; set; } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /CameraController/Preset.cs: -------------------------------------------------------------------------------- 1 | using CameraControlLib; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Newtonsoft.Json; 8 | using Newtonsoft.Json.Converters; 9 | 10 | namespace CameraController 11 | { 12 | public class Preset 13 | { 14 | public string Name { get; set; } 15 | public Dictionary Properties { get; } = new Dictionary(); 16 | 17 | public void SetProperty(string propertyId, int value, CameraPropertyFlags flags) 18 | { 19 | PropertyValue propValue; 20 | if (!Properties.TryGetValue(propertyId, out propValue)) 21 | { 22 | propValue = new PropertyValue(); 23 | Properties[propertyId] = propValue; 24 | } 25 | propValue.Value = value; 26 | propValue.Flags = flags; 27 | } 28 | 29 | public void Clear() 30 | { 31 | Properties.Clear(); 32 | } 33 | 34 | public void Clear(string propertyId) 35 | { 36 | Properties.Remove(propertyId); 37 | } 38 | 39 | public void RecordPreset(Camera camera, IEnumerable propertiesToSave) 40 | { 41 | Clear(); 42 | foreach (var propertyId in propertiesToSave) 43 | { 44 | var cameraProperty = camera.Get(propertyId); 45 | SetProperty(propertyId, cameraProperty.Value, cameraProperty.Flags); 46 | } 47 | } 48 | 49 | public void Apply(Camera camera) 50 | { 51 | foreach (var kv in Properties) 52 | { 53 | var presetProperty = kv.Value; 54 | var cameraProperty = camera.Get(kv.Key); 55 | cameraProperty.Value = presetProperty.Value; 56 | cameraProperty.Flags = presetProperty.Flags; 57 | } 58 | } 59 | 60 | public class PropertyValue 61 | { 62 | public int Value { get; set; } 63 | 64 | [JsonConverter(typeof(StringEnumConverter))] 65 | public CameraPropertyFlags Flags { get; set; } 66 | } 67 | } 68 | 69 | public class PresetGroup 70 | { 71 | public string Name { get; set; } 72 | public List Presets { get; } = new List(); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /CameraControlLib/CameraControlLib.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {76FA62D4-EB0C-40EF-949E-51A3A556504C} 8 | Library 9 | Properties 10 | CameraControlLib 11 | CameraControlLib 12 | v4.5.2 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | ..\lib\DirectShowLib-2005.dll 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 58 | -------------------------------------------------------------------------------- /CameraController/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace CameraController.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CameraController.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized resource of type System.Drawing.Bitmap. 65 | /// 66 | internal static System.Drawing.Bitmap NewGroup { 67 | get { 68 | object obj = ResourceManager.GetObject("NewGroup", resourceCulture); 69 | return ((System.Drawing.Bitmap)(obj)); 70 | } 71 | } 72 | 73 | /// 74 | /// Looks up a localized resource of type System.Drawing.Bitmap. 75 | /// 76 | internal static System.Drawing.Bitmap Rename { 77 | get { 78 | object obj = ResourceManager.GetObject("Rename", resourceCulture); 79 | return ((System.Drawing.Bitmap)(obj)); 80 | } 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /CameraController/CameraControlSlider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using CameraControlLib; 11 | 12 | namespace CameraController 13 | { 14 | public partial class CameraControlSlider : UserControl 15 | { 16 | public CameraProperty Property { get; private set; } 17 | 18 | public bool PresetEnabled 19 | { 20 | get { return presetEnabledCheckbox.Checked; } 21 | set { presetEnabledCheckbox.Checked = value; } 22 | } 23 | 24 | public CameraControlSlider() 25 | { 26 | InitializeComponent(); 27 | } 28 | 29 | public CameraControlSlider(CameraProperty prop) : this() 30 | { 31 | SetCameraProperty(prop); 32 | } 33 | 34 | public void SetCameraProperty(CameraProperty prop) 35 | { 36 | if (Property != null) 37 | { 38 | Property.Refreshed -= Property_Refreshed; 39 | } 40 | 41 | Property = prop; 42 | Enabled = (Property != null && Property.Supported); 43 | propertyName.Text = Property.Name ?? "Undefined property"; 44 | 45 | if (Property != null) 46 | { 47 | Property.Refreshed += Property_Refreshed; 48 | valueTrackbar.Minimum = Property.Min; 49 | valueTrackbar.Maximum = Property.Max; 50 | valueTrackbar.SmallChange = Property.MinimumStepSize; 51 | valueTrackbar.LargeChange = Property.MinimumStepSize * 4; 52 | valueTrackbar.TickFrequency = Property.MinimumStepSize; 53 | 54 | var validModes = new List(); 55 | foreach (var propertyMode in SUPPORTED_MODES) 56 | if (Property.Capabilities.HasFlag(propertyMode.Flag)) 57 | validModes.Add(propertyMode); 58 | 59 | modeSelector.DataSource = validModes; 60 | modeSelector.DisplayMember = "Name"; 61 | modeSelector.ValueMember = "Flag"; 62 | 63 | Property_Refreshed(Property, new EventArgs()); 64 | } 65 | } 66 | 67 | class PropertyMode 68 | { 69 | public CameraPropertyFlags Flag { get; set; } 70 | public String Name { get; set; } 71 | } 72 | 73 | static List SUPPORTED_MODES = new List() { 74 | new PropertyMode() {Name = "Automatic", Flag = CameraPropertyFlags.Automatic}, 75 | new PropertyMode() {Name = "Manual", Flag = CameraPropertyFlags.Manual} 76 | }; 77 | 78 | private void Property_Refreshed(object sender, EventArgs e) 79 | { 80 | valueTrackbar.Value = Property.Value; 81 | if (!modeSelector.DroppedDown) 82 | modeSelector.SelectedValue = Property.Flags; 83 | } 84 | 85 | private void valueTrackbar_Scroll(object sender, EventArgs e) 86 | { 87 | if (Property != null && Property.Supported) 88 | { 89 | Property.Value = valueTrackbar.Value; 90 | Property.Flags = CameraPropertyFlags.Manual; 91 | Property.Save(); 92 | } 93 | } 94 | 95 | private void modeSelector_SelectionChangeCommitted(object sender, EventArgs e) 96 | { 97 | if (Property != null && Property.Supported) 98 | { 99 | Property.Flags = (CameraPropertyFlags)modeSelector.SelectedValue; 100 | Property.Save(); 101 | } 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /CameraController/OptionsDialog.cs: -------------------------------------------------------------------------------- 1 | using CameraControlLib; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel; 5 | using System.Data; 6 | using System.Drawing; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | using System.Windows.Forms; 11 | 12 | namespace CameraController 13 | { 14 | public partial class OptionsDialog : Form 15 | { 16 | private Settings _settings; 17 | List _cameraPropertyDescriptors = Camera.KnownProperties.ToList(); 18 | 19 | public OptionsDialog(Settings settings) 20 | { 21 | InitializeComponent(); 22 | _settings = settings; 23 | 24 | // Prepare a list of available cameras. 25 | // If the currently selected default camera is not available, it will be added to 26 | // the list with an "[unplugged?]" comment in front of it. This means the existing 27 | // default will be preserved if the options are edited with the camera unplugged. 28 | var availableCameras = CameraDescriptor.GetAll().Cast().ToList(); 29 | var defaultCameraList = availableCameras.Select(c => new DefaultCameraListItem() { CameraDescriptor = c }).ToList(); 30 | var currentCameraSetting = _settings.DefaultCamera; 31 | ICameraDescriptor cameraToSelect = null; 32 | if (currentCameraSetting != null) 33 | { 34 | var existingCameraEntry = availableCameras.FirstOrDefault(c => c.Name == currentCameraSetting.Name && c.DevicePath == currentCameraSetting.DevicePath); 35 | if (existingCameraEntry != null) 36 | { 37 | cameraToSelect = existingCameraEntry; 38 | } 39 | else 40 | { 41 | defaultCameraList.Insert(0, new DefaultCameraListItem() { CameraDescriptor = currentCameraSetting, Comment = "unplugged?" }); 42 | cameraToSelect = currentCameraSetting; 43 | } 44 | } 45 | 46 | availableCamerasComboBox.DataSource = defaultCameraList; 47 | availableCamerasComboBox.DisplayMember = "Text"; 48 | availableCamerasComboBox.ValueMember = "CameraDescriptor"; 49 | availableCamerasComboBox.SelectedValue = cameraToSelect; 50 | 51 | visiblePropertiesListbox.DataSource = _cameraPropertyDescriptors; 52 | visiblePropertiesListbox.DisplayMember = "Name"; 53 | UpdateVisiblePropertiesCheckState(); 54 | } 55 | 56 | class DefaultCameraListItem 57 | { 58 | public ICameraDescriptor CameraDescriptor { get; set; } 59 | public string Comment { get; set; } = null; 60 | public string Text 61 | { 62 | get 63 | { 64 | if (Comment != null) 65 | return String.Format("[{0}] {1}", Comment, CameraDescriptor.Name); 66 | else 67 | return CameraDescriptor.Name; 68 | } 69 | } 70 | } 71 | 72 | public void UpdateSettings() 73 | { 74 | _settings.HiddenProperties = GetHiddenProperties(); 75 | var selectedDefaultCamera = availableCamerasComboBox.SelectedValue as ICameraDescriptor; 76 | if (selectedDefaultCamera != null) 77 | { 78 | _settings.DefaultCamera = new CameraReference() { Name = selectedDefaultCamera.Name, DevicePath = selectedDefaultCamera.DevicePath }; 79 | } 80 | } 81 | 82 | private void UpdateVisiblePropertiesCheckState() 83 | { 84 | Predicate isVisible = (id) => _settings.HiddenProperties == null || !_settings.HiddenProperties.Contains(id); 85 | for (int i = 0; i < _cameraPropertyDescriptors.Count; i++) 86 | { 87 | visiblePropertiesListbox.SetItemChecked(i, isVisible(_cameraPropertyDescriptors[i].Id)); 88 | } 89 | } 90 | 91 | private List GetHiddenProperties() 92 | { 93 | List hiddenProperties = new List(); 94 | for (int i = 0; i < _cameraPropertyDescriptors.Count; i++) 95 | if (!visiblePropertiesListbox.GetItemChecked(i)) 96 | hiddenProperties.Add(_cameraPropertyDescriptors[i].Id); 97 | return hiddenProperties; 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /CameraController/CameraSelectDialog.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace CameraController 2 | { 3 | partial class CameraSelectDialog 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.okButton = new System.Windows.Forms.Button(); 32 | this.cancelButton = new System.Windows.Forms.Button(); 33 | this.availableCameraComboBox = new System.Windows.Forms.ComboBox(); 34 | this.label1 = new System.Windows.Forms.Label(); 35 | this.SuspendLayout(); 36 | // 37 | // okButton 38 | // 39 | this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 40 | this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; 41 | this.okButton.Location = new System.Drawing.Point(256, 78); 42 | this.okButton.Name = "okButton"; 43 | this.okButton.Size = new System.Drawing.Size(75, 23); 44 | this.okButton.TabIndex = 0; 45 | this.okButton.Text = "OK"; 46 | this.okButton.UseVisualStyleBackColor = true; 47 | // 48 | // cancelButton 49 | // 50 | this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 51 | this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; 52 | this.cancelButton.Location = new System.Drawing.Point(337, 78); 53 | this.cancelButton.Name = "cancelButton"; 54 | this.cancelButton.Size = new System.Drawing.Size(75, 23); 55 | this.cancelButton.TabIndex = 1; 56 | this.cancelButton.Text = "Cancel"; 57 | this.cancelButton.UseVisualStyleBackColor = true; 58 | // 59 | // availableCameraComboBox 60 | // 61 | this.availableCameraComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 62 | this.availableCameraComboBox.FormattingEnabled = true; 63 | this.availableCameraComboBox.Location = new System.Drawing.Point(12, 36); 64 | this.availableCameraComboBox.Name = "availableCameraComboBox"; 65 | this.availableCameraComboBox.Size = new System.Drawing.Size(400, 21); 66 | this.availableCameraComboBox.TabIndex = 2; 67 | // 68 | // label1 69 | // 70 | this.label1.AutoSize = true; 71 | this.label1.Location = new System.Drawing.Point(12, 20); 72 | this.label1.Name = "label1"; 73 | this.label1.Size = new System.Drawing.Size(93, 13); 74 | this.label1.TabIndex = 3; 75 | this.label1.Text = "Available cameras"; 76 | // 77 | // CameraSelectDialog 78 | // 79 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 80 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 81 | this.ClientSize = new System.Drawing.Size(424, 113); 82 | this.Controls.Add(this.label1); 83 | this.Controls.Add(this.availableCameraComboBox); 84 | this.Controls.Add(this.cancelButton); 85 | this.Controls.Add(this.okButton); 86 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; 87 | this.MaximizeBox = false; 88 | this.MinimizeBox = false; 89 | this.Name = "CameraSelectDialog"; 90 | this.Text = "Select Camera"; 91 | this.ResumeLayout(false); 92 | this.PerformLayout(); 93 | 94 | } 95 | 96 | #endregion 97 | 98 | private System.Windows.Forms.Button okButton; 99 | private System.Windows.Forms.Button cancelButton; 100 | private System.Windows.Forms.ComboBox availableCameraComboBox; 101 | private System.Windows.Forms.Label label1; 102 | } 103 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | [Xx]64/ 19 | [Xx]86/ 20 | [Bb]uild/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opendb 80 | *.opensdf 81 | *.sdf 82 | *.cachefile 83 | *.VC.db 84 | 85 | # Visual Studio profiler 86 | *.psess 87 | *.vsp 88 | *.vspx 89 | *.sap 90 | 91 | # TFS 2012 Local Workspace 92 | $tf/ 93 | 94 | # Guidance Automation Toolkit 95 | *.gpState 96 | 97 | # ReSharper is a .NET coding add-in 98 | _ReSharper*/ 99 | *.[Rr]e[Ss]harper 100 | *.DotSettings.user 101 | 102 | # JustCode is a .NET coding add-in 103 | .JustCode 104 | 105 | # TeamCity is a build add-in 106 | _TeamCity* 107 | 108 | # DotCover is a Code Coverage Tool 109 | *.dotCover 110 | 111 | # NCrunch 112 | _NCrunch_* 113 | .*crunch*.local.xml 114 | nCrunchTemp_* 115 | 116 | # MightyMoose 117 | *.mm.* 118 | AutoTest.Net/ 119 | 120 | # Web workbench (sass) 121 | .sass-cache/ 122 | 123 | # Installshield output folder 124 | [Ee]xpress/ 125 | 126 | # DocProject is a documentation generator add-in 127 | DocProject/buildhelp/ 128 | DocProject/Help/*.HxT 129 | DocProject/Help/*.HxC 130 | DocProject/Help/*.hhc 131 | DocProject/Help/*.hhk 132 | DocProject/Help/*.hhp 133 | DocProject/Help/Html2 134 | DocProject/Help/html 135 | 136 | # Click-Once directory 137 | publish/ 138 | 139 | # Publish Web Output 140 | *.[Pp]ublish.xml 141 | *.azurePubxml 142 | 143 | # TODO: Un-comment the next line if you do not want to checkin 144 | # your web deploy settings because they may include unencrypted 145 | # passwords 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # NuGet Packages 150 | *.nupkg 151 | # The packages folder can be ignored because of Package Restore 152 | **/packages/* 153 | # except build/, which is used as an MSBuild target. 154 | !**/packages/build/ 155 | # Uncomment if necessary however generally it will be regenerated when needed 156 | #!**/packages/repositories.config 157 | # NuGet v3's project.json files produces more ignoreable files 158 | *.nuget.props 159 | *.nuget.targets 160 | 161 | # Microsoft Azure Build Output 162 | csx/ 163 | *.build.csdef 164 | 165 | # Microsoft Azure Emulator 166 | ecf/ 167 | rcf/ 168 | 169 | # Windows Store app package directory 170 | AppPackages/ 171 | BundleArtifacts/ 172 | 173 | # Visual Studio cache files 174 | # files ending in .cache can be ignored 175 | *.[Cc]ache 176 | # but keep track of directories ending in .cache 177 | !*.[Cc]ache/ 178 | 179 | # Others 180 | ClientBin/ 181 | [Ss]tyle[Cc]op.* 182 | ~$* 183 | *~ 184 | *.dbmdl 185 | *.dbproj.schemaview 186 | *.pfx 187 | *.publishsettings 188 | node_modules/ 189 | orleans.codegen.cs 190 | 191 | # RIA/Silverlight projects 192 | Generated_Code/ 193 | 194 | # Backup & report files from converting an old project file 195 | # to a newer Visual Studio version. Backup files are not needed, 196 | # because we have git ;-) 197 | _UpgradeReport_Files/ 198 | Backup*/ 199 | UpgradeLog*.XML 200 | UpgradeLog*.htm 201 | 202 | # SQL Server files 203 | *.mdf 204 | *.ldf 205 | 206 | # Business Intelligence projects 207 | *.rdl.data 208 | *.bim.layout 209 | *.bim_*.settings 210 | 211 | # Microsoft Fakes 212 | FakesAssemblies/ 213 | 214 | # GhostDoc plugin setting file 215 | *.GhostDoc.xml 216 | 217 | # Node.js Tools for Visual Studio 218 | .ntvs_analysis.dat 219 | 220 | # Visual Studio 6 build log 221 | *.plg 222 | 223 | # Visual Studio 6 workspace options file 224 | *.opt 225 | 226 | # Visual Studio LightSwitch build output 227 | **/*.HTMLClient/GeneratedArtifacts 228 | **/*.DesktopClient/GeneratedArtifacts 229 | **/*.DesktopClient/ModelManifest.xml 230 | **/*.Server/GeneratedArtifacts 231 | **/*.Server/ModelManifest.xml 232 | _Pvt_Extensions 233 | 234 | # LightSwitch generated files 235 | GeneratedArtifacts/ 236 | ModelManifest.xml 237 | 238 | # Paket dependency manager 239 | .paket/paket.exe 240 | 241 | # FAKE - F# Make 242 | .fake/ 243 | -------------------------------------------------------------------------------- /CameraController/CameraControlSlider.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace CameraController 2 | { 3 | partial class CameraControlSlider 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.valueTrackbar = new System.Windows.Forms.TrackBar(); 32 | this.presetEnabledCheckbox = new System.Windows.Forms.CheckBox(); 33 | this.modeSelector = new System.Windows.Forms.ComboBox(); 34 | this.propertyName = new System.Windows.Forms.Label(); 35 | ((System.ComponentModel.ISupportInitialize)(this.valueTrackbar)).BeginInit(); 36 | this.SuspendLayout(); 37 | // 38 | // valueTrackbar 39 | // 40 | this.valueTrackbar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 41 | | System.Windows.Forms.AnchorStyles.Right))); 42 | this.valueTrackbar.Location = new System.Drawing.Point(135, 3); 43 | this.valueTrackbar.Name = "valueTrackbar"; 44 | this.valueTrackbar.Size = new System.Drawing.Size(110, 45); 45 | this.valueTrackbar.TabIndex = 0; 46 | this.valueTrackbar.Scroll += new System.EventHandler(this.valueTrackbar_Scroll); 47 | // 48 | // presetEnabledCheckbox 49 | // 50 | this.presetEnabledCheckbox.AutoSize = true; 51 | this.presetEnabledCheckbox.Location = new System.Drawing.Point(114, 6); 52 | this.presetEnabledCheckbox.Name = "presetEnabledCheckbox"; 53 | this.presetEnabledCheckbox.Size = new System.Drawing.Size(15, 14); 54 | this.presetEnabledCheckbox.TabIndex = 1; 55 | this.presetEnabledCheckbox.UseVisualStyleBackColor = true; 56 | // 57 | // modeSelector 58 | // 59 | this.modeSelector.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 60 | this.modeSelector.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 61 | this.modeSelector.FormattingEnabled = true; 62 | this.modeSelector.Location = new System.Drawing.Point(251, 3); 63 | this.modeSelector.Name = "modeSelector"; 64 | this.modeSelector.Size = new System.Drawing.Size(73, 21); 65 | this.modeSelector.TabIndex = 2; 66 | this.modeSelector.SelectionChangeCommitted += new System.EventHandler(this.modeSelector_SelectionChangeCommitted); 67 | // 68 | // propertyName 69 | // 70 | this.propertyName.Location = new System.Drawing.Point(-3, 6); 71 | this.propertyName.Name = "propertyName"; 72 | this.propertyName.Size = new System.Drawing.Size(111, 32); 73 | this.propertyName.TabIndex = 3; 74 | this.propertyName.Text = ""; 75 | this.propertyName.TextAlign = System.Drawing.ContentAlignment.TopRight; 76 | // 77 | // CameraControlSlider 78 | // 79 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 80 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 81 | this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; 82 | this.Controls.Add(this.propertyName); 83 | this.Controls.Add(this.modeSelector); 84 | this.Controls.Add(this.presetEnabledCheckbox); 85 | this.Controls.Add(this.valueTrackbar); 86 | this.Name = "CameraControlSlider"; 87 | this.Size = new System.Drawing.Size(327, 38); 88 | ((System.ComponentModel.ISupportInitialize)(this.valueTrackbar)).EndInit(); 89 | this.ResumeLayout(false); 90 | this.PerformLayout(); 91 | 92 | } 93 | 94 | #endregion 95 | 96 | private System.Windows.Forms.TrackBar valueTrackbar; 97 | private System.Windows.Forms.CheckBox presetEnabledCheckbox; 98 | private System.Windows.Forms.ComboBox modeSelector; 99 | private System.Windows.Forms.Label propertyName; 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /CameraController/NameEntryDialog.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace CameraController 2 | { 3 | partial class NameEntryDialog 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.label1 = new System.Windows.Forms.Label(); 32 | this.groupNameTextbox = new System.Windows.Forms.TextBox(); 33 | this.okButton = new System.Windows.Forms.Button(); 34 | this.cancelButton = new System.Windows.Forms.Button(); 35 | this.SuspendLayout(); 36 | // 37 | // label1 38 | // 39 | this.label1.AutoSize = true; 40 | this.label1.Location = new System.Drawing.Point(12, 22); 41 | this.label1.Name = "label1"; 42 | this.label1.Size = new System.Drawing.Size(35, 13); 43 | this.label1.TabIndex = 0; 44 | this.label1.Text = "Name"; 45 | // 46 | // groupNameTextbox 47 | // 48 | this.groupNameTextbox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 49 | | System.Windows.Forms.AnchorStyles.Right))); 50 | this.groupNameTextbox.Location = new System.Drawing.Point(12, 38); 51 | this.groupNameTextbox.Name = "groupNameTextbox"; 52 | this.groupNameTextbox.Size = new System.Drawing.Size(301, 20); 53 | this.groupNameTextbox.TabIndex = 1; 54 | this.groupNameTextbox.Validating += new System.ComponentModel.CancelEventHandler(this.groupNameTextbox_Validating); 55 | // 56 | // okButton 57 | // 58 | this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 59 | this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; 60 | this.okButton.Location = new System.Drawing.Point(157, 85); 61 | this.okButton.Name = "okButton"; 62 | this.okButton.Size = new System.Drawing.Size(75, 23); 63 | this.okButton.TabIndex = 2; 64 | this.okButton.Text = "OK"; 65 | this.okButton.UseVisualStyleBackColor = true; 66 | // 67 | // cancelButton 68 | // 69 | this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 70 | this.cancelButton.CausesValidation = false; 71 | this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; 72 | this.cancelButton.Location = new System.Drawing.Point(238, 85); 73 | this.cancelButton.Name = "cancelButton"; 74 | this.cancelButton.Size = new System.Drawing.Size(75, 23); 75 | this.cancelButton.TabIndex = 3; 76 | this.cancelButton.Text = "Cancel"; 77 | this.cancelButton.UseVisualStyleBackColor = true; 78 | // 79 | // NameEntryDialog 80 | // 81 | this.AcceptButton = this.okButton; 82 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 83 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 84 | this.CancelButton = this.cancelButton; 85 | this.ClientSize = new System.Drawing.Size(325, 120); 86 | this.Controls.Add(this.cancelButton); 87 | this.Controls.Add(this.okButton); 88 | this.Controls.Add(this.groupNameTextbox); 89 | this.Controls.Add(this.label1); 90 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; 91 | this.MaximizeBox = false; 92 | this.MinimizeBox = false; 93 | this.Name = "NameEntryDialog"; 94 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 95 | this.Shown += new System.EventHandler(this.PresetGroupNameDialog_Shown); 96 | this.ResumeLayout(false); 97 | this.PerformLayout(); 98 | 99 | } 100 | 101 | #endregion 102 | 103 | private System.Windows.Forms.Label label1; 104 | private System.Windows.Forms.TextBox groupNameTextbox; 105 | private System.Windows.Forms.Button okButton; 106 | private System.Windows.Forms.Button cancelButton; 107 | } 108 | } -------------------------------------------------------------------------------- /CameraController/NameEntryDialog.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /CameraController/OptionsDialog.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /CameraController/CameraControlSlider.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /CameraController/CameraSelectDialog.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /CameraController/MainWindow.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | 124 | 179, 17 125 | 126 | -------------------------------------------------------------------------------- /CameraController/OptionsDialog.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace CameraController 2 | { 3 | partial class OptionsDialog 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.availableCamerasComboBox = new System.Windows.Forms.ComboBox(); 32 | this.label1 = new System.Windows.Forms.Label(); 33 | this.visiblePropertiesListbox = new System.Windows.Forms.CheckedListBox(); 34 | this.label2 = new System.Windows.Forms.Label(); 35 | this.okButton = new System.Windows.Forms.Button(); 36 | this.cancelButton = new System.Windows.Forms.Button(); 37 | this.SuspendLayout(); 38 | // 39 | // availableCamerasComboBox 40 | // 41 | this.availableCamerasComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 42 | | System.Windows.Forms.AnchorStyles.Right))); 43 | this.availableCamerasComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 44 | this.availableCamerasComboBox.FormattingEnabled = true; 45 | this.availableCamerasComboBox.Location = new System.Drawing.Point(98, 17); 46 | this.availableCamerasComboBox.Name = "availableCamerasComboBox"; 47 | this.availableCamerasComboBox.Size = new System.Drawing.Size(285, 21); 48 | this.availableCamerasComboBox.TabIndex = 0; 49 | // 50 | // label1 51 | // 52 | this.label1.AutoSize = true; 53 | this.label1.Location = new System.Drawing.Point(12, 20); 54 | this.label1.Name = "label1"; 55 | this.label1.Size = new System.Drawing.Size(80, 13); 56 | this.label1.TabIndex = 1; 57 | this.label1.Text = "Default Camera"; 58 | // 59 | // visiblePropertiesListbox 60 | // 61 | this.visiblePropertiesListbox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 62 | | System.Windows.Forms.AnchorStyles.Right))); 63 | this.visiblePropertiesListbox.CheckOnClick = true; 64 | this.visiblePropertiesListbox.FormattingEnabled = true; 65 | this.visiblePropertiesListbox.Location = new System.Drawing.Point(12, 74); 66 | this.visiblePropertiesListbox.Name = "visiblePropertiesListbox"; 67 | this.visiblePropertiesListbox.Size = new System.Drawing.Size(371, 199); 68 | this.visiblePropertiesListbox.TabIndex = 2; 69 | // 70 | // label2 71 | // 72 | this.label2.AutoSize = true; 73 | this.label2.Location = new System.Drawing.Point(15, 58); 74 | this.label2.Name = "label2"; 75 | this.label2.Size = new System.Drawing.Size(86, 13); 76 | this.label2.TabIndex = 3; 77 | this.label2.Text = "Visible properties"; 78 | // 79 | // okButton 80 | // 81 | this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 82 | this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; 83 | this.okButton.Location = new System.Drawing.Point(227, 293); 84 | this.okButton.Name = "okButton"; 85 | this.okButton.Size = new System.Drawing.Size(75, 23); 86 | this.okButton.TabIndex = 4; 87 | this.okButton.Text = "OK"; 88 | this.okButton.UseVisualStyleBackColor = true; 89 | // 90 | // cancelButton 91 | // 92 | this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 93 | this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; 94 | this.cancelButton.Location = new System.Drawing.Point(308, 293); 95 | this.cancelButton.Name = "cancelButton"; 96 | this.cancelButton.Size = new System.Drawing.Size(75, 23); 97 | this.cancelButton.TabIndex = 5; 98 | this.cancelButton.Text = "Cancel"; 99 | this.cancelButton.UseVisualStyleBackColor = true; 100 | // 101 | // OptionsDialog 102 | // 103 | this.AcceptButton = this.okButton; 104 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 105 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 106 | this.CancelButton = this.cancelButton; 107 | this.ClientSize = new System.Drawing.Size(395, 328); 108 | this.Controls.Add(this.cancelButton); 109 | this.Controls.Add(this.okButton); 110 | this.Controls.Add(this.label2); 111 | this.Controls.Add(this.visiblePropertiesListbox); 112 | this.Controls.Add(this.label1); 113 | this.Controls.Add(this.availableCamerasComboBox); 114 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; 115 | this.MaximizeBox = false; 116 | this.MinimizeBox = false; 117 | this.Name = "OptionsDialog"; 118 | this.Text = "Options"; 119 | this.ResumeLayout(false); 120 | this.PerformLayout(); 121 | 122 | } 123 | 124 | #endregion 125 | 126 | private System.Windows.Forms.ComboBox availableCamerasComboBox; 127 | private System.Windows.Forms.Label label1; 128 | private System.Windows.Forms.CheckedListBox visiblePropertiesListbox; 129 | private System.Windows.Forms.Label label2; 130 | private System.Windows.Forms.Button okButton; 131 | private System.Windows.Forms.Button cancelButton; 132 | } 133 | } -------------------------------------------------------------------------------- /CameraController/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 122 | ..\Resources\NewSolutionFolder_6289.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 123 | 124 | 125 | ..\Resources\Rename_6779.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 126 | 127 | -------------------------------------------------------------------------------- /CameraController/MainWindow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using CameraControlLib; 11 | 12 | namespace CameraController 13 | { 14 | public partial class MainWindow : Form 15 | { 16 | public Settings Settings { get; private set; } 17 | public Camera Camera { get; private set; } 18 | List _sliderControls = new List(); 19 | 20 | public MainWindow(Settings settings) 21 | { 22 | InitializeComponent(); 23 | Settings = settings; 24 | presetSelectorControl.Initialize(Settings, CapturePreset); 25 | 26 | var defaultCamera = GetDefaultCamera(); 27 | SetCamera(defaultCamera?.Create()); 28 | } 29 | 30 | private CameraDescriptor GetDefaultCamera() 31 | { 32 | CameraDescriptor preferredCamera = null; 33 | if (Settings.DefaultCamera != null) 34 | preferredCamera = CameraDescriptor.Find(Settings.DefaultCamera.Name, Settings.DefaultCamera.DevicePath); 35 | return preferredCamera ?? CameraDescriptor.GetAll().FirstOrDefault(); 36 | } 37 | 38 | private void SetCamera(Camera camera) 39 | { 40 | if (Camera != null && Camera != camera) 41 | Camera.Dispose(); 42 | 43 | Camera = camera; 44 | presetSelectorControl.ActivePreset = null; 45 | UpdateCameraSliders(); 46 | } 47 | 48 | private void UpdateCameraSliders(bool forceShowAll = false) 49 | { 50 | foreach (Control control in propertySliderPanel.Controls) 51 | control.Dispose(); 52 | propertySliderPanel.Controls.Clear(); 53 | _sliderControls.Clear(); 54 | 55 | if (Camera != null) 56 | { 57 | Camera.Refresh(); 58 | int topPosition = 0; 59 | int sliderControlWidth = propertySliderPanel.Width - 10; //Allow 10px margin on the right 60 | foreach (var prop in Camera.GetSupportedProperties()) 61 | { 62 | if (!forceShowAll && Settings.HiddenProperties != null && Settings.HiddenProperties.Contains(prop.Id)) 63 | continue; 64 | 65 | var slider = new CameraControlSlider(prop); 66 | slider.Top = topPosition; 67 | slider.Width = sliderControlWidth; 68 | slider.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; 69 | topPosition += slider.Height; 70 | propertySliderPanel.Controls.Add(slider); 71 | _sliderControls.Add(slider); 72 | } 73 | } 74 | else 75 | { 76 | Label noCameraSelectedLabel = new Label(); 77 | noCameraSelectedLabel.AutoSize = true; 78 | noCameraSelectedLabel.Text = "No camera selected"; 79 | noCameraSelectedLabel.Font = new Font(noCameraSelectedLabel.Font.FontFamily, 14, FontStyle.Regular); 80 | noCameraSelectedLabel.Left = 20; 81 | noCameraSelectedLabel.Top = 20; 82 | propertySliderPanel.Controls.Add(noCameraSelectedLabel); 83 | } 84 | } 85 | 86 | private IEnumerable GetPresetEnabledProperties() 87 | { 88 | foreach (var slider in _sliderControls) 89 | if (slider.PresetEnabled) 90 | yield return slider.Property.Id; 91 | } 92 | 93 | private void CapturePreset(Preset preset) 94 | { 95 | var enabledProperties = GetPresetEnabledProperties(); 96 | preset.RecordPreset(Camera, enabledProperties); 97 | } 98 | 99 | private void cameraUpdateTimer_Tick(object sender, EventArgs e) 100 | { 101 | if (Camera != null) 102 | { 103 | Camera.Refresh(); 104 | 105 | if (presetSelectorControl.ActivePreset != null) 106 | { 107 | presetSelectorControl.ActivePreset.Apply(Camera); 108 | Camera.Save(); 109 | } 110 | } 111 | } 112 | 113 | private void alwaysOnTopToolStripMenuItem_Click(object sender, EventArgs e) 114 | { 115 | TopMost = alwaysOnTopToolStripMenuItem.Checked; 116 | } 117 | 118 | private void exitToolStripMenuItem_Click(object sender, EventArgs e) 119 | { 120 | Application.Exit(); 121 | } 122 | 123 | private void selectCameraToolStripMenuItem_Click(object sender, EventArgs e) 124 | { 125 | using (var cameraSelectDialog = new CameraSelectDialog()) 126 | { 127 | if (cameraSelectDialog.ShowDialog(this) == DialogResult.OK) 128 | { 129 | SetCamera(cameraSelectDialog.SelectedCamera?.Create()); 130 | } 131 | } 132 | } 133 | 134 | private void optionsToolStripMenuItem1_Click(object sender, EventArgs e) 135 | { 136 | using (var optionsDialog = new OptionsDialog(Settings)) 137 | { 138 | if (optionsDialog.ShowDialog(this) == DialogResult.OK) 139 | { 140 | optionsDialog.UpdateSettings(); 141 | Settings.Save(); 142 | 143 | UpdateCameraSliders(); 144 | } 145 | } 146 | } 147 | 148 | private void resetToDefaultsToolStripMenuItem_Click(object sender, EventArgs e) 149 | { 150 | presetSelectorControl.ActivePreset = null; 151 | Camera?.ResetToDefault(); 152 | Camera?.Save(); 153 | } 154 | 155 | private void presetSelectorControl_SelectedPresetChanged(object sender, PresetSelectorEventArgs e) 156 | { 157 | if (e.Preset != null) 158 | { 159 | foreach (var slider in _sliderControls) 160 | { 161 | slider.PresetEnabled = e.Preset.Properties.ContainsKey(slider.Property.Id); 162 | } 163 | } 164 | } 165 | 166 | private void presetSelectorControl_ApplyPreset(object sender, PresetSelectorEventArgs e) 167 | { 168 | e.Preset.Apply(Camera); 169 | Camera.Save(); 170 | } 171 | 172 | private void presetSelectorControl_ActivePresetChanged(object sender, PresetSelectorEventArgs e) 173 | { 174 | foreach (var slider in _sliderControls) 175 | { 176 | slider.Enabled = e.Preset == null || !e.Preset.Properties.ContainsKey(slider.Property.Id); 177 | } 178 | } 179 | } 180 | } 181 | -------------------------------------------------------------------------------- /CameraController/CameraController.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {42B92CB0-1307-4339-A10F-CCCF823A4252} 8 | WinExe 9 | Properties 10 | CameraController 11 | CameraController 12 | v4.5.2 13 | 512 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | ..\packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll 38 | True 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | UserControl 55 | 56 | 57 | CameraControlSlider.cs 58 | 59 | 60 | Form 61 | 62 | 63 | CameraSelectDialog.cs 64 | 65 | 66 | Form 67 | 68 | 69 | MainWindow.cs 70 | 71 | 72 | Form 73 | 74 | 75 | OptionsDialog.cs 76 | 77 | 78 | 79 | Form 80 | 81 | 82 | NameEntryDialog.cs 83 | 84 | 85 | UserControl 86 | 87 | 88 | PresetSelectorControl.cs 89 | 90 | 91 | 92 | 93 | 94 | CameraControlSlider.cs 95 | 96 | 97 | CameraSelectDialog.cs 98 | 99 | 100 | MainWindow.cs 101 | 102 | 103 | OptionsDialog.cs 104 | 105 | 106 | NameEntryDialog.cs 107 | 108 | 109 | PresetSelectorControl.cs 110 | 111 | 112 | ResXFileCodeGenerator 113 | Resources.Designer.cs 114 | Designer 115 | 116 | 117 | True 118 | Resources.resx 119 | True 120 | 121 | 122 | 123 | SettingsSingleFileGenerator 124 | Settings.Designer.cs 125 | 126 | 127 | True 128 | Settings.settings 129 | True 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | {76fa62d4-eb0c-40ef-949e-51a3a556504c} 138 | CameraControlLib 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 155 | -------------------------------------------------------------------------------- /CameraControlLib/CameraProperty.cs: -------------------------------------------------------------------------------- 1 | using DirectShowLib; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace CameraControlLib 9 | { 10 | [Flags] 11 | public enum CameraPropertyFlags 12 | { 13 | None = 0, 14 | Automatic = 1, 15 | Manual = 2, 16 | Relative = 16 17 | } 18 | 19 | public abstract class CameraPropertyDescriptor 20 | { 21 | public string Id { get; protected set; } 22 | public string Name { get; protected set; } 23 | public abstract string Group { get; } 24 | 25 | public abstract CameraProperty Create(Camera camera); 26 | } 27 | 28 | 29 | public abstract class CameraProperty 30 | { 31 | public CameraPropertyDescriptor Descriptor { get; protected set; } 32 | public string Id { get { return Descriptor.Id; } } 33 | public string Name { get { return Descriptor.Name; } } 34 | public bool Supported { get; protected set; } 35 | public int Min { get; protected set; } 36 | public int Max { get; protected set; } 37 | public int Default { get; protected set; } 38 | public int MinimumStepSize { get; protected set; } 39 | public CameraPropertyFlags Capabilities { get; protected set; } 40 | public int Value { get; set; } 41 | public CameraPropertyFlags Flags { get; set; } 42 | 43 | /// 44 | /// Updates the value and flags on the device 45 | /// 46 | public abstract void Save(); 47 | 48 | /// 49 | /// Gets the current value and flags on the device 50 | /// 51 | public abstract void Refresh(); 52 | 53 | public event EventHandler Saved; 54 | 55 | protected void OnSave() 56 | { 57 | Saved?.Invoke(this, new EventArgs()); 58 | } 59 | 60 | public event EventHandler Refreshed; 61 | 62 | protected void OnRefresh() 63 | { 64 | Refreshed?.Invoke(this, new EventArgs()); 65 | } 66 | 67 | public void ResetToDefault() 68 | { 69 | Value = Default; 70 | if (Capabilities.HasFlag(CameraPropertyFlags.Automatic)) 71 | Flags = CameraPropertyFlags.Automatic; 72 | else 73 | Flags = CameraPropertyFlags.Manual; 74 | Flags &= Capabilities; 75 | } 76 | } 77 | 78 | 79 | internal class CamControlProperty : CameraProperty 80 | { 81 | private readonly IAMCameraControl _cameraControl; 82 | private readonly CameraControlProperty _cameraProperty; 83 | 84 | public CamControlProperty(CameraPropertyDescriptor descriptor, IAMCameraControl cameraControl, CameraControlProperty cameraProperty) 85 | { 86 | Descriptor = descriptor; 87 | _cameraControl = cameraControl; 88 | _cameraProperty = cameraProperty; 89 | UpdateRange(); 90 | } 91 | 92 | public void UpdateRange() 93 | { 94 | int min = 0, max = 0, stepping = 0, defaultValue = 0; 95 | CameraControlFlags flags = CameraControlFlags.None; 96 | 97 | if (_cameraControl == null) 98 | Supported = false; 99 | else 100 | Supported = _cameraControl.GetRange(_cameraProperty, out min, out max, out stepping, out defaultValue, out flags) == 0; 101 | 102 | Min = min; 103 | Max = max; 104 | Default = defaultValue; 105 | MinimumStepSize = stepping; 106 | Capabilities = (CameraPropertyFlags)flags; 107 | } 108 | 109 | public override void Save() 110 | { 111 | _cameraControl.Set(_cameraProperty, Value, (CameraControlFlags)Flags); 112 | OnSave(); 113 | } 114 | 115 | public override void Refresh() 116 | { 117 | int value; 118 | CameraControlFlags flags; 119 | _cameraControl.Get(_cameraProperty, out value, out flags); 120 | Value = value; 121 | Flags = (CameraPropertyFlags)flags; 122 | OnRefresh(); 123 | } 124 | 125 | internal static CameraPropertyDescriptor CreateDescriptor(string id, string name, CameraControlProperty cameraProperty) 126 | { 127 | return new CamControlPropertyDescriptor(id, name, cameraProperty); 128 | } 129 | 130 | internal class CamControlPropertyDescriptor : CameraPropertyDescriptor 131 | { 132 | private CameraControlProperty _cameraProperty; 133 | public override string Group { get { return "cameraControl"; } } 134 | 135 | public CamControlPropertyDescriptor(string id, string name, CameraControlProperty cameraProperty) 136 | { 137 | Id = id; 138 | Name = name; 139 | _cameraProperty = cameraProperty; 140 | } 141 | 142 | public override CameraProperty Create(Camera camera) 143 | { 144 | return new CamControlProperty(this, camera.Filter as IAMCameraControl, _cameraProperty); 145 | } 146 | } 147 | } 148 | 149 | internal class VideoProcAmpCameraProperty : CameraProperty 150 | { 151 | private readonly IAMVideoProcAmp _videoAmpControl; 152 | private readonly VideoProcAmpProperty _videoAmpProperty; 153 | 154 | public VideoProcAmpCameraProperty(CameraPropertyDescriptor descriptor, IAMVideoProcAmp videoAmpControl, VideoProcAmpProperty videoAmpProperty) 155 | { 156 | Descriptor = descriptor; 157 | _videoAmpControl = videoAmpControl; 158 | _videoAmpProperty = videoAmpProperty; 159 | UpdateRange(); 160 | } 161 | 162 | void UpdateRange() 163 | { 164 | int min = 0, max = 0, stepping = 0, defaultValue = 0; 165 | VideoProcAmpFlags flags = VideoProcAmpFlags.None; 166 | 167 | if (_videoAmpControl == null) 168 | Supported = false; 169 | else 170 | Supported = _videoAmpControl.GetRange(_videoAmpProperty, out min, out max, out stepping, out defaultValue, out flags) == 0; 171 | 172 | Min = min; 173 | Max = max; 174 | Default = defaultValue; 175 | MinimumStepSize = stepping; 176 | Capabilities = (CameraPropertyFlags)flags; 177 | } 178 | 179 | public override void Save() 180 | { 181 | _videoAmpControl.Set(_videoAmpProperty, Value, (VideoProcAmpFlags)Flags); 182 | OnSave(); 183 | } 184 | 185 | public override void Refresh() 186 | { 187 | int value; 188 | VideoProcAmpFlags flags; 189 | _videoAmpControl.Get(_videoAmpProperty, out value, out flags); 190 | Value = value; 191 | Flags = (CameraPropertyFlags)flags; 192 | OnRefresh(); 193 | } 194 | 195 | internal static VideoProcAmpPropertyDescriptor CreateDescriptor(string id, string name, VideoProcAmpProperty videoProcProperty) 196 | { 197 | return new VideoProcAmpPropertyDescriptor(id, name, videoProcProperty); 198 | } 199 | 200 | internal class VideoProcAmpPropertyDescriptor : CameraPropertyDescriptor 201 | { 202 | private VideoProcAmpProperty _videoProcProperty; 203 | public override string Group { get { return "videoProcAmp"; } } 204 | 205 | public VideoProcAmpPropertyDescriptor(string id, string name, VideoProcAmpProperty cameraProperty) 206 | { 207 | Id = id; 208 | Name = name; 209 | _videoProcProperty = cameraProperty; 210 | } 211 | 212 | public override CameraProperty Create(Camera camera) 213 | { 214 | return new VideoProcAmpCameraProperty(this, camera.Filter as IAMVideoProcAmp, _videoProcProperty); 215 | } 216 | } 217 | } 218 | } 219 | -------------------------------------------------------------------------------- /CameraController/PresetSelectorControl.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 489, 17 122 | 123 | 124 | 17, 17 125 | 126 | 127 | 128 | AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w 129 | LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 130 | ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACi 131 | BQAAAk1TRnQBSQFMAgEBBAEAAQgBAAEIAQABEAEAARABAAT/ARkBAAj/AUIBTQE2BwABNgMAASgDAAFA 132 | AwABIAMAAQEBAAEYBgABGP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8AFQAD/yTxDAAG8VQAKvEGAAP/ 133 | J/EJAAPxBvYD8VEAA/EBZgLMAWYCzAFmAswBZgLMAWYCzAFmAswBZgLMAWYCzAFmAswBZgLMAWYCzAFm 134 | AswD8QYAA/EBxgHWAe8BZgLMAWYCzAFmAswBZgLMAWYCzAFmAswBZgLMAWYCzAFmAswBxgHWAe8BZgLM 135 | A/EGAAPxA/YGhgP2A/FOAAPxAWYCzAFmAswBZgLMAWYCzAFmAswBZgLMAWYCzAFmAswBZgLMAWYCzAFm 136 | AswBZgLMA/EDAAP/A/EBmQLMAWYCzAFmAswBZgLMAWYCzAFmAswBZgLMAWYCzAFmAswBmQLMA/EBZgLM 137 | A/EDAAPxA/YDhgZCA4YD9gPxSwAD8QFmAswBZgLMAWYCzAFmAswBZgLMAWYCzAFmAswBZgLMAWYCzAFm 138 | AswBZgLMAWYCzAPxAwAD8QHGAdYB7wFmAswBZgLMAWYCzAFmAswBZgLMAWYCzAFmAswBZgLMAZkCzAPq 139 | A/EBZgLMA/EDAAP2A4YDQgGvAa4CrwGuAa8DQgOGA/ZLAAPxAWYCzAFmAswBZgLMAWYCzAFmAswBZgLM 140 | AWYCzAFmAswBZgLMAWYCzAFmAswBZgLMA/EDAAPxAZkCzAFmAswBZgLMAWYCzAFmAswBZgLMAWYCzAFm 141 | AswBZgLMAdYC5wbxAWYCzAPxAwAD9gNCAa8BrgGvAfEB7wHwAfEB7wHwAa8BrgGvA0ID9ksAA/EBZgLM 142 | AWYCzAFmAswBZgLMAWYCzAFmAswBZgLMAWYCzAFmAswBZgLMAWYCzAFmAswD8QMABvEBZgLMHvEBZgLM 143 | A/EDAAP2A0IB8QHvAfAB8QHvAfAB8QHvAfAB8QHvAfADQhv2MwAD8QFmAswBZgLMAWYCzAFmAswBZgLM 144 | AWYCzAFmAswBZgLMAWYCzAFmAswBZgLMAWYCzAPxBgAD8QFmAswe8QFmAswD8QMAA/YDQgHxAe8B8AHx 145 | Ae8B8AHxAe8B8AHxAe8B8BtCA/YzAAPxAWYCzAFmAswBZgLMAWYCzAFmAswBZgLMAWYCzAFmAswBZgLM 146 | AWYCzAFmAswBZgLMA/EGAAPxAWYCzB7xAWYCzAPxAwAD9gNCAfEB7wHwAfEB7wHwAfEB7wHwAfEB7wHw 147 | G0ID9jMAA/EBZgLMAWYCzAFmAswBZgLMAWYCzAFmAswBZgLMAWYCzAFmAswBZgLMAWYCzAFmAswD8QYA 148 | A/EBZgLMAWYCzAFmAswBZgLMA+oS8QFmAswD8QMAA/YDQgHxAe8B8AHxAe8B8AHxAe8B8AHxAe8B8ANC 149 | G/YzAA/xAZkCzAGZAswP8QFmAswD8QYADPEBmQLMAZkCzBLxAWYCzAPxAwAD9hJCA/ZXAAPxAcYB1gHv 150 | AWYCzAFmAswBZgLMAWYCzAFmAswBZgLMAWYCzAPxDwAD8QHGAdYB7wFmAswBZgLMAWYCzAFmAswBZgLM 151 | AWYCzAFmAswBZgLMA/EDAAP2EkID9lcAA/8b8Q8AIfEDAAP2EkID9qgAGPb/AAkAAUIBTQE+BwABPgMA 152 | ASgDAAFAAwABIAMAAQEBAAEBBgABARYAA/+BAAr/AcABAQHnA/8BgAEBAYABAQHDA/8BgAEBAYABAQGB 153 | A/8BgAEBAQABAQEAA/8BgAEBAQABAQEAA/8BgAEBAQABAQEAA/8BgAEBAQABAQIAAv8BgAEBAYABAQIA 154 | Av8BgAEBAYABAQIAAv8BgAEBAYABAQIAAv8BgAEBAYABAQEAA/8B+AEBAfABAQEAA/8B+AEBAfABAQEA 155 | B/8BAAv/Cw== 156 | 157 | 158 | 159 | 171, 17 160 | 161 | 162 | 330, 17 163 | 164 | -------------------------------------------------------------------------------- /CameraController/PresetSelectorControl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace CameraController 12 | { 13 | public partial class PresetSelectorControl : UserControl 14 | { 15 | public event EventHandler ApplyPreset; 16 | public event EventHandler ActivePresetChanged; 17 | public event EventHandler SelectedPresetChanged; 18 | 19 | public Settings Settings { get; set; } 20 | 21 | private Preset _activePreset = null; 22 | public Preset ActivePreset 23 | { 24 | get { return _activePreset; } 25 | set 26 | { 27 | _activePreset = value; 28 | OnActivePresetChanged(); 29 | } 30 | } 31 | 32 | public Preset SelectedPreset 33 | { 34 | get { return this.GetSelectedNodeTag(); } 35 | } 36 | 37 | private Action _capturePresetFunction; 38 | private Font _activePresetFont = new Font(TreeView.DefaultFont, FontStyle.Bold); 39 | 40 | public PresetSelectorControl() 41 | { 42 | InitializeComponent(); 43 | } 44 | 45 | public void Initialize(Settings settings, Action capturePreset) 46 | { 47 | Settings = settings; 48 | _capturePresetFunction = capturePreset; 49 | Settings.Saved += Settings_Saved; 50 | RefreshPresetsList(); 51 | } 52 | 53 | private void Settings_Saved(object sender, EventArgs e) 54 | { 55 | //TODO: saving settings causes preset treeview to redraw. 56 | RefreshPresetsList(); 57 | } 58 | 59 | private void SavePresets() 60 | { 61 | Settings.Save(); 62 | } 63 | 64 | private void OnActivePresetChanged() 65 | { 66 | UpdateTreeViewIcons(); 67 | ActivePresetChanged?.Invoke(this, new PresetSelectorEventArgs(ActivePreset)); 68 | } 69 | 70 | private void RefreshPresetsList() 71 | { 72 | presetTreeView.Nodes.Clear(); 73 | var presetGroups = Settings.PresetGroups.OrderBy(group => group.Name).ToList(); 74 | foreach (var group in presetGroups) 75 | { 76 | TreeNode groupNode = new TreeNode(group.Name); 77 | groupNode.Tag = group; 78 | groupNode.ContextMenuStrip = groupContextMenu; 79 | foreach (var preset in group.Presets.OrderBy(p => Name)) 80 | { 81 | TreeNode presetNode = new TreeNode(preset.Name); 82 | presetNode.ContextMenuStrip = presetContextMenu; 83 | presetNode.Tag = preset; 84 | groupNode.Nodes.Add(presetNode); 85 | } 86 | presetTreeView.Nodes.Add(groupNode); 87 | } 88 | UpdateTreeViewIcons(); 89 | presetTreeView.ExpandAll(); 90 | } 91 | 92 | private void UpdateTreeViewIcons() 93 | { 94 | foreach (TreeNode groupNode in presetTreeView.Nodes) 95 | { 96 | groupNode.ImageKey = groupNode.SelectedImageKey = groupNode.IsExpanded ? "GroupOpen" : "GroupClosed"; 97 | foreach (TreeNode presetNode in groupNode.Nodes) 98 | { 99 | bool isActivePreset = ActivePreset != null && presetNode.Tag == ActivePreset; 100 | presetNode.ImageKey = presetNode.SelectedImageKey = "Preset"; 101 | presetNode.NodeFont = isActivePreset ? _activePresetFont : TreeView.DefaultFont; 102 | presetNode.Text = presetNode.Text; 103 | } 104 | } 105 | } 106 | 107 | private void presetTreeView_OnNodeInteraction(object sender, TreeViewEventArgs e) 108 | { 109 | UpdateTreeViewIcons(); 110 | } 111 | 112 | private void applyPresetMenuItem_Click(object sender, EventArgs e) 113 | { 114 | var preset = GetSelectedNodeTag(); 115 | if (preset != null) 116 | { 117 | ApplyPreset?.Invoke(this, new PresetSelectorEventArgs(preset)); 118 | } 119 | } 120 | 121 | private void presetTreeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) 122 | { 123 | ((TreeView)sender).SelectedNode = e.Node; 124 | } 125 | 126 | private T GetSelectedNodeTag() where T : class 127 | { 128 | return presetTreeView.SelectedNode?.Tag as T; 129 | } 130 | 131 | private void renameGroupToolStripMenuItem_Click(object sender, EventArgs e) 132 | { 133 | var group = GetSelectedNodeTag(); 134 | var groupNode = presetTreeView.SelectedNode; 135 | if (group != null) 136 | { 137 | using (var dialog = new NameEntryDialog("Rename group")) 138 | { 139 | dialog.GroupName = group.Name; 140 | if (dialog.ShowDialog(this) == DialogResult.OK) 141 | { 142 | group.Name = groupNode.Text = dialog.GroupName; 143 | SavePresets(); 144 | } 145 | } 146 | } 147 | } 148 | 149 | private void addGroupToolStripMenuItem_Click(object sender, EventArgs e) 150 | { 151 | using (var dialog = new NameEntryDialog("Add preset group")) 152 | { 153 | dialog.GroupName = "New group"; 154 | if (dialog.ShowDialog(this) == DialogResult.OK) 155 | { 156 | PresetGroup group = new PresetGroup() { Name = dialog.GroupName }; 157 | Settings.PresetGroups.Add(group); 158 | SavePresets(); 159 | } 160 | } 161 | } 162 | 163 | private void renameToolStripMenuItem_Click(object sender, EventArgs e) 164 | { 165 | var preset = GetSelectedNodeTag(); 166 | var presetNode = presetTreeView.SelectedNode; 167 | if (preset != null) 168 | { 169 | using (var dialog = new NameEntryDialog("Rename preset")) 170 | { 171 | dialog.GroupName = preset.Name; 172 | if (dialog.ShowDialog(this) == DialogResult.OK) 173 | { 174 | preset.Name = presetNode.Text = dialog.GroupName; 175 | SavePresets(); 176 | } 177 | } 178 | } 179 | } 180 | 181 | private void addPresetToolStripMenuItem_Click(object sender, EventArgs e) 182 | { 183 | var group = GetSelectedNodeTag(); 184 | var groupNode = presetTreeView.SelectedNode; 185 | if (group != null) 186 | { 187 | var preset = new Preset(); 188 | _capturePresetFunction(preset); 189 | using (var dialog = new NameEntryDialog("Add preset")) 190 | { 191 | if (dialog.ShowDialog(this) == DialogResult.OK) 192 | { 193 | preset.Name = dialog.GroupName; 194 | group.Presets.Add(preset); 195 | SavePresets(); 196 | } 197 | } 198 | } 199 | } 200 | 201 | private void presetTreeView_AfterSelect(object sender, TreeViewEventArgs e) 202 | { 203 | SelectedPresetChanged?.Invoke(this, new PresetSelectorEventArgs(SelectedPreset)); 204 | } 205 | 206 | private void presetTreeView_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) 207 | { 208 | if (GetSelectedNodeTag() != null) 209 | { 210 | keepPresetAppliedToolStripMenuItem_Click(this, new EventArgs()); 211 | } 212 | } 213 | 214 | private void keepPresetAppliedToolStripMenuItem_Click(object sender, EventArgs e) 215 | { 216 | var preset = GetSelectedNodeTag(); 217 | if (ActivePreset != preset) 218 | ActivePreset = preset; 219 | else 220 | ActivePreset = null; 221 | } 222 | 223 | private void presetContextMenu_Opening(object sender, CancelEventArgs e) 224 | { 225 | var preset = GetSelectedNodeTag(); 226 | keepPresetAppliedToolStripMenuItem.Checked = ActivePreset == preset; 227 | } 228 | 229 | private void savePresetToolStripMenuItem_Click(object sender, EventArgs e) 230 | { 231 | var preset = GetSelectedNodeTag(); 232 | if (preset != null) 233 | { 234 | if (MessageBox.Show("Are you sure you want to save over this preset?", "Save preset?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) 235 | { 236 | _capturePresetFunction(preset); 237 | SavePresets(); 238 | } 239 | } 240 | } 241 | 242 | private void deleteToolStripMenuItem_Click(object sender, EventArgs e) 243 | { 244 | var preset = GetSelectedNodeTag(); 245 | if (preset != null) 246 | { 247 | if (MessageBox.Show("Are you sure you want to save over this preset?", "Save preset?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) 248 | { 249 | SavePresets(); 250 | } 251 | } 252 | } 253 | } 254 | 255 | public class PresetSelectorEventArgs : EventArgs 256 | { 257 | public Preset Preset { get; set; } 258 | 259 | public PresetSelectorEventArgs(Preset preset) 260 | { 261 | Preset = preset; 262 | } 263 | } 264 | } 265 | -------------------------------------------------------------------------------- /CameraControlLib/Camera.cs: -------------------------------------------------------------------------------- 1 | using DirectShowLib; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Runtime.InteropServices.ComTypes; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace CameraControlLib 10 | { 11 | /// 12 | /// Provides access to the properties of a camera. 13 | /// 14 | /// 15 | /// To create a Camera, use Camera.GetAll() to enumerate the 16 | /// available video capture devices. This method returns a list of 17 | /// camera descriptors and calling the Create() method on the camera 18 | /// descriptor will instantiate the Camera device. 19 | /// 20 | /// The descriptors don't store any unmanaged resources and so don't need 21 | /// resource cleanup, but the Camera object should be disposed when 22 | /// finished with it. 23 | /// 24 | public class Camera : IDisposable 25 | { 26 | private DsDevice _device; 27 | private IBaseFilter _filter; 28 | private Dictionary _cameraProperties = new Dictionary(); 29 | 30 | public CameraProperty Focus { get { return Get("Focus"); } } 31 | public CameraProperty Exposure { get { return Get("Exposure"); } } 32 | public CameraProperty Zoom { get { return Get("Zoom"); } } 33 | public CameraProperty Pan { get { return Get("Pan"); } } 34 | public CameraProperty Tilt { get { return Get("Tilt"); } } 35 | public CameraProperty Roll { get { return Get("Roll"); } } 36 | public CameraProperty Iris { get { return Get("Iris"); } } 37 | 38 | public CameraProperty Brightness { get { return Get("Brightness"); } } 39 | public CameraProperty Contrast { get { return Get("Contrast"); } } 40 | public CameraProperty Hue { get { return Get("Hue"); } } 41 | public CameraProperty Saturation { get { return Get("Saturation"); } } 42 | public CameraProperty Sharpness { get { return Get("Sharpness"); } } 43 | public CameraProperty Gamma { get { return Get("Gamma"); } } 44 | public CameraProperty ColorEnable { get { return Get("ColorEnable"); } } 45 | public CameraProperty WhiteBalance { get { return Get("WhiteBalance"); } } 46 | public CameraProperty BacklightCompensation { get { return Get("BacklightCompensation"); } } 47 | public CameraProperty Gain { get { return Get("Gain"); } } 48 | 49 | internal IBaseFilter Filter { get { return _filter; } } 50 | 51 | internal Camera(DsDevice device) 52 | { 53 | _device = device; 54 | IFilterGraph2 graphBuilder = new FilterGraph() as IFilterGraph2; 55 | IMoniker i = _device.Mon as IMoniker; 56 | graphBuilder.AddSourceFilterForMoniker(i, null, _device.Name, out _filter); 57 | 58 | RegisterProperties(); 59 | } 60 | 61 | private readonly static List s_knownProperties = new List() 62 | { 63 | CamControlProperty.CreateDescriptor("Focus", "Focus", CameraControlProperty.Focus), 64 | CamControlProperty.CreateDescriptor("Exposure", "Exposure time", CameraControlProperty.Exposure), 65 | CamControlProperty.CreateDescriptor("Zoom", "Zoom", CameraControlProperty.Zoom), 66 | CamControlProperty.CreateDescriptor("Pan", "Pan", CameraControlProperty.Pan), 67 | CamControlProperty.CreateDescriptor("Tilt", "Tilt", CameraControlProperty.Tilt), 68 | CamControlProperty.CreateDescriptor("Roll", "Roll", CameraControlProperty.Roll), 69 | CamControlProperty.CreateDescriptor("Iris", "Iris", CameraControlProperty.Iris), 70 | 71 | VideoProcAmpCameraProperty.CreateDescriptor("Brightness", "Brightness", VideoProcAmpProperty.Brightness), 72 | VideoProcAmpCameraProperty.CreateDescriptor("Contrast", "Contrast", VideoProcAmpProperty.Contrast), 73 | VideoProcAmpCameraProperty.CreateDescriptor("Hue", "Hue", VideoProcAmpProperty.Hue), 74 | VideoProcAmpCameraProperty.CreateDescriptor("Saturation", "Saturation", VideoProcAmpProperty.Saturation), 75 | VideoProcAmpCameraProperty.CreateDescriptor("Sharpness", "Sharpness", VideoProcAmpProperty.Sharpness), 76 | VideoProcAmpCameraProperty.CreateDescriptor("Gamma", "Gamma", VideoProcAmpProperty.Gamma), 77 | VideoProcAmpCameraProperty.CreateDescriptor("ColorEnable", "Color Enable", VideoProcAmpProperty.ColorEnable), 78 | VideoProcAmpCameraProperty.CreateDescriptor("WhiteBalance", "White Balance", VideoProcAmpProperty.WhiteBalance), 79 | VideoProcAmpCameraProperty.CreateDescriptor("BacklightCompensation", "Backlight Compensation", VideoProcAmpProperty.BacklightCompensation), 80 | VideoProcAmpCameraProperty.CreateDescriptor("Gain", "Gain", VideoProcAmpProperty.Gain) 81 | }; 82 | 83 | public CameraProperty Get(string propertyId) 84 | { 85 | return _cameraProperties[propertyId]; 86 | } 87 | 88 | public static System.Collections.Generic.IReadOnlyList KnownProperties 89 | { 90 | get { return s_knownProperties.AsReadOnly(); } 91 | } 92 | 93 | private void RegisterProperties() 94 | { 95 | foreach (var descriptor in Camera.KnownProperties) 96 | { 97 | _cameraProperties[descriptor.Id] = descriptor.Create(this); 98 | } 99 | } 100 | 101 | /// 102 | /// Gets a list of all the available properties, even if the camera doesn't appear to support them. 103 | /// 104 | /// 105 | public List GetProperties() 106 | { 107 | return _cameraProperties.Values.ToList(); 108 | } 109 | 110 | /// 111 | /// Gets a list of the properties supported by this camera. 112 | /// 113 | /// 114 | public List GetSupportedProperties() 115 | { 116 | return _cameraProperties.Values.Where(p => p.Supported).ToList(); 117 | } 118 | 119 | /// 120 | /// Fetches updated 121 | /// 122 | public void Refresh() 123 | { 124 | foreach (var prop in _cameraProperties.Values) 125 | prop.Refresh(); 126 | } 127 | 128 | public void Save() 129 | { 130 | foreach (var prop in _cameraProperties.Values) 131 | prop.Save(); 132 | } 133 | 134 | public void ResetToDefault() 135 | { 136 | foreach (var prop in _cameraProperties.Values) 137 | prop.ResetToDefault(); 138 | } 139 | 140 | public static IList GetAll() 141 | { 142 | return CameraDescriptor.GetAll(); 143 | } 144 | 145 | #region IDisposable Support 146 | private bool _disposedValue = false; // To detect redundant calls 147 | 148 | protected virtual void Dispose(bool disposing) 149 | { 150 | if (!_disposedValue) 151 | { 152 | if (disposing) 153 | { 154 | // TODO: dispose managed state (managed objects). 155 | } 156 | _disposedValue = true; 157 | } 158 | } 159 | 160 | ~Camera() 161 | { 162 | // Do not change this code. Put cleanup code in Dispose(bool disposing) above. 163 | Dispose(false); 164 | } 165 | 166 | // This code added to correctly implement the disposable pattern. 167 | public void Dispose() 168 | { 169 | // Do not change this code. Put cleanup code in Dispose(bool disposing) above. 170 | Dispose(true); 171 | GC.SuppressFinalize(this); 172 | } 173 | #endregion 174 | } 175 | 176 | 177 | public interface ICameraDescriptor 178 | { 179 | string Name { get; } 180 | string DevicePath { get; } 181 | } 182 | 183 | 184 | /// 185 | /// Represents an available Camera device, but has no unmanaged resources associated 186 | /// 187 | public class CameraDescriptor : ICameraDescriptor 188 | { 189 | public string Name { get; private set; } 190 | public string DevicePath { get; private set; } 191 | 192 | private CameraDescriptor() { } 193 | 194 | public Camera Create() 195 | { 196 | DsDevice matchingDevice = null; 197 | DsDevice[] cameraDevices = null; 198 | try 199 | { 200 | cameraDevices = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice); 201 | var exactMatch = cameraDevices.FirstOrDefault(d => d.Name == Name && d.DevicePath == DevicePath); 202 | var nameMatch = cameraDevices.FirstOrDefault(d => d.Name == Name); 203 | matchingDevice = exactMatch ?? nameMatch; 204 | if (matchingDevice == null) 205 | throw new InvalidOperationException("Could not find selected camera device"); 206 | return new Camera(matchingDevice); 207 | } 208 | finally 209 | { 210 | DisposeDevices(cameraDevices, deviceToKeep: matchingDevice); 211 | } 212 | } 213 | 214 | public static List GetAll() 215 | { 216 | DsDevice[] cameraDevices = null; 217 | try 218 | { 219 | return DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice).Select(d => CameraDescriptor.FromDsDevice(d)).ToList(); 220 | } 221 | finally 222 | { 223 | DisposeDevices(cameraDevices); 224 | } 225 | } 226 | 227 | /// 228 | /// Attempts to find a camera by its name and device path. 229 | /// 230 | /// If both name and devicePath do not match, it will fall back to 231 | /// identifying the camera by name alone. 232 | /// 233 | /// The name of the camera 234 | /// The device path for the camera 235 | /// A matching camera descriptor, or null if the camera is not found 236 | public static CameraDescriptor Find(string name, string devicePath) 237 | { 238 | var cameraDescriptors = CameraDescriptor.GetAll(); 239 | var exactMatch = cameraDescriptors.FirstOrDefault(c => c.Name == name && c.DevicePath == devicePath); 240 | var nameMatch = cameraDescriptors.FirstOrDefault(c => c.Name == name); 241 | return exactMatch ?? nameMatch; 242 | } 243 | 244 | internal static CameraDescriptor FromDsDevice(DsDevice device) 245 | { 246 | return new CameraDescriptor() { Name = device.Name, DevicePath = device.DevicePath }; 247 | } 248 | 249 | private static void DisposeDevices(IEnumerable devices, DsDevice deviceToKeep = null) 250 | { 251 | if (devices != null) 252 | { 253 | foreach (var device in devices) 254 | if (device != null && device != deviceToKeep) 255 | device.Dispose(); 256 | } 257 | } 258 | } 259 | } 260 | -------------------------------------------------------------------------------- /CameraController/MainWindow.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace CameraController 2 | { 3 | partial class MainWindow 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.components = new System.ComponentModel.Container(); 32 | this.cameraUpdateTimer = new System.Windows.Forms.Timer(this.components); 33 | this.propertySliderPanel = new System.Windows.Forms.Panel(); 34 | this.mainMenuStrip = new System.Windows.Forms.MenuStrip(); 35 | this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 36 | this.selectCameraToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 37 | this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); 38 | this.resetToDefaultsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 39 | this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); 40 | this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 41 | this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 42 | this.alwaysOnTopToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 43 | this.optionsToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); 44 | this.splitContainer1 = new System.Windows.Forms.SplitContainer(); 45 | this.presetSelectorControl = new CameraController.PresetSelectorControl(); 46 | this.mainMenuStrip.SuspendLayout(); 47 | ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); 48 | this.splitContainer1.Panel1.SuspendLayout(); 49 | this.splitContainer1.Panel2.SuspendLayout(); 50 | this.splitContainer1.SuspendLayout(); 51 | this.SuspendLayout(); 52 | // 53 | // cameraUpdateTimer 54 | // 55 | this.cameraUpdateTimer.Enabled = true; 56 | this.cameraUpdateTimer.Interval = 250; 57 | this.cameraUpdateTimer.Tick += new System.EventHandler(this.cameraUpdateTimer_Tick); 58 | // 59 | // propertySliderPanel 60 | // 61 | this.propertySliderPanel.AutoScroll = true; 62 | this.propertySliderPanel.AutoScrollMinSize = new System.Drawing.Size(400, 200); 63 | this.propertySliderPanel.Dock = System.Windows.Forms.DockStyle.Fill; 64 | this.propertySliderPanel.Location = new System.Drawing.Point(0, 0); 65 | this.propertySliderPanel.Name = "propertySliderPanel"; 66 | this.propertySliderPanel.Size = new System.Drawing.Size(441, 337); 67 | this.propertySliderPanel.TabIndex = 2; 68 | // 69 | // mainMenuStrip 70 | // 71 | this.mainMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 72 | this.fileToolStripMenuItem, 73 | this.optionsToolStripMenuItem}); 74 | this.mainMenuStrip.Location = new System.Drawing.Point(0, 0); 75 | this.mainMenuStrip.Name = "mainMenuStrip"; 76 | this.mainMenuStrip.Size = new System.Drawing.Size(624, 24); 77 | this.mainMenuStrip.TabIndex = 3; 78 | this.mainMenuStrip.Text = "menuStrip1"; 79 | // 80 | // fileToolStripMenuItem 81 | // 82 | this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { 83 | this.selectCameraToolStripMenuItem, 84 | this.toolStripSeparator2, 85 | this.resetToDefaultsToolStripMenuItem, 86 | this.toolStripSeparator1, 87 | this.exitToolStripMenuItem}); 88 | this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; 89 | this.fileToolStripMenuItem.Size = new System.Drawing.Size(60, 20); 90 | this.fileToolStripMenuItem.Text = "Camera"; 91 | // 92 | // selectCameraToolStripMenuItem 93 | // 94 | this.selectCameraToolStripMenuItem.Name = "selectCameraToolStripMenuItem"; 95 | this.selectCameraToolStripMenuItem.Size = new System.Drawing.Size(161, 22); 96 | this.selectCameraToolStripMenuItem.Text = "Select Camera..."; 97 | this.selectCameraToolStripMenuItem.Click += new System.EventHandler(this.selectCameraToolStripMenuItem_Click); 98 | // 99 | // toolStripSeparator2 100 | // 101 | this.toolStripSeparator2.Name = "toolStripSeparator2"; 102 | this.toolStripSeparator2.Size = new System.Drawing.Size(158, 6); 103 | // 104 | // resetToDefaultsToolStripMenuItem 105 | // 106 | this.resetToDefaultsToolStripMenuItem.Name = "resetToDefaultsToolStripMenuItem"; 107 | this.resetToDefaultsToolStripMenuItem.Size = new System.Drawing.Size(161, 22); 108 | this.resetToDefaultsToolStripMenuItem.Text = "Reset to defaults"; 109 | this.resetToDefaultsToolStripMenuItem.Click += new System.EventHandler(this.resetToDefaultsToolStripMenuItem_Click); 110 | // 111 | // toolStripSeparator1 112 | // 113 | this.toolStripSeparator1.Name = "toolStripSeparator1"; 114 | this.toolStripSeparator1.Size = new System.Drawing.Size(158, 6); 115 | // 116 | // exitToolStripMenuItem 117 | // 118 | this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; 119 | this.exitToolStripMenuItem.Size = new System.Drawing.Size(161, 22); 120 | this.exitToolStripMenuItem.Text = "Exit"; 121 | this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); 122 | // 123 | // optionsToolStripMenuItem 124 | // 125 | this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { 126 | this.alwaysOnTopToolStripMenuItem, 127 | this.optionsToolStripMenuItem1}); 128 | this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem"; 129 | this.optionsToolStripMenuItem.Size = new System.Drawing.Size(47, 20); 130 | this.optionsToolStripMenuItem.Text = "Tools"; 131 | // 132 | // alwaysOnTopToolStripMenuItem 133 | // 134 | this.alwaysOnTopToolStripMenuItem.CheckOnClick = true; 135 | this.alwaysOnTopToolStripMenuItem.Name = "alwaysOnTopToolStripMenuItem"; 136 | this.alwaysOnTopToolStripMenuItem.Size = new System.Drawing.Size(149, 22); 137 | this.alwaysOnTopToolStripMenuItem.Text = "Always on top"; 138 | this.alwaysOnTopToolStripMenuItem.Click += new System.EventHandler(this.alwaysOnTopToolStripMenuItem_Click); 139 | // 140 | // optionsToolStripMenuItem1 141 | // 142 | this.optionsToolStripMenuItem1.Name = "optionsToolStripMenuItem1"; 143 | this.optionsToolStripMenuItem1.Size = new System.Drawing.Size(149, 22); 144 | this.optionsToolStripMenuItem1.Text = "Options..."; 145 | this.optionsToolStripMenuItem1.Click += new System.EventHandler(this.optionsToolStripMenuItem1_Click); 146 | // 147 | // splitContainer1 148 | // 149 | this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; 150 | this.splitContainer1.Location = new System.Drawing.Point(0, 24); 151 | this.splitContainer1.Name = "splitContainer1"; 152 | // 153 | // splitContainer1.Panel1 154 | // 155 | this.splitContainer1.Panel1.Controls.Add(this.propertySliderPanel); 156 | // 157 | // splitContainer1.Panel2 158 | // 159 | this.splitContainer1.Panel2.Controls.Add(this.presetSelectorControl); 160 | this.splitContainer1.Size = new System.Drawing.Size(624, 337); 161 | this.splitContainer1.SplitterDistance = 441; 162 | this.splitContainer1.TabIndex = 4; 163 | // 164 | // presetSelectorControl 165 | // 166 | this.presetSelectorControl.ActivePreset = null; 167 | this.presetSelectorControl.Dock = System.Windows.Forms.DockStyle.Fill; 168 | this.presetSelectorControl.Location = new System.Drawing.Point(0, 0); 169 | this.presetSelectorControl.Name = "presetSelectorControl"; 170 | this.presetSelectorControl.Settings = null; 171 | this.presetSelectorControl.Size = new System.Drawing.Size(179, 337); 172 | this.presetSelectorControl.TabIndex = 0; 173 | this.presetSelectorControl.ApplyPreset += new System.EventHandler(this.presetSelectorControl_ApplyPreset); 174 | this.presetSelectorControl.ActivePresetChanged += new System.EventHandler(this.presetSelectorControl_ActivePresetChanged); 175 | this.presetSelectorControl.SelectedPresetChanged += new System.EventHandler(this.presetSelectorControl_SelectedPresetChanged); 176 | // 177 | // MainWindow 178 | // 179 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 180 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 181 | this.ClientSize = new System.Drawing.Size(624, 361); 182 | this.Controls.Add(this.splitContainer1); 183 | this.Controls.Add(this.mainMenuStrip); 184 | this.MainMenuStrip = this.mainMenuStrip; 185 | this.MinimumSize = new System.Drawing.Size(640, 200); 186 | this.Name = "MainWindow"; 187 | this.RightToLeftLayout = true; 188 | this.Text = "Camera Controller"; 189 | this.mainMenuStrip.ResumeLayout(false); 190 | this.mainMenuStrip.PerformLayout(); 191 | this.splitContainer1.Panel1.ResumeLayout(false); 192 | this.splitContainer1.Panel2.ResumeLayout(false); 193 | ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); 194 | this.splitContainer1.ResumeLayout(false); 195 | this.ResumeLayout(false); 196 | this.PerformLayout(); 197 | 198 | } 199 | 200 | #endregion 201 | private System.Windows.Forms.Timer cameraUpdateTimer; 202 | private System.Windows.Forms.Panel propertySliderPanel; 203 | private System.Windows.Forms.MenuStrip mainMenuStrip; 204 | private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; 205 | private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; 206 | private System.Windows.Forms.ToolStripMenuItem optionsToolStripMenuItem; 207 | private System.Windows.Forms.ToolStripMenuItem alwaysOnTopToolStripMenuItem; 208 | private System.Windows.Forms.ToolStripMenuItem selectCameraToolStripMenuItem; 209 | private System.Windows.Forms.ToolStripMenuItem optionsToolStripMenuItem1; 210 | private System.Windows.Forms.SplitContainer splitContainer1; 211 | private PresetSelectorControl presetSelectorControl; 212 | private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; 213 | private System.Windows.Forms.ToolStripMenuItem resetToDefaultsToolStripMenuItem; 214 | private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; 215 | } 216 | } 217 | 218 | -------------------------------------------------------------------------------- /CameraController/PresetSelectorControl.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace CameraController 2 | { 3 | partial class PresetSelectorControl 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.components = new System.ComponentModel.Container(); 32 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PresetSelectorControl)); 33 | this.presetTreeView = new System.Windows.Forms.TreeView(); 34 | this.backgroundContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components); 35 | this.addGroupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 36 | this.presetStatusImages = new System.Windows.Forms.ImageList(this.components); 37 | this.presetContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components); 38 | this.applyPresetMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 39 | this.keepPresetAppliedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 40 | this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); 41 | this.savePresetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 42 | this.renameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 43 | this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 44 | this.groupContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components); 45 | this.addPresetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 46 | this.renameGroupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 47 | this.backgroundContextMenu.SuspendLayout(); 48 | this.presetContextMenu.SuspendLayout(); 49 | this.groupContextMenu.SuspendLayout(); 50 | this.SuspendLayout(); 51 | // 52 | // presetTreeView 53 | // 54 | this.presetTreeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 55 | | System.Windows.Forms.AnchorStyles.Left) 56 | | System.Windows.Forms.AnchorStyles.Right))); 57 | this.presetTreeView.ContextMenuStrip = this.backgroundContextMenu; 58 | this.presetTreeView.FullRowSelect = true; 59 | this.presetTreeView.HideSelection = false; 60 | this.presetTreeView.ImageIndex = 0; 61 | this.presetTreeView.ImageList = this.presetStatusImages; 62 | this.presetTreeView.Location = new System.Drawing.Point(3, 3); 63 | this.presetTreeView.Name = "presetTreeView"; 64 | this.presetTreeView.SelectedImageIndex = 0; 65 | this.presetTreeView.Size = new System.Drawing.Size(207, 287); 66 | this.presetTreeView.StateImageList = this.presetStatusImages; 67 | this.presetTreeView.TabIndex = 0; 68 | this.presetTreeView.AfterCollapse += new System.Windows.Forms.TreeViewEventHandler(this.presetTreeView_OnNodeInteraction); 69 | this.presetTreeView.AfterExpand += new System.Windows.Forms.TreeViewEventHandler(this.presetTreeView_OnNodeInteraction); 70 | this.presetTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.presetTreeView_AfterSelect); 71 | this.presetTreeView.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.presetTreeView_NodeMouseClick); 72 | this.presetTreeView.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.presetTreeView_NodeMouseDoubleClick); 73 | // 74 | // backgroundContextMenu 75 | // 76 | this.backgroundContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 77 | this.addGroupToolStripMenuItem}); 78 | this.backgroundContextMenu.Name = "backgroundContextMenu"; 79 | this.backgroundContextMenu.Size = new System.Drawing.Size(142, 26); 80 | // 81 | // addGroupToolStripMenuItem 82 | // 83 | this.addGroupToolStripMenuItem.Image = global::CameraController.Properties.Resources.NewGroup; 84 | this.addGroupToolStripMenuItem.Name = "addGroupToolStripMenuItem"; 85 | this.addGroupToolStripMenuItem.Size = new System.Drawing.Size(141, 22); 86 | this.addGroupToolStripMenuItem.Text = "Add Group..."; 87 | this.addGroupToolStripMenuItem.Click += new System.EventHandler(this.addGroupToolStripMenuItem_Click); 88 | // 89 | // presetStatusImages 90 | // 91 | this.presetStatusImages.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("presetStatusImages.ImageStream"))); 92 | this.presetStatusImages.TransparentColor = System.Drawing.Color.Transparent; 93 | this.presetStatusImages.Images.SetKeyName(0, "GroupClosed"); 94 | this.presetStatusImages.Images.SetKeyName(1, "GroupOpen"); 95 | this.presetStatusImages.Images.SetKeyName(2, "Preset"); 96 | this.presetStatusImages.Images.SetKeyName(3, "blank.png"); 97 | // 98 | // presetContextMenu 99 | // 100 | this.presetContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 101 | this.applyPresetMenuItem, 102 | this.keepPresetAppliedToolStripMenuItem, 103 | this.toolStripSeparator1, 104 | this.savePresetToolStripMenuItem, 105 | this.renameToolStripMenuItem, 106 | this.deleteToolStripMenuItem}); 107 | this.presetContextMenu.Name = "presetContextMenu"; 108 | this.presetContextMenu.Size = new System.Drawing.Size(188, 142); 109 | this.presetContextMenu.Opening += new System.ComponentModel.CancelEventHandler(this.presetContextMenu_Opening); 110 | // 111 | // applyPresetMenuItem 112 | // 113 | this.applyPresetMenuItem.Name = "applyPresetMenuItem"; 114 | this.applyPresetMenuItem.Size = new System.Drawing.Size(187, 22); 115 | this.applyPresetMenuItem.Text = "Apply Once"; 116 | this.applyPresetMenuItem.Click += new System.EventHandler(this.applyPresetMenuItem_Click); 117 | // 118 | // keepPresetAppliedToolStripMenuItem 119 | // 120 | this.keepPresetAppliedToolStripMenuItem.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold); 121 | this.keepPresetAppliedToolStripMenuItem.Name = "keepPresetAppliedToolStripMenuItem"; 122 | this.keepPresetAppliedToolStripMenuItem.Size = new System.Drawing.Size(187, 22); 123 | this.keepPresetAppliedToolStripMenuItem.Text = "Keep Preset Applied"; 124 | this.keepPresetAppliedToolStripMenuItem.Click += new System.EventHandler(this.keepPresetAppliedToolStripMenuItem_Click); 125 | // 126 | // toolStripSeparator1 127 | // 128 | this.toolStripSeparator1.Name = "toolStripSeparator1"; 129 | this.toolStripSeparator1.Size = new System.Drawing.Size(184, 6); 130 | // 131 | // savePresetToolStripMenuItem 132 | // 133 | this.savePresetToolStripMenuItem.Name = "savePresetToolStripMenuItem"; 134 | this.savePresetToolStripMenuItem.Size = new System.Drawing.Size(187, 22); 135 | this.savePresetToolStripMenuItem.Text = "Save Preset"; 136 | this.savePresetToolStripMenuItem.Click += new System.EventHandler(this.savePresetToolStripMenuItem_Click); 137 | // 138 | // renameToolStripMenuItem 139 | // 140 | this.renameToolStripMenuItem.Image = global::CameraController.Properties.Resources.Rename; 141 | this.renameToolStripMenuItem.Name = "renameToolStripMenuItem"; 142 | this.renameToolStripMenuItem.Size = new System.Drawing.Size(187, 22); 143 | this.renameToolStripMenuItem.Text = "Rename"; 144 | this.renameToolStripMenuItem.Click += new System.EventHandler(this.renameToolStripMenuItem_Click); 145 | // 146 | // deleteToolStripMenuItem 147 | // 148 | this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem"; 149 | this.deleteToolStripMenuItem.Size = new System.Drawing.Size(187, 22); 150 | this.deleteToolStripMenuItem.Text = "Delete"; 151 | this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click); 152 | // 153 | // groupContextMenu 154 | // 155 | this.groupContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 156 | this.addPresetToolStripMenuItem, 157 | this.renameGroupToolStripMenuItem}); 158 | this.groupContextMenu.Name = "groupContextMenu"; 159 | this.groupContextMenu.Size = new System.Drawing.Size(162, 48); 160 | // 161 | // addPresetToolStripMenuItem 162 | // 163 | this.addPresetToolStripMenuItem.Name = "addPresetToolStripMenuItem"; 164 | this.addPresetToolStripMenuItem.Size = new System.Drawing.Size(161, 22); 165 | this.addPresetToolStripMenuItem.Text = "Add Preset..."; 166 | this.addPresetToolStripMenuItem.Click += new System.EventHandler(this.addPresetToolStripMenuItem_Click); 167 | // 168 | // renameGroupToolStripMenuItem 169 | // 170 | this.renameGroupToolStripMenuItem.Image = global::CameraController.Properties.Resources.Rename; 171 | this.renameGroupToolStripMenuItem.Name = "renameGroupToolStripMenuItem"; 172 | this.renameGroupToolStripMenuItem.Size = new System.Drawing.Size(161, 22); 173 | this.renameGroupToolStripMenuItem.Text = "Rename group..."; 174 | this.renameGroupToolStripMenuItem.Click += new System.EventHandler(this.renameGroupToolStripMenuItem_Click); 175 | // 176 | // PresetSelectorControl 177 | // 178 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 179 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 180 | this.Controls.Add(this.presetTreeView); 181 | this.Name = "PresetSelectorControl"; 182 | this.Size = new System.Drawing.Size(213, 293); 183 | this.backgroundContextMenu.ResumeLayout(false); 184 | this.presetContextMenu.ResumeLayout(false); 185 | this.groupContextMenu.ResumeLayout(false); 186 | this.ResumeLayout(false); 187 | 188 | } 189 | 190 | #endregion 191 | 192 | private System.Windows.Forms.TreeView presetTreeView; 193 | private System.Windows.Forms.ImageList presetStatusImages; 194 | private System.Windows.Forms.ContextMenuStrip presetContextMenu; 195 | private System.Windows.Forms.ToolStripMenuItem applyPresetMenuItem; 196 | private System.Windows.Forms.ToolStripMenuItem savePresetToolStripMenuItem; 197 | private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem; 198 | private System.Windows.Forms.ContextMenuStrip groupContextMenu; 199 | private System.Windows.Forms.ToolStripMenuItem addPresetToolStripMenuItem; 200 | private System.Windows.Forms.ToolStripMenuItem renameGroupToolStripMenuItem; 201 | private System.Windows.Forms.ToolStripMenuItem renameToolStripMenuItem; 202 | private System.Windows.Forms.ContextMenuStrip backgroundContextMenu; 203 | private System.Windows.Forms.ToolStripMenuItem addGroupToolStripMenuItem; 204 | private System.Windows.Forms.ToolStripMenuItem keepPresetAppliedToolStripMenuItem; 205 | private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; 206 | } 207 | } 208 | --------------------------------------------------------------------------------