Example #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        private async Task OnExportData()
        {
            if (_context.Editor.Project != null && _context.Editor.Project.CurrentDatabase != null)
            {
                var database = _context.Editor.Project.CurrentDatabase;

                var dlg = new SaveFileDialog();
                dlg.Filters.Add(new FileDialogFilter() { Name = "Csv", Extensions = { "csv" } });
                dlg.Filters.Add(new FileDialogFilter() { Name = "All", Extensions = { "*" } });
                dlg.InitialFileName = database.Name;
                var result = await dlg.ShowAsync(this);
                if (result != null)
                {
                    _context.ExportData(result, database);
                }
            }
        }
Example #2
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="item"></param>
 /// <param name="type"></param>
 private async Task OnExportObject(object item, ExportType type)
 {
     if (item != null)
     {
         string initial = string.Empty;
         string name = string.Empty;
         string ext = string.Empty;
         
         switch (type)
         {
             case ExportType.Style:
                 name = "Style";
                 ext = "style";
                 initial = (item as ShapeStyle).Name;
                 break;
             case ExportType.Styles:
                 name = "Styles";
                 ext = "styles";
                 initial = (item as StyleLibrary).Name;
                 break;
             case ExportType.StyleLibrary:
                 name = "StyleLibrary";
                 ext = "stylelibrary";
                 initial = (item as StyleLibrary).Name;
                 break;
             case ExportType.StyleLibraries:
                 name = "StyleLibraries";
                 ext = "stylelibraries";
                 initial = (item as Project).Name;
                 break;
             case ExportType.Group:
                 name = "Group";
                 ext = "group";
                 initial = (item as XGroup).Name;
                 break;
             case ExportType.Groups:
                 name = "Groups";
                 ext = "groups";
                 initial = (item as GroupLibrary).Name;
                 break;
             case ExportType.GroupLibrary:
                 name = "GroupLibrary";
                 ext = "grouplibrary";
                 initial = (item as GroupLibrary).Name;
                 break;
             case ExportType.GroupLibraries:
                 name = "GroupLibraries";
                 ext = "grouplibraries";
                 initial = (item as Project).Name;
                 break;
             case ExportType.Template:
                 name = "Template";
                 ext = "template";
                 initial = (item as Container).Name;
                 break;
             case ExportType.Templates:
                 name = "Templates";
                 ext = "templates";
                 initial = (item as Project).Name;
                 break;
         }
         
         var dlg = new SaveFileDialog();
         dlg.Filters.Add(new FileDialogFilter() { Name = name, Extensions = { ext } });
         dlg.Filters.Add(new FileDialogFilter() { Name = "All", Extensions = { "*" } });
         dlg.InitialFileName = initial;
         var result = await dlg.ShowAsync(this);
         if (result != null)
         {
             _context.ExportObject(result, item, type);
         }
     }
 }
Example #3
0
     /// <summary>
     /// 
     /// </summary>
     /// <returns></returns>
     private async Task OnExport()
     {
         if (_context.Editor.Project != null)
         {
             var dlg = new SaveFileDialog();
             dlg.Filters.Add(new FileDialogFilter() { Name = "Pdf", Extensions = { "pdf" } });
             dlg.Filters.Add(new FileDialogFilter() { Name = "Dxf", Extensions = { "dxf" } });
             dlg.Filters.Add(new FileDialogFilter() { Name = "All", Extensions = { "*" } });
             dlg.InitialFileName = _context.Editor.Project.Name;
             var result = await dlg.ShowAsync(this);
             if (result != null)
             {
                 var ext = System.IO.Path.GetExtension(result).ToLower();
 
                 if (ext == ".pdf")
                 {
                     _context.ExportAsPdf(result, _context.Editor.Project);
                     Process.Start(result);
                 }
 
                 if (ext == ".dxf")
                 {
                     _context.ExportAsDxf(result);
                     Process.Start(result);
                 }
             }
         }
     }
Example #4
0
 /// <summary>
 /// 
 /// </summary>
 /// <returns></returns>
 private async Task OnSaveAs()
 {
     if (_context.Editor.Project != null)
     {
         var dlg = new SaveFileDialog();
         dlg.Filters.Add(new FileDialogFilter() { Name = "Project", Extensions = { "project" } });
         dlg.Filters.Add(new FileDialogFilter() { Name = "All", Extensions = { "*" } });
         dlg.InitialFileName = _context.Editor.Project.Name;
         var result = await dlg.ShowAsync(this);
         if (result != null)
         {
             _context.Save(result);
         }
     }
 }
Example #5
0
        /// <summary>
        /// Export item object to external file.
        /// </summary>
        /// <param name="item">The item object to export.</param>
        /// <param name="type">The type of item object.</param>
        /// <returns>The await <see cref="Task"/>.</returns>
        private async Task OnExportObject(object item, ExportType type)
        {
            try
            {
                if (item != null)
                {
                    string initial = string.Empty;
                    string name = string.Empty;
                    string ext = string.Empty;

                    switch (type)
                    {
                        case ExportType.Style:
                            name = "Style";
                            ext = "style";
                            initial = (item as ShapeStyle).Name;
                            break;
                        case ExportType.Styles:
                            name = "Styles";
                            ext = "styles";
                            initial = (item as StyleLibrary).Name;
                            break;
                        case ExportType.StyleLibrary:
                            name = "StyleLibrary";
                            ext = "stylelibrary";
                            initial = (item as StyleLibrary).Name;
                            break;
                        case ExportType.StyleLibraries:
                            name = "StyleLibraries";
                            ext = "stylelibraries";
                            initial = (item as Project).Name;
                            break;
                        case ExportType.Group:
                            name = "Group";
                            ext = "group";
                            initial = (item as XGroup).Name;
                            break;
                        case ExportType.Groups:
                            name = "Groups";
                            ext = "groups";
                            initial = (item as GroupLibrary).Name;
                            break;
                        case ExportType.GroupLibrary:
                            name = "GroupLibrary";
                            ext = "grouplibrary";
                            initial = (item as GroupLibrary).Name;
                            break;
                        case ExportType.GroupLibraries:
                            name = "GroupLibraries";
                            ext = "grouplibraries";
                            initial = (item as Project).Name;
                            break;
                        case ExportType.Template:
                            name = "Template";
                            ext = "template";
                            initial = (item as Container).Name;
                            break;
                        case ExportType.Templates:
                            name = "Templates";
                            ext = "templates";
                            initial = (item as Project).Name;
                            break;
                    }

                    var dlg = new SaveFileDialog();
                    dlg.Filters.Add(new FileDialogFilter() { Name = name, Extensions = { ext } });
                    dlg.Filters.Add(new FileDialogFilter() { Name = "All", Extensions = { "*" } });
                    dlg.InitialFileName = initial;
                    var result = await dlg.ShowAsync(_mainWindow);
                    if (result != null)
                    {
                        _context.ExportObject(result, item, type);
                    }
                }
            }
            catch (Exception ex)
            {
                if (_context.Editor.Log != null)
                {
                    _context.Editor.Log.LogError("{0}{1}{2}",
                        ex.Message,
                        Environment.NewLine,
                        ex.StackTrace);
                }
            }
        }
Example #6
0
        /// <summary>
        /// Export records to external file.
        /// </summary>
        /// <returns>The await <see cref="Task"/>.</returns>
        private async Task OnExportData()
        {
            try
            {
                if (_context.Editor.Project != null && _context.Editor.Project.CurrentDatabase != null)
                {
                    var database = _context.Editor.Project.CurrentDatabase;

                    var dlg = new SaveFileDialog();
                    dlg.Filters.Add(new FileDialogFilter() { Name = "Csv", Extensions = { "csv" } });
                    dlg.Filters.Add(new FileDialogFilter() { Name = "All", Extensions = { "*" } });
                    dlg.InitialFileName = database.Name;
                    var result = await dlg.ShowAsync(_mainWindow);
                    if (result != null)
                    {
                        _context.ExportData(result, database);
                    }
                }
            }
            catch (Exception ex)
            {
                if (_context.Editor.Log != null)
                {
                    _context.Editor.Log.LogError("{0}{1}{2}",
                        ex.Message,
                        Environment.NewLine,
                        ex.StackTrace);
                }
            }
        }
Example #7
0
        /// <summary>
        /// Export item object to external file.
        /// </summary>
        /// <param name="item">The item object to export.</param>
        /// <returns>The await <see cref="Task"/>.</returns>
        private async Task OnExport(object item)
        {
            try
            {
                string name = string.Empty;

                if (item is Container)
                {
                    name = (item as Container).Name;
                }
                else if (item is Document)
                {
                    name = (item as Document).Name;
                }
                else if (item is Project)
                {
                    name = (item as Project).Name;
                }
                else if (item is EditorContext)
                {
                    var editor = (item as EditorContext).Editor;
                    if (editor.Project == null)
                        return;

                    name = editor.Project.Name;
                    item = editor.Project;
                }
                else if (item == null)
                {
                    if (_context.Editor.Project == null)
                        return;

                    name = _context.Editor.Project.Name;
                    item = _context.Editor.Project;
                }

                var dlg = new SaveFileDialog();
                dlg.Filters.Add(new FileDialogFilter() { Name = "Pdf", Extensions = { "pdf" } });
                dlg.Filters.Add(new FileDialogFilter() { Name = "Dxf", Extensions = { "dxf" } });
                dlg.Filters.Add(new FileDialogFilter() { Name = "All", Extensions = { "*" } });
                dlg.InitialFileName = name;
                var result = await dlg.ShowAsync(_mainWindow);
                if (result != null)
                {
                    var ext = System.IO.Path.GetExtension(result).ToLower();

                    if (ext == ".pdf")
                    {
                        _context.ExportAsPdf(result, item);
                        Process.Start(result);
                    }

                    if (ext == ".dxf")
                    {
                        _context.ExportAsDxf(result);
                        Process.Start(result);
                    }
                }
            }
            catch (Exception ex)
            {
                if (_context.Editor.Log != null)
                {
                    _context.Editor.Log.LogError("{0}{1}{2}",
                        ex.Message,
                        Environment.NewLine,
                        ex.StackTrace);
                }
            }
        }