private async void AddToProject()
        {
            try
            {
                this.IsBusy = true;
                this.AddToProjectCommand.RaiseCanExecuteChanged();

                var project = Project.GetActiveProject();
                var icons   = this.Densities.Count == 0
                    ? new List <IProjectIcon>()
                {
                    this.Icon.Provider.CreateProjectIcon(this.Icon, this.Color, this.Size, null)
                }
                    : this.Densities.Where(x => x.IsSelected).Select(density =>
                                                                     { return(this.Icon.Provider.CreateProjectIcon(this.Icon, this.Color, this.Size, density.Item)); });

                foreach (var icon in icons)
                {
                    await this._projectManager.AddIcon(project, icon, this.Name);
                }
            }
            catch (System.Exception ex)
            {
                OutputPane.Output(ex.Message);
                OutputPane.Output(ex.StackTrace);
                OutputPane.Activate();
            }
            finally
            {
                this.IsBusy = false;
                this.AddToProjectCommand.RaiseCanExecuteChanged();
            }
        }
Exemple #2
0
 public void QueueProjectsForBuilding(ICollection <IVsProject> projects)
 {
     BuildContext(true);
     OutputPane.Clear();
     OutputPane.Activate();
     foreach (IVsProject p in projects)
     {
         _buildProjects.Add(p);
     }
     BuildNextProject();
 }
Exemple #3
0
        public async Task <IVsOutputWindowPane> GetOutputPaneAsync()
        {
            // this shows how to get VS Services
            // you can add ref to a DLL if needed, and add Using's if needed
            // if you're outputting to the OutputWindow, be aware that the OutputPanes are editor instances, which will
            // look like a leak as they accumulate data.
            Guid            guidPane     = new Guid("{CEEAB38D-8BC4-4675-9DFD-993BBE9996A5}");
            IVsOutputWindow outputWindow = await _asyncServiceProvider.GetServiceAsync(typeof(SVsOutputWindow)) as IVsOutputWindow;

            var crPane = outputWindow.CreatePane(
                ref guidPane,
                "PerfGraphVSIX",
                fInitVisible: 1,
                fClearWithSolution: 0);

            outputWindow.GetPane(ref guidPane, out var OutputPane);
            OutputPane.Activate();
            return(OutputPane);
        }
        public static void Show()
        {
            ThreadHelper.JoinableTaskFactory.Run(async() =>
            {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                IVsUIShell uiShell = await ServiceProvider.GetGlobalServiceAsync <SVsUIShell, IVsUIShell>();

                IVsWindowFrame outputWindowFrame = null;
                Guid outoutToolWindowGuid        = new Guid("{ 0x34e76e81, 0xee4a, 0x11d0, {0xae, 0x2e, 0x00, 0xa0, 0xc9, 0x0f, 0xff, 0xc3 } }");
                int hr = uiShell.FindToolWindow((uint)__VSFINDTOOLWIN.FTW_fForceCreate, ref outoutToolWindowGuid, out outputWindowFrame);

                if (ErrorHandler.Succeeded(hr) && outputWindowFrame != null)
                {
                    hr = outputWindowFrame.ShowNoActivate();
                    if (ErrorHandler.Succeeded(hr) && OutputPane != null)
                    {
                        OutputPane.Activate();
                    }
                }
            });
        }
Exemple #5
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();
            }
        }
Exemple #6
0
        /// <summary>
        ///     Called when the package is initialising.
        /// </summary>
        /// <param name="cancellationToken">
        ///     A <see cref="CancellationToken"/> that can be used to cancel the operation.
        /// </param>
        /// <param name="progress">
        ///     The initialisation progress-reporting facility.
        /// </param>
        /// <returns>
        ///     A <see cref="Task"/> representing package initialisation.
        /// </returns>
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            Trace.WriteLine("Enter ExtensionPackage.InitializeAsync.");

            cancellationToken.Register(
                () => InitCompletion.TrySetCanceled(cancellationToken)
                );

            await base.InitializeAsync(cancellationToken, progress);

            OutputPane = GetOutputPane(PackageOutputPaneGuid, "LSP Demo");
            OutputPane.Activate();

            await TaskScheduler.Default;

            try
            {
                Trace.WriteLine("Creating language service...");

                LanguageClient = new LanguageClient(Log.Logger, new ProcessStartInfo("dotnet")
                {
                    Arguments = @"""D:\Development\github\tintoy\msbuild-project-tools\out\language-server\MSBuildProjectTools.LanguageServer.Host.dll""",
                    //Arguments = @"""D:\Development\github\tintoy\dotnet-language-client\samples\Server\bin\Debug\netcoreapp2.0\Server.dll""",
                    Environment =
                    {
                        ["MSBUILD_PROJECT_TOOLS_DIR"]             = @"D:\Development\github\tintoy\msbuild-project-tools",
                        ["MSBUILD_PROJECT_TOOLS_SEQ_URL"]         = "http://localhost:5341/",
                        ["MSBUILD_PROJECT_TOOLS_SEQ_API_KEY"]     = "wxEURGakoVuXpIRXyMnt",
                        ["MSBUILD_PROJECT_TOOLS_VERBOSE_LOGGING"] = "1",
                        ["LSP_SEQ_URL"]         = "http://localhost:5341/",
                        ["LSP_SEQ_API_KEY"]     = "wxEURGakoVuXpIRXyMnt",
                        ["LSP_VERBOSE_LOGGING"] = "1"
                    }
                });
                LanguageClient.Window.OnLogMessage(LanguageClient_LogMessage);

                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                Trace.WriteLine("Retrieving solution directory...");

                IVsSolution solution = (IVsSolution)GetService(typeof(SVsSolution));

                int hr = solution.GetSolutionInfo(out string solutionDir, out _, out _);
                ErrorHandler.ThrowOnFailure(hr);

                Trace.WriteLine("Initialising language client...");

                await TaskScheduler.Default;

                await LanguageClient.Initialize(solutionDir);

                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                Trace.WriteLine("Language client initialised.");

                InitCompletion.TrySetResult(null);
            }
            catch (Exception languageClientError)
            {
                Trace.WriteLine(languageClientError);

                InitCompletion.TrySetException(languageClientError);
            }
            finally
            {
                Trace.WriteLine("Exit ExtensionPackage.InitializeAsync.");
            }
        }
Exemple #7
0
 private void ActiveOutputPane()
 {
     ThreadHelper.ThrowIfNotOnUIThread();
     OutputPane.Activate();
 }