コード例 #1
0
        internal void AddSelectedObject(AnnObjectTreeNode node)
        {
            node.IsSelected = true;
            node.Invalidate();
            SelectedItems.Add(node);
            AnnObjectCollection annObjects = new AnnObjectCollection();

            foreach (AnnObjectTreeNode item in SelectedItems)
            {
                annObjects.Add(item.AnnObject);
            }
            if (_imageViewer != null && _automation != null)
            {
                var invalidRect = LeadRectD.Empty;
                foreach (AnnObject annObject in annObjects)
                {
                    if (annObject != null)
                    {
                        invalidRect = LeadRectD.UnionRects(invalidRect, _automation.GetObjectInvalidateRect(annObject));
                    }
                }
                _automation.ActiveContainer = ((PageTreeNode)node.TreeParentNode).AnnContainer;
                _automation.SelectObjects(annObjects);
                _imageViewer.EnsureBoundsVisible(invalidRect);
            }
        }
コード例 #2
0
        public void Populate()
        {
            SuspendLayout();
            Clear();

            if (_automation != null)
            {
                foreach (var annContainer in _automation.Containers)
                {
                    if (annContainer.Children.Count > 0)
                    {
                        PageTreeNode page = new PageTreeNode(annContainer, this);
                        TreeRootNode.ChildNodes.Add(page);
                        page.TreeParentNode = TreeRootNode;

                        foreach (var annObject in annContainer.Children)
                        {
                            if (annObject.Id != AnnObject.SelectObjectId && annObject.Id != AnnObject.None)
                            {
                                AnnObjectTreeNode annNode = new AnnObjectTreeNode(annObject, page, _automation, this);
                                page.ChildNodes.Add(annNode);
                            }
                        }

                        if (page.ChildNodes.Count > 0)
                        {
                            Controls.Add(page);
                        }
                    }
                }
            }
            ResumeLayout();
        }
コード例 #3
0
        public void UpdateMetadata()
        {
            Dictionary <string, string> metadata = _annObject.Metadata;
            string author = null;

            if (metadata.ContainsKey(AnnObject.AuthorMetadataKey))
            {
                author = metadata[AnnObject.AuthorMetadataKey];
            }

            if (!string.IsNullOrEmpty(author))
            {
                _lblAuthor.Text = author;
            }

            string lastModified = null;

            if (metadata.ContainsKey(AnnObject.ModifiedMetadataKey))
            {
                lastModified = AnnObjectTreeNode.ToLocalTimeString(metadata[AnnObject.ModifiedMetadataKey]);
            }

            if (!string.IsNullOrEmpty(lastModified))
            {
                _lblDate.Text = lastModified;
            }

            if (metadata.ContainsKey(AnnObject.ContentMetadataKey))
            {
                _tbComment.Text = metadata[AnnObject.ContentMetadataKey];
            }
        }
コード例 #4
0
        private void UpdateContent(AnnObject annObject)
        {
            var metadata = annObject.Metadata;

            string author = null;

            if (metadata.ContainsKey(AnnObject.AuthorMetadataKey))
            {
                author = metadata[AnnObject.AuthorMetadataKey];
            }

            if (string.IsNullOrEmpty(author))
            {
                author = "[author]";
            }

            string lastModified = null;

            if (metadata.ContainsKey(AnnObject.ModifiedMetadataKey))
            {
                lastModified = AnnObjectTreeNode.ToLocalTimeString(AnnObject.ModifiedMetadataKey);
            }

            if (string.IsNullOrEmpty(lastModified))
            {
                lastModified = "[date]";
            }

            _contentGroupBox.Text = string.Format("By {0} at {1}", author, lastModified);

            string text = null;

            var textObject = annObject as AnnTextObject;

            if (textObject != null)
            {
                text = textObject.Text;
            }
            else
            {
                // Get it from the content
                if (metadata.ContainsKey(AnnObject.ContentMetadataKey))
                {
                    text = metadata[AnnObject.ContentMetadataKey];
                }
            }

            _contentTextBox.Text = text;
        }
コード例 #5
0
        public void PopulateContainer(AnnContainer annContainer)
        {
            SuspendLayout();
            List <AutomationTreeNode> pages = TreeRootNode.ChildNodes;
            PageTreeNode insertedPage       = null;
            bool         pageExists         = false;

            if (pages.Count > 0)
            {
                foreach (PageTreeNode page in pages)
                {
                    if (page.AnnContainer.PageNumber == annContainer.PageNumber)// page already exists
                    {
                        pageExists = true;
                        RemoveChildsFromTree(page.ChildNodes);
                        page.ChildNodes.Clear();
                        if (annContainer.Children.Count > 0)
                        {
                            foreach (AnnObject annObject in annContainer.Children)
                            {
                                if (annObject.Id != AnnObject.SelectObjectId && annObject.Id != AnnObject.None)
                                {
                                    AnnObjectTreeNode annNode = new AnnObjectTreeNode(annObject, page, _automation, this);
                                    page.ChildNodes.Add(annNode);
                                }
                            }

                            if (page.ChildNodes.Count > 0 && !Controls.Contains(page))
                            {
                                Controls.Add(page);
                            }

                            if (page.IsExpanded)
                            {
                                int startingIndex = Controls.IndexOf(page);
                                AddChildsToTree(page.ChildNodes, ref startingIndex);
                            }
                        }
                        else //Empty Page
                        {
                            pages.Remove(page);
                            Controls.Remove(page);
                        }
                        break;
                    }
                    else if (page.AnnContainer.PageNumber > annContainer.PageNumber) // insert new page
                    {
                        pageExists = true;
                        if (annContainer.Children.Count > 0)
                        {
                            insertedPage = new PageTreeNode(annContainer, this);
                            insertedPage.TreeParentNode = TreeRootNode;
                            foreach (AnnObject annObject in annContainer.Children)
                            {
                                if (annObject.Id != AnnObject.SelectObjectId && annObject.Id != AnnObject.None)
                                {
                                    AnnObjectTreeNode annNode = new AnnObjectTreeNode(annObject, insertedPage, _automation, this);
                                    insertedPage.ChildNodes.Add(annNode);
                                }
                            }
                            pages.Insert(pages.IndexOf(page), insertedPage);
                            Controls.Add(insertedPage);
                            Controls.SetChildIndex(insertedPage, Controls.GetChildIndex(page));
                        }
                        break;
                    }
                }
            }
            if (!pageExists) //add new page
            {
                if (annContainer.Children.Count > 0)
                {
                    PageTreeNode newPage = new PageTreeNode(annContainer, this);
                    newPage.TreeParentNode = TreeRootNode;
                    List <AutomationTreeNode> annNodes = new List <AutomationTreeNode>();
                    foreach (AnnObject annObject in annContainer.Children)
                    {
                        if (annObject.Id != AnnObject.SelectObjectId && annObject.Id != AnnObject.None)
                        {
                            AnnObjectTreeNode annNode = new AnnObjectTreeNode(annObject, newPage, _automation, this);
                            annNodes.Add(annNode);
                        }
                    }
                    newPage.ChildNodes = annNodes;
                    pages.Add(newPage);
                    Controls.Add(newPage);
                }
            }
            ResumeLayout();

            UpdateSelection();
        }