using System;
using System.Collections.Generic;
using System.Text;
namespace Be.Windows.Forms
{
///
/// Defines the type of the Find operation.
///
public enum FindType
{
///
/// Used for Text Find operations
///
Text,
///
/// Used for Hex Find operations
///
Hex
}
///
/// Defines all state information nee
///
public class FindOptions
{
public bool WrapSearch { get; set; }
public bool HasWildcard { get; set; }
///
/// Gets or sets whether the Find options are valid
///
public bool IsValid { get; set; }
///
/// Gets the Find buffer used for case insensitive Find operations. This is the binary representation of Text.
///
internal byte[] FindBuffer { get; private set; }
///
/// Gets the Find buffer used for case sensitive Find operations. This is the binary representation of Text in lower case format.
///
internal byte[] FindBufferLowerCase { get; private set; }
///
/// Gets the Find buffer used for case sensitive Find operations. This is the binary representation of Text in upper case format.
///
internal byte[] FindBufferUpperCase { get; private set; }
///
/// Contains the MatchCase value
///
bool _matchCase;
///
/// Gets or sets the value, whether the Find operation is case sensitive or not.
///
public bool MatchCase
{
get { return _matchCase; }
set
{
_matchCase = value;
}
}
///
/// Contains the text that should be found.
///
string _text;
///
/// Gets or sets the text that should be found. Only used, when Type is FindType.Hex.
///
public string Text
{
get { return _text; }
set
{
_text = value;
}
}
///
/// Gets or sets the hex buffer that should be found. Only used, when Type is FindType.Hex.
///
public byte[] Hex { get; set; }
///
/// Gets or sets the type what should be searched.
///
public FindType Type { get; set; }
///
/// Updates the find buffer.
///
internal void UpdateFindBuffer(IByteCharConverter byteCharConverter)
{
string text = this.Text != null ? this.Text : string.Empty;
FindBuffer = byteCharConverter.GetBytes(text);
FindBufferLowerCase = byteCharConverter.GetBytes(text.ToLower());
FindBufferUpperCase = byteCharConverter.GetBytes(text.ToUpper());
}
}
}