private void button2_Click(object sender, EventArgs e) { BookmarkInfo bmi = comboBox1.SelectedItem as BookmarkInfo; if (bmi != null) { _ignoreDataChanged = true; Repository.Instance.DeleteCollection(bmi.Name); _ignoreDataChanged = false; comboBox1.Items.Remove(bmi); comboBox1_SelectedIndexChanged(sender, e); textBox1_TextChanged(sender, e); } }
public void DeleteCollection(string name) { BookmarkInfo bmi = _bookmarks[name.ToLower()] as BookmarkInfo; if (bmi != null) { lock (_core.SettingsProvider) { _core.SettingsProvider.Database.Execute(string.Format("delete from {1} where BookmarkID={0}", bmi.ID, _core.SettingsProvider.GetFullTableName("bmcodes"))); _core.SettingsProvider.Database.Execute(string.Format("delete from {1} where ID={0}", bmi.ID, _core.SettingsProvider.GetFullTableName("bookmark"))); } _bookmarks.Remove(name); } }
private void button7_Click(object sender, EventArgs e) { BookmarkInfo bmi = comboBox1.SelectedItem as BookmarkInfo; if (bmi != null) { _ignoreDataChanged = true; List <Framework.Data.Geocache> gcList = Utils.DataAccess.GetSelectedGeocaches(Core.Geocaches); foreach (Framework.Data.Geocache gc in gcList) { Repository.Instance.AddToCollection(bmi.Name, gc.Code); } _ignoreDataChanged = false; comboBox1_SelectedIndexChanged(sender, e); } }
private void button6_Click(object sender, EventArgs e) { BookmarkInfo bmi = comboBox1.SelectedItem as BookmarkInfo; if (bmi != null && Core.ActiveGeocache != null) { if (bmi.GeocacheCodes[Core.ActiveGeocache.Code] == null) { _ignoreDataChanged = true; Repository.Instance.AddToCollection(bmi.Name, Core.ActiveGeocache.Code); _ignoreDataChanged = false; listBox1.Items.Add(Core.ActiveGeocache.Code); } } button6.Enabled = false; }
public void RemoveFromCollection(string collectionName, string geocacheCode) { BookmarkInfo bmi = _bookmarks[collectionName.ToLower()] as BookmarkInfo; if (bmi != null) { if (bmi.GeocacheCodes[geocacheCode.ToUpper()] != null) { lock (_core.SettingsProvider) { _core.SettingsProvider.Database.Execute(string.Format("delete from {2} where BookmarkID={0} and Code='{1}'", bmi.ID, geocacheCode.ToUpper(), _core.SettingsProvider.GetFullTableName("bmcodes"))); } bmi.GeocacheCodes.Remove(geocacheCode.ToUpper()); } } }
public void AddToCollection(string collectionName, string geocacheCode) { BookmarkInfo bmi = AddCollection(collectionName); if (bmi != null) { if (bmi.GeocacheCodes[geocacheCode.ToUpper()] == null) { lock (_core.SettingsProvider) { _core.SettingsProvider.Database.Execute(string.Format("insert into {2} (BookmarkID, Code) values ({0}, '{1}')", bmi.ID, geocacheCode.ToUpper(), _core.SettingsProvider.GetFullTableName("bmcodes"))); } bmi.GeocacheCodes.Add(geocacheCode.ToUpper(), true); } } }
private void checkButtons() { BookmarkInfo bmi = comboBox1.SelectedItem as BookmarkInfo; if (bmi != null) { button5.Enabled = listBox1.Items.Count > 0; button6.Enabled = Core.ActiveGeocache != null && !Repository.Instance.InCollection(bmi.Name, Core.ActiveGeocache.Code); button7.Enabled = (from Framework.Data.Geocache gc in Core.Geocaches where gc.Selected select gc).FirstOrDefault() != null; } else { button6.Enabled = false; button7.Enabled = false; } listBox1_SelectedIndexChanged(null, EventArgs.Empty); }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { listBox1.Items.Clear(); BookmarkInfo bmi = comboBox1.SelectedItem as BookmarkInfo; if (bmi != null) { button2.Enabled = true; listBox1.Items.AddRange((from string s in bmi.GeocacheCodes.Keys select s).OrderBy(x => x).ToArray()); } else { button2.Enabled = false; } checkButtons(); checkActiveGeocache(); }
public void Initialize(Framework.Interfaces.ICore core) { _core = core; if (_bookmarks == null) { _bookmarks = new Hashtable(); try { lock (_core.SettingsProvider) { if (!_core.SettingsProvider.TableExists(_core.SettingsProvider.GetFullTableName("bookmark"))) { _core.SettingsProvider.Database.Execute(string.Format("create table '{0}' (ID integer primary key autoincrement, Name text)", _core.SettingsProvider.GetFullTableName("bookmark"))); } if (!_core.SettingsProvider.TableExists(_core.SettingsProvider.GetFullTableName("bmcodes"))) { _core.SettingsProvider.Database.Execute(string.Format("create table '{0}' (BookmarkID integer, Code text)", _core.SettingsProvider.GetFullTableName("bmcodes"))); } var bms = _core.SettingsProvider.Database.Fetch<BookmarkPoco>(string.Format("select * from {0}", _core.SettingsProvider.GetFullTableName("bookmark"))); foreach (var bm in bms) { BookmarkInfo bmi = new BookmarkInfo(); bmi.ID = bm.ID; bmi.Name = bm.Name; _bookmarks.Add(bmi.Name.ToLower(), bmi); } var bmcs = _core.SettingsProvider.Database.Fetch<BookmarkCodePoco>(string.Format("select * from {0}", _core.SettingsProvider.GetFullTableName("bmcodes"))); foreach (var bmc in bmcs) { BookmarkInfo bmi = (from BookmarkInfo b in _bookmarks.Values where b.ID == bmc.BookmarkID select b).FirstOrDefault(); if (bmi != null) { bmi.GeocacheCodes.Add(bmc.Code, true); } } } } catch { } } }
public void Initialize(Framework.Interfaces.ICore core) { _core = core; if (_bookmarks == null) { _bookmarks = new Hashtable(); try { lock (_core.SettingsProvider) { if (!_core.SettingsProvider.TableExists(_core.SettingsProvider.GetFullTableName("bookmark"))) { _core.SettingsProvider.Database.Execute(string.Format("create table '{0}' (ID integer primary key autoincrement, Name text)", _core.SettingsProvider.GetFullTableName("bookmark"))); } if (!_core.SettingsProvider.TableExists(_core.SettingsProvider.GetFullTableName("bmcodes"))) { _core.SettingsProvider.Database.Execute(string.Format("create table '{0}' (BookmarkID integer, Code text)", _core.SettingsProvider.GetFullTableName("bmcodes"))); } var bms = _core.SettingsProvider.Database.Fetch <BookmarkPoco>(string.Format("select * from {0}", _core.SettingsProvider.GetFullTableName("bookmark"))); foreach (var bm in bms) { BookmarkInfo bmi = new BookmarkInfo(); bmi.ID = bm.ID; bmi.Name = bm.Name; _bookmarks.Add(bmi.Name.ToLower(), bmi); } var bmcs = _core.SettingsProvider.Database.Fetch <BookmarkCodePoco>(string.Format("select * from {0}", _core.SettingsProvider.GetFullTableName("bmcodes"))); foreach (var bmc in bmcs) { BookmarkInfo bmi = (from BookmarkInfo b in _bookmarks.Values where b.ID == bmc.BookmarkID select b).FirstOrDefault(); if (bmi != null) { bmi.GeocacheCodes.Add(bmc.Code, true); } } } } catch { } } }
public void Initialize(Framework.Interfaces.ICore core) { if (_bookmarks == null) { _bookmarks = new Hashtable(); try { _dbcon = new Utils.DBConComSqlite(Path.Combine(core.PluginDataPath, "gccollections.db3")); object o = _dbcon.ExecuteScalar("SELECT name FROM sqlite_master WHERE type='table' AND name='bookmark'"); if (o == null || o.GetType() == typeof(DBNull)) { _dbcon.ExecuteNonQuery("create table 'bookmark' (ID integer primary key autoincrement, Name text)"); _dbcon.ExecuteNonQuery("create table 'codes' (BookmarkID integer, Code text)"); } DbDataReader dr = _dbcon.ExecuteReader("select ID, Name from bookmark"); while (dr.Read()) { BookmarkInfo bmi = new BookmarkInfo(); bmi.ID = (int)dr["ID"]; bmi.Name = (string)dr["Name"]; _bookmarks.Add(bmi.Name.ToLower(), bmi); } dr = _dbcon.ExecuteReader("select BookmarkID, Code from codes"); while (dr.Read()) { int id = (int)dr["BookmarkID"]; BookmarkInfo bmi = (from BookmarkInfo b in _bookmarks.Values where b.ID==id select b).FirstOrDefault(); if (bmi != null) { bmi.GeocacheCodes.Add(dr["Code"], true); } } } catch { } } }
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; } } } } }
public BookmarkInfo AddCollection(string name) { BookmarkInfo bmi = _bookmarks[name.ToLower()] as BookmarkInfo; if (bmi == null) { int id; lock (_core.SettingsProvider) { _core.SettingsProvider.Database.Execute(string.Format("insert into {1} (Name) values ('{0}')", name.Replace("'", "''"), _core.SettingsProvider.GetFullTableName("bookmark"))); id = _core.SettingsProvider.Database.ExecuteScalar <int>(string.Format("select ID from {1} where Name = '{0}'", name.Replace("'", "''"), _core.SettingsProvider.GetFullTableName("bookmark"))); } bmi = new BookmarkInfo(); bmi.ID = id; bmi.Name = name; _bookmarks.Add(name.ToLower(), bmi); } return(bmi); }
public BookmarkInfo AddCollection(string name) { BookmarkInfo bmi = _bookmarks[name.ToLower()] as BookmarkInfo; if (bmi == null) { _dbcon.ExecuteNonQuery(string.Format("insert into bookmark (Name) values ('{0}')", name.Replace("'", "''"))); int id = (int)_dbcon.ExecuteScalar(string.Format("select ID from bookmark where Name = '{0}'", name.Replace("'", "''"))); bmi = new BookmarkInfo(); bmi.ID = id; bmi.Name = name; _bookmarks.Add(name.ToLower(), bmi); } return bmi; }
public BookmarkInfo AddCollection(string name) { BookmarkInfo bmi = _bookmarks[name.ToLower()] as BookmarkInfo; if (bmi == null) { int id; lock (_core.SettingsProvider) { _core.SettingsProvider.Database.Execute(string.Format("insert into {1} (Name) values ('{0}')", name.Replace("'", "''"), _core.SettingsProvider.GetFullTableName("bookmark"))); id = _core.SettingsProvider.Database.ExecuteScalar<int>(string.Format("select ID from {1} where Name = '{0}'", name.Replace("'", "''"), _core.SettingsProvider.GetFullTableName("bookmark"))); } bmi = new BookmarkInfo(); bmi.ID = id; bmi.Name = name; _bookmarks.Add(name.ToLower(), bmi); } return bmi; }