예제 #1
0
        void ExecuteExport()
        {
            InteractiveContext.Current.SaveLocalSettings("ExportViewportHlr", Settings);

            var exchangers = ExchangeRegistry.EnumerateExchanger <IDrawingExporter>()?.ToArray();

            if (exchangers == null || exchangers.Length == 0)
            {
                return;
            }

            // Create Filter
            var filter = string.Join("|",
                                     exchangers.Select(exchanger =>
            {
                var extensions = string.Join(";", exchanger.Extensions.Select(s => "*." + s));
                return(string.Format("{0} ({1})|{1}", exchanger.Description, extensions));
            }));

            // Execute Dialog
            var dlg = new SaveFileDialog()
            {
                CheckPathExists = true,
                OverwritePrompt = true,
                Filter          = filter,
                FilterIndex     = _LastFilterIndex
            };
            var result = dlg.ShowDialog(Application.Current.MainWindow) ?? false;

            DialogResult = true;
            if (result)
            {
                var exporter = exchangers[dlg.FilterIndex - 1];
                _LastFilterIndex = dlg.FilterIndex;

                if (!ExchangerSettings.Execute <IDrawingExporter>(exporter))
                {
                    return;
                }

                using (new ProcessingScope(null, "Exporting Line Drawing"))
                {
                    if (!DoExport(dlg.FileName, exporter))
                    {
                        MessageBox.Show(Application.Current.MainWindow, "The export was not successfull. Please see message log for further information about the error.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }
        }
예제 #2
0
        public static bool Execute <T>(IExchanger exchanger) where T : IExchanger
        {
            ExchangeRegistry.LoadSettings();

            var panel = ExchangeRegistry.FindExchangerSettingsPanel(exchanger)?.CreatePanel <T>(exchanger);

            if (panel == null)
            {
                return(true); // No settings available
            }
            var exchangerSettings = new ExchangerSettings(exchanger, panel);

            if (!exchangerSettings.ShowDialog())
            {
                return(false);
            }

            ExchangeRegistry.SaveSettings();

            return(true);
        }