Beispiel #1
0
        void Enter_KeyDown(object semder, KeyRoutedEventArgs e)
        {
            if (e.Key == VirtualKey.Enter && pinBeingPlaced)
            {
                // Try putting some SQLite stuff here...
                using (var dataBase = new VendingInfoContext())
                {
                    var machine = new Machine
                    {
                        machineName     = inputPrompt.Text,
                        machineLocation = mLoc
                    };

                    dataBase.Machines.Add(machine);

                    dataBase.SaveChanges();

                    Debug.WriteLine(machine.Id + ":" + machine.machineName + ":" + machine.machineLocation);
                }

                // Now that the user has confirmed their data entry, disable the edit
                // mode of the textbox, and reset the pinBeingPlaced variable to false.
                inputPrompt.IsReadOnly = true;
                pinBeingPlaced         = false;
            }
        }
Beispiel #2
0
        // This is the task which runs to load database information to the app.
        public void loadData()
        {
            List <string> machineNames     = new List <string>();
            List <double> machineCoordLat  = new List <double>();
            List <double> machineCoordLong = new List <double>();

            using (var queryContext = new VendingInfoContext())
            {
                try
                {
                    // Finish implementing database query system!
                    var machineEntities = queryContext.Machines.ToList();

                    // Organizes pin data from SQLite database into compartmentalized variables
                    // for use within the application.
                    for (int i = 0; i < machineEntities.Count(); i++)
                    {
                        machineNames.Add(machineEntities.ElementAt(i).machineName);

                        double tempLat  = double.Parse(machineEntities.ElementAt(i).machineLocation.Substring(0, 16));
                        double tempLong = double.Parse(machineEntities.ElementAt(i).machineLocation.Substring(17));
                        machineCoordLat.Add(tempLat);
                        machineCoordLong.Add(tempLong);
                    }

                    // Not sure if this actually helps with anything...
                    Debug.WriteLine(machineEntities[0].Id);
                }
                catch (Exception e)
                {
                    // Thrown if an exception occurs.
                    Debug.WriteLine("No elements in database at this time...: " + e);
                }
            }

            // Places all stored location pins onto the application's map.
            for (int i = 0; i < machineNames.Count(); i++)
            {
                Bing.Maps.Location loc = new Bing.Maps.Location(machineCoordLat.ElementAt(i), machineCoordLong.ElementAt(i));

                Bing.Maps.Pushpin pushPin = new Bing.Maps.Pushpin();
                pushPin.SetValue(Bing.Maps.MapLayer.PositionProperty, loc);
                this.VendFinderApp.Children.Add(pushPin);

                // Add textbox containing location name to placed pin location...
                TextBox locText = new TextBox();
                locText.Height = (1 / 4) * Height;
                locText.Width  = Width;
                locText.SetValue(Bing.Maps.MapLayer.PositionProperty, loc);
                locText.Text      = machineNames.ElementAt(i);
                locText.IsEnabled = true;
                locText.UpdateLayout();
                locText.Opacity    = 1;
                locText.Visibility = Visibility.Visible;
                locText.IsReadOnly = true;
                VendFinderApp.Children.Add(locText);
            }

            //double lat = double.Parse(universalText.Substring(0, 16));
            //double longi = double.Parse(universalText.Substring(17));
            //Bing.Maps.Location loc = new Bing.Maps.Location(lat, longi);

            //Bing.Maps.Pushpin pushPin = new Bing.Maps.Pushpin();
            //pushPin.SetValue(Bing.Maps.MapLayer.PositionProperty, loc);
            //this.VendFinderApp.Children.Add(pushPin);
        }