当前位置: 首页>>代码示例>>C#>>正文


C# Documents.Block类代码示例

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


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

示例1: AddBlock

        public static void AddBlock(Block from, FlowDocument to)
        {
            if (from != null)
              {
            //if (from is ItemsContent)
            //{
            //  ((ItemsContent)from).RunBeforeCopy();
            //}
            //else
            {
              TextRange range = new TextRange(from.ContentStart, from.ContentEnd);

              MemoryStream stream = new MemoryStream();

              System.Windows.Markup.XamlWriter.Save(range, stream);

              range.Save(stream, DataFormats.XamlPackage);

              TextRange textRange2 = new TextRange(to.ContentEnd, to.ContentEnd);

              textRange2.Load(stream, DataFormats.XamlPackage);
            }

              }
        }
开发者ID:adamnowak,项目名称:SmartWorking,代码行数:25,代码来源:XPSCreator.cs

示例2: ReportPaginator

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="report">report document</param>
        /// <param name="data">report data</param>
        /// <exception cref="ArgumentException">Flow document must have a specified page height</exception>
        /// <exception cref="ArgumentException">Flow document must have a specified page width</exception>
        /// <exception cref="ArgumentException">Flow document can have only one report header section</exception>
        /// <exception cref="ArgumentException">Flow document can have only one report footer section</exception>
        public ReportPaginator(ReportDocument report, ReportData data)
        {
            _report = report;
            _data = data;

            _flowDocument = report.CreateFlowDocument();
            _pageSize = new Size(_flowDocument.PageWidth, _flowDocument.PageHeight);

            if (_flowDocument.PageHeight == double.NaN) throw new ArgumentException("Flow document must have a specified page height");
            if (_flowDocument.PageWidth == double.NaN) throw new ArgumentException("Flow document must have a specified page width");

            _dynamicCache = new ReportPaginatorDynamicCache(_flowDocument);
            ArrayList listPageHeaders = _dynamicCache.GetFlowDocumentVisualListByType(typeof(SectionReportHeader));
            if (listPageHeaders.Count > 1) throw new ArgumentException("Flow document can have only one report header section");
            if (listPageHeaders.Count == 1) _blockPageHeader = (SectionReportHeader)listPageHeaders[0];
            ArrayList listPageFooters = _dynamicCache.GetFlowDocumentVisualListByType(typeof(SectionReportFooter));
            if (listPageFooters.Count > 1) throw new ArgumentException("Flow document can have only one report footer section");
            if (listPageFooters.Count == 1) _blockPageFooter = (SectionReportFooter)listPageFooters[0];

            _paginator = ((IDocumentPaginatorSource)_flowDocument).DocumentPaginator;

            // remove header and footer in our working copy
            Block block = _flowDocument.Blocks.FirstBlock;
            while (block != null)
            {
                Block thisBlock = block;
                block = block.NextBlock;
                if ((thisBlock == _blockPageHeader) || (thisBlock == _blockPageFooter)) _flowDocument.Blocks.Remove(thisBlock);
            }

            // get report context values
            _reportContextValues = _dynamicCache.GetFlowDocumentVisualListByInterface(typeof(IInlineContextValue));

            FillData();
        }
开发者ID:ivpusic,项目名称:Edward-company-cSharp-app,代码行数:44,代码来源:ReportPaginator.cs

示例3: AnchoredBlock

        //-------------------------------------------------------------------
        //
        // Constructors
        //
        //-------------------------------------------------------------------

        #region Constructors

        /// <summary>
        /// Creates a new AnchoredBlock instance.
        /// </summary>
        /// <param name="block">
        /// Optional child of the new AnchoredBlock, may be null.
        /// </param>
        /// <param name="insertionPosition">
        /// Optional position at which to insert the new AnchoredBlock. May
        /// be null.
        /// </param>
        protected AnchoredBlock(Block block, TextPointer insertionPosition)
        {
            if (insertionPosition != null)
            {
                insertionPosition.TextContainer.BeginChange();
            }
            try
            {
                if (insertionPosition != null)
                {
                    // This will throw InvalidOperationException if schema validity is violated.
                    insertionPosition.InsertInline(this);
                }

                if (block != null)
                {
                    this.Blocks.Add(block);
                }
            }
            finally
            {
                if (insertionPosition != null)
                {
                    insertionPosition.TextContainer.EndChange();
                }
            }
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:45,代码来源:AnchoredBlock.cs

示例4: AddBlock

 private void AddBlock(Block block, TextSelection selection)
 {
     if (selection == null || selection.End == null)
         AddBlockToEnd(block);
     else
         _flowDocument.Blocks.InsertAfter(selection.End.GetInsertionPosition(LogicalDirection.Forward).Paragraph, block);
 }
开发者ID:hinduCoder,项目名称:Diploma,代码行数:7,代码来源:FormattingProvider.cs

示例5: BlockComponent

        public BlockComponent(Block block)
        {
            if (block == null) throw new ArgumentNullException(nameof(block));

            Block = block;

            SubscribeForEvents();
        }
开发者ID:ethno2405,项目名称:BrailleTranslator,代码行数:8,代码来源:BlockComponent.cs

示例6: Serialize

 public XmlElement Serialize(Block block, XmlDocument xmlDocument)
 {
     var image = (ImageBlock)block;
     var imageElement = xmlDocument.CreateElement("Image");
     var srcAttribute = xmlDocument.CreateAttribute("Src");
     srcAttribute.InnerText = Path.GetFileName(image.Source.ToString());
     imageElement.Attributes.Append(srcAttribute);
     return imageElement;
 }
开发者ID:hinduCoder,项目名称:Diploma,代码行数:9,代码来源:ISerializeBlockStrategy.cs

示例7: readSocket

 public Block readSocket(Block source, Block destination)
 {
     StackPanel innards = (StackPanel)source.innerPane.Children.ElementAt(0);
     List<System.Windows.UIElement> components = innards.Children.ToList();
     Debug.WriteLine("+" + components.ElementAt(0));
     destination.innerPane.Children.Clear();
     destination.innerPane.Children.Insert(0, source.innerPane.Children.ElementAt(0));
     return destination;
 }
开发者ID:dhumphri,项目名称:CSE485-Columba,代码行数:9,代码来源:SocketReader.cs

示例8: ReadRuns

 private static IEnumerable<string> ReadRuns(Block block)
 {
     var result = new List<string>();
     if (block is Paragraph)
     {
         result.AddRange((block as Paragraph).Inlines.OfType<Run>().Select(inline => inline.Text.Trim()));
     }
     return result;
 }
开发者ID:hpbaotho,项目名称:sambapos,代码行数:9,代码来源:PrinterTools.cs

示例9: Section

        /// <summary>
        /// Initializes a new instance of a Section class specifying a first Block child for it.
        /// </summary>
        /// <param name="block">
        /// Block element added to a Section as its first child.
        /// </param>
        public Section(Block block)
            : base()
        {
            if (block == null)
            {
                throw new ArgumentNullException("block");
            }

            this.Blocks.Add(block);
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:16,代码来源:Section.cs

示例10: AddBlock

 private void AddBlock(Block block)
 {
     if (scroll == null)
     scroll = reportViewer.Template.FindName("PART_ContentHost", reportViewer) as ScrollViewer;
       if (scroll.ScrollableHeight - scroll.ExtentHeight < 5)
       {
     report.Blocks.Add(block);
     scroll.ScrollToEnd();
       }
       else
     report.Blocks.Add(block);
 }
开发者ID:sunoru,项目名称:PBO,代码行数:12,代码来源:BattleReport.xaml.cs

示例11: AddXaml

 /// <summary>Adds XAML content to a RichTextBox.</summary>
 /// <param name="richTextBox">The textbox to add to.</param>
 /// <param name="xaml">The block to add.</param>
 /// <remarks>This method effectively handles a Section block element if specified (adding all child Blocks to the textbox).</remarks>
 public static void AddXaml(this RichTextBox richTextBox, Block xaml)
 {
     if (richTextBox == null) throw new ArgumentNullException("richTextBox");
     if (xaml == null) throw new ArgumentNullException("xaml");
     if (xaml is Section)
     {
         AddBlocks(richTextBox, ((Section)xaml).Blocks);
     }
     else
     {
         richTextBox.Blocks.Add(xaml);
     }
 }
开发者ID:philcockfield,项目名称:Open.TestHarness.SL,代码行数:17,代码来源:ControlExtensions.cs

示例12: ReportPaginator

        // ReSharper restore InconsistentNaming

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="report">report document</param>
        /// <param name="data">report data</param>
        /// <exception cref="ArgumentException">Flow document must have a specified page height</exception>
        /// <exception cref="ArgumentException">Flow document must have a specified page width</exception>
        /// <exception cref="ArgumentException">Flow document can have only one report header section</exception>
        /// <exception cref="ArgumentException">Flow document can have only one report footer section</exception>
        public ReportPaginator(ReportDocument report, ReportData data, Action<int, int> PageGeneratedCallBack = null, FlowDocument flowDocument = null)
        {
            _report = report;
            _data = data;
            _pageGeneratedCallBack = PageGeneratedCallBack;

            _flowDocument = flowDocument;
            if (_flowDocument == null) 
                _flowDocument = report.CreateFlowDocument();

            _pageSize = new Size(_flowDocument.PageWidth, _flowDocument.PageHeight);

            if (_flowDocument.PageHeight == double.NaN) throw new ArgumentException("Flow document must have a specified page height");
            if (_flowDocument.PageWidth == double.NaN) throw new ArgumentException("Flow document must have a specified page width");

            _dynamicCache = new ReportPaginatorDynamicCache(_flowDocument);
            ArrayList listPageHeaders = _dynamicCache.GetFlowDocumentVisualListByType(typeof(SectionReportHeader));
            if (listPageHeaders.Count > 1) throw new ArgumentException("Flow document can have only one report header section");
            if (listPageHeaders.Count == 1) _blockPageHeader = (SectionReportHeader)listPageHeaders[0];
            ArrayList listPageFooters = _dynamicCache.GetFlowDocumentVisualListByType(typeof(SectionReportFooter));
            if (listPageFooters.Count > 1) throw new ArgumentException("Flow document can have only one report footer section");
            if (listPageFooters.Count == 1) _blockPageFooter = (SectionReportFooter)listPageFooters[0];

            _paginator = ((IDocumentPaginatorSource)_flowDocument).DocumentPaginator;

            // remove header and footer in our working copy
            Block block = _flowDocument.Blocks.FirstBlock;
            while (block != null)
            {
                Block thisBlock = block;
                block = block.NextBlock;
                if ((thisBlock == _blockPageHeader) || (thisBlock == _blockPageFooter)) _flowDocument.Blocks.Remove(thisBlock);
            }

            // get report context values
            _reportContextValues = _dynamicCache.GetFlowDocumentVisualListByInterface(typeof(IInlineContextValue));

            FillData();

            /*Application.Current.Dispatcher.Invoke(new Action(() =>
                {
                    Window aa = new Window();
                    FlowDocumentPageViewer bb = new FlowDocumentPageViewer();
                    bb.Document = _flowDocument;
                    aa.Content = bb;
                    aa.SizeToContent = SizeToContent.WidthAndHeight;
                    aa.ShowDialog();
                }));*/
        }
开发者ID:ChrisCross67,项目名称:CodeReason.Reports,代码行数:60,代码来源:ReportPaginator.cs

示例13: PowerEntry

        /// <summary>
        /// Create a new <see cref="PowerEntry"/>. All arguments to this method are assumed 
        /// to be escaped for HTML already.
        /// </summary>
        /// <param name="heading">
        /// The heading <see cref="Block"/>. This cannot be null.
        /// </param>
        /// <param name="flavorText">
        /// The flavor text <see cref="Block"/>. This may be null.
        /// </param>
        /// <param name="detail">
        /// The detail <see cref="Block"/>.  This cannot be null.
        /// </param>
        /// <param name="modifierSource">
        /// The <see cref="ModifierSource"/> that this <see cref="PowerEntry"/> was created for.
        /// This may be null.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Only <paramref name="modifierSource"/> can be null.
        /// </exception>
        public PowerEntry(Block heading, Block flavorText, Block detail, ModifierSource modifierSource)
        {
            if (heading == null)
            {
                throw new ArgumentNullException("heading");
            }
            if (detail == null)
            {
                throw new ArgumentNullException("detail");
            }

            Heading = heading;
            FlavorText = flavorText;
            Detail = detail;
            ModifierSource = modifierSource;
        }
开发者ID:anthonylangsworth,项目名称:GammaWorldCharacter,代码行数:36,代码来源:PowerEntry.cs

示例14: Accept

        private bool Accept(Block block)
        {
            if (!TryMatch(block)) return false;

            if (block is Table)
            {
                foreach (var inner in ((Table) block).RowGroups
                    .SelectMany(x => x.Rows)
                    .SelectMany(x => x.Cells)
                    .SelectMany(x => x.Blocks))
                {
                    if (!Accept(inner)) return false;
                }

                return true;
            }

            if (block is Paragraph)
            {
                foreach (var inner in  ((Paragraph) block).Inlines)
                {
                    if (!TryMatch(inner)) return false;
                }

                return true;
            }

            if (block is BlockUIContainer)
            {
                // ignore children
                return true;
            }

            if (block is List)
            {
                foreach (var inner in  ((List) block).ListItems.SelectMany(listItem => listItem.Blocks))
                {
                    if (!Accept(inner)) return false;
                }

                return true;
            }

            throw new InvalidOperationException("Unknown block type: " + block.GetType());
        }
开发者ID:JackWangCUMT,项目名称:Plainion,代码行数:45,代码来源:FlowDocumentVisitor.cs

示例15: Clone

		private Block Clone(Block block)
		{
			var paragraph = block as Paragraph;
			if (paragraph != null)
			{
				var newParagraph = new Paragraph();
				if (DependencyPropertyHelper.GetValueSource(paragraph, Paragraph.PaddingProperty).BaseValueSource != BaseValueSource.Default)
					newParagraph.SetValue(Paragraph.PaddingProperty, paragraph.Padding);
				if (DependencyPropertyHelper.GetValueSource(paragraph, Paragraph.MarginProperty).BaseValueSource != BaseValueSource.Default)
					newParagraph.SetValue(Paragraph.MarginProperty, paragraph.Margin);
				if (DependencyPropertyHelper.GetValueSource(paragraph, Paragraph.TextAlignmentProperty).BaseValueSource != BaseValueSource.Default)
					newParagraph.SetValue(Paragraph.TextAlignmentProperty, paragraph.TextAlignment);
				CopyProperties(paragraph, newParagraph);
				foreach (var inline in paragraph.Inlines)
					newParagraph.Inlines.Add(Clone(inline));
				return newParagraph;
			}
			throw new NotSupportedException();
		}
开发者ID:xbadcode,项目名称:Rubezh,代码行数:19,代码来源:TableProvider.cs


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