#region "forClass"
//value of the width textBoxAddress property; default value = 100
int textBox_Width = 100;
//value of the textBoxAddress height property; default value = 26
int textBox_Height = 26;
//value of the labelAddress width property; default value = 40
int label_Width = 40;
//value of the textBoxAddress Multiline property; default value = "true"
bool textBox_Multiline = true;
string Symbol_City = "000000";
string Street = "Green Street";
string Building = "5";
string Apartment = "9";
string Entrance = "A";
string ZIP = "99999";
string ADDRESS = "ADDRESS";
string City = "Sun City";
DataTable dt_Cities = new DataTable ();
string Value_Member ="";
string Display_Member = "";
//Length of the Symbol_City string that has to be used for "find" process
int Length_Symbol = 6;
#endregion
//-----------------------------------------------------------------
//The method that allows to adjust the control sizes
//according to the sizes of the textBox
private void init()
{
panelTextBox.Width = textBox_Width ;
panelAddress.Width = textBox_Width + label_Width + 8;
panelAddress.Height = C_TextBox_Height ;
this.Height = C_TextBox_Height + 2;
this.Width = panelAddress.Width + 2;
}
//----------------------------------------------------------------
//The method showAddress that shows the FormAddress form
//as a modal dialog if the adr_OK property of the FormAddress
//equals "true"
private void showAddress()
{
FormAddress fAddress = new FormAddress ();
fillProperties_Form(fAddress);
fAddress.ShowDialog ();
if (fAddress.adr_OK )
{
getFromProperties_Form (fAddress);
}
}
//----------------------------------------------------------------
//The method fillProperties_Form that sets
//the FormAddress properties
private void fillProperties_Form(FormAddress f)
{
ADDRESS = getAddress();
f.adr_APARTMENT = Apartment ;
f.adr_BUILDING = Building ;
f.adr_ENTRANCE = Entrance ;
f.adr_ZIP = ZIP;
f.adr_SYMBOL_CITY = Symbol_City ;
f.adr_STREET = Street;
f.adr_CITY = City;
f.adr_Address = ADDRESS;
f.adr_Display_Member = Display_Member ;
f.adr_Value_Member = Value_Member ;
f.adr_DataTableCities = dt_Cities ;
f.adr_lengthCode = Length_Symbol ;
}
//----------------------------------------------------------------
//The method getFromProperties_Form that sets
//the properties of the control
private void getFromProperties_Form(FormAddress f)
{
this.C_APARTMENT = f.adr_APARTMENT ;
this.C_BUILDING = f.adr_BUILDING ;
this.C_ENTRANCE = f.adr_ENTRANCE;
this.C_ZIP = f.adr_ZIP;
this.C_SYMBOL_CITY = f.adr_SYMBOL_CITY;
this.C_STREET = f.adr_STREET;
this.C_CITY = f.adr_CITY;
this.C_Address = f.adr_Address;
}
//-----------------------------------------------
//The method that returns "Address" as one string
private string getAddress()
{
string sResult="";
sResult= Street + " " + Building + "/" + Apartment +
", " + Entrance + " " + ZIP + ", " + City;
return (sResult);
}
//----------------------------------------------
//The method textBoxAddress_KeyUp that executes the showAddress
// method on the KeyUp event of the textBoxAddress
private void textBoxAddress_KeyUp
(object sender, System.Windows.Forms.KeyEventArgs e)
{
showAddress ();
}
//The method labelAddress_DoubleClick that executes
//the showAddress method on the DoubleClick event of the labelAddress
private void labelAddress_DoubleClick(object sender, System.EventArgs e)
{
showAddress ();
}
//One of opportunities to apply the init() method is
//to "call" it from the Address_Resize event
private void Address_Resize(object sender, System.EventArgs e)
{
// init();
}
//---------------------------------------------
#region "properties"
//The C_TextBox_Width property that allows to set:
//the panelTextBox width property,
//the panelAddress width property,
//the Address control width property
public int C_TextBox_Width
{
get
{
return textBox_Width;
}
set
{
textBox_Width =value ;
panelTextBox.Width =textBox_Width ;
panelAddress.Width =textBox_Width + label_Width + 8;
this.Width = panelAddress.Width + 2;
}
}
//-------------------------------------------------------------
public int C_TextBox_Height
{
get
{
return textBox_Height;
}
set
{
textBox_Height = value ;
panelAddress.Height = C_TextBox_Height ;
this.Height = C_TextBox_Height + 2;
}
}
//----------------------------------------------------
public bool C_TextBox_Multiline
{
get
{
return textBox_Multiline;
}
set
{
textBox_Multiline = value;
textBoxAddress.Multiline = textBox_Multiline;
}
}
//--------------------------------------------------
public string C_CITY
{
get
{
return City;
}
set
{
City = value;
}
}
//---------------------------------------------------------
public string C_SYMBOL_CITY
{
get
{
return Symbol_City;
}
set
{
Symbol_City = value;
}
}
//-------------------------------------------------
public string C_STREET
{
get
{
return Street;
}
set
{
Street = value;
}
}
//-------------------------------------------------
public string C_BUILDING
{
get
{
return Building;
}
set
{
Building = value;
}
}
//-------------------------------------------------
public string C_APARTMENT
{
get
{
return Apartment;
}
set
{
Apartment = value;
}
}
//-------------------------------------------------
public string C_ENTRANCE
{
get
{
return Entrance;
}
set
{
Entrance = value;
}
}
//-------------------------------------------------
public string C_ZIP
{
get
{
return ZIP;
}
set
{
ZIP = value;
}
}
//----------------------------------------------------------
public string C_Address
{
get
{
ADDRESS = getAddress ();
return ADDRESS;
}
set
{
ADDRESS = value;
textBoxAddress.Text = ADDRESS;
}
}
//----------------------------------------------------------------
//The C_LengthSymbol property that sets the length of
//the Symbol_City string that has to be used for "find" process
//of the FormAddress form.
public int C_LengthSymbol
{
set
{
Length_Symbol = value;
}
}
//----------------------------------------------------------------
public DataTable C_DataTableCities
{
set
{
dt_Cities = value;
}
}
//----------------------------------------------------------------
public string C_Value_Member
{
set
{
Value_Member = value;
}
}
//----------------------------------------------------------------
public string C_Display_Member
{
set
{
Display_Member = value;
}
}
#endregion