示例#1
0
        private void AssertContainsIconColor(string folderPath, string iconName, RequiredColor expectedColor)
        {
            string  fullImagePath = Path.Combine(folderPath, iconName);
            SKColor actualColor   = TestColorHelper.GetAverageColor(fullImagePath);

            TestColorHelper.AssertSameColor(SKColor.Parse(expectedColor.ColorHexValue), actualColor);
        }
        private string HandlePostfixColor(IList <RequiredColor> requiredColors, string colorIconName, RequiredColor requiredColor)
        {
            if (requiredColors.Count > 1)
            {
                colorIconName = _imageRenamer.AddPostfix(colorIconName, $"_{requiredColor.ColorName}");
            }

            return(colorIconName);
        }
        private void AssertIconColor(string fullImagePath, RequiredColor requiredColor)
        {
            SKColor actualColor = TestColorHelper.GetAverageColor(fullImagePath);

            TestColorHelper.AssertSameColor(SKColor.Parse(requiredColor.ColorHexValue), actualColor);
        }
        private void CreateIcons(string[] resolutionFolders, string baseIconName,
                                 int requiredSize, FileInfo file, IList <Image> imagesInfo, string destinationPath, RequiredColor color = null)
        {
            string folderName = $"{Path.GetFileNameWithoutExtension(baseIconName)}.imageset";
            string folderPath = Path.Combine(destinationPath, folderName);


            EnsureDirectoryExists(folderPath);

            foreach (string scaleFactorString in resolutionFolders)
            {
                string finalIconName = _imageRenamer.AddPostfix(baseIconName, $"_{scaleFactorString}");

                string destinationIconPath = Path.Combine(folderPath, finalIconName);

                int size = (int)(requiredSize * ResNameAssociation[scaleFactorString]);

                _resizer.Resize(file.FullName, destinationIconPath, size, size, color?.ColorHexValue);

                Image image = new Image
                {
                    Appearances = new string[] { },
                    Scale       = scaleFactorString,
                    Idiom       = "universal",
                    FileName    = finalIconName,
                };
                imagesInfo.Add(image);
                string relativeIconPath = Path.Combine("Assets.xcassets", folderName, finalIconName);
                _projectFileUpdater.AddIcon(relativeIconPath);
            }

            CreateContentJson(folderPath, imagesInfo);
            string relativeContentFilePath = Path.Combine("Assets.xcassets", folderName, "Contents.json");

            _projectFileUpdater.AddIcon(relativeContentFilePath);
        }