public static bool ExportAnnonce(IAnnonceContent annonce) { _wdDocument.AttachedTemplate.BuildingBlockEntries("RowTemplate") .Insert(_wdDocument.Paragraphs.Last.Range, true); dynamic wdTable = _wdDocument.Tables[1]; dynamic firstCellRange = _wdDocument.Tables[1].Rows.Last.Cells[1].Range; //Цена firstCellRange.Paragraphs[1].Range.Text = string.Format("{0:N2} руб.{1}", annonce.Price, Environment.NewLine).Trim(' '); //Заголовок firstCellRange.Paragraphs[2].Range.Text = string.Format("{0}{1}", annonce.Title, Environment.NewLine).Trim(' '); //Описание firstCellRange.Paragraphs[3].Range.Text = string.Format("{0}{1}", annonce.Description, Environment.NewLine).Trim(); //Изображение if (annonce.Image == null) { wdTable.Rows.Last.Cells[2].Range.Text = "Нет изображения"; return(true); } wdTable.Rows.Last.Cells[2].Range.Text = ""; var imgFileName = Path.GetTempFileName() + ".jpg"; using (var bmp = new Bitmap(annonce.Image)) { bmp.Save(imgFileName, ImageFormat.Jpeg); } wdTable.Rows.Last.Cells[2].Range.InlineShapes.AddPicture(imgFileName); File.Delete(imgFileName); return(true); }
public AnnoncePresenter(IAnnonceContent annonce) : this() { label1.DataBindings.Add(new Binding("Text", this, "Id", true, DataSourceUpdateMode.OnPropertyChanged)); pictureBox1.Image = annonce.Image; priceLabel.Text = annonce.Price.Equals(0) ? "" : annonce.Price.ToString("##.### руб."); descriptionLabel.Text = annonce.Description; titleLabel.Text = annonce.Title; Id = ++Number; }
public async void LoadAnnonces() { counter = 0; foreach (HtmlNode annonceNode in AnnonceNodes) { AnnonceNode = annonceNode; IAnnonceContent content = await Task <IAnnonceContent> .Factory.StartNew(GetContent); Annonces.Add(content); AnnonceParsed?.Invoke(null, new AnnonceParsedEventArgs(content, AnnoncesParced + 1, TotalAnnonces)); AnnoncesParced++; } }
public AnnonceParsedEventArgs(IAnnonceContent content, int number, int total) { Content = content; Number = number; TotalAnnonces = total; }