コード例 #1
0
ファイル: Presets.cs プロジェクト: pheijmans-zz/GAPP
        private async Task splitScreen()
        {
            Form main = (from Framework.Interfaces.IPluginUIMainWindow a in Core.GetPlugin(Framework.PluginType.UIMainWindow) select a.MainForm).FirstOrDefault();

            if (main != null)
            {
                //get the 3 screens: cache list, geocache viewer and map
                Framework.Interfaces.IPluginUIChildWindow gclistPlugin = (from Framework.Interfaces.IPluginUIChildWindow a in Core.GetPlugin(Framework.PluginType.UIChildWindow) where a.GetType().ToString() == "GlobalcachingApplication.Plugins.SimpleCacheList.SimpleCacheList" select a).FirstOrDefault();
                Framework.Interfaces.IPluginUIChildWindow viewerPlugin = (from Framework.Interfaces.IPluginUIChildWindow a in Core.GetPlugin(Framework.PluginType.UIChildWindow) where a.GetType().ToString() == "GlobalcachingApplication.Plugins.GCView.GeocacheViewer" select a).FirstOrDefault();
                Framework.Interfaces.IPluginUIChildWindow mapPlugin    = (from Framework.Interfaces.IPluginUIChildWindow a in Core.GetPlugin(Framework.PluginType.Map) where a.GetType().ToString() == "GlobalcachingApplication.Plugins.GMap.GMap" select a).FirstOrDefault();
                if (gclistPlugin != null && viewerPlugin != null && mapPlugin != null)
                {
                    await gclistPlugin.ActionAsync(gclistPlugin.DefaultAction);

                    await viewerPlugin.ActionAsync(viewerPlugin.DefaultAction);

                    await mapPlugin.ActionAsync(mapPlugin.DefaultAction);

                    if (gclistPlugin.ChildForm != null && viewerPlugin.ChildForm != null && mapPlugin.ChildForm != null)
                    {
                        System.Drawing.Size clntSize = main.ClientSize;
                        clntSize.Height -= 80;
                        clntSize.Width  -= 20;
                        gclistPlugin.ChildForm.SetBounds(0, 0, clntSize.Width, clntSize.Height / 2);
                        viewerPlugin.ChildForm.SetBounds(0, clntSize.Height / 2, clntSize.Width / 2, clntSize.Height / 2);
                        mapPlugin.ChildForm.SetBounds(clntSize.Width / 2, clntSize.Height / 2, clntSize.Width / 2, clntSize.Height / 2);
                    }
                }
            }
        }
コード例 #2
0
ファイル: Presets.cs プロジェクト: pheijmans-zz/GAPP
 private async Task openPreset(string presetname)
 {
     try
     {
         int pos = presetname.IndexOf('|');
         if (pos > 0)
         {
             presetname = presetname.Substring(pos + 1);
             if (_presets.Contains(presetname))
             {
                 //lock (Core.SettingsProvider)
                 {
                     List <Framework.Interfaces.IPlugin> pins = Core.GetPlugins();
                     List <FormsPoco> pocos = Core.SettingsProvider.Database.Fetch <FormsPoco>(string.Format("select * from {1} where preset='{0}'", presetname.Replace("'", "''"), Core.SettingsProvider.GetFullTableName("forms")));
                     foreach (var poco in pocos)
                     {
                         Framework.Interfaces.IPluginUIChildWindow p = (from Framework.Interfaces.IPlugin a in pins where a.GetType().ToString() == poco.plugintype select a).FirstOrDefault() as Framework.Interfaces.IPluginUIChildWindow;
                         if (p != null)
                         {
                             if (poco.visible == 0)
                             {
                                 if (p.ChildForm != null && p.ChildForm.Visible)
                                 {
                                     p.ChildForm.Hide();
                                 }
                             }
                             else
                             {
                                 if (p.ChildForm == null || !p.ChildForm.Visible)
                                 {
                                     await p.ActionAsync(p.DefaultAction);
                                 }
                                 if (p.ChildForm != null)
                                 {
                                     p.ChildForm.SetBounds(poco.x, poco.y, poco.w, poco.h);
                                 }
                             }
                         }
                         else if (poco.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[] { poco.customtag });
                                     }
                                 }
                             }
                             catch
                             {
                             }
                         }
                     }
                 }
             }
         }
     }
     catch
     {
     }
 }
コード例 #3
0
ファイル: Presets.cs プロジェクト: pheijmans-zz/GAPP
        private void newPreset()
        {
            //check if saved preset
            string presetname = null;

            using (PresetNameForm dlg = new PresetNameForm(_presets))
            {
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    presetname = dlg.PresetName;
                }
            }
            if (!string.IsNullOrEmpty(presetname))
            {
                try
                {
                    lock (Core.SettingsProvider)
                    {
                        if (!_presets.Contains(presetname))
                        {
                            //we need to add the action
                            AddAction(string.Concat("Presets|", presetname));
                            Framework.Interfaces.IPluginUIMainWindow main = (from Framework.Interfaces.IPluginUIMainWindow a in Core.GetPlugin(Framework.PluginType.UIMainWindow) select a).FirstOrDefault();
                            main.AddAction(this, "Presets", presetname);

                            _presets.Add(presetname);
                        }
                        Core.SettingsProvider.Database.Execute(string.Format("delete from {1} where preset='{0}'", presetname.Replace("'", "''"), Core.SettingsProvider.GetFullTableName("forms")));
                        Core.SettingsProvider.Database.Execute(string.Format("delete from {1} where name='{0}'", presetname.Replace("'", "''"), Core.SettingsProvider.GetFullTableName("preset")));

                        Core.SettingsProvider.Database.Execute(string.Format("insert into {1} (name) values ('{0}')", presetname.Replace("'", "''"), Core.SettingsProvider.GetFullTableName("preset")));
                        List <Framework.Interfaces.IPlugin> pins = Core.GetPlugins();
                        foreach (Framework.Interfaces.IPlugin pin in pins)
                        {
                            Framework.Interfaces.IPluginUIChildWindow p = pin as Framework.Interfaces.IPluginUIChildWindow;
                            if (p != null)
                            {
                                if (p.ChildForm != null && p.ChildForm.Visible)
                                {
                                    Core.SettingsProvider.Database.Execute(string.Format("insert into {6} (preset, plugintype, x, y, w, h, visible) values ('{0}', '{1}', {2}, {3}, {4}, {5}, 1)", presetname.Replace("'", "''"), p.GetType().ToString(), p.ChildForm.Left, p.ChildForm.Top, p.ChildForm.Width, p.ChildForm.Height, Core.SettingsProvider.GetFullTableName("forms")));
                                }
                                else
                                {
                                    Core.SettingsProvider.Database.Execute(string.Format("insert into {2} (preset, plugintype, x, y, w, h, visible) values ('{0}', '{1}', 0, 0, 100, 100, 0)", presetname.Replace("'", "''"), p.GetType().ToString(), Core.SettingsProvider.GetFullTableName("forms")));
                                }
                            }
                            else if (pin.GetType().ToString() == "GlobalcachingApplication.Plugins.Maps.MapsPlugin")
                            {
                                //special onw
                                try
                                {
                                    MethodInfo mi = pin.GetType().GetMethod("GetWindowStateText");
                                    if (mi != null)
                                    {
                                        string s = mi.Invoke(pin, null) as string;
                                        if (s != null)
                                        {
                                            Core.SettingsProvider.Database.Execute(string.Format("insert into {3} (preset, plugintype, x, y, w, h, visible, customtag) values ('{0}', '{1}', 0, 0, 100, 100, 0, '{2}')", presetname.Replace("'", "''"), pin.GetType().ToString(), s.Replace("'", "''"), Core.SettingsProvider.GetFullTableName("forms")));
                                        }
                                    }
                                }
                                catch
                                {
                                }
                            }
                        }
                    }
                }
                catch
                {
                }
            }
        }