コード例 #1
0
 public void GetPolygonOfArea(Framework.Data.AreaInfo area)
 {
     PreLoadAreaInfo();
     if (area.Polygons == null)
     {
         Framework.Data.AreaInfo ainf = (from ai in _cachedAreaInfo where ai.ID == area.ID select ai).FirstOrDefault();
         if (ainf != null)
         {
             try
             {
                 area.Polygons = new List <Framework.Data.Polygon>();
                 using (Utils.DBCon dbcon = new Utils.DBConComSqlite(_databaseFilename))
                 {
                     int actPolyId = -1;
                     Framework.Data.Polygon polg = null;
                     DbDataReader           dr   = dbcon.ExecuteReader(string.Format("select * from poly where areainfoid={0} order by id, position", area.ID));
                     while (dr.Read())
                     {
                         int polyId = (int)dr["id"];
                         if (actPolyId != polyId)
                         {
                             polg = new Framework.Data.Polygon();
                             area.Polygons.Add(polg);
                             actPolyId = polyId;
                         }
                         polg.AddLocation(new Framework.Data.Location((double)dr["lat"], (double)dr["lon"]));
                     }
                 }
             }
             catch
             {
             }
         }
     }
 }
コード例 #2
0
ファイル: IgnoreService.cs プロジェクト: RH-Code/GAPP
        private IgnoreService(Framework.Interfaces.ICore core)
        {
            _filterFields = new Hashtable();
            _core = core;

            foreach (string s in Enum.GetNames(typeof(FilterField)))
            {
                _filterFields.Add(s, new Hashtable());
            }

            try
            {
                _databaseFile = System.IO.Path.Combine(core.PluginDataPath, "ignoregc.db3");
                InitDatabase();
                using (Utils.DBCon dbcon = new Utils.DBConComSqlite(_databaseFile))
                {
                    DbDataReader dr = dbcon.ExecuteReader("select field, filter from filterfields");
                    while (dr.Read())
                    {
                        Hashtable ht = _filterFields[dr["field"]] as Hashtable;
                        if (ht != null)
                        {
                            ht.Add(dr["filter"], true);
                        }
                    }
                }
            }
            catch
            {
            }
        }
コード例 #3
0
ファイル: Presets.cs プロジェクト: RH-Code/GAPP
        public override bool Initialize(Framework.Interfaces.ICore core)
        {
            AddAction(ACTION_SAVECURRENT);
            AddAction(ACTION_SEP);
            AddAction(ACTION_SPLITSCREEN);

            core.LanguageItems.Add(new Framework.Data.LanguageItem(PresetNameForm.STR_NAME));
            core.LanguageItems.Add(new Framework.Data.LanguageItem(PresetNameForm.STR_OK));
            core.LanguageItems.Add(new Framework.Data.LanguageItem(PresetNameForm.STR_TITLE));

            core.LanguageItems.Add(new Framework.Data.LanguageItem(SettingsPanel.STR_DELETE));
            core.LanguageItems.Add(new Framework.Data.LanguageItem(SettingsPanel.STR_PRESETS));

            if (Properties.Settings.Default.UpgradeNeeded)
            {
                Properties.Settings.Default.Upgrade();
                Properties.Settings.Default.UpgradeNeeded = false;
                Properties.Settings.Default.Save();
            }

            try
            {
                _presetDatabaseFile = System.IO.Path.Combine(new string[] { core.PluginDataPath, "Presets.db3" });
            }
            catch
            {
            }

            try
            {
                if (System.IO.File.Exists(_presetDatabaseFile))
                {
                    using (Utils.DBCon dbcon = new Utils.DBConComSqlite(_presetDatabaseFile))
                    {
                        initDatabase(dbcon);
                        DbDataReader dr = dbcon.ExecuteReader("select name from preset");
                        while (dr.Read())
                        {
                            _presets.Add((string)dr["name"]);
                            AddAction(string.Concat("Presets|", (string)dr["name"]));
                        }
                    }
                }
            }
            catch
            {
            }


            return base.Initialize(core);
        }
コード例 #4
0
        private void PreLoadAreaInfo()
        {
            if (_cachedAreaInfo == null)
            {
                _cachedAreaInfo = new List <Framework.Data.AreaInfo>();

                try
                {
                    using (Utils.DBCon dbcon = new Utils.DBConComSqlite(_databaseFilename))
                    {
                        if (InitDatabase(dbcon))
                        {
                            DbDataReader dr = dbcon.ExecuteReader("select * from areainfo");
                            while (dr.Read())
                            {
                                Framework.Data.AreaInfo ai = new Framework.Data.AreaInfo();
                                ai.ID       = (int)dr["id"];
                                ai.ParentID = dr["parentid"] == DBNull.Value ? null : dr["parentid"];
                                ai.Level    = (Framework.Data.AreaType)(short)(int) dr["level"];
                                ai.Name     = (string)dr["name"];
                                ai.MinLat   = (double)dr["minlat"];
                                ai.MinLon   = (double)dr["minlon"];
                                ai.MaxLat   = (double)dr["maxlat"];
                                ai.MaxLon   = (double)dr["maxlon"];
                                _cachedAreaInfo.Add(ai);
                            }
                        }

                        object o = dbcon.ExecuteScalar("select Max(id) from areainfo");
                        if (o != null)
                        {
                            _maxAreaInfoId = (int)(long)o;
                        }
                        o = dbcon.ExecuteScalar("select Max(id) from poly");
                        if (o != null)
                        {
                            _maxPolyId = (int)(long)o;
                        }
                    }
                }
                catch
                {
                    //corrupt file
                    _cachedAreaInfo.Clear();
                }
            }
        }
コード例 #5
0
ファイル: ShortcutsSetup.cs プロジェクト: RH-Code/GAPP
        public override bool Initialize(Framework.Interfaces.ICore core)
        {
            bool result = base.Initialize(core);
            if (result)
            {
                core.LanguageItems.Add(new Framework.Data.LanguageItem(SettingsPanel.STR_CLEAR));
                core.LanguageItems.Add(new Framework.Data.LanguageItem(SettingsPanel.STR_INFO));

                try
                {
                    _shortcutDatabaseFile = System.IO.Path.Combine(core.PluginDataPath, "Shortcuts.db3" );
                }
                catch
                {
                }

                if (System.IO.File.Exists(_shortcutDatabaseFile))
                {
                    using (Utils.DBCon dbcon = new Utils.DBConComSqlite(_shortcutDatabaseFile))
                    {
                        initDatabase(dbcon);
                        DbDataReader dr = dbcon.ExecuteReader("select * from shortcut");
                        while (dr.Read())
                        {
                            core.ShortcutInfo.Add(new Framework.Data.ShortcutInfo() { PluginType = (string)dr["plugintype"], PluginAction = (string)dr["action"], PluginSubAction = (string)dr["subaction"], ShortcutKeys = (Keys)(int)dr["keys"], ShortcutKeyString = (string)dr["keystring"] });
                        }
                    }
                }
                else
                {
                    core.ShortcutInfo.AddRange(new Framework.Data.ShortcutInfo[]
                            {
                                new Framework.Data.ShortcutInfo(){PluginType="GlobalcachingApplication.Plugins.GCView.GeocacheViewer", PluginAction="View Geocache", PluginSubAction="", ShortcutKeys = Keys.F3, ShortcutKeyString = "F3" },
                                new Framework.Data.ShortcutInfo(){PluginType="GlobalcachingApplication.Plugins.GMap.GMap", PluginAction="Google Map", PluginSubAction="", ShortcutKeys = Keys.Control | Keys.M, ShortcutKeyString = "Ctrl+M" },
                                new Framework.Data.ShortcutInfo(){PluginType="GlobalcachingApplication.Plugins.FilterEx.GeocacheSearch", PluginAction="Search geocache", PluginSubAction="", ShortcutKeys = Keys.Control | Keys.F, ShortcutKeyString = "Ctrl+F" },
                                new Framework.Data.ShortcutInfo(){PluginType="GlobalcachingApplication.Plugins.TxtSearch.GeocacheTextSearch", PluginAction="Search geocache by text", PluginSubAction="", ShortcutKeys = Keys.Control | Keys.T, ShortcutKeyString = "Ctrl+T" },
                            }
                    );
                }
            }
            return result;
        }
コード例 #6
0
        public override bool Action(string action)
        {
            bool result = base.Action(action);
            if (result)
            {
                if (action == ACTION_SELECT)
                {
                    Core.Geocaches.BeginUpdate();
                    try
                    {
                        string databaseFile = System.IO.Path.Combine(new string[] { Core.PluginDataPath, "attachements.db3" });
                        if (System.IO.File.Exists(databaseFile))
                        {
                            foreach (Framework.Data.Geocache gc in Core.Geocaches)
                            {
                                gc.Selected = false;
                            }
                            Utils.DBCon dbcon = new Utils.DBConComSqlite(databaseFile);
                            DbDataReader dr = dbcon.ExecuteReader("select distinct code from attachements");
                            while (dr.Read())
                            {
                                string code = dr["code"] as string;
                                Framework.Data.Geocache gc = Utils.DataAccess.GetGeocache(Core.Geocaches, code);
                                if (gc != null)
                                {
                                    gc.Selected = true;
                                }
                            }
                        }

                    }
                    catch
                    {
                    }
                    Core.Geocaches.EndUpdate();
                }
            }
            return result;
        }
コード例 #7
0
ファイル: Presets.cs プロジェクト: RH-Code/GAPP
 private void openPreset(string presetname)
 {
     try
     {
         int pos = presetname.IndexOf('|');
         if (pos > 0)
         {
             presetname = presetname.Substring(pos + 1);
             if (_presets.Contains(presetname))
             {
                 using (Utils.DBCon dbcon = new Utils.DBConComSqlite(_presetDatabaseFile))
                 {
                     initDatabase(dbcon);
                     List<Framework.Interfaces.IPlugin> pins = Core.GetPlugins();
                     DbDataReader dr = dbcon.ExecuteReader(string.Format("select * from forms where preset='{0}'", presetname));
                     while (dr.Read())
                     {
                         Framework.Interfaces.IPluginUIChildWindow p = (from Framework.Interfaces.IPlugin a in pins where a.GetType().ToString() == (string)dr["plugintype"] select a).FirstOrDefault() as Framework.Interfaces.IPluginUIChildWindow;
                         if (p != null)
                         {
                             if ((int)dr["visible"] == 0)
                             {
                                 if (p.ChildForm != null && p.ChildForm.Visible)
                                 {
                                     p.ChildForm.Hide();
                                 }
                             }
                             else
                             {
                                 if (p.ChildForm == null || !p.ChildForm.Visible)
                                 {
                                     p.Action(p.DefaultAction);
                                 }
                                 if (p.ChildForm != null)
                                 {
                                     p.ChildForm.SetBounds((int)dr["x"], (int)dr["y"], (int)dr["w"], (int)dr["h"]);
                                 }
                             }
                         }
                         else if ((string)dr["plugintype"]=="GlobalcachingApplication.Plugins.Maps.MapsPlugin")
                         {
                             try
                             {
                                 Framework.Interfaces.IPlugin mp = Utils.PluginSupport.PluginByName(Core, "GlobalcachingApplication.Plugins.Maps.MapsPlugin");
                                 if (mp != null)
                                 {
                                     MethodInfo mi = mp.GetType().GetMethod("SetWindowStates");
                                     if (mi != null)
                                     {
                                         mi.Invoke(mp, new object[] { dr["customtag"] as string });
                                     }
                                 }
                             }
                             catch
                             {
                             }
                         }
                     }
                 }
             }
         }
     }
     catch
     {
     }
 }
コード例 #8
0
ファイル: LanguageSupport.cs プロジェクト: RH-Code/GAPP
        private void initDatabase()
        {
            string xmlFileContents;
            Assembly assembly = Assembly.GetExecutingAssembly();
            using (StreamReader textStreamReader = new StreamReader(assembly.GetManifestResourceStream("GlobalcachingApplication.Plugins.LanguageEng.LookupDictionary.xml")))
            {
                xmlFileContents = textStreamReader.ReadToEnd();
            }
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xmlFileContents);
            XmlElement root = doc.DocumentElement;
            XmlNodeList strngs = root.SelectNodes("string");
            if (strngs != null)
            {
                foreach (XmlNode sn in strngs)
                {
                    if (!string.IsNullOrEmpty(sn.Attributes["value"].InnerText))
                    {
                        _fixedLookupTable[sn.Attributes["name"].InnerText.ToLower()] = sn.Attributes["value"].InnerText;
                    }
                }
            }

            try
            {
                using (Utils.DBCon dbcon = new Utils.DBConComSqlite(_customDictionaryDatabaseFile))
                {
                    object o = dbcon.ExecuteScalar("SELECT name FROM sqlite_master WHERE type='table' AND name='translation'");
                    if (o == null || o.GetType() == typeof(DBNull))
                    {
                        dbcon.ExecuteNonQuery("create table 'translation' (item_name text, item_value text)");
                    }
                    DbDataReader dr = dbcon.ExecuteReader("select * from translation");
                    while (dr.Read())
                    {
                        _customLookupTable[dr["item_name"].ToString().ToLower()] = dr["item_value"].ToString();
                    }
                }
            }
            catch
            {
            }
        }
コード例 #9
0
ファイル: AreasPlugin.cs プロジェクト: gahadzikwa/GAPP
        private void PreLoadAreaInfo()
        {
            if (_cachedAreaInfo == null)
            {
                _cachedAreaInfo = new List<Framework.Data.AreaInfo>();

                try
                {
                    using (Utils.DBCon dbcon = new Utils.DBConComSqlite(_databaseFilename))
                    {
                        if (InitDatabase(dbcon))
                        {
                            DbDataReader dr = dbcon.ExecuteReader("select * from areainfo");
                            while (dr.Read())
                            {
                                Framework.Data.AreaInfo ai = new Framework.Data.AreaInfo();
                                ai.ID = (int)dr["id"];
                                ai.ParentID = dr["parentid"] == DBNull.Value ? null : dr["parentid"];
                                ai.Level = (Framework.Data.AreaType)(short)(int)dr["level"];
                                ai.Name = (string)dr["name"];
                                ai.MinLat = (double)dr["minlat"];
                                ai.MinLon = (double)dr["minlon"];
                                ai.MaxLat = (double)dr["maxlat"];
                                ai.MaxLon = (double)dr["maxlon"];
                                _cachedAreaInfo.Add(ai);
                            }
                        }

                        object o = dbcon.ExecuteScalar("select Max(id) from areainfo");
                        if (o != null)
                        {
                            _maxAreaInfoId = (int)(long)o;
                        }
                        o = dbcon.ExecuteScalar("select Max(id) from poly");
                        if (o != null)
                        {
                            _maxPolyId = (int)(long)o;
                        }
                    }
                }
                catch
                {
                    //corrupt file
                    _cachedAreaInfo.Clear();
                }
            }
        }
コード例 #10
0
ファイル: AreasPlugin.cs プロジェクト: gahadzikwa/GAPP
 public void GetPolygonOfArea(Framework.Data.AreaInfo area)
 {
     PreLoadAreaInfo();
     if (area.Polygons == null)
     {
         Framework.Data.AreaInfo ainf = (from ai in _cachedAreaInfo where ai.ID == area.ID select ai).FirstOrDefault();
         if (ainf!=null)
         {
             try
             {
                 area.Polygons = new List<Framework.Data.Polygon>();
                 using (Utils.DBCon dbcon = new Utils.DBConComSqlite(_databaseFilename))
                 {
                     int actPolyId = -1;
                     Framework.Data.Polygon polg = null;
                     DbDataReader dr = dbcon.ExecuteReader(string.Format("select * from poly where areainfoid={0} order by id, position", area.ID));
                     while (dr.Read())
                     {
                         int polyId = (int)dr["id"];
                         if (actPolyId != polyId)
                         {
                             polg = new Framework.Data.Polygon();
                             area.Polygons.Add(polg);
                             actPolyId = polyId;
                         }
                         polg.AddLocation(new Framework.Data.Location((double)dr["lat"], (double)dr["lon"]));
                     }
                 }
             }
             catch
             {
             }
         }
     }
 }
コード例 #11
0
ファイル: ImportPQ.cs プロジェクト: RH-Code/GAPP
 private Hashtable getProcessedPq()
 {
     Hashtable result = new Hashtable();
     if (_databaseFile != null)
     {
         try
         {
             using (Utils.DBCon dbcon = new Utils.DBConComSqlite(_databaseFile))
             {
                 initDatabase(dbcon);
                 DbDataReader dr = dbcon.ExecuteReader("select * from processedpq");
                 while (dr.Read())
                 {
                     result.Add(dr["pqname"], DateTime.Parse((string)dr["processdate"]));
                 }
             }
         }
         catch
         {
         }
     }
     return result;
 }