Example #1
0
        /// <inheritdoc/>
        async Task IEditorApplication.OnImportXamlAsync(string path)
        {
            if (path == null)
            {
                var dlg = new OpenFileDialog()
                {
                    Filter      = "Xaml (*.xaml)|*.xaml|All (*.*)|*.*",
                    FilterIndex = 0,
                    Multiselect = true,
                    FileName    = ""
                };

                if (dlg.ShowDialog(_mainWindow) == true)
                {
                    var results = dlg.FileNames;

                    foreach (var result in results)
                    {
                        _editor?.OnImportXaml(result);
                    }
                }
            }
            else
            {
                if (System.IO.File.Exists(path))
                {
                    _editor?.OnImportXaml(path);
                }
            }

            await Task.Delay(0);
        }
Example #2
0
        /// <inheritdoc/>
        async Task IEditorApplication.OnImportXamlAsync(string path)
        {
            try
            {
                if (path == null)
                {
                    var dlg = new OpenFileDialog();
                    dlg.AllowMultiple = true;
                    dlg.Filters.Add(new FileDialogFilter()
                    {
                        Name = "Xaml", Extensions = { "xaml" }
                    });
                    dlg.Filters.Add(new FileDialogFilter()
                    {
                        Name = "All", Extensions = { "*" }
                    });

                    var results = await dlg.ShowAsync(_mainWindow);

                    if (results != null)
                    {
                        foreach (var result in results)
                        {
                            _editor?.OnImportXaml(result);
                        }
                    }
                }
                else
                {
                    if (_fileIO.Exists(path))
                    {
                        _editor?.OnImportXaml(path);
                    }
                }
            }
            catch (Exception ex)
            {
                _log?.LogError($"{ex.Message}{Environment.NewLine}{ex.StackTrace}");
            }
        }