Exemple #1
0
        public override bool Action(string action)
        {
            bool result = base.Action(action);
            if (result)
            {
                using (SelectByAreaForm dlg = new SelectByAreaForm(Core))
                {
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        Core.Geocaches.BeginUpdate();

                        SelectByAreaForm.SelectionSelect searchOption = dlg.SearchOption;
                        bool withinRadius = dlg.WithinRadius;
                        double radius = 0.0;
                        double minlat = 0.0;
                        double minlon = 0.0;
                        double maxlat = 0.0;
                        double maxlon = 0.0;
                        Framework.Data.Location center = null;
                        if (withinRadius)
                        {
                            radius = dlg.Radius * 1000.0;
                            center = dlg.Center;
                        }
                        else{
                            minlat = dlg.MinLat;
                            minlon = dlg.MinLon;
                            maxlat = dlg.MaxLat;
                            maxlon = dlg.MaxLon;
                        }

                        if (searchOption == SelectByAreaForm.SelectionSelect.NewSearch)
                        {

                            //reset current
                            foreach (Framework.Data.Geocache gc in Core.Geocaches)
                            {
                                gc.Selected = false;
                            }
                        }

                        var gcList = (from Framework.Data.Geocache wp in Core.Geocaches
                                     where ((searchOption != SelectByAreaForm.SelectionSelect.WithinSelection) || wp.Selected)
                                            && (!withinRadius || Utils.Calculus.CalculateDistance(wp, center).EllipsoidalDistance<=radius)
                                            && (withinRadius || ( wp.Lat >= minlat && wp.Lat <= maxlat && wp.Lon >= minlon && wp.Lon <= maxlon))
                                     select wp).ToList();

                        if (searchOption == SelectByAreaForm.SelectionSelect.WithinSelection)
                        {
                            //reset current
                            foreach (Framework.Data.Geocache gc in Core.Geocaches)
                            {
                                gc.Selected = false;
                            }
                        }

                        foreach (Framework.Data.Geocache gc in gcList)
                        {
                            gc.Selected = true;
                        }

                        Core.Geocaches.EndUpdate();
                    }
                }
                result = true;
            }
            return result;
        }
Exemple #2
0
        public override bool Action(string action)
        {
            bool result = base.Action(action);

            if (result)
            {
                using (SelectByAreaForm dlg = new SelectByAreaForm(Core))
                {
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        Core.Geocaches.BeginUpdate();

                        SelectByAreaForm.SelectionSelect searchOption = dlg.SearchOption;
                        bool   withinRadius            = dlg.WithinRadius;
                        double radius                  = 0.0;
                        double minlat                  = 0.0;
                        double minlon                  = 0.0;
                        double maxlat                  = 0.0;
                        double maxlon                  = 0.0;
                        Framework.Data.Location center = null;
                        if (withinRadius)
                        {
                            radius = dlg.Radius * 1000.0;
                            center = dlg.Center;
                        }
                        else
                        {
                            minlat = dlg.MinLat;
                            minlon = dlg.MinLon;
                            maxlat = dlg.MaxLat;
                            maxlon = dlg.MaxLon;
                        }

                        if (searchOption == SelectByAreaForm.SelectionSelect.NewSearch)
                        {
                            //reset current
                            foreach (Framework.Data.Geocache gc in Core.Geocaches)
                            {
                                gc.Selected = false;
                            }
                        }

                        var gcList = (from Framework.Data.Geocache wp in Core.Geocaches
                                      where ((searchOption != SelectByAreaForm.SelectionSelect.WithinSelection) || wp.Selected) &&
                                      (!withinRadius || Utils.Calculus.CalculateDistance(wp, center).EllipsoidalDistance <= radius) &&
                                      (withinRadius || (wp.Lat >= minlat && wp.Lat <= maxlat && wp.Lon >= minlon && wp.Lon <= maxlon))
                                      select wp).ToList();

                        if (searchOption == SelectByAreaForm.SelectionSelect.WithinSelection)
                        {
                            //reset current
                            foreach (Framework.Data.Geocache gc in Core.Geocaches)
                            {
                                gc.Selected = false;
                            }
                        }

                        foreach (Framework.Data.Geocache gc in gcList)
                        {
                            gc.Selected = true;
                        }

                        Core.Geocaches.EndUpdate();
                    }
                }
                result = true;
            }
            return(result);
        }