Exemple #1
0
        private void SetNuGetPackagesVersion()
        {
            StatusBar.DisplayMessage("Obtaining NuGet packages versions...");
            // Clear the cached versions, so for every new solution we create, we'll check Nuget for latest versions and then use that version
            // for all projects in the solution.
            NugetPackageVersionManager.ClearCache();

            StatusBar.DisplayMessage(" ");
        }
Exemple #2
0
        private async void AddToProject()
        {
            try
            {
                this.IsBusy = true;
                this.AddToProjectCommand.RaiseCanExecuteChanged();
                StatusBar.DisplayMessage("Downloading icons ...");

                var project    = VS.Project.GetActiveProject();
                var projectDir = VS.Project.GetProjectDirectory(project);

                var selectedTypes = new List <Type>();
                if (this.Mdpi.IsSelected)
                {
                    selectedTypes.Add(this.Mdpi.Item);
                }
                if (this.Hdpi.IsSelected)
                {
                    selectedTypes.Add(this.Hdpi.Item);
                }
                if (this.XHdpi.IsSelected)
                {
                    selectedTypes.Add(this.XHdpi.Item);
                }
                if (this.XXHdpi.IsSelected)
                {
                    selectedTypes.Add(this.XXHdpi.Item);
                }
                if (this.XXXHdpi.IsSelected)
                {
                    selectedTypes.Add(this.XXXHdpi.Item);
                }

                foreach (var type in selectedTypes)
                {
                    var color   = (this.Color.IsKnown) ? this.Color : Pallete.Black;
                    var iconUrl = this.GenerateUrl(this.Icon.Group.Id, this.Icon.Id,
                                                   type.Folder, color.Name, this.Size.Value);

                    byte[] icon;
                    using (var client = new HttpClient())
                        icon = await client.GetByteArrayAsync(iconUrl);

                    if (!this.Color.IsKnown)
                    {
                        icon = ColorUtils.ReplaceColor(icon, this.Color.Color);
                    }

                    var filepath = type.Destination(projectDir, this.Name);
                    FileUtils.WriteAllBytes(icon, filepath);
                    // add to project
                    VS.Project.AddFileToProject(project, filepath, "AndroidResource");
                }

                project.Save();
            }
            catch (System.Exception ex)
            {
                OutputPane.Output(ex.Message);
                OutputPane.Output(ex.StackTrace);
                OutputPane.Activate();
            }
            finally
            {
                StatusBar.Clear();
                this.IsBusy = false;
                this.AddToProjectCommand.RaiseCanExecuteChanged();
            }
        }