/// <summary>
        /// Loads the height data.
        /// </summary>
        private void LoadHeightData()
        {
            this.tm = new TerrainModel();

            DateTime dtStart = DateTime.Now;

            //tm.LoadXYZFile(@"D:\BigData\SRTM Tiles Germany\srtm_38_03.xyz");
            this.tm.LoadXYZFile(@"C:\Lanser\BigData\SRTM Tiles Germany\srtm_38_03.xyz");
            DateTime dtStop = DateTime.Now;

            GMapPolygon polygon = new GMapPolygon(new List <PointLatLng>
            {
                new PointLatLng(this.tm.YMin, this.tm.XMin),
                new PointLatLng(this.tm.YMax, this.tm.XMin),
                new PointLatLng(this.tm.YMax, this.tm.XMax),
                new PointLatLng(this.tm.YMin, this.tm.XMax)
            });

            this.mcMapControl.Markers.Add(polygon);

            MB.Information($"Time: {( dtStop - dtStart ).ToHHMMSSString()} / Points: {this.tm.PointCount}");

            GC.WaitForPendingFinalizers();
            GC.Collect();
        }
Example #2
0
        /// <summary>
        /// Deletes the RFDevices.
        /// </summary>
        private void DeleteRFDevices()
        {
            if (this.dgRFDevices.SelectedItems.Count == 0)
            {
                MB.Information("No RFDevice Is Selected In The DataGrid!");
                return;
            }

            List <RFDeviceViewModel> list = new List <RFDeviceViewModel>(this.dgRFDevices.SelectedItems.Count);

            foreach (var item in this.dgRFDevices.SelectedItems)
            {
                list.Add(item as RFDeviceViewModel);
            }

            list.ForEach(DeleteRFDevice);

            //var lDelete =new List<RFDeviceViewModel>( dgRFDevices.SelectedItems);
            //            foreach( RFDeviceViewModel device in .ToList() )
            //            {
            //                DeleteRFDevice( device );
            //            }

            //foreach (RFDeviceViewModel device in (from devicemodel in this.RFDevicesCollection where devicemodel.IsMarked == true select devicemodel).ToList())
            //{
            //    DeleteRFDevice(device);
            //}
        }
Example #3
0
        /// <summary>
        /// Saves the templates.
        /// </summary>
        /// <param name="strFilename">The string filename.</param>
        private void SaveTemplates(string strFilename)
        {
            this.Cursor = Cursors.Wait;

            try
            {
                XElement eSIGENCEScenarioTemplates = new XElement("SIGENCEScenarioTemplates", new XAttribute("Version", Tool.Version));

                //-------------------------------------------------------------

                foreach (RFDevice d in from template in this.RFDeviceTemplateCollection select template)
                {
                    if (d.PrimaryKey != Guid.Empty)
                    {
                        eSIGENCEScenarioTemplates.Add(d.ToXml());
                    }
                }

                //-------------------------------------------------------------

                eSIGENCEScenarioTemplates.SaveDefault(strFilename);

                MB.Information("{0}\nsuccessfully saved.", strFilename);
            }
            catch (Exception ex)
            {
                MB.Error(ex);
            }

            this.Cursor = Cursors.Arrow;
        }
Example #4
0
        /// <summary>
        /// Handles the Click event of the Button_FindScenario control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void Button_FindScenario_Click(object sender, RoutedEventArgs e)
        {
            //Dirty Hack ..

            MB.Information("There Is Only One Scenario,\nso we load it!");

            foreach (var w in App.Current.Windows)
            {
                if (w is ScenarioWindow)
                {
                    (w as ScenarioWindow).DisplayScenario();
                }
            }
        }
Example #5
0
        //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------


        /// <summary>
        /// Copies the RFDevice.
        /// </summary>
        private void CopyRFDevice()
        {
            this.lCopiedRFDevices.Clear();

            if (this.dgRFDevices.SelectedItems.Count == 0)
            {
                MB.Information("You marked no RFDevice to copy.\nPlease select the RFDevices in the datagrid and push the button again.");
                return;
            }

            foreach (var device in this.dgRFDevices.SelectedItems)
            {
                this.lCopiedRFDevices.Add(device as RFDeviceViewModel);
            }
        }
Example #6
0
        /// <summary>
        /// Adds to templates.
        /// </summary>
        private void AddToTemplates()
        {
            if (this.dgRFDevices.SelectedItem == null)
            {
                MB.Information("No RFDevice Is Selected In The DataGrid!");
                return;
            }

            if (this.dgRFDevices.SelectedItems.Count > 1)
            {
                MB.Information("There Are More Than One RFDevice Selected In The DataGrid!");
                return;
            }

            AddToTemplates(this.dgRFDevices.SelectedItem as RFDeviceViewModel);
        }
        /// <summary>
        /// Edits the rf device.
        /// </summary>
        private void EditRFDevice()
        {
            if (this.dgRFDevices.SelectedItem == null)
            {
                MB.Information("No RFDevice Is Selected In The DataGrid!");
                return;
            }

            if (this.dgRFDevices.SelectedItems.Count > 1)
            {
                MB.Information("There Are More Than One RFDevice Selected In The DataGrid!");
                return;
            }

            OpenDeviceEditDialog(this.dgRFDevices.SelectedItem as RFDeviceViewModel);
        }
        ///// <summary>
        ///// Deletes the RFDevice.
        ///// </summary>
        //private void DeleteRFDevice()
        //{
        //    if (this.dgRFDevices.SelectedItem == null)
        //    {
        //        MB.Information("No RFDevice Is Selected In The DataGrid!");
        //        return;
        //    }

        //    if (this.dgRFDevices.SelectedItems.Count > 1)
        //    {
        //        MB.Information("There Are More Than One RFDevice Selected In The DataGrid!");
        //        return;
        //    }

        //    DeleteRFDevice(this.dgRFDevices.SelectedItem as RFDeviceViewModel);
        //}


        /// <summary>
        /// Deletes the RFDevices.
        /// </summary>
        private void DeleteRFDevices()
        {
            if (this.dgRFDevices.SelectedItems.Count == 0)
            {
                MB.Information("No RFDevice Is Selected In The DataGrid!");
                return;
            }

            List <RFDeviceViewModel> list = new List <RFDeviceViewModel>(this.dgRFDevices.SelectedItems.Count);

            foreach (object item in this.dgRFDevices.SelectedItems)
            {
                list.Add(item as RFDeviceViewModel);
            }

            list.ForEach(DeleteRFDevice);
        }
Example #9
0
        /// <summary>
        /// Exports the RFDevices.
        /// </summary>
        /// <param name="devicelist">The devicelist.</param>
        /// <param name="fiExportFile">The fi export file.</param>
        private void ExportRFDevices(RFDeviceList devicelist, FileInfo fiExportFile)
        {
            this.Cursor = Cursors.Wait;

            try
            {
                switch (fiExportFile.Extension.ToLower())
                {
                case ".csv":
                    devicelist.SaveAsCsv(fiExportFile.FullName);
                    MB.Information("File {0} successful created.", fiExportFile.Name);
                    break;

                case ".json":
                    devicelist.SaveAsJson(fiExportFile.FullName);
                    MB.Information("File {0} successful created.", fiExportFile.Name);
                    break;

                case ".xml":
                    devicelist.SaveAsXml(fiExportFile.FullName);
                    MB.Information("File {0} successful created.", fiExportFile.Name);
                    break;

                //case ".sqlite":
                //    devicelist.SaveAsSQLite( fiExportFile.FullName );
                //    MB.Information( "File {0} successful created." , fiExportFile.Name );
                //    break;

                case ".xlsx":
                    SaveAsExcel(devicelist, fiExportFile.FullName);
                    break;

                default:
                    MB.Warning("The FileType '{0}' Is Currently Not Supported For Export!", fiExportFile.Extension.ToLower());
                    break;
                }
            }
            catch (Exception ex)
            {
                MB.Error(ex);
            }

            this.Cursor = Cursors.Arrow;
        }
Example #10
0
        /// <summary>
        /// Rfs the device qr code.
        /// </summary>
        private void RFDeviceQRCode()
        {
            if (this.dgRFDevices.SelectedItem == null)
            {
                MB.Information("No RFDevice Is Selected In The DataGrid!");
                return;
            }

            if (this.dgRFDevices.SelectedItems.Count > 1)
            {
                MB.Information("There Are More Than One RFDevice Selected In The DataGrid!");
                return;
            }

            QRCodeDialog dlg = new QRCodeDialog(this.dgRFDevices.SelectedItem as RFDeviceViewModel);

            dlg.ShowDialog();
            dlg = null;
        }
Example #11
0
        /// <summary>
        /// Pastes the RFDevice.
        /// </summary>
        private void PasteRFDevice()
        {
            if (this.lCopiedRFDevices.Count > 0)
            {
                foreach (var device in this.lCopiedRFDevices)
                {
                    // Create a copy of the original device and change the primarykey
                    RFDevice newdevice = device.RFDevice.Clone();

                    newdevice.PrimaryKey = Guid.NewGuid();
                    newdevice.StartTime += this.settings.DeviceCopyTimeAddValue;

                    AddRFDevice(newdevice);
                }
            }
            else
            {
                MB.Information("There are no copied RFDevices in the list.\nPlease mark a RFDevice and copied it.");
            }
        }
        /// <summary>
        /// Creates the highest points.
        /// </summary>
        private void CreateHighestPoints()
        {
            if (this.tm == null)
            {
                MB.Information("Please Load First An Terrain Model!");
                return;
            }

            DateTime         dtStart       = DateTime.Now;
            List <LatLonAlt> highestpoints = this.tm.GetHighestPoints(new Envelope(this.tm.XMin, this.tm.XMax, this.tm.YMin, this.tm.YMax), 10, 20);
            DateTime         dtStop        = DateTime.Now;


            if (highestpoints.Count > 0)
            {
                int iCounter = 0;

                foreach (LatLonAlt lla in highestpoints)
                {
                    RFDevice dev = new RFDevice()
                    {
                        Latitude     = lla.Lat,
                        Longitude    = lla.Lon,
                        Altitude     = lla.Alt,
                        Name         = $"HighPoint #{++iCounter } @ {lla.Alt} m",
                        DeviceSource = DeviceSource.Automatic,
                        Id           = iCounter
                    };

                    AddRFDevice(dev, true);
                }
            }

            MB.Information($"Time: {( dtStop - dtStart ).ToHHMMSSString()} / Points: {highestpoints.Count}");

            GC.WaitForPendingFinalizers();
            GC.Collect();
        }
Example #13
0
        //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------


        /// <summary>
        /// Imports the rf devices.
        /// </summary>
        /// <param name="fiImportFile">The fi import file.</param>
        private void ImportRFDevices(FileInfo fiImportFile)
        {
            this.Cursor = Cursors.Wait;

            try
            {
                switch (fiImportFile.Extension.ToLower())
                {
                //case ".csv":
                //    MB.Information("File {0} successful imported.", fiImportFile.Name);
                //    break;

                //case ".json":
                //    MB.Information("File {0} successful imported.", fiImportFile.Name);
                //    break;

                //case ".xml":
                //    MB.Information("File {0} successful imported.", fiImportFile.Name);
                //    break;

                case ".xlsx":
                    LoadFromExcel(fiImportFile.FullName);
                    break;

                default:
                    MB.Information("Currently The Import Of {0} Is Not Implemented!", fiImportFile.Extension);
                    break;
                }
            }
            catch (Exception ex)
            {
                MB.Error(ex);
            }

            this.Cursor = Cursors.Arrow;
        }
        private void LoadStreets()
        {
            RemoveStreets();

            string strFilename = $"{Tool.StartupPath}\\streets_bw.sqlite";

            RectLatLng bb = this.mcMapControl.ViewArea;

            //TODO: Check if the area is not to big ... But what is big ?

            SQLiteConnectionStringBuilder csbDatabase = new SQLiteConnectionStringBuilder
            {
                DataSource = strFilename
            };

            using (SQLiteConnection dbConnection = new SQLiteConnection(csbDatabase.ConnectionString))
            {
                dbConnection.Open();

                try
                {
                    //                                     0     1   2   3
                    //const string strSelectStatement = "select highway,ref,name,way from streets_bw where highway in ('motorway','motorway_link','trunk','trunk_link','primary','secondary','primary_link','secondary_link','residential')";
                    const string strSelectStatement = "select highway,ref,name,way from streets_bw";

                    uint iCounter = 0;

                    DateTime dtStart = DateTime.Now;

                    using (SQLiteCommand dbSelectCommand = new SQLiteCommand(strSelectStatement, dbConnection))
                    {
                        using (SQLiteDataReader dbResult = dbSelectCommand.ExecuteReader())
                        {
                            while (dbResult.Read())
                            {
                                Highway type = Highway.Unknown;

                                try
                                {
                                    type = (Highway)Enum.Parse(typeof(Highway), dbResult.GetString(0), true);
                                }
                                catch (Exception ex)
                                {
                                    Debug.WriteLine(ex.Message);
                                }

                                string strRef  = dbResult.GetStringOrNull(1);
                                string strName = dbResult.GetStringOrNull(2);

                                LineString way = (LineString)dbResult.GetGeometryFromWKB(3);

                                if (bb.Contains(way.Coordinate.ToPointLatLng()))
                                {
                                    List <PointLatLng> list = new List <PointLatLng>(way.Count);

                                    list.AddRange(way.Coordinates.Select(pos => pos.ToPointLatLng()));

                                    this.Dispatcher.Invoke(() =>
                                    {
                                        PathMarker mrWay = new PathMarker(this.mcMapControl, list, type, $"{( strName.IsNotEmpty() ? strName : "Unknown" )}{( strRef.IsNotEmpty() ? $" ({strRef})" : "" )}")
                                        {
                                            Tag = type
                                        };

                                        this.mcMapControl.Markers.Add(mrWay);
                                    });

                                    iCounter++;
                                }
                            }
                        }
                    }

                    DateTime dtStop = DateTime.Now;

                    MB.Information("Load {0} Ways In {1}.", iCounter, (dtStop - dtStart).ToHHMMSSString());
                }
                catch (Exception ex)
                {
                    MB.Error(ex);
                }
                finally
                {
                    if (dbConnection.State == ConnectionState.Open)
                    {
                        dbConnection.Close();
                    }
                }
            }
        }