示例#1
0
        private void richEditControl1_MouseClick(object sender, MouseEventArgs e)
        {
            PageLayoutPosition pageLayoutPosition = richEditControl1.ActiveView.GetDocumentLayoutPosition(e.Location);

            if (pageLayoutPosition == null)
            {
                return;
            }
            int                   pageIndex  = pageLayoutPosition.PageIndex;
            Point                 point      = pageLayoutPosition.Position;
            LayoutPage            layoutPage = richEditControl1.DocumentLayout.GetPage(pageIndex);
            HitTestManager        hitTest    = new HitTestManager(richEditControl1.DocumentLayout);
            RichEditHitTestResult result     = hitTest.HitTest(layoutPage, point);

            if (result.LayoutElement is CharacterBox && richEditControl1.Document.Selection.Length == 0)
            {
                CharacterBox     character     = (CharacterBox)result.LayoutElement;
                DocumentPosition caretPosition = richEditControl1.Document.CaretPosition;
                SubDocument      document      = caretPosition.BeginUpdateDocument();
                if (document.GetSubDocumentType() == GetLocation(character.Parent))
                {
                    DocumentRange characterRange = document.CreateRange(character.Range.Start, 1);
                    UpdateCheckState(document, characterRange, character.Text);
                }
                caretPosition.EndUpdateDocument(document);
            }
        }
示例#2
0
        public static void SetTextWatermark(RichEditControl richEditControl, string text)
        {
            Section     section     = richEditControl.Document.Sections[0];
            SubDocument subDocument = section.BeginUpdateHeader();

            subDocument.Delete(subDocument.Range);
            Shape shape = subDocument.Shapes.InsertTextBox(subDocument.Range.Start);

            shape.ShapeFormat.TextBox.Document.AppendText(text);

            CharacterProperties cp = shape.ShapeFormat.TextBox.Document.BeginUpdateCharacters(shape.ShapeFormat.TextBox.Document.Range);

            cp.FontName  = "Comic Sans MS";
            cp.FontSize  = 32;
            cp.ForeColor = Color.Red;
            Font measureFont = new Font(cp.FontName, cp.FontSize.Value);

            shape.ShapeFormat.TextBox.Document.EndUpdateCharacters(cp);

            shape.RotationAngle = -45;
            Size sizeInPixels = TextRenderer.MeasureText(text, measureFont);

            shape.Size = new SizeF(Units.PixelsToDocumentsF(sizeInPixels.Width, richEditControl.DpiX), Units.PixelsToDocumentsF(sizeInPixels.Height, richEditControl.DpiY));
            shape.ShapeFormat.TextBox.HeightRule = TextBoxSizeRule.Auto;
            shape.Offset = new PointF(section.Page.Width / 2 - shape.Size.Width / 2, section.Page.Height / 2 - shape.Size.Height / 2);
            section.EndUpdateHeader(subDocument);
        }
示例#3
0
        void AddFooterToDocument(DevExpress.XtraRichEdit.API.Native.Document document, string htmlText)
        {
            SubDocument doc = document.Sections[0].BeginUpdateFooter();

            doc.AppendHtmlText(htmlText);
            document.Sections[0].EndUpdateFooter(doc);
        }
示例#4
0
        static void ModifyFieldCode(Document document)
        {
            #region #ModifyFieldCode
            DocumentPosition caretPosition   = document.CaretPosition;
            SubDocument      currentDocument = caretPosition.BeginUpdateDocument();

            //Create a DATE field at the caret position
            currentDocument.Fields.Create(caretPosition, "DATE");
            currentDocument.EndUpdate();

            for (int i = 0; i < currentDocument.Fields.Count; i++)
            {
                string fieldCode = document.GetText(currentDocument.Fields[i].CodeRange);
                if (fieldCode == "DATE")
                {
                    //Retrieve the range obtained by the field code
                    DocumentPosition position = currentDocument.Fields[i].CodeRange.End;

                    //Insert the format switch to the end of the field code range
                    currentDocument.InsertText(position, @"\@ ""M/d/yyyy h:mm am/pm""");
                }
            }

            //Update all document fields
            currentDocument.Fields.Update();
            #endregion #ModifyFieldCode
        }
        void InsertRowNumber(TableRow row, int rowNumber)
        {
            SubDocument   doc   = row.FirstCell.Range.BeginUpdateDocument();
            DocumentRange range = doc.InsertText(row.FirstCell.Range.Start, String.Format("{0}", rowNumber + 2));

            range.EndUpdateDocument(doc);
        }
        private void EditComment()
        {
            #region #EditCommentContent
            Document document = richEditControl.Document;

            int commentCount = document.Comments.Count;
            if (commentCount > 0)
            {
                //The target comment is the first one
                Comment comment = document.Comments[0];
                if (comment != null)
                {
                    //Open the comment for modification
                    SubDocument commentDocument = comment.BeginUpdate();

                    //Add text to the comment range
                    commentDocument.InsertText(commentDocument.CreatePosition(0),
                                               "J. Taylor, Enabling Voice - over - IP and RAID with sofa,  in Proceedings of NOSSDAV, Oct. 1994.\r\n" +
                                               @"R.Tarjan, S.Shenker, J.Gray, A.Einstein, Q.Thomas, and X.Sato, ""Deconstructing operating systems with flanchedripper"", in Proceedings of INFOCOM, Mar. 2000.");

                    //End the comment update
                    comment.EndUpdate(commentDocument);
                }
            }
            #endregion #EditCommentContent
        }
 private void CreateNewIterator()
 {
     layoutIterator = new LayoutIterator(richEditControl1.DocumentLayout);
     doc            = richEditControl1.Document;
     UpdateInfoAndSelection();
     MessageBox.Show("Layout is modified, creating a new iterator.");
 }
示例#8
0
        static void EditSeparator(Document document)
        {
            #region #EditSeparator
            document.LoadDocument("Documents//Grimm.docx");

            //Check whether the footnotes already have a separator:
            if (document.Footnotes.HasSeparator(NoteSeparatorType.Separator))
            {
                //Initiate the update session:
                SubDocument noteSeparator = document.Footnotes.BeginUpdateSeparator(NoteSeparatorType.Separator);

                //Clear the separator range:
                noteSeparator.Delete(noteSeparator.Range);

                //Append a new text:
                noteSeparator.AppendText("***");

                CharacterProperties characterProperties = noteSeparator.BeginUpdateCharacters(noteSeparator.Range);
                characterProperties.ForeColor = System.Drawing.Color.Blue;
                noteSeparator.EndUpdateCharacters(characterProperties);

                //Finalize the update:
                document.Footnotes.EndUpdateSeparator(noteSeparator);
            }
            #endregion #EditSeparator
        }
        public void AddImageWatermark(object sender, EventArgs e)
        {
            Image watermarkImage = null;

            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Title  = "Select Image";
            dlg.Filter = "image files (*.png)|*.png";

            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                watermarkImage = Image.FromFile(dlg.FileName);
            }
            dlg.Dispose();
            if (watermarkImage == null)
            {
                return;
            }

            Section     currentSection = GetCurrentSection();
            SubDocument subDocument    = currentSection.BeginUpdateHeader();

            subDocument.Delete(subDocument.Range);
            Shape shape = subDocument.Shapes.InsertPicture(subDocument.Range.Start, watermarkImage);

            shape.RotationAngle = -45;
            shape.Offset        = new PointF(Convert.ToInt64(currentSection.Page.Width) / 2 - Convert.ToInt64(shape.Size.Width) / 2, Convert.ToInt64(currentSection.Page.Height) / 2 - Convert.ToInt64(shape.Size.Height) / 2);
            currentSection.EndUpdateHeader(subDocument);
        }
        public Form1()
        {
            InitializeComponent();

            // Fill first section with text
            for (int i = 0; i < 5; i++)
            {
                richEditControl1.Document.AppendText(StringSample.SampleText);
            }

            // Add a header to the document
            Section     firstSection = richEditControl1.Document.Sections[0];
            SubDocument doc          = firstSection.BeginUpdateHeader();

            doc.InsertText(doc.CreatePosition(doc.Range.End.ToInt()), "Default Header");
            firstSection.EndUpdateHeader(doc);

            // Add a new section with a separate header
            richEditControl1.Document.AppendSection();

            Section newSection = richEditControl1.Document.Sections[richEditControl1.Document.Sections.Count - 1];

            newSection.UnlinkHeaderFromPrevious();

            doc = newSection.BeginUpdateHeader();
            doc.Replace(doc.Range, "Non-Default Header");
            newSection.EndUpdateHeader(doc);

            richEditControl1.Document.AppendText(StringSample.SampleText);
        }
示例#11
0
    //public DxDoc(DxChartFactory factory, string projtitle, string datafile, string netid)
    //{
    //	_creator_netid = netid;
    //	//Document doc = new DevExpress.XtraRichEdit.API.Native.Document();
    //}



    //public DxDoc(List<DxChartOrder> ordersC, string path, string projtitle, string datafile, string netid)
    //{
    //	_creator_netid = netid;
    //	_temppath = path;
    //	_projtitle = projtitle;
    //	_datafile = datafile;
    //	_filename = "test.docx"; // filename;

    //	MakeDocx(ordersC);

    //	//Document doc = new DevExpress.XtraRichEdit.API.Native.Document();
    //}



    //public DxDoc(DataTable dt_plots, List<string> htmltables, string path, string filename, string projtitle, string datafile, string netid)
    //{
    //	_creator_netid = netid;
    //	_temppath = path;
    //	_projtitle = projtitle;
    //	_datafile = datafile;
    //	_filename = filename;

    //	MakeDocx(dt_plots, htmltables);

    //	//Document doc = new DevExpress.XtraRichEdit.API.Native.Document();
    //}

    //public DxDoc(DataTable dt_plots, DataTable dt_tables, string path, string filename, string projtitle, string datafile, string netid)
    //{
    //	_creator_netid = netid;
    //	_temppath = path;
    //	_projtitle = projtitle;
    //	_datafile = datafile;
    //	_filename = filename;

    //	MakeDocx(dt_plots, dt_tables);

    //	//Document doc = new DevExpress.XtraRichEdit.API.Native.Document();
    //}
    #endregion


    protected void DocxHeader(DevExpress.XtraRichEdit.API.Native.Document doc, string s1, string s2)
    {
        DevExpress.XtraRichEdit.API.Native.Section firstSection = doc.Sections[0];
        // Create an empty header.
        SubDocument newHeader = firstSection.BeginUpdateHeader();

        firstSection.EndUpdateHeader(newHeader);
        // Check whether the document already has a header (the same header for all pages).
        if (firstSection.HasHeader(DevExpress.XtraRichEdit.API.Native.HeaderFooterType.Primary))
        {
            SubDocument myHeader = firstSection.BeginUpdateHeader();
            doc.ChangeActiveDocument(myHeader);
            doc.CaretPosition = myHeader.CreatePosition(0);

            string        txt   = String.Format("{0}     p.", s1);
            DocumentRange range = myHeader.InsertText(myHeader.CreatePosition(0), txt);
            Field         fld   = myHeader.Fields.Create(range.End, "PAGE");   //  "PAGE \\* ARABICDASH");
            myHeader.Fields.Update();

            myHeader.Paragraphs.Append();
            string user_time = String.Format("{0}     {1:MM/dd/yy H:mm}", _creator_netid, System.DateTime.Now);
            myHeader.AppendText(String.Format("{0}                             {1}", s2, user_time));


            firstSection.EndUpdateHeader(myHeader);
        }
    }
示例#12
0
        private static void ProcessSection(Section section, HeaderFooterType headerFooterType, SubDocumentDelegate subDocumentProcessor)
        {
            if (section.HasHeader(headerFooterType))
            {
                SubDocument header = section.BeginUpdateHeader(headerFooterType);
                try
                {
                    subDocumentProcessor(header);
                    ProcessShapes(header.Shapes, subDocumentProcessor);
                }
                finally
                {
                    section.EndUpdateHeader(header);
                }
            }

            if (section.HasFooter(headerFooterType))
            {
                SubDocument footer = section.BeginUpdateFooter(headerFooterType);
                try
                {
                    subDocumentProcessor(footer);
                    ProcessShapes(footer.Shapes, subDocumentProcessor);
                }
                finally
                {
                    section.EndUpdateFooter(footer);
                }
            }
        }
示例#13
0
        static void EditEndnote(Document document)
        {
            #region #EditEndnote
            document.LoadDocument("Documents//Grimm.docx");

            //Access the first endnote's content:
            SubDocument endnote = document.Endnotes[0].BeginUpdate();

            //Exclude the reference mark and the space after it from the range to be edited:
            DocumentRange noteTextRange = endnote.CreateRange(endnote.Range.Start.ToInt() + 2, endnote.Range.Length
                                                              - 2);

            //Access the range's character properties:
            CharacterProperties characterProperties = endnote.BeginUpdateCharacters(noteTextRange);

            characterProperties.ForeColor = System.Drawing.Color.Red;
            characterProperties.Italic    = true;

            //Finalize the character options update:
            endnote.EndUpdateCharacters(characterProperties);

            //Finalize the endnote update:
            document.Endnotes[0].EndUpdate(endnote);
            #endregion #EditEndnote
        }
        public static string GetInformationAboutRichEditDocumentLayout(Document currentDocument, DocumentLayout currentDocumentLayout)
        {
            SubDocument      subDocument = currentDocument.CaretPosition.BeginUpdateDocument();
            DocumentPosition docPosition = subDocument.CreatePosition(currentDocument.CaretPosition.ToInt() == 0 ? 0 : currentDocument.CaretPosition.ToInt() - 1);

            ReadOnlyShapeCollection         shapes = subDocument.Shapes.Get(subDocument.CreateRange(docPosition, 1));
            ReadOnlyDocumentImageCollection images = subDocument.Images.Get(subDocument.CreateRange(docPosition, 1));

            if (shapes.Count == 0 && images.Count == 0)
            {
                docPosition = subDocument.CreatePosition(currentDocument.CaretPosition.ToInt());
            }

            string returnedInformation = "";

            // get infromation about a current document element
            returnedInformation += GetInformationAboutCurrentDocumentElement(currentDocument, currentDocumentLayout, subDocument, docPosition);

            // collect information about CURRENT PAGE
            RangedLayoutElement layoutPosition = currentDocumentLayout.GetElement <RangedLayoutElement>(docPosition);

            if (layoutPosition != null)
            {
                int currentPageIndex = currentDocumentLayout.GetPageIndex(layoutPosition);
                returnedInformation += PageLayoutHelper.GetInformationAboutCurrentPage(currentDocumentLayout, currentDocumentLayout.GetPage(currentPageIndex), docPosition);
            }

            currentDocument.CaretPosition.EndUpdateDocument(subDocument);

            return(returnedInformation);
        }
        public void RemoveImageWatermark(object sender, EventArgs e)
        {
            Section     currentSection = GetCurrentSection();
            SubDocument subDocument    = currentSection.BeginUpdateHeader();

            subDocument.Delete(subDocument.Range);
            currentSection.EndUpdateHeader(subDocument);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Section     section = richEditControl1.Document.Sections[0];
            SubDocument subdoc  = section.BeginUpdateHeader();

            subdoc.Tables.Create(subdoc.Range.End, 2, 3, AutoFitBehaviorType.AutoFitToWindow);
            section.EndUpdateHeader(subdoc);
        }
        private void SetTestHeaderContent()
        {
            Section     firstSection = richEditControl1.Document.Sections[0];
            SubDocument doc          = firstSection.BeginUpdateHeader(HeaderFooterType.Odd);

            doc.InsertText(doc.Range.Start, "Page header");
            richEditControl1.Document.Sections[0].EndUpdateHeader(doc);
        }
        private void SaveSelectedRange()
        {
            DocumentRange selection   = richEditControl.Document.Selection;
            SubDocument   subDocument = selection.BeginUpdateDocument();

            sourceSelectedRange = subDocument.CreateRange(selection.Start, richEditControl.Document.Selection.Length);
            selection.EndUpdateDocument(subDocument);
        }
            public static void MakeMultiplicationCell(TableCell cell, int i, int j)
            {
                SubDocument doc = cell.Range.BeginUpdateDocument();

                doc.InsertText(cell.Range.Start,
                               String.Format("{0}*{1} = {2}", i + 2, j + 2, (i + 2) * (j + 2)));
                cell.Range.EndUpdateDocument(doc);
            }
        void ResetRange(DocumentRange r)
        {
            SubDocument         d  = r.BeginUpdateDocument();
            CharacterProperties cp = d.BeginUpdateCharacters(r);

            cp.BackColor = System.Drawing.Color.White;
            d.EndUpdateCharacters(cp);
            r.EndUpdateDocument(d);
        }
示例#21
0
 static void InsertTextAtCaretPosition(Document document)
 {
     #region #InsertTextAtCaretPosition
     DocumentPosition pos = document.CaretPosition;
     SubDocument      doc = pos.BeginUpdateDocument();
     doc.InsertText(pos, " INSERTED TEXT ");
     pos.EndUpdateDocument(doc);
     #endregion #InsertTextAtCaretPosition
 }
示例#22
0
        public static DocumentRange InsertField(SubDocument document, DocumentPosition start, TemplateItem foundField)
        {
            if (foundField != null)
            {
                return(BuildBarcode(document, start, foundField));
            }

            return(document.InsertText(start, string.Empty));
        }
 private void btnInsertText_Click(object sender, EventArgs e)
 {
     #region #InsertText
     DocumentPosition pos = richEditControl1.Document.CaretPosition;
     SubDocument      doc = pos.BeginUpdateDocument();
     doc.InsertText(pos, " INSERTED TEXT ");
     pos.EndUpdateDocument(doc);
     #endregion #InsertText
 }
 private static void ProcessComments(CommentCollection comments, SubDocumentDelegate subDocumentProcessor)
 {
     foreach (Comment comment in comments)
     {
         SubDocument commentSubDocument = comment.BeginUpdate();
         subDocumentProcessor(commentSubDocument);
         comment.EndUpdate(commentSubDocument);
     }
 }
示例#25
0
        private static DocumentRange BuildBarcode(SubDocument document, DocumentPosition start, TemplateItem foundFeld)
        {
            if (!string.IsNullOrEmpty(foundFeld.Code))
            {
                using (var barCode = new BarCode())
                {
                    barCode.Symbology = Symbology.Code128;
                    barCode.Options.Code128.Charset      = Code128CharacterSet.CharsetAuto;
                    barCode.Options.Code128.ShowCodeText = false;
                    barCode.Unit = GraphicsUnit.Point;

                    barCode.CodeText       = foundFeld.Code;
                    barCode.CodeBinaryData = Encoding.UTF8.GetBytes(barCode.CodeText);

                    barCode.BackColor = Color.White;
                    barCode.ForeColor = Color.Black;

                    if (foundFeld.BarCodeHeight.HasValue)
                    {
                        barCode.ImageHeight = foundFeld.BarCodeHeight.Value;
                    }
                    if (foundFeld.BarCodeWidth.HasValue)
                    {
                        barCode.ImageWidth = foundFeld.BarCodeWidth.Value;
                    }
                    if (foundFeld.BarCodeRotation.HasValue)
                    {
                        barCode.RotationAngle = foundFeld.BarCodeRotation.Value;
                    }
                    if (foundFeld.BarCodeAutoScale.HasValue)
                    {
                        barCode.AutoSize = foundFeld.BarCodeAutoScale.Value;
                    }

                    barCode.DpiY = foundFeld.BarCodeDpiY;
                    barCode.DpiX = foundFeld.BarCodeDpiX;

                    barCode.Module = foundFeld.Module.HasValue ? foundFeld.Module.Value : 1f;

                    var img = document.Images.Insert(start, barCode.BarCodeImage);

                    if (foundFeld.BarCodeScaleY.HasValue)
                    {
                        img.ScaleY = foundFeld.BarCodeScaleY.Value;
                    }

                    if (foundFeld.BarCodeScaleX.HasValue)
                    {
                        img.ScaleX = foundFeld.BarCodeScaleX.Value;
                    }

                    return(img.Range);
                }
            }
            return(document.InsertText(start, string.Empty));
        }
示例#26
0
 public void UpdateCheckState(SubDocument document, DocumentRange range, string prevState)
 {
     if (prevState.Equals(checkedCheckBox))
     {
         document.Replace(range, uncheckedCheckBox);
     }
     else if (prevState.Equals(uncheckedCheckBox))
     {
         document.Replace(range, checkedCheckBox);
     }
 }
示例#27
0
        private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            DocumentPosition    caretPosition = richEditControl1.Document.CaretPosition;
            SubDocument         document      = caretPosition.BeginUpdateDocument();
            DocumentRange       checkBox      = document.InsertText(caretPosition, uncheckedCheckBox);
            CharacterProperties cp            = document.BeginUpdateCharacters(checkBox);

            cp.FontName = "MS Gothic";
            document.EndUpdateCharacters(cp);
            caretPosition.EndUpdateDocument(document);
        }
 private void btnAppendToParagraph_Click(object sender, EventArgs e)
 {
     #region #AppendToParagraph
     DocumentPosition pos    = richEditControl1.Document.CaretPosition;
     SubDocument      doc    = pos.BeginUpdateDocument();
     Paragraph        par    = doc.Paragraphs.Get(pos);
     DocumentPosition newPos = doc.CreatePosition(par.Range.End.ToInt() - 1);
     doc.InsertText(newPos, "<<Appended to the End>>");
     pos.EndUpdateDocument(doc);
     #endregion #AppendToParagraph
 }
示例#29
0
        // Create New Invoice
        public void InvoiceCreate(string OrderID)
        {
            MemoryStream rtfStream = new MemoryStream();
            MemoryStream pdfStream = new MemoryStream();

            RichEditDocumentServer docServer = new RichEditDocumentServer();

            docServer.Document.LoadDocument(Server.MapPath("~/App_Data/WorkDirectory/Invoice.rtf"), DocumentFormat.Rtf);

            // Rtf file
            Document rtf = docServer.Document;

            // Customer's Data
            var arrayCustomer = SelectOrder(OrderID);

            var arrayOrderDetail = SelectOrderDetails(OrderID);

            // Replace Header String
            SubDocument header = docServer.Document.Sections[0].BeginUpdateHeader();

            header.ReplaceAll("#invoiceid", arrayCustomer[7].ToString(), SearchOptions.WholeWord);

            // Replace Fields
            rtf.ReplaceAll("#orderid", arrayCustomer[0].ToString(), SearchOptions.WholeWord);
            rtf.ReplaceAll("#customerid", arrayCustomer[1].ToString(), SearchOptions.WholeWord);
            rtf.ReplaceAll("#date", Convert.ToDateTime(arrayCustomer[2]).ToShortDateString(), SearchOptions.WholeWord);
            rtf.ReplaceAll("#customer", arrayCustomer[3].ToString(), SearchOptions.WholeWord);
            rtf.ReplaceAll("#address", arrayCustomer[4].ToString().Trim(), SearchOptions.WholeWord);
            rtf.ReplaceAll("#email", arrayCustomer[5].ToString().Trim(), SearchOptions.WholeWord);
            rtf.ReplaceAll("#phone", arrayCustomer[6].ToString(), SearchOptions.WholeWord);

            docServer.SaveDocument(rtfStream, DocumentFormat.Rtf);
            docServer.ExportToPdf(pdfStream);

            using (SqlConnection con = new SqlConnection(conStr))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.Connection  = con;

                    cmd.CommandText = @"insert into Invoices (OrderID, InvoiceRtf, InvoicePdf) 
                                        values (@OrderID, @InvoiceRtf, @InvoicePdf)";

                    cmd.Parameters.AddWithValue("@OrderID", OrderID);
                    cmd.Parameters.AddWithValue("@InvoiceRtf", SqlDbType.VarBinary).Value = rtfStream.ToArray();
                    cmd.Parameters.AddWithValue("@InvoicePdf", SqlDbType.VarBinary).Value = pdfStream.ToArray();

                    con.Open();
                    cmd.ExecuteNonQuery();
                    con.Close();
                }
            }
        }
 private void StyleComments(Document document)
 {
     for (int i = 0; i < document.Comments.Count; i++)
     {
         SubDocument commentDocument = document.Comments[i].BeginUpdate();
         for (int j = 0; j < commentDocument.Paragraphs.Count; j++)
         {
             commentDocument.Paragraphs[j].Style = document.ParagraphStyles["Balloon Text"];
         }
         document.Comments[i].EndUpdate(commentDocument);
     }
 }
        public void SetElement_IsDirty()
        {
            // Arrange

            var collection = new DocumentCollection<SubDocument>
            {
                new SubDocument()
            };

            collection.ClearStatus();

            // Act

            collection[0] = new SubDocument();

            var result = collection.IsDirty;

            // Assert

            Assert.IsTrue(result);
        }