Ejemplo n.º 1
0
        private void PERMap_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            e.Handled = true;

            if (fileNameTXB.Text == "")
            {
                MessageBox.Show("Write any location name");
                return;
            }

            foreach (Pushpin child in this.PERMap.Children)
            {
                if ((string)child.Content == fileNameTXB.Text)
                {
                    MessageBox.Show("Change name, this location already exists");
                    return;
                }
            }

            Location PERlocation = new Location();
            Pushpin  PERpushpin  = new Pushpin();

            this.PERMap.TryViewportPointToLocation(e.GetPosition(this.PERMap), out PERlocation);

            coordinatesTXB.Text = PERlocation.Latitude.ToString() + " " + PERlocation.Longitude.ToString();
            PERpushpin.SetValue(MapLayer.PositionProperty, PERlocation);
            PERpushpin.Content = fileNameTXB.Text;
            this.PERMap.Children.Add(PERpushpin);
        }
Ejemplo n.º 2
0
        public MainWindow()
        {
            InitializeComponent();

            DataContext = this;

            LoraSerialPort             = new SerialPort();
            LoraSerialPort.PortName    = "COM20";
            LoraSerialPort.BaudRate    = 115200;
            LoraSerialPort.ReadTimeout = 200;
            LoraSerialPort.Open();

            readThreadLora = new Thread(ReadFromLora);
            readThreadLora.IsBackground = true;
            readThreadLora.Start();


            dupalist    = new List <PERLocation>();
            choosendupa = null;
            //choosendupa = new PERLocation();

            ComboBox locationsList = new ComboBox();


            foreach (string file in Directory.EnumerateFiles(directoryPath, "*.txt"))
            {
                string [] data = File.ReadAllLines(file);

                Pushpin PERpushpin = new Pushpin();

                string[] cordinates      = data[0].Split(' ');
                double[] cordinatesDoube = new double[2];

                cordinatesDoube[0] = Convert.ToDouble(cordinates[0]);
                cordinatesDoube[1] = Convert.ToDouble(cordinates[1]);

                Location PERlocation = new Location(cordinatesDoube[0], cordinatesDoube[1]);

                PERpushpin.SetValue(MapLayer.PositionProperty, PERlocation);

                string fileName = file.Remove(0, file.LastIndexOf(@"\") + 1);
                fileName = fileName.Remove(fileName.LastIndexOf("."));

                //locationsList.Items.Add(fileName);

                // PERpushpin.Content = fileName;
                //this.PERMap.Children.Add(PERpushpin);


                dupalist.Add(new PERLocation(fileName, new Location(cordinatesDoube[0], cordinatesDoube[1])));
            }

            // RaisePropertyChanged("dupalist");

            //duuuppaa.UpdateLayout();
            //pinLSTB.UpdateLayout();
        }