protected void HandleBlocks(BlockCollection destBlockColl, TreeNode node, Inline nodeRun) { if (nodeRun != null) { destBlockColl.Add(new Paragraph(nodeRun)); } if (node.ChildCount > 0) { HtmlBlockExtractionVisitor blockVisitor = new HtmlBlockExtractionVisitor(TextChannel); foreach (TreeNode child in node.ListOfChildren) { child.AcceptDepthFirst(blockVisitor); } destBlockColl.AddRange(blockVisitor.ExtractedBlocks); } }
public static void AddRangeAndInsertRange() { var blockCollection = new BlockCollection<int>(); blockCollection.AddRange(new List<Block<int>> { new Block<int>(DefaultBlockSize) {1}, new Block<int>(DefaultBlockSize) {2} }); blockCollection.InsertRange(0, new List<Block<int>> { new Block<int>(DefaultBlockSize) {0} }); blockCollection.AddRange(new List<Block<int>> { new Block<int>(DefaultBlockSize) {3} }); blockCollection.InsertRange(4, new List<Block<int>> { new Block<int>(DefaultBlockSize) {4}, new Block<int>(DefaultBlockSize) {5} }); var checkArray = new[] { 0, 1, 2, 3, 4, 5 }; Assert.AreEqual(blockCollection.Count, checkArray.Length); for (int i = 0; i < checkArray.Length; i++) { Assert.AreEqual(blockCollection[i][0], checkArray[i]); } //Exceptions ExceptionManager.IsThrowActionException <ArgumentNullException, ICollection<Block<int>>> (blockCollection.AddRange, null); ExceptionManager.IsThrowActionException <ArgumentNullException, int, ICollection<Block<int>>> (blockCollection.InsertRange, 0, null); ExceptionManager.IsThrowActionException <ArgumentNullException, int, ICollection<Block<int>>> (blockCollection.InsertRange, -1, new Collection<Block<int>>()); ExceptionManager.IsThrowActionException <ArgumentNullException, int, ICollection<Block<int>>> (blockCollection.InsertRange, blockCollection.Count + 1, new Collection<Block<int>>()); }
public static void AddRangeAndInsertRange() { var blockCollection = new BlockCollection <int>(); blockCollection.AddRange(new List <Block <int> > { new Block <int>(DefaultBlockSize) { 1 }, new Block <int>(DefaultBlockSize) { 2 } }); blockCollection.InsertRange(0, new List <Block <int> > { new Block <int>(DefaultBlockSize) { 0 } }); blockCollection.AddRange(new List <Block <int> > { new Block <int>(DefaultBlockSize) { 3 } }); blockCollection.InsertRange(4, new List <Block <int> > { new Block <int>(DefaultBlockSize) { 4 }, new Block <int>(DefaultBlockSize) { 5 } }); var checkArray = new[] { 0, 1, 2, 3, 4, 5 }; Assert.AreEqual(blockCollection.Count, checkArray.Length); for (int i = 0; i < checkArray.Length; i++) { Assert.AreEqual(blockCollection[i][0], checkArray[i]); } //Exceptions ExceptionManager.IsThrowActionException <ArgumentNullException, ICollection <Block <int> > > (blockCollection.AddRange, null); ExceptionManager.IsThrowActionException <ArgumentNullException, int, ICollection <Block <int> > > (blockCollection.InsertRange, 0, null); ExceptionManager.IsThrowActionException <ArgumentNullException, int, ICollection <Block <int> > > (blockCollection.InsertRange, -1, new Collection <Block <int> >()); ExceptionManager.IsThrowActionException <ArgumentNullException, int, ICollection <Block <int> > > (blockCollection.InsertRange, blockCollection.Count + 1, new Collection <Block <int> >()); }
public static FlowDocument ReciboDeVenta(int códigoVenta) { FlowDocument flowDocument1 = (FlowDocument)null; using (EmpeñosDataContext empeñosDataContext = new EmpeñosDataContext()) { Venta venta = empeñosDataContext.Ventas.SingleOrDefault <Venta>((System.Linq.Expressions.Expression <Func <Venta, bool> >)(ven => ven.Código == códigoVenta)); if (venta != null) { Image image = new Image() { Stretch = Stretch.None }; BitmapImage bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.UriSource = new Uri(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location.ToString()), "Recursos\\Imágenes\\Logo.png"), UriKind.Absolute); bitmapImage.EndInit(); image.Source = (ImageSource)bitmapImage; FlowDocument flowDocument2 = new FlowDocument(); flowDocument2.PageWidth = Recibos.anchoPágina; Thickness thickness = new Thickness(Recibos.margenPágina); flowDocument2.PagePadding = thickness; double num1 = double.NaN; flowDocument2.PageHeight = num1; FontFamily fontFamily = new FontFamily("Arial"); flowDocument2.FontFamily = fontFamily; double num2 = 13.0; flowDocument2.FontSize = num2; flowDocument2.Blocks.Add((Block) new BlockUIContainer((UIElement)image)); BlockCollection blocks1 = flowDocument2.Blocks; Paragraph paragraph1 = new Paragraph(); int num3 = 2; paragraph1.TextAlignment = (TextAlignment)num3; paragraph1.Inlines.Add(new LineBreak()); paragraph1.Inlines.Add(new Run("Compra Venta")); paragraph1.Inlines.Add(new LineBreak()); InlineCollection inlines1 = paragraph1.Inlines; Run run1 = new Run("La Salvada"); double num4 = 18.0; run1.FontSize = num4; FontWeight bold1 = FontWeights.Bold; run1.FontWeight = bold1; inlines1.Add(run1); paragraph1.Inlines.Add(new LineBreak()); paragraph1.Inlines.Add(new Run("Porfirio Morales Mora")); paragraph1.Inlines.Add(new LineBreak()); paragraph1.Inlines.Add(new Run("Cédula: 2-0290-0936")); paragraph1.Inlines.Add(new LineBreak()); paragraph1.Inlines.Add(new LineBreak()); paragraph1.Inlines.Add(new Run("Tel: 2474-0641")); paragraph1.Inlines.Add(new LineBreak()); paragraph1.Inlines.Add(new Run("Aguas Zarcas - San Carlos")); paragraph1.Inlines.Add(new LineBreak()); paragraph1.Inlines.Add(new LineBreak()); InlineCollection inlines2 = paragraph1.Inlines; Run run2 = new Run("FACTURA DE VENTA NO. " + (object)venta.Código); FontWeight bold2 = FontWeights.Bold; run2.FontWeight = bold2; double num5 = 18.0; run2.FontSize = num5; inlines2.Add(run2); blocks1.Add((Block)paragraph1); BlockCollection blocks2 = flowDocument2.Blocks; Paragraph paragraph2 = new Paragraph(); int num6 = 0; paragraph2.TextAlignment = (TextAlignment)num6; paragraph2.Inlines.Add(new Run("Fecha : " + venta.Fecha.ToString("dd/MMM/yyyy"))); paragraph2.Inlines.Add(new LineBreak()); paragraph2.Inlines.Add(new Run("Cliente: " + venta.Cliente.NombreCompleto)); paragraph2.Inlines.Add(new LineBreak()); paragraph2.Inlines.Add(new Run("Cédula : " + venta.Código_Cliente)); paragraph2.Inlines.Add(new LineBreak()); paragraph2.Inlines.Add(new LineBreak()); InlineCollection inlines3 = paragraph2.Inlines; Line line = new Line(); int num7 = 1; line.Stretch = (Stretch)num7; SolidColorBrush solidColorBrush = new SolidColorBrush(Colors.Black); line.Stroke = (Brush)solidColorBrush; double num8 = 1.0; line.X2 = num8; inlines3.Add((UIElement)line); blocks2.Add((Block)paragraph2); flowDocument1 = flowDocument2; foreach (VentasDetalle ventasDetalle in venta.VentasDetalles) { BlockCollection blocks3 = flowDocument1.Blocks; Paragraph paragraph3 = new Paragraph(); int num9 = 0; paragraph3.TextAlignment = (TextAlignment)num9; paragraph3.Inlines.Add(new Run(ventasDetalle.Artículo.ToString())); blocks3.Add((Block)paragraph3); } BlockCollection blocks4 = flowDocument1.Blocks; Block[] blockArray = new Block[4]; int index1 = 0; Paragraph paragraph4 = new Paragraph(); int num10 = 1; paragraph4.TextAlignment = (TextAlignment)num10; if (venta.Impuesto > 0) { paragraph4.Inlines.Add(new Run("Sub-Total: ")); paragraph4.Inlines.Add(venta.VentasDetalles.Sum <VentasDetalle>((Func <VentasDetalle, int>)(det => det.Artículo.Precio.Value)).ToString("C0")); paragraph4.Inlines.Add(new LineBreak()); paragraph4.Inlines.Add(new Run("IVA: ")); paragraph4.Inlines.Add(venta.Impuesto.ToString("C0")); paragraph4.Inlines.Add(new LineBreak()); paragraph4.Inlines.Add(new Run("Monto Total: ")); paragraph4.Inlines.Add(venta.Total.ToString("C0")); } else { paragraph4.Inlines.Add(new Run("Monto Total: ")); paragraph4.Inlines.Add(venta.VentasDetalles.Sum <VentasDetalle>((Func <VentasDetalle, int>)(det => det.Artículo.Precio.Value)).ToString("C0")); } blockArray[index1] = (Block)paragraph4; int index2 = 1; Paragraph paragraph5 = new Paragraph(); int num11 = 3; paragraph5.TextAlignment = (TextAlignment)num11; double num12 = 10.0; paragraph5.FontSize = num12; paragraph5.Inlines.Add(new LineBreak()); paragraph5.Inlines.Add(new LineBreak()); paragraph5.Inlines.Add(new LineBreak()); paragraph5.Inlines.Add(new LineBreak()); paragraph5.Inlines.Add(new Run("1. Favor revisar los artículos antes de salir del local, no se aceptan devoluciones.")); blockArray[index2] = (Block)paragraph5; int index3 = 2; Paragraph paragraph6 = new Paragraph(); int num13 = 2; paragraph6.TextAlignment = (TextAlignment)num13; paragraph6.Inlines.Add(new Run("GRACIAS POR PREFERIRNOS.")); blockArray[index3] = (Block)paragraph6; int index4 = 3; Paragraph paragraph7 = new Paragraph(); int num14 = 2; paragraph7.TextAlignment = (TextAlignment)num14; paragraph7.Inlines.Add(new LineBreak()); paragraph7.Inlines.Add(new LineBreak()); blockArray[index4] = (Block)paragraph7; blocks4.AddRange((IEnumerable)blockArray); } } return(flowDocument1); }