Example #1
0
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            var dlg = new Dialogs.WindowFormulaSolver();

            dlg.ShowDialog();
        }
Example #2
0
        private async void Window_Initialized(object sender, EventArgs e)
        {
            var pa = ProgressCommandLineArguments(Environment.GetCommandLineArgs());

            if (!string.IsNullOrEmpty(pa.Database))
            {
                var d = (from a in AvailableDatabases where string.Compare(a, pa.Database, true) == 0 select a).FirstOrDefault();
                if (d != null)
                {
                    Settings.Settings.Default.SelectedDatabase = d;
                }
                else
                {
                    System.Windows.MessageBox.Show(string.Format("Database '{0}' not found", pa.Database), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }

            Settings.Settings.Default.ActiveGeocacheCode = pa.GeocacheCode;

            if (!string.IsNullOrEmpty(pa.Flow))
            {
                var fl = (from a in UIControls.ActionBuilder.Manager.Instance.ActionFlows where string.Compare(a.Name, pa.Flow, true) == 0 select a).FirstOrDefault();
                if (fl != null)
                {
                    flowBuilder.ActiveActionFlow = fl;
                    await UIControls.ActionBuilder.Manager.Instance.RunActionFow(fl);

                    Close();
                }
                else
                {
                    System.Windows.MessageBox.Show(string.Format("Flow '{0}' not found", pa.Database), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    Close();
                }
            }
            else if (!string.IsNullOrEmpty(pa.Sequence))
            {
                var sq = (from a in FlowSequences.Manager.Instance.FlowSequences where string.Compare(a.Name, pa.Sequence, true) == 0 select a).FirstOrDefault();
                if (sq != null)
                {
                    ActiveFlowSequence = sq;
                    await FlowSequences.Manager.Instance.RunFowSequence(sq);

                    Close();
                }
                else
                {
                    System.Windows.MessageBox.Show(string.Format("Sequence '{0}' not found", pa.Database), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    Close();
                }
            }
            else if (!string.IsNullOrEmpty(pa.Function))
            {
                switch (pa.Function)
                {
                case "FormulaSolver":
                {
                    var dlg = new Dialogs.WindowFormulaSolver();
                    dlg.ShowDialog();
                }
                break;

                case "AddToCollection":
                {
                    var dlg = new Dialogs.WindowAddToGeocacheCollection();
                    dlg.ShowDialog();
                }
                break;

                case "OfflineOSMMapActive":
                {
                    List <GSAKWrapper.MapProviders.GeocachePoco> gcl = null;
                    double?cLat = null;
                    double?cLon = null;
                    var    fn   = System.IO.Path.Combine(Settings.Settings.Default.DatabaseFolderPath, Settings.Settings.Default.SelectedDatabase, "sqlite.db3");
                    if (System.IO.File.Exists(fn))
                    {
                        using (var tempdb = new Database.DBConSqlite(fn))
                        {
                            using (var db = new NPoco.Database(tempdb.Connection, NPoco.DatabaseType.SQLite))
                            {
                                gcl = db.Fetch <GSAKWrapper.MapProviders.GeocachePoco>("select Code, Name, CacheType, Found, IsOwner, Latitude, Longitude, kAfterLat, kAfterLon from Caches left join Corrected on Caches.Code=Corrected.kCode where Caches.Code=@0", pa.GeocacheCode);
                            }
                            if (gcl.Count > 0)
                            {
                                if (!string.IsNullOrEmpty(gcl[0].kAfterLat) && !string.IsNullOrEmpty(gcl[0].kAfterLon))
                                {
                                    cLat = double.Parse(gcl[0].kAfterLat, CultureInfo.InvariantCulture);
                                    cLon = double.Parse(gcl[0].kAfterLon, CultureInfo.InvariantCulture);
                                }
                                else
                                {
                                    cLat = double.Parse(gcl[0].Latitude, CultureInfo.InvariantCulture);
                                    cLon = double.Parse(gcl[0].Longitude, CultureInfo.InvariantCulture);
                                }
                                var wnd = new Dialogs.WindowOSMOfflineMap(gcl, cLat, cLon, 18);
                                wnd.ShowDialog();
                            }
                            else
                            {
                                System.Windows.MessageBox.Show(string.Format("Geocache '{0}' not found", pa.GeocacheCode), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                            }
                        }
                    }
                }
                break;
                }
                Close();
            }
            else
            {
#if DEBUG
                //if (Settings.Settings.Default.VersionCheckedAtDay != DateTime.Now.Day)
#else
                if (Settings.Settings.Default.VersionCheckedAtDay != DateTime.Now.Day)
#endif
                {
                    var thrd = new Thread(new ThreadStart(this.CheckForNewVersionThreadMethod));
                    thrd.IsBackground = true;
                    thrd.Start();
                }
            }
        }