/// <summary> /// Imprime item /// </summary> protected virtual void ImprimirItem(Graphics g, Foto foto, PointF posiçãoAtual, ItensImpressão itens) { float y = posiçãoAtual.Y; // Desenhar foto if ((itens & ItensImpressão.Foto) > 0) { SizeF tamanho; if (foto.Imagem.Width / (double)foto.Imagem.Height >= fotoDimensões.Width / (double)fotoDimensões.Height) tamanho = new SizeF(fotoDimensões.Width, (float)((float) fotoDimensões.Width * (float) foto.Imagem.Height)/(float)foto.Imagem.Width); else tamanho = new SizeF((float)((float) foto.Imagem.Width * (float) fotoDimensões.Height / (float) foto.Imagem.Height), fotoDimensões.Height); #if DEBUG if (tamanho.Width > fotoDimensões.Width) throw new Exception("Largura maior que tamanho máximo."); if (tamanho.Height > fotoDimensões.Height) throw new Exception("Altura maior que tamanho máximo."); #endif g.DrawImage(foto.Imagem, posiçãoAtual.X + (fotoDimensões.Width - tamanho.Width) / 2, posiçãoAtual.Y + (fotoDimensões.Height - tamanho.Height) / 2, tamanho.Width, tamanho.Height); y += fotoDimensões.Height; y += espaçamentoTexto; } Entidades.Mercadoria.Mercadoria mercadoria = null; if ((itens & (ItensImpressão.RequerMercadoria | ItensImpressão.Referência)) > 0) mercadoria = foto.ObterMercadoria(); // Desenhar referência if ((itens & ItensImpressão.Referência) > 0) DesenharStringCentralizada(g, foto.ReferênciaFormatada + "-" + mercadoria.Dígito.ToString(), posiçãoAtual.X, ref y, itemDimensões.Width); if ((itens & ItensImpressão.FaixaGrupo) > 0) { string str = ""; if (mercadoria.Grupo.HasValue) str = string.Format("{0}-{1}", mercadoria.Faixa, mercadoria.Grupo.Value); else str = mercadoria.Faixa; if ((itens & ItensImpressão.Peso) > 0 && mercadoria.DePeso) { if (str.Length > 0) str += " - "; str += string.Format("9{0:###0.0}9", mercadoria.Peso); } if ((itens & ItensImpressão.Índice) > 0) { if (str.Length > 0) str += " - "; str += string.Format(" {0:###,###,##0.00}", mercadoria.ÍndiceArredondado); } DesenharStringCentralizada(g, str, posiçãoAtual.X, ref y, itemDimensões.Width); } else if ((itens & ItensImpressão.Peso) > 0 && mercadoria.DePeso) { string str; str = string.Format("9{0:###0.0}9", mercadoria.Peso); if (str.Length > 0) str += " - "; if ((itens & ItensImpressão.Índice) > 0) { if (str.Length > 0) str += " - "; str += string.Format(" {0:###,###,##0.00}", mercadoria.ÍndiceArredondado); } DesenharStringCentralizada(g, str, posiçãoAtual.X, ref y, itemDimensões.Width); } else if ((itens & ItensImpressão.Índice) > 0 && mercadoria.ÍndiceArredondado > 0) { DesenharStringCentralizada(g, string.Format("{0:###,###,##0.00}", mercadoria.ÍndiceArredondado), posiçãoAtual.X, ref y, itemDimensões.Width); } // Desenhar descrição if ((itens & ItensImpressão.Descrição) > 0) DesenharStringCentralizada(g, foto.Descrição, posiçãoAtual.X, ref y, itemDimensões.Width); if ((itens & ItensImpressão.DescriçãoMercadoria) > 0) { string str = mercadoria.Descrição.Trim(); bool formatar = true; foreach (char c in str) formatar &= !char.IsLower(c); if (formatar) str = Apresentação.Pessoa.FormatadorNome.FormatarTexto(str); DesenharStringCentralizada(g, str, posiçãoAtual.X, ref y, itemDimensões.Width); } // Desenhar fornecedor MercadoriaFornecedor fornecedor = Entidades.Mercadoria.MercadoriaFornecedor.ObterFornecedor(mercadoria.ReferênciaNumérica); if (fornecedor != null) { if ((itens & ItensImpressão.Fornecedor) > 0) DesenharStringCentralizada(g, (fornecedor != null ? fornecedor.FornecedorCódigo.ToString() : ""), posiçãoAtual.X, ref y, itemDimensões.Width); if ((itens & ItensImpressão.FornecedorReferência) > 0) DesenharStringCentralizada(g, (!String.IsNullOrEmpty(fornecedor.ReferênciaFornecedorComFFL) ? fornecedor.ReferênciaFornecedorComFFL : ""), posiçãoAtual.X, ref y, itemDimensões.Width); } }