Exemplo n.º 1
0
 /// <summary>
 /// Save currently selected shapes as enhanced metafile.
 /// </summary>
 /// <param name="path">The file path.</param>
 private void ExportAsEmf(string path)
 {
     try
     {
         var writer = new EmfWriter();
         writer.Save(
             path,
             _context.Editor.Project.CurrentContainer,
             _context.Editor.Project);
     }
     catch (Exception ex)
     {
         if (_context.Editor.Log != null)
         {
             _context.Editor.Log.LogError("{0}{1}{2}",
                 ex.Message,
                 Environment.NewLine,
                 ex.StackTrace);
         }
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Copy currently selected shapes to clipboard as enhanced metafile.
        /// </summary>
        private void OnCopyAsEmf()
        {
            if (_context.Editor.Project == null || _context.Editor.Project.CurrentContainer == null)
                return;

            var project = _context.Editor.Project;
            var container = _context.Editor.Project.CurrentContainer;
            var writer = new EmfWriter();

            if (_context.Editor.Renderers[0].State.SelectedShape != null)
            {
                var shapes = Enumerable.Repeat(_context.Editor.Renderers[0].State.SelectedShape, 1).ToList();
                writer.SetClipboard(
                    shapes,
                    container.Template.Width,
                    container.Template.Height,
                    container.Data.Properties,
                    project);
            }
            else if (_context.Editor.Renderers[0].State.SelectedShapes != null)
            {
                var shapes = _context.Editor.Renderers[0].State.SelectedShapes.ToList();
                writer.SetClipboard(
                    shapes,
                    container.Template.Width,
                    container.Template.Height,
                    container.Data.Properties,
                    project);
            }
            else
            {
                writer.SetClipboard(container, project);
            }
        }