Esempio n. 1
0
 private void Aplication_CreateDefault()
 {
     //Create new document if there are now documents at this time
     if (Globals.ThisAddIn.Application.Documents.Count <= 0)
     {
         Globals.ThisAddIn.Application.Documents.Add();
     }
     WordProcessingHelper.CreateDefaultDocumentStyle(Globals.ThisAddIn.Application.ActiveDocument);
 }
        private void On_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            Debug.WriteLine("On_CellDoubleClick");
            if (e.RowIndex >= this.DGV_SplitRepresentative.Rows.Count ||
                e.RowIndex < 0)
            {
                return;
            }
            string representative_name = (string)this.DGV_SplitRepresentative.Rows[e.RowIndex].Cells["Representative_Name"].Value;
            string representative_duty = (string)this.DGV_SplitRepresentative.Rows[e.RowIndex].Cells["Representative_Duty"].Value;
            List <DocumentParagraph> representativeDocumentParagraphs = new List <DocumentParagraph>();

            foreach (DocumentParagraph para in this.mDocumentEntity.paragraphs)
            {
                if (para.belongTo != null &&
                    Utils.FormatRepresentative(para.belongTo.name, para.belongTo.duty).Equals(
                        Utils.FormatRepresentative(representative_name, representative_duty)))
                {
                    ///Generate document here
                    representativeDocumentParagraphs.Add(para);
                }
            }
            if (representativeDocumentParagraphs.Count > 0)
            {
                Word.Document newDocument = Globals.ThisAddIn.Application.Documents.Add();
                WordProcessingHelper.SaveRepresentativeDocument(AppsSettings.GetInstance().Session, newDocument, representativeDocumentParagraphs[0].belongTo.name);
                WordProcessingHelper.CreateDefaultDocumentStyle(newDocument);
                WordProcessingHelper.CreateDocumentTitle(newDocument, AppsSettings.GetInstance().Session);
                WordProcessingHelper.GenerateRepresentativeDocument(representativeDocumentParagraphs, newDocument);
                newDocument.Save();
            }
            else
            {
            }

            DialogResult = DialogResult.OK;
        }