private static CloudBuilder PrepareCloudBuilder( IWordsProvider wordsProvider, IStyleProvider styleProvider, ICloudLayouter layouter, ICloudSettingsProvider settingsProvider) { return(CloudBuilder.StartNew(layouter, settingsProvider) .WithWordsSize(word => TextRenderer.MeasureText(word, styleProvider.GetStyle(word).Font)) .WithWords(wordsProvider.GetWords())); }
public Bitmap Render() { var cloud = cloudBuilder.Build(); var bitmap = new Bitmap(settingsProvider.CloudSettings.Size.Width, settingsProvider.CloudSettings.Size.Height); using (var graphics = Graphics.FromImage(bitmap)) { graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; graphics.FillRectangle(new SolidBrush(styleProvider.Background), 0, 0, bitmap.Width, bitmap.Height); foreach (var tag in cloud.Tags) { var style = styleProvider.GetStyle(tag.Word); FillString(graphics, tag.Word, style.Font, new SolidBrush(style.Color), tag.Place); } } return(bitmap); }