Browse Source

Added Emgu.CV.Platform.Net shared project.

pull/348/head
Canming Huang 5 years ago
parent
commit
895c915631
  1. 13
      Emgu.CV.DebuggerVisualizers/Emgu.CV.DebuggerVisualizers.Console.Test/Emgu.CV.DebuggerVisualizers.Console.Test.csproj
  2. 22
      Emgu.CV.DebuggerVisualizers/Emgu.CV.DebuggerVisualizers.csproj
  3. 94
      Emgu.CV.Platform/DotNet/Emgu.CV.Platform.Net.projitems
  4. 13
      Emgu.CV.Platform/DotNet/Emgu.CV.Platform.Net.shproj
  5. 708
      Emgu.CV.Platform/DotNet/ParameterInputDialog.cs
  6. 2
      Solution/Windows.Desktop/Emgu.CV.DebuggerVisualizers.sln

13
Emgu.CV.DebuggerVisualizers/Emgu.CV.DebuggerVisualizers.Console.Test/Emgu.CV.DebuggerVisualizers.Console.Test.csproj

@ -54,19 +54,16 @@
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Emgu.CV.Platform\DotNet\Framework\Emgu.CV.Platform.NetFramework.csproj">
<Project>{90e78bbf-c7fe-4d8e-ade1-75448e866fdb}</Project>
<Name>Emgu.CV.Platform.NetFramework</Name>
</ProjectReference>
<ProjectReference Include="..\..\Emgu.CV.Platform\NetStandard\Emgu.CV.Platform.NetStandard.csproj">
<Project>{5db57d3a-1db6-4930-ae6a-e1587140b0c6}</Project>
<Name>Emgu.CV.Platform.NetStandard</Name>
</ProjectReference>
<ProjectReference Include="..\Emgu.CV.DebuggerVisualizers.csproj">
<Project>{e8f09998-297b-485c-b234-e5ace5f55772}</Project>
<Name>Emgu.CV.DebuggerVisualizers</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation">
<Version>4.3.0</Version>
</PackageReference>
</ItemGroup>
<Import Project="..\..\Emgu.CV.Runtime\Windows\Emgu.CV.Runtime.Windows.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

22
Emgu.CV.DebuggerVisualizers/Emgu.CV.DebuggerVisualizers.csproj

@ -81,10 +81,15 @@
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Emgu.CV.NativeImage\BitmapExtension.cs">
<Link>BitmapExtension.cs</Link>
</Compile>
<Compile Include="BitmapVisualizer.cs" />
<Compile Include="DenseHistogramVisualizer.cs" />
<Compile Include="ImageVisualizer.cs" />
@ -97,15 +102,16 @@
<Service Include="{B4F97281-0DBD-4835-9ED8-7DFB966E87FF}" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Emgu.CV.Platform\DotNet\Framework\Emgu.CV.Platform.NetFramework.csproj">
<Project>{90e78bbf-c7fe-4d8e-ade1-75448e866fdb}</Project>
<Name>Emgu.CV.Platform.NetFramework</Name>
</ProjectReference>
<ProjectReference Include="..\Emgu.CV.Platform\NetStandard\Emgu.CV.Platform.NetStandard.csproj">
<Project>{5db57d3a-1db6-4930-ae6a-e1587140b0c6}</Project>
<Name>Emgu.CV.Platform.NetStandard</Name>
</ProjectReference>
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation">
<Version>4.3.0</Version>
</PackageReference>
</ItemGroup>
<Import Project="..\Emgu.Util\Emgu.Util.projitems" Label="Shared" />
<Import Project="..\Emgu.CV.Platform\DotNet\Emgu.CV.Platform.Net.projitems" Label="Shared" />
<Import Project="..\Emgu.CV.OCR\Emgu.CV.OCR.projitems" Label="Shared" />
<Import Project="..\Emgu.CV.Cuda\Emgu.CV.Cuda.projitems" Label="Shared" />
<Import Project="..\Emgu.CV.Contrib\Emgu.CV.Contrib.projitems" Label="Shared" />
<Import Project="..\Emgu.CV\Emgu.CV.projitems" Label="Shared" />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Target Name="DeployBinary" AfterTargets="AfterBuild">
<Message Text="Copying $(OutputPath)$(AssemblyName).dll to ..\libs" Importance="high" />

94
Emgu.CV.Platform/DotNet/Emgu.CV.Platform.Net.projitems

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>ac06f404-0a97-4142-a021-572d686e231f</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>Emgu.CV.Platform.Net</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)HistogramBox.cs" />
<Compile Include="$(MSBuildThisFileDirectory)HistogramViewer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)HistogramViewer.Designer.cs">
<DependentUpon>HistogramViewer.cs</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)ImageBox.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ImageBox.Designer.cs">
<DependentUpon>ImageBox.cs</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)ImageProperty.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ImageProperty.Designer.cs">
<DependentUpon>ImageProperty.cs</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)ImagePropertyDialog.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ImagePropertyDialog.designer.cs">
<DependentUpon>ImagePropertyDialog.cs</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)ImageViewer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ImageViewer.Designer.cs">
<DependentUpon>ImageViewer.cs</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)MatrixBox.cs" />
<Compile Include="$(MSBuildThisFileDirectory)MatrixBox.Designer.cs">
<DependentUpon>MatrixBox.cs</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)MatrixViewer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)MatrixViewer.Designer.cs">
<DependentUpon>MatrixViewer.cs</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Operation.cs" />
<Compile Include="$(MSBuildThisFileDirectory)OperationsView.cs" />
<Compile Include="$(MSBuildThisFileDirectory)OperationsView.designer.cs">
<DependentUpon>OperationsView.cs</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)PanAndZoomPictureBox.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ParameterInputDialog.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ParameterInputDialog.designer.cs">
<DependentUpon>ParameterInputDialog.cs</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)HistogramViewer.resx">
<DependentUpon>HistogramViewer.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)ImageBox.resx">
<DependentUpon>ImageBox.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)ImageProperty.resx">
<DependentUpon>ImageProperty.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)ImageViewer.resx">
<DependentUpon>ImageViewer.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)MatrixBox.resx">
<DependentUpon>MatrixBox.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)MatrixViewer.resx">
<DependentUpon>MatrixViewer.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)OperationsView.resx">
<DependentUpon>OperationsView.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)PanAndZoomPictureBox.resx">
<SubType>Designer</SubType>
<DependentUpon>PanAndZoomPictureBox.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)ParameterInputDialog.resx">
<DependentUpon>ParameterInputDialog.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)ImagePropertyDialog.resx">
<DependentUpon>ImagePropertyDialog.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
</Project>

13
Emgu.CV.Platform/DotNet/Emgu.CV.Platform.Net.shproj

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>ac06f404-0a97-4142-a021-572d686e231f</ProjectGuid>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<PropertyGroup />
<Import Project="Emgu.CV.Platform.Net.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>

708
Emgu.CV.Platform/DotNet/ParameterInputDialog.cs

@ -12,387 +12,387 @@ using Emgu.CV.Structure;
namespace Emgu.CV.UI
{
/// <summary>
/// The dialog to ask user for parameters to the specific method
/// </summary>
internal partial class ParameterInputDialog : Form
{
private bool _sucessed;
/// <summary>
/// The List of parameter values
/// </summary>
private Object[] _paramValue;
/// <summary>
/// The array of parameter info
/// </summary>
private ParameterInfo[] _paramInfo;
private ParamInputPanel[] _paramPanel;
/// <summary>
/// Get the parameters obtained by this parameter input dialog
/// </summary>
public Object[] Parameters
{
get
{
return _paramValue;
}
}
private ParameterInputDialog(ParameterInfo[] paramInfo, Object[] paramList)
{
InitializeComponent();
int panelsHeight = 0;
_paramValue = new object[paramInfo.Length];
_paramInfo = paramInfo;
_paramPanel = new ParamInputPanel[paramInfo.Length];
for (int i = 0; i < paramInfo.Length; i++)
{
ParamInputPanel panel = CreatePanelForParameter(
paramInfo[i],
(paramList == null || i >= paramList.Length) ? null : paramList[i]);
parameterInputPanel.Controls.Add(panel);
panel.Location = new Point(0, i * panel.Height);
_paramPanel[i] = panel;
panelsHeight += panel.Height;
}
Height = panelsHeight + 100;
}
private bool Successed
{
get { return _sucessed; }
}
private void cancelButton_Click(object sender, EventArgs e)
{
Close();
}
private void okButton_Click(object sender, EventArgs e)
{
for (int i = 0; i < _paramInfo.Length; i++)
{
ParamInputPanel panel = _paramPanel[i];
Object value = panel.GetValue();
if (value == null)
/// <summary>
/// The dialog to ask user for parameters to the specific method
/// </summary>
internal partial class ParameterInputDialog : Form
{
private bool _sucessed;
/// <summary>
/// The List of parameter values
/// </summary>
private Object[] _paramValue;
/// <summary>
/// The array of parameter info
/// </summary>
private ParameterInfo[] _paramInfo;
private ParamInputPanel[] _paramPanel;
/// <summary>
/// Get the parameters obtained by this parameter input dialog
/// </summary>
public Object[] Parameters
{
get
{
MessageBox.Show(String.Format("Parameter {0} is invalid.", panel.Name));
return;
return _paramValue;
}
}
_paramValue[i] = value;
}
private ParameterInputDialog(ParameterInfo[] paramInfo, Object[] paramList)
{
InitializeComponent();
_sucessed = true;
Close();
}
int panelsHeight = 0;
private class ParamInputPanel : Panel
{
private GetParamDelegate _getParamFunction;
_paramValue = new object[paramInfo.Length];
/// <summary>
/// Return the value of the parameter input panel, if unable to retrieve value, return null
/// </summary>
/// <returns>The value of the parameter input panel, if unable to retrieve value, return null</returns>
public Object GetValue()
{
try
{
return _getParamFunction();
}
catch
_paramInfo = paramInfo;
_paramPanel = new ParamInputPanel[paramInfo.Length];
for (int i = 0; i < paramInfo.Length; i++)
{
return null;
ParamInputPanel panel = CreatePanelForParameter(
paramInfo[i],
(paramList == null || i >= paramList.Length) ? null : paramList[i]);
parameterInputPanel.Controls.Add(panel);
panel.Location = new Point(0, i * panel.Height);
_paramPanel[i] = panel;
panelsHeight += panel.Height;
}
}
public delegate Object GetParamDelegate();
Height = panelsHeight + 100;
}
private bool Successed
{
get { return _sucessed; }
}
private void cancelButton_Click(object sender, EventArgs e)
{
Close();
}
/// <summary>
/// The function used to obtain the parameter from this input panel
/// </summary>
public GetParamDelegate GetParamFunction
{
set
private void okButton_Click(object sender, EventArgs e)
{
for (int i = 0; i < _paramInfo.Length; i++)
{
_getParamFunction = value;
}
}
}
/// <summary>
/// Get the name of the parameter
/// </summary>
/// <param name="param">the parameter</param>
/// <returns>the name of the parameter</returns>
private static String ParseParameterName(ParameterInfo param)
{
String name = param.Name;
#region Add space before every upper case character
Char[] nameChars = name.ToCharArray();
List<Char> charList = new List<char>();
foreach (Char c in nameChars)
{
if (Char.IsUpper(c))
{ //upper case char
charList.Add(' ');
}
charList.Add(c);
}
#endregion
//convert the first letter to upper case
charList[0] = Char.ToUpper(charList[0]);
return new string(charList.ToArray());
}
/// <summary>
/// Create a panel for the specific parameter
/// </summary>
/// <param name="param">the parameter to create panel for</param>
/// <param name="defaultValue">The default value for the parameter</param>
/// <returns>the panel</returns>
private static ParamInputPanel CreatePanelForParameter(ParameterInfo param, object defaultValue)
{
ParamInputPanel panel = new ParamInputPanel();
panel.Height = 50;
panel.Width = 400;
Point textBoxStart = new Point(100, 10);
#region add the label for the parameter
Label paramNameLabel = new Label();
paramNameLabel.AutoSize = true;
panel.Controls.Add(paramNameLabel);
paramNameLabel.Location = new Point(10, textBoxStart.Y);
#endregion
if (param == null)
{ // a generic parameter
GenericParameter p = defaultValue as GenericParameter;
paramNameLabel.Text = "";
String[] options = Array.ConvertAll<Type, String>(p.AvailableTypes, delegate(Type t) { return t.Name; });
ComboBox combo = new ComboBox();
panel.Controls.Add(combo);
combo.Location = textBoxStart;
combo.Items.AddRange(options);
combo.SelectedIndex = Array.FindIndex<String>(options, p.SelectedType.ToString().Equals);
panel.GetParamFunction =
delegate()
ParamInputPanel panel = _paramPanel[i];
Object value = panel.GetValue();
if (value == null)
{
return
new GenericParameter(
p.AvailableTypes[Array.FindIndex<String>(options, combo.Text.ToString().Equals)],
p.AvailableTypes);
};
}
else
{
Type paramType = param.ParameterType;
paramNameLabel.Text = String.Format("{0}:", ParseParameterName(param));
if (paramType.IsEnum)
{
ComboBox combo = new ComboBox();
panel.Controls.Add(combo);
combo.Location = textBoxStart;
combo.Items.AddRange(Enum.GetNames(paramType));
combo.SelectedIndex = 0;
combo.Width = 240;
panel.GetParamFunction =
delegate
{
return Enum.Parse(paramType, combo.SelectedItem.ToString(), true);
};
}
else if (paramType == typeof(bool))
{
ComboBox combo = new ComboBox();
panel.Controls.Add(combo);
combo.Location = textBoxStart;
combo.Items.AddRange(new String[] { "True", "False" });
combo.SelectedIndex = 0;
panel.GetParamFunction =
delegate()
{
return combo.SelectedItem.ToString().Equals("True");
};
MessageBox.Show(String.Format("Parameter {0} is invalid.", panel.Name));
return;
}
_paramValue[i] = value;
}
else if (paramType == typeof(UInt64) || paramType == typeof(int) || paramType == typeof(double))
_sucessed = true;
Close();
}
private class ParamInputPanel : Panel
{
private GetParamDelegate _getParamFunction;
/// <summary>
/// Return the value of the parameter input panel, if unable to retrieve value, return null
/// </summary>
/// <returns>The value of the parameter input panel, if unable to retrieve value, return null</returns>
public Object GetValue()
{
//Create inpout box for the int paramater
TextBox inputTextBox = new TextBox();
panel.Controls.Add(inputTextBox);
inputTextBox.Location = textBoxStart;
inputTextBox.Text = defaultValue == null ? "0" : defaultValue.ToString();
panel.GetParamFunction =
delegate()
{
return Convert.ChangeType(inputTextBox.Text, paramType);
};
try
{
return _getParamFunction();
}
catch
{
return null;
}
}
else if (paramType == typeof(MCvScalar))
public delegate Object GetParamDelegate();
/// <summary>
/// The function used to obtain the parameter from this input panel
/// </summary>
public GetParamDelegate GetParamFunction
{
TextBox[] inputBoxes = new TextBox[4];
int boxWidth = 40;
//Create input boxes for the scalar value
for (int i = 0; i < inputBoxes.Length; i++)
{
inputBoxes[i] = new TextBox();
panel.Controls.Add(inputBoxes[i]);
inputBoxes[i].Location = new Point(textBoxStart.X + i * (boxWidth + 5), textBoxStart.Y);
inputBoxes[i].Width = boxWidth;
inputBoxes[i].Text = "0.0";
}
panel.GetParamFunction =
delegate()
{
double[] values = new double[4];
for (int i = 0; i < inputBoxes.Length; i++)
{
values[i] = Convert.ToDouble(inputBoxes[i].Text);
}
return new MCvScalar(values[0], values[1], values[2], values[3]);
};
set
{
_getParamFunction = value;
}
}
else if (paramType == typeof(PointF))
}
/// <summary>
/// Get the name of the parameter
/// </summary>
/// <param name="param">the parameter</param>
/// <returns>the name of the parameter</returns>
private static String ParseParameterName(ParameterInfo param)
{
String name = param.Name;
#region Add space before every upper case character
Char[] nameChars = name.ToCharArray();
List<Char> charList = new List<char>();
foreach (Char c in nameChars)
{
TextBox[] inputBoxes = new TextBox[2];
int boxWidth = 40;
//Create input boxes for the scalar value
for (int i = 0; i < 2; i++)
{
inputBoxes[i] = new TextBox();
panel.Controls.Add(inputBoxes[i]);
inputBoxes[i].Location = new Point(textBoxStart.X + i * (boxWidth + 5), textBoxStart.Y);
inputBoxes[i].Width = boxWidth;
inputBoxes[i].Text = "0.0";
}
panel.GetParamFunction =
delegate()
{
float[] values = new float[inputBoxes.Length];
for (int i = 0; i < inputBoxes.Length; i++)
{
values[i] = Convert.ToSingle(inputBoxes[i].Text);
}
return new PointF(values[0], values[1]);
};
if (Char.IsUpper(c))
{ //upper case char
charList.Add(' ');
}
charList.Add(c);
}
else if (paramType.GetInterface("IColor") == typeof(IColor))
{
IColor t = Activator.CreateInstance(paramType) as IColor;
//string[] channelNames = ReflectColorType.GetNamesOfChannels(t);
TextBox[] inputBoxes = new TextBox[t.Dimension];
int boxWidth = 40;
//Create input boxes for the scalar value
for (int i = 0; i < inputBoxes.Length; i++)
{
inputBoxes[i] = new TextBox();
panel.Controls.Add(inputBoxes[i]);
inputBoxes[i].Location = new Point(textBoxStart.X + i * (boxWidth + 5), textBoxStart.Y);
inputBoxes[i].Width = boxWidth;
inputBoxes[i].Text = "0.0";
}
panel.GetParamFunction =
delegate()
{
double[] values = new double[4];
for (int i = 0; i < inputBoxes.Length; i++)
{
values[i] = Convert.ToDouble(inputBoxes[i].Text);
}
IColor color = Activator.CreateInstance(paramType) as IColor;
color.MCvScalar = new MCvScalar(values[0], values[1], values[2], values[3]);
return color;
};
#endregion
//convert the first letter to upper case
charList[0] = Char.ToUpper(charList[0]);
return new string(charList.ToArray());
}
/// <summary>
/// Create a panel for the specific parameter
/// </summary>
/// <param name="param">the parameter to create panel for</param>
/// <param name="defaultValue">The default value for the parameter</param>
/// <returns>the panel</returns>
private static ParamInputPanel CreatePanelForParameter(ParameterInfo param, object defaultValue)
{
ParamInputPanel panel = new ParamInputPanel();
panel.Height = 50;
panel.Width = 400;
Point textBoxStart = new Point(100, 10);
#region add the label for the parameter
Label paramNameLabel = new Label();
paramNameLabel.AutoSize = true;
panel.Controls.Add(paramNameLabel);
paramNameLabel.Location = new Point(10, textBoxStart.Y);
#endregion
if (param == null)
{ // a generic parameter
GenericParameter p = defaultValue as GenericParameter;
paramNameLabel.Text = "";
String[] options = Array.ConvertAll<Type, String>(p.AvailableTypes, delegate (Type t) { return t.Name; });
ComboBox combo = new ComboBox();
panel.Controls.Add(combo);
combo.Location = textBoxStart;
combo.Items.AddRange(options);
combo.SelectedIndex = Array.FindIndex<String>(options, p.SelectedType.ToString().Equals);
panel.GetParamFunction =
delegate ()
{
return
new GenericParameter(
p.AvailableTypes[Array.FindIndex<String>(options, combo.Text.ToString().Equals)],
p.AvailableTypes);
};
}
else
{
throw new NotSupportedException(String.Format("Parameter type '{0}' is not supported", paramType.Name));
Type paramType = param.ParameterType;
paramNameLabel.Text = String.Format("{0}:", ParseParameterName(param));
if (paramType.IsEnum)
{
ComboBox combo = new ComboBox();
panel.Controls.Add(combo);
combo.Location = textBoxStart;
combo.Items.AddRange(Enum.GetNames(paramType));
combo.SelectedIndex = 0;
combo.Width = 240;
panel.GetParamFunction =
delegate
{
return Enum.Parse(paramType, combo.SelectedItem.ToString(), true);
};
}
else if (paramType == typeof(bool))
{
ComboBox combo = new ComboBox();
panel.Controls.Add(combo);
combo.Location = textBoxStart;
combo.Items.AddRange(new String[] { "True", "False" });
combo.SelectedIndex = 0;
panel.GetParamFunction =
delegate ()
{
return combo.SelectedItem.ToString().Equals("True");
};
}
else if (paramType == typeof(UInt64) || paramType == typeof(int) || paramType == typeof(double))
{
//Create inpout box for the int paramater
TextBox inputTextBox = new TextBox();
panel.Controls.Add(inputTextBox);
inputTextBox.Location = textBoxStart;
inputTextBox.Text = defaultValue == null ? "0" : defaultValue.ToString();
panel.GetParamFunction =
delegate ()
{
return Convert.ChangeType(inputTextBox.Text, paramType);
};
}
else if (paramType == typeof(MCvScalar))
{
TextBox[] inputBoxes = new TextBox[4];
int boxWidth = 40;
//Create input boxes for the scalar value
for (int i = 0; i < inputBoxes.Length; i++)
{
inputBoxes[i] = new TextBox();
panel.Controls.Add(inputBoxes[i]);
inputBoxes[i].Location = new Point(textBoxStart.X + i * (boxWidth + 5), textBoxStart.Y);
inputBoxes[i].Width = boxWidth;
inputBoxes[i].Text = "0.0";
}
panel.GetParamFunction =
delegate ()
{
double[] values = new double[4];
for (int i = 0; i < inputBoxes.Length; i++)
{
values[i] = Convert.ToDouble(inputBoxes[i].Text);
}
return new MCvScalar(values[0], values[1], values[2], values[3]);
};
}
else if (paramType == typeof(PointF))
{
TextBox[] inputBoxes = new TextBox[2];
int boxWidth = 40;
//Create input boxes for the scalar value
for (int i = 0; i < 2; i++)
{
inputBoxes[i] = new TextBox();
panel.Controls.Add(inputBoxes[i]);
inputBoxes[i].Location = new Point(textBoxStart.X + i * (boxWidth + 5), textBoxStart.Y);
inputBoxes[i].Width = boxWidth;
inputBoxes[i].Text = "0.0";
}
panel.GetParamFunction =
delegate ()
{
float[] values = new float[inputBoxes.Length];
for (int i = 0; i < inputBoxes.Length; i++)
{
values[i] = Convert.ToSingle(inputBoxes[i].Text);
}
return new PointF(values[0], values[1]);
};
}
else if (paramType.GetInterface("IColor") == typeof(IColor))
{
IColor t = Activator.CreateInstance(paramType) as IColor;
//string[] channelNames = ReflectColorType.GetNamesOfChannels(t);
TextBox[] inputBoxes = new TextBox[t.Dimension];
int boxWidth = 40;
//Create input boxes for the scalar value
for (int i = 0; i < inputBoxes.Length; i++)
{
inputBoxes[i] = new TextBox();
panel.Controls.Add(inputBoxes[i]);
inputBoxes[i].Location = new Point(textBoxStart.X + i * (boxWidth + 5), textBoxStart.Y);
inputBoxes[i].Width = boxWidth;
inputBoxes[i].Text = "0.0";
}
panel.GetParamFunction =
delegate ()
{
double[] values = new double[4];
for (int i = 0; i < inputBoxes.Length; i++)
{
values[i] = Convert.ToDouble(inputBoxes[i].Text);
}
IColor color = Activator.CreateInstance(paramType) as IColor;
color.MCvScalar = new MCvScalar(values[0], values[1], values[2], values[3]);
return color;
};
}
else
{
throw new NotSupportedException(String.Format("Parameter type '{0}' is not supported", paramType.Name));
}
}
}
return panel;
}
/// <summary>
/// Obtain the parameters for <paramref name="method"/> and put them in <paramref name="defaultParameterValues"/>
/// </summary>
/// <param name="method">The method to Obtain parameters from</param>
/// <param name="defaultParameterValues">The list that will be used as the storage for the retrieved parameters, if it contains elements, those elements will be used as default value</param>
/// <returns>True if successed, false otherwise</returns>
public static Object[] GetParams(MethodInfo method, Object[] defaultParameterValues)
{
List<ParameterInfo> parameterList = new List<ParameterInfo>();
List<Object> defaultParameterValueList = new List<object>();
#region find all the generic types and options and add that to the lists.
if (method.ContainsGenericParameters)
{
ExposableMethodAttribute att =
(method.GetCustomAttributes(typeof(ExposableMethodAttribute), false)[0] as ExposableMethodAttribute);
Type[] typeOptions = att.GenericParametersOptions;
int[] optionSize = att.GenericParametersOptionSizes;
GenericParameter[] genericOptions = new GenericParameter[optionSize.Length];
int count = 0;
for (int i = 0; i < optionSize.Length; i++)
return panel;
}
/// <summary>
/// Obtain the parameters for <paramref name="method"/> and put them in <paramref name="defaultParameterValues"/>
/// </summary>
/// <param name="method">The method to Obtain parameters from</param>
/// <param name="defaultParameterValues">The list that will be used as the storage for the retrieved parameters, if it contains elements, those elements will be used as default value</param>
/// <returns>True if successed, false otherwise</returns>
public static Object[] GetParams(MethodInfo method, Object[] defaultParameterValues)
{
List<ParameterInfo> parameterList = new List<ParameterInfo>();
List<Object> defaultParameterValueList = new List<object>();
#region find all the generic types and options and add that to the lists.
if (method.ContainsGenericParameters)
{
Type[] types = new Type[optionSize[i]];
for (int j = 0; j < types.Length; j++)
types[j] = typeOptions[count++];
genericOptions[i] = new GenericParameter(types[0], types);
ExposableMethodAttribute att =
(method.GetCustomAttributes(typeof(ExposableMethodAttribute), false)[0] as ExposableMethodAttribute);
Type[] typeOptions = att.GenericParametersOptions;
int[] optionSize = att.GenericParametersOptionSizes;
GenericParameter[] genericOptions = new GenericParameter[optionSize.Length];
int count = 0;
for (int i = 0; i < optionSize.Length; i++)
{
Type[] types = new Type[optionSize[i]];
for (int j = 0; j < types.Length; j++)
types[j] = typeOptions[count++];
genericOptions[i] = new GenericParameter(types[0], types);
}
//Type[] instanceGenericParameters = method.ReflectedType.GetGenericArguments();
Type[] genericTypes = method.GetGenericArguments();
for (int i = 0; i < genericTypes.Length; i++)
{
parameterList.Add(null);
defaultParameterValueList.Add(
defaultParameterValues == null ?
genericOptions[i] :
defaultParameterValues[i]);
}
}
#endregion
parameterList.AddRange(method.GetParameters());
if (defaultParameterValues != null)
defaultParameterValueList.AddRange(defaultParameterValues);
//Type[] instanceGenericParameters = method.ReflectedType.GetGenericArguments();
Type[] genericTypes = method.GetGenericArguments();
//if the method requires no parameter, simply return an empty array
if (parameterList.Count == 0)
return new object[0];
for (int i = 0; i < genericTypes.Length; i++)
#region Handle the cases where at least one parameter is required as input
using (ParameterInputDialog dlg = new ParameterInputDialog(parameterList.ToArray(), defaultParameterValueList.ToArray()))
{
parameterList.Add(null);
defaultParameterValueList.Add(
defaultParameterValues == null ?
genericOptions[i]:
defaultParameterValues[i]);
dlg.ShowDialog();
return dlg.Successed ? dlg.Parameters : null;
}
}
#endregion
parameterList.AddRange(method.GetParameters());
if (defaultParameterValues != null)
defaultParameterValueList.AddRange(defaultParameterValues);
//if the method requires no parameter, simply return an empty array
if (parameterList.Count == 0)
return new object[0];
#region Handle the cases where at least one parameter is required as input
using (ParameterInputDialog dlg = new ParameterInputDialog(parameterList.ToArray(), defaultParameterValueList.ToArray()))
{
dlg.ShowDialog();
return dlg.Successed ? dlg.Parameters : null;
}
#endregion
}
}
#endregion
}
}
}

2
Solution/Windows.Desktop/Emgu.CV.DebuggerVisualizers.sln

@ -22,6 +22,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emgu.CV.Platform.NetFramewo
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emgu.CV.DebuggerVisualizers.Console.Test", "..\..\Emgu.CV.DebuggerVisualizers\Emgu.CV.DebuggerVisualizers.Console.Test\Emgu.CV.DebuggerVisualizers.Console.Test.csproj", "{37099E39-A3FC-4CB9-8365-6F5264C4337F}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Emgu.CV.Platform.Net", "..\..\Emgu.CV.Platform\DotNet\Emgu.CV.Platform.Net.shproj", "{AC06F404-0A97-4142-A021-572D686E231F}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
..\..\Emgu.CV.Contrib\Emgu.CV.Contrib.projitems*{11e54a7e-778d-466c-a176-71e150976ac1}*SharedItemsImports = 13

Loading…
Cancel
Save