コード例 #1
0
ファイル: RunwayBorderDisplay.cs プロジェクト: tanxulong/MUAC
        public static void Build(ref GMapOverlay OverlayOut)
        {
            // Here loop through defined Runways and display them on the map
            foreach (SystemAdaptationDataSet.RunwayBorder Runway in SystemAdaptationDataSet.RunwayBorderDataSet)
            {
                System.Collections.Generic.List <PointLatLng> RunwayPointList = new System.Collections.Generic.List <PointLatLng>();
                foreach (GeoCordSystemDegMinSecUtilities.LatLongClass RunwayPoint in Runway.RunwayBorderPoints)
                {
                    RunwayPointList.Add(new PointLatLng(RunwayPoint.GetLatLongDecimal().LatitudeDecimal, RunwayPoint.GetLatLongDecimal().LongitudeDecimal));
                }

                // Get Runway border display attributes
                DisplayAttributes.DisplayAttributesType RunwayBorderDisplayAttribute = DisplayAttributes.GetDisplayAttribute(DisplayAttributes.DisplayItemsType.RunwayBorder);

                GMapPolygon RunwayPolygon = new GMapPolygon(RunwayPointList, Runway.RunwayName);
                RunwayPolygon.Stroke = new Pen(RunwayBorderDisplayAttribute.LineColor, RunwayBorderDisplayAttribute.LineWidth);

                Type brushType = typeof(Brushes);

                Brush myBrush = (Brush)brushType.InvokeMember(RunwayBorderDisplayAttribute.AreaPolygonColor.Name,
                                                              BindingFlags.Public | BindingFlags.Static | BindingFlags.GetProperty,
                                                              null, null, new object[] { });

                RunwayPolygon.Fill = myBrush;
                OverlayOut.Polygons.Add(RunwayPolygon);
            }
        }
コード例 #2
0
        public static void Build(ref GMapOverlay OverlayOut)
        {
            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Display defined radars
            //
            string FileName   = @"C:\ASTERIX\IMAGES\radar.jpg";
            Image  RadarImage = Image.FromFile(FileName);

            // Get radar display attributes
            DisplayAttributes.DisplayAttributesType RadarDisplayAttribute = DisplayAttributes.GetDisplayAttribute(DisplayAttributes.DisplayItemsType.Radar);
            RadarImage = GraphicUtilities.ResizeImage(RadarImage, new Size(RadarDisplayAttribute.ImageSize.Width, RadarDisplayAttribute.ImageSize.Height), false);

            // Here loop through defined radars and display them on the map
            foreach (SystemAdaptationDataSet.Radar Radar in SystemAdaptationDataSet.RadarDataSet)
            {
                // Image properties
                GMapMarkerImage MyMarkerImage =
                    new GMapMarkerImage(new PointLatLng(Radar.RadarPosition.GetLatLongDecimal().LatitudeDecimal, Radar.RadarPosition.GetLatLongDecimal().LongitudeDecimal), RadarImage);
                MyMarkerImage.ToolTipMode = MarkerTooltipMode.Never;
                System.Drawing.SolidBrush myBrush;

                myBrush = new System.Drawing.SolidBrush(RadarDisplayAttribute.TextColor);

                // Get radar marker image
                WaypointMarker WPT_Marker = new WaypointMarker(new PointLatLng(Radar.RadarPosition.GetLatLongDecimal().LatitudeDecimal, Radar.RadarPosition.GetLatLongDecimal().LongitudeDecimal), Radar.RadarName,
                                                               new Font(RadarDisplayAttribute.TextFont, RadarDisplayAttribute.TextSize, FontStyle.Bold, GraphicsUnit.Pixel), myBrush);

                // Load radar marker and label to overlay
                OverlayOut.Markers.Add(MyMarkerImage);
                OverlayOut.Markers.Add(WPT_Marker);
            }
        }
コード例 #3
0
        public static void Load()
        {
            string DisplayAdaptationDataLine;
            string FileName;

            char[]       delimiterChars = { ',', '\t' };
            StreamReader MyStreamReader;

            FileName = @"C:\ASTERIX\ADAPTATION\DisplayAttributes.txt";

            if (System.IO.File.Exists(FileName))
            {
                MyStreamReader = System.IO.File.OpenText(FileName);
                while (MyStreamReader.Peek() >= 0)
                {
                    DisplayAdaptationDataLine = MyStreamReader.ReadLine();
                    string[] words = DisplayAdaptationDataLine.Split(delimiterChars);
                    if (words[0][0] != '#')
                    {
                        DisplayAttributes.DisplayAttributesType DisplayAttribute = new DisplayAttributes.DisplayAttributesType();

                        DisplayAttribute.ItemName         = words[0];
                        DisplayAttribute.TextSize         = int.Parse(words[1]);
                        DisplayAttribute.TextFont         = new FontFamily(words[2]);
                        DisplayAttribute.TextColor        = Color.FromName(words[3]);
                        DisplayAttribute.LineWidth        = int.Parse(words[4]);
                        DisplayAttribute.LineColor        = Color.FromName(words[5]);
                        DisplayAttribute.LineStyle        = DisplayAttributes.GetLineStypefromString(words[6]);
                        DisplayAttribute.AreaPolygonColor = Color.FromName(words[7]);
                        DisplayAttribute.ImageSize        = new Size(int.Parse(words[8]), int.Parse((words[9])));
                        DisplayAttributes.SetDisplayAttribute((DisplayAttributes.DisplayItemsType)Enum.Parse(typeof(DisplayAttributes.DisplayItemsType), DisplayAttribute.ItemName, true), DisplayAttribute);
                    }
                }
            }
        }
        public static void Load()
        {
            string DisplayAdaptationDataLine;
            string FileName;
            char[] delimiterChars = { ',', '\t' };
            StreamReader MyStreamReader;

            FileName = @"C:\ASTERIX\ADAPTATION\DisplayAttributes.txt";

            if (System.IO.File.Exists(FileName))
            {
                MyStreamReader = System.IO.File.OpenText(FileName);
                while (MyStreamReader.Peek() >= 0)
                {
                    DisplayAdaptationDataLine = MyStreamReader.ReadLine();
                    string[] words = DisplayAdaptationDataLine.Split(delimiterChars);
                    if (words[0][0] != '#')
                    {
                        DisplayAttributes.DisplayAttributesType DisplayAttribute = new DisplayAttributes.DisplayAttributesType();

                        DisplayAttribute.ItemName = words[0];
                        DisplayAttribute.TextSize = int.Parse(words[1]);
                        DisplayAttribute.TextFont = new FontFamily(words[2]);
                        DisplayAttribute.TextColor = Color.FromName(words[3]);
                        DisplayAttribute.LineWidth = int.Parse(words[4]);
                        DisplayAttribute.LineColor = Color.FromName(words[5]);
                        DisplayAttribute.LineStyle = DisplayAttributes.GetLineStypefromString(words[6]);
                        DisplayAttribute.AreaPolygonColor = Color.FromName(words[7]);
                        DisplayAttribute.ImageSize = new Size(int.Parse(words[8]), int.Parse((words[9])));
                        DisplayAttributes.SetDisplayAttribute((DisplayAttributes.DisplayItemsType)Enum.Parse(typeof(DisplayAttributes.DisplayItemsType), DisplayAttribute.ItemName, true), DisplayAttribute);
                    }
                }
            }
        }
コード例 #5
0
        private void SyncFormData()
        {
            // First get all the display attributes for the selected data item
            DisplayAttributes.DisplayAttributesType DisplayAttribute =
                DisplayAttributes.GetDisplayAttribute((DisplayAttributes.DisplayItemsType)Enum.Parse(typeof(DisplayAttributes.DisplayItemsType),
                                                                                                     this.comboBoxDataItem.Text, true));

            /////////////////////////////////////////////////////////////
            // TEXT ATTRIBUTES
            /////////////////////////////////////////////////////////////

            // Text Attributes Color
            this.comboBoxTextColorChoice.SelectedIndex =
                this.comboBoxTextColorChoice.FindStringExact(DisplayAttribute.TextColor.Name);

            // Text Attributes Font
            this.comboBoxTextFontChoice.SelectedIndex =
                this.comboBoxTextFontChoice.FindStringExact(DisplayAttribute.TextFont.Name);

            // Text Attributes Size
            this.comboBoxTextSizeChoice.SelectedIndex = DisplayAttribute.TextSize - 1;

            /////////////////////////////////////////////////////////////
            // LINE ATTRIBUTES
            /////////////////////////////////////////////////////////////

            // Line Attributes Color
            this.comboBoxLineColorChoice.SelectedIndex = this.comboBoxLineColorChoice.FindStringExact(DisplayAttribute.LineColor.Name);

            // Line Attributes Type

            this.comboBoxLineStyleChoice.SelectedIndex = this.comboBoxLineStyleChoice.FindStringExact(DisplayAttribute.LineStyle.ToString());

            // Line Attributes Size.
            this.comboBoxLineWidth.SelectedIndex = DisplayAttribute.LineWidth - 1;

            /////////////////////////////////////////////////////////////
            // AREA/POLYGON ATTRIBUTES
            /////////////////////////////////////////////////////////////
            this.comboBoxAreaPolygonColorChoice.SelectedIndex =
                this.comboBoxAreaPolygonColorChoice.FindStringExact(DisplayAttribute.AreaPolygonColor.Name);

            /////////////////////////////////////////////////////////////
            // IMAGE ATTRIBUTES
            /////////////////////////////////////////////////////////////
            this.numericUpDown_X.Value = DisplayAttribute.ImageSize.Width;
            this.numericUpDown_Y.Value = DisplayAttribute.ImageSize.Height;
            this.pictureBox.BackColor  = Color.FromName(this.comboBoxBackgroundColor.Text);

            UpdateSampleLine();
            UpdateSampleText();
            UpdateAreaPolygonSample();
            UpdatePictureSample();
        }
コード例 #6
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            DisplayAttributes.DisplayAttributesType NewDisplayAttribute = new DisplayAttributes.DisplayAttributesType();
            NewDisplayAttribute.ItemName  = this.comboBoxDataItem.Text;
            NewDisplayAttribute.TextSize  = int.Parse(this.comboBoxTextSizeChoice.Text);
            NewDisplayAttribute.TextFont  = new FontFamily(this.comboBoxTextFontChoice.Text);
            NewDisplayAttribute.TextColor = Color.FromName(this.comboBoxTextColorChoice.Text);
            NewDisplayAttribute.LineWidth = int.Parse(this.comboBoxLineWidth.Text);
            NewDisplayAttribute.LineColor = Color.FromName(this.comboBoxLineColorChoice.Text);
            NewDisplayAttribute.LineStyle = DisplayAttributes.GetLineStypefromString(this.comboBoxLineStyleChoice.Text);

            NewDisplayAttribute.AreaPolygonColor = Color.FromName(this.comboBoxAreaPolygonColorChoice.Text);
            NewDisplayAttribute.ImageSize        = new Size((int)this.numericUpDown_X.Value, (int)this.numericUpDown_Y.Value);
            DisplayAttributes.SetDisplayAttribute((DisplayAttributes.DisplayItemsType)Enum.Parse(typeof(DisplayAttributes.DisplayItemsType), NewDisplayAttribute.ItemName, true), NewDisplayAttribute);

            // Always update the background color as well
            NewDisplayAttribute           = new DisplayAttributes.DisplayAttributesType();
            NewDisplayAttribute.TextColor = Color.FromName(this.comboBoxBackgroundColor.Text);
            NewDisplayAttribute.ItemName  = "BackgroundColor";
            DisplayAttributes.SetDisplayAttribute(DisplayAttributes.DisplayItemsType.BackgroundColor, NewDisplayAttribute);

            // Populate the display origin
            GeoCordSystemDegMinSecUtilities.LatLongPrefix LatPrefix;
            GeoCordSystemDegMinSecUtilities.LatLongPrefix LoNPrefix;

            if (this.comboBoxLatDirection.SelectedIndex == 0)
            {
                LatPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.N;
            }
            else
            {
                LatPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.W;
            }

            if (this.comboBoxLonDirection.SelectedIndex == 0)
            {
                LoNPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.E;
            }
            else
            {
                LoNPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.S;
            }

            GeoCordSystemDegMinSecUtilities.LatLongClass LatLon =
                new GeoCordSystemDegMinSecUtilities.LatLongClass(int.Parse(this.txtLatDDD.Text), int.Parse(this.txtLatMM.Text), int.Parse(this.txtLatSS.Text), LatPrefix,
                                                                 int.Parse(this.txtLonDDD.Text), int.Parse(this.txtLonMM.Text), int.Parse(this.txtLonSS.Text), LoNPrefix);

            SystemAdaptationDataSet.SystemOrigin = new GMap.NET.PointLatLng(LatLon.GetLatLongDecimal().LatitudeDecimal, LatLon.GetLatLongDecimal().LongitudeDecimal);
        }
コード例 #7
0
        public static void Save()
        {
            string FileName;

            FileName = @"C:\ASTERIX\ADAPTATION\LabelAttributes.txt";
            DisplayAttributes.DisplayAttributesType DisplayAttribute = new DisplayAttributes.DisplayAttributesType();
            string DisplayAttributesStream =
                "#TEXT_COLOR,value" + Environment.NewLine +
                "#TEXT_FONT,value" + Environment.NewLine +
                "#TEXT_SIZE,value" + Environment.NewLine +
                "#LINE_COLOR,value" + Environment.NewLine +
                "#LINE_STYLE,value" + Environment.NewLine +
                "#LINE_WIDTH,value" + Environment.NewLine +
                "#TARGET_COLOR,value" + Environment.NewLine +
                "#TARGET_STYLE,value" + Environment.NewLine +
                "#TARGET_SIZE,value" + Environment.NewLine;

            DisplayAttributesStream = DisplayAttributesStream +
                                      "TEXT_COLOR," + LabelAttributes.TextColor.Name + Environment.NewLine +
                                      "TEXT_FONT," + LabelAttributes.TextFont.Name + Environment.NewLine +
                                      "TEXT_SIZE," + LabelAttributes.TextSize.ToString() + Environment.NewLine +
                                      "LINE_COLOR," + LabelAttributes.LineColor.Name + Environment.NewLine +
                                      "LINE_STYLE," + LabelAttributes.LineStyle.ToString() + Environment.NewLine +
                                      "LINE_WIDTH," + LabelAttributes.LineWidth.ToString() + Environment.NewLine +
                                      "TARGET_COLOR," + LabelAttributes.TargetColor.Name + Environment.NewLine +
                                      "TARGET_STYLE," + LabelAttributes.TargetStyle.ToString() + Environment.NewLine +
                                      "TARGET_SIZE," + LabelAttributes.TargetSize.ToString();

            // 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("Label attributes succefully saved");
            }
            catch (System.IO.IOException e)
            {
                MessageBox.Show(e.Message);
            }

            // close the stream
            tw.Close();
        }
コード例 #8
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            DisplayAttributes.DisplayAttributesType NewDisplayAttribute = new DisplayAttributes.DisplayAttributesType();
            NewDisplayAttribute.ItemName = this.comboBoxDataItem.Text;
            NewDisplayAttribute.TextSize = int.Parse(this.comboBoxTextSizeChoice.Text);
            NewDisplayAttribute.TextFont = new FontFamily(this.comboBoxTextFontChoice.Text);
            NewDisplayAttribute.TextColor = Color.FromName(this.comboBoxTextColorChoice.Text);
            NewDisplayAttribute.LineWidth = int.Parse(this.comboBoxLineWidth.Text);
            NewDisplayAttribute.LineColor = Color.FromName(this.comboBoxLineColorChoice.Text);
            NewDisplayAttribute.LineStyle = DisplayAttributes.GetLineStypefromString(this.comboBoxLineStyleChoice.Text);

            NewDisplayAttribute.AreaPolygonColor = Color.FromName(this.comboBoxAreaPolygonColorChoice.Text);

            DisplayAttributes.SetDisplayAttribute((DisplayAttributes.DisplayItemsType)Enum.Parse(typeof(DisplayAttributes.DisplayItemsType), NewDisplayAttribute.ItemName, true), NewDisplayAttribute);

               // Always update the background color as well
            NewDisplayAttribute = new DisplayAttributes.DisplayAttributesType();
            NewDisplayAttribute.TextColor = Color.FromName(this.comboBoxBackgroundColor.Text);
            NewDisplayAttribute.ItemName = "BackgroundColor";
            DisplayAttributes.SetDisplayAttribute(DisplayAttributes.DisplayItemsType.BackgroundColor, NewDisplayAttribute);

            // Populate the display origin
            GeoCordSystemDegMinSecUtilities.LatLongPrefix LatPrefix;
            GeoCordSystemDegMinSecUtilities.LatLongPrefix LoNPrefix;

            if (this.comboBoxLatDirection.SelectedIndex == 0)
                LatPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.N;
            else
                LatPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.W;

            if (this.comboBoxLonDirection.SelectedIndex == 0)
                LoNPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.E;
            else
                LoNPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.S;

            GeoCordSystemDegMinSecUtilities.LatLongClass LatLon =
                new GeoCordSystemDegMinSecUtilities.LatLongClass(int.Parse(this.txtLatDDD.Text), int.Parse(this.txtLatMM.Text), int.Parse(this.txtLatSS.Text), LatPrefix,
                    int.Parse(this.txtLonDDD.Text), int.Parse(this.txtLonMM.Text), int.Parse(this.txtLonSS.Text), LoNPrefix);

            SystemAdaptationDataSet.SystemOrigin = new GMap.NET.PointLatLng(LatLon.GetLatLongDecimal().LatitudeDecimal, LatLon.GetLatLongDecimal().LongitudeDecimal);
        }
コード例 #9
0
        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();
        }
        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();
        }
コード例 #11
0
ファイル: LoadCoreSettings.cs プロジェクト: tanxulong/MUAC
        public static void Load()
        {
            string ConfigurationData;
            string FileName;

            char[]       delimiterChars = { ',', '\t' };
            StreamReader MyStreamReader;

            string ItemName;
            int    LatDeg;
            int    LatMin;
            int    LatSec;

            GeoCordSystemDegMinSecUtilities.LatLongPrefix LatPrefix;
            int LonDeg;
            int LonMin;
            int LonSec;

            GeoCordSystemDegMinSecUtilities.LatLongPrefix LonPrefix;

            /////////////////////////////////////////////////////////////////////////
            // First set the system origin
            /////////////////////////////////////////////////////////////////////////
            FileName = @"C:\ASTERIX\ADAPTATION\Main_Settings.txt";
            Exception Bad_Main_Settings = new Exception("Bad Main_Settings.txt file");

            if (System.IO.File.Exists(FileName))
            {
                MyStreamReader = System.IO.File.OpenText(FileName);
                while (MyStreamReader.Peek() >= 0)
                {
                    ConfigurationData = MyStreamReader.ReadLine();
                    string[] words = ConfigurationData.Split(delimiterChars);
                    if (words[0][0] != '#')
                    {
                        switch (words[0])
                        {
                        case "SYS_ORIGIN":
                            ItemName = words[0];

                            // Get Latitude
                            if (int.TryParse(words[1], out LatDeg) == false)
                            {
                                throw Bad_Main_Settings;
                            }
                            if (int.TryParse(words[2], out LatMin) == false)
                            {
                                throw Bad_Main_Settings;
                            }
                            if (int.TryParse(words[3], out LatSec) == false)
                            {
                                throw Bad_Main_Settings;
                            }

                            switch (words[4])
                            {
                            case "E":
                                LatPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.E;
                                break;

                            case "W":
                                LatPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.W;
                                break;

                            case "N":
                                LatPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.N;
                                break;

                            case "S":
                                LatPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.S;
                                break;

                            default:
                                throw Bad_Main_Settings;
                            }

                            // Get Longitude
                            if (int.TryParse(words[5], out LonDeg) == false)
                            {
                                throw Bad_Main_Settings;
                            }
                            if (int.TryParse(words[6], out LonMin) == false)
                            {
                                throw Bad_Main_Settings;
                            }
                            if (int.TryParse(words[7], out LonSec) == false)
                            {
                                throw Bad_Main_Settings;
                            }

                            switch (words[8])
                            {
                            case "E":
                                LonPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.E;
                                break;

                            case "W":
                                LonPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.W;
                                break;

                            case "N":
                                LonPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.N;
                                break;

                            case "S":
                                LonPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.S;
                                break;

                            default:
                                throw Bad_Main_Settings;
                            }

                            GeoCordSystemDegMinSecUtilities.LatLongClass T = new GeoCordSystemDegMinSecUtilities.LatLongClass(LatDeg, LatMin, LatSec,
                                                                                                                              LatPrefix, LonDeg, LonMin, LonSec, LonPrefix);
                            SystemAdaptationDataSet.SystemOrigin = new GMap.NET.PointLatLng(T.GetLatLongDecimal().LatitudeDecimal, T.GetLatLongDecimal().LongitudeDecimal);

                            break;

                        case "BACKGROUND":

                            DisplayAttributes.DisplayAttributesType DisplayAttributeBackground = DisplayAttributes.GetDisplayAttribute(DisplayAttributes.DisplayItemsType.BackgroundColor);
                            DisplayAttributeBackground.TextColor = System.Drawing.Color.FromName(words[1]);
                            DisplayAttributes.SetDisplayAttribute(DisplayAttributes.DisplayItemsType.BackgroundColor, DisplayAttributeBackground);
                            break;
                        }
                    }
                }
            }
            else
            {
                // Here is it initialized to the center of Bosnia and Herzegovina.
                SystemAdaptationDataSet.SystemOrigin = new GMap.NET.PointLatLng(44.05267, 17.6769);
            }
        }