Esempio n. 1
0
        public override bool Action(string action)
        {
            bool result = base.Action(action);
            if (result)
            {
                using (GeocacheTextSearchForm dlg = new GeocacheTextSearchForm())
                {
                    if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        Core.Geocaches.BeginUpdate();

                        if (dlg.SearchOption.Selection == GeocacheTextSearchForm.DialogContent.SelectionSelect.NewSearch)
                        {
                            //reset current
                            foreach (Framework.Data.Geocache gc in Core.Geocaches)
                            {
                                gc.Selected = false;
                            }
                        }

                        StringComparison scType;

                        if (dlg.SearchOption.CaseSensative) scType = StringComparison.CurrentCultureIgnoreCase;
                        else scType = StringComparison.OrdinalIgnoreCase;

                        if (dlg.SearchOption.Field == GeocacheTextSearchForm.DialogContent.FieldSelect.Description)
                        {
                            if (dlg.SearchOption.Selection == GeocacheTextSearchForm.DialogContent.SelectionSelect.WithinSelection)
                            {
                                _gcSearchList = Utils.DataAccess.GetSelectedGeocaches(Core.Geocaches);
                            }
                            else if (dlg.SearchOption.Selection == GeocacheTextSearchForm.DialogContent.SelectionSelect.AddToSelection)
                            {
                                _gcSearchList = (from Framework.Data.Geocache gc in Core.Geocaches where !gc.Selected select gc).ToList();
                            }
                            else
                            {
                                _gcSearchList = (from Framework.Data.Geocache gc in Core.Geocaches select gc).ToList();
                            }
                            _scType = scType;
                            _txt = dlg.SearchOption.Text;

                            _actionReady = new ManualResetEvent(false);
                            Thread thrd = new Thread(new ThreadStart(this.searchInDescriptionThreadMethod));
                            thrd.Start();
                            while (!_actionReady.WaitOne(100))
                            {
                                System.Windows.Forms.Application.DoEvents();
                            }
                            thrd.Join();

                            if (dlg.SearchOption.Selection == GeocacheTextSearchForm.DialogContent.SelectionSelect.WithinSelection)
                            {
                                //reset current
                                foreach (Framework.Data.Geocache gc in Core.Geocaches)
                                {
                                    gc.Selected = false;
                                }
                            }

                        }
                        else
                        {
                            var gcList = (from Framework.Data.Geocache wp in Core.Geocaches
                                         where ((dlg.SearchOption.Selection != GeocacheTextSearchForm.DialogContent.SelectionSelect.WithinSelection) || wp.Selected)
                                                && ((dlg.SearchOption.Field != GeocacheTextSearchForm.DialogContent.FieldSelect.Name || wp.Name.IndexOf(dlg.SearchOption.Text, scType) >= 0)
                                                && (dlg.SearchOption.Field != GeocacheTextSearchForm.DialogContent.FieldSelect.Code || wp.Code.IndexOf(dlg.SearchOption.Text, scType) >= 0)
                                                && (dlg.SearchOption.Field != GeocacheTextSearchForm.DialogContent.FieldSelect.Owner || wp.Owner.IndexOf(dlg.SearchOption.Text, scType) >= 0))
                                         select wp).ToList();

                            if (dlg.SearchOption.Selection == GeocacheTextSearchForm.DialogContent.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();
                    }
                }
            }
            return result;
        }
Esempio n. 2
0
        public async override Task <bool> ActionAsync(string action)
        {
            bool result = base.Action(action);

            if (result)
            {
                using (GeocacheTextSearchForm dlg = new GeocacheTextSearchForm())
                {
                    if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        Core.Geocaches.BeginUpdate();

                        if (dlg.SearchOption.Selection == GeocacheTextSearchForm.DialogContent.SelectionSelect.NewSearch)
                        {
                            //reset current
                            foreach (Framework.Data.Geocache gc in Core.Geocaches)
                            {
                                gc.Selected = false;
                            }
                        }

                        StringComparison scType;

                        if (dlg.SearchOption.CaseSensative)
                        {
                            scType = StringComparison.CurrentCultureIgnoreCase;
                        }
                        else
                        {
                            scType = StringComparison.OrdinalIgnoreCase;
                        }

                        if (dlg.SearchOption.Field == GeocacheTextSearchForm.DialogContent.FieldSelect.Description)
                        {
                            if (dlg.SearchOption.Selection == GeocacheTextSearchForm.DialogContent.SelectionSelect.WithinSelection)
                            {
                                _gcSearchList = Utils.DataAccess.GetSelectedGeocaches(Core.Geocaches);
                            }
                            else if (dlg.SearchOption.Selection == GeocacheTextSearchForm.DialogContent.SelectionSelect.AddToSelection)
                            {
                                _gcSearchList = (from Framework.Data.Geocache gc in Core.Geocaches where !gc.Selected select gc).ToList();
                            }
                            else
                            {
                                _gcSearchList = (from Framework.Data.Geocache gc in Core.Geocaches select gc).ToList();
                            }
                            _scType = scType;
                            _txt    = dlg.SearchOption.Text;

                            await Task.Run(() =>
                            {
                                this.searchInDescriptionThreadMethod();
                            });

                            if (dlg.SearchOption.Selection == GeocacheTextSearchForm.DialogContent.SelectionSelect.WithinSelection)
                            {
                                //reset current
                                foreach (Framework.Data.Geocache gc in Core.Geocaches)
                                {
                                    gc.Selected = false;
                                }
                            }
                        }
                        else
                        {
                            var gcList = (from Framework.Data.Geocache wp in Core.Geocaches
                                          where ((dlg.SearchOption.Selection != GeocacheTextSearchForm.DialogContent.SelectionSelect.WithinSelection) || wp.Selected) &&
                                          ((dlg.SearchOption.Field != GeocacheTextSearchForm.DialogContent.FieldSelect.Name || wp.Name.IndexOf(dlg.SearchOption.Text, scType) >= 0) &&
                                           (dlg.SearchOption.Field != GeocacheTextSearchForm.DialogContent.FieldSelect.Code || wp.Code.IndexOf(dlg.SearchOption.Text, scType) >= 0) &&
                                           (dlg.SearchOption.Field != GeocacheTextSearchForm.DialogContent.FieldSelect.Owner || wp.Owner.IndexOf(dlg.SearchOption.Text, scType) >= 0))
                                          select wp).ToList();

                            if (dlg.SearchOption.Selection == GeocacheTextSearchForm.DialogContent.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();
                    }
                }
            }
            return(result);
        }
Esempio n. 3
0
        public async override Task<bool> ActionAsync(string action)
        {
            bool result = base.Action(action);
            if (result)
            {
                using (GeocacheTextSearchForm dlg = new GeocacheTextSearchForm())
                {
                    if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        Core.Geocaches.BeginUpdate();

                        if (dlg.SearchOption.Selection == GeocacheTextSearchForm.DialogContent.SelectionSelect.NewSearch)
                        {
                            //reset current
                            foreach (Framework.Data.Geocache gc in Core.Geocaches)
                            {
                                gc.Selected = false;
                            }
                        }

                        StringComparison scType;

                        if (dlg.SearchOption.CaseSensative) scType = StringComparison.CurrentCultureIgnoreCase;
                        else scType = StringComparison.OrdinalIgnoreCase;

                        if (dlg.SearchOption.Field == GeocacheTextSearchForm.DialogContent.FieldSelect.Description)
                        {
                            if (dlg.SearchOption.Selection == GeocacheTextSearchForm.DialogContent.SelectionSelect.WithinSelection)
                            {
                                _gcSearchList = Utils.DataAccess.GetSelectedGeocaches(Core.Geocaches);
                            }
                            else if (dlg.SearchOption.Selection == GeocacheTextSearchForm.DialogContent.SelectionSelect.AddToSelection)
                            {
                                _gcSearchList = (from Framework.Data.Geocache gc in Core.Geocaches where !gc.Selected select gc).ToList();
                            }
                            else
                            {
                                _gcSearchList = (from Framework.Data.Geocache gc in Core.Geocaches select gc).ToList();
                            }
                            _scType = scType;
                            _txt = dlg.SearchOption.Text;

                            await Task.Run(() =>
                                {
                                    this.searchInDescriptionThreadMethod();
                                });

                            if (dlg.SearchOption.Selection == GeocacheTextSearchForm.DialogContent.SelectionSelect.WithinSelection)
                            {
                                //reset current
                                foreach (Framework.Data.Geocache gc in Core.Geocaches)
                                {
                                    gc.Selected = false;
                                }
                            }

                        }
                        else
                        {
                            var gcList = (from Framework.Data.Geocache wp in Core.Geocaches
                                         where ((dlg.SearchOption.Selection != GeocacheTextSearchForm.DialogContent.SelectionSelect.WithinSelection) || wp.Selected)
                                                && ((dlg.SearchOption.Field != GeocacheTextSearchForm.DialogContent.FieldSelect.Name || wp.Name.IndexOf(dlg.SearchOption.Text, scType) >= 0)
                                                && (dlg.SearchOption.Field != GeocacheTextSearchForm.DialogContent.FieldSelect.Code || wp.Code.IndexOf(dlg.SearchOption.Text, scType) >= 0)
                                                && (dlg.SearchOption.Field != GeocacheTextSearchForm.DialogContent.FieldSelect.Owner || wp.Owner.IndexOf(dlg.SearchOption.Text, scType) >= 0))
                                         select wp).ToList();

                            if (dlg.SearchOption.Selection == GeocacheTextSearchForm.DialogContent.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();
                    }
                }
            }
            return result;
        }