public Form GetForm(DocumentInfo document, string descrizione, MergeFieldType type)
        {
            var tipo = "rtf";
            switch (document.FileExtension)
            {
                case ".doc":
                    tipo = "doc";
                    break;
                case ".docx":
                    tipo = "docx";
                    break;
            }

            _documentInfo = document;

            RichTextEditorForm form;
            if (document.Body != null)
            {
                var stream = new MemoryStream(document.Body) { Position = 0 };
                form = new RichTextEditorForm(stream, tipo, type) { Text = descrizione };
            }
            else
            {
                form = new RichTextEditorForm("rtf", type);
            }
            
            form.DocumentSave += formDocumentSave;
            return form;
        }
        public void OpenFormDialog(DocumentInfo document, string descrizione, MergeFieldType type)
        {
            var tipo = "rtf";
            switch (document.FileExtension)
            {
                case ".doc":
                    tipo = "doc";
                    break;
                case ".docx":
                    tipo = "docx";
                    break;
            }

            _documentInfo = document;

            if (document.Body != null)
            {
                var stream = new MemoryStream(document.Body) { Position = 0 };
                using (var editor = new RichTextEditorForm(stream, tipo, type) { Text = descrizione })
                {
                    editor.DocumentSave += formDocumentSave; 
                    editor.ShowDialog();
                    editor.DocumentSave -= formDocumentSave;
                    editor.Close();
                    editor.Dispose();
                }

                Application.DoEvents();
            }
            else
            {
                using (var editor = new RichTextEditorForm("rtf", type))
                {
                    editor.DocumentSave += formDocumentSave;
                    editor.ShowDialog();
                    editor.DocumentSave -= formDocumentSave;
                    editor.Close();
                    editor.Dispose();
                }

                Application.DoEvents();
            }
        }