Example #1
0
        private void PageTree_MouseMove(object sender, MouseEventArgs e)
        {
            var ht = PageTree.HitTest(e.Location);

            PageTree.Cursor = ht.Node != null && ht.Node.Bounds.Contains(e.Location)
                ? Cursors.Hand : Cursors.Default;
        }
Example #2
0
        /// <summary>
        /// Changes left menu and breadcrumbs if page is in workroom
        /// Redirects to profile page if needed
        /// </summary>
        /// <param name="page">page for initialization</param>
        /// <param name="enableRedirect">If redirect is enabled</param>
        private static void InitializeWorkroomPage(PageBase page, bool enableRedirect)
        {
            //Check if page is in workroom
            PageReference start = GetWorkroomStartPageLink(page);

            if (PageReference.IsNullOrEmpty(start))
            {
                return;
            }

            /// Redirect ot profile page
            if (enableRedirect)
            {
                RedirectToUserProfilePage(page);
            }

            ///Update left menu tree
            PageTree tree = page.Master.FindControl(_subMenuControlID) as PageTree;

            if (tree != null)
            {
                tree.PageLink       = start;
                tree.NumberOfLevels = 3;
                tree.DataBind();
            }
        }
Example #3
0
        internal PdfPage(TableBuilder tableBuilder, PageTree parent)
        {
            _tableBuilder = tableBuilder;
            _parent       = parent;
            _parent.AddPage(this);

            Reference     = tableBuilder.ReserveId();
            ContentStream = new ContentStream(tableBuilder.ReserveId());
        }
Example #4
0
        /// <summary>
        /// Constructor for <see cref="PdfWriter"/>
        /// </summary>
        /// <param name="stream">The <see cref="Stream"/> to write the PDF file</param>
        /// <param name="ownsStream">If the stream is owned, then when this <see cref="PdfWriter"/> is disposed, the stream is also disposed.</param>
        public PdfWriter(Stream stream, bool ownsStream)
        {
            _stream = new PdfStream(stream);
            _writeHeader(_stream);

            _pageTree = new PageTree(_tableBuilder.ReserveId());
            _catalog  = new Catalog(_tableBuilder.ReserveId(), _pageTree);

            DocumentInformation = new DocumentInformation(_tableBuilder.ReserveId())
            {
                Producer     = $"Synercoding.FileFormats.Pdf {typeof(PdfWriter).GetTypeInfo().Assembly.GetName().Version}",
                CreationDate = DateTime.Now
            };

            _ownsStream = ownsStream;
        }
Example #5
0
 public abstract void Render(PageTree parent, MarkdownWriter writer);
Example #6
0
        public override void BuildDocs(string outputPath)
        {
            var pages     = new PageTree("docs");
            var PageTrees = new List <PageTree>();

            foreach (var type in Library.GetExportedTypes())
            {
                var typePath = $"{type.Namespace.Replace('.', '/')}/{DocUtilities.GetURLTitle(type)}";
                var typeData = Docs[ID.GetIDString(type)];

                pages[typePath] = new TypePage(type, typeData, Docs);
                PageTrees.Add(pages.GetNode(typePath));

                // Constructors
                var ctors = type.GetConstructors();
                if (ctors.Length > 0)
                {
                    // Path to ctors group
                    var ctorsGroupPath = $"{typePath}/ctors";

                    var ctorsData = new Dictionary <ConstructorInfo, MemberXmlDocs>();
                    foreach (var ctor in ctors)
                    {
                        var ctorData = Docs[ID.GetIDString(ctor)];
                        ctorsData.Add(ctor, ctorData);
                    }

                    pages[ctorsGroupPath] = new ConstructorsPage(type, ctors, ctorsData);
                    PageTrees.Add(pages.GetNode(ctorsGroupPath));
                }

                // Method groups
                foreach (var methodGroup in type.GetMethods()
                         .Where(m => !m.Name.StartsWith("get_") && !m.Name.StartsWith("set_"))
                         .GroupBy(m => m.Name))
                {
                    // Path to method group
                    var methodGroupPath = $"{typePath}/{methodGroup.Key}";

                    // Map of reflected methods and documentation
                    var methods = new Dictionary <MethodInfo, MemberXmlDocs>();

                    foreach (var method in methodGroup)
                    {
                        var methodData = Docs[ID.GetIDString(method)];
                        methods[method] = methodData;
                    }

                    pages[methodGroupPath] = new MethodGroupPage(type, methodGroup.Key, methods);
                    PageTrees.Add(pages.GetNode(methodGroupPath));
                }

                // Fields
                foreach (var field in type.GetFields().Where(f => (f.IsPublic || !f.IsPrivate) && (!f.DeclaringType.IsEnum || !f.IsSpecialName)))
                {
                    var fieldPath = Path.Combine(typePath, field.Name).Replace('\\', '/');
                    var fieldData = Docs[ID.GetIDString(field)];
                    pages[fieldPath] = new FieldPage(field, fieldData);
                    PageTrees.Add(pages.GetNode(fieldPath));
                }

                // Properties and Indexers
                int numIndexers = 0;
                foreach (var property in type.GetProperties())
                {
                    var propData = Docs[ID.GetIDString(property)];

                    string propPath;
                    if (property.GetIndexParameters().Length > 0)
                    {
                        propPath = $"{typePath}/this/{++numIndexers}";
                    }
                    else
                    {
                        propPath = $"{typePath}/{property.Name}";
                    }

                    pages[propPath] = new PropertyPage(property, propData);
                    PageTrees.Add(pages.GetNode(propPath));
                }
            }

            // Create a task for each document that needs to be exported, run them all at once
            var exportTasks = new Task[PageTrees.Count];

            for (int i = 0; i < PageTrees.Count; i++)
            {
                var node = PageTrees[i];
                exportTasks[i] = Task.Run(() =>
                {
                    var documentDir  = Directory.GetParent($"{outputPath}/{node.Path}").FullName;
                    var documentPath = $"{outputPath}/{node.Path}.md";
                    Directory.CreateDirectory(documentDir);
                    using (var writer = new MarkdownWriter(documentPath))
                    {
                        node.Page.Render(node, writer);
                    }
                });
            }

            // Wait for all export tasks to finish
            Task.WaitAll(exportTasks);
        }