IDS camera added
This commit is contained in:
@@ -43,6 +43,10 @@ public class DefaultControlFactory : IControlFactory
|
||||
{
|
||||
return CreateListControl(name, description, type, initialValue, valueChangedCallback, optionsWindow, settingDescription, previewLabel, getPreview);
|
||||
}
|
||||
else if (type == typeof(string) && propertyInfo.GetCustomAttribute<FileAttribute>()!=null)
|
||||
{
|
||||
return CreateFileControl(name, description, initialValue, valueChangedCallback, optionsWindow, settingDescription, previewLabel, getPreview, propertyInfo.GetCustomAttribute<FileAttribute>().Filter);
|
||||
}
|
||||
else if (type == typeof(string) && name.EndsWith("Path", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return CreatePathControl(name, description, initialValue, valueChangedCallback, optionsWindow, settingDescription, previewLabel, getPreview);
|
||||
@@ -156,7 +160,36 @@ public class DefaultControlFactory : IControlFactory
|
||||
|
||||
return CreateOuterPanel(settingDescription, previewLabel, label, textBox, browseButton);
|
||||
}
|
||||
private Control CreateFileControl(string name, string description, object initialValue, Action<object> valueChangedCallback,
|
||||
OptionsWindow optionsWindow, string settingDescription, Label previewLabel, Func<object, string> getPreview, string filter)
|
||||
{
|
||||
var textBox = new TextBox { Text = initialValue as string, Width = 400 };
|
||||
var label = new Label { Text = description, AutoSize = true, Padding = new Padding(0, 5, 0, 0) };
|
||||
var browseButton = new Button { Text = "Browse", AutoSize = true };
|
||||
|
||||
browseButton.Click += (s, e) =>
|
||||
{
|
||||
using (var dialog = new CommonOpenFileDialog {Filters = { new CommonFileDialogFilter(filter, filter) }})
|
||||
{
|
||||
if (dialog.ShowDialog(optionsWindow.Handle) == CommonFileDialogResult.Ok)
|
||||
{
|
||||
textBox.Text = dialog.FileName;
|
||||
valueChangedCallback(dialog.FileName);
|
||||
if (previewLabel != null && getPreview != null)
|
||||
previewLabel.Text = getPreview(dialog.FileName);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
textBox.TextChanged += (s, e) =>
|
||||
{
|
||||
valueChangedCallback(textBox.Text);
|
||||
if (previewLabel != null && getPreview != null)
|
||||
previewLabel.Text = getPreview(textBox.Text);
|
||||
};
|
||||
|
||||
return CreateOuterPanel(settingDescription, previewLabel, label, textBox, browseButton);
|
||||
}
|
||||
private Control CreateStringControl(string description, object initialValue, Action<object> valueChangedCallback,
|
||||
string settingDescription, Label previewLabel, Func<object, string> getPreview)
|
||||
{
|
||||
|
||||
15
framework/Inspectron.Settings/Attributes/FileAttribute.cs
Normal file
15
framework/Inspectron.Settings/Attributes/FileAttribute.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
|
||||
namespace Inspectron.Settings.Attributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public class FileAttribute:Attribute
|
||||
{
|
||||
public string Filter { get; }
|
||||
|
||||
public FileAttribute(string filter)
|
||||
{
|
||||
Filter = filter;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user