using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using QC.QsprShared.Config;

namespace QC.QTMApplication;

public class SearchSetting : Form
{
	public delegate bool SearchEventHandler(object sender, EventArgs e);

	private WorkspaceConfig WConfig;

	private IContainer components;

	private Label label1;

	private TextBox txtSearchString;

	private Label label2;

	private ComboBox cboSearchOption;

	private GroupBox groupBox1;

	private CheckBox chkMatchCase;

	private Button btnOk;

	private Label label3;

	public event SearchEventHandler SearchChangedEvent;

	public SearchSetting(WorkspaceConfig wConfig)
	{
		WConfig = wConfig;
		InitializeComponent();
		txtSearchString.Text = WConfig.SearchString;
		cboSearchOption.DataSource = Enum.GetValues(typeof(WorkspaceConfig.SearchOptions));
		cboSearchOption.SelectedItem = WConfig.CurrentSearchOptions;
		chkMatchCase.Checked = WConfig.SearchCaseMatch;
	}

	private void btnOk_Click(object sender, EventArgs e)
	{
		WConfig.CurrentSearchOptions = (WorkspaceConfig.SearchOptions)cboSearchOption.SelectedValue;
		WConfig.SearchString = txtSearchString.Text;
		WConfig.SearchCaseMatch = chkMatchCase.Checked;
		base.DialogResult = DialogResult.OK;
		Close();
	}

	private void cboSearchOption_SelectedValueChanged(object sender, EventArgs e)
	{
		if (cboSearchOption.Text == WorkspaceConfig.SearchOptions.TestName.ToString() || cboSearchOption.Text == WorkspaceConfig.SearchOptions.RealName.ToString() || cboSearchOption.Text == WorkspaceConfig.SearchOptions.ParameterName.ToString() || cboSearchOption.Text == WorkspaceConfig.SearchOptions.TestErrorCode.ToString() || cboSearchOption.Text == WorkspaceConfig.SearchOptions.Comments.ToString() || cboSearchOption.Text == WorkspaceConfig.SearchOptions.Registry.ToString())
		{
			txtSearchString.Enabled = true;
		}
		else
		{
			txtSearchString.Enabled = false;
		}
		if (cboSearchOption.Text == WorkspaceConfig.SearchOptions.ParameterName.ToString())
		{
			chkMatchCase.Enabled = false;
		}
		else
		{
			chkMatchCase.Enabled = true;
		}
	}

	protected override void Dispose(bool disposing)
	{
		if (disposing && components != null)
		{
			components.Dispose();
		}
		base.Dispose(disposing);
	}

	private void InitializeComponent()
	{
		this.label1 = new System.Windows.Forms.Label();
		this.txtSearchString = new System.Windows.Forms.TextBox();
		this.label2 = new System.Windows.Forms.Label();
		this.cboSearchOption = new System.Windows.Forms.ComboBox();
		this.groupBox1 = new System.Windows.Forms.GroupBox();
		this.chkMatchCase = new System.Windows.Forms.CheckBox();
		this.btnOk = new System.Windows.Forms.Button();
		this.label3 = new System.Windows.Forms.Label();
		this.groupBox1.SuspendLayout();
		base.SuspendLayout();
		this.label1.AutoSize = true;
		this.label1.Location = new System.Drawing.Point(1, 52);
		this.label1.Name = "label1";
		this.label1.Size = new System.Drawing.Size(53, 13);
		this.label1.TabIndex = 0;
		this.label1.Text = "Find what";
		this.txtSearchString.Location = new System.Drawing.Point(4, 69);
		this.txtSearchString.Name = "txtSearchString";
		this.txtSearchString.Size = new System.Drawing.Size(223, 20);
		this.txtSearchString.TabIndex = 1;
		this.label2.AutoSize = true;
		this.label2.Location = new System.Drawing.Point(1, 9);
		this.label2.Name = "label2";
		this.label2.Size = new System.Drawing.Size(45, 13);
		this.label2.TabIndex = 2;
		this.label2.Text = "Look in:";
		this.cboSearchOption.FormattingEnabled = true;
		this.cboSearchOption.Items.AddRange(new object[3] { "Test Name (as appears in the Test Tree)", "Real Name (as appears in the Test Code)", "Parameter Name" });
		this.cboSearchOption.Location = new System.Drawing.Point(4, 26);
		this.cboSearchOption.Name = "cboSearchOption";
		this.cboSearchOption.Size = new System.Drawing.Size(223, 21);
		this.cboSearchOption.TabIndex = 3;
		this.cboSearchOption.SelectedValueChanged += new System.EventHandler(cboSearchOption_SelectedValueChanged);
		this.groupBox1.Controls.Add(this.chkMatchCase);
		this.groupBox1.Location = new System.Drawing.Point(3, 95);
		this.groupBox1.Name = "groupBox1";
		this.groupBox1.Size = new System.Drawing.Size(224, 64);
		this.groupBox1.TabIndex = 4;
		this.groupBox1.TabStop = false;
		this.groupBox1.Text = "Find options";
		this.chkMatchCase.AutoSize = true;
		this.chkMatchCase.Location = new System.Drawing.Point(7, 20);
		this.chkMatchCase.Name = "chkMatchCase";
		this.chkMatchCase.Size = new System.Drawing.Size(82, 17);
		this.chkMatchCase.TabIndex = 0;
		this.chkMatchCase.Text = "Match case";
		this.chkMatchCase.UseVisualStyleBackColor = true;
		this.btnOk.BackColor = System.Drawing.SystemColors.Control;
		this.btnOk.Location = new System.Drawing.Point(129, 165);
		this.btnOk.Name = "btnOk";
		this.btnOk.Size = new System.Drawing.Size(98, 23);
		this.btnOk.TabIndex = 5;
		this.btnOk.Text = "Find Next";
		this.btnOk.UseVisualStyleBackColor = true;
		this.btnOk.Click += new System.EventHandler(btnOk_Click);
		this.label3.AutoSize = true;
		this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		this.label3.Location = new System.Drawing.Point(1, 188);
		this.label3.Name = "label3";
		this.label3.Size = new System.Drawing.Size(114, 15);
		this.label3.TabIndex = 6;
		this.label3.Text = "Use F3 to Find Next";
		base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f);
		base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
		base.ClientSize = new System.Drawing.Size(229, 210);
		base.Controls.Add(this.label3);
		base.Controls.Add(this.btnOk);
		base.Controls.Add(this.groupBox1);
		base.Controls.Add(this.cboSearchOption);
		base.Controls.Add(this.label2);
		base.Controls.Add(this.txtSearchString);
		base.Controls.Add(this.label1);
		base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
		base.MaximizeBox = false;
		base.Name = "SearchSetting";
		base.ShowIcon = false;
		base.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
		this.Text = "Search Setting";
		this.groupBox1.ResumeLayout(false);
		this.groupBox1.PerformLayout();
		base.ResumeLayout(false);
		base.PerformLayout();
	}
}
