// get information about a current floating object
        public static string GetInformationAboutCurrentFloatingObject(FloatingObjectAnchorBox currentObjectAnchor, DocumentLayout currentLayout)
        {
            LayoutFloatingObject currentFloatingObject = currentObjectAnchor.FloatingObjectBox;
            string returnedInformation = "";

            if (currentFloatingObject.Type == LayoutType.FloatingPicture)
            {
                returnedInformation = "!A FLOATING PICTURE IS SELECTED!\r\n";
            }
            else if (currentFloatingObject.Type == LayoutType.TextBox)
            {
                returnedInformation = "!A TEXT BOX IS SELECTED!\r\n";
            }

            returnedInformation += String.Format("Anchor location: {0}\r\n", currentObjectAnchor.Bounds.Location);
            returnedInformation += String.Format("Object bounds: {0}\r\n", currentFloatingObject.Bounds);
            returnedInformation += String.Format("Rotation: {0}\r\n", currentFloatingObject.RotationAngle);

            if (currentFloatingObject.Type == LayoutType.TextBox)
            {
                LayoutTextBox currentTextBox = currentFloatingObject as LayoutTextBox;
                returnedInformation += String.Format("\r\n!!Content information:\r\n");
                returnedInformation += TextBoxLayoutHelper.GetInformationAboutCurrentTextBoxContent(currentTextBox, currentLayout);
            }
            else if (currentFloatingObject.Type == LayoutType.FloatingPicture)
            {
                LayoutFloatingPicture currentFloatingPicture = currentFloatingObject as LayoutFloatingPicture;
                returnedInformation += String.Format("\r\n!!Image properties:\r\n");
                returnedInformation += GetInformationAboutOfficeImage(currentFloatingPicture.Image);
            }

            return(returnedInformation);
        }
コード例 #2
0
        void TryScrollToFloatingObject(LayoutElement element)
        {
            LayoutFloatingObject layoutFloatingObject = element as LayoutFloatingObject;

            if (layoutFloatingObject == null)
            {
                layoutFloatingObject = element.GetParentByType <LayoutTextBox>();
            }
            if (layoutFloatingObject != null)
            {
                FloatingObjectAnchorBox anchor = layoutFloatingObject.AnchorBox;
                ScrollToPosition(anchor.Range.Start);
                richEdit.Document.Selection = richEdit.Document.CreateRange(anchor.Range.Start, anchor.Range.Length);
            }
        }
コード例 #3
0
        void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (!(e.Node.IsSelected) || e.Node.Tag == null)
            {
                return;
            }
            // Rebuild the tree if required.
            rebuild = true;

            richEditControl1.Document.ChangeActiveDocument(richEditControl1.Document);
            LayoutElement       element       = layoutTreeDictionary[e.Node];
            RangedLayoutElement rangedElement = element as RangedLayoutElement;

            // Select a range or scroll to a document position, according to the type of the layout element.
            if ((ContentDisplayAction)e.Node.Tag == ContentDisplayAction.ScrollTo)
            {
                LayoutPage     page            = element.GetParentByType <LayoutPage>();
                LayoutPageArea nearestPageArea = page.PageAreas[0];

                if ((element.Type == LayoutType.Header) || (element.GetParentByType <LayoutHeader>() != null))
                {
                    ScrollToPosition(nearestPageArea.Range.Start);
                }
                if ((element.Type == LayoutType.Footer) || (element.GetParentByType <LayoutFooter>() != null))
                {
                    ScrollToPosition(nearestPageArea.Range.Start + nearestPageArea.Range.Length);
                }
                LayoutFloatingObject layoutFloatingObject = element as LayoutFloatingObject;
                if (layoutFloatingObject != null)
                {
                    FloatingObjectAnchorBox anchor = layoutFloatingObject.AnchorBox;
                    ScrollToPosition(anchor.Range.Start);
                    richEditControl1.Document.Selection = richEditControl1.Document.CreateRange(anchor.Range.Start, anchor.Range.Length);
                }
                LayoutComment layoutComment = element as LayoutComment;
                if (layoutComment != null)
                {
                    Comment comment = layoutComment.GetDocumentComment();
                    ScrollToPosition(comment.Range.Start.ToInt());
                }

                LayoutTextBox textBox = element.GetParentByType <LayoutTextBox>();
                if (textBox != null)
                {
                    // Do not rebuild the tree.
                    rebuild = false;
                    ScrollToPosition(textBox.AnchorBox.Range.Start);
                    SubDocument doc = richEditControl1.DocumentLayout.BeginUpdateDocument(textBox);
                    richEditControl1.Document.ChangeActiveDocument(doc);
                    richEditControl1.Document.Selection = doc.CreateRange(rangedElement.Range.Start, rangedElement.Range.Length);
                    richEditControl1.DocumentLayout.EndUpdateDocument(doc);
                }
            }
            else
            {
                if (rangedElement == null)
                {
                    return;
                }
                ScrollToPosition(rangedElement.Range.Start);
                richEditControl1.Document.Selection = richEditControl1.Document.CreateRange(rangedElement.Range.Start, rangedElement.Range.Length);
            }
        }