コード例 #1
0
ファイル: Converter.cs プロジェクト: helios57/anrl
 public Converter(Map map)
 {
     topLeftLongitude = map.XTopLeft;
     topLeftLatitude = map.YTopLeft;
     sizeLongitude = map.XSize;
     sizeLatitude = map.YSize;
 }
コード例 #2
0
ファイル: MapImportFromMaps.cs プロジェクト: helios57/anrl
 private void btnSave_Click(object sender, EventArgs e)
 {
     //try
     //{
         btnSave.Enabled = false;
         fldName.Enabled = false;
         Map m = new Map();
         m.Name = fldName.Text;
         m.XSize = Double.Parse(fldSizeX.Text, NumberFormatInfo.InvariantInfo);
         m.YSize = Double.Parse(fldSizeY.Text, NumberFormatInfo.InvariantInfo);
         m.XRot = 0;
         m.YRot = 0;
         m.XTopLeft = Double.Parse(fldX.Text, NumberFormatInfo.InvariantInfo);
         m.YTopLeft = Double.Parse(fldY.Text, NumberFormatInfo.InvariantInfo);
         MemoryStream ms = new MemoryStream();
         gMapControl1.ToImage().Save(ms, System.Drawing.Imaging.ImageFormat.Png);
         m.Picture = new Picture();
         m.Picture.Data = ms.ToArray();
         m.Competition = Client.SelectedCompetition;
         Client.DBContext.MapSet.Add(m);
         Client.DBContext.SaveChanges();
         MessageBox.Show("Map saved successfull!");
         btnSave.Enabled = true;
         fldName.Enabled = true;
       //  }
        // catch (Exception ex)
        // {
      //   MessageBox.Show(ex.Message, "Error while Saving");
        // }
 }
コード例 #3
0
ファイル: MapLegacy.cs プロジェクト: helios57/anrl
        void ofd_FileOk(object sender, CancelEventArgs e)
        {
            OpenFileDialog ofd = sender as OpenFileDialog;
            PictureBox p = new PictureBox();
            p.Image = Image.FromFile(ofd.FileName);
            Map m = new Map();
            m.Name = fldName.Text;
            string[] coordinatesFromPath = ofd.FileName.Remove(ofd.FileName.LastIndexOf(".")).Substring(ofd.FileName.LastIndexOf(@"\") + 1).Split("_".ToCharArray());
            foreach (string coordinate in coordinatesFromPath)
            {
                if (coordinate.Length != 6 || coordinate == null || coordinate == string.Empty)
                {
                    throw (new FormatException("Coordinates in image name not in correct format!"));
                }
            }

            double topLeftLatitude = Converter.CHtoWGSlat(Convert.ToDouble(coordinatesFromPath[0]), Convert.ToDouble(coordinatesFromPath[1]));
            double topLeftLongitude = Converter.CHtoWGSlng(Convert.ToDouble(coordinatesFromPath[0]), Convert.ToDouble(coordinatesFromPath[1]));
            double bottomRightLatitude = Converter.CHtoWGSlat(Convert.ToDouble(coordinatesFromPath[2]), Convert.ToDouble(coordinatesFromPath[3]));
            double bottomRightLongitude = Converter.CHtoWGSlng(Convert.ToDouble(coordinatesFromPath[2]), Convert.ToDouble(coordinatesFromPath[3]));

            m.XSize = (bottomRightLongitude - topLeftLongitude) / p.Image.Width;
            m.YSize = (bottomRightLatitude - topLeftLatitude) / p.Image.Height;
            m.XRot = 0;
            m.YRot = 0;
            m.XTopLeft = topLeftLongitude;
            m.YTopLeft = topLeftLatitude;
            MemoryStream ms = new MemoryStream();
            p.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
            m.Picture = new Picture();
            m.Picture.Data = ms.ToArray();
            m.Competition = Client.SelectedCompetition;
            Client.DBContext.MapSet.Add(m);
            Client.DBContext.SaveChanges();
            btnImportANR.Enabled = true;
        }
コード例 #4
0
ファイル: MapLegacy.cs プロジェクト: helios57/anrl
        void ofd_FileOk2(object sender, CancelEventArgs e)
        {
            OpenFileDialog ofd = sender as OpenFileDialog;
            PictureBox p = new PictureBox();
            p.Image = Image.FromFile(ofd.FileName);
            Map m = new Map();
            m.Name = fldName.Text;
            double topLeftLatitude;
            double topLeftLongitude;
            double bottomRightLatitude;
            double bottomRightLongitude;
            string[] coordinatesFromPath = ofd.FileName.Remove(ofd.FileName.LastIndexOf(".")).Substring(ofd.FileName.LastIndexOf(@"\") + 1).Split("_".ToCharArray());
            topLeftLatitude = Convert.ToDouble(coordinatesFromPath[0]);
            topLeftLongitude = Convert.ToDouble(coordinatesFromPath[1]);
            bottomRightLatitude = Convert.ToDouble(coordinatesFromPath[2]);
            bottomRightLongitude = Convert.ToDouble(coordinatesFromPath[3]);

            m.XSize = (bottomRightLongitude -topLeftLongitude ) / p.Image.Width;
            m.YSize = (bottomRightLatitude - topLeftLatitude) / p.Image.Height;
            m.XRot = 0;
            m.YRot = 0;
            m.XTopLeft = topLeftLongitude;
            m.YTopLeft = topLeftLatitude;
            MemoryStream ms = new MemoryStream();
            p.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
            m.Picture = new Picture();
            m.Picture.Data = ms.ToArray();
            m.Competition = Client.SelectedCompetition;
            Client.DBContext.MapSet.Add(m);
            Client.DBContext.SaveChanges();
            button1.Enabled = true;
        }
コード例 #5
0
ファイル: ParcourEditSingle.cs プロジェクト: helios57/anrl
 public ListItemMap(Map imap)
 {
     map = imap;
 }
コード例 #6
0
ファイル: ParcourEditSingle.cs プロジェクト: helios57/anrl
        private void comboBoxParcours_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListItem li = comboBoxParcours.SelectedItem as ListItem;
            if (li != null)
            {
                Parcour p = li.getParcour();
                Map m = null;
                comboBoxMaps.SelectedItem = null;
                if (p.Map!=null)
                {
                    m = p.Map;
                    MemoryStream ms = new MemoryStream(m.Picture.Data);
                    PictureBox1.Image = System.Drawing.Image.FromStream(ms);
                    c = new Converter(m);
                    PictureBox1.SetConverter(c);
                    CurrentMap = m;
                    foreach (Object lim in comboBoxMaps.Items)
                    {
                        ListItemMap limm = lim as ListItemMap;
                        if (limm.getMap() == m)
                        {
                            comboBoxMaps.SelectedItem = lim;
                            break;
                        }
                    }
                }
                else
                {
                    p = new Parcour();
                }

                List<Line> toDelete = p.Line.Where(pp => pp.Type == (int)LineType.START || pp.Type == (int)LineType.END).ToList();
                foreach (Line l in toDelete)
                {
                    p.Line.Remove(l);
                }
                activeParcour = p;
                PictureBox1.SetParcour(activeParcour);
                generatedParcour = activeParcour.Line.Count(pp => pp.Type == (int)LineType.Point) > 0;
            }
        }
コード例 #7
0
ファイル: ParcourEditSingle.cs プロジェクト: helios57/anrl
 private void comboBoxMaps_SelectedIndexChanged(object sender, EventArgs e)
 {
     ListItemMap limm = comboBoxMaps.SelectedItem as ListItemMap;
     if (limm != null)
     {
         activeParcour = new Parcour();
         CurrentMap = limm.getMap();
         MemoryStream ms = new MemoryStream(CurrentMap.Picture.Data);
         PictureBox1.Image = System.Drawing.Image.FromStream(ms);
         c = new Converter(CurrentMap);
         PictureBox1.SetParcour(activeParcour);
         PictureBox1.SetConverter(c);
     }
 }
コード例 #8
0
ファイル: ParcourGen.cs プロジェクト: helios57/anrl
 private void comboBoxMaps_SelectedIndexChanged(object sender, EventArgs e)
 {
     ListItem li = comboBoxMaps.SelectedItem as ListItem;
     if (li != null)
     {
         MemoryStream ms = new MemoryStream(li.getMap().Picture.Data);
         PictureBox1.Image = System.Drawing.Image.FromStream(ms);
         c = new Converter(li.getMap());
         PictureBox1.SetConverter(c);
         CurrentMap = li.getMap();
     }
 }
コード例 #9
0
ファイル: ParcourEdit.cs プロジェクト: helios57/anrl
 private void comboBoxParcours_SelectedIndexChanged(object sender, EventArgs e)
 {
     ListItem li = comboBoxParcours.SelectedItem as ListItem;
     if (li != null)
     {
         Parcour p = li.getParcour();
         Map m = p.Map;
         MemoryStream ms = new MemoryStream(m.Picture.Data);
         PictureBox1.Image = System.Drawing.Image.FromStream(ms);
         c = new Converter(m);
         PictureBox1.SetConverter(c);
         CurrentMap = m;
         List<Line> toDelete =  p.Line.Where(pp=> pp.Type == (int)LineType.START || pp.Type == (int)LineType.END).ToList();
         foreach(Line l in toDelete)
         {
             p.Line.Remove(l);
         }
         activeParcour = p;
         PictureBox1.SetParcour(activeParcour);
         bool generatedParcour = activeParcour.Line.Count(pp => pp.Type == (int)LineType.Point) > 0;
         btnRecalc.Enabled = generatedParcour;
         chkAutocalc.Enabled = generatedParcour;
         chkAutocalc.Checked = generatedParcour;
     }
 }