Beispiel #1
0
        //unlinks two events
        public bool UnLinkEvents(Event event1, Event event2)
        {
            bool unlinked = false;

            //remove the element from the xeelent entry using linq for both events
            if (event1.Links.Remove(event2.ID))
            {
                ROOT_DOCUMENT.Descendants(LLE + "Event")
                .Where(id => id.Element(LLE + "eventid").Value == event1.ID)
                .Single()
                .Element(LLE + "link")
                .Descendants(LLE + "eventid")
                .Where(id => id.Value == event2.ID)
                .Single()
                .Remove();
                unlinked = true;
            }
            if (event2.Links.Remove(event1.ID))
            {
                ROOT_DOCUMENT.Descendants(LLE + "Event")
                .Where(id => id.Element(LLE + "eventid").Value == event2.ID)
                .Single()
                .Element(LLE + "link")
                .Descendants(LLE + "eventid")
                .Where(id => id.Value == event1.ID)
                .Single()
                .Remove();
                unlinked = true;
            }

            //save the file if successful
            if (unlinked)
            {
                ROOT_DOCUMENT.Save(FILE);
                //remove the lines from the map
                mapHelper.Clear("links_" + event1.ID);
                mapHelper.Clear("links_" + event2.ID);
            }
            return(unlinked);
        }
Beispiel #2
0
        private void viewToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //get coordinates from the mouse position
            Coordinates coordinates = new Coordinates(mapCtrl.FromLocalToLatLng(MOUSE_X_COORDINATES, MOUSE_Y_COORDINATES).Lat, mapCtrl.FromLocalToLatLng(MOUSE_X_COORDINATES, MOUSE_Y_COORDINATES).Lng);

            ToolboxEventFlowLayout.Controls.Clear();

            //add a clear button to the form
            Button clearButton = new Button();

            clearButton.Text   = "Clear Selection";
            clearButton.Click += new EventHandler(ClearSelection);
            ToolboxEventFlowLayout.Controls.Add(clearButton);

            //clear the matchlines overlay
            mapHelper.Clear("matchlines");

            //setup for results view
            int numResults    = 0;
            int radius        = 0;
            int defaultRadius = 2;

            try
            {
                radius = Int32.Parse(radiusInput.Text);
                //make sure its not negative
                if (radius < 0)
                {
                    radius = defaultRadius;
                }
            }
            //default to 2 if the radius is not a correct value
            catch (FormatException)
            {
                radius = defaultRadius;
            }
            catch (OverflowException)
            {
                radius = defaultRadius;
            }

            //get the surrounding events and draw aline to each event
            foreach (Event ev in eventHelper.GetSurroundingEvents(coordinates, radius))
            {
                numResults++;

                mapHelper.DrawLine("matchlines", ev.Location, coordinates, Color.Red);
                ToolboxEventFlowLayout.Controls.Add(ev.CreatePanel());
            }
            //assume there will be results
            Label resultNr = new Label();

            resultNr.Text = numResults + " results Found. Sorted by closest event";
            ToolboxEventFlowLayout.Controls.Add(resultNr);
            //if no results
            if (numResults == 0)
            {
                resultNr      = new Label();
                resultNr.Text = "No Results Found. Search a different area";
            }
            mapHelper.DrawCircle("circle", coordinates, radius, 50);
        }