• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Document类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Document的典型用法代码示例。如果您正苦于以下问题:C# Document类的具体用法?C# Document怎么用?C# Document使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Document类属于命名空间,在下文中一共展示了Document类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: FixAllAsync

        private async Task<Document> FixAllAsync(
            Document document, ImmutableArray<Diagnostic> diagnostics, CancellationToken cancellationToken)
        {
            var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);

            // Create an editor to do all the transformations.  This allows us to fix all
            // the diagnostics in a clean manner.  If we used the normal batch fix provider
            // then it might fail to apply all the individual text changes as many of the 
            // changes produced by the diff might end up overlapping others.
            var editor = new SyntaxEditor(root, document.Project.Solution.Workspace);
            var options = document.Project.Solution.Workspace.Options;

            // Attempt to use an out-var declaration if that's the style the user prefers.
            // Note: if using 'var' would cause a problem, we will use the actual type
            // of hte local.  This is necessary in some cases (for example, when the
            // type of the out-var-decl affects overload resolution or generic instantiation).
            var useVarWhenDeclaringLocals = options.GetOption(CSharpCodeStyleOptions.UseVarWhenDeclaringLocals);
            var useImplicitTypeForIntrinsicTypes = options.GetOption(CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes).Value;

            foreach (var diagnostic in diagnostics)
            {
                cancellationToken.ThrowIfCancellationRequested();
                await AddEditsAsync(document, editor, diagnostic, 
                    useVarWhenDeclaringLocals, useImplicitTypeForIntrinsicTypes, 
                    cancellationToken).ConfigureAwait(false);
            }

            var newRoot = editor.GetChangedRoot();
            return document.WithSyntaxRoot(newRoot);
        }
开发者ID:otawfik-ms,项目名称:roslyn,代码行数:30,代码来源:CSharpInlineDeclarationCodeFixProvider.cs


示例2: GetAllViews

        /// <summary>
        /// Finds all the views in the active document.
        /// </summary>
        /// <param name="doc">the active document</param>
        public static ViewSet GetAllViews (Document doc)
        {
            ViewSet allViews = new ViewSet();

            FilteredElementCollector fec = new FilteredElementCollector(doc);
            ElementClassFilter elementsAreWanted = new ElementClassFilter(typeof(FloorType));
            fec.WherePasses(elementsAreWanted);
            List<Element> elements = fec.ToElements() as List<Element>;

            foreach (Element element in elements)
            {
               Autodesk.Revit.DB.View view = element as Autodesk.Revit.DB.View;

               if (null == view)
               {
                  continue;
               }
               else
               {
                  
                  ElementType objType = doc.GetElement(view.GetTypeId()) as ElementType;
                  if (null == objType || objType.Name.Equals("Drawing Sheet"))
                  {
                     continue;
                  }
                  else
                  {
                     allViews.Insert(view);
                  }
               }
            }

            return allViews;
        }
开发者ID:15921050052,项目名称:RevitLookup,代码行数:38,代码来源:View.cs


示例3: Run

        public static void Run()
        {
            // ExStart:ExtractTextFromPageRegion
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Text();

            // Open document
            Document pdfDocument = new Document(dataDir + "ExtractTextAll.pdf");

            // Create TextAbsorber object to extract text
            TextAbsorber absorber = new TextAbsorber();
            absorber.TextSearchOptions.LimitToPageBounds = true;
            absorber.TextSearchOptions.Rectangle = new Aspose.Pdf.Rectangle(100, 200, 250, 350);

            // Accept the absorber for first page
            pdfDocument.Pages[1].Accept(absorber);

            // Get the extracted text
            string extractedText = absorber.Text;
            // Create a writer and open the file
            TextWriter tw = new StreamWriter(dataDir + "extracted-text.txt");
            // Write a line of text to the file
            tw.WriteLine(extractedText);
            // Close the stream
            tw.Close();
            // ExEnd:ExtractTextFromPageRegion          
            
        }
开发者ID:aspose-pdf,项目名称:Aspose.Pdf-for-.NET,代码行数:28,代码来源:ExtractTextFromPageRegion.cs


示例4: SetGenerateTypeOptions

 public void SetGenerateTypeOptions(
     Accessibility accessibility = Accessibility.NotApplicable,
     TypeKind typeKind = TypeKind.Class,
     string typeName = null,
     Project project = null,
     bool isNewFile = false,
     string newFileName = null,
     IList<string> folders = null,
     string fullFilePath = null,
     Document existingDocument = null,
     bool areFoldersValidIdentifiers = true,
     string defaultNamespace = null,
     bool isCancelled = false)
 {
     Accessibility = accessibility;
     TypeKind = typeKind;
     TypeName = typeName;
     Project = project;
     IsNewFile = isNewFile;
     NewFileName = newFileName;
     Folders = folders;
     FullFilePath = fullFilePath;
     ExistingDocument = existingDocument;
     AreFoldersValidIdentifiers = areFoldersValidIdentifiers;
     DefaultNamespace = defaultNamespace;
     IsCancelled = isCancelled;
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:27,代码来源:TestGenerateTypeOptionsService.cs


示例5: GetGenerateTypeOptions

 public GenerateTypeOptionsResult GetGenerateTypeOptions(
     string className,
     GenerateTypeDialogOptions generateTypeDialogOptions,
     Document document,
     INotificationService notificationService,
     IProjectManagementService projectManagementService,
     ISyntaxFactsService syntaxFactsService)
 {
     // Storing the actual values
     ClassName = className;
     GenerateTypeDialogOptions = generateTypeDialogOptions;
     if (DefaultNamespace == null)
     {
         DefaultNamespace = projectManagementService.GetDefaultNamespace(Project, Project?.Solution.Workspace);
     }
     return new GenerateTypeOptionsResult(
         accessibility: Accessibility,
         typeKind: TypeKind,
         typeName: TypeName,
         project: Project,
         isNewFile: IsNewFile,
         newFileName: NewFileName,
         folders: Folders,
         fullFilePath: FullFilePath,
         existingDocument: ExistingDocument,
         areFoldersValidIdentifiers: AreFoldersValidIdentifiers,
         defaultNamespace: DefaultNamespace,
         isCancelled: IsCancelled);
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:29,代码来源:TestGenerateTypeOptionsService.cs


示例6: CanExecute

        public override bool CanExecute(IDictionary<string, object> parameter)
        {
            _document = _dte.ActiveDocument;
            if (_document == null || _document.ProjectItem == null || _document.ProjectItem.FileCodeModel == null)
            {
                MessageBox(ErrMessage);
                return false;
            }

            _serviceClass = GetClass(_document.ProjectItem.FileCodeModel.CodeElements);
            if (_serviceClass == null)
            {
                MessageBox(ErrMessage);
                return false;
            }

            _serviceInterface = GetServiceInterface(_serviceClass as CodeElement);
            if (_serviceInterface == null)
            {
                MessageBox(ErrMessage);
                return false;
            }

            _serviceName = _serviceClass.Name.Replace("AppService", "");
            return true;
        }
开发者ID:chimeramvp,项目名称:ABPHelper,代码行数:26,代码来源:AddNewServiceMethodHelper.cs


示例7: button2_Click

 private void button2_Click(object sender, EventArgs e)
 {
     BaseFont bfTimes = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, false);
     iTextSharp.text.Font times = new iTextSharp.text.Font(bfTimes, 12, iTextSharp.text.Font.ITALIC, BaseColor.DARK_GRAY);
     Document doc = new Document(iTextSharp.text.PageSize.LETTER,10,10,42,42);
     PdfWriter pdw = PdfWriter.GetInstance(doc, new FileStream(naziv + ".pdf", FileMode.Create));
     doc.Open();
     Paragraph p = new Paragraph("Word Count for : "+naziv,times);
     doc.Add(p);
     p.Alignment = 1;
     PdfPTable pdt = new PdfPTable(2);
     pdt.HorizontalAlignment = 1;
     pdt.SpacingBefore = 20f;
     pdt.SpacingAfter = 20f;
     pdt.AddCell("Word");
     pdt.AddCell("No of repetitions");
     foreach (Rijec r in lista_rijeci)
     {
         pdt.AddCell(r.Tekst);
         pdt.AddCell(Convert.ToString(r.Ponavljanje));
     }
     using (MemoryStream stream = new MemoryStream())
     {
         chart1.SaveImage(stream, ChartImageFormat.Png);
         iTextSharp.text.Image chartImage = iTextSharp.text.Image.GetInstance(stream.GetBuffer());
         chartImage.ScalePercent(75f);
         chartImage.Alignment = 1;
         doc.Add(chartImage);
     }
     doc.Add(pdt);
     doc.Close();
     MessageBox.Show("PDF created!");
 }
开发者ID:dbajramovic,项目名称:masterwordcounter,代码行数:33,代码来源:TextResult.cs


示例8: DocEdit

 public DocEdit(Form parent, Document doc)
 {
     MdiParent = parent;
     InitializeComponent();
     m_doc = doc;
     doc.AddView(this);
 }
开发者ID:WinWrap,项目名称:ClassicExamples,代码行数:7,代码来源:DocEdit.cs


示例9: FindBracesAsync

        public async Task<BraceMatchingResult?> FindBracesAsync(
            Document document,
            int position,
            CancellationToken cancellationToken)
        {
            var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
            var token = root.FindToken(position);

            var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
            if (position < text.Length && this.IsBrace(text[position]))
            {
                if (token.RawKind == _openBrace.Kind && AllowedForToken(token))
                {
                    var leftToken = token;
                    if (TryFindMatchingToken(leftToken, out var rightToken))
                    {
                        return new BraceMatchingResult(leftToken.Span, rightToken.Span);
                    }
                }
                else if (token.RawKind == _closeBrace.Kind && AllowedForToken(token))
                {
                    var rightToken = token;
                    if (TryFindMatchingToken(rightToken, out var leftToken))
                    {
                        return new BraceMatchingResult(leftToken.Span, rightToken.Span);
                    }
                }
            }

            return null;
        }
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:31,代码来源:AbstractBraceMatcher.cs


示例10: MakePage

        void MakePage(Document doc, Range range)
        {
            var table = doc.Tables.Add(range, (int)m_numberOfRows, 2);

            table.Rows.SetHeight(136.1F, WdRowHeightRule.wdRowHeightExactly);
            table.Columns.SetWidth(295.65F, WdRulerStyle.wdAdjustNone); // 297.65F

            table.LeftPadding = 0.75F;
            table.RightPadding = 0.75F;
            table.TopPadding = 5F;

            for (int row = 1; row <= m_numberOfRows; ++row)
                for (int col = 1; col <= 2; ++col)
                {
                    string code = m_tr.ReadLine();

                    if (code == null) return;

                    Console.WriteLine("Row:{0}, Col:{1}", row, col);
                    var cell = table.Cell(row, col);

                    cell.Range.Delete();
                    cell.VerticalAlignment = WdCellVerticalAlignment.wdCellAlignVerticalCenter;

                    PopCell(cell.Range, "Horsell Jubilation Balloon Race", isBold:true, fontSize:12, first:true);
                    PopCell(cell.Range, "", fontSize:12);
                    PopCell(cell.Range, "Notice to the finder of this balloon:", isBold:true);
                    PopCell(cell.Range, "Please go to the website www.diamondballoons.info to register your details and the location of the balloon. By doing so you will be entered into a draw for a £25 Amazon Gift Voucher. Good luck and thank you!");
                    PopCell(cell.Range, code, false, 12, centre: true);
                    PopCell(cell.Range, "", fontSize: 12);

                    ++m_count;
                }
        }
开发者ID:petebarber,项目名称:Balloon,代码行数:34,代码来源:Program.cs


示例11: Run

        public static void Run()
        {
            // ExStart:ConvertPageRegionToDOM         
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Images();

            // Open document
            Document document = new Document( dataDir + "AddImage.pdf");
            // Get rectangle of particular page region
            Aspose.Pdf.Rectangle pageRect = new Aspose.Pdf.Rectangle(20, 671, 693, 1125);
            // Set CropBox value as per rectangle of desired page region
            document.Pages[1].CropBox = pageRect;
            // Save cropped document into stream
            MemoryStream ms = new MemoryStream();
            document.Save(ms);
            // Open cropped PDF document and convert to image
            document = new Document(ms);
            // Create Resolution object
            Resolution resolution = new Resolution(300);
            // Create PNG device with specified attributes
            PngDevice pngDevice = new PngDevice(resolution);
            dataDir = dataDir + "ConvertPageRegionToDOM_out.png";
            // Convert a particular page and save the image to stream
            pngDevice.Process(document.Pages[1], dataDir);
            ms.Close();
            // ExEnd:ConvertPageRegionToDOM   
            Console.WriteLine("\nPage region converted to DOM successfully.\nFile saved at " + dataDir); 
        }
开发者ID:aspose-pdf,项目名称:Aspose.Pdf-for-.NET,代码行数:28,代码来源:ConvertPageRegionToDOM.cs


示例12: GetItemAsync

        public async Task<QuickInfoItem> GetItemAsync(
            Document document,
            int position,
            CancellationToken cancellationToken)
        {
            var tree = await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);
            var token = await tree.GetTouchingTokenAsync(position, cancellationToken, findInsideTrivia: true).ConfigureAwait(false);

            var state = await GetQuickInfoItemAsync(document, token, position, cancellationToken).ConfigureAwait(false);
            if (state != null)
            {
                return state;
            }

            if (ShouldCheckPreviousToken(token))
            {
                var previousToken = token.GetPreviousToken();

                if ((state = await GetQuickInfoItemAsync(document, previousToken, position, cancellationToken).ConfigureAwait(false)) != null)
                {
                    return state;
                }
            }

            return null;
        }
开发者ID:RoryVL,项目名称:roslyn,代码行数:26,代码来源:AbstractQuickInfoProvider.cs


示例13:

 public DocumentEditState this[Document document]
 {
     get
     {
         return _dataObject[document.Id.ToString(CultureInfo.InvariantCulture)];
     }
 }
开发者ID:coder0xff,项目名称:Alterity,代码行数:7,代码来源:DocumentEditStateCollection.cs


示例14: AnalyzeTypeAtPositionAsync

        public async Task<ExtractInterfaceTypeAnalysisResult> AnalyzeTypeAtPositionAsync(
            Document document,
            int position,
            TypeDiscoveryRule typeDiscoveryRule,
            CancellationToken cancellationToken)
        {
            var typeNode = GetTypeDeclaration(document, position, typeDiscoveryRule, cancellationToken);
            if (typeNode == null)
            {
                var errorMessage = FeaturesResources.CouldNotExtractInterfaceSelection;
                return new ExtractInterfaceTypeAnalysisResult(errorMessage);
            }

            var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
            var type = semanticModel.GetDeclaredSymbol(typeNode, cancellationToken);
            if (type == null || type.Kind != SymbolKind.NamedType)
            {
                var errorMessage = FeaturesResources.CouldNotExtractInterfaceSelection;
                return new ExtractInterfaceTypeAnalysisResult(errorMessage);
            }

            var typeToExtractFrom = type as INamedTypeSymbol;
            var extractableMembers = typeToExtractFrom.GetMembers().Where(IsExtractableMember);
            if (!extractableMembers.Any())
            {
                var errorMessage = FeaturesResources.CouldNotExtractInterfaceTypeMember;
                return new ExtractInterfaceTypeAnalysisResult(errorMessage);
            }

            return new ExtractInterfaceTypeAnalysisResult(this, document, typeNode, typeToExtractFrom, extractableMembers);
        }
开发者ID:GloryChou,项目名称:roslyn,代码行数:31,代码来源:AbstractExtractInterfaceService.cs


示例15: CalculateStats

        private void CalculateStats(Document document)
        {
            var all = document.Map.WorldSpawn.FindAll();
            var solids = all.OfType<Solid>().ToList();
            var faces = solids.SelectMany(x => x.Faces).ToList();
            var entities = all.OfType<Entity>().ToList();
            var numSolids = solids.Count;
            var numFaces = faces.Count;
            var numPointEnts = entities.Count(x => !x.HasChildren);
            var numSolidEnts = entities.Count(x => x.HasChildren);
            var uniqueTextures = faces.Select(x => x.Texture.Name).Distinct().ToList();
            var numUniqueTextures = uniqueTextures.Count;
            var textureMemory = faces.Select(x => x.Texture.Texture)
                .Where(x => x != null)
                .Distinct()
                .Sum(x => x.Width * x.Height * 3); // 3 bytes per pixel
            var textureMemoryMb = textureMemory / (1024m * 1024m);
            var items = document.TextureCollection.GetItems(uniqueTextures);
            var packages = items.Select(x => x.Package).Distinct();
            // todo texture memory, texture packages

            NumSolids.Text = numSolids.ToString(CultureInfo.CurrentCulture);
            NumFaces.Text = numFaces.ToString(CultureInfo.CurrentCulture);
            NumPointEntities.Text = numPointEnts.ToString(CultureInfo.CurrentCulture);
            NumSolidEntities.Text = numSolidEnts.ToString(CultureInfo.CurrentCulture);
            NumUniqueTextures.Text = numUniqueTextures.ToString(CultureInfo.CurrentCulture);
            // TextureMemory.Text = textureMemory.ToString(CultureInfo.CurrentCulture);
            TextureMemory.Text = textureMemory.ToString("#,##0", CultureInfo.CurrentCulture)
                + " bytes (" + textureMemoryMb.ToString("0.00", CultureInfo.CurrentCulture) + " MB)";
            foreach (var tp in packages)
            {
                TexturePackages.Items.Add(tp);
            }
        }
开发者ID:KonstantinUb,项目名称:sledge,代码行数:34,代码来源:MapInformationDialog.cs


示例16: HtmlLinkElement

 /// <summary>
 /// Creates a new HTML link element.
 /// </summary>
 public HtmlLinkElement(Document owner, String prefix = null)
     : base(owner, Tags.Link, prefix, NodeFlags.Special | NodeFlags.SelfClosing)
 {
     RegisterAttributeObserver(AttributeNames.Media, UpdateMedia);
     RegisterAttributeObserver(AttributeNames.Disabled, UpdateDisabled);
     RegisterAttributeObserver(AttributeNames.Href, value => UpdateSource(value));
 }
开发者ID:kk9599,项目名称:AngleSharp,代码行数:10,代码来源:HtmlLinkElement.cs


示例17: Run

        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithBookmarks();

            // Load the source document.
            Document srcDoc = new Document(dataDir + "Template.doc");

            // This is the bookmark whose content we want to copy.
            Bookmark srcBookmark = srcDoc.Range.Bookmarks["ntf010145060"];

            // We will be adding to this document.
            Document dstDoc = new Document();

            // Let's say we will be appending to the end of the body of the last section.
            CompositeNode dstNode = dstDoc.LastSection.Body;

            // It is a good idea to use this import context object because multiple nodes are being imported.
            // If you import multiple times without a single context, it will result in many styles created.
            NodeImporter importer = new NodeImporter(srcDoc, dstDoc, ImportFormatMode.KeepSourceFormatting);

            // Do it once.
            AppendBookmarkedText(importer, srcBookmark, dstNode);

            // Do it one more time for fun.
            AppendBookmarkedText(importer, srcBookmark, dstNode);

            // Save the finished document.
            dstDoc.Save(dataDir + "Template Out.doc");

            Console.WriteLine("\nBookmark copied successfully.\nFile saved at " + dataDir + "Template Out.doc");
        }
开发者ID:robv8r,项目名称:Aspose_Words_NET,代码行数:32,代码来源:CopyBookmarkedText.cs


示例18: GenerateContent

 /// <summary>
 /// Fill the target document with random content
 /// </summary>
 /// <param Name="doc"></param>
 public void GenerateContent(Document doc)
 {
     //Starting with the start symbol, randomly navigate the Finite State Machine
     //Filling the target document with content until it hits the terminate symbol
     Section next = StartSymbol;
     while ((next = next.generate(doc)) != null) { }
 }
开发者ID:malacandrian,项目名称:fyp,代码行数:11,代码来源:DocGenerator.cs


示例19: Main

        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            string input = dataDir+ @"input.pdf";
            using (Document pdfDocument = new Document(input))
            {
                foreach (Field field in pdfDocument.Form)
                {
                    SignatureField sf = field as SignatureField;
                    if (sf != null)
                    {
                        Stream cerStream = sf.ExtractCertificate();
                        if (cerStream != null)
                        {
                            using (cerStream)
                            {
                                byte[] bytes = new byte[cerStream.Length];
                                using (FileStream fs = new FileStream(dataDir+ @"input.cer", FileMode.CreateNew))
                                {
                                    cerStream.Read(bytes, 0, bytes.Length);
                                    fs.Write(bytes, 0, bytes.Length);
                                }
                            }
                        }
                    }
                }
            }
        }
开发者ID:Ravivishnubhotla,项目名称:Aspose_Pdf_NET,代码行数:30,代码来源:Program.cs


示例20: Main

        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Aspose.Note.Examples.Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            Dictionary<string, string> replacements = new Dictionary<string, string>();
            replacements.Add("Some task here", "New Text Here");

            // Load the document into Aspose.Note.
            Document oneFile = new Document(dataDir + "Aspose.one");

            IList<Node> pageNodes = oneFile.GetChildNodes(NodeType.Page);
            CompositeNode<Page> compositeNode = (CompositeNode<Page>)pageNodes[0];

            // Get all RichText nodes
            IList<Node> textNodes = compositeNode.GetChildNodes(NodeType.RichText);

            foreach (Node node in textNodes)
            {
                foreach (KeyValuePair<string, string> kvp in replacements)
                {
                    RichText richText = (RichText)node;
                    if (richText != null && richText.Text.Contains(kvp.Key))
                    {
                        // Replace text of a shape
                        richText.Text = richText.Text.Replace(kvp.Key, kvp.Value);
                    }
                }
            }

            // Save to any supported file format
            oneFile.Save(dataDir + "Output.pdf", SaveFormat.Pdf);
        }
开发者ID:saqibmasood,项目名称:Aspose_Note_NET,代码行数:33,代码来源:ReplaceTextOnParticularPage.cs



注:本文中的Document类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# DocumentBuilder类代码示例发布时间:2022-05-24
下一篇:
C# DockingManager类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap