public Result <Bitmap> DrawCloud(string pathToWordsFile, BaseCloudLayouter layouter, Size imageSize, FontFamily fontFamily, IColorSelector colorSelector, IWordPainter?wordPainter = null) { wordPainter ??= new SimpleWordPainter(); layouter.ClearLayout(); if (!File.Exists(pathToWordsFile)) { return(Result.Fail <Bitmap>($"File {pathToWordsFile} not found")); } var interestingWords = Result.Of(() => Path.GetExtension(pathToWordsFile)) .Then(ext => readers.First(x => x.Types.Contains(ext))) .Then(reader => reader.ReadAllLinesFromFile(pathToWordsFile)) .Then(WordPreparer.GetInterestingWords); var statistic = interestingWords.Then(words => WordPreparer.GetWordsStatistic(words)); return(statistic.Then(_ => DrawCloud( RectanglesForWordsCreator.GetReadyWords( statistic.GetValueOrThrow(), layouter, fontFamily, wordPainter), imageSize, colorSelector, wordPainter))); }
private void Button1_Click(object sender, System.EventArgs e) { IColorSelector ColorSelector = null; if (Buttons[0] == sender) { // Create color selector object. ColorSelector = new ColorSelectorClass(); // Open the selector dialog. if (ColorSelector.DoModal(this.Handle.ToInt32())) { // // A Color was selected (if the above method returned false, // this indicates that the user pressed Cancel). txtStartColor.BackColor = System.Drawing.ColorTranslator.FromOle(ColorSelector.Color.RGB); } UpdateRamp(); } else { ColorSelector = new ColorSelectorClass(); if (ColorSelector.DoModal(this.Handle.ToInt32())) txtEndColor.BackColor = System.Drawing.ColorTranslator.FromOle(ColorSelector.Color.RGB); UpdateRamp(); } }
private static Result <Bitmap> DrawCloud(IEnumerable <DrawingWord> words, Size imageSize, IColorSelector colorSelector, IWordPainter wordPainter) { var cloud = new Bitmap(imageSize.Width, imageSize.Height); var graphics = Graphics.FromImage(cloud); foreach (var word in words) { wordPainter.DrawWord(word.Word, word.Font, new SolidBrush(colorSelector.GetColor(word)), graphics, word.Location); } return(cloud); }
public Bitmap DrawCloud(string pathToWordsFile, BaseCloudLayouter layouter, Size imageSize, FontFamily fontFamily, IColorSelector colorSelector, IWordPainter?wordPainter = null) { wordPainter ??= new SimpleWordPainter(); layouter.ClearLayout(); if (!File.Exists(pathToWordsFile)) { throw new FileNotFoundException(); } var ext = Path.GetExtension(pathToWordsFile); var reader = readers.First(x => x.Types.Contains(ext)); var interestingWords = WordPreparer.GetInterestingWords(reader.ReadAllLinesFromFile(pathToWordsFile)); var statistic = WordPreparer.GetWordsStatistic(interestingWords); return(DrawCloud(RectanglesForWordsCreator.GetReadyWords(statistic, layouter, fontFamily, wordPainter), imageSize, colorSelector, wordPainter)); }
public RadColorDialogForm() { this.colorSelector = RadColorEditor.CreateColorSelectorInstance(); this.EnableAnalytics = false; this.InitializeComponent(); this.context = new RadThemeComponentBase.ThemeContext((Control)this); this.colorSelector.SelectedColor = Color.Red; this.colorSelector.OkButtonClicked += (ColorChangedEventHandler)((sender, args) => { this.DialogResult = DialogResult.OK; this.Close(); }); this.colorSelector.CancelButtonClicked += (ColorChangedEventHandler)((sender, args) => { this.DialogResult = DialogResult.Cancel; this.Close(); }); (this.colorSelector as Telerik.WinControls.UI.RadColorSelector).ColorChanged += new ColorChangedEventHandler(this.RadColorDialogForm_ColorChanged); this.ThemeNameChanged += new ThemeNameChangedEventHandler(this.RadColorDialogForm_ThemeNameChanged); }
public override Boolean Set(String property, IEnumerable <String> arguments) { switch (property.ToLower()) { case "t": case "type": IColorSelector proposedSelector = Selectors .FirstOrDefault(x => x.Name.Value == arguments.FirstOrDefault().ToLower()); if (proposedSelector == null) { return(false); } CurrentSelector = proposedSelector; return(true); default: return(false); } }
/// <summary> /// Creates instance of RadColorDialog class /// </summary> public RadColorDialogForm() { colorSelector = RadColorEditor.CreateColorSelectorInstance(); UserControl colorSelectorControl = colorSelector as UserControl; colorSelector.SelectedColor = System.Drawing.Color.Red; colorSelector.OkButtonClicked += delegate(object sender, ColorChangedEventArgs args) { this.DialogResult = DialogResult.OK; this.Close(); }; colorSelector.CancelButtonClicked += delegate(object sender, ColorChangedEventArgs args) { this.DialogResult = DialogResult.Cancel; this.Close(); }; colorSelectorControl.Dock = DockStyle.Fill; this.Controls.Add(colorSelectorControl); InitializeComponent(); }
// ColorSelector attached property accessors public static void SetColorSelector(UIElement element, IColorSelector value) { element.SetValue(ColorSelectorProperty, value); }
public TagCloudDrawer(TagCloudVizualizer vizualizer, ITagCloudLayouter layouter, IColorSelector colorSelector) { this.vizualizer = vizualizer; this.layouter = layouter; this.colorSelector = colorSelector; }
public Color AddColorSelector(IColorSelector colorSelector) { Selectors.Add(colorSelector); CurrentSelector = colorSelector; return(this); }
public Color(ITwitchClientManager client, TextWriter writer) : base(client, writer) { Selectors = new List <IColorSelector>(); CurrentSelector = Selectors.FirstOrDefault(); }
public WordLayouter(FontFamily family, IPointsLayout pointsLayout, IColorSelector colorSelector) { this.family = family; this.pointsLayout = pointsLayout; this.colorSelector = colorSelector; }
public TreemapParameters WithColor(IColorSelector color) { Color = color; return(this); }
public TreemapParameters WithColor(IColorSelector color) { Color = color; return this; }
protected void BuildLegend(ParametersBase parameters) { LegendTitle = parameters.LegendTitle; IColorSelector color = parameters.Color; if (String.IsNullOrEmpty(LegendTitle)) { LegendTitle = "Color"; } if (LegendTitle.Length > 15) { LegendTitle = LegendTitle.Substring(0, 13) + "..."; } float maxWidth = 0f; List <string> legendTexts = new List <string>(); if (color is ColorGradient) { ColorGradient gradient = color as ColorGradient; legendTexts = gradient.Stops.Select(s => parameters.LegendTextFormater.Format(s.Value)).ToList(); } else if (color is ColorPalette) { ColorPalette palette = color as ColorPalette; legendTexts = palette.Colors.Keys.Select(s => parameters.LegendTextFormater.Format(s)).ToList(); } var sizes = legendTexts.Select(t => DefaultFont.RenderText(t)); maxWidth = sizes.Max(s => s.Width); LegendTextHeight = sizes.Max(s => s.Height); //Legend title var titleSize = DefaultFontBold.RenderText(LegendTitle); LegendTitleWidth = titleSize.Width; LegendTitleHeight = titleSize.Height; if (parameters.LegendPosition == Position.Right || parameters.LegendPosition == Position.Left) { maxWidth = Math.Max(maxWidth, (float)(LegendTitleWidth - LegendThickness - SmallMargin)); } switch (parameters.LegendPosition) { case Position.Left: case Position.Right: PlotArea = PlotArea.WithWidth(PlotArea.Width - Margin - LegendThickness - SmallMargin - maxWidth); LegendTitleArea = new Rect( PlotArea.Left + PlotArea.Width + Margin, PlotArea.Top, LegendTitleWidth, LegendTitleHeight); LegendArea = new Rect( PlotArea.Left + PlotArea.Width + Margin, PlotArea.Top + LegendTitleHeight + SmallMargin, LegendThickness, Math.Max(PlotArea.Height - LegendTitleHeight - SmallMargin, 0)); break; case Position.Top: case Position.Bottom: PlotArea = PlotArea.WithHeight(PlotArea.Height - Margin - LegendTitleHeight - SmallMargin - LegendThickness); if (color is ColorGradient) { PlotArea = PlotArea.WithHeight(PlotArea.Height - SmallMargin - LegendTextHeight); } LegendTitleArea = new Rect( Math.Max(PlotArea.Left + (PlotArea.Width - LegendTitleWidth) / 2, 0), PlotArea.Top + PlotArea.Height + Margin, LegendTitleWidth, LegendTitleHeight); LegendArea = new Rect( PlotArea.Left, PlotArea.Top + PlotArea.Height + Margin + LegendTitleHeight + SmallMargin, PlotArea.Width, LegendThickness); break; default: break; } }
public LoggerBuilder AddColorSelector(IColorSelector selector) { _colorSelector = x => selector.GetColor(x); return(this); }