private void MenuItemClick(object sender, EventArgs e)
        {
            try
            {
                uint cookie = 0;
                _statusBar.Progress(ref cookie, 1, "", 0, 0);
                _statusBar.Animation(1, ref _sortIcon);
                var selectedResxFilePaths = GetSelectedResxFilePaths().ToList();
                for (var i = 0; i < selectedResxFilePaths.Count; i++)
                {
                    _resxSorter.
                    Sort(XDocument.Load(selectedResxFilePaths[i])).
                    Save(selectedResxFilePaths[i]);

                    _statusBar.Progress(ref cookie, 1, "", (uint)i + 1, (uint)selectedResxFilePaths.Count);
                    _statusBar.SetText(string.Format("Sorting {0} out of {1} resx files...", i + 1,
                                                     selectedResxFilePaths.Count));
                }

                WriteToOutput(string.Join(Environment.NewLine,
                                          new[] { string.Format("Sorted {0} resx files:", selectedResxFilePaths.Count()) }.Concat(
                                              selectedResxFilePaths)));
                _statusBar.Progress(ref cookie, 0, "", 0, 0);
                _statusBar.Animation(0, ref _sortIcon);
                SetStatusBar("Resx sort succeeded");
            }
            catch (Exception exception)
            {
                WriteToOutput("Failed to sort resx files: {0}", exception.Message);
                SetStatusBar("Failed to sort resx files");
            }
        }
Beispiel #2
0
        static public void Run(IServiceProvider serviceProvider, IVsStatusbar statusbar)
        {
            var dte      = (DTE2)serviceProvider.GetService(typeof(DTE));
            var projects = dte.Solution.Projects;

            uint   cookie = 0;
            object icon   = (short)Microsoft.VisualStudio.Shell.Interop.Constants.SBAI_Build;

            // Initialize the progress bar.
            statusbar.Progress(ref cookie, 1, "", 0, 0);
            statusbar.Animation(1, ref icon);

            for (uint i = 1, n = (uint)projects.Count; i <= n; ++i)
            {
                var project = projects.Item(i);
                statusbar.Progress(ref cookie, 1, "", i + 1, n);
                statusbar.SetText(string.Format("Converting {0}", project.Name));

                ProjectConverter.Run(serviceProvider, project);
            }

            // Clear the progress bar.
            statusbar.Animation(0, ref icon);
            statusbar.Progress(ref cookie, 0, "", 0, 0);
            statusbar.FreezeOutput(0);
            statusbar.Clear();
        }
        private void PrepareStatusbar(out object icon)
        {
            icon = (short)InteropConstants.SBAI_Save;
            var tmpIcon = icon;

            ThreadHelper.JoinableTaskFactory.Run(async() =>
            {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
                // You're now on the UI thread.

                try
                {
                    _statusBar.IsFrozen(out var frozen);

                    if (frozen != 0)
                    {
                        return;
                    }

                    _statusBar.SetText("Rendering template...");
                    _statusBar.Animation(1, ref tmpIcon);
                }
                catch (Exception exception)
                {
                    Log.Debug("Failed to prepare statusbar: {0}", exception.Message);
                }
            });
        }
Beispiel #4
0
        /// <summary>
        /// Override this method to define the async command body te execute on the
        /// background thread
        /// </summary>
        protected override async Task ExecuteAsync()
        {
            IVsStatusbar statusBar = (IVsStatusbar)await SpectNetPackage.Default.GetServiceAsync(typeof(SVsStatusbar));

            statusBar.IsFrozen(out int frozen);
            if (frozen != 0)
            {
                statusBar.FreezeOutput(0);
            }
            statusBar.SetText("Building ZX Spectrum code");
            statusBar.FreezeOutput(1);
            object icon = (short)Constants.SBAI_Build;

            statusBar.Animation(1, ref icon);
            try
            {
                CompileSuccess = await Task.Run(() => CompileCode());
            }
            catch (Exception ex)
            {
                CompileException = ex;
            }
            finally
            {
                statusBar.FreezeOutput(0);
                statusBar.Animation(0, ref icon);
                statusBar.Clear();
            }
        }
        /// <summary>
        /// Starts indeterminate animation with given icon
        /// </summary>
        public static void StartIndeterminate(Microsoft.VisualStudio.Shell.Interop.Constants icon)
        {
            CheckInstance();
            object i = (short)icon;

            try {
                statusBar.Animation(1, ref i);
            } catch { }
        }
Beispiel #6
0
        private void ShowIndterminateProgress(string displayText)
        {
            // Display the animated Visual Studio icon in the Animation region.
            if (_animationIcon == null)
            {
                _animationIcon = (short)Constants.SBAI_Find;
                _statusBar.Animation(1, ref _animationIcon);
            }

            _statusBar.SetText(displayText);
        }
Beispiel #7
0
        private void CompileAllCommandCallback(object sender, EventArgs args)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            Interlocked.Exchange(ref package.IsCompiling, 1);

            var projs    = new List <Project>();
            var selitems = package.dte2.ToolWindows.SolutionExplorer.UIHierarchyItems;

            if (selitems != null)
            {
                foreach (UIHierarchyItem uiitem in selitems)
                {
                    if (uiitem != null)
                    {
                        var proj = uiitem.Object as Project;
                        if (proj != null)
                        {
                            projs.Add(proj);
                        }
                    }
                }
            }

            UPPCompiler.RaiseReported(null, new CompilerReportedEventArgs(null));

            package.JoinableTaskFactory.RunAsyncAsVsTask(VsTaskRunContext.UIThreadBackgroundPriority,
                                                         async cancellationToken =>
            {
                await package.JoinableTaskFactory.SwitchToMainThreadAsync();

                IVsStatusbar statusBar = (IVsStatusbar)package.GetServiceAsync(typeof(SVsStatusbar));

                object icon = (short)Microsoft.VisualStudio.Shell.Interop.Constants.SBAI_Build;

                statusBar?.Animation(1, ref icon);

                var tasks = package.Compile(projs);

                await TaskScheduler.Default;

                await Task.WhenAll(tasks.Select(vtask => vtask.WaitForFinishedAsync()));

                await package.JoinableTaskFactory.SwitchToMainThreadAsync();

                statusBar?.Animation(0, ref icon);

                Interlocked.Exchange(ref package.IsCompiling, 0);

                return(VSConstants.S_OK);
            });
        }
        //<Snippet1>
        void AnimationExample()
        {
            IVsStatusbar statusBar =
                (IVsStatusbar)GetService(typeof(SVsStatusbar));
            object icon =
                (short)Microsoft.VisualStudio.Shell.Interop.Constants.SBAI_General;

            // Display the animated Visual Studio icon in the Animation region.
            statusBar.Animation(1, ref icon);

            System.Windows.Forms.MessageBox.Show(
                "Click OK to end status bar animation.");

            statusBar.Animation(0, ref icon);
        }
Beispiel #9
0
        public override void StopProgressMessage(string message)
        {
            // stock general animation icon
            object icon = (short)Microsoft.VisualStudio.Shell.Interop.Constants.SBAI_General;

            try
            {
                // Make sure the status bar is not frozen
                int frozen;
                _statusBar.IsFrozen(out frozen);

                if (frozen != 0)
                {
                    _statusBar.FreezeOutput(0);
                }


                if (String.IsNullOrEmpty(message))
                {
                    _statusBar.SetText(message);
                }
                else
                {
                    _statusBar.Clear();
                }

                // stop the animation
                _statusBar?.Animation(0, ref icon);
            }
            catch (InvalidOperationException)
            {
            }
        }
Beispiel #10
0
        public static void StopProgressMessage(string message = null)
        {
            ThreadHelper.JoinableTaskFactory.RunAsync(async() =>
            {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                // stock general animation icon
                object icon = (short)Constants.SBAI_General;

                // Make sure the status bar is not frozen
                int frozen;
                _statusBar.IsFrozen(out frozen);

                if (frozen != 0)
                {
                    _statusBar.FreezeOutput(0);
                }


                if (String.IsNullOrEmpty(message))
                {
                    _statusBar.SetText(message);
                }
                else
                {
                    _statusBar.Clear();
                }

                // stop the animation
                _statusBar?.Animation(0, ref icon);
            });
        }
Beispiel #11
0
        public static void StartProgressMessage(string message)
        {
            ThreadHelper.JoinableTaskFactory.RunAsync(async() =>
            {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                // stock general animation icon
                object icon = (short)Constants.SBAI_General;


                // Make sure the status bar is not frozen
                int frozen;
                _statusBar.IsFrozen(out frozen);

                if (frozen != 0)
                {
                    _statusBar.FreezeOutput(0);
                }

                _statusBar.SetText(message);

                // start icon animation
                _statusBar.Animation(1, ref icon);
            });
        }
Beispiel #12
0
 public void Dispose(string?message = null, short?icon = null)
 {
     Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
     // Stop the animation.
     _animationIcon = icon ?? DEFAULT_ICON;
     _statusBar.Animation(0, ref _animationIcon);
     _message.Dispose(message);
 }
Beispiel #13
0
        void OnCompilationEnd(string status)
        {
            IVsStatusbar statusBar = (IVsStatusbar)GetService(typeof(SVsStatusbar));
            object       icon      = (short)Constants.SBAI_Build;

            statusBar.Animation(0, ref icon);
            statusBar.SetText(status);
            m_commands[PackageGuids.CommandCompileActive].Enabled = true;
        }
Beispiel #14
0
        private void PrepareStatusbar(out uint cookie, out object icon)
        {
            cookie = 0;
            icon   = (short)InteropConstants.SBAI_Save;

            int frozen;

            statusBar.IsFrozen(out frozen);

            if (frozen != 0)
            {
                return;
            }

            statusBar.Progress(ref cookie, 1, string.Empty, 0, 0);
            statusBar.SetText("Rendering template...");
            statusBar.Animation(1, ref icon);
        }
Beispiel #15
0
        public void Notify(string message, bool showSpinner)
        {
            RunOnUIThread.Run(() =>
            {
                object icon = (short)Microsoft.VisualStudio.Shell.Interop.Constants.SBAI_General;
                vsStatusBar.Animation(showSpinner ? 1 : 0, ref icon);

                vsStatusBar.SetText(message);
            });
        }
Beispiel #16
0
        void OnCompilationStart()
        {
            IVsStatusbar statusBar = (IVsStatusbar)GetService(typeof(SVsStatusbar));

            statusBar.SetText("Asm compilation started.");
            object icon = (short)Constants.SBAI_Build;

            statusBar.Animation(1, ref icon);
            m_commands[PackageGuids.CommandCompileActive].Enabled = false;
        }
        public static void Animation(vsStatusAnimation aAnimation, int aEnableAnimation)
        {
            DispatcherHandler.BeginInvoke(() =>
            {
                // Use the standard Visual Studio icon for building.
                object icon = (short)Microsoft.VisualStudio.Shell.Interop.Constants.SBAI_Build;

                // Display the icon in the Animation region.
                mStatusBar.Animation(aEnableAnimation, ref icon);
            });
        }
Beispiel #18
0
 private static bool TrySetTypingsLoadingStatusBar(IVsStatusbar statusBar, object icon) {
     if (statusBar != null && !IsStatusBarFrozen(statusBar)) {
         statusBar.SetText(SR.GetString(SR.StatusTypingsLoading));
         statusBar.Animation(1, ref icon);
         if (ErrorHandler.Succeeded(statusBar.FreezeOutput(1))) {
             return true;
         }
         Debug.Fail("Failed to freeze typings status bar");
     }
     return false;
 }
Beispiel #19
0
        private static void TrySetTypingsLoadedStatusBar(IVsStatusbar statusBar, object icon, bool statusSetSuccess) {
            if (statusBar != null && (statusSetSuccess || !IsStatusBarFrozen(statusBar))) {
                if (!ErrorHandler.Succeeded(statusBar.FreezeOutput(0))) {
                    Debug.Fail("Failed to unfreeze typings status bar");
                    return;
                }

                statusBar.Animation(0, ref icon);
                statusBar.SetText(SR.GetString(SR.StatusTypingsLoaded));
            }
        }
Beispiel #20
0
        public Animation(IVsStatusbar statusBar, string message, short?icon = null)
        {
            _statusBar = statusBar;
            _message   = new Message(statusBar, message);
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();

            _animationIcon = icon ?? DEFAULT_ICON;
            // Display the icon in the Animation region.

            _statusBar.Animation(1, ref _animationIcon);
        }
Beispiel #21
0
            public override void Dispose()
            {
                _taskFactory.Run(async() =>
                {
                    await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                    StatusBar.Animation(0, ref icon);
                    StatusBar.Progress(ref cookie, 0, "", 0, 0);
                    StatusBar.FreezeOutput(0);
                    StatusBar.Clear();
                });
            }
            public override void Dispose()
            {
                _taskFactory.Run(async() =>
                {
                    await _taskFactory.SwitchToMainThreadAsync();

                    _statusBar.Animation(0, ref Icon);
                    _statusBar.Progress(ref _cookie, 0, "", 0, 0);
                    _statusBar.FreezeOutput(0);
                    _statusBar.Clear();
                });
            }
Beispiel #23
0
        private void PrepareStatusbar(out object icon)
        {
            icon = (short)InteropConstants.SBAI_Save;

            try
            {
                int frozen;
                _statusBar.IsFrozen(out frozen);

                if (frozen != 0)
                {
                    return;
                }

                _statusBar.SetText("Rendering template...");
                _statusBar.Animation(1, ref icon);
            }
            catch (Exception exception)
            {
                Log.Debug("Failed to prepare statusbar: {0}", exception.Message);
            }
        }
Beispiel #24
0
        private void PrepareStatusbar(out uint cookie, out object icon)
        {
            cookie = 0;
            icon   = (short)InteropConstants.SBAI_Save;

            try
            {
                int frozen;
                statusBar.IsFrozen(out frozen);

                if (frozen != 0)
                {
                    return;
                }

                statusBar.Progress(ref cookie, 1, string.Empty, 0, 0);
                statusBar.SetText("Rendering template...");
                statusBar.Animation(1, ref icon);
            }
            catch (Exception exception)
            {
                Log.Debug("Failed to prepare statusbar: {0}", exception.Message);
            }
        }
Beispiel #25
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        public void MenuItemCallback(object sender, EventArgs e)
        {
            IVsStatusbar statusBar = (IVsStatusbar)ServiceProvider.GetService(typeof(SVsStatusbar));
            uint         cookie    = 0;
            string       label     = "SILVERPROD Best practis analysing";

            object icon = (short)Microsoft.VisualStudio.Shell.Interop.Constants.SBAI_Build;

            // Display the icon in the Animation region.
            statusBar.Animation(1, ref icon);
            statusBar.SetText(label);
            statusBar.Progress(ref cookie, 1, label, 5, 10);

            DTE     dte                    = Package.GetGlobalService(typeof(SDTE)) as DTE;
            Project activeProject          = null;
            Array   activeSolutionProjects = GetActiveProject(dte);
            Boolean error                  = false;
            String  Spd                    = Properties.ModelList.Default["Trigramme"].ToString();

            if (activeSolutionProjects != null && activeSolutionProjects.Length > 0)
            {
                activeProject = activeSolutionProjects.GetValue(0) as Project;


                errorListProvider.Tasks.Clear();
                SPD spd = new SPD();
                spd.ShowDialog();
                error = AnalyserRules.TryByProjectItem(activeProject.ProjectItems, errorListProvider, Spd, dte, activeProject.FullName);
                errorListProvider.Show();
                TeamServeceConnect.getListWorkitem(TeamServeceConnect.getURI(dte.Solution.FullName));
                if (!error)
                {
                    if (TeamServeceConnect.getURI(dte.Solution.FullName) != "")
                    {
                        string _ret = "The solution is not configured with DevOps/VSTS";
                        AnalyserRules.addMessageErrorList(dte, errorListProvider, _ret, dte.Solution.FullName, "", 0, 0);
                    }
                    if (TeamServeceConnect.getListTeamProjects(dte.Solution.FullName).Contains(activeProject.FullName.Split('\\')[activeProject.FullName.Split('\\').Length - 1].Replace(".rnrproj", "")))
                    {
                        System.Windows.Forms.MessageBox.Show("true");
                    }
                    System.Windows.Forms.MessageBox.Show(TeamServeceConnect.getListTeamProjects(dte.Solution.FullName)[TeamServeceConnect.getListTeamProjects(dte.Solution.FullName).IndexOf(activeProject.FullName.Split('\\')[activeProject.FullName.Split('\\').Length - 1].Replace(".rnrproj", ""))].ToString());
                }
            }
            label = "SILVERPROD Best practis analysed";
            statusBar.Progress(ref cookie, 0, "", 0, 0);
            statusBar.SetText(label);
        }
Beispiel #26
0
        public void ClearStatusMessage()
        {
            // Make sure the status bar is not frozen
            int frozen;

            StatusBar.IsFrozen(out frozen);

            if (frozen != 0)
            {
                StatusBar.FreezeOutput(0);
            }

            StatusBar.SetText("");
            StatusBar.Animation(0, _animationObject);
            //StatusBar.Clear();
        }
Beispiel #27
0
        public static async Task EndAnimationAsync(StatusAnimation animation)
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            try
            {
                IVsStatusbar statusBar = await GetServiceAsync();

                statusBar.FreezeOutput(0);
                statusBar.Animation(0, animation);
                statusBar.FreezeOutput(1);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
            }
        }
Beispiel #28
0
        /// <summary>Ends the animation on the status bar.</summary>
        public async Task EndAnimationAsync(StatusAnimation animation)
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            try
            {
                IVsStatusbar statusBar = await GetServiceAsync();

                statusBar.FreezeOutput(0);
                statusBar.Animation(0, animation);
                statusBar.FreezeOutput(1);
            }
            catch (Exception ex)
            {
                await ex.LogAsync();
            }
        }
        /// <summary>Ends the animation on the status bar.</summary>
        public async Task EndAnimationAsync(StatusAnimation animation)
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            try
            {
                IVsStatusbar statusBar = await VS.Services.GetStatusBarAsync();

                object icon = (short)animation;

                statusBar.FreezeOutput(0);
                statusBar.Animation(0, ref icon);
                statusBar.FreezeOutput(1);
            }
            catch (Exception ex)
            {
                await ex.LogAsync();
            }
        }
        private static void TrySetTypingsLoadedStatusBar(IVsStatusbar statusBar, object icon, bool statusSetSuccess) {
            if (statusBar != null && (statusSetSuccess || !IsStatusBarFrozen(statusBar))) {
                if (!ErrorHandler.Succeeded(statusBar.FreezeOutput(0))) {
                    Debug.Fail("Failed to unfreeze typings status bar");
                    return;
                }

                statusBar.Animation(0, ref icon);
                statusBar.SetText(Resources.StatusTypingsLoaded);
            }
        }
 private static bool TrySetTypingsLoadingStatusBar(IVsStatusbar statusBar, object icon) {
     if (statusBar != null && !IsStatusBarFrozen(statusBar)) {
         statusBar.SetText(Resources.StatusTypingsLoading);
         statusBar.Animation(1, ref icon);
         if (ErrorHandler.Succeeded(statusBar.FreezeOutput(1))) {
             return true;
         }
         Debug.Fail("Failed to freeze typings status bar");
     }
     return false;
 }
        private void StopAnimation()
        {
            IVsStatusbar statusBar = (IVsStatusbar)_package.GetService <SVsStatusbar>();

            statusBar.Animation(0, ref icon);
        }