public static void Save()
{
string BackgroundColor = "Black";
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// HANLDE Display Attributes First
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
string FileName;
FileName = @"C:\ASTERIX\ADAPTATION\DisplayAttributes.txt";
DisplayAttributes.DisplayAttributesType DisplayAttribute = new DisplayAttributes.DisplayAttributesType();
string DisplayAttributesStream = "#ITEM_NAME,TEXT_SIZE,TEXT_FONT,TEXT_COLOR,LINE_WIDTH,LINE_COLOR,LINE_STYLE,AREA_COLOR,IMAGE_SIZE" + Environment.NewLine;
System.Collections.Generic.List<DisplayAttributes.DisplayAttributesType> AllDisplayAtributes = DisplayAttributes.GetAllDisplayAttributes();
foreach (DisplayAttributes.DisplayAttributesType DataItem in DisplayAttributes.GetAllDisplayAttributes())
{
if (DataItem.ItemName != "BackgroundColor")
{
DisplayAttributesStream = DisplayAttributesStream + DataItem.ItemName + ',';
DisplayAttributesStream = DisplayAttributesStream + DataItem.TextSize.ToString() + ',';
DisplayAttributesStream = DisplayAttributesStream + DataItem.TextFont.Name + ',';
DisplayAttributesStream = DisplayAttributesStream + DataItem.TextColor.Name + ',';
DisplayAttributesStream = DisplayAttributesStream + DataItem.LineWidth.ToString() + ',';
DisplayAttributesStream = DisplayAttributesStream + DataItem.LineColor.Name + ',';
DisplayAttributesStream = DisplayAttributesStream + DataItem.LineStyle.ToString() + ',';
DisplayAttributesStream = DisplayAttributesStream + DataItem.AreaPolygonColor.Name + ',';
DisplayAttributesStream = DisplayAttributesStream + DataItem.ImageSize.Width.ToString() + ',';
DisplayAttributesStream = DisplayAttributesStream + DataItem.ImageSize.Height.ToString() + Environment.NewLine;
}
else
{
BackgroundColor = DataItem.TextColor.Name;
}
}
// Remove the last character, which is the new line.
DisplayAttributesStream.Remove(DisplayAttributesStream.Length - 1);
// create a writer and open the file
TextWriter tw = new StreamWriter(FileName);
try
{
// write a line of text to the file
tw.Write(DisplayAttributesStream);
MessageBox.Show("DisplayAttributes succefully saved");
}
catch (System.IO.IOException e)
{
MessageBox.Show(e.Message);
}
// close the stream
tw.Close();
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// HANLDE MainSettings First
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
FileName = @"C:\ASTERIX\ADAPTATION\Main_Settings.txt";
DisplayAttributesStream = "# System center is : Deg (int), Min (int), Sec (int), Prefix (E/W/N/S)" + Environment.NewLine;
GeoCordSystemDegMinSecUtilities.LatLongClass LatLon = new GeoCordSystemDegMinSecUtilities.LatLongClass(SystemAdaptationDataSet.SystemOriginPoint.Lat, SystemAdaptationDataSet.SystemOriginPoint.Lng);
int Int_Lat_Sec = (int)LatLon.GetDegMinSec().Latitude.Sec;
string LatPrefix = "N";
if (LatLon.GetDegMinSec().Latitude.Prefix == GeoCordSystemDegMinSecUtilities.LatLongPrefix.S)
LatPrefix = "S";
int Int_Lon_Sec = (int)LatLon.GetDegMinSec().Longitude.Sec;
string LonPrefix = "E";
if (LatLon.GetDegMinSec().Longitude.Prefix == GeoCordSystemDegMinSecUtilities.LatLongPrefix.W)
LonPrefix = "W";
// 44,6,0,N,20,0,0,E
DisplayAttributesStream = DisplayAttributesStream + "SYS_ORIGIN," +
LatLon.GetDegMinSec().Latitude.Deg.ToString() + ',' + LatLon.GetDegMinSec().Latitude.Min.ToString() + ',' + Int_Lat_Sec.ToString() + ',' + LatPrefix + ',' +
LatLon.GetDegMinSec().Longitude.Deg.ToString() + ',' + LatLon.GetDegMinSec().Longitude.Min.ToString() + ',' + Int_Lon_Sec.ToString() + ',' + LonPrefix +
Environment.NewLine; ;
DisplayAttributesStream = DisplayAttributesStream + "BACKGROUND," + BackgroundColor;
// create a writer and open the file
tw = new StreamWriter(FileName);
try
{
// write a line of text to the file
tw.Write(DisplayAttributesStream);
MessageBox.Show("Main_Settings succefully saved");
}
catch (System.IO.IOException e)
{
MessageBox.Show(e.Message);
}
// close the stream
tw.Close();
}