Example #1
0
        private void SaveToFile()
        {
            var formats = new Dictionary <string, string>
            {
                ["Comma-separated files (with formatting) (*.csv)"] = "*.csv",
                ["Comma-separated files (raw data) (*.csv)"]        = "*.csv",
            };
            string filter = string.Join("|", formats.Select(kv => $"{kv.Key}|{kv.Value}"));
            var    file   = ViewManager.ShowSaveFileDialog(Text.Get("EphemeridesWindow.ExportTitle"), "Ephemerides", ".csv", filter, out int selectedFilterIndex);

            if (file != null)
            {
                IEphemeridesWriter writer = null;
                string             ext    = Path.GetExtension(file);
                switch (ext)
                {
                case ".csv":
                    writer = new EphemeridesCsvWriter(file, sky.Context.GeoLocation.UtcOffset, selectedFilterIndex == 2);
                    break;

                default:
                    break;
                }

                writer?.Write(Body, StartDate, EndDate, Step, Ephemeris);

                var answer = ViewManager.ShowMessageBox("$EphemeridesWindow.ExportDoneTitle", "$EphemeridesWindow.ExportDoneText", MessageBoxButton.YesNo);
                if (answer == MessageBoxResult.Yes)
                {
                    System.Diagnostics.Process.Start(file);
                }
            }
        }
Example #2
0
        private void SaveToFile()
        {
            var file = ViewManager.ShowSaveFileDialog(Text.Get("EphemeridesWindow.ExportTitle"), "Ephemerides", ".csv", "Comma-separated files (*.csv)|*.csv");

            if (file != null)
            {
                IEphemeridesWriter writer = null;
                string             ext    = Path.GetExtension(file);
                switch (ext)
                {
                case ".csv":
                    writer = new EphemeridesCsvWriter(file, sky.Context.GeoLocation.UtcOffset);
                    break;

                default:
                    break;
                }

                writer?.Write(Body, StartDate, EndDate, Step, Ephemeris);

                ViewManager.ShowMessageBox("$EphemeridesWindow.ExportDoneTitle", "$EphemeridesWindow.ExportDoneText", MessageBoxButton.OK);
            }
        }