protected override void OnValidationBeginning(ValidationContext context)
 {
     if (context != null)
     {
         if (context.Categories != ValidationCategories.Load &&
             context.Categories != ValidationCategories.Open)
         {
             Logger.Clear();
         }
         Logger.SuspendRefresh();
     }
     status = new VSStatusBar(serviceProvider);
     status.ShowMessage(Properties.Resources.ValidationProgressMessage);
 }
예제 #2
0
 private void GenerateArtifacts(IArtifactLinkContainer links)
 {
     if (links != null)
     {
         if (links != null &&
             links.ArtifactLinks != null)
         {
             VSStatusBar status = new VSStatusBar(this.ServiceProvider);
             try
             {
                 ICodeGenerationService codeGenerationService = this.ServiceProvider.GetService(typeof(ICodeGenerationService)) as ICodeGenerationService;
                 int generatedObjects = codeGenerationService.GenerateArtifacts(links.ArtifactLinks,
                                                                                l => { status.ShowMessage(l.ItemPath); });
                 Logger.Write(
                     string.Format(CultureInfo.CurrentCulture, Properties.Resources.GeneratedObjects, generatedObjects),
                     System.Diagnostics.TraceEventType.Information);
             }
             finally
             {
                 status.Clear();
             }
         }
     }
 }
예제 #3
0
        private static void ShowStatus(ModelElement element)
        {
            VSStatusBar status = new VSStatusBar(element.Store);

            status.ShowMessage(string.Format(CultureInfo.CurrentCulture, Resources.ValidationStatusProgressMessage, ModelElementToString(element)));
        }
예제 #4
0
        protected override void OnExecute(Microsoft.VisualStudio.Shell.OleMenuCommand command)
        {
            if (VSTextView.ActiveTextView == null)
            {
                return;
            }

            long      getElement = 0;
            long      regionTime = 0;
            Stopwatch sw         = new Stopwatch();

            sw.Start();

            //开始之前先格式化
            VSBase.ExecuteCommand((uint)VSConstants.VSStd2KCmdID.FORMATDOCUMENT);
            VSStatusBar.SetText("quick region......");
            using (VSUndo.StartUndo())
            {
                SettingModel model = SettingFrm.ReadSetting();
                if (model != null)
                {
                    QuickRegionSettingModel quickRegionModel = model.QuickRegionModel;
                    VSCodeModel             codeModel        = new VSCodeModel();
                    List <CodeElement>      classLists       = GetClassAndStructInFile(codeModel);

                    for (int i = 0; i < classLists.Count; i++)
                    {
                        sw.Stop();
                        getElement = sw.ElapsedMilliseconds;
                        sw.Restart();

                        List <CodeElement> noneEventElements = codeModel.GetNotRegionNoneEventMethodInClass(classLists[i]);
                        if (noneEventElements.Count != 0)
                        {
                            RegionElement(noneEventElements, i, model.QuickRegionModel.Method);
                        }

                        List <CodeElement> eventElements = codeModel.GetNotRegionEventInClass(classLists[i]);
                        if (eventElements.Count != 0)
                        {
                            RegionElement(eventElements, i, model.QuickRegionModel.Event);
                        }

                        List <CodeElement> constructorElements = codeModel.GetNotRegionConstructorInClass(classLists[i]);
                        if (constructorElements.Count != 0)
                        {
                            RegionElement(constructorElements, i, model.QuickRegionModel.Constructor);
                        }

                        List <CodeElement> propertyElements = codeModel.GetNotRegionPropertyInClass(classLists[i]);
                        if (propertyElements.Count != 0)
                        {
                            RegionElement(propertyElements, i, model.QuickRegionModel.Property);
                        }

                        List <CodeElement> variablesElements = codeModel.GetNotRegionVariablesInClass(classLists[i]);
                        if (variablesElements.Count != 0)
                        {
                            RegionElement(variablesElements, i, model.QuickRegionModel.Variable);
                        }

                        sw.Stop();
                        regionTime = sw.ElapsedMilliseconds;
                    }

                    //QuickRegionpNonEventMethod(textView, quickRegionModel.Method);
                    //QuickRegionpEventMethod(textView, quickRegionModel.Event);
                    //QuickRegionConstructor(textView, quickRegionModel.Constructor);
                    //QuickRegionpProperty(textView, quickRegionModel.Property);
                    //QuickRegionDelegates(textView, "- Delegate -");
                    //QuickRegionVariables(textView, quickRegionModel.Variable);
                    //CleanEmptyRegion(textView);
                    CleanBlankLine(codeModel);

                    VSDocument.SaveActiveDocument();
                    VSBase.ExecuteCommand((uint)VSConstants.VSStd2KCmdID.FORMATDOCUMENT);
                    VSBase.ExecuteCommand((uint)VSConstants.VSStd2KCmdID.OUTLN_COLLAPSE_TO_DEF);
                }
            }
            VsOutput.ShowDebugMessage("region complete, get element time total: " + getElement + " milliseconds\r\n" + " region time: " + regionTime);
        }