Пример #1
0
        private bool CheckCorrectnessOfInput(int width, int height, Color[] colors, string fontFamily, out string error)
        {
            error = null;
            var firstRectangle = tagCloud.WordRectangles[0].Rectangle;
            var screen         = new Rectangle(0, 0, width, height);

            if (!CanTagCloudFitTheScreen(screen))
            {
                var tagCloudSize = CoveredArea().Size;
                error = "Tag cloud is too large for that resolution. Tag cloud size is " +
                        $"{tagCloudSize.Width}x{tagCloudSize.Height} and " +
                        $"center is {firstRectangle.Location.X + firstRectangle.Width / 2}," +
                        $"{firstRectangle.Location.Y + firstRectangle.Height / 2}";
                return(false);
            }

            var installedFonts = new InstalledFontCollection().Families.Select(family => family.Name);

            if (!installedFonts.Contains(fontFamily))
            {
                error = $"Font {fontFamily} is not supported";
                return(false);
            }

            if (colors == null || colors.Length == 0)
            {
                error = "Colors are not specified";
                return(false);
            }

            return(true);
        }