forked from mirrors/NBTExplorer
Create rule forms
This commit is contained in:
parent
48fc7e4d0e
commit
1c654c66d3
13 changed files with 1172 additions and 20 deletions
|
@ -5,6 +5,8 @@ using System.Windows.Forms;
|
|||
using NBTExplorer.Windows;
|
||||
using NBTExplorer.Model.Search;
|
||||
using Substrate.Nbt;
|
||||
using NBTExplorer.Windows.Search;
|
||||
using System.Drawing;
|
||||
|
||||
namespace NBTExplorer.Controllers
|
||||
{
|
||||
|
@ -99,40 +101,127 @@ namespace NBTExplorer.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
private TreeNode CreateIntegralNode<T, K> (string typeName)
|
||||
where K : TagNode
|
||||
where T : IntegralTagRule<K>, new()
|
||||
{
|
||||
T rule = new T();
|
||||
|
||||
using (ValueRuleForm form = new ValueRuleForm(SearchRule.NumericOpStrings) {
|
||||
Text = "Edit " + typeName + " Tag Rule",
|
||||
}) {
|
||||
if (form.ShowDialog() == DialogResult.OK) {
|
||||
rule.Name = form.TagName;
|
||||
rule.Value = form.TagValueAsLong;
|
||||
rule.Operator = form.Operator;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
TreeNode node = CreateNode(rule);
|
||||
node.Text = rule.NodeDisplay;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
private TreeNode CreateFloatNode<T, K> (string typeName)
|
||||
where K : TagNode
|
||||
where T : FloatTagRule<K>, new()
|
||||
{
|
||||
T rule = new T();
|
||||
|
||||
using (ValueRuleForm form = new ValueRuleForm(SearchRule.NumericOpStrings) {
|
||||
Text = "Edit " + typeName + " Tag Rule",
|
||||
}) {
|
||||
if (form.ShowDialog() == DialogResult.OK) {
|
||||
rule.Name = form.TagName;
|
||||
rule.Value = form.TagValueAsDouble;
|
||||
rule.Operator = form.Operator;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
TreeNode node = CreateNode(rule);
|
||||
node.Text = rule.NodeDisplay;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
private TreeNode CreateStringNode (string typeName)
|
||||
{
|
||||
StringTagRule rule = new StringTagRule();
|
||||
|
||||
using (StringRuleForm form = new StringRuleForm(SearchRule.StringOpStrings) {
|
||||
Text = "Edit " + typeName + " Tag Rule",
|
||||
}) {
|
||||
if (form.ShowDialog() == DialogResult.OK) {
|
||||
rule.Name = form.TagName;
|
||||
rule.Value = form.TagValue;
|
||||
rule.Operator = form.Operator;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
TreeNode node = CreateNode(rule);
|
||||
node.Text = rule.NodeDisplay;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
private TreeNode CreateWildcardNode (string typeName)
|
||||
{
|
||||
WildcardRule rule = new WildcardRule();
|
||||
|
||||
using (WildcardRuleForm form = new WildcardRuleForm(SearchRule.WildcardOpStrings) {
|
||||
Text = "Edit " + typeName + " Rule",
|
||||
}) {
|
||||
if (form.ShowDialog() == DialogResult.OK) {
|
||||
rule.Name = form.TagName;
|
||||
rule.Value = form.TagValue;
|
||||
rule.Operator = form.Operator;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
TreeNode node = CreateNode(rule);
|
||||
node.Text = rule.NodeDisplay;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
public void CreateNode (TreeNode node, TagType type)
|
||||
{
|
||||
if (node == null || !(node.Tag is GroupRule))
|
||||
return;
|
||||
|
||||
GroupRule dataNode = node.Tag as GroupRule;
|
||||
//if (!dataNode.CanCreateTag(type))
|
||||
// return;
|
||||
|
||||
TreeNode newNode = null;
|
||||
|
||||
switch (type) {
|
||||
case TagType.TAG_BYTE:
|
||||
newNode = CreateNode(new ByteTagRule());
|
||||
(newNode.Tag as ByteTagRule).Name = "raining";
|
||||
newNode.Text = (newNode.Tag as SearchRule).NodeDisplay;
|
||||
newNode = CreateIntegralNode<ByteTagRule, TagNodeByte>("Byte");
|
||||
break;
|
||||
case TagType.TAG_SHORT:
|
||||
newNode = CreateNode(new ShortTagRule());
|
||||
newNode = CreateIntegralNode<ShortTagRule, TagNodeShort>("Short");
|
||||
break;
|
||||
case TagType.TAG_INT:
|
||||
newNode = CreateNode(new IntTagRule());
|
||||
newNode = CreateIntegralNode<IntTagRule, TagNodeInt>("Int");
|
||||
break;
|
||||
case TagType.TAG_LONG:
|
||||
newNode = CreateNode(new LongTagRule());
|
||||
newNode = CreateIntegralNode<LongTagRule, TagNodeLong>("Long");
|
||||
break;
|
||||
case TagType.TAG_FLOAT:
|
||||
newNode = CreateNode(new FloatTagRule());
|
||||
newNode = CreateFloatNode<FloatTagRule, TagNodeFloat>("Float");
|
||||
break;
|
||||
case TagType.TAG_DOUBLE:
|
||||
newNode = CreateNode(new DoubleTagRule());
|
||||
newNode = CreateFloatNode<DoubleTagRule, TagNodeDouble>("Double");
|
||||
break;
|
||||
case TagType.TAG_STRING:
|
||||
newNode = CreateNode(new StringTagRule());
|
||||
newNode = CreateStringNode("String");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -157,11 +246,14 @@ namespace NBTExplorer.Controllers
|
|||
|
||||
GroupRule dataNode = node.Tag as GroupRule;
|
||||
|
||||
TreeNode newNode = CreateNode(new WildcardRule());
|
||||
node.Nodes.Add(newNode);
|
||||
dataNode.Rules.Add(newNode.Tag as SearchRule);
|
||||
TreeNode newNode = CreateWildcardNode("Wildcard");
|
||||
|
||||
node.Expand();
|
||||
if (newNode != null) {
|
||||
node.Nodes.Add(newNode);
|
||||
dataNode.Rules.Add(newNode.Tag as SearchRule);
|
||||
|
||||
node.Expand();
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateWildcardNode ()
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace NBTExplorer.Model.Search
|
|||
|
||||
public abstract class SearchRule
|
||||
{
|
||||
protected static readonly Dictionary<NumericOperator, string> NumericOpStrings = new Dictionary<NumericOperator, string>() {
|
||||
public static readonly Dictionary<NumericOperator, string> NumericOpStrings = new Dictionary<NumericOperator, string>() {
|
||||
{ NumericOperator.Equals, "=" },
|
||||
{ NumericOperator.NotEquals, "!=" },
|
||||
{ NumericOperator.GreaterThan, ">" },
|
||||
|
@ -42,7 +42,7 @@ namespace NBTExplorer.Model.Search
|
|||
{ NumericOperator.Any, "ANY" },
|
||||
};
|
||||
|
||||
protected static readonly Dictionary<StringOperator, string> StringOpStrings = new Dictionary<StringOperator, string>() {
|
||||
public static readonly Dictionary<StringOperator, string> StringOpStrings = new Dictionary<StringOperator, string>() {
|
||||
{ StringOperator.Equals, "=" },
|
||||
{ StringOperator.NotEquals, "!=" },
|
||||
{ StringOperator.Contains, "Contains" },
|
||||
|
@ -52,7 +52,7 @@ namespace NBTExplorer.Model.Search
|
|||
{ StringOperator.Any, "ANY" },
|
||||
};
|
||||
|
||||
protected static readonly Dictionary<WildcardOperator, string> WildcardOpStrings = new Dictionary<WildcardOperator, string>() {
|
||||
public static readonly Dictionary<WildcardOperator, string> WildcardOpStrings = new Dictionary<WildcardOperator, string>() {
|
||||
{ WildcardOperator.Equals, "=" },
|
||||
{ WildcardOperator.NotEquals, "!=" },
|
||||
{ WildcardOperator.Any, "ANY" },
|
||||
|
@ -189,7 +189,7 @@ namespace NBTExplorer.Model.Search
|
|||
public class IntTagRule : IntegralTagRule<TagNodeInt>
|
||||
{ }
|
||||
|
||||
public class LongTagRule : IntegralTagRule<TagNodeInt>
|
||||
public class LongTagRule : IntegralTagRule<TagNodeLong>
|
||||
{ }
|
||||
|
||||
public abstract class FloatTagRule<T> : TagRule
|
||||
|
|
|
@ -208,6 +208,24 @@
|
|||
<Compile Include="Windows\FormHandlers.cs" />
|
||||
<Compile Include="Windows\NbtClipboardControllerWin.cs" />
|
||||
<Compile Include="Windows\SearchStateWin.cs" />
|
||||
<Compile Include="Windows\Search\WildcardRuleForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Windows\Search\WildcardRuleForm.Designer.cs">
|
||||
<DependentUpon>WildcardRuleForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Windows\Search\StringRuleForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Windows\Search\StringRuleForm.Designer.cs">
|
||||
<DependentUpon>StringRuleForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Windows\Search\ValueRuleForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Windows\Search\ValueRuleForm.Designer.cs">
|
||||
<DependentUpon>ValueRuleForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="Windows\CancelSearchForm.resx">
|
||||
<DependentUpon>CancelSearchForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
@ -252,6 +270,15 @@
|
|||
<EmbeddedResource Include="Vendor\Be.Windows.Forms.HexBox\HexBox.resx">
|
||||
<DependentUpon>HexBox.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Windows\Search\WildcardRuleForm.resx">
|
||||
<DependentUpon>WildcardRuleForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Windows\Search\StringRuleForm.resx">
|
||||
<DependentUpon>StringRuleForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Windows\Search\ValueRuleForm.resx">
|
||||
<DependentUpon>ValueRuleForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<None Include="app.config">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
|
|
|
@ -22,6 +22,11 @@ namespace NBTExplorer.Windows
|
|||
return DefaultIcon;
|
||||
}
|
||||
|
||||
public int Lookup<T> ()
|
||||
{
|
||||
return Lookup(typeof(T));
|
||||
}
|
||||
|
||||
public void Register (Type type, int iconIndex)
|
||||
{
|
||||
_iconRegistry[type] = iconIndex;
|
||||
|
|
150
Windows/Search/StringRuleForm.Designer.cs
generated
Normal file
150
Windows/Search/StringRuleForm.Designer.cs
generated
Normal file
|
@ -0,0 +1,150 @@
|
|||
namespace NBTExplorer.Windows.Search
|
||||
{
|
||||
partial class StringRuleForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose (bool disposing)
|
||||
{
|
||||
if (disposing && (components != null)) {
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent ()
|
||||
{
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this._textName = new System.Windows.Forms.TextBox();
|
||||
this._textValue = new System.Windows.Forms.TextBox();
|
||||
this._selectOperator = new System.Windows.Forms.ComboBox();
|
||||
this._ruleGroup = new System.Windows.Forms.GroupBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this._buttonOK = new System.Windows.Forms.Button();
|
||||
this._buttonCancel = new System.Windows.Forms.Button();
|
||||
this._ruleGroup.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(6, 22);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(60, 13);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "Tag Name:";
|
||||
//
|
||||
// _textName
|
||||
//
|
||||
this._textName.Location = new System.Drawing.Point(102, 19);
|
||||
this._textName.Name = "_textName";
|
||||
this._textName.Size = new System.Drawing.Size(142, 20);
|
||||
this._textName.TabIndex = 1;
|
||||
//
|
||||
// _textValue
|
||||
//
|
||||
this._textValue.Location = new System.Drawing.Point(102, 72);
|
||||
this._textValue.Name = "_textValue";
|
||||
this._textValue.Size = new System.Drawing.Size(142, 20);
|
||||
this._textValue.TabIndex = 2;
|
||||
//
|
||||
// _selectOperator
|
||||
//
|
||||
this._selectOperator.FormattingEnabled = true;
|
||||
this._selectOperator.Location = new System.Drawing.Point(102, 45);
|
||||
this._selectOperator.Name = "_selectOperator";
|
||||
this._selectOperator.Size = new System.Drawing.Size(142, 21);
|
||||
this._selectOperator.TabIndex = 3;
|
||||
//
|
||||
// _ruleGroup
|
||||
//
|
||||
this._ruleGroup.Controls.Add(this.label2);
|
||||
this._ruleGroup.Controls.Add(this._textName);
|
||||
this._ruleGroup.Controls.Add(this._selectOperator);
|
||||
this._ruleGroup.Controls.Add(this.label1);
|
||||
this._ruleGroup.Controls.Add(this._textValue);
|
||||
this._ruleGroup.Location = new System.Drawing.Point(12, 12);
|
||||
this._ruleGroup.Name = "_ruleGroup";
|
||||
this._ruleGroup.Size = new System.Drawing.Size(250, 98);
|
||||
this._ruleGroup.TabIndex = 4;
|
||||
this._ruleGroup.TabStop = false;
|
||||
this._ruleGroup.Text = "Rule";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(6, 75);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(59, 13);
|
||||
this.label2.TabIndex = 5;
|
||||
this.label2.Text = "Tag Value:";
|
||||
//
|
||||
// _buttonOK
|
||||
//
|
||||
this._buttonOK.Location = new System.Drawing.Point(186, 116);
|
||||
this._buttonOK.Name = "_buttonOK";
|
||||
this._buttonOK.Size = new System.Drawing.Size(75, 23);
|
||||
this._buttonOK.TabIndex = 5;
|
||||
this._buttonOK.Text = "OK";
|
||||
this._buttonOK.UseVisualStyleBackColor = true;
|
||||
this._buttonOK.Click += new System.EventHandler(this._buttonOK_Click);
|
||||
//
|
||||
// _buttonCancel
|
||||
//
|
||||
this._buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this._buttonCancel.Location = new System.Drawing.Point(105, 116);
|
||||
this._buttonCancel.Name = "_buttonCancel";
|
||||
this._buttonCancel.Size = new System.Drawing.Size(75, 23);
|
||||
this._buttonCancel.TabIndex = 6;
|
||||
this._buttonCancel.Text = "Cancel";
|
||||
this._buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// ValueRuleForm
|
||||
//
|
||||
this.AcceptButton = this._buttonOK;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this._buttonCancel;
|
||||
this.ClientSize = new System.Drawing.Size(273, 151);
|
||||
this.Controls.Add(this._buttonCancel);
|
||||
this.Controls.Add(this._buttonOK);
|
||||
this.Controls.Add(this._ruleGroup);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "ValueRuleForm";
|
||||
this.ShowInTaskbar = false;
|
||||
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
||||
this.Text = "Edit Value Rule";
|
||||
this.TopMost = true;
|
||||
this._ruleGroup.ResumeLayout(false);
|
||||
this._ruleGroup.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.TextBox _textName;
|
||||
private System.Windows.Forms.TextBox _textValue;
|
||||
private System.Windows.Forms.ComboBox _selectOperator;
|
||||
private System.Windows.Forms.GroupBox _ruleGroup;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Button _buttonOK;
|
||||
private System.Windows.Forms.Button _buttonCancel;
|
||||
}
|
||||
}
|
59
Windows/Search/StringRuleForm.cs
Normal file
59
Windows/Search/StringRuleForm.cs
Normal file
|
@ -0,0 +1,59 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using NBTExplorer.Model.Search;
|
||||
|
||||
namespace NBTExplorer.Windows.Search
|
||||
{
|
||||
public partial class StringRuleForm : Form
|
||||
{
|
||||
public StringRuleForm (Dictionary<StringOperator, string> operators)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
foreach (var op in operators)
|
||||
_selectOperator.Items.Add(op.Key);
|
||||
|
||||
_selectOperator.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
public string RuleGroupName
|
||||
{
|
||||
get { return _ruleGroup.Text; }
|
||||
set { _ruleGroup.Text = value; }
|
||||
}
|
||||
|
||||
public string TagName
|
||||
{
|
||||
get { return _textName.Text; }
|
||||
set { _textName.Text = value; }
|
||||
}
|
||||
|
||||
public string TagValue
|
||||
{
|
||||
get { return _textValue.Text; }
|
||||
set { _textValue.Text = value; }
|
||||
}
|
||||
|
||||
public StringOperator Operator
|
||||
{
|
||||
get { return (StringOperator)_selectOperator.SelectedItem; }
|
||||
set { _selectOperator.SelectedItem = value; }
|
||||
}
|
||||
|
||||
private void _buttonOK_Click (object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(TagName)) {
|
||||
MessageBox.Show(this, "Rule missing name");
|
||||
return;
|
||||
}
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
120
Windows/Search/StringRuleForm.resx
Normal file
120
Windows/Search/StringRuleForm.resx
Normal file
|
@ -0,0 +1,120 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
150
Windows/Search/ValueRuleForm.Designer.cs
generated
Normal file
150
Windows/Search/ValueRuleForm.Designer.cs
generated
Normal file
|
@ -0,0 +1,150 @@
|
|||
namespace NBTExplorer.Windows.Search
|
||||
{
|
||||
partial class ValueRuleForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose (bool disposing)
|
||||
{
|
||||
if (disposing && (components != null)) {
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent ()
|
||||
{
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this._textName = new System.Windows.Forms.TextBox();
|
||||
this._textValue = new System.Windows.Forms.TextBox();
|
||||
this._selectOperator = new System.Windows.Forms.ComboBox();
|
||||
this._ruleGroup = new System.Windows.Forms.GroupBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this._buttonOK = new System.Windows.Forms.Button();
|
||||
this._buttonCancel = new System.Windows.Forms.Button();
|
||||
this._ruleGroup.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(6, 22);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(60, 13);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "Tag Name:";
|
||||
//
|
||||
// _textName
|
||||
//
|
||||
this._textName.Location = new System.Drawing.Point(102, 19);
|
||||
this._textName.Name = "_textName";
|
||||
this._textName.Size = new System.Drawing.Size(142, 20);
|
||||
this._textName.TabIndex = 1;
|
||||
//
|
||||
// _textValue
|
||||
//
|
||||
this._textValue.Location = new System.Drawing.Point(102, 72);
|
||||
this._textValue.Name = "_textValue";
|
||||
this._textValue.Size = new System.Drawing.Size(142, 20);
|
||||
this._textValue.TabIndex = 2;
|
||||
//
|
||||
// _selectOperator
|
||||
//
|
||||
this._selectOperator.FormattingEnabled = true;
|
||||
this._selectOperator.Location = new System.Drawing.Point(102, 45);
|
||||
this._selectOperator.Name = "_selectOperator";
|
||||
this._selectOperator.Size = new System.Drawing.Size(142, 21);
|
||||
this._selectOperator.TabIndex = 3;
|
||||
//
|
||||
// _ruleGroup
|
||||
//
|
||||
this._ruleGroup.Controls.Add(this.label2);
|
||||
this._ruleGroup.Controls.Add(this._textName);
|
||||
this._ruleGroup.Controls.Add(this._selectOperator);
|
||||
this._ruleGroup.Controls.Add(this.label1);
|
||||
this._ruleGroup.Controls.Add(this._textValue);
|
||||
this._ruleGroup.Location = new System.Drawing.Point(12, 12);
|
||||
this._ruleGroup.Name = "_ruleGroup";
|
||||
this._ruleGroup.Size = new System.Drawing.Size(250, 98);
|
||||
this._ruleGroup.TabIndex = 4;
|
||||
this._ruleGroup.TabStop = false;
|
||||
this._ruleGroup.Text = "Rule";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(6, 75);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(59, 13);
|
||||
this.label2.TabIndex = 5;
|
||||
this.label2.Text = "Tag Value:";
|
||||
//
|
||||
// _buttonOK
|
||||
//
|
||||
this._buttonOK.Location = new System.Drawing.Point(186, 116);
|
||||
this._buttonOK.Name = "_buttonOK";
|
||||
this._buttonOK.Size = new System.Drawing.Size(75, 23);
|
||||
this._buttonOK.TabIndex = 5;
|
||||
this._buttonOK.Text = "OK";
|
||||
this._buttonOK.UseVisualStyleBackColor = true;
|
||||
this._buttonOK.Click += new System.EventHandler(this._buttonOK_Click);
|
||||
//
|
||||
// _buttonCancel
|
||||
//
|
||||
this._buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this._buttonCancel.Location = new System.Drawing.Point(105, 116);
|
||||
this._buttonCancel.Name = "_buttonCancel";
|
||||
this._buttonCancel.Size = new System.Drawing.Size(75, 23);
|
||||
this._buttonCancel.TabIndex = 6;
|
||||
this._buttonCancel.Text = "Cancel";
|
||||
this._buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// ValueRuleForm
|
||||
//
|
||||
this.AcceptButton = this._buttonOK;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this._buttonCancel;
|
||||
this.ClientSize = new System.Drawing.Size(273, 151);
|
||||
this.Controls.Add(this._buttonCancel);
|
||||
this.Controls.Add(this._buttonOK);
|
||||
this.Controls.Add(this._ruleGroup);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "ValueRuleForm";
|
||||
this.ShowInTaskbar = false;
|
||||
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
||||
this.Text = "Edit Value Rule";
|
||||
this.TopMost = true;
|
||||
this._ruleGroup.ResumeLayout(false);
|
||||
this._ruleGroup.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.TextBox _textName;
|
||||
private System.Windows.Forms.TextBox _textValue;
|
||||
private System.Windows.Forms.ComboBox _selectOperator;
|
||||
private System.Windows.Forms.GroupBox _ruleGroup;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Button _buttonOK;
|
||||
private System.Windows.Forms.Button _buttonCancel;
|
||||
}
|
||||
}
|
100
Windows/Search/ValueRuleForm.cs
Normal file
100
Windows/Search/ValueRuleForm.cs
Normal file
|
@ -0,0 +1,100 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using NBTExplorer.Model.Search;
|
||||
|
||||
namespace NBTExplorer.Windows.Search
|
||||
{
|
||||
public partial class ValueRuleForm : Form
|
||||
{
|
||||
public ValueRuleForm (Dictionary<NumericOperator, string> operators)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
foreach (var op in operators)
|
||||
_selectOperator.Items.Add(op.Key);
|
||||
|
||||
_selectOperator.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
public string RuleGroupName
|
||||
{
|
||||
get { return _ruleGroup.Text; }
|
||||
set { _ruleGroup.Text = value; }
|
||||
}
|
||||
|
||||
public string TagName
|
||||
{
|
||||
get { return _textName.Text; }
|
||||
set { _textName.Text = value; }
|
||||
}
|
||||
|
||||
public string TagValue
|
||||
{
|
||||
get { return _textValue.Text; }
|
||||
set { _textValue.Text = value; }
|
||||
}
|
||||
|
||||
public long TagValueAsLong
|
||||
{
|
||||
get
|
||||
{
|
||||
long lvalue;
|
||||
if (long.TryParse(TagValue, out lvalue))
|
||||
return lvalue;
|
||||
|
||||
double fvalue;
|
||||
if (double.TryParse(TagValue, out fvalue))
|
||||
return (long)fvalue;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double TagValueAsDouble
|
||||
{
|
||||
get
|
||||
{
|
||||
double fvalue;
|
||||
if (double.TryParse(TagValue, out fvalue))
|
||||
return fvalue;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public NumericOperator Operator
|
||||
{
|
||||
get { return (NumericOperator)_selectOperator.SelectedItem; }
|
||||
set { _selectOperator.SelectedItem = value; }
|
||||
}
|
||||
|
||||
private void _buttonOK_Click (object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(TagName) || !TryParseValue()) {
|
||||
MessageBox.Show(this, "Rule missing name or value");
|
||||
return;
|
||||
}
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
|
||||
private bool TryParseValue ()
|
||||
{
|
||||
if (Operator == NumericOperator.Any)
|
||||
return true;
|
||||
|
||||
long lvalue;
|
||||
double fvalue;
|
||||
if (long.TryParse(TagValue, out lvalue) || double.TryParse(TagValue, out fvalue))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
120
Windows/Search/ValueRuleForm.resx
Normal file
120
Windows/Search/ValueRuleForm.resx
Normal file
|
@ -0,0 +1,120 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
150
Windows/Search/WildcardRuleForm.Designer.cs
generated
Normal file
150
Windows/Search/WildcardRuleForm.Designer.cs
generated
Normal file
|
@ -0,0 +1,150 @@
|
|||
namespace NBTExplorer.Windows.Search
|
||||
{
|
||||
partial class WildcardRuleForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose (bool disposing)
|
||||
{
|
||||
if (disposing && (components != null)) {
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent ()
|
||||
{
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this._textName = new System.Windows.Forms.TextBox();
|
||||
this._textValue = new System.Windows.Forms.TextBox();
|
||||
this._selectOperator = new System.Windows.Forms.ComboBox();
|
||||
this._ruleGroup = new System.Windows.Forms.GroupBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this._buttonOK = new System.Windows.Forms.Button();
|
||||
this._buttonCancel = new System.Windows.Forms.Button();
|
||||
this._ruleGroup.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(6, 22);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(60, 13);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "Tag Name:";
|
||||
//
|
||||
// _textName
|
||||
//
|
||||
this._textName.Location = new System.Drawing.Point(102, 19);
|
||||
this._textName.Name = "_textName";
|
||||
this._textName.Size = new System.Drawing.Size(142, 20);
|
||||
this._textName.TabIndex = 1;
|
||||
//
|
||||
// _textValue
|
||||
//
|
||||
this._textValue.Location = new System.Drawing.Point(102, 72);
|
||||
this._textValue.Name = "_textValue";
|
||||
this._textValue.Size = new System.Drawing.Size(142, 20);
|
||||
this._textValue.TabIndex = 2;
|
||||
//
|
||||
// _selectOperator
|
||||
//
|
||||
this._selectOperator.FormattingEnabled = true;
|
||||
this._selectOperator.Location = new System.Drawing.Point(102, 45);
|
||||
this._selectOperator.Name = "_selectOperator";
|
||||
this._selectOperator.Size = new System.Drawing.Size(142, 21);
|
||||
this._selectOperator.TabIndex = 3;
|
||||
//
|
||||
// _ruleGroup
|
||||
//
|
||||
this._ruleGroup.Controls.Add(this.label2);
|
||||
this._ruleGroup.Controls.Add(this._textName);
|
||||
this._ruleGroup.Controls.Add(this._selectOperator);
|
||||
this._ruleGroup.Controls.Add(this.label1);
|
||||
this._ruleGroup.Controls.Add(this._textValue);
|
||||
this._ruleGroup.Location = new System.Drawing.Point(12, 12);
|
||||
this._ruleGroup.Name = "_ruleGroup";
|
||||
this._ruleGroup.Size = new System.Drawing.Size(250, 98);
|
||||
this._ruleGroup.TabIndex = 4;
|
||||
this._ruleGroup.TabStop = false;
|
||||
this._ruleGroup.Text = "Rule";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(6, 75);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(59, 13);
|
||||
this.label2.TabIndex = 5;
|
||||
this.label2.Text = "Tag Value:";
|
||||
//
|
||||
// _buttonOK
|
||||
//
|
||||
this._buttonOK.Location = new System.Drawing.Point(186, 116);
|
||||
this._buttonOK.Name = "_buttonOK";
|
||||
this._buttonOK.Size = new System.Drawing.Size(75, 23);
|
||||
this._buttonOK.TabIndex = 5;
|
||||
this._buttonOK.Text = "OK";
|
||||
this._buttonOK.UseVisualStyleBackColor = true;
|
||||
this._buttonOK.Click += new System.EventHandler(this._buttonOK_Click);
|
||||
//
|
||||
// _buttonCancel
|
||||
//
|
||||
this._buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this._buttonCancel.Location = new System.Drawing.Point(105, 116);
|
||||
this._buttonCancel.Name = "_buttonCancel";
|
||||
this._buttonCancel.Size = new System.Drawing.Size(75, 23);
|
||||
this._buttonCancel.TabIndex = 6;
|
||||
this._buttonCancel.Text = "Cancel";
|
||||
this._buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// ValueRuleForm
|
||||
//
|
||||
this.AcceptButton = this._buttonOK;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this._buttonCancel;
|
||||
this.ClientSize = new System.Drawing.Size(273, 151);
|
||||
this.Controls.Add(this._buttonCancel);
|
||||
this.Controls.Add(this._buttonOK);
|
||||
this.Controls.Add(this._ruleGroup);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "ValueRuleForm";
|
||||
this.ShowInTaskbar = false;
|
||||
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
||||
this.Text = "Edit Value Rule";
|
||||
this.TopMost = true;
|
||||
this._ruleGroup.ResumeLayout(false);
|
||||
this._ruleGroup.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.TextBox _textName;
|
||||
private System.Windows.Forms.TextBox _textValue;
|
||||
private System.Windows.Forms.ComboBox _selectOperator;
|
||||
private System.Windows.Forms.GroupBox _ruleGroup;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Button _buttonOK;
|
||||
private System.Windows.Forms.Button _buttonCancel;
|
||||
}
|
||||
}
|
59
Windows/Search/WildcardRuleForm.cs
Normal file
59
Windows/Search/WildcardRuleForm.cs
Normal file
|
@ -0,0 +1,59 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using NBTExplorer.Model.Search;
|
||||
|
||||
namespace NBTExplorer.Windows.Search
|
||||
{
|
||||
public partial class WildcardRuleForm : Form
|
||||
{
|
||||
public WildcardRuleForm (Dictionary<WildcardOperator, string> operators)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
foreach (var op in operators)
|
||||
_selectOperator.Items.Add(op.Key);
|
||||
|
||||
_selectOperator.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
public string RuleGroupName
|
||||
{
|
||||
get { return _ruleGroup.Text; }
|
||||
set { _ruleGroup.Text = value; }
|
||||
}
|
||||
|
||||
public string TagName
|
||||
{
|
||||
get { return _textName.Text; }
|
||||
set { _textName.Text = value; }
|
||||
}
|
||||
|
||||
public string TagValue
|
||||
{
|
||||
get { return _textValue.Text; }
|
||||
set { _textValue.Text = value; }
|
||||
}
|
||||
|
||||
public WildcardOperator Operator
|
||||
{
|
||||
get { return (WildcardOperator)_selectOperator.SelectedItem; }
|
||||
set { _selectOperator.SelectedItem = value; }
|
||||
}
|
||||
|
||||
private void _buttonOK_Click (object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(TagName)) {
|
||||
MessageBox.Show(this, "Rule missing name");
|
||||
return;
|
||||
}
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
120
Windows/Search/WildcardRuleForm.resx
Normal file
120
Windows/Search/WildcardRuleForm.resx
Normal file
|
@ -0,0 +1,120 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
Loading…
Reference in a new issue