Esempio n. 1
0
 public void DrawMap(PlaceXmlModel place)
 {
     foreach (var item in place.Items)
     {
         DrawItem(item);
     }
     FitMap(place);
     AdjustAxis();
 }
Esempio n. 2
0
 private void FitMap(PlaceXmlModel place)
 {
     if (place.Items?.Count > 0)
     {
         double _minX = double.MaxValue;
         double _maxX = double.MinValue;
         double _minY = double.MaxValue;
         double _maxY = double.MinValue;
         foreach (var p in place.Items[0].Area?.Points)
         {
             _maxX = Math.Max(_maxX, double.Parse(p.X));
             _minX = Math.Min(_minX, double.Parse(p.X));
             _maxY = Math.Max(_maxY, double.Parse(p.Y));
             _minY = Math.Min(_minY, double.Parse(p.Y));
         }
         Chart1.PlotOriginX = Math.Round(_minX) - 1;
         Chart1.PlotOriginY = Math.Round(_minY) - 1;
         double height = _maxY - _minY + 8;
         Chart1.PlotHeight = height;
         Chart1.PlotWidth  = this.Width / this.Height * height;
     }
 }
Esempio n. 3
0
        public void ExportMap()
        {
            PlaceXmlModel map = new PlaceXmlModel();

            map.Items = new List <PlaceXmlModel.Item>();
            map.Items.Add(examItem);
            map.Name   = "科二地图";
            map.Point0 = "0,0";
            string path = System.AppDomain.CurrentDomain.BaseDirectory + "Place.xml";

            using (FileStream fs = File.Open(path, FileMode.Create, FileAccess.ReadWrite))
            {
                XmlSerializer           xmlSerializer = new XmlSerializer(typeof(PlaceXmlModel));
                XmlTextWriter           textWriter    = new XmlTextWriter(fs, Encoding.UTF8);
                XmlSerializerNamespaces ns            = new XmlSerializerNamespaces();
                ns.Add("", "");
                // 换行
                textWriter.Formatting = Formatting.Indented;
                // 序列化
                xmlSerializer.Serialize(textWriter, map, ns);
                textWriter.Close();
            }
        }