protected void ImportGeocaches(List <string> gcCodes) { if (gcCodes != null && gcCodes.Count > 0) { _gcList = new List <string>(); _gcList.AddRange(gcCodes); using (Utils.FrameworkDataUpdater d = new Utils.FrameworkDataUpdater(Core)) { _errormessage = null; _actionReady = new ManualResetEvent(false); Thread thrd = new Thread(new ThreadStart(this.importGeocachesThreadMethod)); thrd.Start(); while (!_actionReady.WaitOne(500)) { System.Windows.Forms.Application.DoEvents(); } thrd.Join(); _actionReady.Dispose(); if (!string.IsNullOrEmpty(_errormessage)) { System.Windows.Forms.MessageBox.Show(_errormessage, Utils.LanguageSupport.Instance.GetTranslation(Utils.LanguageSupport.Instance.GetTranslation(STR_ERROR)), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } } } }
public async override Task <bool> ActionAsync(string action) { bool result = base.Action(action); if (result && action == ACTION_FILTER) { using (LogPurgerForm dlg = new LogPurgerForm()) { if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(Core)) { await Task.Run(() => { this.purgeLogsWithFilterThreadMethod(); }); } } } } else if (result && action == ACTION_QUICKPURGE) { using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(Core)) { await Task.Run(() => { this.purgeLogsThreadMethod(); }); } } return(result); }
public async override Task<bool> ActionAsync(string action) { bool result = base.Action(action); if (result && action == ACTION_FILTER) { using (LogPurgerForm dlg = new LogPurgerForm()) { if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(Core)) { await Task.Run(() => { this.purgeLogsWithFilterThreadMethod(); }); } } } } else if (result && action == ACTION_QUICKPURGE) { using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(Core)) { await Task.Run(() => { this.purgeLogsThreadMethod(); }); } } return result; }
private async Task <bool> addGeocachesToDatabase(List <ListViewItem> lvis) { bool result = false; _geocacheCodes = new List <string>(); foreach (ListViewItem lvi in lvis) { if (!(lvi.Tag as GeocacheVisitsItem).InDatabase) { _geocacheCodes.Add((lvi.Tag as GeocacheVisitsItem).Code); } } if (_geocacheCodes.Count > 0) { this.ControlBox = false; this.groupBox1.Enabled = false; this.groupBox2.Enabled = false; this.panel1.Enabled = false; using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(_core)) { await Task.Run(() => { this.getGeocachesThreadMethod(); }); } if (!string.IsNullOrEmpty(_errormessage)) { System.Windows.Forms.MessageBox.Show(_errormessage, Utils.LanguageSupport.Instance.GetTranslation(Utils.LanguageSupport.Instance.GetTranslation(STR_ERROR)), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } else { result = true; } foreach (ListViewItem lvi in lvis) { GeocacheVisitsItem vi = lvi.Tag as GeocacheVisitsItem; if (!vi.InDatabase) { vi.InDatabase = Utils.DataAccess.GetGeocache(_core.Geocaches, vi.Code) != null; if (vi.InDatabase) { lvi.SubItems[0].Text = Utils.LanguageSupport.Instance.GetTranslation(STR_YES); } } } listView1_SelectedIndexChanged(this, null); button3.Enabled = (from a in _geocacheVisitsItems where !a.InDatabase select a).Count() > 0; button5.Enabled = (from a in _geocacheVisitsItems where a.InDatabase select a).Count() > 0; this.ControlBox = true; this.groupBox1.Enabled = true; this.groupBox2.Enabled = true; this.panel1.Enabled = true; } else { result = true; } return(result); }
private async void button1_Click(object sender, EventArgs e) { _prefix = textBox1.Text; using (Utils.FrameworkDataUpdater updater = new Utils.FrameworkDataUpdater(_core)) { await Task.Run(() => { this.assignRegionsThreadMethod(); }); } Close(); }
private void button5_Click(object sender, EventArgs e) { using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(_core)) { var list = from a in _geocacheVisitsItems join Framework.Data.Geocache b in _core.Geocaches on a.Code equals b.Code select b; foreach (var x in list) { x.Selected = true; } } Close(); }
private void RunActionFlow(ActionFlow flow, bool notifyDone) { try { using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(Core)) { //flows can call eachother, initialize them all foreach (ActionFlow af in _actionFlows) { foreach (ActionImplementation ai in af.Actions) { ai.PrepareRun(); } } //find start and run ActionStart startAction = (from a in flow.Actions where a is ActionStart select a).FirstOrDefault() as ActionStart; if (notifyDone) { //first start startAction.PrepareFlow(); } foreach (Framework.Data.Geocache gc in Core.Geocaches) { startAction.Run(gc); } //wrap up foreach (ActionFlow af in _actionFlows) { foreach (ActionImplementation ai in af.Actions) { ai.FinalizeRun(); } } } if (notifyDone && PluginSettings.Instance.ShowFlowCompletedMessage) { using (ExecutionCompletedForm dlg = new ExecutionCompletedForm()) { dlg.ShowDialog(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button1_Click(object sender, EventArgs e) { _prefix = textBox1.Text; _actionReady = new ManualResetEvent(false); _actionReady.Reset(); using (Utils.FrameworkDataUpdater updater = new Utils.FrameworkDataUpdater(_core)) { Thread thrd = new Thread(new ThreadStart(this.assignRegionsThreadMethod)); thrd.Start(); while (!_actionReady.WaitOne(100)) { System.Windows.Forms.Application.DoEvents(); } thrd.Join(); } _actionReady.Close(); Close(); }
public override bool Action(string action) { bool result = base.Action(action); if (result && action == ACTION_FILTER) { using (LogPurgerForm dlg = new LogPurgerForm()) { if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(Core)) { _actionReady = new ManualResetEvent(false); Thread thrd = new Thread(new ThreadStart(this.purgeLogsWithFilterThreadMethod)); thrd.Start(); while (!_actionReady.WaitOne(10)) { System.Windows.Forms.Application.DoEvents(); } thrd.Join(); _actionReady.Dispose(); _actionReady = null; } } } } else if (result && action == ACTION_QUICKPURGE) { using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(Core)) { _actionReady = new ManualResetEvent(false); Thread thrd = new Thread(new ThreadStart(this.purgeLogsThreadMethod)); thrd.Start(); while (!_actionReady.WaitOne(10)) { System.Windows.Forms.Application.DoEvents(); } thrd.Join(); _actionReady.Dispose(); _actionReady = null; } } return result; }
private void button5_Click(object sender, EventArgs e) { BookmarkInfo bmi = comboBox1.SelectedItem as BookmarkInfo; if (bmi != null) { using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(Core)) { foreach (string s in bmi.GeocacheCodes.Keys) { Framework.Data.Geocache gc = Utils.DataAccess.GetGeocache(Core.Geocaches, s); if (gc != null) { gc.Selected = true; } } } } }
private void button2_Click(object sender, EventArgs e) { if (logViewControl1.logList.SelectedItems != null && logViewControl1.logList.SelectedItems.Count > 0) { this.Cursor = Cursors.WaitCursor; using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(Core)) { foreach (Framework.Data.Log l in logViewControl1.logList.SelectedItems) { if (l != null) { Utils.DataAccess.DeleteLog(Core, l); } } } UpdateView(true); this.Cursor = Cursors.Default; } }
private async void buttonSubmit_Click(object sender, EventArgs e) { if (_gc != null && (comboBoxLogType1.SelectedItem as Framework.Data.LogType) != null) { panel1.Enabled = false; panel2.Enabled = false; panel3.Enabled = false; Cursor = Cursors.WaitCursor; _logDate = dateTimePicker1.Value.Date; _logType = (comboBoxLogType1.SelectedItem as Framework.Data.LogType); _tbs14 = (from string a in checkedListBox1.CheckedItems select a.Split(new char[] { ',' }, 2)[0]).ToList(); _tbs75 = (from string a in checkedListBox2.CheckedItems select a.Split(new char[] { ',' }, 2)[0]).ToList(); _logText = textBox1.Text; _addToFavorites = checkBox1.Checked; using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(_core)) { await Task.Run(() => { this.logThreadMethod(); }); } if (!string.IsNullOrEmpty(_errormessage)) { System.Windows.Forms.MessageBox.Show(_errormessage, Utils.LanguageSupport.Instance.GetTranslation(Utils.LanguageSupport.Instance.GetTranslation(STR_ERROR)), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } else if (!AskForNext || textBoxGC.ReadOnly || System.Windows.Forms.MessageBox.Show(Utils.LanguageSupport.Instance.GetTranslation(STR_OKANOTHER), Utils.LanguageSupport.Instance.GetTranslation(STR_SUCCESS), System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No) { DialogResult = System.Windows.Forms.DialogResult.OK; Close(); } panel3.Enabled = true; panel2.Enabled = true; panel1.Enabled = true; toolStripStatusLabel1.Visible = false; toolStripStatusLabel1.Text = ""; } Cursor = Cursors.Default; }
public async override Task <bool> ActionAsync(string action) { bool result = base.Action(action); if (result) { if (action == ACTION_SHOW) { if (Utils.API.GeocachingLiveV6.CheckAPIAccessAvailable(Core, false)) { bool perform = true; if (PluginSettings.Instance.ShowSettingsDialog) { using (SettingsForm dlg = new SettingsForm()) { perform = dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK; } } if (perform) { using (Utils.FrameworkDataUpdater updater = new Utils.FrameworkDataUpdater(Core)) { _errormessage = ""; await Task.Run(() => { this.threadMethod(); }); if (!string.IsNullOrEmpty(_errormessage)) { System.Windows.Forms.MessageBox.Show(_errormessage, Utils.LanguageSupport.Instance.GetTranslation(STR_ERROR), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } } } } } result = true; } return(result); }
void checkGeocachesAdded() { _context.Post(new SendOrPostCallback(delegate(object state) { if (Core.Geocaches.Count > 0) { using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(Core)) { Hashtable ht = new Hashtable(); foreach (Framework.Data.Geocache g in Core.Geocaches) { if (_prevList[g.Code] == null && !g.Saved) { g.Selected = true; } ht.Add(g.Code, g); } _prevList = ht; } } }), null); }
private async void buttonSubmit_Click(object sender, EventArgs e) { panel1.Enabled = false; panel2.Enabled = false; this.ControlBox = false; _logDate = dateTimePicker1.Value.Date; _logType = (comboBoxLogType1.SelectedItem as Framework.Data.LogType); _tbs75 = (from string a in checkedListBox1.CheckedItems select a.Split(new char[] { ',' }, 2)[0]).ToList(); _logText = textBox2.Text; _foundcount = (int)numericUpDown1.Value; if (checkBox1.Checked) { _gcList = ((from int a in listView1.CheckedIndices orderby a select(Framework.Data.Geocache) listView1.Items[a].Tag).Take(1).ToList()); } else { _gcList = ((from int a in listView1.CheckedIndices orderby a select(Framework.Data.Geocache) listView1.Items[a].Tag).ToList()); } using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(_core)) { await Task.Run(() => { this.logThreadMethod(); }); } if (!string.IsNullOrEmpty(_errormessage)) { System.Windows.Forms.MessageBox.Show(_errormessage, Utils.LanguageSupport.Instance.GetTranslation(Utils.LanguageSupport.Instance.GetTranslation(STR_ERROR)), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } numericUpDown1.Value = _foundcount; panel2.Enabled = true; panel1.Enabled = true; toolStripStatusLabel1.Visible = false; toolStripStatusLabel1.Text = ""; this.ControlBox = true; }
public async override Task<bool> ActionAsync(string action) { bool result = base.Action(action); if (result && action == ACTION_CLEARFLAGS_SELECTED) { List<Framework.Data.Geocache> gcList = Utils.DataAccess.GetSelectedGeocaches(Core.Geocaches); if (gcList == null || gcList.Count == 0) { System.Windows.Forms.MessageBox.Show(Utils.LanguageSupport.Instance.GetTranslation(STR_NOCACHES_SELECTED), Utils.LanguageSupport.Instance.GetTranslation(STR_INFORMATION), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } else { using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(Core)) { foreach (Framework.Data.Geocache gc in gcList) { gc.Flagged = false; } } } } else if (result && action == ACTION_CLEARFLAGS_ALL) { using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(Core)) { foreach (Framework.Data.Geocache gc in Core.Geocaches) { gc.Flagged = false; } } } else if (result && action == ACTION_SELECTION) { List<Framework.Data.Geocache> gcList = Utils.DataAccess.GetSelectedGeocaches(Core.Geocaches); if (gcList == null || gcList.Count == 0) { System.Windows.Forms.MessageBox.Show(Utils.LanguageSupport.Instance.GetTranslation(STR_NOCACHES_SELECTED), Utils.LanguageSupport.Instance.GetTranslation(STR_INFORMATION), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } else { string msg = string.Format("{0} {1} {2}", Utils.LanguageSupport.Instance.GetTranslation(STR_ABOUTTODELETE), gcList.Count, Utils.LanguageSupport.Instance.GetTranslation(STR_GEOCACHES)); if (System.Windows.Forms.MessageBox.Show(msg, Utils.LanguageSupport.Instance.GetTranslation(STR_WARNING), System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Warning, System.Windows.Forms.MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.OK) { using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(Core)) { if (Core.ActiveGeocache != null && gcList.Contains(Core.ActiveGeocache)) { Core.ActiveGeocache = null; } _gcList = gcList; await Task.Run(() => { this.deleteSelectionThreadMethod(); }); } } } } else if (result && action == ACTION_ACTIVE) { if (Core.ActiveGeocache == null) { System.Windows.Forms.MessageBox.Show(Utils.LanguageSupport.Instance.GetTranslation(STR_NOCACHES_SELECTED), Utils.LanguageSupport.Instance.GetTranslation(STR_INFORMATION), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } else { string msg = string.Format("{0} {1} {2}", Utils.LanguageSupport.Instance.GetTranslation(STR_ABOUTTODELETE), 1, Utils.LanguageSupport.Instance.GetTranslation(STR_GEOCACHES)); if (System.Windows.Forms.MessageBox.Show(msg, Utils.LanguageSupport.Instance.GetTranslation(STR_WARNING), System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Warning, System.Windows.Forms.MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.OK) { using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(Core)) { Utils.DataAccess.DeleteGeocache(Core, Core.ActiveGeocache); Core.ActiveGeocache = null; } } } } return result; }
protected void ImportGeocaches(List<string> gcCodes) { if (gcCodes != null && gcCodes.Count > 0) { _gcList = new List<string>(); _gcList.AddRange(gcCodes); using (Utils.FrameworkDataUpdater d = new Utils.FrameworkDataUpdater(Core)) { _errormessage = null; _actionReady = new ManualResetEvent(false); Thread thrd = new Thread(new ThreadStart(this.importGeocachesThreadMethod)); thrd.Start(); while (!_actionReady.WaitOne(500)) { System.Windows.Forms.Application.DoEvents(); } thrd.Join(); _actionReady.Dispose(); if (!string.IsNullOrEmpty(_errormessage)) { System.Windows.Forms.MessageBox.Show(_errormessage, Utils.LanguageSupport.Instance.GetTranslation(Utils.LanguageSupport.Instance.GetTranslation(STR_ERROR)), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } } } }
private void button1_Click(object sender, EventArgs e) { _inEnvelope = checkBox1.Checked; if (radioButtonNewSearch.Checked) { _gcList = (from Framework.Data.Geocache g in _core.Geocaches select g).ToList(); } else if (radioButtonAddToCurrent.Checked) { _gcList = (from Framework.Data.Geocache g in _core.Geocaches where !g.Selected select g).ToList(); } else //within current { _gcList = (from Framework.Data.Geocache g in _core.Geocaches where g.Selected select g).ToList(); } using (Utils.FrameworkDataUpdater updater = new Utils.FrameworkDataUpdater(_core)) { if (radioButtonNewSearch.Checked || radioButtonWithinSelection.Checked) { foreach (Framework.Data.Geocache g in _core.Geocaches) { g.Selected = false; } } if (comboBox2.SelectedIndex < 1) { _areaName = ""; } else { _areaName = comboBox2.Text; } switch (comboBox1.SelectedIndex) { case 0: _level = Framework.Data.AreaType.Country; break; case 1: _level = Framework.Data.AreaType.State; break; case 2: _level = Framework.Data.AreaType.Municipality; break; case 3: _level = Framework.Data.AreaType.City; break; default: _level = Framework.Data.AreaType.Other; break; } _prefix = textBox1.Text; _actionReady = new ManualResetEvent(false); _actionReady.Reset(); Thread thrd = new Thread(new ThreadStart(this.performSelectionMethod)); thrd.Start(); while (!_actionReady.WaitOne(100)) { System.Windows.Forms.Application.DoEvents(); } thrd.Join(); _actionReady.Close(); Close(); } }
public async override Task <bool> ActionAsync(string action) { bool result = base.Action(action); if (result && action == ACTION_CLEARFLAGS_SELECTED) { List <Framework.Data.Geocache> gcList = Utils.DataAccess.GetSelectedGeocaches(Core.Geocaches); if (gcList == null || gcList.Count == 0) { System.Windows.Forms.MessageBox.Show(Utils.LanguageSupport.Instance.GetTranslation(STR_NOCACHES_SELECTED), Utils.LanguageSupport.Instance.GetTranslation(STR_INFORMATION), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } else { using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(Core)) { foreach (Framework.Data.Geocache gc in gcList) { gc.Flagged = false; } } } } else if (result && action == ACTION_CLEARFLAGS_ALL) { using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(Core)) { foreach (Framework.Data.Geocache gc in Core.Geocaches) { gc.Flagged = false; } } } else if (result && action == ACTION_SELECTION) { List <Framework.Data.Geocache> gcList = Utils.DataAccess.GetSelectedGeocaches(Core.Geocaches); if (gcList == null || gcList.Count == 0) { System.Windows.Forms.MessageBox.Show(Utils.LanguageSupport.Instance.GetTranslation(STR_NOCACHES_SELECTED), Utils.LanguageSupport.Instance.GetTranslation(STR_INFORMATION), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } else { string msg = string.Format("{0} {1} {2}", Utils.LanguageSupport.Instance.GetTranslation(STR_ABOUTTODELETE), gcList.Count, Utils.LanguageSupport.Instance.GetTranslation(STR_GEOCACHES)); if (System.Windows.Forms.MessageBox.Show(msg, Utils.LanguageSupport.Instance.GetTranslation(STR_WARNING), System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Warning, System.Windows.Forms.MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.OK) { using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(Core)) { if (Core.ActiveGeocache != null && gcList.Contains(Core.ActiveGeocache)) { Core.ActiveGeocache = null; } _gcList = gcList; await Task.Run(() => { this.deleteSelectionThreadMethod(); }); } } } } else if (result && action == ACTION_ACTIVE) { if (Core.ActiveGeocache == null) { System.Windows.Forms.MessageBox.Show(Utils.LanguageSupport.Instance.GetTranslation(STR_NOCACHES_SELECTED), Utils.LanguageSupport.Instance.GetTranslation(STR_INFORMATION), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } else { string msg = string.Format("{0} {1} {2}", Utils.LanguageSupport.Instance.GetTranslation(STR_ABOUTTODELETE), 1, Utils.LanguageSupport.Instance.GetTranslation(STR_GEOCACHES)); if (System.Windows.Forms.MessageBox.Show(msg, Utils.LanguageSupport.Instance.GetTranslation(STR_WARNING), System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Warning, System.Windows.Forms.MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.OK) { using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(Core)) { Utils.DataAccess.DeleteGeocache(Core, Core.ActiveGeocache); Core.ActiveGeocache = null; } } } } return(result); }
private async Task<bool> addGeocachesToDatabase(List<ListViewItem> lvis) { bool result = false; _geocacheCodes = new List<string>(); foreach (ListViewItem lvi in lvis) { if (!(lvi.Tag as GeocacheVisitsItem).InDatabase) { _geocacheCodes.Add((lvi.Tag as GeocacheVisitsItem).Code); } } if (_geocacheCodes.Count > 0) { this.ControlBox = false; this.groupBox1.Enabled = false; this.groupBox2.Enabled = false; this.panel1.Enabled = false; using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(_core)) { await Task.Run(() => { this.getGeocachesThreadMethod(); }); } if (!string.IsNullOrEmpty(_errormessage)) { System.Windows.Forms.MessageBox.Show(_errormessage, Utils.LanguageSupport.Instance.GetTranslation(Utils.LanguageSupport.Instance.GetTranslation(STR_ERROR)), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } else { result = true; } foreach (ListViewItem lvi in lvis) { GeocacheVisitsItem vi = lvi.Tag as GeocacheVisitsItem; if (!vi.InDatabase) { vi.InDatabase = Utils.DataAccess.GetGeocache(_core.Geocaches, vi.Code) != null; if (vi.InDatabase) { lvi.SubItems[0].Text = Utils.LanguageSupport.Instance.GetTranslation(STR_YES); } } } listView1_SelectedIndexChanged(this, null); button3.Enabled = (from a in _geocacheVisitsItems where !a.InDatabase select a).Count() > 0; button5.Enabled = (from a in _geocacheVisitsItems where a.InDatabase select a).Count() > 0; this.ControlBox = true; this.groupBox1.Enabled = true; this.groupBox2.Enabled = true; this.panel1.Enabled = true; } else { result = true; } return result; }
public async override Task<bool> ActionAsync(string action) { bool result = base.Action(action); Editor ed = Utils.PluginSupport.PluginByName(Core, "GlobalcachingApplication.Plugins.IgnoreGeocaches.Editor") as Editor; if (ed != null) { EditorForm ef = ed.ChildForm as EditorForm; if (ef != null) { if (result && action == ACTION_EDIT) { ed.Action(ed.DefaultAction); } else if (result && action == ACTION_SELECTION) { List<Framework.Data.Geocache> gcList = Utils.DataAccess.GetSelectedGeocaches(Core.Geocaches); if (gcList == null || gcList.Count == 0) { System.Windows.Forms.MessageBox.Show(Utils.LanguageSupport.Instance.GetTranslation(STR_NOCACHES_SELECTED), Utils.LanguageSupport.Instance.GetTranslation(STR_INFORMATION), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } else { string msg = string.Format("{0} {1} {2}", Utils.LanguageSupport.Instance.GetTranslation(STR_ABOUTTODELETE), gcList.Count, Utils.LanguageSupport.Instance.GetTranslation(STR_GEOCACHES)); if (System.Windows.Forms.MessageBox.Show(msg, Utils.LanguageSupport.Instance.GetTranslation(STR_WARNING), System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Warning, System.Windows.Forms.MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.OK) { using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(Core)) { if (Core.ActiveGeocache != null && gcList.Contains(Core.ActiveGeocache)) { Core.ActiveGeocache = null; } _gcList = gcList; await Task.Run(() => { this.deleteSelectionThreadMethod(); }); } } } } else if (result && action == ACTION_ACTIVE) { if (Core.ActiveGeocache == null) { System.Windows.Forms.MessageBox.Show(Utils.LanguageSupport.Instance.GetTranslation(STR_NOCACHES_SELECTED), Utils.LanguageSupport.Instance.GetTranslation(STR_INFORMATION), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } else { string msg = string.Format("{0} {1} {2}", Utils.LanguageSupport.Instance.GetTranslation(STR_ABOUTTODELETE), 1, Utils.LanguageSupport.Instance.GetTranslation(STR_GEOCACHES)); if (System.Windows.Forms.MessageBox.Show(msg, Utils.LanguageSupport.Instance.GetTranslation(STR_WARNING), System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Warning, System.Windows.Forms.MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.OK) { ef.AddFilter(IgnoreService.FilterField.GeocacheCode, Core.ActiveGeocache.Code); Utils.DataAccess.DeleteGeocache(Core, Core.ActiveGeocache); Core.ActiveGeocache = null; } } } } } return result; }
private bool addGeocachesToDatabase(List<ListViewItem> lvis) { bool result = false; _geocacheCodes = new List<string>(); foreach (ListViewItem lvi in lvis) { if (!(lvi.Tag as GeocacheVisitsItem).InDatabase) { _geocacheCodes.Add((lvi.Tag as GeocacheVisitsItem).Code); } } if (_geocacheCodes.Count > 0) { this.ControlBox = false; this.groupBox1.Enabled = false; this.groupBox2.Enabled = false; this.panel1.Enabled = false; using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(_core)) { _actionReady = new ManualResetEvent(false); Thread thrd = new Thread(new ThreadStart(this.getGeocachesThreadMethod)); thrd.Start(); while (!_actionReady.WaitOne(100)) { System.Windows.Forms.Application.DoEvents(); } thrd.Join(); _actionReady.Dispose(); _actionReady = null; } if (!string.IsNullOrEmpty(_errormessage)) { System.Windows.Forms.MessageBox.Show(_errormessage, Utils.LanguageSupport.Instance.GetTranslation(Utils.LanguageSupport.Instance.GetTranslation(STR_ERROR)), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } else { result = true; } foreach (ListViewItem lvi in lvis) { GeocacheVisitsItem vi = lvi.Tag as GeocacheVisitsItem; if (!vi.InDatabase) { vi.InDatabase = Utils.DataAccess.GetGeocache(_core.Geocaches, vi.Code) != null; if (vi.InDatabase) { lvi.SubItems[0].Text = Utils.LanguageSupport.Instance.GetTranslation(STR_YES); } } } listView1_SelectedIndexChanged(this, null); button3.Enabled = (from a in _geocacheVisitsItems where !a.InDatabase select a).Count() > 0; button5.Enabled = (from a in _geocacheVisitsItems where a.InDatabase select a).Count() > 0; this.ControlBox = true; this.groupBox1.Enabled = true; this.groupBox2.Enabled = true; this.panel1.Enabled = true; } else { result = true; } return result; }
private async void button1_Click(object sender, EventArgs e) { _inEnvelope = checkBox1.Checked; if (radioButtonNewSearch.Checked) { _gcList = (from Framework.Data.Geocache g in _core.Geocaches select g).ToList(); } else if (radioButtonAddToCurrent.Checked) { _gcList = (from Framework.Data.Geocache g in _core.Geocaches where !g.Selected select g).ToList(); } else //within current { _gcList = (from Framework.Data.Geocache g in _core.Geocaches where g.Selected select g).ToList(); } using (Utils.FrameworkDataUpdater updater = new Utils.FrameworkDataUpdater(_core)) { if (radioButtonNewSearch.Checked || radioButtonWithinSelection.Checked) { foreach (Framework.Data.Geocache g in _core.Geocaches) { g.Selected = false; } } if (comboBox2.SelectedIndex < 1) { _areaName = ""; } else { _areaName = comboBox2.Text; } switch (comboBox1.SelectedIndex) { case 0: _level = Framework.Data.AreaType.Country; break; case 1: _level = Framework.Data.AreaType.State; break; case 2: _level = Framework.Data.AreaType.Municipality; break; case 3: _level = Framework.Data.AreaType.City; break; default: _level = Framework.Data.AreaType.Other; break; } _prefix = textBox1.Text; await Task.Run(() => { this.performSelectionMethod(); }); Close(); } }
private void getGeocacheInbackgroundMethod() { Utils.API.LiveV6.Geocache[] gcList = null; try { using (Utils.API.GeocachingLiveV6 client = new Utils.API.GeocachingLiveV6(Core, string.IsNullOrEmpty(Core.GeocachingComAccount.APIToken))) { var req = new Utils.API.LiveV6.SearchForGeocachesRequest(); req.AccessToken = client.Token; req.CacheCode = new Utils.API.LiveV6.CacheCodeFilter(); req.CacheCode.CacheCodes = new string[] { _codeToGetWithLiveAPI }; req.GeocacheLogCount = 5; req.IsLite = Core.GeocachingComAccount.MemberTypeId == 1; req.MaxPerPage = 1; var resp = client.Client.SearchForGeocaches(req); if (resp.Status.StatusCode == 0 && resp.Geocaches != null) { gcList = resp.Geocaches; } } } catch { } _context.Post(new SendOrPostCallback(delegate(object state) { Framework.Data.Geocache activeGC = null; if (gcList != null) { using (Utils.FrameworkDataUpdater dupd = new Utils.FrameworkDataUpdater(Core)) { List<Framework.Data.Geocache> lst = Utils.API.Import.AddGeocaches(Core, gcList); if (lst != null && lst.Count > 0) { activeGC = lst[lst.Count - 1]; } } } toolStripStatusLabelGettingGeocache.Visible = false; Core.ActiveGeocache = activeGC; if (activeGC != null) { if (linkLabelUnavailableCache.Visible) { if (linkLabelUnavailableCache.Text.IndexOf(activeGC.Code) >= 0) { linkLabelUnavailableCache.Visible = false; } } } }), null); }
void _serverConnection_DataReceived(object sender, EventArgs e) { _context.Post(new SendOrPostCallback(delegate(object state) { try { if (_serverConnection != null) { byte[] data = _serverConnection.ReadData(); while (data != null) { //parse data ChatMessage msg = ChatMessage.Parse(data); if (msg != null) { //handle data if (msg.Name == "signinfailed") { CloseConnection(); break; } else if (msg.Name == "signinsuccess") { _retryCount = 0; panel1.Enabled = true; splitContainer1.Enabled = true; toolStripStatusLabelConnectionStatus.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_CONNECTED); } else if (msg.Name == "txt") { AddMessage(msg.ID, msg.Parameters["msg"], Color.FromArgb(int.Parse(msg.Parameters["color"]))); if (checkBoxPlaySound.Checked && _sndWelcome != null) { _sndMessage.Play(); //System.Media.SystemSounds.Beep.Play(); } } else if (msg.Name == "usersinroom") { bool newUser = false; int i = 0; UserInRoomInfo[] curUsr = (from UserInRoomInfo a in listBox1.Items select a as UserInRoomInfo).ToArray(); foreach (var x in curUsr) { x.present = false; } bool wasempty = curUsr.Length == 0; while (msg.Parameters.ContainsKey(string.Format("name{0}", i))) { string id = msg.Parameters[string.Format("id{0}", i)]; UserInRoomInfo c = (from x in curUsr where x.ID == id select x).FirstOrDefault(); if (c == null) { c = new UserInRoomInfo(); c.ID = id; c.Username = msg.Parameters[string.Format("name{0}", i)]; c.present = true; c.FollowThisUser = false; c.SelectionCount = -1; if (msg.Parameters.ContainsKey(string.Format("sc{0}", i))) { string selCount = msg.Parameters[string.Format("sc{0}", i)]; if (!string.IsNullOrEmpty(selCount)) { c.SelectionCount = int.Parse(selCount); } } c.CanBeFollowed = bool.Parse(msg.Parameters[string.Format("cbf{0}", i)]); c.ActiveGeocache = msg.Parameters[string.Format("agc{0}", i)]; listBox1.Items.Add(c); if (!wasempty) { AddMessage("-1", string.Format("{0} {1}", c.Username, Utils.LanguageSupport.Instance.GetTranslation(STR_JOINED)), Color.Black); } newUser = true; } else { c.CanBeFollowed = bool.Parse(msg.Parameters[string.Format("cbf{0}", i)]); c.ActiveGeocache = msg.Parameters[string.Format("agc{0}", i)]; c.present = true; } i++; } foreach (var x in curUsr) { if (!x.present) { listBox1.Items.Remove(x); } } typeof(ListBox).InvokeMember("RefreshItems", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, null, listBox1, new object[] { }); listBox1_SelectedIndexChanged(this, EventArgs.Empty); if (checkBoxPlaySound.Checked && newUser && _sndWelcome != null) { _sndWelcome.Play(); //System.Media.SystemSounds.Beep.Play(); } } else if (msg.Name == "follow") { UserInRoomInfo[] curUsr = (from UserInRoomInfo a in listBox1.Items select a as UserInRoomInfo).ToArray(); UserInRoomInfo c = (from x in curUsr where x.ID == msg.ID select x).FirstOrDefault(); if (c != null) { c.CanBeFollowed = bool.Parse(msg.Parameters["canfollow"]); c.ActiveGeocache = msg.Parameters["cache"]; c.SelectionCount = -1; if (msg.Parameters.ContainsKey("selected")) { string selCount = msg.Parameters["selected"]; if (!string.IsNullOrEmpty(selCount)) { c.SelectionCount = int.Parse(selCount); } } if (c.FollowThisUser) { if (!c.CanBeFollowed) { c.FollowThisUser = false; linkLabelUnavailableCache.Visible = false; } else { if (!string.IsNullOrEmpty(c.ActiveGeocache)) { Framework.Data.Geocache gc = Utils.DataAccess.GetGeocache(Core.Geocaches, c.ActiveGeocache); if (gc != null) { Core.ActiveGeocache = gc; linkLabelUnavailableCache.Visible = false; } else if (c.ActiveGeocache.StartsWith("GC") && Core.GeocachingComAccount.MemberTypeId > 1) { //offer to download linkLabelUnavailableCache.Links.Clear(); linkLabelUnavailableCache.Text = string.Format("{0}: {1}", Utils.LanguageSupport.Instance.GetTranslation(STR_MISSING), c.ActiveGeocache); linkLabelUnavailableCache.Links.Add(linkLabelUnavailableCache.Text.IndexOf(':') + 2, c.ActiveGeocache.Length, c.ActiveGeocache); linkLabelUnavailableCache.Visible = true; } else { linkLabelUnavailableCache.Visible = false; } } else { linkLabelUnavailableCache.Visible = false; } } } } typeof(ListBox).InvokeMember("RefreshItems", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, null, listBox1, new object[] { }); listBox1_SelectedIndexChanged(this, EventArgs.Empty); } else if (msg.Name == "rooms") { RoomInfo[] curRms = (from RoomInfo a in listBox2.Items select a as RoomInfo).ToArray(); foreach (var x in curRms) { x.present = false; } int i = 0; while (msg.Parameters.ContainsKey(string.Format("name{0}", i))) { string name = msg.Parameters[string.Format("name{0}", i)]; RoomInfo c = (from x in curRms where x.Name == name select x).FirstOrDefault(); if (c == null) { c = new RoomInfo(); c.present = true; c.Name = name; listBox2.Items.Add(c); } else { c.present = true; } i++; } foreach (var x in curRms) { if (!x.present) { listBox2.Items.Remove(x); } } typeof(ListBox).InvokeMember("RefreshItems", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, null, listBox2, new object[] { }); } else if (msg.Name == "reqsel") { StringBuilder sb = new StringBuilder(); UserInRoomInfo[] curUsr = (from UserInRoomInfo a in listBox1.Items select a as UserInRoomInfo).ToArray(); UserInRoomInfo c = (from x in curUsr where x.ID == msg.ID select x).FirstOrDefault(); if (c != null) { AddMessage("-1", string.Format("{0} {1}", c.Username, Utils.LanguageSupport.Instance.GetTranslation(STR_REQUESTEDSELECTION)), Color.Black); var gsel = from Framework.Data.Geocache g in Core.Geocaches where g.Selected select g; foreach (var g in gsel) { sb.AppendFormat("{0},", g.Code); } } ChatMessage bmsg = new ChatMessage(); bmsg.Name = "reqselresp"; bmsg.Parameters.Add("reqid", msg.Parameters["reqid"]); bmsg.Parameters.Add("clientid", msg.ID); bmsg.Parameters.Add("selection", sb.ToString()); sendMessage(bmsg); } else if (msg.Name == "reqselresp") { if (msg.Parameters["reqid"] == _currentCopySelectionRequestID) { //handle response string[] gcCodes = msg.Parameters["selection"].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); Core.Geocaches.BeginUpdate(); foreach (Framework.Data.Geocache g in Core.Geocaches) { g.Selected = gcCodes.Contains(g.Code); } Core.Geocaches.EndUpdate(); //are we missing geocaches? _importGeocaches.Clear(); if (Core.GeocachingComAccount.MemberTypeId > 1) { foreach (string s in gcCodes) { if (Utils.DataAccess.GetGeocache(Core.Geocaches, s) == null && s.StartsWith("GC")) { _importGeocaches.Add(s); } } if (_importGeocaches.Count > 0) { _frameworkUpdater = new Utils.FrameworkDataUpdater(Core); _getGeocacheThread = new Thread(new ThreadStart(getCopiedSelectionGeocacheInbackgroundMethod)); _getGeocacheThread.IsBackground = true; _getGeocacheThread.Start(); } } //reset request prop. timerCopySelection.Enabled = false; _currentCopySelectionRequestID = null; _copySelectionRequestStarted = DateTime.MinValue; toolStripStatusLabelRequestSelection.Visible = false; } } } data = _serverConnection.ReadData(); } } } catch { CloseConnection(); } }), null); }
private void getCopiedSelectionGeocacheInbackgroundMethod() { try { int max = _importGeocaches.Count; using (Utils.ProgressBlock prog = new Utils.ProgressBlock(OwnerPlugin as Utils.BasePlugin.Plugin, STR_COPYSELECTION, STR_RETRIEVING, max, 0, true)) { using (Utils.API.GeocachingLiveV6 client = new Utils.API.GeocachingLiveV6(Core, string.IsNullOrEmpty(Core.GeocachingComAccount.APIToken))) { var req = new Utils.API.LiveV6.SearchForGeocachesRequest(); req.AccessToken = client.Token; while (_importGeocaches.Count > 0) { req.CacheCode = new Utils.API.LiveV6.CacheCodeFilter(); req.CacheCode.CacheCodes = (from gc in _importGeocaches select gc).Take(10).ToArray(); req.GeocacheLogCount = 5; req.IsLite = Core.GeocachingComAccount.MemberTypeId == 1; req.MaxPerPage = req.CacheCode.CacheCodes.Length; var resp = client.Client.SearchForGeocaches(req); if (resp.Status.StatusCode == 0 && resp.Geocaches != null) { _importGeocaches.RemoveRange(0, req.CacheCode.CacheCodes.Length); Utils.API.Import.AddGeocaches(Core, resp.Geocaches); } else { break; } if (!prog.UpdateProgress(STR_COPYSELECTION, STR_RETRIEVING, max, max - _importGeocaches.Count)) { break; } } } } } catch { } _context.Send(new SendOrPostCallback(delegate(object state) { _frameworkUpdater.Dispose(); _frameworkUpdater = null; }), null); }
public async override Task<bool> ActionAsync(string action) { bool result = base.Action(action); if (result) { if (action == ACTION_SHOW) { if (Utils.API.GeocachingLiveV6.CheckAPIAccessAvailable(Core, false)) { bool perform = true; if (PluginSettings.Instance.ShowSettingsDialog) { using (SettingsForm dlg = new SettingsForm()) { perform = dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK; } } if (perform) { using (Utils.FrameworkDataUpdater updater = new Utils.FrameworkDataUpdater(Core)) { _errormessage = ""; await Task.Run(() => { this.threadMethod(); }); if (!string.IsNullOrEmpty(_errormessage)) { System.Windows.Forms.MessageBox.Show(_errormessage, Utils.LanguageSupport.Instance.GetTranslation(STR_ERROR), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } } } } } result = true; } return result; }
public override bool Action(string action) { bool result = base.Action(action); if (result) { if (action == ACTION_SHOW) { if (Utils.API.GeocachingLiveV6.CheckAPIAccessAvailable(Core, false)) { bool perform = true; if (Properties.Settings.Default.ShowSettingsDialog) { using (SettingsForm dlg = new SettingsForm()) { perform = dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK; } } if (perform) { using (Utils.FrameworkDataUpdater updater = new Utils.FrameworkDataUpdater(Core)) { _errormessage = ""; _actionReady = new ManualResetEvent(false); Thread thrd = new Thread(new ThreadStart(this.threadMethod)); thrd.Start(); while (!_actionReady.WaitOne(100)) { System.Windows.Forms.Application.DoEvents(); } thrd.Join(); _actionReady.Dispose(); if (!string.IsNullOrEmpty(_errormessage)) { System.Windows.Forms.MessageBox.Show(_errormessage, Utils.LanguageSupport.Instance.GetTranslation(STR_ERROR), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } } } } } result = true; } return result; }
private void buttonSubmit_Click(object sender, EventArgs e) { panel1.Enabled = false; panel2.Enabled = false; this.ControlBox = false; _logDate = dateTimePicker1.Value.Date; _logType = (comboBoxLogType1.SelectedItem as Framework.Data.LogType); _tbs75 = (from string a in checkedListBox1.CheckedItems select a.Split(new char[] { ',' }, 2)[0]).ToList(); _logText = textBox2.Text; _foundcount = (int)numericUpDown1.Value; if (checkBox1.Checked) { _gcList = ((from int a in listView1.CheckedIndices orderby a select (Framework.Data.Geocache)listView1.Items[a].Tag).Take(1).ToList()); } else { _gcList = ((from int a in listView1.CheckedIndices orderby a select (Framework.Data.Geocache)listView1.Items[a].Tag).ToList()); } using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(_core)) { _actionReady = new ManualResetEvent(false); Thread thrd = new Thread(new ThreadStart(this.logThreadMethod)); thrd.Start(); while (!_actionReady.WaitOne(100)) { System.Windows.Forms.Application.DoEvents(); } thrd.Join(); _actionReady.Dispose(); _actionReady = null; } if (!string.IsNullOrEmpty(_errormessage)) { System.Windows.Forms.MessageBox.Show(_errormessage, Utils.LanguageSupport.Instance.GetTranslation(Utils.LanguageSupport.Instance.GetTranslation(STR_ERROR)), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } numericUpDown1.Value = _foundcount; panel2.Enabled = true; panel1.Enabled = true; toolStripStatusLabel1.Visible = false; toolStripStatusLabel1.Text = ""; this.ControlBox = true; }
public override bool Action(string action) { bool result = base.Action(action); if (result && action == ACTION_CLEARFLAGS_SELECTED) { List<Framework.Data.Geocache> gcList = Utils.DataAccess.GetSelectedGeocaches(Core.Geocaches); if (gcList == null || gcList.Count == 0) { System.Windows.Forms.MessageBox.Show(Utils.LanguageSupport.Instance.GetTranslation(STR_NOCACHES_SELECTED), Utils.LanguageSupport.Instance.GetTranslation(STR_INFORMATION), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } else { using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(Core)) { foreach (Framework.Data.Geocache gc in gcList) { gc.Flagged = false; } } } } else if (result && action == ACTION_CLEARFLAGS_ALL) { using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(Core)) { foreach (Framework.Data.Geocache gc in Core.Geocaches) { gc.Flagged = false; } } } else if (result && action == ACTION_SELECTION) { List<Framework.Data.Geocache> gcList = Utils.DataAccess.GetSelectedGeocaches(Core.Geocaches); if (gcList == null || gcList.Count == 0) { System.Windows.Forms.MessageBox.Show(Utils.LanguageSupport.Instance.GetTranslation(STR_NOCACHES_SELECTED), Utils.LanguageSupport.Instance.GetTranslation(STR_INFORMATION), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } else { string msg = string.Format("{0} {1} {2}", Utils.LanguageSupport.Instance.GetTranslation(STR_ABOUTTODELETE), gcList.Count, Utils.LanguageSupport.Instance.GetTranslation(STR_GEOCACHES)); if (System.Windows.Forms.MessageBox.Show(msg, Utils.LanguageSupport.Instance.GetTranslation(STR_WARNING), System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Warning, System.Windows.Forms.MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.OK) { using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(Core)) { if (Core.ActiveGeocache != null && gcList.Contains(Core.ActiveGeocache)) { Core.ActiveGeocache = null; } _gcList = gcList; _actionReady = new ManualResetEvent(false); Thread thrd = new Thread(new ThreadStart(this.deleteSelectionThreadMethod)); thrd.Start(); while (!_actionReady.WaitOne(10)) { System.Windows.Forms.Application.DoEvents(); } thrd.Join(); _actionReady.Dispose(); _actionReady = null; } } } } else if (result && action == ACTION_ACTIVE) { if (Core.ActiveGeocache == null) { System.Windows.Forms.MessageBox.Show(Utils.LanguageSupport.Instance.GetTranslation(STR_NOCACHES_SELECTED), Utils.LanguageSupport.Instance.GetTranslation(STR_INFORMATION), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } else { string msg = string.Format("{0} {1} {2}", Utils.LanguageSupport.Instance.GetTranslation(STR_ABOUTTODELETE), 1, Utils.LanguageSupport.Instance.GetTranslation(STR_GEOCACHES)); if (System.Windows.Forms.MessageBox.Show(msg, Utils.LanguageSupport.Instance.GetTranslation(STR_WARNING), System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Warning, System.Windows.Forms.MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.OK) { using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(Core)) { Utils.DataAccess.DeleteGeocache(Core, Core.ActiveGeocache); Core.ActiveGeocache = null; } } } } return result; }
public async override Task <bool> ActionAsync(string action) { bool result = base.Action(action); Editor ed = Utils.PluginSupport.PluginByName(Core, "GlobalcachingApplication.Plugins.IgnoreGeocaches.Editor") as Editor; if (ed != null) { EditorForm ef = ed.ChildForm as EditorForm; if (ef != null) { if (result && action == ACTION_EDIT) { ed.Action(ed.DefaultAction); } else if (result && action == ACTION_SELECTION) { List <Framework.Data.Geocache> gcList = Utils.DataAccess.GetSelectedGeocaches(Core.Geocaches); if (gcList == null || gcList.Count == 0) { System.Windows.Forms.MessageBox.Show(Utils.LanguageSupport.Instance.GetTranslation(STR_NOCACHES_SELECTED), Utils.LanguageSupport.Instance.GetTranslation(STR_INFORMATION), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } else { string msg = string.Format("{0} {1} {2}", Utils.LanguageSupport.Instance.GetTranslation(STR_ABOUTTODELETE), gcList.Count, Utils.LanguageSupport.Instance.GetTranslation(STR_GEOCACHES)); if (System.Windows.Forms.MessageBox.Show(msg, Utils.LanguageSupport.Instance.GetTranslation(STR_WARNING), System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Warning, System.Windows.Forms.MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.OK) { using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(Core)) { if (Core.ActiveGeocache != null && gcList.Contains(Core.ActiveGeocache)) { Core.ActiveGeocache = null; } _gcList = gcList; await Task.Run(() => { this.deleteSelectionThreadMethod(); }); } } } } else if (result && action == ACTION_ACTIVE) { if (Core.ActiveGeocache == null) { System.Windows.Forms.MessageBox.Show(Utils.LanguageSupport.Instance.GetTranslation(STR_NOCACHES_SELECTED), Utils.LanguageSupport.Instance.GetTranslation(STR_INFORMATION), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } else { string msg = string.Format("{0} {1} {2}", Utils.LanguageSupport.Instance.GetTranslation(STR_ABOUTTODELETE), 1, Utils.LanguageSupport.Instance.GetTranslation(STR_GEOCACHES)); if (System.Windows.Forms.MessageBox.Show(msg, Utils.LanguageSupport.Instance.GetTranslation(STR_WARNING), System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Warning, System.Windows.Forms.MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.OK) { ef.AddFilter(IgnoreService.FilterField.GeocacheCode, Core.ActiveGeocache.Code); Utils.DataAccess.DeleteGeocache(Core, Core.ActiveGeocache); Core.ActiveGeocache = null; } } } } } return(result); }