Ejemplo n.º 1
0
        private string GetFilePath(IProject project, IProjectIcon icon, string name)
        {
            var root = project.GetRootDirectory();

            return((icon.Density == "drawable" || icon.Density == "drawable-v21")
                ? Path.Combine(root, RESOURCES_FOLDER, icon.Density, $"{name}.xml")
                : Path.Combine(root, RESOURCES_FOLDER, $"drawable-{icon.Density}", $"{name}.png"));
        }
        public async Task AddIcon(IProject project, IProjectIcon icon, string name)
        {
            // download icon
            var data = await icon.Get();

            // save file
            var root     = project.GetRootDirectory();
            var filename = $"{name}.png";
            var filepath = Path.Combine(root, filename);

            FileUtils.WriteAllBytes(data, filepath);
            // add to project
            project.AddFile(filepath, "Content");
            // save
            project.Save();
        }
Ejemplo n.º 3
0
        public async Task AddIcon(IProject project, IProjectIcon icon, string name)
        {
            // download icon
            var data = await icon.Get();

            // save file
            var root     = project.GetRootDirectory();
            var filename = $"{name}@{icon.Density}.png".Replace("@1x", "");
            var filepath = Path.Combine(root, RESOURCES_FOLDER, filename);

            FileUtils.WriteAllBytes(data, filepath);
            // add to project
            project.AddFile(filepath, "BundleResource");
            // save
            project.Save();
        }
Ejemplo n.º 4
0
        public async Task AddIcon(IProject project, IProjectIcon icon, string name)
        {
            // download icon
            var data = await icon.Get();

            // TEMP solution to https://github.com/interisti/vs-material-icons-generator/issues/17
            if (data == null)
            {
                return;
            }
            // save file
            var filepath = this.GetFilePath(project, icon, name);

            FileUtils.WriteAllBytes(data, filepath);
            // add to project
            project.AddFile(filepath, "AndroidResource");
            // save
            project.Save();
        }