Changes recommended by Rider/Resharper

This commit is contained in:
2022-04-08 02:20:17 +02:00
parent 1a11a67248
commit 827f68b0c6
122 changed files with 1598 additions and 1201 deletions

1
.gitignore vendored
View File

@@ -4,5 +4,6 @@
*/bin/* */bin/*
*/obj/* */obj/*
*.csproj.user *.csproj.user
*.DotSettings.user
*.suo *.suo
.vs .vs

13
.idea/.idea.VAR.Toolbox/.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,13 @@
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/contentModel.xml
/.idea.VAR.Json.iml
/modules.xml
/projectSettingsUpdater.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@@ -0,0 +1,3 @@
<component name="ProjectDictionaryState">
<dictionary name="VAR" />
</component>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>

8
.idea/.idea.VAR.Toolbox/.idea/vcs.xml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/VAR.HttpServer" vcs="Git" />
<mapping directory="$PROJECT_DIR$/VAR.Json" vcs="Git" />
</component>
</project>

View File

@@ -10,8 +10,8 @@ namespace VAR.Toolbox.TestPlugin
InitializeComponent(); InitializeComponent();
} }
public string ToolName { get { return "Test"; } } public string ToolName => "Test";
public bool HasIcon { get { return false; } } public bool HasIcon => false;
} }
} }

View File

@@ -3,11 +3,12 @@
* Build as class library. * Build as class library.
* Add reference to ```VAR.Toolbox``` for interface declarations and utilities. * Add reference to ```VAR.Toolbox``` for interface declarations and utilities.
* Use the interfaces to extend functionality: * Use the interfaces to extend functionality:
* ```IToolForm```: Tool window. * ```IToolForm```: Tool window.
* ```IToolPanel```: Tool panels in the main window. Try to fit all on 200px width. * ```IToolPanel```: Tool panels in the main window. Try to fit all on 200px width.
* ```ITextCoder```: Text codification clases. * ```ITextCoder```: Text codification clases.
* ```IProxyCmdExecutor```: Proxy command executors, mainly for remote executions. * ```IProxyCmdExecutor```: Proxy command executors, mainly for remote executions.
## Usage ## Usage
Put the generated assembly near ```VAR.Toolbox.exe``` it will load as plug-ins any assembly that starts with ```VAR.Toolbox``` Put the generated assembly near ```VAR.Toolbox.exe``` it will load as plug-ins any assembly that starts
with ```VAR.Toolbox```

View File

@@ -32,4 +32,4 @@ using System.Runtime.InteropServices;
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -9,9 +9,10 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>VAR.Toolbox.TestPlugin</RootNamespace> <RootNamespace>VAR.Toolbox.TestPlugin</RootNamespace>
<AssemblyName>VAR.Toolbox.TestPlugin</AssemblyName> <AssemblyName>VAR.Toolbox.TestPlugin</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>

View File

@@ -0,0 +1,63 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_IFELSE/@EntryValue">NotRequired</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/TRAILING_COMMA_IN_MULTILINE_LISTS/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/TRAILING_COMMA_IN_SINGLELINE_LISTS/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/EMPTY_BLOCK_STYLE/@EntryValue">TOGETHER_SAME_LINE</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_EXISTING_EMBEDDED_BLOCK_ARRANGEMENT/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_EMBEDDED_BLOCK_ON_SAME_LINE/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_AFTER_TYPECAST_PARENTHESES/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_WITHIN_SINGLE_LINE_ARRAY_INITIALIZER_BRACES/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/HtmlFormatter/ALLOW_FAR_ALIGNMENT/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/HtmlFormatter/NormalizeTagNames/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/HtmlFormatter/ProcessingInstructionAttributeIndenting/@EntryValue">OneStep</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/HtmlFormatter/TagAttributeIndenting/@EntryValue">OneStep</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/HtmlFormatter/TagSpaceBeforeHeaderEnd1/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CSharpVarKeywordUsage/ForBuiltInTypes/@EntryValue">UseVarWhenEvident</s:String>
<s:String x:Key="/Default/CodeStyle/CSharpVarKeywordUsage/ForOtherTypes/@EntryValue">UseVarWhenEvident</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AES/@EntryIndexedValue">AES</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AM/@EntryIndexedValue">AM</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AUX/@EntryIndexedValue">AUX</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=BPP/@EntryIndexedValue">BPP</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DC/@EntryIndexedValue">DC</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DES/@EntryIndexedValue">DES</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=EPM/@EntryIndexedValue">EPM</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GDI/@EntryIndexedValue">GDI</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ID/@EntryIndexedValue">ID</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IP/@EntryIndexedValue">IP</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RECT/@EntryIndexedValue">RECT</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RGB/@EntryIndexedValue">RGB</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SCART/@EntryIndexedValue">SCART</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SPDIF/@EntryIndexedValue">SPDIF</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SQL/@EntryIndexedValue">SQL</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SRCCOPY/@EntryIndexedValue">SRCCOPY</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TCP/@EntryIndexedValue">TCP</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=URL/@EntryIndexedValue">URL</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=USB/@EntryIndexedValue">USB</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=VAR/@EntryIndexedValue">VAR</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=WMIC/@EntryIndexedValue">WMIC</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=YRYBY/@EntryIndexedValue">YRYBY</s:String>
<s:Boolean x:Key="/Default/CodeStyle/Naming/CSharpNaming/ApplyAutoDetectedRules/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Constants/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=EnumMember/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb"&gt;&lt;ExtraRule Prefix="T" Suffix="" Style="AaBb_AaBb" /&gt;&lt;/Policy&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Interfaces/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="I" Suffix="" Style="AaBb_AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=LocalConstants/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Locals/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb_AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Method/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Parameters/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb_AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateConstants/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb_AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb_AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb_AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Property/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PublicFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=StaticReadonly/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=TypesAndNamespaces/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /&gt;</s:String>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=bitblt/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Deserializa/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Screenshooter/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=tbps/@EntryIndexedValue">True</s:Boolean>
</wpf:ResourceDictionary>

View File

@@ -6,7 +6,8 @@ namespace VAR.Toolbox.Code
{ {
public abstract class BaseFactory<T> where T : INamed public abstract class BaseFactory<T> where T : INamed
{ {
private static Dictionary<string, Type> _dictTypes = null; // ReSharper disable once StaticMemberInGenericType
private static Dictionary<string, Type> _dictTypes;
private static Dictionary<string, Type> GetDict() private static Dictionary<string, Type> GetDict()
{ {
@@ -37,8 +38,10 @@ namespace VAR.Toolbox.Code
Dictionary<string, Type> dict = GetDict(); Dictionary<string, Type> dict = GetDict();
if (dict.ContainsKey(name) == false) if (dict.ContainsKey(name) == false)
{ {
throw new NotImplementedException(string.Format("Cant create {1} with this name: {0}", name, typeof(T).Name)); throw new NotImplementedException(string.Format("Cant create {1} with this name: {0}", name,
typeof(T).Name));
} }
Type type = dict[name]; Type type = dict[name];
T instance = (T)Activator.CreateInstance(type); T instance = (T)Activator.CreateInstance(type);
@@ -55,10 +58,13 @@ namespace VAR.Toolbox.Code
{ {
return (T)(object)null; return (T)(object)null;
} }
if (dict.ContainsKey(name) == false) if (dict.ContainsKey(name) == false)
{ {
throw new NotImplementedException(string.Format("Cant create {1} with this config: {0}", config, typeof(T).Name)); throw new NotImplementedException(string.Format("Cant create {1} with this config: {0}", config,
typeof(T).Name));
} }
Type type = dict[name]; Type type = dict[name];
T instance = (T)Activator.CreateInstance(type, new object[] { nextConfig }); T instance = (T)Activator.CreateInstance(type, new object[] { nextConfig });
@@ -70,4 +76,4 @@ namespace VAR.Toolbox.Code
{ {
string Name { get; } string Name { get; }
} }
} }

View File

@@ -11,26 +11,32 @@
/// Pan control. /// Pan control.
/// </summary> /// </summary>
Pan = 0, Pan = 0,
/// <summary> /// <summary>
/// Tilt control. /// Tilt control.
/// </summary> /// </summary>
Tilt, Tilt,
/// <summary> /// <summary>
/// Roll control. /// Roll control.
/// </summary> /// </summary>
Roll, Roll,
/// <summary> /// <summary>
/// Zoom control. /// Zoom control.
/// </summary> /// </summary>
Zoom, Zoom,
/// <summary> /// <summary>
/// Exposure control. /// Exposure control.
/// </summary> /// </summary>
Exposure, Exposure,
/// <summary> /// <summary>
/// Iris control. /// Iris control.
/// </summary> /// </summary>
Iris, Iris,
/// <summary> /// <summary>
/// Focus control. /// Focus control.
/// </summary> /// </summary>
@@ -47,13 +53,15 @@
/// No control flag. /// No control flag.
/// </summary> /// </summary>
None = 0x0, None = 0x0,
/// <summary> /// <summary>
/// Auto control Flag. /// Auto control Flag.
/// </summary> /// </summary>
Auto = 0x0001, Auto = 0x0001,
/// <summary> /// <summary>
/// Manual control Flag. /// Manual control Flag.
/// </summary> /// </summary>
Manual = 0x0002 Manual = 0x0002
} }
} }

View File

@@ -1,6 +1,5 @@
namespace VAR.Toolbox.Code.DirectShow namespace VAR.Toolbox.Code.DirectShow
{ {
using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
/// <summary> /// <summary>
@@ -8,15 +7,15 @@
/// or shutter speed. To obtain this interface, query the filter that controls the camera. /// or shutter speed. To obtain this interface, query the filter that controls the camera.
/// </summary> /// </summary>
[ComImport, [ComImport,
Guid("C6E13370-30AC-11d0-A18C-00A0C9118956"), Guid("C6E13370-30AC-11d0-A18C-00A0C9118956"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IAMCameraControl internal interface IAMCameraControl
{ {
/// <summary> /// <summary>
/// Gets the range and default value of a specified camera property. /// Gets the range and default value of a specified camera property.
/// </summary> /// </summary>
/// ///
/// <param name="Property">Specifies the property to query.</param> /// <param name="property">Specifies the property to query.</param>
/// <param name="pMin">Receives the minimum value of the property.</param> /// <param name="pMin">Receives the minimum value of the property.</param>
/// <param name="pMax">Receives the maximum value of the property.</param> /// <param name="pMax">Receives the maximum value of the property.</param>
/// <param name="pSteppingDelta">Receives the step size for the property.</param> /// <param name="pSteppingDelta">Receives the step size for the property.</param>
@@ -27,47 +26,47 @@
/// ///
[PreserveSig] [PreserveSig]
int GetRange( int GetRange(
[In] CameraControlProperty Property, [In] CameraControlProperty property,
[Out] out int pMin, [Out] out int pMin,
[Out] out int pMax, [Out] out int pMax,
[Out] out int pSteppingDelta, [Out] out int pSteppingDelta,
[Out] out int pDefault, [Out] out int pDefault,
[Out] out CameraControlFlags pCapsFlags [Out] out CameraControlFlags pCapsFlags
); );
/// <summary> /// <summary>
/// Sets a specified property on the camera. /// Sets a specified property on the camera.
/// </summary> /// </summary>
/// ///
/// <param name="Property">Specifies the property to set.</param> /// <param name="property">Specifies the property to set.</param>
/// <param name="lValue">Specifies the new value of the property.</param> /// <param name="lValue">Specifies the new value of the property.</param>
/// <param name="Flags">Specifies the desired control setting, as a member of the CameraControlFlags enumeration.</param> /// <param name="flags">Specifies the desired control setting, as a member of the CameraControlFlags enumeration.</param>
/// ///
/// <returns>Return's <b>HRESULT</b> error code.</returns> /// <returns>Return's <b>HRESULT</b> error code.</returns>
/// ///
[PreserveSig] [PreserveSig]
int Set( int Set(
[In] CameraControlProperty Property, [In] CameraControlProperty property,
[In] int lValue, [In] int lValue,
[In] CameraControlFlags Flags [In] CameraControlFlags flags
); );
/// <summary> /// <summary>
/// Gets the current setting of a camera property. /// Gets the current setting of a camera property.
/// </summary> /// </summary>
/// ///
/// <param name="Property">Specifies the property to retrieve.</param> /// <param name="property">Specifies the property to retrieve.</param>
/// <param name="lValue">Receives the value of the property.</param> /// <param name="lValue">Receives the value of the property.</param>
/// <param name="Flags">Receives a member of the CameraControlFlags enumeration. /// <param name="flags">Receives a member of the CameraControlFlags enumeration.
/// The returned value indicates whether the setting is controlled manually or automatically.</param> /// The returned value indicates whether the setting is controlled manually or automatically.</param>
/// ///
/// <returns>Return's <b>HRESULT</b> error code.</returns> /// <returns>Return's <b>HRESULT</b> error code.</returns>
/// ///
[PreserveSig] [PreserveSig]
int Get( int Get(
[In] CameraControlProperty Property, [In] CameraControlProperty property,
[Out] out int lValue, [Out] out int lValue,
[Out] out CameraControlFlags Flags [Out] out CameraControlFlags flags
); );
} }
} }

View File

@@ -1,6 +1,5 @@
#pragma warning disable IDE1006 #pragma warning disable IDE1006
using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace VAR.Toolbox.Code.DirectShow namespace VAR.Toolbox.Code.DirectShow
@@ -9,8 +8,8 @@ namespace VAR.Toolbox.Code.DirectShow
/// The IAMCrossbar interface routes signals from an analog or digital source to a video capture filter. /// The IAMCrossbar interface routes signals from an analog or digital source to a video capture filter.
/// </summary> /// </summary>
[ComImport, System.Security.SuppressUnmanagedCodeSecurity, [ComImport, System.Security.SuppressUnmanagedCodeSecurity,
Guid("C6E13380-30AC-11D0-A18C-00A0C9118956"), Guid("C6E13380-30AC-11D0-A18C-00A0C9118956"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IAMCrossbar internal interface IAMCrossbar
{ {
/// <summary> /// <summary>
@@ -79,4 +78,4 @@ namespace VAR.Toolbox.Code.DirectShow
[Out] out int pinIndexRelated, [Out] out int pinIndexRelated,
[Out] out PhysicalConnectorType physicalType); [Out] out PhysicalConnectorType physicalType);
} }
} }

View File

@@ -1,6 +1,5 @@
namespace VAR.Toolbox.Code.DirectShow namespace VAR.Toolbox.Code.DirectShow
{ {
using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
/// <summary> /// <summary>
@@ -9,8 +8,8 @@ namespace VAR.Toolbox.Code.DirectShow
/// </summary> /// </summary>
/// ///
[ComImport, [ComImport,
Guid("C6E13340-30AC-11d0-A18C-00A0C9118956"), Guid("C6E13340-30AC-11d0-A18C-00A0C9118956"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IAMStreamConfig internal interface IAMStreamConfig
{ {
/// <summary> /// <summary>
@@ -60,8 +59,10 @@ namespace VAR.Toolbox.Code.DirectShow
[PreserveSig] [PreserveSig]
int GetStreamCaps( int GetStreamCaps(
[In] int index, [In] int index,
[Out, MarshalAs(UnmanagedType.LPStruct)] out AMMediaType mediaType, [Out, MarshalAs(UnmanagedType.LPStruct)]
[In, MarshalAs(UnmanagedType.LPStruct)] VideoStreamConfigCaps streamConfigCaps out AMMediaType mediaType,
); [In, MarshalAs(UnmanagedType.LPStruct)]
VideoStreamConfigCaps streamConfigCaps
);
} }
} }

View File

@@ -9,8 +9,8 @@
/// </summary> /// </summary>
/// ///
[ComImport, [ComImport,
Guid("6A2E0670-28E4-11D0-A18c-00A0C9118956"), Guid("6A2E0670-28E4-11D0-A18c-00A0C9118956"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IAMVideoControl internal interface IAMVideoControl
{ {
/// <summary> /// <summary>
@@ -101,4 +101,4 @@
[Out] out int listSize, [Out] out int listSize,
[Out] out IntPtr frameRate); [Out] out IntPtr frameRate);
} }
} }

View File

@@ -9,8 +9,8 @@ namespace VAR.Toolbox.Code.DirectShow
/// </summary> /// </summary>
/// ///
[ComImport, [ComImport,
Guid("56A86895-0AD4-11CE-B03A-0020AF0BA770"), Guid("56A86895-0AD4-11CE-B03A-0020AF0BA770"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IBaseFilter internal interface IBaseFilter
{ {
// --- IPersist Methods // --- IPersist Methods
@@ -19,12 +19,12 @@ namespace VAR.Toolbox.Code.DirectShow
/// Returns the class identifier (CLSID) for the component object. /// Returns the class identifier (CLSID) for the component object.
/// </summary> /// </summary>
/// ///
/// <param name="ClassID">Points to the location of the CLSID on return.</param> /// <param name="classID">Points to the location of the CLSID on return.</param>
/// ///
/// <returns>Return's <b>HRESULT</b> error code.</returns> /// <returns>Return's <b>HRESULT</b> error code.</returns>
/// ///
[PreserveSig] [PreserveSig]
int GetClassID([Out] out Guid ClassID); int GetClassID([Out] out Guid classID);
// --- IMediaFilter Methods // --- IMediaFilter Methods
@@ -151,4 +151,4 @@ namespace VAR.Toolbox.Code.DirectShow
[PreserveSig] [PreserveSig]
int QueryVendorInfo([Out, MarshalAs(UnmanagedType.LPWStr)] out string vendorInfo); int QueryVendorInfo([Out, MarshalAs(UnmanagedType.LPWStr)] out string vendorInfo);
} }
} }

View File

@@ -1,3 +1,5 @@
// ReSharper disable IdentifierTypo
namespace VAR.Toolbox.Code.DirectShow namespace VAR.Toolbox.Code.DirectShow
{ {
using System; using System;
@@ -8,8 +10,8 @@ namespace VAR.Toolbox.Code.DirectShow
/// </summary> /// </summary>
/// ///
[ComImport, [ComImport,
Guid("93E5A4E0-2D50-11d2-ABFA-00A0C9C6E38D"), Guid("93E5A4E0-2D50-11d2-ABFA-00A0C9C6E38D"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface ICaptureGraphBuilder2 internal interface ICaptureGraphBuilder2
{ {
/// <summary> /// <summary>
@@ -48,14 +50,15 @@ namespace VAR.Toolbox.Code.DirectShow
/// ///
[PreserveSig] [PreserveSig]
int SetOutputFileName( int SetOutputFileName(
[In, MarshalAs(UnmanagedType.LPStruct)] Guid type, [In, MarshalAs(UnmanagedType.LPStruct)]
Guid type,
[In, MarshalAs(UnmanagedType.LPWStr)] string fileName, [In, MarshalAs(UnmanagedType.LPWStr)] string fileName,
[Out] out IBaseFilter baseFilter, [Out] out IBaseFilter baseFilter,
[Out] out IntPtr fileSinkFilter [Out] out IntPtr fileSinkFilter
); );
/// <summary> /// <summary>
/// Searche the graph for a specified interface, starting from a specified filter. /// Search the graph for a specified interface, starting from a specified filter.
/// </summary> /// </summary>
/// ///
/// <param name="category">GUID that specifies the search criteria.</param> /// <param name="category">GUID that specifies the search criteria.</param>
@@ -68,12 +71,16 @@ namespace VAR.Toolbox.Code.DirectShow
/// ///
[PreserveSig] [PreserveSig]
int FindInterface( int FindInterface(
[In, MarshalAs(UnmanagedType.LPStruct)] Guid category, [In, MarshalAs(UnmanagedType.LPStruct)]
[In, MarshalAs(UnmanagedType.LPStruct)] Guid type, Guid category,
[In, MarshalAs(UnmanagedType.LPStruct)]
Guid type,
[In] IBaseFilter baseFilter, [In] IBaseFilter baseFilter,
[In, MarshalAs(UnmanagedType.LPStruct)] Guid interfaceID, [In, MarshalAs(UnmanagedType.LPStruct)]
[Out, MarshalAs(UnmanagedType.IUnknown)] out object retInterface Guid interfaceID,
); [Out, MarshalAs(UnmanagedType.IUnknown)]
out object retInterface
);
/// <summary> /// <summary>
/// Connect an output pin on a source filter to a rendering filter, optionally through a compression filter. /// Connect an output pin on a source filter to a rendering filter, optionally through a compression filter.
@@ -89,12 +96,15 @@ namespace VAR.Toolbox.Code.DirectShow
/// ///
[PreserveSig] [PreserveSig]
int RenderStream( int RenderStream(
[In, MarshalAs(UnmanagedType.LPStruct)] Guid category, [In, MarshalAs(UnmanagedType.LPStruct)]
[In, MarshalAs(UnmanagedType.LPStruct)] Guid mediaType, Guid category,
[In, MarshalAs(UnmanagedType.IUnknown)] object source, [In, MarshalAs(UnmanagedType.LPStruct)]
Guid mediaType,
[In, MarshalAs(UnmanagedType.IUnknown)]
object source,
[In] IBaseFilter compressor, [In] IBaseFilter compressor,
[In] IBaseFilter renderer [In] IBaseFilter renderer
); );
/// <summary> /// <summary>
/// Set the start and stop times for one or more streams of captured data. /// Set the start and stop times for one or more streams of captured data.
@@ -114,14 +124,17 @@ namespace VAR.Toolbox.Code.DirectShow
/// ///
[PreserveSig] [PreserveSig]
int ControlStream( int ControlStream(
[In, MarshalAs(UnmanagedType.LPStruct)] Guid category, [In, MarshalAs(UnmanagedType.LPStruct)]
[In, MarshalAs(UnmanagedType.LPStruct)] Guid mediaType, Guid category,
[In, MarshalAs(UnmanagedType.Interface)] IBaseFilter filter, [In, MarshalAs(UnmanagedType.LPStruct)]
Guid mediaType,
[In, MarshalAs(UnmanagedType.Interface)]
IBaseFilter filter,
[In] long start, [In] long start,
[In] long stop, [In] long stop,
[In] short startCookie, [In] short startCookie,
[In] short stopCookie [In] short stopCookie
); );
/// <summary> /// <summary>
/// Preallocate a capture file to a specified size. /// Preallocate a capture file to a specified size.
@@ -136,7 +149,7 @@ namespace VAR.Toolbox.Code.DirectShow
int AllocCapFile( int AllocCapFile(
[In, MarshalAs(UnmanagedType.LPWStr)] string fileName, [In, MarshalAs(UnmanagedType.LPWStr)] string fileName,
[In] long size [In] long size
); );
/// <summary> /// <summary>
/// Copy the valid media data from a capture file. /// Copy the valid media data from a capture file.
@@ -155,7 +168,7 @@ namespace VAR.Toolbox.Code.DirectShow
[In, MarshalAs(UnmanagedType.LPWStr)] string newFileName, [In, MarshalAs(UnmanagedType.LPWStr)] string newFileName,
[In, MarshalAs(UnmanagedType.Bool)] bool allowEscAbort, [In, MarshalAs(UnmanagedType.Bool)] bool allowEscAbort,
[In] IntPtr callback [In] IntPtr callback
); );
/// <summary> /// <summary>
/// ///
@@ -173,13 +186,17 @@ namespace VAR.Toolbox.Code.DirectShow
/// ///
[PreserveSig] [PreserveSig]
int FindPin( int FindPin(
[In, MarshalAs(UnmanagedType.IUnknown)] object source, [In, MarshalAs(UnmanagedType.IUnknown)]
object source,
[In] PinDirection pinDirection, [In] PinDirection pinDirection,
[In, MarshalAs(UnmanagedType.LPStruct)] Guid category, [In, MarshalAs(UnmanagedType.LPStruct)]
[In, MarshalAs(UnmanagedType.LPStruct)] Guid mediaType, Guid category,
[In, MarshalAs(UnmanagedType.LPStruct)]
Guid mediaType,
[In, MarshalAs(UnmanagedType.Bool)] bool unconnected, [In, MarshalAs(UnmanagedType.Bool)] bool unconnected,
[In] int index, [In] int index,
[Out, MarshalAs(UnmanagedType.Interface)] out IPin pin [Out, MarshalAs(UnmanagedType.Interface)]
); out IPin pin
);
} }
} }

View File

@@ -10,8 +10,8 @@ namespace VAR.Toolbox.Code.DirectShow
/// </summary> /// </summary>
/// ///
[ComImport, [ComImport,
Guid("29840822-5B84-11D0-BD3B-00A0C911CE86"), Guid("29840822-5B84-11D0-BD3B-00A0C911CE86"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface ICreateDevEnum internal interface ICreateDevEnum
{ {
/// <summary> /// <summary>
@@ -27,4 +27,4 @@ namespace VAR.Toolbox.Code.DirectShow
[PreserveSig] [PreserveSig]
int CreateClassEnumerator([In] ref Guid type, [Out] out IEnumMoniker enumMoniker, [In] int flags); int CreateClassEnumerator([In] ref Guid type, [Out] out IEnumMoniker enumMoniker, [In] int flags);
} }
} }

View File

@@ -1,6 +1,5 @@
namespace VAR.Toolbox.Code.DirectShow namespace VAR.Toolbox.Code.DirectShow
{ {
using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
/// <summary> /// <summary>
@@ -9,8 +8,8 @@ namespace VAR.Toolbox.Code.DirectShow
/// </summary> /// </summary>
/// ///
[ComImport, [ComImport,
Guid("56A86893-0AD4-11CE-B03A-0020AF0BA770"), Guid("56A86893-0AD4-11CE-B03A-0020AF0BA770"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IEnumFilters internal interface IEnumFilters
{ {
/// <summary> /// <summary>
@@ -25,7 +24,8 @@ namespace VAR.Toolbox.Code.DirectShow
/// ///
[PreserveSig] [PreserveSig]
int Next([In] int cFilters, int Next([In] int cFilters,
[Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] IBaseFilter[] filters, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)]
IBaseFilter[] filters,
[Out] out int filtersFetched); [Out] out int filtersFetched);
/// <summary> /// <summary>
@@ -61,4 +61,4 @@ namespace VAR.Toolbox.Code.DirectShow
[PreserveSig] [PreserveSig]
int Clone([Out] out IEnumFilters enumFilters); int Clone([Out] out IEnumFilters enumFilters);
} }
} }

View File

@@ -1,6 +1,5 @@
namespace VAR.Toolbox.Code.DirectShow namespace VAR.Toolbox.Code.DirectShow
{ {
using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
/// <summary> /// <summary>
@@ -8,8 +7,8 @@ namespace VAR.Toolbox.Code.DirectShow
/// </summary> /// </summary>
/// ///
[ComImport, [ComImport,
Guid("56A86892-0AD4-11CE-B03A-0020AF0BA770"), Guid("56A86892-0AD4-11CE-B03A-0020AF0BA770"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IEnumPins internal interface IEnumPins
{ {
/// <summary> /// <summary>
@@ -24,7 +23,8 @@ namespace VAR.Toolbox.Code.DirectShow
/// ///
[PreserveSig] [PreserveSig]
int Next([In] int cPins, int Next([In] int cPins,
[Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] IPin[] pins, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)]
IPin[] pins,
[Out] out int pinsFetched); [Out] out int pinsFetched);
/// <summary> /// <summary>
@@ -58,4 +58,4 @@ namespace VAR.Toolbox.Code.DirectShow
[PreserveSig] [PreserveSig]
int Clone([Out] out IEnumPins enumPins); int Clone([Out] out IEnumPins enumPins);
} }
} }

View File

@@ -1,6 +1,5 @@
namespace VAR.Toolbox.Code.DirectShow namespace VAR.Toolbox.Code.DirectShow
{ {
using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
/// <summary> /// <summary>
@@ -8,8 +7,8 @@ namespace VAR.Toolbox.Code.DirectShow
/// </summary> /// </summary>
/// ///
[ComImport, [ComImport,
Guid("56A868A6-0Ad4-11CE-B03A-0020AF0BA770"), Guid("56A868A6-0Ad4-11CE-B03A-0020AF0BA770"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IFileSourceFilter internal interface IFileSourceFilter
{ {
/// <summary> /// <summary>
@@ -23,7 +22,8 @@ namespace VAR.Toolbox.Code.DirectShow
/// ///
[PreserveSig] [PreserveSig]
int Load([In, MarshalAs(UnmanagedType.LPWStr)] string fileName, int Load([In, MarshalAs(UnmanagedType.LPWStr)] string fileName,
[In, MarshalAs(UnmanagedType.LPStruct)] AMMediaType mediaType); [In, MarshalAs(UnmanagedType.LPStruct)]
AMMediaType mediaType);
/// <summary> /// <summary>
/// Retrieves the current file. /// Retrieves the current file.
@@ -36,6 +36,7 @@ namespace VAR.Toolbox.Code.DirectShow
/// ///
[PreserveSig] [PreserveSig]
int GetCurFile([Out, MarshalAs(UnmanagedType.LPWStr)] out string fileName, int GetCurFile([Out, MarshalAs(UnmanagedType.LPWStr)] out string fileName,
[Out, MarshalAs(UnmanagedType.LPStruct)] AMMediaType mediaType); [Out, MarshalAs(UnmanagedType.LPStruct)]
AMMediaType mediaType);
} }
} }

View File

@@ -9,8 +9,8 @@ namespace VAR.Toolbox.Code.DirectShow
/// </summary> /// </summary>
/// ///
[ComImport, [ComImport,
Guid("56A8689F-0AD4-11CE-B03A-0020AF0BA770"), Guid("56A8689F-0AD4-11CE-B03A-0020AF0BA770"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IFilterGraph internal interface IFilterGraph
{ {
/// <summary> /// <summary>
@@ -70,7 +70,9 @@ namespace VAR.Toolbox.Code.DirectShow
/// <returns>Return's <b>HRESULT</b> error code.</returns> /// <returns>Return's <b>HRESULT</b> error code.</returns>
/// ///
[PreserveSig] [PreserveSig]
int ConnectDirect([In] IPin pinOut, [In] IPin pinIn, [In, MarshalAs(UnmanagedType.LPStruct)] AMMediaType mediaType); int ConnectDirect([In] IPin pinOut, [In] IPin pinIn,
[In, MarshalAs(UnmanagedType.LPStruct)]
AMMediaType mediaType);
/// <summary> /// <summary>
/// Breaks the existing pin connection and reconnects it to the same pin. /// Breaks the existing pin connection and reconnects it to the same pin.
@@ -103,4 +105,4 @@ namespace VAR.Toolbox.Code.DirectShow
[PreserveSig] [PreserveSig]
int SetDefaultSyncSource(); int SetDefaultSyncSource();
} }
} }

View File

@@ -10,8 +10,8 @@ namespace VAR.Toolbox.Code.DirectShow
/// </summary> /// </summary>
/// ///
[ComImport, [ComImport,
Guid("36B73882-C2C8-11CF-8B46-00805F6CEF60"), Guid("36B73882-C2C8-11CF-8B46-00805F6CEF60"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IFilterGraph2 internal interface IFilterGraph2
{ {
// --- IFilterGraph Methods // --- IFilterGraph Methods
@@ -73,7 +73,9 @@ namespace VAR.Toolbox.Code.DirectShow
/// <returns>Return's <b>HRESULT</b> error code.</returns> /// <returns>Return's <b>HRESULT</b> error code.</returns>
/// ///
[PreserveSig] [PreserveSig]
int ConnectDirect([In] IPin pinOut, [In] IPin pinIn, [In, MarshalAs(UnmanagedType.LPStruct)] AMMediaType mediaType); int ConnectDirect([In] IPin pinOut, [In] IPin pinIn,
[In, MarshalAs(UnmanagedType.LPStruct)]
AMMediaType mediaType);
/// <summary> /// <summary>
/// Breaks the existing pin connection and reconnects it to the same pin. /// Breaks the existing pin connection and reconnects it to the same pin.
@@ -226,8 +228,9 @@ namespace VAR.Toolbox.Code.DirectShow
[PreserveSig] [PreserveSig]
int ReconnectEx( int ReconnectEx(
[In] IPin pin, [In] IPin pin,
[In, MarshalAs(UnmanagedType.LPStruct)] AMMediaType mediaType [In, MarshalAs(UnmanagedType.LPStruct)]
); AMMediaType mediaType
);
/// <summary> /// <summary>
/// Render an output pin, with an option to use existing renderers only. /// Render an output pin, with an option to use existing renderers only.
@@ -244,7 +247,6 @@ namespace VAR.Toolbox.Code.DirectShow
[In] IPin outputPin, [In] IPin outputPin,
[In] int flags, [In] int flags,
[In] IntPtr context [In] IntPtr context
); );
} }
} }

View File

@@ -8,8 +8,8 @@ namespace VAR.Toolbox.Code.DirectShow
/// </summary> /// </summary>
/// ///
[ComImport, [ComImport,
Guid("56A868A9-0AD4-11CE-B03A-0020AF0BA770"), Guid("56A868A9-0AD4-11CE-B03A-0020AF0BA770"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IGraphBuilder internal interface IGraphBuilder
{ {
// --- IFilterGraph Methods // --- IFilterGraph Methods
@@ -71,7 +71,9 @@ namespace VAR.Toolbox.Code.DirectShow
/// <returns>Return's <b>HRESULT</b> error code.</returns> /// <returns>Return's <b>HRESULT</b> error code.</returns>
/// ///
[PreserveSig] [PreserveSig]
int ConnectDirect([In] IPin pinOut, [In] IPin pinIn, [In, MarshalAs(UnmanagedType.LPStruct)] AMMediaType mediaType); int ConnectDirect([In] IPin pinOut, [In] IPin pinIn,
[In, MarshalAs(UnmanagedType.LPStruct)]
AMMediaType mediaType);
/// <summary> /// <summary>
/// Breaks the existing pin connection and reconnects it to the same pin. /// Breaks the existing pin connection and reconnects it to the same pin.
@@ -188,4 +190,4 @@ namespace VAR.Toolbox.Code.DirectShow
[PreserveSig] [PreserveSig]
int ShouldOperationContinue(); int ShouldOperationContinue();
} }
} }

View File

@@ -1,6 +1,5 @@
#pragma warning disable IDE1006 #pragma warning disable IDE1006
using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace VAR.Toolbox.Code.DirectShow namespace VAR.Toolbox.Code.DirectShow
@@ -11,8 +10,8 @@ namespace VAR.Toolbox.Code.DirectShow
/// </summary> /// </summary>
/// ///
[ComImport, [ComImport,
Guid("56A868B1-0AD4-11CE-B03A-0020AF0BA770"), Guid("56A868B1-0AD4-11CE-B03A-0020AF0BA770"),
InterfaceType(ComInterfaceType.InterfaceIsDual)] InterfaceType(ComInterfaceType.InterfaceIsDual)]
internal interface IMediaControl internal interface IMediaControl
{ {
/// <summary> /// <summary>
@@ -47,7 +46,7 @@ namespace VAR.Toolbox.Code.DirectShow
/// </summary> /// </summary>
/// ///
/// <param name="timeout">Duration of the time-out, in milliseconds, or INFINITE to specify an infinite time-out.</param> /// <param name="timeout">Duration of the time-out, in milliseconds, or INFINITE to specify an infinite time-out.</param>
/// <param name="filterState">Ìariable that receives a member of the <b>FILTER_STATE</b> enumeration.</param> /// <param name="filterState">Variable that receives a member of the <b>FILTER_STATE</b> enumeration.</param>
/// ///
/// <returns>Return's <b>HRESULT</b> error code.</returns> /// <returns>Return's <b>HRESULT</b> error code.</returns>
/// ///
@@ -87,7 +86,8 @@ namespace VAR.Toolbox.Code.DirectShow
/// ///
[PreserveSig] [PreserveSig]
int get_FilterCollection( int get_FilterCollection(
[Out, MarshalAs(UnmanagedType.IDispatch)] out object collection); [Out, MarshalAs(UnmanagedType.IDispatch)]
out object collection);
/// <summary> /// <summary>
/// Retrieves a collection of all the filters listed in the registry. /// Retrieves a collection of all the filters listed in the registry.
@@ -99,7 +99,8 @@ namespace VAR.Toolbox.Code.DirectShow
/// ///
[PreserveSig] [PreserveSig]
int get_RegFilterCollection( int get_RegFilterCollection(
[Out, MarshalAs(UnmanagedType.IDispatch)] out object collection); [Out, MarshalAs(UnmanagedType.IDispatch)]
out object collection);
/// <summary> /// <summary>
/// Pauses the filter graph, allowing filters to queue data, and then stops the filter graph. /// Pauses the filter graph, allowing filters to queue data, and then stops the filter graph.
@@ -110,4 +111,4 @@ namespace VAR.Toolbox.Code.DirectShow
[PreserveSig] [PreserveSig]
int StopWhenReady(); int StopWhenReady();
} }
} }

View File

@@ -8,8 +8,8 @@
/// filter graph's default handling of events. /// filter graph's default handling of events.
/// </summary> /// </summary>
[ComVisible(true), ComImport, [ComVisible(true), ComImport,
Guid("56a868c0-0ad4-11ce-b03a-0020af0ba770"), Guid("56a868c0-0ad4-11ce-b03a-0020af0ba770"),
InterfaceType(ComInterfaceType.InterfaceIsDual)] InterfaceType(ComInterfaceType.InterfaceIsDual)]
internal interface IMediaEventEx internal interface IMediaEventEx
{ {
/// <summary> /// <summary>
@@ -34,7 +34,8 @@
/// <returns>Return's <b>HRESULT</b> error code.</returns> /// <returns>Return's <b>HRESULT</b> error code.</returns>
/// ///
[PreserveSig] [PreserveSig]
int GetEvent([Out, MarshalAs(UnmanagedType.I4)] out DsEvCode lEventCode, [Out] out IntPtr lParam1, [Out] out IntPtr lParam2, int msTimeout); int GetEvent([Out, MarshalAs(UnmanagedType.I4)] out DsEvCode lEventCode, [Out] out IntPtr lParam1,
[Out] out IntPtr lParam2, int msTimeout);
/// <summary> /// <summary>
/// Waits for the filter graph to render all available data. /// Waits for the filter graph to render all available data.
@@ -85,14 +86,14 @@
/// Registers a window to process event notifications. /// Registers a window to process event notifications.
/// </summary> /// </summary>
/// ///
/// <param name="hwnd">Handle to the window, or <see cref="IntPtr.Zero"/> to stop receiving event messages.</param> /// <param name="hWnd">Handle to the window, or <see cref="IntPtr.Zero"/> to stop receiving event messages.</param>
/// <param name="lMsg">Window message to be passed as the notification.</param> /// <param name="lMsg">Window message to be passed as the notification.</param>
/// <param name="lInstanceData">Value to be passed as the <i>lParam</i> parameter for the <i>lMsg</i> message.</param> /// <param name="lInstanceData">Value to be passed as the <i>lParam</i> parameter for the <i>lMsg</i> message.</param>
/// ///
/// <returns>Return's <b>HRESULT</b> error code.</returns> /// <returns>Return's <b>HRESULT</b> error code.</returns>
/// ///
[PreserveSig] [PreserveSig]
int SetNotifyWindow(IntPtr hwnd, int lMsg, IntPtr lInstanceData); int SetNotifyWindow(IntPtr hWnd, int lMsg, IntPtr lInstanceData);
/// <summary> /// <summary>
/// Enables or disables event notifications. /// Enables or disables event notifications.
@@ -116,4 +117,4 @@
[PreserveSig] [PreserveSig]
int GetNotifyFlags(out int lplNoNotifyFlags); int GetNotifyFlags(out int lplNoNotifyFlags);
} }
} }

View File

@@ -1,3 +1,5 @@
// ReSharper disable IdentifierTypo
namespace VAR.Toolbox.Code.DirectShow namespace VAR.Toolbox.Code.DirectShow
{ {
using System; using System;
@@ -9,8 +11,8 @@ namespace VAR.Toolbox.Code.DirectShow
/// </summary> /// </summary>
/// ///
[ComImport, System.Security.SuppressUnmanagedCodeSecurity, [ComImport, System.Security.SuppressUnmanagedCodeSecurity,
Guid("56a86899-0ad4-11ce-b03a-0020af0ba770"), Guid("56a86899-0ad4-11ce-b03a-0020af0ba770"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IMediaFilter : IPersist internal interface IMediaFilter : IPersist
{ {
#region IPersist Methods #region IPersist Methods
@@ -87,5 +89,4 @@ namespace VAR.Toolbox.Code.DirectShow
[PreserveSig] [PreserveSig]
int GetSyncSource([Out] out IReferenceClock pClock); int GetSyncSource([Out] out IReferenceClock pClock);
} }
} }

View File

@@ -8,8 +8,8 @@ namespace VAR.Toolbox.Code.DirectShow
/// handler to use in the client process, as it is used in the default implementation of marshaling. /// handler to use in the client process, as it is used in the default implementation of marshaling.
/// </summary> /// </summary>
[ComImport, [ComImport,
Guid("0000010c-0000-0000-C000-000000000046"), Guid("0000010c-0000-0000-C000-000000000046"),
InterfaceType(ComInterfaceType.InterfaceIsDual)] InterfaceType(ComInterfaceType.InterfaceIsDual)]
internal interface IPersist internal interface IPersist
{ {
/// <summary> /// <summary>
@@ -20,4 +20,4 @@ namespace VAR.Toolbox.Code.DirectShow
[PreserveSig] [PreserveSig]
int GetClassID([Out] out Guid pClassID); int GetClassID([Out] out Guid pClassID);
} }
} }

View File

@@ -8,8 +8,8 @@ namespace VAR.Toolbox.Code.DirectShow
/// </summary> /// </summary>
/// ///
[ComImport, [ComImport,
Guid("56A86891-0AD4-11CE-B03A-0020AF0BA770"), Guid("56A86891-0AD4-11CE-B03A-0020AF0BA770"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IPin internal interface IPin
{ {
/// <summary> /// <summary>
@@ -181,4 +181,4 @@ namespace VAR.Toolbox.Code.DirectShow
long stop, long stop,
double rate); double rate);
} }
} }

View File

@@ -9,8 +9,8 @@ namespace VAR.Toolbox.Code.DirectShow
/// </summary> /// </summary>
/// ///
[ComImport, [ComImport,
Guid("55272A00-42CB-11CE-8135-00AA004BB851"), Guid("55272A00-42CB-11CE-8135-00AA004BB851"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IPropertyBag internal interface IPropertyBag
{ {
/// <summary> /// <summary>
@@ -26,7 +26,8 @@ namespace VAR.Toolbox.Code.DirectShow
[PreserveSig] [PreserveSig]
int Read( int Read(
[In, MarshalAs(UnmanagedType.LPWStr)] string propertyName, [In, MarshalAs(UnmanagedType.LPWStr)] string propertyName,
[In, Out, MarshalAs(UnmanagedType.Struct)] ref object pVar, [In, Out, MarshalAs(UnmanagedType.Struct)]
ref object pVar,
[In] IntPtr pErrorLog); [In] IntPtr pErrorLog);
/// <summary> /// <summary>
@@ -43,4 +44,4 @@ namespace VAR.Toolbox.Code.DirectShow
[In, MarshalAs(UnmanagedType.LPWStr)] string propertyName, [In, MarshalAs(UnmanagedType.LPWStr)] string propertyName,
[In, MarshalAs(UnmanagedType.Struct)] ref object pVar); [In, MarshalAs(UnmanagedType.Struct)] ref object pVar);
} }
} }

View File

@@ -1,3 +1,6 @@
// ReSharper disable CommentTypo
// ReSharper disable IdentifierTypo
namespace VAR.Toolbox.Code.DirectShow namespace VAR.Toolbox.Code.DirectShow
{ {
using System; using System;
@@ -11,8 +14,8 @@ namespace VAR.Toolbox.Code.DirectShow
/// retrieve the current reference time, or to request notification of an elapsed time. /// retrieve the current reference time, or to request notification of an elapsed time.
/// </summary> /// </summary>
[ComImport, System.Security.SuppressUnmanagedCodeSecurity, [ComImport, System.Security.SuppressUnmanagedCodeSecurity,
Guid("56a86897-0ad4-11ce-b03a-0020af0ba770"), Guid("56a86897-0ad4-11ce-b03a-0020af0ba770"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IReferenceClock internal interface IReferenceClock
{ {
/// <summary> /// <summary>
@@ -73,4 +76,4 @@ namespace VAR.Toolbox.Code.DirectShow
[PreserveSig] [PreserveSig]
int Unadvise([In] int dwAdviseCookie); int Unadvise([In] int dwAdviseCookie);
} }
} }

View File

@@ -9,8 +9,8 @@ namespace VAR.Toolbox.Code.DirectShow
/// </summary> /// </summary>
/// ///
[ComImport, [ComImport,
Guid("6B652FFF-11FE-4FCE-92AD-0266B5D7C78F"), Guid("6B652FFF-11FE-4FCE-92AD-0266B5D7C78F"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface ISampleGrabber internal interface ISampleGrabber
{ {
/// <summary> /// <summary>
@@ -93,4 +93,4 @@ namespace VAR.Toolbox.Code.DirectShow
[PreserveSig] [PreserveSig]
int SetCallback(ISampleGrabberCB callback, int whichMethodToCallback); int SetCallback(ISampleGrabberCB callback, int whichMethodToCallback);
} }
} }

View File

@@ -8,8 +8,8 @@ namespace VAR.Toolbox.Code.DirectShow
/// </summary> /// </summary>
/// ///
[ComImport, [ComImport,
Guid("0579154A-2B53-4994-B0D0-E773148EFF85"), Guid("0579154A-2B53-4994-B0D0-E773148EFF85"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface ISampleGrabberCB internal interface ISampleGrabberCB
{ {
/// <summary> /// <summary>
@@ -25,7 +25,7 @@ namespace VAR.Toolbox.Code.DirectShow
int SampleCB(double sampleTime, IntPtr sample); int SampleCB(double sampleTime, IntPtr sample);
/// <summary> /// <summary>
/// Callback method that receives a pointer to the sample bufferþ /// Callback method that receives a pointer to the sample buffer
/// </summary> /// </summary>
/// ///
/// <param name="sampleTime">Starting time of the sample, in seconds.</param> /// <param name="sampleTime">Starting time of the sample, in seconds.</param>
@@ -37,4 +37,4 @@ namespace VAR.Toolbox.Code.DirectShow
[PreserveSig] [PreserveSig]
int BufferCB(double sampleTime, IntPtr buffer, int bufferLen); int BufferCB(double sampleTime, IntPtr buffer, int bufferLen);
} }
} }

View File

@@ -1,6 +1,7 @@
// ReSharper disable CommentTypo
namespace VAR.Toolbox.Code.DirectShow namespace VAR.Toolbox.Code.DirectShow
{ {
using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
/// <summary> /// <summary>
@@ -8,8 +9,8 @@ namespace VAR.Toolbox.Code.DirectShow
/// </summary> /// </summary>
/// ///
[ComImport, [ComImport,
Guid("B196B28B-BAB4-101A-B69C-00AA00341D07"), Guid("B196B28B-BAB4-101A-B69C-00AA00341D07"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface ISpecifyPropertyPages internal interface ISpecifyPropertyPages
{ {
/// <summary> /// <summary>
@@ -26,4 +27,4 @@ namespace VAR.Toolbox.Code.DirectShow
[PreserveSig] [PreserveSig]
int GetPages(out CAUUID pPages); int GetPages(out CAUUID pPages);
} }
} }

View File

@@ -10,8 +10,8 @@ namespace VAR.Toolbox.Code.DirectShow
/// </summary> /// </summary>
/// ///
[ComImport, [ComImport,
Guid("56A868B4-0AD4-11CE-B03A-0020AF0BA770"), Guid("56A868B4-0AD4-11CE-B03A-0020AF0BA770"),
InterfaceType(ComInterfaceType.InterfaceIsDual)] InterfaceType(ComInterfaceType.InterfaceIsDual)]
internal interface IVideoWindow internal interface IVideoWindow
{ {
/// <summary> /// <summary>
@@ -95,7 +95,7 @@ namespace VAR.Toolbox.Code.DirectShow
/// Queries whether the video renderer automatically shows the video window when it receives video data. /// Queries whether the video renderer automatically shows the video window when it receives video data.
/// </summary> /// </summary>
/// ///
/// <param name="autoShow">REceives window auto show flag.</param> /// <param name="autoShow">Receives window auto show flag.</param>
/// ///
/// <returns>Return's <b>HRESULT</b> error code.</returns> /// <returns>Return's <b>HRESULT</b> error code.</returns>
/// ///
@@ -257,7 +257,7 @@ namespace VAR.Toolbox.Code.DirectShow
int get_Height(out int height); int get_Height(out int height);
/// <summary> /// <summary>
/// Specifies a parent window for the video windowþ /// Specifies a parent window for the video window
/// </summary> /// </summary>
/// ///
/// <param name="owner">Specifies a handle to the parent window.</param> /// <param name="owner">Specifies a handle to the parent window.</param>
@@ -268,7 +268,7 @@ namespace VAR.Toolbox.Code.DirectShow
int put_Owner(IntPtr owner); int put_Owner(IntPtr owner);
/// <summary> /// <summary>
/// Retrieves the video window's parent window, if anyþ /// Retrieves the video window's parent window, if any
/// </summary> /// </summary>
/// ///
/// <param name="owner">Parent window's handle.</param> /// <param name="owner">Parent window's handle.</param>
@@ -360,7 +360,7 @@ namespace VAR.Toolbox.Code.DirectShow
/// Forwards a message to the video window. /// Forwards a message to the video window.
/// </summary> /// </summary>
/// ///
/// <param name="hwnd">Handle to the window.</param> /// <param name="hWnd">Handle to the window.</param>
/// <param name="msg">Specifies the message.</param> /// <param name="msg">Specifies the message.</param>
/// <param name="wParam">Message parameter.</param> /// <param name="wParam">Message parameter.</param>
/// <param name="lParam">Message parameter.</param> /// <param name="lParam">Message parameter.</param>
@@ -368,10 +368,10 @@ namespace VAR.Toolbox.Code.DirectShow
/// <returns>Return's <b>HRESULT</b> error code.</returns> /// <returns>Return's <b>HRESULT</b> error code.</returns>
/// ///
[PreserveSig] [PreserveSig]
int NotifyOwnerMessage(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam); int NotifyOwnerMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
/// <summary> /// <summary>
/// Sets the position of the video windowþ /// Sets the position of the video window
/// </summary> /// </summary>
/// ///
/// <param name="left">Specifies the x-coordinate, in pixels.</param> /// <param name="left">Specifies the x-coordinate, in pixels.</param>
@@ -458,4 +458,4 @@ namespace VAR.Toolbox.Code.DirectShow
[PreserveSig] [PreserveSig]
int IsCursorHidden([Out, MarshalAs(UnmanagedType.Bool)] out bool hideCursor); int IsCursorHidden([Out, MarshalAs(UnmanagedType.Bool)] out bool hideCursor);
} }
} }

View File

@@ -1,4 +1,6 @@
namespace VAR.Toolbox.Code.DirectShow // ReSharper disable CommentTypo
namespace VAR.Toolbox.Code.DirectShow
{ {
/// <summary> /// <summary>
/// Specifies the physical type of pin (audio or video). /// Specifies the physical type of pin (audio or video).
@@ -10,62 +12,77 @@
/// connection type should not be changed (input) or was not determined (output). /// connection type should not be changed (input) or was not determined (output).
/// </summary> /// </summary>
Default = 0, Default = 0,
/// <summary> /// <summary>
/// Specifies a tuner pin for video. /// Specifies a tuner pin for video.
/// </summary> /// </summary>
VideoTuner = 1, VideoTuner = 1,
/// <summary> /// <summary>
/// Specifies a composite pin for video. /// Specifies a composite pin for video.
/// </summary> /// </summary>
VideoComposite, VideoComposite,
/// <summary> /// <summary>
/// Specifies an S-Video (Y/C video) pin. /// Specifies an S-Video (Y/C video) pin.
/// </summary> /// </summary>
VideoSVideo, VideoSVideo,
/// <summary> /// <summary>
/// Specifies an RGB pin for video. /// Specifies an RGB pin for video.
/// </summary> /// </summary>
VideoRGB, VideoRGB,
/// <summary> /// <summary>
/// Specifies a YRYBY (Y, RY, BY) pin for video. /// Specifies a YRYBY (Y, RY, BY) pin for video.
/// </summary> /// </summary>
VideoYRYBY, VideoYRYBY,
/// <summary> /// <summary>
/// Specifies a serial digital pin for video. /// Specifies a serial digital pin for video.
/// </summary> /// </summary>
VideoSerialDigital, VideoSerialDigital,
/// <summary> /// <summary>
/// Specifies a parallel digital pin for video. /// Specifies a parallel digital pin for video.
/// </summary> /// </summary>
VideoParallelDigital, VideoParallelDigital,
/// <summary> /// <summary>
/// Specifies a SCSI (Small Computer System Interface) pin for video. /// Specifies a SCSI (Small Computer System Interface) pin for video.
/// </summary> /// </summary>
VideoSCSI, VideoSCSI,
/// <summary> /// <summary>
/// Specifies an AUX (auxiliary) pin for video. /// Specifies an AUX (auxiliary) pin for video.
/// </summary> /// </summary>
VideoAUX, VideoAUX,
/// <summary> /// <summary>
/// Specifies an IEEE 1394 pin for video. /// Specifies an IEEE 1394 pin for video.
/// </summary> /// </summary>
Video1394, Video1394,
/// <summary> /// <summary>
/// Specifies a USB (Universal Serial Bus) pin for video. /// Specifies a USB (Universal Serial Bus) pin for video.
/// </summary> /// </summary>
VideoUSB, VideoUSB,
/// <summary> /// <summary>
/// Specifies a video decoder pin. /// Specifies a video decoder pin.
/// </summary> /// </summary>
VideoDecoder, VideoDecoder,
/// <summary> /// <summary>
/// Specifies a video encoder pin. /// Specifies a video encoder pin.
/// </summary> /// </summary>
VideoEncoder, VideoEncoder,
/// <summary> /// <summary>
/// Specifies a SCART (Peritel) pin for video. /// Specifies a SCART (Peritel) pin for video.
/// </summary> /// </summary>
VideoSCART, VideoSCART,
/// <summary> /// <summary>
/// Not used. /// Not used.
/// </summary> /// </summary>
@@ -75,41 +92,50 @@
/// Specifies a tuner pin for audio. /// Specifies a tuner pin for audio.
/// </summary> /// </summary>
AudioTuner = 4096, AudioTuner = 4096,
/// <summary> /// <summary>
/// Specifies a line pin for audio. /// Specifies a line pin for audio.
/// </summary> /// </summary>
AudioLine, AudioLine,
/// <summary> /// <summary>
/// Specifies a microphone pin. /// Specifies a microphone pin.
/// </summary> /// </summary>
AudioMic, AudioMic,
/// <summary> /// <summary>
/// Specifies an AES/EBU (Audio Engineering Society/European Broadcast Union) digital pin for audio. /// Specifies an AES/EBU (Audio Engineering Society/European Broadcast Union) digital pin for audio.
/// </summary> /// </summary>
AudioAESDigital, AudioAESDigital,
/// <summary> /// <summary>
/// Specifies an S/PDIF (Sony/Philips Digital Interface Format) digital pin for audio. /// Specifies an S/PDIF (Sony/Philips Digital Interface Format) digital pin for audio.
/// </summary> /// </summary>
AudioSPDIFDigital, AudioSPDIFDigital,
/// <summary> /// <summary>
/// Specifies a SCSI pin for audio. /// Specifies a SCSI pin for audio.
/// </summary> /// </summary>
AudioSCSI, AudioSCSI,
/// <summary> /// <summary>
/// Specifies an AUX pin for audio. /// Specifies an AUX pin for audio.
/// </summary> /// </summary>
AudioAUX, AudioAUX,
/// <summary> /// <summary>
/// Specifies an IEEE 1394 pin for audio. /// Specifies an IEEE 1394 pin for audio.
/// </summary> /// </summary>
Audio1394, Audio1394,
/// <summary> /// <summary>
/// Specifies a USB pin for audio. /// Specifies a USB pin for audio.
/// </summary> /// </summary>
AudioUSB, AudioUSB,
/// <summary> /// <summary>
/// Specifies an audio decoder pin. /// Specifies an audio decoder pin.
/// </summary> /// </summary>
AudioDecoder AudioDecoder
} }
} }

View File

@@ -1,3 +1,7 @@
// ReSharper disable IdentifierTypo
// ReSharper disable CommentTypo
// ReSharper disable InconsistentNaming
namespace VAR.Toolbox.Code.DirectShow namespace VAR.Toolbox.Code.DirectShow
{ {
using System; using System;
@@ -31,7 +35,7 @@ namespace VAR.Toolbox.Code.DirectShow
/// </summary> /// </summary>
/// ///
[ComVisible(false), [ComVisible(false),
StructLayout(LayoutKind.Sequential)] StructLayout(LayoutKind.Sequential)]
internal class AMMediaType : IDisposable internal class AMMediaType : IDisposable
{ {
/// <summary> /// <summary>
@@ -47,14 +51,12 @@ namespace VAR.Toolbox.Code.DirectShow
/// <summary> /// <summary>
/// If <b>true</b>, samples are of a fixed size. /// If <b>true</b>, samples are of a fixed size.
/// </summary> /// </summary>
[MarshalAs(UnmanagedType.Bool)] [MarshalAs(UnmanagedType.Bool)] public bool FixedSizeSamples = true;
public bool FixedSizeSamples = true;
/// <summary> /// <summary>
/// If <b>true</b>, samples are compressed using temporal (interframe) compression. /// If <b>true</b>, samples are compressed using temporal (interframe) compression.
/// </summary> /// </summary>
[MarshalAs(UnmanagedType.Bool)] [MarshalAs(UnmanagedType.Bool)] public bool TemporalCompression;
public bool TemporalCompression;
/// <summary> /// <summary>
/// Size of the sample in bytes. For compressed data, the value can be zero. /// Size of the sample in bytes. For compressed data, the value can be zero.
@@ -131,7 +133,7 @@ namespace VAR.Toolbox.Code.DirectShow
/// </summary> /// </summary>
/// ///
[ComVisible(false), [ComVisible(false),
StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)] StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
internal struct PinInfo internal struct PinInfo
{ {
/// <summary> /// <summary>
@@ -153,7 +155,7 @@ namespace VAR.Toolbox.Code.DirectShow
// FILTER_INFO // FILTER_INFO
[ComVisible(false), [ComVisible(false),
StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)] StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
internal struct FilterInfo internal struct FilterInfo
{ {
/// <summary> /// <summary>
@@ -175,7 +177,7 @@ namespace VAR.Toolbox.Code.DirectShow
/// </summary> /// </summary>
/// ///
[ComVisible(false), [ComVisible(false),
StructLayout(LayoutKind.Sequential)] StructLayout(LayoutKind.Sequential)]
internal struct VideoInfoHeader internal struct VideoInfoHeader
{ {
/// <summary> /// <summary>
@@ -216,7 +218,7 @@ namespace VAR.Toolbox.Code.DirectShow
/// </summary> /// </summary>
/// ///
[ComVisible(false), [ComVisible(false),
StructLayout(LayoutKind.Sequential)] StructLayout(LayoutKind.Sequential)]
internal struct VideoInfoHeader2 internal struct VideoInfoHeader2
{ {
/// <summary> /// <summary>
@@ -285,7 +287,7 @@ namespace VAR.Toolbox.Code.DirectShow
/// </summary> /// </summary>
/// ///
[ComVisible(false), [ComVisible(false),
StructLayout(LayoutKind.Sequential, Pack = 2)] StructLayout(LayoutKind.Sequential, Pack = 2)]
internal struct BitmapInfoHeader internal struct BitmapInfoHeader
{ {
/// <summary> /// <summary>
@@ -351,7 +353,7 @@ namespace VAR.Toolbox.Code.DirectShow
/// </summary> /// </summary>
/// ///
[ComVisible(false), [ComVisible(false),
StructLayout(LayoutKind.Sequential)] StructLayout(LayoutKind.Sequential)]
internal struct RECT internal struct RECT
{ {
/// <summary> /// <summary>
@@ -382,7 +384,7 @@ namespace VAR.Toolbox.Code.DirectShow
/// </summary> /// </summary>
/// ///
[ComVisible(false), [ComVisible(false),
StructLayout(LayoutKind.Sequential)] StructLayout(LayoutKind.Sequential)]
internal struct CAUUID internal struct CAUUID
{ {
/// <summary> /// <summary>
@@ -421,17 +423,18 @@ namespace VAR.Toolbox.Code.DirectShow
internal enum DsEvCode internal enum DsEvCode
{ {
None, None,
Complete = 0x01, // EC_COMPLETE Complete = 0x01, // EC_COMPLETE
DeviceLost = 0x1F, // EC_DEVICE_LOST DeviceLost = 0x1F, // EC_DEVICE_LOST
//(...) not yet interested in other events //(...) not yet interested in other events
} }
[Flags, ComVisible(false)] [Flags, ComVisible(false)]
internal enum AnalogVideoStandard internal enum AnalogVideoStandard
{ {
None = 0x00000000, // This is a digital sensor // ReSharper disable InconsistentNaming
NTSC_M = 0x00000001, // 75 IRE Setup None = 0x00000000, // This is a digital sensor
NTSC_M_J = 0x00000002, // Japan, 0 IRE Setup NTSC_M = 0x00000001, // 75 IRE Setup
NTSC_M_J = 0x00000002, // Japan, 0 IRE Setup
NTSC_433 = 0x00000004, NTSC_433 = 0x00000004,
PAL_B = 0x00000010, PAL_B = 0x00000010,
PAL_D = 0x00000020, PAL_D = 0x00000020,
@@ -449,7 +452,9 @@ namespace VAR.Toolbox.Code.DirectShow
SECAM_K1 = 0x00020000, SECAM_K1 = 0x00020000,
SECAM_L = 0x00040000, SECAM_L = 0x00040000,
SECAM_L1 = 0x00080000, SECAM_L1 = 0x00080000,
PAL_N_COMBO = 0x00100000 // Argentina
PAL_N_COMBO = 0x00100000 // Argentina
// ReSharper restore InconsistentNaming
} }
[Flags, ComVisible(false)] [Flags, ComVisible(false)]
@@ -462,7 +467,7 @@ namespace VAR.Toolbox.Code.DirectShow
} }
[StructLayout(LayoutKind.Sequential), ComVisible(false)] [StructLayout(LayoutKind.Sequential), ComVisible(false)]
internal class VideoStreamConfigCaps // VIDEO_STREAM_CONFIG_CAPS internal class VideoStreamConfigCaps // VIDEO_STREAM_CONFIG_CAPS
{ {
public Guid Guid; public Guid Guid;
public AnalogVideoStandard VideoStandard; public AnalogVideoStandard VideoStandard;
@@ -507,4 +512,4 @@ namespace VAR.Toolbox.Code.DirectShow
/// </summary> /// </summary>
State_Running State_Running
} }
} }

View File

@@ -20,24 +20,20 @@ namespace VAR.Toolbox.Code.DirectShow
/// ///
/// <returns>Returns filter's pin.</returns> /// <returns>Returns filter's pin.</returns>
/// ///
public static IPin GetPin(IBaseFilter filter, PinDirection dir, int num) private static IPin GetPin(IBaseFilter filter, PinDirection dir, int num)
{ {
IPin[] pin = new IPin[1]; IPin[] pin = new IPin[1];
IEnumPins pinsEnum = null;
// enum filter pins // enum filter pins
if (filter.EnumPins(out pinsEnum) == 0) if (filter.EnumPins(out IEnumPins pinsEnum) == 0)
{ {
PinDirection pinDir;
int n;
try try
{ {
// get next pin // get next pin
while (pinsEnum.Next(1, pin, out n) == 0) while (pinsEnum.Next(1, pin, out int _) == 0)
{ {
// query pin`s direction // query pin`s direction
pin[0].QueryDirection(out pinDir); pin[0].QueryDirection(out PinDirection pinDir);
if (pinDir == dir) if (pinDir == dir)
{ {
@@ -55,6 +51,7 @@ namespace VAR.Toolbox.Code.DirectShow
Marshal.ReleaseComObject(pinsEnum); Marshal.ReleaseComObject(pinsEnum);
} }
} }
return null; return null;
} }
@@ -86,4 +83,4 @@ namespace VAR.Toolbox.Code.DirectShow
return GetPin(filter, PinDirection.Output, num); return GetPin(filter, PinDirection.Output, num);
} }
} }
} }

View File

@@ -1,3 +1,8 @@
// ReSharper disable CommentTypo
// ReSharper disable IdentifierTypo
// ReSharper disable InconsistentNaming
namespace VAR.Toolbox.Code.DirectShow namespace VAR.Toolbox.Code.DirectShow
{ {
using System; using System;
@@ -7,7 +12,7 @@ namespace VAR.Toolbox.Code.DirectShow
/// DirectShow class IDs. /// DirectShow class IDs.
/// </summary> /// </summary>
[ComVisible(false)] [ComVisible(false)]
static internal class Clsid internal static class Clsid
{ {
/// <summary> /// <summary>
/// System device enumerator. /// System device enumerator.
@@ -57,7 +62,6 @@ namespace VAR.Toolbox.Code.DirectShow
public static readonly Guid NullRenderer = public static readonly Guid NullRenderer =
new Guid(0xC1F400A4, 0x3F08, 0x11d3, 0x9F, 0x0B, 0x00, 0x60, 0x08, 0x03, 0x9E, 0x37); new Guid(0xC1F400A4, 0x3F08, 0x11d3, 0x9F, 0x0B, 0x00, 0x60, 0x08, 0x03, 0x9E, 0x37);
} }
/// <summary> /// <summary>
@@ -65,7 +69,7 @@ namespace VAR.Toolbox.Code.DirectShow
/// </summary> /// </summary>
/// ///
[ComVisible(false)] [ComVisible(false)]
static internal class FormatType internal static class FormatType
{ {
/// <summary> /// <summary>
/// VideoInfo. /// VideoInfo.
@@ -91,7 +95,7 @@ namespace VAR.Toolbox.Code.DirectShow
/// </summary> /// </summary>
/// ///
[ComVisible(false)] [ComVisible(false)]
static internal class MediaType internal static class MediaType
{ {
/// <summary> /// <summary>
/// Video. /// Video.
@@ -144,7 +148,7 @@ namespace VAR.Toolbox.Code.DirectShow
/// </summary> /// </summary>
/// ///
[ComVisible(false)] [ComVisible(false)]
static internal class MediaSubType internal static class MediaSubType
{ {
/// <summary> /// <summary>
/// YUY2 (packed 4:2:2). /// YUY2 (packed 4:2:2).
@@ -260,7 +264,7 @@ namespace VAR.Toolbox.Code.DirectShow
/// </summary> /// </summary>
/// ///
[ComVisible(false)] [ComVisible(false)]
static internal class PinCategory internal static class PinCategory
{ {
/// <summary> /// <summary>
/// Capture pin. /// Capture pin.
@@ -279,7 +283,6 @@ namespace VAR.Toolbox.Code.DirectShow
/// ///
public static readonly Guid Preview = public static readonly Guid Preview =
new Guid(0xfb6c4282, 0x0353, 0x11d1, 0x90, 0x5f, 0x00, 0x00, 0xc0, 0xcc, 0x16, 0xba); new Guid(0xfb6c4282, 0x0353, 0x11d1, 0x90, 0x5f, 0x00, 0x00, 0xc0, 0xcc, 0x16, 0xba);
} }
/// <summary> /// <summary>
@@ -324,4 +327,4 @@ namespace VAR.Toolbox.Code.DirectShow
public static readonly Guid AudioCompressorCategory = public static readonly Guid AudioCompressorCategory =
new Guid(0x33D9A761, 0x90C8, 0x11D0, 0xBD, 0x43, 0x00, 0xA0, 0xC9, 0x11, 0xCE, 0x86); new Guid(0x33D9A761, 0x90C8, 0x11D0, 0xBD, 0x43, 0x00, 0xA0, 0xC9, 0x11, 0xCE, 0x86);
} }
} }

View File

@@ -5,7 +5,7 @@ namespace VAR.Toolbox.Code
{ {
public static class EventDispatcher public static class EventDispatcher
{ {
private static List<IEventListener> _eventListeners = null; private static List<IEventListener> _eventListeners;
private static IEnumerable<IEventListener> GetEventListeners() private static IEnumerable<IEventListener> GetEventListeners()
{ {
@@ -19,8 +19,7 @@ namespace VAR.Toolbox.Code
_eventListeners = new List<IEventListener>(); _eventListeners = new List<IEventListener>();
foreach (Type eventListener in eventListeners) foreach (Type eventListener in eventListeners)
{ {
IEventListener eventListenerInstance = Activator.CreateInstance(eventListener) as IEventListener; if (Activator.CreateInstance(eventListener) is IEventListener eventListenerInstance)
if (eventListenerInstance != null)
{ {
_eventListeners.Add(eventListenerInstance); _eventListeners.Add(eventListenerInstance);
} }
@@ -37,6 +36,5 @@ namespace VAR.Toolbox.Code
eventListener.ProcessEvent(eventName, eventData); eventListener.ProcessEvent(eventName, eventData);
} }
} }
} }
} }

View File

@@ -7,13 +7,16 @@ namespace VAR.Toolbox.Code
{ {
public static byte[] HexStringToBytes(string input) public static byte[] HexStringToBytes(string input)
{ {
int[] hexValues = new int[] { int[] hexValues = new int[]
{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
};
if (input.Length % 2 == 1) if (input.Length % 2 == 1)
{ {
throw new Exception("Unenven number of hex digits"); throw new Exception("Uneven number of hex digits");
} }
byte[] bytes = new byte[input.Length / 2]; byte[] bytes = new byte[input.Length / 2];
int count = input.Length; int count = input.Length;
for (int x = 0, i = 0; i < count; i += 2, x += 1) for (int x = 0, i = 0; i < count; i += 2, x += 1)
@@ -21,7 +24,7 @@ namespace VAR.Toolbox.Code
bytes[x] = (byte)( bytes[x] = (byte)(
hexValues[Char.ToUpper(input[i + 0]) - '0'] << 4 | hexValues[Char.ToUpper(input[i + 0]) - '0'] << 4 |
hexValues[Char.ToUpper(input[i + 1]) - '0'] hexValues[Char.ToUpper(input[i + 1]) - '0']
); );
} }
return bytes; return bytes;
@@ -38,7 +41,8 @@ namespace VAR.Toolbox.Code
sbOutput.Append(HexAlphabet[(b >> 4)]); sbOutput.Append(HexAlphabet[(b >> 4)]);
sbOutput.Append(HexAlphabet[(b & 0xF)]); sbOutput.Append(HexAlphabet[(b & 0xF)]);
} }
return sbOutput.ToString(); return sbOutput.ToString();
} }
} }
} }

View File

@@ -1,13 +1,7 @@
using System; namespace VAR.Toolbox.Code
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VAR.Toolbox.Code
{ {
public interface IEventListener public interface IEventListener
{ {
void ProcessEvent(string eventName, object eventData); void ProcessEvent(string eventName, object eventData);
} }
} }

View File

@@ -4,4 +4,4 @@
{ {
void OutputLine(string line); void OutputLine(string line);
} }
} }

View File

@@ -6,19 +6,18 @@ namespace VAR.Toolbox.Code
public class Logger public class Logger
{ {
/// <summary> /// <summary>
/// Obtiene el StreamWritter de salida /// Obtiene el StreamWriter de salida
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
private static StreamWriter GetOutputStreamWritter() private static StreamWriter GetOutputStreamWriter()
{ {
try try
{ {
string location = System.Reflection.Assembly.GetEntryAssembly().Location; string location = System.Reflection.Assembly.GetEntryAssembly()?.Location;
string path = Path.GetDirectoryName(location); string path = Path.GetDirectoryName(location);
string filenameWithoutExtension = Path.GetFileNameWithoutExtension(location); string filenameWithoutExtension = Path.GetFileNameWithoutExtension(location);
string fileOut = string.Format("{0}/{1}.{2}.txt", path, filenameWithoutExtension, string fileOut = $"{path}/{filenameWithoutExtension}.{DateTime.UtcNow:yyyy-MM}.txt";
DateTime.UtcNow.ToString("yyyy-MM"));
return File.AppendText(fileOut); return File.AppendText(fileOut);
} }
catch (Exception) catch (Exception)
@@ -28,10 +27,10 @@ namespace VAR.Toolbox.Code
} }
/// <summary> /// <summary>
/// Cierra el StreamWritter de salida /// Cierra el StreamWriter de salida
/// </summary> /// </summary>
/// <param name="stream">The stream.</param> /// <param name="stream">The stream.</param>
private static void CloseOutputStreamWritter(StreamWriter stream) private static void CloseOutputStreamWriter(StreamWriter stream)
{ {
if (stream != null) if (stream != null)
{ {
@@ -50,6 +49,7 @@ namespace VAR.Toolbox.Code
{ {
stream.WriteLine(line); stream.WriteLine(line);
} }
Console.Out.WriteLine(line); Console.Out.WriteLine(line);
} }
@@ -61,14 +61,17 @@ namespace VAR.Toolbox.Code
{ {
try try
{ {
StreamWriter outStream = GetOutputStreamWritter(); StreamWriter outStream = GetOutputStreamWriter();
WriteLine(outStream, string.Empty); WriteLine(outStream, string.Empty);
WriteLine(outStream, string.Format("---------------------------- {0} -----------------------", text)); WriteLine(outStream, $"---------------------------- {text} -----------------------");
WriteLine(outStream, string.Format("\\- Date: {0}", DateTime.UtcNow.ToString("s"))); WriteLine(outStream, $"\\- Date: {DateTime.UtcNow:s}");
WriteLine(outStream, string.Empty); WriteLine(outStream, string.Empty);
CloseOutputStreamWritter(outStream); CloseOutputStreamWriter(outStream);
}
catch (Exception)
{
/* Nom Nom Nom */
} }
catch (Exception) { /* Nom Nom Nom */}
} }
/// <summary> /// <summary>
@@ -79,38 +82,45 @@ namespace VAR.Toolbox.Code
{ {
try try
{ {
StreamWriter outStream = GetOutputStreamWritter(); StreamWriter outStream = GetOutputStreamWriter();
WriteLine(outStream, string.Format("{0} -- {1}", DateTime.UtcNow.ToString("s"), text)); WriteLine(outStream, $"{DateTime.UtcNow:s} -- {text}");
CloseOutputStreamWritter(outStream); CloseOutputStreamWriter(outStream);
}
catch (Exception)
{
/* Nom Nom Nom */
} }
catch (Exception) { /* Nom Nom Nom */}
} }
/// <summary> /// <summary>
/// Logea una excepcion /// Logea una excepción
/// </summary> /// </summary>
/// <param name="ex">The Exception.</param> /// <param name="ex">The Exception.</param>
public static void Log(Exception ex) public static void Log(Exception ex)
{ {
try try
{ {
StreamWriter outStream = GetOutputStreamWritter(); StreamWriter outStream = GetOutputStreamWriter();
WriteLine(outStream, string.Empty); WriteLine(outStream, string.Empty);
WriteLine(outStream, string.Format("!!!!!!!!!!!!!!!!!!!!!!!!!!!! {0} !!!!!!!!!!!!!!!!!!!!!!!", "Exception")); WriteLine(outStream,
WriteLine(outStream, string.Format("\\- Date: {0}", DateTime.UtcNow.ToString("s"))); "!!!!!!!!!!!!!!!!!!!!!!!!!!!! Exception !!!!!!!!!!!!!!!!!!!!!!!");
WriteLine(outStream, $"\\- Date: {DateTime.UtcNow:s}");
WriteLine(outStream, string.Empty); WriteLine(outStream, string.Empty);
Exception exAux = ex; Exception exAux = ex;
while (exAux != null) while (exAux != null)
{ {
WriteLine(outStream, string.Format("Message: {0}", exAux.Message)); WriteLine(outStream, $"Message: {exAux.Message}");
WriteLine(outStream, string.Format("Stacktrace: {0}", exAux.StackTrace)); WriteLine(outStream, $"Stacktrace: {exAux.StackTrace}");
exAux = exAux.InnerException; exAux = exAux.InnerException;
} }
CloseOutputStreamWritter(outStream);
}
catch (Exception) { /* Nom Nom Nom */}
}
CloseOutputStreamWriter(outStream);
}
catch (Exception)
{
/* Nom Nom Nom */
}
}
} }
} }

View File

@@ -39,14 +39,17 @@ namespace VAR.Toolbox.Code
{ {
input.Data.Mouse.Flags = down ? User32.MOUSEEVENTF_LEFTDOWN : User32.MOUSEEVENTF_LEFTUP; input.Data.Mouse.Flags = down ? User32.MOUSEEVENTF_LEFTDOWN : User32.MOUSEEVENTF_LEFTUP;
} }
if (button == MouseButtons.Middle) if (button == MouseButtons.Middle)
{ {
input.Data.Mouse.Flags = down ? User32.MOUSEEVENTF_MIDDLEDOWN : User32.MOUSEEVENTF_MIDDLEUP; input.Data.Mouse.Flags = down ? User32.MOUSEEVENTF_MIDDLEDOWN : User32.MOUSEEVENTF_MIDDLEUP;
} }
if (button == MouseButtons.Right) if (button == MouseButtons.Right)
{ {
input.Data.Mouse.Flags = down ? User32.MOUSEEVENTF_RIGHTDOWN : User32.MOUSEEVENTF_RIGHTUP; input.Data.Mouse.Flags = down ? User32.MOUSEEVENTF_RIGHTDOWN : User32.MOUSEEVENTF_RIGHTUP;
} }
User32.INPUT[] inputs = new User32.INPUT[] { input }; User32.INPUT[] inputs = new User32.INPUT[] { input };
if (User32.SendInput(1, inputs, Marshal.SizeOf(typeof(User32.INPUT))) == 0) if (User32.SendInput(1, inputs, Marshal.SizeOf(typeof(User32.INPUT))) == 0)
throw new Exception(); throw new Exception();

View File

@@ -4,4 +4,4 @@
{ {
bool ExecuteCmd(string cmd, IOutputHandler outputHandler); bool ExecuteCmd(string cmd, IOutputHandler outputHandler);
} }
} }

View File

@@ -2,7 +2,8 @@
{ {
public class ProxyCmdExecutorDummy : IProxyCmdExecutor public class ProxyCmdExecutorDummy : IProxyCmdExecutor
{ {
public string Name { get { return "Dummy"; } } private readonly string _config;
public string Name => "Dummy";
public ProxyCmdExecutorDummy(string config) public ProxyCmdExecutorDummy(string config)
{ {
@@ -10,12 +11,14 @@
{ {
throw new System.ArgumentNullException(nameof(config)); throw new System.ArgumentNullException(nameof(config));
} }
_config = config;
} }
public bool ExecuteCmd(string cmdString, IOutputHandler outputHandler) public bool ExecuteCmd(string cmdString, IOutputHandler outputHandler)
{ {
outputHandler.OutputLine(string.Format("DummyExecution: {0}", cmdString)); outputHandler.OutputLine($"DummyExecution: {cmdString} | {_config}");
return true; return true;
} }
} }
} }

View File

@@ -1,6 +1,4 @@
namespace VAR.Toolbox.Code.ProxyCmdExecutors namespace VAR.Toolbox.Code.ProxyCmdExecutors
{ {
public class ProxyCmdExecutorFactory : BaseFactory<IProxyCmdExecutor> public class ProxyCmdExecutorFactory : BaseFactory<IProxyCmdExecutor> { }
{ }
}
}

View File

@@ -5,9 +5,9 @@ namespace VAR.Toolbox.Code.ProxyCmdExecutors
{ {
public class ProxyCmdExecutorThroughSQLServer : IProxyCmdExecutor public class ProxyCmdExecutorThroughSQLServer : IProxyCmdExecutor
{ {
public string Name { get { return "SqlServer"; } } public string Name => "SqlServer";
private readonly string _connectionString = null; private readonly string _connectionString;
public ProxyCmdExecutorThroughSQLServer(string connectionString) public ProxyCmdExecutorThroughSQLServer(string connectionString)
{ {
@@ -27,8 +27,9 @@ namespace VAR.Toolbox.Code.ProxyCmdExecutors
string output = Convert.ToString(reader[0]); string output = Convert.ToString(reader[0]);
outputHandler.OutputLine(output); outputHandler.OutputLine(output);
} }
cnx.Close(); cnx.Close();
return true; return true;
} }
} }
} }

View File

@@ -4,7 +4,7 @@ namespace VAR.Toolbox.Code.ProxyCmdExecutors
{ {
public class ProxyCmdExecutorWMIC : IProxyCmdExecutor public class ProxyCmdExecutorWMIC : IProxyCmdExecutor
{ {
public string Name { get { return "WMIC"; } } public string Name => "WMIC";
private readonly string _configWMIC; private readonly string _configWMIC;
@@ -15,7 +15,8 @@ namespace VAR.Toolbox.Code.ProxyCmdExecutors
public bool ExecuteCmd(string cmd, IOutputHandler outputHandler) public bool ExecuteCmd(string cmd, IOutputHandler outputHandler)
{ {
string parameters = string.Format(" /node:\"{0}\" process call create \"cmd.exe /c \\\"{1}\\\"\"", _configWMIC.Replace("\"", "\\\""), cmd.Replace("\"", "\\\"")); string parameters = string.Format(" /node:\"{0}\" process call create \"cmd.exe /c \\\"{1}\\\"\"",
_configWMIC.Replace("\"", "\\\""), cmd.Replace("\"", "\\\""));
Process process = new Process(); Process process = new Process();
process.StartInfo.UseShellExecute = false; process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardOutput = true;

View File

@@ -17,6 +17,5 @@ namespace VAR.Toolbox.Code
interfaceType.IsAssignableFrom(x) && interfaceType.IsAssignableFrom(x) &&
true); true);
} }
} }
} }

View File

@@ -6,7 +6,7 @@ using VAR.Toolbox.Code.Windows;
namespace VAR.Toolbox.Code namespace VAR.Toolbox.Code
{ {
public class Screenshooter public static class Screenshoter
{ {
public static Bitmap CaptureScreen(Bitmap bmp = null) public static Bitmap CaptureScreen(Bitmap bmp = null)
{ {
@@ -17,7 +17,7 @@ namespace VAR.Toolbox.Code
int screenHeight = SystemInformation.VirtualScreen.Height; int screenHeight = SystemInformation.VirtualScreen.Height;
// Create a bitmap of the appropriate size to receive the screenshot. // Create a bitmap of the appropriate size to receive the screenshot.
if (bmp == null || bmp?.Width != screenWidth || bmp?.Height != screenHeight) if (bmp == null || bmp.Width != screenWidth || bmp.Height != screenHeight)
{ {
bmp = new Bitmap(screenWidth, screenHeight); bmp = new Bitmap(screenWidth, screenHeight);
} }
@@ -27,6 +27,7 @@ namespace VAR.Toolbox.Code
{ {
g.CopyFromScreen(screenLeft, screenTop, 0, 0, bmp.Size); g.CopyFromScreen(screenLeft, screenTop, 0, 0, bmp.Size);
} }
return bmp; return bmp;
} }
@@ -76,8 +77,5 @@ namespace VAR.Toolbox.Code
return img; return img;
} }
} }
} }

View File

@@ -7,4 +7,4 @@
string Encode(string input, string key); string Encode(string input, string key);
string Decode(string input, string key); string Decode(string input, string key);
} }
} }

View File

@@ -5,9 +5,9 @@ namespace VAR.Toolbox.Code.TextCoders
{ {
public class TextCoderBase64ToAscii : ITextCoder public class TextCoderBase64ToAscii : ITextCoder
{ {
public string Name { get { return "Base64ToAscii"; } } public string Name => "Base64ToAscii";
public bool NeedsKey { get { return false; } } public bool NeedsKey => false;
public string Decode(string input, string key) public string Decode(string input, string key)
{ {
@@ -23,4 +23,4 @@ namespace VAR.Toolbox.Code.TextCoders
return returnValue; return returnValue;
} }
} }
} }

View File

@@ -5,9 +5,9 @@ namespace VAR.Toolbox.Code.TextCoders
{ {
public class TextCoderBase64ToUtf8 : ITextCoder public class TextCoderBase64ToUtf8 : ITextCoder
{ {
public string Name { get { return "Base64ToUtf8"; } } public string Name => "Base64ToUtf8";
public bool NeedsKey { get { return false; } } public bool NeedsKey => false;
public string Decode(string input, string key) public string Decode(string input, string key)
{ {
@@ -23,4 +23,4 @@ namespace VAR.Toolbox.Code.TextCoders
return returnValue; return returnValue;
} }
} }
} }

View File

@@ -1,6 +1,4 @@
namespace VAR.Toolbox.Code.TextCoders namespace VAR.Toolbox.Code.TextCoders
{ {
public class TextCoderFactory : BaseFactory<ITextCoder> public class TextCoderFactory : BaseFactory<ITextCoder> { }
{ }
}
}

View File

@@ -4,9 +4,9 @@ namespace VAR.Toolbox.Code.TextCoders
{ {
public class TextCoderHexToAscii : ITextCoder public class TextCoderHexToAscii : ITextCoder
{ {
public string Name { get { return "HexToAscii"; } } public string Name => "HexToAscii";
public bool NeedsKey { get { return false; } } public bool NeedsKey => false;
public string Decode(string input, string key) public string Decode(string input, string key)
{ {
@@ -20,6 +20,5 @@ namespace VAR.Toolbox.Code.TextCoders
byte[] toEncodeAsBytes = Encoding.ASCII.GetBytes(input); byte[] toEncodeAsBytes = Encoding.ASCII.GetBytes(input);
return HexUtils.BytesToHexString(toEncodeAsBytes); return HexUtils.BytesToHexString(toEncodeAsBytes);
} }
} }
} }

View File

@@ -4,9 +4,9 @@ namespace VAR.Toolbox.Code.TextCoders
{ {
public class TextCoderHexToUtf8 : ITextCoder public class TextCoderHexToUtf8 : ITextCoder
{ {
public string Name { get { return "HexToUtf8"; } } public string Name => "HexToUtf8";
public bool NeedsKey { get { return false; } } public bool NeedsKey => false;
public string Decode(string input, string key) public string Decode(string input, string key)
{ {
@@ -21,4 +21,4 @@ namespace VAR.Toolbox.Code.TextCoders
return HexUtils.BytesToHexString(toEncodeAsBytes); return HexUtils.BytesToHexString(toEncodeAsBytes);
} }
} }
} }

View File

@@ -7,11 +7,14 @@ using System.Threading.Tasks;
namespace VAR.Toolbox.Code namespace VAR.Toolbox.Code
{ {
public class WebServicesUtils public static class WebServicesUtils
{ {
private static readonly CookieContainer _cookieJar = new CookieContainer(); private static readonly CookieContainer _cookieJar = new CookieContainer();
public static string CallApi(string urlService, string urlApiMethod, Dictionary<string, string> prms, object content, CookieContainer cookieJar = null, string stringContent = null, Dictionary<string, string> customHeaders = null, string verb = "POST", bool disableCertificateValidation = false) public static string CallApi(string urlService, string urlApiMethod, Dictionary<string, string> parameters,
object content, CookieContainer cookieJar = null, string stringContent = null,
Dictionary<string, string> customHeaders = null, string verb = "POST",
bool disableCertificateValidation = false)
{ {
if (urlService?.StartsWith("!") == true) if (urlService?.StartsWith("!") == true)
{ {
@@ -20,11 +23,12 @@ namespace VAR.Toolbox.Code
} }
if (cookieJar == null) { cookieJar = _cookieJar; } if (cookieJar == null) { cookieJar = _cookieJar; }
try try
{ {
var sbRequestUrl = new StringBuilder(); var sbRequestUrl = new StringBuilder();
sbRequestUrl.Append(urlService); sbRequestUrl.Append(urlService);
if (urlService.EndsWith("/") && urlApiMethod.StartsWith("/")) if (urlService != null && urlService.EndsWith("/") && urlApiMethod.StartsWith("/"))
{ {
sbRequestUrl.Append(urlApiMethod.Substring(1)); sbRequestUrl.Append(urlApiMethod.Substring(1));
} }
@@ -32,23 +36,19 @@ namespace VAR.Toolbox.Code
{ {
sbRequestUrl.Append(urlApiMethod); sbRequestUrl.Append(urlApiMethod);
} }
if (prms != null)
if (parameters != null)
{ {
foreach (KeyValuePair<string, string> pair in prms) foreach (KeyValuePair<string, string> pair in parameters)
{ {
if (pair.Value == null) sbRequestUrl.AppendFormat("&{0}={1}", pair.Key,
{ pair.Value == null ? string.Empty : HttpServer.HttpUtility.UrlEncode(pair.Value));
sbRequestUrl.AppendFormat("&{0}={1}", pair.Key, string.Empty);
}
else
{
sbRequestUrl.AppendFormat("&{0}={1}", pair.Key, HttpServer.HttpUtility.UrlEncode(pair.Value));
}
} }
} }
if (sbRequestUrl.Length > 2048) if (sbRequestUrl.Length > 2048)
{ {
throw new Exception(string.Format("CallApi: Request URL longer than 2048: url: \"{0}\"", sbRequestUrl.ToString())); throw new Exception($"CallApi: Request URL longer than 2048: url: \"{sbRequestUrl}\"");
} }
var http = (HttpWebRequest)WebRequest.Create(new Uri(sbRequestUrl.ToString())); var http = (HttpWebRequest)WebRequest.Create(new Uri(sbRequestUrl.ToString()));
@@ -56,7 +56,8 @@ namespace VAR.Toolbox.Code
#if UNIFIKAS_COMMONS #if UNIFIKAS_COMMONS
if (disableCertificateValidation) if (disableCertificateValidation)
{ {
http.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => { return true; }; http.ServerCertificateValidationCallback =
(sender, certificate, chain, sslPolicyErrors) => { return true; };
} }
#else #else
if (disableCertificateValidation) if (disableCertificateValidation)
@@ -83,6 +84,7 @@ namespace VAR.Toolbox.Code
{ {
parsedContent = stringContent; parsedContent = stringContent;
} }
UTF8Encoding encoding = new UTF8Encoding(); UTF8Encoding encoding = new UTF8Encoding();
byte[] bytes = encoding.GetBytes(parsedContent); byte[] bytes = encoding.GetBytes(parsedContent);
@@ -97,40 +99,47 @@ namespace VAR.Toolbox.Code
responseTask.Wait(); responseTask.Wait();
WebResponse response = responseTask.Result; WebResponse response = responseTask.Result;
var stream = response.GetResponseStream(); var stream = response.GetResponseStream();
if (stream == null) { return null; }
var sr = new StreamReader(stream); var sr = new StreamReader(stream);
return sr.ReadToEnd(); return sr.ReadToEnd();
} }
catch (Exception ex) catch (Exception ex)
{ {
// ReSharper disable once PossibleIntendedRethrow
throw ex; throw ex;
} }
} }
public static string CallSoapMethod(string url, string method, Dictionary<string, object> parms, string namespaceUrl = "http://tempuri.org", ICredentials credentials = null) public static string CallSoapMethod(string url, string method, Dictionary<string, object> parameters,
string namespaceUrl = "http://tempuri.org", ICredentials credentials = null)
{ {
// Los servicios SOAP se llaman siempre a través de HTTP. // Los servicios SOAP se llaman siempre a través de HTTP.
if (url.ToLower().StartsWith("https://")) if (url.ToLower().StartsWith("https://"))
{ {
url = string.Format("http://{0}", url.Substring("https://".Length)); url = $"http://{url.Substring("https://".Length)}";
} }
// Construir petición // Construir petición
var sbData = new StringBuilder(); var sbData = new StringBuilder();
sbData.AppendFormat("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"); sbData.AppendFormat("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
sbData.AppendFormat("<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"); sbData.AppendFormat(
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">");
sbData.AppendFormat("<soap:Body>"); sbData.AppendFormat("<soap:Body>");
sbData.AppendFormat("<{0} xmlns=\"{1}\">", method, namespaceUrl); sbData.AppendFormat("<{0} xmlns=\"{1}\">", method, namespaceUrl);
foreach (KeyValuePair<string, object> parm in parms) foreach (KeyValuePair<string, object> parameter in parameters)
{ {
if (parm.Value != null && !(parm.Value is DBNull)) if (parameter.Value != null && !(parameter.Value is DBNull))
{ {
sbData.AppendFormat("<{0}>{1}</{0}>", parm.Key, parm.Value); sbData.AppendFormat("<{0}>{1}</{0}>", parameter.Key, parameter.Value);
} }
else else
{ {
sbData.AppendFormat("<{0} i:nil=\"true\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" />", parm.Key); sbData.AppendFormat("<{0} i:nil=\"true\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" />",
parameter.Key);
} }
} }
sbData.AppendFormat("</{0}>", method); sbData.AppendFormat("</{0}>", method);
sbData.AppendFormat("</soap:Body>"); sbData.AppendFormat("</soap:Body>");
sbData.AppendFormat("</soap:Envelope>"); sbData.AppendFormat("</soap:Envelope>");
@@ -138,22 +147,20 @@ namespace VAR.Toolbox.Code
byte[] postData = Encoding.UTF8.GetBytes(sbData.ToString()); byte[] postData = Encoding.UTF8.GetBytes(sbData.ToString());
// Realizar petición // Realizar petición
var client = new System.Net.WebClient(); var client = new WebClient();
if (credentials != null) if (credentials != null)
{ {
client.Credentials = credentials; client.Credentials = credentials;
} }
client.Headers.Add("Accept", "text/xml"); client.Headers.Add("Accept", "text/xml");
client.Headers.Add("Accept-Charset", "UTF-8"); client.Headers.Add("Accept-Charset", "UTF-8");
client.Headers.Add("Content-Type", "text/xml; charset=UTF-8"); client.Headers.Add("Content-Type", "text/xml; charset=UTF-8");
if (namespaceUrl.ToLower().StartsWith("http")) client.Headers.Add("SOAPAction",
{ namespaceUrl.ToLower().StartsWith("http")
client.Headers.Add("SOAPAction", string.Format("\"{0}/{1}\"", namespaceUrl, method)); ? $"\"{namespaceUrl}/{method}\""
} : $"\"{namespaceUrl}:{method}\"");
else
{
client.Headers.Add("SOAPAction", string.Format("\"{0}:{1}\"", namespaceUrl, method));
}
byte[] data; byte[] data;
try try
{ {
@@ -161,11 +168,11 @@ namespace VAR.Toolbox.Code
} }
catch (Exception ex) catch (Exception ex)
{ {
throw new Exception(string.Format("Failure calling SoapService: URL: {0}", url), ex); throw new Exception($"Failure calling SoapService: URL: {url}", ex);
} }
string strData = System.Text.Encoding.UTF8.GetString(data);
string strData = Encoding.UTF8.GetString(data);
return strData; return strData;
} }
} }
} }

View File

@@ -1,5 +1,7 @@
#pragma warning disable IDE0018 #pragma warning disable IDE0018
#pragma warning disable IDE0059 #pragma warning disable IDE0059
// ReSharper disable SuspiciousTypeConversion.Global
// ReSharper disable ConvertToAutoProperty
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -10,26 +12,23 @@ using System.Runtime.InteropServices.ComTypes;
using VAR.Toolbox.Code.DirectShow; using VAR.Toolbox.Code.DirectShow;
using VAR.Toolbox.Code.Windows; using VAR.Toolbox.Code.Windows;
namespace VAR.Toolbox.Code namespace VAR.Toolbox.Code
{ {
public class Webcam public class Webcam
{ {
#region Declarations #region Declarations
private readonly IFilterGraph2 graph; private readonly IMediaControl _control;
private readonly ICaptureGraphBuilder2 capture; private readonly IBaseFilter _sourceFilter;
private readonly IMediaControl control; private readonly IBaseFilter _sampleGrabberFilter;
private readonly IBaseFilter sourceFilter; private readonly IBaseFilter _nullRenderer;
private readonly IBaseFilter samplegrabberfilter;
private readonly IBaseFilter nullrenderer;
private readonly Grabber grabber; private readonly int _width;
private readonly int _height;
private readonly int _bpp;
private readonly int width = 0; private bool _active;
private readonly int height = 0;
private readonly int bpp = 0;
private bool active = false;
private static Dictionary<string, string> _deviceDescriptions; private static Dictionary<string, string> _deviceDescriptions;
@@ -37,11 +36,13 @@ namespace VAR.Toolbox.Code
#region Properties #region Properties
public int Width { get { return width; } } public int Width => _width;
public int Height { get { return height; } }
public int BPP { get { return bpp; } }
public bool Active { get { return active; } } public int Height => _height;
public int BPP => _bpp;
public bool Active => _active;
#endregion Properties #endregion Properties
@@ -49,33 +50,29 @@ namespace VAR.Toolbox.Code
public Webcam(string monikerString) public Webcam(string monikerString)
{ {
int result; IFilterGraph2 graph = CreateInstanceFromClsid<IFilterGraph2>(Clsid.FilterGraph);
ICaptureGraphBuilder2 capture = CreateInstanceFromClsid<ICaptureGraphBuilder2>(Clsid.CaptureGraphBuilder2);
graph = CreateInstanceFromClsid<IFilterGraph2>(Clsid.FilterGraph); _control = (IMediaControl)graph;
capture = CreateInstanceFromClsid<ICaptureGraphBuilder2>(Clsid.CaptureGraphBuilder2);
control = (IMediaControl)graph;
capture.SetFiltergraph((IGraphBuilder)graph); capture.SetFiltergraph((IGraphBuilder)graph);
IBindCtx bindCtx = null;
IMoniker moniker = null;
int n = 0; int n = 0;
if (Win32.CreateBindCtx(0, out bindCtx) != 0) if (Win32.CreateBindCtx(0, out IBindCtx bindCtx) != 0)
{ {
throw new Exception("Failed to create binding context"); throw new Exception("Failed to create binding context");
} }
if (Win32.MkParseDisplayName(bindCtx, monikerString, ref n, out moniker) != 0)
if (Win32.MkParseDisplayName(bindCtx, monikerString, ref n, out IMoniker moniker) != 0)
{ {
throw new Exception("Failed to create binding moniker"); throw new Exception("Failed to create binding moniker");
} }
graph.AddSourceFilterForMoniker(moniker, bindCtx, monikerString, out sourceFilter); graph.AddSourceFilterForMoniker(moniker, bindCtx, monikerString, out _sourceFilter);
samplegrabberfilter = CreateInstanceFromClsid<IBaseFilter>(Clsid.SampleGrabber); _sampleGrabberFilter = CreateInstanceFromClsid<IBaseFilter>(Clsid.SampleGrabber);
graph.AddFilter(samplegrabberfilter, string.Format("SampleGrabber {0}", monikerString)); graph.AddFilter(_sampleGrabberFilter, $"SampleGrabber {monikerString}");
ISampleGrabber sampleGrabber = (ISampleGrabber)samplegrabberfilter; ISampleGrabber sampleGrabber = (ISampleGrabber)_sampleGrabberFilter;
// Set media type // Set media type
AMMediaType mediaType = new AMMediaType AMMediaType mediaType = new AMMediaType
@@ -85,15 +82,16 @@ namespace VAR.Toolbox.Code
}; };
sampleGrabber.SetMediaType(mediaType); sampleGrabber.SetMediaType(mediaType);
grabber = new Grabber(this); var grabber = new Grabber(this);
result = sampleGrabber.SetCallback(grabber, 1); int result = sampleGrabber.SetCallback(grabber, 1);
if (result < 0) throw new Exception("Failure creating Webcam device"); if (result < 0) throw new Exception("Failure creating Webcam device");
//set the null renderer //set the null renderer
nullrenderer = CreateInstanceFromClsid<IBaseFilter>(Clsid.NullRenderer); _nullRenderer = CreateInstanceFromClsid<IBaseFilter>(Clsid.NullRenderer);
graph.AddFilter(nullrenderer, string.Format("NullRenderer {0}", monikerString)); graph.AddFilter(_nullRenderer, $"NullRenderer {monikerString}");
result = capture.RenderStream(PinCategory.Preview, MediaType.Video, sourceFilter, samplegrabberfilter, nullrenderer); result = capture.RenderStream(PinCategory.Preview, MediaType.Video, _sourceFilter, _sampleGrabberFilter,
_nullRenderer);
if (result < 0) throw new Exception("Failure creating Webcam device"); if (result < 0) throw new Exception("Failure creating Webcam device");
AMMediaType queryMediaType = new AMMediaType(); AMMediaType queryMediaType = new AMMediaType();
@@ -102,14 +100,15 @@ namespace VAR.Toolbox.Code
{ {
if (queryMediaType.FormatType == FormatType.VideoInfo) if (queryMediaType.FormatType == FormatType.VideoInfo)
{ {
VideoInfoHeader videoInfo = (VideoInfoHeader)Marshal.PtrToStructure(queryMediaType.FormatPtr, typeof(VideoInfoHeader)); VideoInfoHeader videoInfo =
width = videoInfo.BmiHeader.Width; (VideoInfoHeader)Marshal.PtrToStructure(queryMediaType.FormatPtr, typeof(VideoInfoHeader));
height = videoInfo.BmiHeader.Height; _width = videoInfo.BmiHeader.Width;
bpp = videoInfo.BmiHeader.BitCount; _height = videoInfo.BmiHeader.Height;
_bpp = videoInfo.BmiHeader.BitCount;
} }
} }
control.Run(); _control.Run();
Stop(); Stop();
} }
@@ -119,41 +118,37 @@ namespace VAR.Toolbox.Code
public void Start() public void Start()
{ {
control.Run(); _control.Run();
int result; int result = _nullRenderer.Run(0);
result = nullrenderer.Run(0);
if (result < 0) throw new Exception("Webcam Start failure"); if (result < 0) throw new Exception("Webcam Start failure");
result = samplegrabberfilter.Run(0); result = _sampleGrabberFilter.Run(0);
if (result < 0) throw new Exception("Webcam Start failure"); if (result < 0) throw new Exception("Webcam Start failure");
result = sourceFilter.Run(0); result = _sourceFilter.Run(0);
if (result < 0) throw new Exception("Webcam Start failure"); if (result < 0) throw new Exception("Webcam Start failure");
active = true; _active = true;
} }
public void Stop() public void Stop()
{ {
int result; int result = _sourceFilter.Stop();
result = sourceFilter.Stop();
if (result < 0) throw new Exception("Webcam Stop failure"); if (result < 0) throw new Exception("Webcam Stop failure");
result = samplegrabberfilter.Stop(); result = _sampleGrabberFilter.Stop();
if (result < 0) throw new Exception("Webcam Stop failure"); if (result < 0) throw new Exception("Webcam Stop failure");
result = nullrenderer.Stop(); result = _nullRenderer.Stop();
if (result < 0) throw new Exception("Webcam Stop failure"); if (result < 0) throw new Exception("Webcam Stop failure");
control.Stop(); _control.Stop();
active = false; _active = false;
} }
public static Dictionary<string, string> ListDevices() public static Dictionary<string, string> ListDevices()
{ {
if (_deviceDescriptions != null) { return _deviceDescriptions; } if (_deviceDescriptions != null) { return _deviceDescriptions; }
int result;
Dictionary<string, string> devices = new Dictionary<string, string>(); Dictionary<string, string> devices = new Dictionary<string, string>();
ICreateDevEnum devEnum = CreateInstanceFromClsid<ICreateDevEnum>(Clsid.SystemDeviceEnum); ICreateDevEnum devEnum = CreateInstanceFromClsid<ICreateDevEnum>(Clsid.SystemDeviceEnum);
IEnumMoniker enumMon = null;
Guid category = FilterCategory.VideoInputDevice; Guid category = FilterCategory.VideoInputDevice;
result = devEnum.CreateClassEnumerator(ref category, out enumMon, 0); int result = devEnum.CreateClassEnumerator(ref category, out IEnumMoniker enumMon, 0);
if (result != 0) if (result != 0)
throw new ApplicationException("No devices of the category"); throw new ApplicationException("No devices of the category");
@@ -175,6 +170,7 @@ namespace VAR.Toolbox.Code
Marshal.ReleaseComObject(devMoniker[0]); Marshal.ReleaseComObject(devMoniker[0]);
devMoniker[0] = null; devMoniker[0] = null;
} }
_deviceDescriptions = devices; _deviceDescriptions = devices;
Marshal.ReleaseComObject(devEnum); Marshal.ReleaseComObject(devEnum);
@@ -202,8 +198,7 @@ namespace VAR.Toolbox.Code
// //
private static string GetMonikerString(IMoniker moniker) private static string GetMonikerString(IMoniker moniker)
{ {
string str; moniker.GetDisplayName(null, null, out string str);
moniker.GetDisplayName(null, null, out str);
return str; return str;
} }
@@ -213,14 +208,13 @@ namespace VAR.Toolbox.Code
private static string GetMonikerName(IMoniker moniker) private static string GetMonikerName(IMoniker moniker)
{ {
Object bagObj = null; Object bagObj = null;
IPropertyBag bag = null;
try try
{ {
Guid bagId = typeof(IPropertyBag).GUID; Guid bagId = typeof(IPropertyBag).GUID;
// get property bag of the moniker // get property bag of the moniker
moniker.BindToStorage(null, null, ref bagId, out bagObj); moniker.BindToStorage(null, null, ref bagId, out bagObj);
bag = (IPropertyBag)bagObj; IPropertyBag bag = (IPropertyBag)bagObj;
// read FriendlyName // read FriendlyName
object val = ""; object val = "";
@@ -242,11 +236,9 @@ namespace VAR.Toolbox.Code
finally finally
{ {
// release all COM objects // release all COM objects
bag = null;
if (bagObj != null) if (bagObj != null)
{ {
Marshal.ReleaseComObject(bagObj); Marshal.ReleaseComObject(bagObj);
bagObj = null;
} }
} }
} }
@@ -267,7 +259,7 @@ namespace VAR.Toolbox.Code
{ {
private readonly Webcam _parent; private readonly Webcam _parent;
private readonly Bitmap[] _frames = null; private readonly Bitmap[] _frames;
private readonly int _numFrames = 10; private readonly int _numFrames = 10;
private int _currentFrameIndex = -1; private int _currentFrameIndex = -1;
@@ -281,11 +273,13 @@ namespace VAR.Toolbox.Code
{ {
_currentFrameIndex = (_currentFrameIndex + 1) % _numFrames; _currentFrameIndex = (_currentFrameIndex + 1) % _numFrames;
Bitmap currentBitmap = _frames[_currentFrameIndex]; Bitmap currentBitmap = _frames[_currentFrameIndex];
if (currentBitmap == null || currentBitmap?.Width != _parent.width || currentBitmap?.Height != _parent.height) if (currentBitmap == null || currentBitmap.Width != _parent._width ||
currentBitmap.Height != _parent._height)
{ {
currentBitmap = new Bitmap(_parent.width, _parent.height, PixelFormat.Format24bppRgb); currentBitmap = new Bitmap(_parent._width, _parent._height, PixelFormat.Format24bppRgb);
_frames[_currentFrameIndex] = currentBitmap; _frames[_currentFrameIndex] = currentBitmap;
} }
return currentBitmap; return currentBitmap;
} }
@@ -299,12 +293,12 @@ namespace VAR.Toolbox.Code
if (_parent.NewFrame != null) if (_parent.NewFrame != null)
{ {
// create new image // create new image
Bitmap _image = GetNextFrame(); Bitmap image = GetNextFrame();
Rectangle _imageRect = new Rectangle(0, 0, _parent.width, _parent.height); Rectangle imageRect = new Rectangle(0, 0, _parent._width, _parent._height);
// lock bitmap data // lock bitmap data
BitmapData imageData = _image.LockBits( BitmapData imageData = image.LockBits(
_imageRect, imageRect,
ImageLockMode.ReadWrite, ImageLockMode.ReadWrite,
PixelFormat.Format24bppRgb); PixelFormat.Format24bppRgb);
@@ -314,10 +308,10 @@ namespace VAR.Toolbox.Code
unsafe unsafe
{ {
byte* dst = (byte*)imageData.Scan0.ToPointer() + dstStride * (_parent.height - 1); byte* dst = (byte*)imageData.Scan0.ToPointer() + dstStride * (_parent._height - 1);
byte* src = (byte*)buffer.ToPointer(); byte* src = (byte*)buffer.ToPointer();
for (int y = 0; y < _parent.height; y++) for (int y = 0; y < _parent._height; y++)
{ {
Win32.memcpy(dst, src, srcStride); Win32.memcpy(dst, src, srcStride);
dst -= dstStride; dst -= dstStride;
@@ -326,10 +320,10 @@ namespace VAR.Toolbox.Code
} }
// unlock bitmap data // unlock bitmap data
_image.UnlockBits(imageData); image.UnlockBits(imageData);
// notify parent // notify parent
_parent.NewFrame?.Invoke(this, _image); _parent.NewFrame?.Invoke(this, image);
} }
return 0; return 0;
@@ -338,4 +332,4 @@ namespace VAR.Toolbox.Code
#endregion Grabber #endregion Grabber
} }
} }

View File

@@ -11,16 +11,21 @@ namespace VAR.Toolbox.Code.Windows
public static extern bool BitBlt(IntPtr hObject, int nXDest, int nYDest, public static extern bool BitBlt(IntPtr hObject, int nXDest, int nYDest,
int nWidth, int nHeight, IntPtr hObjectSource, int nWidth, int nHeight, IntPtr hObjectSource,
int nXSrc, int nYSrc, int dwRop); int nXSrc, int nYSrc, int dwRop);
[DllImport("gdi32.dll")] [DllImport("gdi32.dll")]
public static extern IntPtr CreateCompatibleBitmap(IntPtr hDC, int nWidth, public static extern IntPtr CreateCompatibleBitmap(IntPtr hDC, int nWidth,
int nHeight); int nHeight);
[DllImport("gdi32.dll")] [DllImport("gdi32.dll")]
public static extern IntPtr CreateCompatibleDC(IntPtr hDC); public static extern IntPtr CreateCompatibleDC(IntPtr hDC);
[DllImport("gdi32.dll")] [DllImport("gdi32.dll")]
public static extern bool DeleteDC(IntPtr hDC); public static extern bool DeleteDC(IntPtr hDC);
[DllImport("gdi32.dll")] [DllImport("gdi32.dll")]
public static extern bool DeleteObject(IntPtr hObject); public static extern bool DeleteObject(IntPtr hObject);
[DllImport("gdi32.dll")] [DllImport("gdi32.dll")]
public static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObject); public static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObject);
} }
} }

View File

@@ -2,6 +2,11 @@
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
// ReSharper disable InconsistentNaming
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable FieldCanBeMadeReadOnly.Global
// ReSharper disable IdentifierTypo
namespace VAR.Toolbox.Code.Windows namespace VAR.Toolbox.Code.Windows
{ {
public static class User32 public static class User32
@@ -23,14 +28,11 @@ namespace VAR.Toolbox.Code.Windows
[StructLayout(LayoutKind.Explicit)] [StructLayout(LayoutKind.Explicit)]
public struct MOUSEKEYBDHARDWAREINPUT public struct MOUSEKEYBDHARDWAREINPUT
{ {
[FieldOffset(0)] [FieldOffset(0)] public HARDWAREINPUT Hardware;
public HARDWAREINPUT Hardware;
[FieldOffset(0)] [FieldOffset(0)] public KEYBDINPUT Keyboard;
public KEYBDINPUT Keyboard;
[FieldOffset(0)] [FieldOffset(0)] public MOUSEINPUT Mouse;
public MOUSEINPUT Mouse;
} }
/// <summary> /// <summary>
@@ -93,7 +95,7 @@ namespace VAR.Toolbox.Code.Windows
[DllImport("User32.dll")] [DllImport("User32.dll")]
public static extern int SendInput(int nInputs, INPUT[] pInputs, int cbSize); public static extern int SendInput(int nInputs, INPUT[] pInputs, int cbSize);
// <summary> /// <summary>
/// Struct representing a point. /// Struct representing a point.
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
@@ -111,18 +113,16 @@ namespace VAR.Toolbox.Code.Windows
public static extern bool GetCursorPos(out POINT lpPoint); public static extern bool GetCursorPos(out POINT lpPoint);
[DllImport("User32.dll")] [DllImport("User32.dll")]
public static extern Boolean SetCursorPos(UInt32 X, UInt32 Y); public static extern Boolean SetCursorPos(UInt32 x, UInt32 y);
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct LASTINPUTINFO public struct LASTINPUTINFO
{ {
public static readonly int SizeOf = Marshal.SizeOf(typeof(LASTINPUTINFO)); public static readonly int SizeOf = Marshal.SizeOf(typeof(LASTINPUTINFO));
[MarshalAs(UnmanagedType.U4)] [MarshalAs(UnmanagedType.U4)] public UInt32 cbSize;
public UInt32 cbSize;
[MarshalAs(UnmanagedType.U4)] [MarshalAs(UnmanagedType.U4)] public UInt32 dwTime;
public UInt32 dwTime;
} }
[DllImport("user32.dll")] [DllImport("user32.dll")]
@@ -139,7 +139,7 @@ namespace VAR.Toolbox.Code.Windows
public const int HT_CAPTION = 0x2; public const int HT_CAPTION = 0x2;
[DllImport("user32.dll")] [DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);
[DllImport("user32.dll")] [DllImport("user32.dll")]
public static extern bool ReleaseCapture(); public static extern bool ReleaseCapture();
@@ -177,14 +177,15 @@ namespace VAR.Toolbox.Code.Windows
public static string GetActiveWindowTitle() public static string GetActiveWindowTitle()
{ {
const int nChars = 256; const int NChars = 256;
StringBuilder Buff = new StringBuilder(nChars); StringBuilder buff = new StringBuilder(NChars);
IntPtr handle = GetForegroundWindow(); IntPtr handle = GetForegroundWindow();
if (GetWindowText(handle, Buff, nChars) > 0) if (GetWindowText(handle, buff, NChars) > 0)
{ {
return Buff.ToString(); return buff.ToString();
} }
return null; return null;
} }
} }

View File

@@ -4,6 +4,10 @@ using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes; using System.Runtime.InteropServices.ComTypes;
// ReSharper disable IdentifierTypo
// ReSharper disable StringLiteralTypo
// ReSharper disable CommentTypo
namespace VAR.Toolbox.Code.Windows namespace VAR.Toolbox.Code.Windows
{ {
public static class Win32 public static class Win32
@@ -21,7 +25,7 @@ namespace VAR.Toolbox.Code.Windows
/// ///
[DllImport("ole32.dll")] [DllImport("ole32.dll")]
public static extern public static extern
int CreateBindCtx(int reserved, out IBindCtx ppbc); int CreateBindCtx(int reserved, out IBindCtx ppbc);
/// <summary> /// <summary>
/// Converts a string into a moniker that identifies the object named by the string. /// Converts a string into a moniker that identifies the object named by the string.
@@ -37,8 +41,8 @@ namespace VAR.Toolbox.Code.Windows
/// ///
[DllImport("ole32.dll", CharSet = CharSet.Unicode)] [DllImport("ole32.dll", CharSet = CharSet.Unicode)]
public static extern public static extern
int MkParseDisplayName(IBindCtx pbc, string szUserName, int MkParseDisplayName(IBindCtx pbc, string szUserName,
ref int pchEaten, out IMoniker ppmk); ref int pchEaten, out IMoniker ppmk);
/// <summary> /// <summary>
/// Copy a block of memory. /// Copy a block of memory.
@@ -51,7 +55,7 @@ namespace VAR.Toolbox.Code.Windows
/// <returns>Return's the value of <b>dst</b> - pointer to destination.</returns> /// <returns>Return's the value of <b>dst</b> - pointer to destination.</returns>
/// ///
[DllImport("ntdll.dll", CallingConvention = CallingConvention.Cdecl)] [DllImport("ntdll.dll", CallingConvention = CallingConvention.Cdecl)]
public static unsafe extern int memcpy( public static extern unsafe int memcpy(
byte* dst, byte* dst,
byte* src, byte* src,
int count); int count);
@@ -81,7 +85,7 @@ namespace VAR.Toolbox.Code.Windows
int y, int y,
[MarshalAs(UnmanagedType.LPWStr)] string caption, [MarshalAs(UnmanagedType.LPWStr)] string caption,
int cObjects, int cObjects,
[MarshalAs( UnmanagedType.Interface, ArraySubType = UnmanagedType.IUnknown )] [MarshalAs(UnmanagedType.Interface, ArraySubType = UnmanagedType.IUnknown)]
ref object ppUnk, ref object ppUnk,
int cPages, int cPages,
IntPtr lpPageClsID, IntPtr lpPageClsID,
@@ -90,7 +94,8 @@ namespace VAR.Toolbox.Code.Windows
IntPtr lpvReserved); IntPtr lpvReserved);
[DllImport("PowrProf.dll")] [DllImport("PowrProf.dll")]
public static extern Boolean SetSuspendState(Boolean Hibernate, Boolean ForceCritical, Boolean DisableWakeEvent); public static extern Boolean
SetSuspendState(Boolean hibernate, Boolean forceCritical, Boolean disableWakeEvent);
public static uint GetLastInputTime() public static uint GetLastInputTime()
{ {
@@ -104,6 +109,7 @@ namespace VAR.Toolbox.Code.Windows
uint lastInputTick = lastInputInfo.dwTime; uint lastInputTick = lastInputInfo.dwTime;
idleTime = envTicks - lastInputTick; idleTime = envTicks - lastInputTick;
} }
return ((idleTime > 0) ? (idleTime / 1000) : 0); return ((idleTime > 0) ? (idleTime / 1000) : 0);
} }
} }

View File

@@ -8,4 +8,4 @@ namespace VAR.Toolbox.Code.WorkLog
List<WorkLogItem> Import(Form form); List<WorkLogItem> Import(Form form);
bool Export(List<WorkLogItem> items, Form form); bool Export(List<WorkLogItem> items, Form form);
} }
} }

View File

@@ -10,7 +10,7 @@ namespace VAR.Toolbox.Code.WorkLog
{ {
public class VARTextWorkLogImporter : IWorkLogImporter public class VARTextWorkLogImporter : IWorkLogImporter
{ {
public string Name { get { return "VARText"; } } public string Name => "VARText";
//TODO: VARTextWorkLogImporter: Export WorkLigItem.Tags //TODO: VARTextWorkLogImporter: Export WorkLigItem.Tags
public bool Export(List<WorkLogItem> items, Form form) public bool Export(List<WorkLogItem> items, Form form)
@@ -23,6 +23,7 @@ namespace VAR.Toolbox.Code.WorkLog
{ {
File.Delete(saveFileDialog.FileName); File.Delete(saveFileDialog.FileName);
} }
using (StreamWriter streamWriter = new StreamWriter(saveFileDialog.FileName)) using (StreamWriter streamWriter = new StreamWriter(saveFileDialog.FileName))
{ {
DateTime lastDateTime = DateTime.MinValue; DateTime lastDateTime = DateTime.MinValue;
@@ -30,30 +31,33 @@ namespace VAR.Toolbox.Code.WorkLog
List<WorkLogItem> itemsOrdered = items.OrderBy(x => x.DateStart).ToList(); List<WorkLogItem> itemsOrdered = items.OrderBy(x => x.DateStart).ToList();
foreach (WorkLogItem item in itemsOrdered) foreach (WorkLogItem item in itemsOrdered)
{ {
int weekOfYear = CultureInfo.InvariantCulture.Calendar.GetWeekOfYear(item.DateStart, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday); int weekOfYear = CultureInfo.InvariantCulture.Calendar.GetWeekOfYear(item.DateStart,
CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
if (weekOfYear != lastWeekOfYear) if (weekOfYear != lastWeekOfYear)
{ {
streamWriter.WriteLine(); streamWriter.WriteLine();
streamWriter.WriteLine(); streamWriter.WriteLine();
streamWriter.WriteLine(string.Format("--- {0:0000}-{1:00}-{2:00}", item.DateStart.Year, item.DateStart.Month, item.DateStart.Day)); streamWriter.WriteLine("--- {0:0000}-{1:00}-{2:00}", item.DateStart.Year, item.DateStart.Month,
item.DateStart.Day);
lastWeekOfYear = weekOfYear; lastWeekOfYear = weekOfYear;
} }
if (lastDateTime.Day != item.DateStart.Day) if (lastDateTime.Day != item.DateStart.Day)
{ {
streamWriter.WriteLine(); streamWriter.WriteLine();
lastDateTime = item.DateStart; lastDateTime = item.DateStart;
} }
streamWriter.WriteLine(string.Format("{0:00}_{1:00}_{2:00} - {3:00}_{4:00}_{5:00} {6}", streamWriter.WriteLine("{0:00}_{1:00}_{2:00} - {3:00}_{4:00}_{5:00} {6}", item.DateStart.Day,
item.DateStart.Day, item.DateStart.Hour, item.DateStart.Minute, item.DateStart.Hour, item.DateStart.Minute, item.DateEnd.Day, item.DateEnd.Hour,
item.DateEnd.Day, item.DateEnd.Hour, item.DateEnd.Minute, item.DateEnd.Minute, item.Activity);
item.Activity));
if (string.IsNullOrEmpty(item.Description) == false) if (string.IsNullOrEmpty(item.Description) == false)
{ {
streamWriter.WriteLine(string.Format(" {0}", item.Description)); streamWriter.WriteLine($" {item.Description}");
} }
} }
} }
return true; return true;
} }
@@ -82,14 +86,13 @@ namespace VAR.Toolbox.Code.WorkLog
{ {
string strDate = lineAux.Substring(4); string strDate = lineAux.Substring(4);
string[] strDateParts = strDate.Split('-'); string[] strDateParts = strDate.Split('-');
if (strDateParts.Length >= 3 && strDateParts[0].Length == 4 && strDateParts[1].Length == 2 && strDateParts[2].Length == 2) if (strDateParts.Length >= 3 && strDateParts[0].Length == 4 && strDateParts[1].Length == 2 &&
strDateParts[2].Length == 2)
{ {
currentDateStart = new DateTime(Convert.ToInt32(strDateParts[0]), Convert.ToInt32(strDateParts[1]), Convert.ToInt32(strDateParts[2]), 0, 0, 0); currentDateStart = new DateTime(Convert.ToInt32(strDateParts[0]),
} Convert.ToInt32(strDateParts[1]), Convert.ToInt32(strDateParts[2]), 0, 0, 0);
else
{
continue;
} }
else { }
} }
else if (lineAux.StartsWith("--")) else if (lineAux.StartsWith("--"))
{ {
@@ -97,7 +100,6 @@ namespace VAR.Toolbox.Code.WorkLog
{ {
currentWorkLog.Description += lineAux + "\n"; currentWorkLog.Description += lineAux + "\n";
} }
continue;
} }
else else
{ {
@@ -108,8 +110,10 @@ namespace VAR.Toolbox.Code.WorkLog
{ {
currentWorkLog.Description += lineAux + "\n"; currentWorkLog.Description += lineAux + "\n";
} }
continue; continue;
} }
int startDay = Convert.ToInt32(match.Groups[1].Value); int startDay = Convert.ToInt32(match.Groups[1].Value);
int startHour = Convert.ToInt32(match.Groups[2].Value); int startHour = Convert.ToInt32(match.Groups[2].Value);
int startMinute = Convert.ToInt32(match.Groups[3].Value); int startMinute = Convert.ToInt32(match.Groups[3].Value);
@@ -138,4 +142,4 @@ namespace VAR.Toolbox.Code.WorkLog
return workLog; return workLog;
} }
} }
} }

View File

@@ -1,6 +1,4 @@
namespace VAR.Toolbox.Code.WorkLog namespace VAR.Toolbox.Code.WorkLog
{ {
public class WorkLogImporterFactory : BaseFactory<IWorkLogImporter> public class WorkLogImporterFactory : BaseFactory<IWorkLogImporter> { }
{ }
}
}

View File

@@ -12,7 +12,7 @@ namespace VAR.Toolbox.Code.WorkLog
public bool Overlaps(WorkLogItem other) public bool Overlaps(WorkLogItem other)
{ {
return (other.DateEnd < this.DateStart || other.DateStart > this.DateEnd) == false; return (other.DateEnd < DateStart || other.DateStart > DateEnd) == false;
} }
} }
} }

View File

@@ -4,16 +4,16 @@ using System.Windows.Forms;
namespace VAR.Toolbox.Controls namespace VAR.Toolbox.Controls
{ {
public class CButton : System.Windows.Forms.Button public class CButton : Button
{ {
private Brush _foreColorBrush; private readonly Brush _foreColorBrush;
private Brush _foreColorDisableBrush; private readonly Brush _foreColorDisableBrush;
private Brush _backColorBrush; private readonly Brush _backColorBrush;
private Brush _backColorOverBrush; private readonly Brush _backColorOverBrush;
private Brush _backColorDownBrush; private readonly Brush _backColorDownBrush;
private bool _mouseIsDown = false; private bool _mouseIsDown;
private bool _mouseIsOver = false; private bool _mouseIsOver;
public CButton() public CButton()
{ {
@@ -47,15 +47,9 @@ namespace VAR.Toolbox.Controls
if (mevent.Button != MouseButtons.None) if (mevent.Button != MouseButtons.None)
{ {
Rectangle r = ClientRectangle; Rectangle r = ClientRectangle;
if (!r.Contains(mevent.X, mevent.Y)) _mouseIsDown = r.Contains(mevent.X, mevent.Y);
{
_mouseIsDown = false;
}
else
{
_mouseIsDown = true;
}
} }
base.OnMouseMove(mevent); base.OnMouseMove(mevent);
} }
@@ -71,7 +65,8 @@ namespace VAR.Toolbox.Controls
base.OnMouseUp(mevent); base.OnMouseUp(mevent);
} }
private StringFormat _stringFormat = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }; private readonly StringFormat _stringFormat = new StringFormat
{ Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center };
protected override void OnPaint(PaintEventArgs pevent) protected override void OnPaint(PaintEventArgs pevent)
{ {
@@ -84,14 +79,7 @@ namespace VAR.Toolbox.Controls
} }
else else
{ {
if (_mouseIsOver) pevent.Graphics.FillRectangle(_mouseIsOver ? _backColorOverBrush : _backColorBrush, rectangle);
{
pevent.Graphics.FillRectangle(_backColorOverBrush, rectangle);
}
else
{
pevent.Graphics.FillRectangle(_backColorBrush, rectangle);
}
} }
} }
else else
@@ -99,8 +87,8 @@ namespace VAR.Toolbox.Controls
pevent.Graphics.FillRectangle(_backColorBrush, rectangle); pevent.Graphics.FillRectangle(_backColorBrush, rectangle);
} }
pevent.Graphics.DrawString(Text, Font, Enabled ? _foreColorBrush : _foreColorDisableBrush, rectangle, _stringFormat); pevent.Graphics.DrawString(Text, Font, Enabled ? _foreColorBrush : _foreColorDisableBrush, rectangle,
_stringFormat);
} }
} }
} }

View File

@@ -3,14 +3,19 @@ using System.Windows.Forms;
namespace VAR.Toolbox.Controls namespace VAR.Toolbox.Controls
{ {
public class CComboBox : System.Windows.Forms.ComboBox public class CComboBox : ComboBox
{ {
public CComboBox() public CComboBox()
{
InitializeComponent();
}
private void InitializeComponent()
{ {
BackColor = Color.FromArgb(255, 0, 0, 0); BackColor = Color.FromArgb(255, 0, 0, 0);
ForeColor = Color.FromArgb(255, 192, 192, 192); ForeColor = Color.FromArgb(255, 192, 192, 192);
FlatStyle = System.Windows.Forms.FlatStyle.Flat; FlatStyle = FlatStyle.Flat;
} }
protected override void OnPaint(PaintEventArgs pevent) protected override void OnPaint(PaintEventArgs pevent)
@@ -19,4 +24,4 @@ namespace VAR.Toolbox.Controls
pevent.Graphics.FillRectangle(Brushes.CadetBlue, rectangle); pevent.Graphics.FillRectangle(Brushes.CadetBlue, rectangle);
} }
} }
} }

View File

@@ -5,9 +5,14 @@ namespace VAR.Toolbox.Controls
public class CDateTimePicker : System.Windows.Forms.DateTimePicker public class CDateTimePicker : System.Windows.Forms.DateTimePicker
{ {
public CDateTimePicker() public CDateTimePicker()
{
InitializeComponent();
}
private void InitializeComponent()
{ {
BackColor = Color.DarkSlateGray; BackColor = Color.DarkSlateGray;
ForeColor = Color.Gray; ForeColor = Color.Gray;
} }
} }
} }

View File

@@ -3,26 +3,31 @@ using System.Windows.Forms;
namespace VAR.Toolbox.Controls namespace VAR.Toolbox.Controls
{ {
public class CGroupBox : System.Windows.Forms.GroupBox public class CGroupBox : GroupBox
{ {
public CGroupBox() public CGroupBox()
{
InitializeComponent();
}
private void InitializeComponent()
{ {
BackColor = Color.FromArgb(255, 32, 32, 32); BackColor = Color.FromArgb(255, 32, 32, 32);
ForeColor = Color.FromArgb(255, 192, 192, 192); ForeColor = Color.FromArgb(255, 192, 192, 192);
BorderColor = Color.FromArgb(255, 64, 64, 64); BorderColor = Color.FromArgb(255, 64, 64, 64);
FlatStyle = System.Windows.Forms.FlatStyle.Flat; FlatStyle = FlatStyle.Flat;
} }
private Color _borderColor = Color.Black; private Color _borderColor = Color.Black;
public Color BorderColor public Color BorderColor
{ {
get { return this._borderColor; } get => _borderColor;
set { this._borderColor = value; } set => _borderColor = value;
} }
private SolidBrush _brushBackColor = null; private SolidBrush _brushBackColor;
private SolidBrush _brushForeColor = null; private SolidBrush _brushForeColor;
protected override void OnPaint(PaintEventArgs e) protected override void OnPaint(PaintEventArgs e)
{ {
@@ -30,6 +35,7 @@ namespace VAR.Toolbox.Controls
{ {
_brushBackColor = new SolidBrush(BackColor); _brushBackColor = new SolidBrush(BackColor);
} }
if (_brushForeColor == null || _brushForeColor.Color != ForeColor) if (_brushForeColor == null || _brushForeColor.Color != ForeColor)
{ {
_brushForeColor = new SolidBrush(ForeColor); _brushForeColor = new SolidBrush(ForeColor);
@@ -50,4 +56,4 @@ namespace VAR.Toolbox.Controls
e.Graphics.DrawString(Text, Font, _brushForeColor, textRect); e.Graphics.DrawString(Text, Font, _brushForeColor, textRect);
} }
} }
} }

View File

@@ -5,9 +5,14 @@ namespace VAR.Toolbox.Controls
public class CSplitContainer : System.Windows.Forms.SplitContainer public class CSplitContainer : System.Windows.Forms.SplitContainer
{ {
public CSplitContainer() public CSplitContainer()
{
InitializeComponent();
}
private void InitializeComponent()
{ {
BackColor = Color.FromArgb(255, 32, 32, 32); BackColor = Color.FromArgb(255, 32, 32, 32);
ForeColor = Color.FromArgb(255, 192, 192, 192); ForeColor = Color.FromArgb(255, 192, 192, 192);
} }
} }
} }

View File

@@ -23,8 +23,8 @@ namespace VAR.Toolbox.Controls
if (control.InvokeRequired) if (control.InvokeRequired)
{ {
control.Invoke(new SetControlPropertyThreadSafeDelegate control.Invoke(new SetControlPropertyThreadSafeDelegate
(SetControlPropertyThreadSafe), (SetControlPropertyThreadSafe),
new object[] { control, propertyName, propertyValue }); new[] { control, propertyName, propertyValue });
} }
else else
{ {
@@ -33,8 +33,8 @@ namespace VAR.Toolbox.Controls
BindingFlags.SetProperty, BindingFlags.SetProperty,
null, null,
control, control,
new object[] { propertyValue }); new[] { propertyValue });
} }
} }
} }
} }

View File

@@ -8,7 +8,7 @@ namespace VAR.Toolbox.Controls
{ {
#region Declarations #region Declarations
private Image _imageShow = null; private Image _imageShow;
#endregion #endregion
@@ -16,7 +16,8 @@ namespace VAR.Toolbox.Controls
public Image ImageShow public Image ImageShow
{ {
get { return _imageShow; } // ReSharper disable once InconsistentlySynchronizedField
get => _imageShow;
set set
{ {
lock (this) lock (this)
@@ -32,6 +33,11 @@ namespace VAR.Toolbox.Controls
#region Control life cycle #region Control life cycle
public CtrImageViewer() public CtrImageViewer()
{
InitializeComponent();
}
private void InitializeComponent()
{ {
BackColor = Color.Black; BackColor = Color.Black;
} }
@@ -46,7 +52,7 @@ namespace VAR.Toolbox.Controls
{ {
base.OnResize(e); base.OnResize(e);
//Redraw(null); //Redraw(null);
this.Invalidate(); Invalidate();
} }
#endregion #endregion
@@ -59,11 +65,12 @@ namespace VAR.Toolbox.Controls
{ {
return; return;
} }
lock (_imageShow) lock (_imageShow)
{ {
if (graph == null) if (graph == null)
{ {
graph = this.CreateGraphics(); graph = CreateGraphics();
} }
// Calcular dimensiones a dibujar y centrar // Calcular dimensiones a dibujar y centrar
@@ -71,7 +78,7 @@ namespace VAR.Toolbox.Controls
int imgDrawHeight; int imgDrawHeight;
float imgDrawX = 0; float imgDrawX = 0;
float imgDrawY = 0; float imgDrawY = 0;
float relation = (float)_imageShow.Width / (float)_imageShow.Height; float relation = _imageShow.Width / (float)_imageShow.Height;
if (relation > 0) if (relation > 0)
{ {
// Imagen mas ancha que alta // Imagen mas ancha que alta
@@ -110,6 +117,5 @@ namespace VAR.Toolbox.Controls
} }
#endregion #endregion
} }
} }

View File

@@ -16,6 +16,7 @@ namespace VAR.Toolbox.Controls
{ {
public string Text { get; set; } public string Text { get; set; }
public object Data { get; set; } public object Data { get; set; }
public override string ToString() public override string ToString()
{ {
return Text; return Text;
@@ -62,6 +63,7 @@ namespace VAR.Toolbox.Controls
CopyToClipboard(); CopyToClipboard();
return true; return true;
} }
return base.ProcessCmdKey(ref msg, keyData); return base.ProcessCmdKey(ref msg, keyData);
} }
@@ -80,6 +82,7 @@ namespace VAR.Toolbox.Controls
{ {
sbText.AppendLine(item.Text); sbText.AppendLine(item.Text);
} }
if (sbText.Length > 0) if (sbText.Length > 0)
{ {
Clipboard.SetText(sbText.ToString()); Clipboard.SetText(sbText.ToString());
@@ -99,7 +102,7 @@ namespace VAR.Toolbox.Controls
} }
} }
private bool _updated = false; private bool _updated;
private readonly List<OutputItem> _pendingOutput = new List<OutputItem>(); private readonly List<OutputItem> _pendingOutput = new List<OutputItem>();
private void UpdatePosition() private void UpdatePosition()
@@ -112,6 +115,7 @@ namespace VAR.Toolbox.Controls
{ {
_listBox.Items.Add(item); _listBox.Items.Add(item);
} }
_pendingOutput.Clear(); _pendingOutput.Clear();
_listBox.ResumeLayout(); _listBox.ResumeLayout();
@@ -124,10 +128,12 @@ namespace VAR.Toolbox.Controls
} }
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)] [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
private static extern IntPtr SendMessage(HandleRef hWnd, Int32 Msg, IntPtr wParam, IntPtr lParam); private static extern IntPtr SendMessage(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam);
private static void EnableRepaint(HandleRef handle, bool enable) private static void EnableRepaint(HandleRef handle, bool enable)
{ {
// ReSharper disable once InconsistentNaming
// ReSharper disable once IdentifierTypo
const int WM_SETREDRAW = 0x000B; const int WM_SETREDRAW = 0x000B;
SendMessage(handle, WM_SETREDRAW, new IntPtr(enable ? 1 : 0), IntPtr.Zero); SendMessage(handle, WM_SETREDRAW, new IntPtr(enable ? 1 : 0), IntPtr.Zero);
} }
@@ -161,6 +167,7 @@ namespace VAR.Toolbox.Controls
public string GetCurrentText() public string GetCurrentText()
{ {
if (_listBox.SelectedItems.Count == 0) { return null; } if (_listBox.SelectedItems.Count == 0) { return null; }
OutputItem item = (OutputItem)_listBox.SelectedItems[0]; OutputItem item = (OutputItem)_listBox.SelectedItems[0];
return item?.Text; return item?.Text;
} }
@@ -168,8 +175,9 @@ namespace VAR.Toolbox.Controls
public object GetCurrentData() public object GetCurrentData()
{ {
if (_listBox.SelectedItems.Count == 0) { return null; } if (_listBox.SelectedItems.Count == 0) { return null; }
OutputItem item = (OutputItem)_listBox.SelectedItems[0]; OutputItem item = (OutputItem)_listBox.SelectedItems[0];
return item?.Data; return item?.Data;
} }
} }
} }

View File

@@ -6,10 +6,16 @@ namespace VAR.Toolbox.Controls
{ {
public Frame() public Frame()
{ {
Font = new System.Drawing.Font(Font.Name, ControlsUtils.GetFontSize(this, 8.25f), Font.Style, Font.Unit, Font.GdiCharSet, Font.GdiVerticalFont); InitializeComponent();
}
private void InitializeComponent()
{
Font = new Font(Font.Name, ControlsUtils.GetFontSize(this, 8.25f), Font.Style, Font.Unit,
Font.GdiCharSet, Font.GdiVerticalFont);
AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
BackColor = Color.FromArgb(255, 32, 32, 32); BackColor = Color.FromArgb(255, 32, 32, 32);
ForeColor = Color.FromArgb(255, 192, 192, 192); ForeColor = Color.FromArgb(255, 192, 192, 192);
} }
} }
} }

View File

@@ -6,6 +6,11 @@ namespace VAR.Toolbox.Controls
public class ListBoxMonospace : ListBox public class ListBoxMonospace : ListBox
{ {
public ListBoxMonospace() public ListBoxMonospace()
{
InitializeComponent();
}
private void InitializeComponent()
{ {
FormattingEnabled = true; FormattingEnabled = true;
Font = new Font("Consolas", ControlsUtils.GetFontSize(this, 9)); Font = new Font("Consolas", ControlsUtils.GetFontSize(this, 9));
@@ -17,17 +22,17 @@ namespace VAR.Toolbox.Controls
protected override void OnMouseWheel(MouseEventArgs e) protected override void OnMouseWheel(MouseEventArgs e)
{ {
(e as HandledMouseEventArgs).Handled = true; ((HandledMouseEventArgs)e).Handled = true;
const int rows = 5; const int Rows = 5;
if (e.Delta > 0) if (e.Delta > 0)
{ {
if (TopIndex < rows) { TopIndex = 0; } if (TopIndex < Rows) { TopIndex = 0; }
else { TopIndex -= rows; } else { TopIndex -= Rows; }
} }
else else
{ {
TopIndex += rows; TopIndex += Rows;
} }
} }
} }
} }

View File

@@ -6,6 +6,11 @@ namespace VAR.Toolbox.Controls
public class ListBoxNormal : ListBox public class ListBoxNormal : ListBox
{ {
public ListBoxNormal() public ListBoxNormal()
{
InitializeComponent();
}
private void InitializeComponent()
{ {
FormattingEnabled = true; FormattingEnabled = true;
Font = new Font("Microsoft Sans Serif", ControlsUtils.GetFontSize(this, 8.25f)); Font = new Font("Microsoft Sans Serif", ControlsUtils.GetFontSize(this, 8.25f));
@@ -16,17 +21,17 @@ namespace VAR.Toolbox.Controls
protected override void OnMouseWheel(MouseEventArgs e) protected override void OnMouseWheel(MouseEventArgs e)
{ {
(e as HandledMouseEventArgs).Handled = true; ((HandledMouseEventArgs)e).Handled = true;
const int rows = 5; const int Rows = 5;
if (e.Delta > 0) if (e.Delta > 0)
{ {
if (TopIndex < rows) { TopIndex = 0; } if (TopIndex < Rows) { TopIndex = 0; }
else { TopIndex -= rows; } else { TopIndex -= Rows; }
} }
else else
{ {
TopIndex += rows; TopIndex += Rows;
} }
} }
} }
} }

View File

@@ -6,10 +6,16 @@ namespace VAR.Toolbox.Controls
{ {
public SubFrame() public SubFrame()
{ {
Font = new System.Drawing.Font(Font.Name, ControlsUtils.GetFontSize(this, 8.25f), Font.Style, Font.Unit, Font.GdiCharSet, Font.GdiVerticalFont); InitializeComponent();
}
private void InitializeComponent()
{
Font = new Font(Font.Name, ControlsUtils.GetFontSize(this, 8.25f), Font.Style, Font.Unit,
Font.GdiCharSet, Font.GdiVerticalFont);
AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
BackColor = Color.FromArgb(255, 32, 32, 32); BackColor = Color.FromArgb(255, 32, 32, 32);
ForeColor = Color.FromArgb(255, 192, 192, 192); ForeColor = Color.FromArgb(255, 192, 192, 192);
} }
} }
} }

View File

@@ -6,6 +6,11 @@ namespace VAR.Toolbox.Controls
public class TextBoxMonospace : TextBox public class TextBoxMonospace : TextBox
{ {
public TextBoxMonospace() public TextBoxMonospace()
{
InitializeComponent();
}
private void InitializeComponent()
{ {
Font = new Font("Consolas", ControlsUtils.GetFontSize(this, 9.0f)); Font = new Font("Consolas", ControlsUtils.GetFontSize(this, 9.0f));
BackColor = Color.FromArgb(255, 0, 0, 0); BackColor = Color.FromArgb(255, 0, 0, 0);
@@ -13,4 +18,4 @@ namespace VAR.Toolbox.Controls
BorderStyle = BorderStyle.FixedSingle; BorderStyle = BorderStyle.FixedSingle;
} }
} }
} }

View File

@@ -6,6 +6,11 @@ namespace VAR.Toolbox.Controls
public class TextBoxNormal : TextBox public class TextBoxNormal : TextBox
{ {
public TextBoxNormal() public TextBoxNormal()
{
InitializeComponent();
}
private void InitializeComponent()
{ {
Font = new Font("Microsoft Sans Serif", ControlsUtils.GetFontSize(this, 8.25f)); Font = new Font("Microsoft Sans Serif", ControlsUtils.GetFontSize(this, 8.25f));
BackColor = Color.FromArgb(255, 0, 0, 0); BackColor = Color.FromArgb(255, 0, 0, 0);
@@ -13,4 +18,4 @@ namespace VAR.Toolbox.Controls
BorderStyle = BorderStyle.FixedSingle; BorderStyle = BorderStyle.FixedSingle;
} }
} }
} }

View File

@@ -2,234 +2,234 @@
<!-- Created with Inkscape (http://www.inkscape.org/) --> <!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg <svg
xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#" xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="64" width="64"
height="64" height="64"
viewBox="0 0 16.933333 16.933334" viewBox="0 0 16.933333 16.933334"
version="1.1" version="1.1"
id="svg8" id="svg8"
inkscape:export-filename="C:\Users\valen\source.coffebreak\VAR.Toolbox\VAR.Toolbox\Images\Toolbox.png" inkscape:export-filename="C:\Users\valen\source.coffebreak\VAR.Toolbox\VAR.Toolbox\Images\Toolbox.png"
inkscape:export-xdpi="96.000008" inkscape:export-xdpi="96.000008"
inkscape:export-ydpi="96.000008" inkscape:export-ydpi="96.000008"
inkscape:version="0.92.1 r15371" inkscape:version="0.92.1 r15371"
sodipodi:docname="toolbox.svg"> sodipodi:docname="toolbox.svg">
<defs <defs
id="defs2"> id="defs2">
<linearGradient <linearGradient
inkscape:collect="always" inkscape:collect="always"
id="linearGradient4845"> id="linearGradient4845">
<stop <stop
style="stop-color:#8d0000;stop-opacity:1" style="stop-color:#8d0000;stop-opacity:1"
offset="0" offset="0"
id="stop4841" /> id="stop4841"/>
<stop <stop
style="stop-color:#ff0400;stop-opacity:1" style="stop-color:#ff0400;stop-opacity:1"
offset="1" offset="1"
id="stop4843" /> id="stop4843"/>
</linearGradient> </linearGradient>
<linearGradient <linearGradient
inkscape:collect="always" inkscape:collect="always"
id="linearGradient4839"> id="linearGradient4839">
<stop <stop
style="stop-color:#8f0000;stop-opacity:1" style="stop-color:#8f0000;stop-opacity:1"
offset="0" offset="0"
id="stop4835" /> id="stop4835"/>
<stop <stop
style="stop-color:#fc0000;stop-opacity:1" style="stop-color:#fc0000;stop-opacity:1"
offset="1" offset="1"
id="stop4837" /> id="stop4837"/>
</linearGradient> </linearGradient>
<linearGradient <linearGradient
inkscape:collect="always" inkscape:collect="always"
xlink:href="#linearGradient4839" xlink:href="#linearGradient4839"
id="linearGradient4833" id="linearGradient4833"
x1="10.583333" x1="10.583333"
y1="293.95728" y1="293.95728"
x2="10.583333" x2="10.583333"
y2="282.84479" y2="282.84479"
gradientUnits="userSpaceOnUse" /> gradientUnits="userSpaceOnUse"/>
<linearGradient <linearGradient
inkscape:collect="always" inkscape:collect="always"
xlink:href="#linearGradient4845" xlink:href="#linearGradient4845"
id="linearGradient4847" id="linearGradient4847"
x1="9.921875" x1="9.921875"
y1="294.03665" y1="294.03665"
x2="9.7895832" x2="9.7895832"
y2="282.92416" y2="282.92416"
gradientUnits="userSpaceOnUse" /> gradientUnits="userSpaceOnUse"/>
</defs> </defs>
<sodipodi:namedview <sodipodi:namedview
id="base" id="base"
pagecolor="#ffffff" pagecolor="#ffffff"
bordercolor="#666666" bordercolor="#666666"
borderopacity="1.0" borderopacity="1.0"
inkscape:pageopacity="0.0" inkscape:pageopacity="0.0"
inkscape:pageshadow="2" inkscape:pageshadow="2"
inkscape:zoom="8" inkscape:zoom="8"
inkscape:cx="22.659532" inkscape:cx="22.659532"
inkscape:cy="29.638443" inkscape:cy="29.638443"
inkscape:document-units="mm" inkscape:document-units="mm"
inkscape:current-layer="layer1" inkscape:current-layer="layer1"
showgrid="true" showgrid="true"
units="px" units="px"
inkscape:window-width="1821" inkscape:window-width="1821"
inkscape:window-height="1246" inkscape:window-height="1246"
inkscape:window-x="-11" inkscape:window-x="-11"
inkscape:window-y="-11" inkscape:window-y="-11"
inkscape:window-maximized="1"> inkscape:window-maximized="1">
<inkscape:grid <inkscape:grid
type="xygrid" type="xygrid"
id="grid4485" id="grid4485"
originy="0" /> originy="0"/>
<inkscape:grid <inkscape:grid
type="xygrid" type="xygrid"
id="grid4487" id="grid4487"
originx="0.13229167" originx="0.13229167"
originy="0.13229167" originy="0.13229167"
units="in" /> units="in"/>
</sodipodi:namedview> </sodipodi:namedview>
<metadata <metadata
id="metadata5"> id="metadata5">
<rdf:RDF> <rdf:RDF>
<cc:Work <cc:Work
rdf:about=""> rdf:about="">
<dc:format>image/svg+xml</dc:format> <dc:format>image/svg+xml</dc:format>
<dc:type <dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
<dc:title></dc:title> <dc:title></dc:title>
</cc:Work> </cc:Work>
</rdf:RDF> </rdf:RDF>
</metadata> </metadata>
<g <g
inkscape:label="Capa 1" inkscape:label="Capa 1"
inkscape:groupmode="layer" inkscape:groupmode="layer"
id="layer1" id="layer1"
transform="translate(0,-280.06665)"> transform="translate(0,-280.06665)">
<path <path
style="fill:url(#linearGradient4833);fill-opacity:1;stroke:#000000;stroke-width:0.26458332;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" style="fill:url(#linearGradient4833);fill-opacity:1;stroke:#000000;stroke-width:0.26458332;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path4665-6" id="path4665-6"
d="m 11.641667,285.75519 c -0.07519,0 -0.132327,-0.055 -0.131923,-0.12982 l 0.01,-1.84881 c 4.07e-4,-0.0754 -0.06708,-0.13652 -0.142114,-0.13656 l -5.8221957,-0.003 c -0.075331,-4e-5 -0.127582,0.0629 -0.1276415,0.13802 l -0.00146,1.84724 c -5.91e-5,0.0747 -0.056695,0.13196 -0.1320265,0.13202 l -3.9709303,0.003 c -0.075186,6e-5 -0.1312438,0.0554 -0.1312438,0.13006 v 2.11525 c 0,0.0745 0.061225,0.13617 0.1364114,0.13612 l 6.3458527,-0.004 c 0.075331,-5e-5 0.1374335,-0.0575 0.1368477,-0.13199 l -0.00413,-0.52582 c -5.88e-4,-0.0748 0.05546,-0.13627 0.1306467,-0.13612 l 1.0559706,0.002 c 0.075331,1.5e-4 0.1346351,0.0531 0.1346351,0.12785 v 0.5279 c 0,0.0745 0.055461,0.13821 0.1305009,0.13818 l 6.3561867,-0.002 c 0.07533,-3e-5 0.127184,-0.0554 0.127111,-0.12992 l -0.0021,-2.11732 c -7.3e-5,-0.0747 -0.05488,-0.13114 -0.130211,-0.13124 l -3.835927,-0.001 z m -5.0288563,0.006 c -0.075331,1.6e-4 -0.1282891,-0.0616 -0.1281431,-0.13641 l 0.00207,-1.05897 c 1.472e-4,-0.0754 0.050745,-0.12793 0.126076,-0.12814 l 3.7139823,-0.0103 c 0.07519,-2.1e-4 0.130354,0.0549 0.130209,0.1302 l -0.0021,1.07344 c -1.43e-4,0.0747 -0.05296,0.12177 -0.128142,0.12194 z" d="m 11.641667,285.75519 c -0.07519,0 -0.132327,-0.055 -0.131923,-0.12982 l 0.01,-1.84881 c 4.07e-4,-0.0754 -0.06708,-0.13652 -0.142114,-0.13656 l -5.8221957,-0.003 c -0.075331,-4e-5 -0.127582,0.0629 -0.1276415,0.13802 l -0.00146,1.84724 c -5.91e-5,0.0747 -0.056695,0.13196 -0.1320265,0.13202 l -3.9709303,0.003 c -0.075186,6e-5 -0.1312438,0.0554 -0.1312438,0.13006 v 2.11525 c 0,0.0745 0.061225,0.13617 0.1364114,0.13612 l 6.3458527,-0.004 c 0.075331,-5e-5 0.1374335,-0.0575 0.1368477,-0.13199 l -0.00413,-0.52582 c -5.88e-4,-0.0748 0.05546,-0.13627 0.1306467,-0.13612 l 1.0559706,0.002 c 0.075331,1.5e-4 0.1346351,0.0531 0.1346351,0.12785 v 0.5279 c 0,0.0745 0.055461,0.13821 0.1305009,0.13818 l 6.3561867,-0.002 c 0.07533,-3e-5 0.127184,-0.0554 0.127111,-0.12992 l -0.0021,-2.11732 c -7.3e-5,-0.0747 -0.05488,-0.13114 -0.130211,-0.13124 l -3.835927,-0.001 z m -5.0288563,0.006 c -0.075331,1.6e-4 -0.1282891,-0.0616 -0.1281431,-0.13641 l 0.00207,-1.05897 c 1.472e-4,-0.0754 0.050745,-0.12793 0.126076,-0.12814 l 3.7139823,-0.0103 c 0.07519,-2.1e-4 0.130354,0.0549 0.130209,0.1302 l -0.0021,1.07344 c -1.43e-4,0.0747 -0.05296,0.12177 -0.128142,0.12194 z"
inkscape:connector-curvature="0" inkscape:connector-curvature="0"
sodipodi:nodetypes="csssssssssssssssssssssssccsssssssss" /> sodipodi:nodetypes="csssssssssssssssssssssssccsssssssss"/>
<path <path
style="fill:url(#linearGradient4847);stroke:#000006;stroke-width:0.26458332;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill-opacity:1" style="fill:url(#linearGradient4847);stroke:#000006;stroke-width:0.26458332;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill-opacity:1"
id="path4669-8" id="path4669-8"
d="m 9.128125,290.3854 c 0,0.0747 -0.088061,0.13409 -0.1632469,0.13394 l -1.0270319,-0.002 c -0.075309,-1.6e-4 -0.1284816,-0.0596 -0.1285795,-0.13434 l -0.00207,-1.57833 c -9.78e-5,-0.0747 -0.059594,-0.13424 -0.1347806,-0.13434 l -6.3458527,-0.008 c -0.075186,-10e-5 -0.1364114,0.0616 -0.1364114,0.13641 v 4.50463 c 0,0.0747 0.061225,0.13641 0.1364114,0.13641 H 15.596683 c 0.07533,0 0.136309,-0.0616 0.136412,-0.13641 l 0.0062,-4.50463 c 1.03e-4,-0.0747 -0.05178,-0.13015 -0.12711,-0.13021 l -6.3489103,-0.005 c -0.075186,-5e-5 -0.1352525,0.0558 -0.135241,0.13057 l 2.355e-4,1.5273 z" d="m 9.128125,290.3854 c 0,0.0747 -0.088061,0.13409 -0.1632469,0.13394 l -1.0270319,-0.002 c -0.075309,-1.6e-4 -0.1284816,-0.0596 -0.1285795,-0.13434 l -0.00207,-1.57833 c -9.78e-5,-0.0747 -0.059594,-0.13424 -0.1347806,-0.13434 l -6.3458527,-0.008 c -0.075186,-10e-5 -0.1364114,0.0616 -0.1364114,0.13641 v 4.50463 c 0,0.0747 0.061225,0.13641 0.1364114,0.13641 H 15.596683 c 0.07533,0 0.136309,-0.0616 0.136412,-0.13641 l 0.0062,-4.50463 c 1.03e-4,-0.0747 -0.05178,-0.13015 -0.12711,-0.13021 l -6.3489103,-0.005 c -0.075186,-5e-5 -0.1352525,0.0558 -0.135241,0.13057 l 2.355e-4,1.5273 z"
inkscape:connector-curvature="0" inkscape:connector-curvature="0"
sodipodi:nodetypes="cssssssssssssssscc" /> sodipodi:nodetypes="cssssssssssssssscc"/>
<path <path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.49032259" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.49032259"
d="m 1.4552083,286.15207 v 1.5875" d="m 1.4552083,286.15207 v 1.5875"
id="path4799" id="path4799"
inkscape:connector-curvature="0" inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" /> sodipodi:nodetypes="cc"/>
<path <path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.49516129" style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.49516129"
d="M 5.5562499,283.90311 H 11.377083" d="M 5.5562499,283.90311 H 11.377083"
id="path4809" id="path4809"
inkscape:connector-curvature="0" /> inkscape:connector-curvature="0"/>
<path <path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.4983871" style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.4983871"
d="M 9.2604166,288.93019 H 15.610416" d="M 9.2604166,288.93019 H 15.610416"
id="path4815" id="path4815"
inkscape:connector-curvature="0" /> inkscape:connector-curvature="0"/>
<path <path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.5032258" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.5032258"
d="m 15.478125,289.06248 v 3.96875" d="m 15.478125,289.06248 v 3.96875"
id="path4817" id="path4817"
inkscape:connector-curvature="0" /> inkscape:connector-curvature="0"/>
<path <path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.74354839" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.74354839"
d="M 15.610416,293.16352 H 1.3229166" d="M 15.610416,293.16352 H 1.3229166"
id="path4819" id="path4819"
inkscape:connector-curvature="0" /> inkscape:connector-curvature="0"/>
<path <path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.5016129" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.5016129"
d="m 1.4552083,293.03123 v -3.96875" d="m 1.4552083,293.03123 v -3.96875"
id="path4821" id="path4821"
inkscape:connector-curvature="0" /> inkscape:connector-curvature="0"/>
<path <path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.76129031" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.76129031"
d="m 1.3229166,287.87186 h 6.2177083 v -0.39688 c 0.046835,-0.19876 0.1523728,-0.35185 0.396875,-0.39687 h 1.0583333 c 0.203798,0.046 0.3525696,0.15839 0.396875,0.39687 v 0.39688 h 6.2177078" d="m 1.3229166,287.87186 h 6.2177083 v -0.39688 c 0.046835,-0.19876 0.1523728,-0.35185 0.396875,-0.39687 h 1.0583333 c 0.203798,0.046 0.3525696,0.15839 0.396875,0.39687 v 0.39688 h 6.2177078"
id="path4823" id="path4823"
inkscape:connector-curvature="0" inkscape:connector-curvature="0"
sodipodi:nodetypes="cccccccc" /> sodipodi:nodetypes="cccccccc"/>
<path <path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.47903225" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.47903225"
d="m 15.478125,286.15207 v 1.5875" d="m 15.478125,286.15207 v 1.5875"
id="path4825" id="path4825"
inkscape:connector-curvature="0" /> inkscape:connector-curvature="0"/>
<path <path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.52741933" style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.52741933"
d="m 1.3229166,288.93019 h 6.35" d="m 1.3229166,288.93019 h 6.35"
id="path4849" id="path4849"
inkscape:connector-curvature="0" /> inkscape:connector-curvature="0"/>
<path <path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.5016129" style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.5016129"
d="m 7.5406249,290.33248 c 0.053822,0.16463 0.1162818,0.32765 0.396875,0.44979 h 1.0583333 c 0.2656949,-0.11387 0.3463096,-0.27777 0.396875,-0.44979" d="m 7.5406249,290.33248 c 0.053822,0.16463 0.1162818,0.32765 0.396875,0.44979 h 1.0583333 c 0.2656949,-0.11387 0.3463096,-0.27777 0.396875,-0.44979"
id="path4851" id="path4851"
inkscape:connector-curvature="0" inkscape:connector-curvature="0"
sodipodi:nodetypes="cccc" /> sodipodi:nodetypes="cccc"/>
<path <path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.49354839" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.49354839"
d="m 7.5406249,289.06248 v 1.32292" d="m 7.5406249,289.06248 v 1.32292"
id="path4853" id="path4853"
inkscape:connector-curvature="0" /> inkscape:connector-curvature="0"/>
<path <path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.50645161" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.50645161"
d="m 9.3927082,289.06248 v 1.32292" d="m 9.3927082,289.06248 v 1.32292"
id="path4855" id="path4855"
inkscape:connector-curvature="0" /> inkscape:connector-curvature="0"/>
<path <path
style="fill:none;fill-rule:evenodd;stroke:#ffffef;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.47903227" style="fill:none;fill-rule:evenodd;stroke:#ffffef;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.47903227"
d="m 1.3229166,286.01977 h 3.96875 c 0.3141845,-0.0698 0.3341114,-0.24069 0.396875,-0.39687" d="m 1.3229166,286.01977 h 3.96875 c 0.3141845,-0.0698 0.3341114,-0.24069 0.396875,-0.39687"
id="path4857" id="path4857"
inkscape:connector-curvature="0" inkscape:connector-curvature="0"
sodipodi:nodetypes="ccc" /> sodipodi:nodetypes="ccc"/>
<path <path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.49677423" style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.49677423"
d="m 6.2177083,285.6229 c 0.072285,0.16809 0.1030371,0.34858 0.396875,0.39687 H 10.31875 c 0.179896,-0.0515 0.345856,-0.12665 0.396875,-0.39687" d="m 6.2177083,285.6229 c 0.072285,0.16809 0.1030371,0.34858 0.396875,0.39687 H 10.31875 c 0.179896,-0.0515 0.345856,-0.12665 0.396875,-0.39687"
id="path4859" id="path4859"
inkscape:connector-curvature="0" inkscape:connector-curvature="0"
sodipodi:nodetypes="cccc" /> sodipodi:nodetypes="cccc"/>
<path <path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.5" style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.5"
d="m 11.244792,285.6229 c 0.04778,0.19396 0.146343,0.35086 0.396875,0.39687 h 3.968749" d="m 11.244792,285.6229 c 0.04778,0.19396 0.146343,0.35086 0.396875,0.39687 h 3.968749"
id="path4861" id="path4861"
inkscape:connector-curvature="0" inkscape:connector-curvature="0"
sodipodi:nodetypes="ccc" /> sodipodi:nodetypes="ccc"/>
<path <path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.75" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.75"
d="m 6.2177083,284.56457 c 0.078702,-0.13995 0.033329,-0.29762 0.3968749,-0.39688 H 10.31875 c 0.244504,0.045 0.35004,0.19812 0.396875,0.39688" d="m 6.2177083,284.56457 c 0.078702,-0.13995 0.033329,-0.29762 0.3968749,-0.39688 H 10.31875 c 0.244504,0.045 0.35004,0.19812 0.396875,0.39688"
id="path4863" id="path4863"
inkscape:connector-curvature="0" inkscape:connector-curvature="0"
sodipodi:nodetypes="cccc" /> sodipodi:nodetypes="cccc"/>
<path <path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.49516129" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.49516129"
d="m 5.6885416,284.0354 v 1.5875" d="m 5.6885416,284.0354 v 1.5875"
id="path4865" id="path4865"
inkscape:connector-curvature="0" /> inkscape:connector-curvature="0"/>
<path <path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.49516129" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.49516129"
d="m 6.2177083,284.56457 v 1.05833" d="m 6.2177083,284.56457 v 1.05833"
id="path4867" id="path4867"
inkscape:connector-curvature="0" /> inkscape:connector-curvature="0"/>
<path <path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.49516129" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.49516129"
d="m 10.715625,284.56457 v 1.05833" d="m 10.715625,284.56457 v 1.05833"
id="path4869" id="path4869"
inkscape:connector-curvature="0" /> inkscape:connector-curvature="0"/>
<path <path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.48387095" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.48387095"
d="m 11.244792,284.0354 v 1.5875" d="m 11.244792,284.0354 v 1.5875"
id="path4871" id="path4871"
inkscape:connector-curvature="0" /> inkscape:connector-curvature="0"/>
</g> </g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -23,8 +23,11 @@ namespace VAR.Toolbox
string executingAssemblyPath = Assembly.GetExecutingAssembly().Location; string executingAssemblyPath = Assembly.GetExecutingAssembly().Location;
string dirName = Path.GetDirectoryName(executingAssemblyPath); string dirName = Path.GetDirectoryName(executingAssemblyPath);
string execName = Path.GetFileNameWithoutExtension(executingAssemblyPath); string execName = Path.GetFileNameWithoutExtension(executingAssemblyPath);
string[] assemblyPaths = Directory.GetFiles(dirName, string.Format("{0}*.dll", execName)); if (dirName != null)
foreach (string assemblyPath in assemblyPaths) { AssemblyLoadFull(assemblyPath); } {
string[] assemblyPaths = Directory.GetFiles(dirName, $"{execName}*.dll");
foreach (string assemblyPath in assemblyPaths) { AssemblyLoadFull(assemblyPath); }
}
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
@@ -45,19 +48,25 @@ namespace VAR.Toolbox
Application.Exit(); Application.Exit();
} }
private static Assembly AssemblyLoadFull(string fullPath, List<string> allAssemblyNames = null) private static void AssemblyLoadFull(string fullPath, List<string> allAssemblyNames = null)
{ {
if (allAssemblyNames == null) if (allAssemblyNames == null)
{ {
allAssemblyNames = AppDomain.CurrentDomain.GetAssemblies().Select(a => a.GetName().Name).ToList(); allAssemblyNames = AppDomain.CurrentDomain.GetAssemblies().Select(a => a.GetName().Name).ToList();
} }
Assembly asm = null; Assembly asm = null;
try try
{ {
asm = Assembly.LoadFrom(fullPath); asm = Assembly.LoadFrom(fullPath);
} }
catch (Exception) { } catch (Exception)
if (asm == null) { return null; } {
// ignored
}
if (asm == null) { return; }
allAssemblyNames.Add(asm.GetName().Name); allAssemblyNames.Add(asm.GetName().Name);
// Load dependencies // Load dependencies
@@ -67,13 +76,10 @@ namespace VAR.Toolbox
{ {
if (allAssemblyNames.Contains(asmName.Name) == false) if (allAssemblyNames.Contains(asmName.Name) == false)
{ {
string fullPathAux = string.Format("{0}/{1}.dll", dirPath, asmName.Name); string fullPathAux = $"{dirPath}/{asmName.Name}.dll";
Assembly asmAux = AssemblyLoadFull(fullPathAux, allAssemblyNames); AssemblyLoadFull(fullPathAux, allAssemblyNames);
} }
} }
return asm;
} }
} }
} }

View File

@@ -12,4 +12,4 @@ using System.Runtime.InteropServices;
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
[assembly: Guid("e8dab98d-4fd0-4d40-b29a-62b4c2fca4d7")] [assembly: Guid("e8dab98d-4fd0-4d40-b29a-62b4c2fca4d7")]
[assembly: AssemblyVersion("1.0.0.*")] [assembly: AssemblyVersion("1.0.0.*")]

View File

@@ -11,20 +11,20 @@ namespace VAR.Toolbox.UI
public string Title public string Title
{ {
get { return base.Text; } get => base.Text;
set { Text = value; } set => Text = value;
} }
public string Description public string Description
{ {
get { return lblDescription.Text; } get => lblDescription.Text;
set { lblDescription.Text = value; } set => lblDescription.Text = value;
} }
public string Value public string Value
{ {
get { return txtValue.Text; } get => txtValue.Text;
set { txtValue.Text = value; } set => txtValue.Text = value;
} }
} }
} }

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using VAR.Toolbox.Controls; using VAR.Toolbox.Controls;
@@ -13,20 +14,17 @@ namespace VAR.Toolbox.UI
public string Title public string Title
{ {
get { return base.Text; } get => base.Text;
set { Text = value; } set => Text = value;
} }
public void LoadItems(List<string> items) public void LoadItems(List<string> items)
{ {
lsbItems.Items.Clear(); lsbItems.Items.Clear();
lsbItems.Items.AddRange(items.ToArray()); lsbItems.Items.AddRange(items.ToArray<object>());
} }
public string Value public string Value => (lsbItems.SelectedItem as string) ?? string.Empty;
{
get { return (lsbItems.SelectedItem as string) ?? string.Empty; }
}
private void lsbItems_SelectedIndexChanged(object sender, System.EventArgs e) private void lsbItems_SelectedIndexChanged(object sender, System.EventArgs e)
{ {
@@ -34,4 +32,4 @@ namespace VAR.Toolbox.UI
Close(); Close();
} }
} }
} }

View File

@@ -5,7 +5,6 @@ using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using VAR.Toolbox.Code; using VAR.Toolbox.Code;
using VAR.Toolbox.Code.Windows; using VAR.Toolbox.Code.Windows;
using VAR.Toolbox.Controls; using VAR.Toolbox.Controls;
@@ -16,14 +15,14 @@ namespace VAR.Toolbox.UI
{ {
#region Declarations #region Declarations
private bool _closing = false; private bool _closing;
private Label lblToolbox; private Label _lblToolbox;
private CButton btnExit; private CButton _btnExit;
private NotifyIcon niTray = null; private NotifyIcon _niTray;
private static FrmToolbox _currentInstance = null; private static FrmToolbox _currentInstance;
#endregion Declarations #endregion Declarations
@@ -39,7 +38,7 @@ namespace VAR.Toolbox.UI
{ {
Icon ico = Icon.ExtractAssociatedIcon(Application.ExecutablePath); Icon ico = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
Icon = ico; Icon = ico;
niTray.Icon = ico; _niTray.Icon = ico;
} }
protected override void OnFormClosing(FormClosingEventArgs e) protected override void OnFormClosing(FormClosingEventArgs e)
@@ -74,7 +73,7 @@ namespace VAR.Toolbox.UI
if (dialogResult == DialogResult.Yes) if (dialogResult == DialogResult.Yes)
{ {
_closing = true; _closing = true;
niTray.Visible = false; _niTray.Visible = false;
CloseChildWindows(); CloseChildWindows();
Close(); Close();
} }
@@ -102,18 +101,18 @@ namespace VAR.Toolbox.UI
private void InitializeDynamicComponents() private void InitializeDynamicComponents()
{ {
SuspendLayout(); SuspendLayout();
const int toolSpacing = 5; const int ToolSpacing = 5;
const int toolWidth = 200; const int ToolWidth = 200;
const int windowSpacing = 10; const int WindowSpacing = 10;
int nextYLocation = 0;
// Get list of ToolForms // Get list of ToolForms
Type iToolForm = typeof(IToolForm); Type iToolForm = typeof(IToolForm);
IEnumerable<Type> toolFormTypes = ReflectionUtils.GetTypesOfInterface(iToolForm); IEnumerable<Type> toolFormTypes = ReflectionUtils.GetTypesOfInterface(iToolForm);
Dictionary<string, Type> dictToolFormTypes = toolFormTypes.ToDictionary(t => Dictionary<string, Type> dictToolFormTypes = toolFormTypes.ToDictionary(t =>
{ {
IToolForm toolForm = System.Runtime.Serialization.FormatterServices.GetUninitializedObject(t) as IToolForm; IToolForm toolForm =
return toolForm.ToolName; System.Runtime.Serialization.FormatterServices.GetUninitializedObject(t) as IToolForm;
return toolForm?.ToolName ?? t.Name;
}); });
// Get list of ToolPanels // Get list of ToolPanels
@@ -121,27 +120,28 @@ namespace VAR.Toolbox.UI
IEnumerable<Type> toolPanelTypes = ReflectionUtils.GetTypesOfInterface(iToolPanel).OrderBy(t => t.Name); IEnumerable<Type> toolPanelTypes = ReflectionUtils.GetTypesOfInterface(iToolPanel).OrderBy(t => t.Name);
// lblToolbox // lblToolbox
lblToolbox = new Label _lblToolbox = new Label
{ {
Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right), Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right),
Font = new Font(Font.FontFamily, ControlsUtils.GetFontSize(this, 27.75F), FontStyle.Bold, GraphicsUnit.Point, 0), Font = new Font(Font.FontFamily, ControlsUtils.GetFontSize(this, 27.75F), FontStyle.Bold,
Location = new Point(windowSpacing, windowSpacing), GraphicsUnit.Point, 0),
Location = new Point(WindowSpacing, WindowSpacing),
Margin = new Padding(0, 0, 0, 0), Margin = new Padding(0, 0, 0, 0),
Name = "lblToolbox", Name = "lblToolbox",
Size = new Size(toolWidth * 2 + toolSpacing, 50), Size = new Size(ToolWidth * 2 + ToolSpacing, 50),
TabIndex = 6, TabIndex = 6,
Text = "Toolbox", Text = "Toolbox",
TextAlign = ContentAlignment.MiddleCenter TextAlign = ContentAlignment.MiddleCenter
}; };
lblToolbox.MouseDown += DragWindow_MouseDown; _lblToolbox.MouseDown += DragWindow_MouseDown;
nextYLocation = lblToolbox.Location.Y + lblToolbox.Size.Height + windowSpacing; int nextYLocation = _lblToolbox.Location.Y + _lblToolbox.Size.Height + WindowSpacing;
// Tool buttons // Tool buttons
int idxButton = 0; int idxButton = 0;
int xStartButtons = windowSpacing; int xStartButtons = WindowSpacing;
int xStepButtons = toolWidth + toolSpacing; int xStepButtons = ToolWidth + ToolSpacing;
int yStartButtons = nextYLocation; int yStartButtons = nextYLocation;
int yStepButtons = 40 + toolSpacing; int yStepButtons = 40 + ToolSpacing;
IEnumerable<KeyValuePair<string, Type>> sortedToolForms = dictToolFormTypes.OrderBy(p => p.Key); IEnumerable<KeyValuePair<string, Type>> sortedToolForms = dictToolFormTypes.OrderBy(p => p.Key);
foreach (KeyValuePair<string, Type> p in sortedToolForms) foreach (KeyValuePair<string, Type> p in sortedToolForms)
{ {
@@ -150,15 +150,15 @@ namespace VAR.Toolbox.UI
CButton btn = new CButton CButton btn = new CButton
{ {
Location = new Point(x, y), Location = new Point(x, y),
Name = string.Format("btn{0}", p.Key), Name = $"btn{p.Key}",
Size = new Size(toolWidth, 40), Size = new Size(ToolWidth, 40),
TabIndex = idxButton, TabIndex = idxButton,
Text = p.Key, Text = p.Key,
}; };
btn.Click += (s, e) => { CreateWindow(p.Value); }; btn.Click += (s, e) => { CreateWindow(p.Value); };
Controls.Add(btn); Controls.Add(btn);
nextYLocation = btn.Location.Y + btn.Size.Height + windowSpacing; nextYLocation = btn.Location.Y + btn.Size.Height + WindowSpacing;
idxButton++; idxButton++;
} }
@@ -166,48 +166,51 @@ namespace VAR.Toolbox.UI
// Tool panels // Tool panels
int idxPanel = 0; int idxPanel = 0;
int yStartPanels = nextYLocation; int yStartPanels = nextYLocation;
int xStartPanels = windowSpacing; int xStartPanels = WindowSpacing;
int xNextPanels = xStartPanels; int xNextPanels = xStartPanels;
foreach (Type t in toolPanelTypes) foreach (Type t in toolPanelTypes)
{ {
ContainerControl pnl = Activator.CreateInstance(t) as ContainerControl; ContainerControl pnl = Activator.CreateInstance(t) as ContainerControl;
if (pnl == null) { continue; } if (pnl == null) { continue; }
pnl.Location = new Point(xNextPanels, yStartPanels); pnl.Location = new Point(xNextPanels, yStartPanels);
Controls.Add(pnl); Controls.Add(pnl);
int tempNextYLocation = pnl.Location.Y + pnl.Size.Height + windowSpacing; int tempNextYLocation = pnl.Location.Y + pnl.Size.Height + WindowSpacing;
if (nextYLocation < tempNextYLocation) if (nextYLocation < tempNextYLocation)
{ {
nextYLocation = tempNextYLocation; nextYLocation = tempNextYLocation;
} }
xNextPanels = pnl.Location.X + pnl.Size.Width + toolSpacing;
xNextPanels = pnl.Location.X + pnl.Size.Width + ToolSpacing;
if ((idxPanel % 2) == 1) if ((idxPanel % 2) == 1)
{ {
yStartPanels = nextYLocation; yStartPanels = nextYLocation;
xNextPanels = xStartPanels; xNextPanels = xStartPanels;
} }
idxPanel++; idxPanel++;
} }
// btnExit // btnExit
btnExit = new CButton _btnExit = new CButton
{ {
Anchor = ((AnchorStyles.Bottom | AnchorStyles.Left) Anchor = ((AnchorStyles.Bottom | AnchorStyles.Left)
| AnchorStyles.Right), | AnchorStyles.Right),
Location = new Point(windowSpacing, nextYLocation), Location = new Point(WindowSpacing, nextYLocation),
Name = "btnExit", Name = "btnExit",
Size = new Size(toolWidth * 2 + toolSpacing, 40), Size = new Size(ToolWidth * 2 + ToolSpacing, 40),
TabIndex = 7, TabIndex = 7,
Text = "Exit", Text = "Exit",
}; };
btnExit.Click += BtnExit_Click; _btnExit.Click += BtnExit_Click;
nextYLocation = btnExit.Location.Y + btnExit.Size.Height + windowSpacing; nextYLocation = _btnExit.Location.Y + _btnExit.Size.Height + WindowSpacing;
// FrmToolbox // FrmToolbox
ClientSize = new Size(425, nextYLocation); ClientSize = new Size(425, nextYLocation);
Controls.Add(btnExit); Controls.Add(_btnExit);
Controls.Add(lblToolbox); Controls.Add(_lblToolbox);
FormBorderStyle = FormBorderStyle.Fixed3D; FormBorderStyle = FormBorderStyle.Fixed3D;
MaximizeBox = false; MaximizeBox = false;
Name = "FrmToolbox"; Name = "FrmToolbox";
@@ -219,12 +222,12 @@ namespace VAR.Toolbox.UI
ResumeLayout(false); ResumeLayout(false);
// niTray // niTray
niTray = new NotifyIcon _niTray = new NotifyIcon
{ {
Text = "VAR.Toolbox", Text = "VAR.Toolbox",
Visible = true Visible = true
}; };
niTray.MouseClick += NiTray_MouseClick; _niTray.MouseClick += NiTray_MouseClick;
ResumeLayout(); ResumeLayout();
@@ -234,21 +237,22 @@ namespace VAR.Toolbox.UI
#region Window handling #region Window handling
private Form CreateWindow(Type type) private void CreateWindow(Type type)
{ {
var frm = Activator.CreateInstance(type) as Form; var frm = Activator.CreateInstance(type) as Form;
if (frm == null) if (frm == null)
{ {
return null; return;
} }
_forms.Add(frm); _forms.Add(frm);
frm.FormClosing += FrmChild_FormClosing; frm.FormClosing += FrmChild_FormClosing;
if ((frm as IToolForm)?.HasIcon == false) if ((frm as IToolForm)?.HasIcon == false)
{ {
frm.Icon = Icon; frm.Icon = Icon;
} }
frm.Show(); frm.Show();
return frm;
} }
private readonly List<Form> _forms = new List<Form>(); private readonly List<Form> _forms = new List<Form>();
@@ -263,7 +267,7 @@ namespace VAR.Toolbox.UI
CloseChildWindows(); CloseChildWindows();
} }
private bool _wasMinimized = false; private bool _wasMinimized;
private void FrmToolbox_Resize(object sender, EventArgs e) private void FrmToolbox_Resize(object sender, EventArgs e)
{ {
@@ -272,6 +276,7 @@ namespace VAR.Toolbox.UI
_wasMinimized = true; _wasMinimized = true;
HideChildWindows(); HideChildWindows();
} }
if (FormWindowState.Normal == WindowState && _wasMinimized) if (FormWindowState.Normal == WindowState && _wasMinimized)
{ {
_wasMinimized = false; _wasMinimized = false;
@@ -312,6 +317,7 @@ namespace VAR.Toolbox.UI
{ {
List<T> list = new List<T>(); List<T> list = new List<T>();
if (_currentInstance == null) { return list; } if (_currentInstance == null) { return list; }
foreach (Form frm in _currentInstance._forms) foreach (Form frm in _currentInstance._forms)
{ {
if (frm is T) if (frm is T)
@@ -319,10 +325,10 @@ namespace VAR.Toolbox.UI
list.Add((T)(object)frm); list.Add((T)(object)frm);
} }
} }
return list; return list;
} }
#endregion Window handling #endregion Window handling
} }
} }

View File

@@ -5,4 +5,4 @@
string ToolName { get; } string ToolName { get; }
bool HasIcon { get; } bool HasIcon { get; }
} }
} }

View File

@@ -1,6 +1,4 @@
namespace VAR.Toolbox.UI namespace VAR.Toolbox.UI
{ {
public interface IToolPanel public interface IToolPanel { }
{ }
}
}

View File

@@ -1,4 +1,4 @@
namespace VAR.Toolbox.UI namespace VAR.Toolbox.UI.Tools
{ {
partial class FrmCoder partial class FrmCoder
{ {

View File

@@ -1,25 +1,26 @@
using System; using System;
using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using VAR.Toolbox.Code.TextCoders; using VAR.Toolbox.Code.TextCoders;
using VAR.Toolbox.Controls; using VAR.Toolbox.Controls;
namespace VAR.Toolbox.UI namespace VAR.Toolbox.UI.Tools
{ {
public partial class FrmCoder : Frame, IToolForm public partial class FrmCoder : Frame, IToolForm
{ {
public string ToolName { get { return "Coder"; } } public string ToolName => "Coder";
public bool HasIcon { get { return false; } } public bool HasIcon => false;
public FrmCoder() public FrmCoder()
{ {
InitializeComponent(); InitializeComponent();
cboCode.Items.AddRange(TextCoderFactory.GetNames()); cboCode.Items.AddRange(TextCoderFactory.GetNames().ToArray<object>());
cboCode.SelectedIndex = 1; cboCode.SelectedIndex = 1;
} }
private ITextCoder _coder = null; private ITextCoder _coder;
private void BtnDecode_Click(object sender, EventArgs e) private void BtnDecode_Click(object sender, EventArgs e)
{ {
@@ -32,6 +33,7 @@ namespace VAR.Toolbox.UI
{ {
MessageBox.Show(ex.Message); MessageBox.Show(ex.Message);
} }
txtOutput.Text = output; txtOutput.Text = output;
} }
@@ -46,14 +48,13 @@ namespace VAR.Toolbox.UI
{ {
MessageBox.Show(ex.Message); MessageBox.Show(ex.Message);
} }
txtOutput.Text = output; txtOutput.Text = output;
} }
private void BtnSwap_Click(object sender, EventArgs e) private void BtnSwap_Click(object sender, EventArgs e)
{ {
string temp = txtOutput.Text; (txtOutput.Text, txtInput.Text) = (txtInput.Text, txtOutput.Text);
txtOutput.Text = txtInput.Text;
txtInput.Text = temp;
} }
private void CboCode_SelectedIndexChanged(object sender, EventArgs e) private void CboCode_SelectedIndexChanged(object sender, EventArgs e)
@@ -63,4 +64,4 @@ namespace VAR.Toolbox.UI
txtKey.Enabled = _coder.NeedsKey; txtKey.Enabled = _coder.NeedsKey;
} }
} }
} }

View File

@@ -5,7 +5,7 @@ using VAR.Toolbox.Code;
using VAR.Toolbox.Code.Windows; using VAR.Toolbox.Code.Windows;
using VAR.Toolbox.Controls; using VAR.Toolbox.Controls;
namespace VAR.Toolbox.UI namespace VAR.Toolbox.UI.Tools
{ {
public class FrmCover : Frame public class FrmCover : Frame
{ {
@@ -14,14 +14,19 @@ namespace VAR.Toolbox.UI
private readonly Random _rnd = new Random(); private readonly Random _rnd = new Random();
private readonly Timer _timer = new Timer(); private readonly Timer _timer = new Timer();
private readonly uint _mouseX = 0; private uint _mouseX;
private readonly uint _mouseY = 0; private uint _mouseY;
#endregion Declarations #endregion Declarations
#region Form life cycle #region Form life cycle
public FrmCover() public FrmCover()
{
InitializeComponent();
}
private void InitializeComponent()
{ {
Mouse.GetPosition(out _mouseX, out _mouseY); Mouse.GetPosition(out _mouseX, out _mouseY);
@@ -47,6 +52,7 @@ namespace VAR.Toolbox.UI
{ {
r = Rectangle.Union(r, s.Bounds); r = Rectangle.Union(r, s.Bounds);
} }
Top = r.Top; Top = r.Top;
Left = r.Left; Left = r.Left;
Width = r.Width; Width = r.Width;
@@ -91,7 +97,11 @@ namespace VAR.Toolbox.UI
(_rnd.Next() % 11) - 5, (_rnd.Next() % 11) - 5,
(_rnd.Next() % 11) - 5); (_rnd.Next() % 11) - 5);
} }
catch (Exception) { } // ignore exceptions moving mouse catch (Exception)
{
// ignored exceptions moving mouse
}
_timer.Stop(); _timer.Stop();
_timer.Start(); _timer.Start();
} }

View File

@@ -1,4 +1,4 @@
namespace VAR.Toolbox.UI namespace VAR.Toolbox.UI.Tools
{ {
partial class FrmIPScan partial class FrmIPScan
{ {

View File

@@ -6,13 +6,13 @@ using System.Threading;
using System.Windows.Forms; using System.Windows.Forms;
using VAR.Toolbox.Controls; using VAR.Toolbox.Controls;
namespace VAR.Toolbox.UI namespace VAR.Toolbox.UI.Tools
{ {
public partial class FrmIPScan : Frame, IToolForm public partial class FrmIPScan : Frame, IToolForm
{ {
public string ToolName { get { return "IPScan"; } } public string ToolName => "IPScan";
public bool HasIcon { get { return false; } } public bool HasIcon => false;
public FrmIPScan() public FrmIPScan()
{ {
@@ -24,19 +24,20 @@ namespace VAR.Toolbox.UI
private void FrmIPScan_Disposed(object sender, EventArgs e) private void FrmIPScan_Disposed(object sender, EventArgs e)
{ {
running = false; _running = false;
} }
private void PrintStatus(string status) private void PrintStatus(string status)
{ {
if (lblStatus.IsDisposed) { return; } if (lblStatus.IsDisposed) { return; }
if (lblStatus.InvokeRequired) if (lblStatus.InvokeRequired)
{ {
lblStatus.Invoke((MethodInvoker)(() => { lblStatus.Text = string.Format("Status: {0}", status); })); lblStatus.Invoke((MethodInvoker)(() => { lblStatus.Text = $"Status: {status}"; }));
} }
else else
{ {
lblStatus.Text = string.Format("Status: {0}", status); lblStatus.Text = $"Status: {status}";
Application.DoEvents(); Application.DoEvents();
} }
} }
@@ -44,6 +45,7 @@ namespace VAR.Toolbox.UI
private void Control_SetEnabled(Control ctrl, bool enabled) private void Control_SetEnabled(Control ctrl, bool enabled)
{ {
if (ctrl.IsDisposed) { return; } if (ctrl.IsDisposed) { return; }
if (ctrl.InvokeRequired) if (ctrl.InvokeRequired)
{ {
ctrl.Invoke((MethodInvoker)(() => { ctrl.Enabled = enabled; })); ctrl.Invoke((MethodInvoker)(() => { ctrl.Enabled = enabled; }));
@@ -63,23 +65,23 @@ namespace VAR.Toolbox.UI
private void BtnStop_Click(object sender, EventArgs e) private void BtnStop_Click(object sender, EventArgs e)
{ {
running = false; _running = false;
} }
private bool running = false; private bool _running;
private void IPScan(string ipBase) private void IPScan(string ipBase)
{ {
Control_SetEnabled(btnScan, false); Control_SetEnabled(btnScan, false);
running = true; _running = true;
ctrOutput.AddLine(string.Format("IPScan started at {0}", DateTime.UtcNow.ToString("s"))); ctrOutput.AddLine($"IPScan started at {DateTime.UtcNow:s}");
for (int i = 1; i < 255 && running; i++) for (int i = 1; i < 255 && _running; i++)
{ {
string ip = ipBase + i.ToString(); string ip = ipBase + i.ToString();
PrintStatus(string.Format("Scanning {0}", ip)); PrintStatus($"Scanning {ip}");
Ping p = new Ping(); Ping p = new Ping();
PingReply pingReply = p.Send(ip, 100); PingReply pingReply = p.Send(ip, 100);
if (pingReply.Status == IPStatus.Success) if (pingReply != null && pingReply.Status == IPStatus.Success)
{ {
string name = "?"; string name = "?";
try try
@@ -88,14 +90,16 @@ namespace VAR.Toolbox.UI
name = hostEntry.HostName; name = hostEntry.HostName;
} }
catch (SocketException) { } catch (SocketException) { }
ctrOutput.AddLine(string.Format("{0} ({1}) is up: ({2} ms)", ip, name, pingReply.RoundtripTime));
ctrOutput.AddLine($"{ip} ({name}) is up: ({pingReply.RoundtripTime} ms)");
} }
Application.DoEvents(); Application.DoEvents();
} }
PrintStatus("Idle"); PrintStatus("Idle");
ctrOutput.AddLine(string.Format("IPScan ended at {0}", DateTime.UtcNow.ToString("s"))); ctrOutput.AddLine($"IPScan ended at {DateTime.UtcNow:s}");
Control_SetEnabled(btnScan, true); Control_SetEnabled(btnScan, true);
} }
} }
} }

View File

@@ -1,4 +1,4 @@
namespace VAR.Toolbox.UI namespace VAR.Toolbox.UI.Tools
{ {
partial class FrmNetworkInfo partial class FrmNetworkInfo
{ {

View File

@@ -7,13 +7,13 @@ using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using VAR.Toolbox.Controls; using VAR.Toolbox.Controls;
namespace VAR.Toolbox.UI namespace VAR.Toolbox.UI.Tools
{ {
public partial class FrmNetworkInfo : Frame, IToolForm public partial class FrmNetworkInfo : Frame, IToolForm
{ {
public string ToolName { get { return "NetworkInfo"; } } public string ToolName => "NetworkInfo";
public bool HasIcon { get { return false; } } public bool HasIcon => false;
public FrmNetworkInfo() public FrmNetworkInfo()
{ {
@@ -39,6 +39,7 @@ namespace VAR.Toolbox.UI
{ {
var listItem = ddlNetworkInterfaces.SelectedItem as ListItem; var listItem = ddlNetworkInterfaces.SelectedItem as ListItem;
if (listItem == null) { return; } if (listItem == null) { return; }
RefreshInterface(listItem.ID); RefreshInterface(listItem.ID);
} }
@@ -59,9 +60,11 @@ namespace VAR.Toolbox.UI
{ {
found = true; found = true;
if (it.Text != nic.Description) { it.Text = nic.Description; } if (it.Text != nic.Description) { it.Text = nic.Description; }
break; break;
} }
} }
if (found == false) if (found == false)
{ {
ddlNetworkInterfaces.Items.Add(new ListItem { ID = nic.Id, Text = nic.Description }); ddlNetworkInterfaces.Items.Add(new ListItem { ID = nic.Id, Text = nic.Description });
@@ -69,7 +72,7 @@ namespace VAR.Toolbox.UI
} }
} }
private string _networkInterfaceId = null; private string _networkInterfaceId;
private void RefreshInterface() private void RefreshInterface()
{ {
@@ -92,16 +95,23 @@ namespace VAR.Toolbox.UI
private void RefreshInterface(NetworkInterface nic) private void RefreshInterface(NetworkInterface nic)
{ {
if (txtID.Text != nic.Id) { txtID.Text = nic.Id; } if (txtID.Text != nic.Id) { txtID.Text = nic.Id; }
if (txtName.Text != nic.Name) { txtName.Text = nic.Name; } if (txtName.Text != nic.Name) { txtName.Text = nic.Name; }
string status = nic.OperationalStatus.ToString(); string status = nic.OperationalStatus.ToString();
if (txtStatus.Text != status) { txtStatus.Text = status; } if (txtStatus.Text != status) { txtStatus.Text = status; }
string speed = FormatNetworkSpeedUnits(nic.Speed); string speed = FormatNetworkSpeedUnits(nic.Speed);
if (txtSpeed.Text != speed) { txtSpeed.Text = speed; } if (txtSpeed.Text != speed) { txtSpeed.Text = speed; }
if (txtDescription.Text != nic.Description) { txtDescription.Text = nic.Description; } if (txtDescription.Text != nic.Description) { txtDescription.Text = nic.Description; }
string strInterface = nic.NetworkInterfaceType.ToString(); string strInterface = nic.NetworkInterfaceType.ToString();
if (txtInterface.Text != strInterface) { txtInterface.Text = strInterface; } if (txtInterface.Text != strInterface) { txtInterface.Text = strInterface; }
string strMac = FormatPhysicalAddress(nic.GetPhysicalAddress().GetAddressBytes()); string strMac = FormatPhysicalAddress(nic.GetPhysicalAddress().GetAddressBytes());
if (txtMAC.Text != strMac) { txtMAC.Text = strMac; } if (txtMAC.Text != strMac) { txtMAC.Text = strMac; }
StringBuilder sbIPs = new StringBuilder(); StringBuilder sbIPs = new StringBuilder();
IPInterfaceProperties ipInterfaceProperties = nic.GetIPProperties(); IPInterfaceProperties ipInterfaceProperties = nic.GetIPProperties();
sbIPs.AppendLine("****** IPs *****"); sbIPs.AppendLine("****** IPs *****");
@@ -109,18 +119,21 @@ namespace VAR.Toolbox.UI
{ {
sbIPs.AppendLine(uniAddress.Address.ToString()); sbIPs.AppendLine(uniAddress.Address.ToString());
} }
sbIPs.AppendLine(); sbIPs.AppendLine();
sbIPs.AppendLine("****** Gateways *****"); sbIPs.AppendLine("****** Gateways *****");
foreach (GatewayIPAddressInformation gwAddress in ipInterfaceProperties.GatewayAddresses) foreach (GatewayIPAddressInformation gwAddress in ipInterfaceProperties.GatewayAddresses)
{ {
sbIPs.AppendLine(gwAddress.Address.ToString()); sbIPs.AppendLine(gwAddress.Address.ToString());
} }
sbIPs.AppendLine(); sbIPs.AppendLine();
sbIPs.AppendLine("****** DNSs *****"); sbIPs.AppendLine("****** DNSs *****");
foreach (IPAddress dnsAddress in ipInterfaceProperties.DnsAddresses) foreach (IPAddress dnsAddress in ipInterfaceProperties.DnsAddresses)
{ {
sbIPs.AppendLine(dnsAddress.ToString()); sbIPs.AppendLine(dnsAddress.ToString());
} }
string strIPs = sbIPs.ToString(); string strIPs = sbIPs.ToString();
if (txtIPs.Text != strIPs) { txtIPs.Text = strIPs; } if (txtIPs.Text != strIPs) { txtIPs.Text = strIPs; }
} }
@@ -128,39 +141,44 @@ namespace VAR.Toolbox.UI
private static string FormatNetworkSpeedUnits(long speed) private static string FormatNetworkSpeedUnits(long speed)
{ {
decimal dSpeed;
if (speed < 1000) if (speed < 1000)
{ {
return string.Format("{0}bps", speed); return $"{speed}bps";
} }
dSpeed = speed / (decimal)1000;
decimal dSpeed = speed / (decimal)1000;
if (dSpeed < 1000) if (dSpeed < 1000)
{ {
return string.Format("{0}kbps", Math.Round(dSpeed, 2)); return $"{Math.Round(dSpeed, 2)}kbps";
} }
dSpeed /= 1000; dSpeed /= 1000;
if (dSpeed < 1000) if (dSpeed < 1000)
{ {
return string.Format("{0}mbps", Math.Round(dSpeed, 2)); return $"{Math.Round(dSpeed, 2)}mbps";
} }
dSpeed /= 1000; dSpeed /= 1000;
if (dSpeed < 1000) if (dSpeed < 1000)
{ {
return string.Format("{0}gbps", Math.Round(dSpeed, 2)); return $"{Math.Round(dSpeed, 2)}gbps";
} }
dSpeed /= 1000; dSpeed /= 1000;
return string.Format("{0}tbps", Math.Round(dSpeed, 2)); return $"{Math.Round(dSpeed, 2)}tbps";
} }
private static string FormatPhysicalAddress(byte[] address) private static string FormatPhysicalAddress(byte[] address)
{ {
StringBuilder sbAddres = new StringBuilder(); StringBuilder sbAddress = new StringBuilder();
foreach (byte b in address) foreach (byte b in address)
{ {
if (sbAddres.Length > 0) { sbAddres.Append(":"); } if (sbAddress.Length > 0) { sbAddress.Append(":"); }
sbAddres.AppendFormat("{0:X2}", b);
sbAddress.AppendFormat("{0:X2}", b);
} }
return sbAddres.ToString();
return sbAddress.ToString();
} }
} }
@@ -169,8 +187,9 @@ namespace VAR.Toolbox.UI
public string Text { get; set; } public string Text { get; set; }
public string ID { get; set; } public string ID { get; set; }
public override string ToString() { return Text; } public override string ToString()
{
return Text;
}
} }
} }

View File

@@ -1,4 +1,4 @@
namespace VAR.Toolbox.UI namespace VAR.Toolbox.UI.Tools
{ {
partial class FrmProxyCmd partial class FrmProxyCmd
{ {

View File

@@ -2,19 +2,20 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Threading; using System.Threading;
using System.Windows.Forms; using System.Windows.Forms;
using VAR.Toolbox.Code; using VAR.Toolbox.Code;
using VAR.Toolbox.Code.ProxyCmdExecutors; using VAR.Toolbox.Code.ProxyCmdExecutors;
using VAR.Toolbox.Controls; using VAR.Toolbox.Controls;
namespace VAR.Toolbox.UI namespace VAR.Toolbox.UI.Tools
{ {
public partial class FrmProxyCmd : Frame, IOutputHandler, IToolForm public partial class FrmProxyCmd : Frame, IOutputHandler, IToolForm
{ {
public string ToolName { get { return "ProxyCmd"; } } public string ToolName => "ProxyCmd";
public bool HasIcon { get { return false; } } public bool HasIcon => false;
#region Declarations #region Declarations
@@ -45,6 +46,7 @@ namespace VAR.Toolbox.UI
Application.DoEvents(); Application.DoEvents();
return; return;
} }
if (e.KeyCode == Keys.Return) if (e.KeyCode == Keys.Return)
{ {
e.Handled = true; e.Handled = true;
@@ -58,35 +60,43 @@ namespace VAR.Toolbox.UI
PrepareProxyCmdExecutor(); PrepareProxyCmdExecutor();
new Thread(() => ExecuteCmd(cmd)).Start(); new Thread(() => ExecuteCmd(cmd)).Start();
} }
return; return;
} }
if (e.KeyCode == Keys.Enter) if (e.KeyCode == Keys.Enter)
{ {
e.Handled = true; e.Handled = true;
return; return;
} }
if (e.KeyCode == Keys.LineFeed) if (e.KeyCode == Keys.LineFeed)
{ {
e.Handled = true; e.Handled = true;
return; return;
} }
if (e.KeyCode == Keys.Up) if (e.KeyCode == Keys.Up)
{ {
e.Handled = true; e.Handled = true;
if (_currentHistoryIndex == -1) { _currentHistoryIndex = _cmdHistory.Count; } if (_currentHistoryIndex == -1) { _currentHistoryIndex = _cmdHistory.Count; }
_currentHistoryIndex--; _currentHistoryIndex--;
if (_currentHistoryIndex < 0) if (_currentHistoryIndex < 0)
{ {
_currentHistoryIndex = 0; _currentHistoryIndex = 0;
} }
if (_currentHistoryIndex >= 0 && _currentHistoryIndex < _cmdHistory.Count) if (_currentHistoryIndex >= 0 && _currentHistoryIndex < _cmdHistory.Count)
{ {
txtInput.Text = _cmdHistory[_currentHistoryIndex]; txtInput.Text = _cmdHistory[_currentHistoryIndex];
txtInput.SelectionStart = txtInput.Text.Length; txtInput.SelectionStart = txtInput.Text.Length;
txtInput.SelectionLength = 0; txtInput.SelectionLength = 0;
} }
return; return;
} }
if (e.KeyCode == Keys.Down) if (e.KeyCode == Keys.Down)
{ {
e.Handled = true; e.Handled = true;
@@ -105,7 +115,6 @@ namespace VAR.Toolbox.UI
txtInput.SelectionLength = 0; txtInput.SelectionLength = 0;
} }
} }
return;
} }
} }
@@ -123,25 +132,25 @@ namespace VAR.Toolbox.UI
#region ProxyCmdExecutor #region ProxyCmdExecutor
private IProxyCmdExecutor _proxyCmdExecutor = null; private IProxyCmdExecutor _proxyCmdExecutor;
private void PrepareProxyCmdExecutor() private void PrepareProxyCmdExecutor()
{ {
if (_proxyCmdExecutor == null) if (_proxyCmdExecutor == null)
{ {
_proxyCmdExecutor = ProxyCmdExecutorFactory.CreateFromConfig(GetCurrentConfig()); _proxyCmdExecutor = ProxyCmdExecutorFactory.CreateFromConfig(GetCurrentConfig()) ??
if (_proxyCmdExecutor == null) new ProxyCmdExecutorDummy(string.Empty);
{
_proxyCmdExecutor = new ProxyCmdExecutorDummy(string.Empty);
}
} }
} }
private void CleanProxyCmdExecutor() private void CleanProxyCmdExecutor()
{ {
// ReSharper disable once SuspiciousTypeConversion.Global
if (_proxyCmdExecutor is IDisposable disposableProxyCmdExecutor) if (_proxyCmdExecutor is IDisposable disposableProxyCmdExecutor)
{ {
disposableProxyCmdExecutor.Dispose(); disposableProxyCmdExecutor.Dispose();
} }
_proxyCmdExecutor = null; _proxyCmdExecutor = null;
} }
@@ -163,6 +172,7 @@ namespace VAR.Toolbox.UI
Logger.Log(ex); Logger.Log(ex);
OutputLine(ex.Message); OutputLine(ex.Message);
} }
Monitor.Exit(_executionLock); Monitor.Exit(_executionLock);
} }
@@ -190,8 +200,9 @@ namespace VAR.Toolbox.UI
{ {
previousSelectedName = selectedConfig.Name; previousSelectedName = selectedConfig.Name;
} }
ddlCurrentConfig.Items.Clear(); ddlCurrentConfig.Items.Clear();
ddlCurrentConfig.Items.AddRange(configItems.ToArray()); ddlCurrentConfig.Items.AddRange(configItems.ToArray<object>());
ddlCurrentConfig.SelectedIndex = 0; ddlCurrentConfig.SelectedIndex = 0;
if (string.IsNullOrEmpty(previousSelectedName) == false) if (string.IsNullOrEmpty(previousSelectedName) == false)
{ {
@@ -210,9 +221,10 @@ namespace VAR.Toolbox.UI
{ {
var selectedConfig = ddlCurrentConfig.SelectedItem as ProxyCmdConfigItem; var selectedConfig = ddlCurrentConfig.SelectedItem as ProxyCmdConfigItem;
if (selectedConfig == null) { return null; } if (selectedConfig == null) { return null; }
return selectedConfig.Config; return selectedConfig.Config;
} }
#endregion Config #endregion Config
} }
} }

Some files were not shown because too many files have changed in this diff Show More