Exemplo n.º 1
0
        public void Run()
        {
            var options = new Options();

            CommandLine.Parser.Default.ParseArguments(Args, options);
            var text          = reader.Read(options.InputFile);
            var words         = parser.Parse(text);
            var useFilters    = GetFiltersNames();
            var useConverters = GetConvertorsNames();

            cloudCreator.Create(words, options.MaxFontSize, options.MinFontSize, options.WordsCount, options.Font, useFilters, useConverters);
            var bitmap = visualizer.Vizualize(cloudCreator.RectanglesCloud, Color.AliceBlue);

            saver.Save(bitmap, options.OutputFile);
            Console.WriteLine($@"Image saved to {options.OutputFile}");
            Console.ReadKey();
        }
Exemplo n.º 2
0
        private void CreateCloud_Click(object sender, RoutedEventArgs e)
        {
            Canvas.Children.Clear();
            cloudCreator.Clear();
            var text  = GetText();
            var words = parser.Parse(text);

            cloudCreator.Create(words, settings.MaxFontSize, settings.MinFontSize, settings.WordsCount, settings.FontName, settings.UseFilters, settings.UseConverters);
            bitmap = visualizer.Vizualize(cloudCreator.RectanglesCloud, settings.BackgroundColor);
            var hBitmap    = bitmap.GetHbitmap();
            var cloudImage = new Image
            {
                Stretch          = Stretch.Uniform,
                StretchDirection = StretchDirection.Both
            };

            cloudImage.BeginInit();
            cloudImage.Width  = Canvas.ActualWidth;
            cloudImage.Height = Canvas.ActualHeight;
            cloudImage.Source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero,
                                                                                             Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
            cloudImage.EndInit();
            Canvas.Children.Add(cloudImage);
        }