Esempio n. 1
0
 internal SettingsMigrator(SVsServiceProvider serviceProvider, IVimApplicationSettings vimApplicationSettings, ILegacySettings legacySettings, [EditorUtilsImport] IProtectedOperations protectedOperations)
 {
     _dte = serviceProvider.GetService<SDTE, _DTE>();
     _vimApplicationSettings = vimApplicationSettings;
     _legacySettings = legacySettings;
     _protectedOperations = protectedOperations;
 }
Esempio n. 2
0
		/// <summary>
		/// Checks the out file.
		/// </summary>
		/// <param name="vs">The vs.</param>
		/// <param name="filePath">The file path.</param>
		public static void CheckOutFile(_DTE vs, string filePath)
		{
            Guard.ArgumentNotNullOrWhiteSpaceString(filePath, "filePath");

            //Do nothing if no DTE instance
            if (vs == null)
            {
                Trace.TraceWarning("TFSHelper.CheckOutFile: No DTE instance available to access TFS functions.");
                return;
            }

			if (File.Exists(filePath))
			{
				if (vs.SourceControl.IsItemUnderSCC(filePath) &&
					!vs.SourceControl.IsItemCheckedOut(filePath))
				{
					bool checkout = vs.SourceControl.CheckOutItem(filePath);
					if (!checkout)
					{
						throw new CheckoutException(
							string.Format(CultureInfo.CurrentCulture, Properties.Resources.CheckoutException, filePath));
					}
				}
				else
				{
					// perform an extra check if the file is read only.
					if (IsReadOnly(filePath))
					{
						ResetReadOnly(filePath);
					}
				}
			}
		}
Esempio n. 3
0
        public static bool MovePageCodeToBackup(string id, string file, string name, string backupFolder, _DTE dte)
        {
            string csfileName = string.Format("{0}.cs", file);
            string designerfileName = string.Format("{0}.designer.cs", file);
            string aspxfileNameBackup = string.Format(@"{0}BTPage_{1}_{2}.aspx", backupFolder, id.Replace("-", "_"), name);
            string csfileNameBackup = string.Format("{0}.cs", aspxfileNameBackup);
            string designerfileNameBackup = string.Format("{0}.designer.cs", aspxfileNameBackup);

            if (File.Exists(file))
            {
                if (File.Exists(aspxfileNameBackup))
                    File.Delete(aspxfileNameBackup);

                if (File.Exists(csfileNameBackup))
                    File.Delete(csfileNameBackup);

                if (File.Exists(designerfileNameBackup))
                    File.Delete(designerfileNameBackup);

                dte.Solution.FindProjectItem(file).Remove();

                File.Move(file, aspxfileNameBackup);
                File.Move(csfileName, csfileNameBackup);
                File.Move(designerfileName, designerfileNameBackup);

                return true;
            }

            return false;
        }
Esempio n. 4
0
        internal VsVimHost(
            IVsAdapter adapter,
            ITextBufferFactoryService textBufferFactoryService,
            ITextEditorFactoryService textEditorFactoryService,
            ITextDocumentFactoryService textDocumentFactoryService,
            ITextBufferUndoManagerProvider undoManagerProvider,
            IVsEditorAdaptersFactoryService editorAdaptersFactoryService,
            IEditorOperationsFactoryService editorOperationsFactoryService,
            IWordUtilFactory wordUtilFactory,
            ITextManager textManager,
            ISharedServiceFactory sharedServiceFactory,
            SVsServiceProvider serviceProvider)
            : base(textBufferFactoryService, textEditorFactoryService, textDocumentFactoryService, editorOperationsFactoryService)
        {
            _vsAdapter = adapter;
            _editorAdaptersFactoryService = editorAdaptersFactoryService;
            _wordUtilFactory = wordUtilFactory;
            _dte = (_DTE)serviceProvider.GetService(typeof(_DTE));
            _vsExtensibility = (IVsExtensibility)serviceProvider.GetService(typeof(IVsExtensibility));
            _textManager = textManager;
            _sharedService = sharedServiceFactory.Create();
            _vsMonitorSelection = serviceProvider.GetService<SVsShellMonitorSelection, IVsMonitorSelection>();

            uint cookie;
            _vsMonitorSelection.AdviseSelectionEvents(this, out cookie);
        }
Esempio n. 5
0
        internal VsVimHost(
            IVsAdapter adapter,
            ITextBufferFactoryService textBufferFactoryService,
            ITextEditorFactoryService textEditorFactoryService,
            ITextDocumentFactoryService textDocumentFactoryService,
            ITextBufferUndoManagerProvider undoManagerProvider,
            IVsEditorAdaptersFactoryService editorAdaptersFactoryService,
            IEditorOperationsFactoryService editorOperationsFactoryService,
            ISmartIndentationService smartIndentationService,
            ITextManager textManager,
            ISharedServiceFactory sharedServiceFactory,
            IVimApplicationSettings vimApplicationSettings,
            SVsServiceProvider serviceProvider)
            : base(textBufferFactoryService, textEditorFactoryService, textDocumentFactoryService, editorOperationsFactoryService)
        {
            _vsAdapter = adapter;
            _editorAdaptersFactoryService = editorAdaptersFactoryService;
            _dte = (_DTE)serviceProvider.GetService(typeof(_DTE));
            _vsExtensibility = (IVsExtensibility)serviceProvider.GetService(typeof(IVsExtensibility));
            _textManager = textManager;
            _sharedService = sharedServiceFactory.Create();
            _vsMonitorSelection = serviceProvider.GetService<SVsShellMonitorSelection, IVsMonitorSelection>();
            _fontProperties = new TextEditorFontProperties(serviceProvider);
            _vimApplicationSettings = vimApplicationSettings;
            _smartIndentationService = smartIndentationService;

            uint cookie;
            _vsMonitorSelection.AdviseSelectionEvents(this, out cookie);
        }
 public object GetTarget(_DTE vs)
 {
     if ((vs.SelectedItems == null) || (vs.SelectedItems.Count <= 0))
       {
     throw new InvalidOperationException("invalid");
       }
       if (vs.SelectedItems.Count != 1)
       {
     return vs.SelectedItems;
       }
       SelectedItem item = vs.SelectedItems.Item(1);
       if (item.Project != null)
       {
     return item.Project;
       }
       if (item.ProjectItem != null)
       {
     return item.ProjectItem;
       }
       if (vs.Solution.Properties.Item("Name").Value.Equals(item.Name))
       {
     return vs.Solution;
       }
       return item;
 }
 public CommandFilter(IWpfTextView textView, IVsEditorAdaptersFactoryService factoryService, _DTE dt)
 {
     this.textView = textView;
     this.factoryService = factoryService;
     dte = dt;
     textView.GotAggregateFocus += textView_GotAggregateFocus;
 }
Esempio n. 8
0
        private static void CheckoutFileIfRequired(_DTE dte, String fileName)
        {
            _checkOutAction = (String fn) => dte.SourceControl.CheckOutItem(fn);

            var sc = dte.SourceControl;
            if (sc != null && sc.IsItemUnderSCC(fileName) && !sc.IsItemCheckedOut(fileName))
                _checkOutAction.EndInvoke(_checkOutAction.BeginInvoke(fileName, null, null));
        }
 public BackspaceDeleteKeyFilter(_DTE app, IWpfTextView textView)
     : base(textView)
 {
     var events = (Events2) app.Events;
     // ReSharper disable RedundantArgumentDefaultValue
     _keyPressEvents = events.TextDocumentKeyPressEvents[null];
     // ReSharper restore RedundantArgumentDefaultValue
     _keyPressEvents.BeforeKeyPress += BeforeKeyPress;
 }
Esempio n. 10
0
        public Configuration(_DTE application, WizardRunKind kind, Dictionary<string, string> replacements)
        {
            Application = application;
            Kind = kind;
            Replacements = replacements;

            DefineSolutionName();
            DefineSolutionRoot();
        }
Esempio n. 11
0
 internal KeyBindingService(SVsServiceProvider serviceProvider, IOptionsDialogService service, [EditorUtilsImport] IProtectedOperations protectedOperations, IVimApplicationSettings vimApplicationSettings)
 {
     _dte = serviceProvider.GetService<SDTE, _DTE>();
     _vsShell = serviceProvider.GetService<SVsShell, IVsShell>();
     _optionsDialogService = service;
     _protectedOperations = protectedOperations;
     _vimApplicationSettings = vimApplicationSettings;
     _importantScopeSet = new Lazy<HashSet<string>>(CreateImportantScopeSet);
 }
Esempio n. 12
0
 internal KeyBindingService(SVsServiceProvider serviceProvider, IOptionsDialogService service, IProtectedOperations protectedOperations, ILegacySettings legacySettings)
 {
     _dte = serviceProvider.GetService<SDTE, _DTE>();
     _vsShell = serviceProvider.GetService<SVsShell, IVsShell>();
     _optionsDialogService = service;
     _protectedOperations = protectedOperations;
     _legacySettings = legacySettings;
     _importantScopeSet = new Lazy<HashSet<string>>(CreateImportantScopeSet);
 }
        internal FallbackKeyProcessorProvider(SVsServiceProvider serviceProvider, IKeyUtil keyUtil, IVimApplicationSettings vimApplicationSettings, IVim vim)
        {
            _dte = (_DTE)serviceProvider.GetService(typeof(_DTE));
            _keyUtil = keyUtil;
            _vimApplicationSettings = vimApplicationSettings;
            _vim = vim;

            var vsShell = (IVsShell)serviceProvider.GetService(typeof(SVsShell));
            _scopeData = new ScopeData(vsShell);
        }
Esempio n. 14
0
        internal KeyBindingService(_DTE dte, IKeyboardOptionsProvider keyboardOptionsProvider, IVimProtectedOperations protectedOperations, IVimApplicationSettings vimApplicationSettings, ScopeData scopeData)
        {
            _dte = dte;
            _keyboardOptionsProvider = keyboardOptionsProvider;
            _protectedOperations = protectedOperations;
            _vimApplicationSettings = vimApplicationSettings;
            _scopeData = scopeData;

            FixKeyMappingIssue();
        }
 internal InitialCleanup(ITextDocument textDocument, _DTE ide, FileConfiguration settings)
 {
     _doc = ide.Documents.OfType<Document>()
         .FirstOrDefault(x => x.FullName == textDocument.FilePath);
     if (_doc != null)
         _textDoc = (TextDocument) _doc.Object("TextDocument");
     _ide = ide;
     _settings = settings;
     _eol = settings.EndOfLine();
 }
Esempio n. 16
0
 internal VsVimHost(
     ITextBufferUndoManagerProvider undoManagerProvider,
     IVsEditorAdaptersFactoryService editorAdaptersFactoryService,
     SVsServiceProvider serviceProvider)
 {
     _undoManagerProvider = undoManagerProvider;
     _editorAdaptersFactoryService = editorAdaptersFactoryService;
     _dte = (_DTE)serviceProvider.GetService(typeof(_DTE));
     _textManager = (IVsTextManager)serviceProvider.GetService(typeof(SVsTextManager));
 }
Esempio n. 17
0
        internal KeyBindingService(_DTE dte, IOptionsDialogService service, IVimProtectedOperations protectedOperations, IVimApplicationSettings vimApplicationSettings, ScopeData scopeData)
        {
            _dte = dte;
            _optionsDialogService = service;
            _protectedOperations = protectedOperations;
            _vimApplicationSettings = vimApplicationSettings;
            _scopeData = scopeData;

            FixKeyMappingIssue();
        }
        private VSCommandBars() {
            commands = Context.DTE.Commands;
            commandsType = Context.DTE.Commands.GetType();

            dte = Context.DTE;
            dteType = Context.DTE.GetType();

            commandBars = dte.GetType().InvokeMember(
                "CommandBars", BindingFlags.GetProperty, null,
                Context.DTE, new object[] {});
            commandBarsType = commandBars.GetType();
        }
Esempio n. 19
0
        public static void MoveCodeToBackup(string id, string file, string name, string backupFolder, _DTE dte)
        {

            string ruleFileNameBackup = string.Format(@"{0}BTRule_{1}_{2}.sql", backupFolder, id.Replace("-", "_"), name);

            if (File.Exists(ruleFileNameBackup))
                File.Delete(ruleFileNameBackup);

            File.Move(file, ruleFileNameBackup);

            dte.Solution.FindProjectItem(file).Remove();
        }
Esempio n. 20
0
        internal Telemetry(IVimApplicationSettings applicationSettings, _DTE dte)
        {
            _vimApplicationSettings = applicationSettings;

            var key = TryReadInstrumentationKey();
            if (key != null)
            {
                _client = CreateClient(dte, key);
                _dteEvents = dte.Events.DTEEvents;
                _dteEvents.OnBeginShutdown += OnBeginShutdown;
            }
        }
        public static Project GetActiveProject(_DTE dte)
        {
            Project activeProject = null;

            var activeSolutionProjects = dte.ActiveSolutionProjects as Array;
            if (activeSolutionProjects != null && activeSolutionProjects.Length > 0)
            {
                activeProject = activeSolutionProjects.GetValue(0) as Project;
            }

            return activeProject;
        }
Esempio n. 22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OutputWindowWriter"/> class.
        /// </summary>
        /// <param name="applicationObject">The application object.</param>
        public OutputWindowWriter(_DTE applicationObject)
        {
            Window window = applicationObject.Windows.Item(Constants.vsWindowKindOutput);
            OutputWindow outputWindow = (OutputWindow)window.Object;

            outputWindowPane = outputWindow.OutputWindowPanes
                .OfType<OutputWindowPane>()
                .Where(p => p.Name == "WSCF.blue")
                .FirstOrDefault() ?? outputWindow.OutputWindowPanes.Add("WSCF.blue");

            outputWindowPane.Clear();
            outputWindowPane.Activate();
        }
Esempio n. 23
0
 internal VsVimHost(
     IVsAdapter adapter,
     ITextBufferUndoManagerProvider undoManagerProvider,
     IVsEditorAdaptersFactoryService editorAdaptersFactoryService,
     ITextManager textManager,
     ITextDocumentFactoryService textDocumentFactoryService,
     SVsServiceProvider serviceProvider)
     : base(textDocumentFactoryService)
 {
     _adapter = adapter;
     _editorAdaptersFactoryService = editorAdaptersFactoryService;
     _dte = (_DTE)serviceProvider.GetService(typeof(_DTE));
     _textManager = textManager;
 }
Esempio n. 24
0
 private static MethodInfo GetMethodInfoFromActiveDocument(_DTE dte)
 {
     dynamic selection = dte.ActiveDocument.Selection;
     TextPoint point = selection.ActivePoint();
     CodeElement clazz = dte.ActiveDocument.ProjectItem.FileCodeModel.CodeElementFromPoint(point,
                                                                                           vsCMElement.
                                                                                               vsCMElementClass);
     CodeElement method = dte.ActiveDocument.ProjectItem.FileCodeModel.CodeElementFromPoint(point,
                                                                                            vsCMElement.
                                                                                                vsCMElementFunction);
     string fullName = dte.ActiveDocument.FullName;
     string parentPath = new DirectoryInfo(fullName).Parent.FullName;
     var info = new MethodInfo(clazz.Name, method.Name, parentPath);
     return info;
 }
Esempio n. 25
0
 private static TelemetryClient CreateClient(_DTE dte, string instrumentationKey)
 {
     var config = TelemetryConfiguration.CreateDefault();
     var client = new TelemetryClient(config);
     client.InstrumentationKey = instrumentationKey;
     client.Context.User.Id = GetUserId();
     client.Context.Session.Id = Guid.NewGuid().ToString();
     client.Context.Properties.Add("Host", dte.Application.Edition);
     client.Context.Properties.Add("HostVersion", dte.Version);
     client.Context.Properties.Add("HostFullVersion", GetFullHostVersion());
     client.Context.Component.Version = VimConstants.VersionNumber;
     client.Context.Properties.Add("AppVersion", VimConstants.VersionNumber);
     client.Context.Device.OperatingSystem = Environment.OSVersion.ToString();
     return client;
 }
Esempio n. 26
0
        /// <summary>
        /// In general a key processor applies to a specific IWpfTextView but
        /// by not making use of it, the fallback processor can be reused for
        /// multiple text views
        /// </summary>
        internal FallbackKeyProcessor(_DTE dte, IKeyUtil keyUtil, IVimApplicationSettings vimApplicationSettings, ITextView textView, IVimBuffer vimBuffer, ScopeData scopeData)
        {
            _dte = dte;
            _keyUtil = keyUtil;
            _vimApplicationSettings = vimApplicationSettings;
            _vimBuffer = vimBuffer;
            _scopeData = scopeData;
            _fallbackCommandList = new List<FallbackCommand>();

            // Register for key binding changes and get the current bindings
            _vimApplicationSettings.SettingsChanged += OnSettingsChanged;
            GetKeyBindings();

            textView.Closed += OnTextViewClosed;
        }
Esempio n. 27
0
        /// <summary>
        /// Selects an item by unfolding , based on
        /// its relative path with regards to the solution.
        /// </summary>
        /// <remarks>
        /// If selection fails, returned object will be null too.
        /// </remarks>
        public static UIHierarchyItem SelectItem(_DTE vs, object target)
        {
            Guard.ArgumentNotNull(vs, "vs");
            Guard.ArgumentNotNull(target, "target");

            UIHierarchy     hier;
            UIHierarchyItem sol;

            GetAndSelectSolutionExplorerHierarchy(vs, out hier, out sol);

            Dictionary <UIHierarchyItems, bool> expandedItems = new Dictionary <UIHierarchyItems, bool>();

            RestoreExpandedItems(expandedItems);

            return(LocateInUICollection(sol.UIHierarchyItems, target, expandedItems));
        }
Esempio n. 28
0
        /// <summary>
        /// Creates a square image and attaches an event handler to the layout changed event that
        /// adds the the square in the upper right-hand corner of the TextView via the adornment layer
        /// </summary>
        /// <param name="view">The <see cref="IWpfTextView"/> upon which the adornment will be drawn</param>
        public VSBackGround(IWpfTextView view, DTE dte)
        {
            _view = view;
            _dte = dte;
            //mToolWnd = new VSBackGroundTool();
            //mToolWnd.InitDTE(dte);

            //Grab a reference to the adornment layer that this adornment should be added to
            _adornmentLayer = view.GetAdornmentLayer("VSBackGround");

            InitializeImageAdornment();

            _view.ViewportHeightChanged += delegate { this.onSizeChange(); };
            _view.ViewportWidthChanged += delegate { this.onSizeChange(); };
            _view.GotAggregateFocus += delegate { this.onSizeChange(); };
        }
Esempio n. 29
0
 // Functions ------------------------------------------------------
 public AddinInit(_DTE a)
 {
     cmdBars = (_CommandBars)a.CommandBars;
     cmds    = a.Commands;
     try {
         cmdProjectContext = FindCommandBar
                                 (new Guid("{D309F791-903F-11D0-9EFC-00A0C911004F}"), 1026);
         cmdSolutionContext = FindCommandBar
                                  (new Guid("{D309F791-903F-11D0-9EFC-00A0C911004F}"), 1043);
         cmdItemContext = FindCommandBar
                              (new Guid("{D309F791-903F-11D0-9EFC-00A0C911004F}"), 1072);
     }
     catch {
         //MessageBox.Show( e.Message );
     }
 }
Esempio n. 30
0
        /// <summary>
        /// This method returned selected project in manager
        /// or active window project
        /// </summary>
        /// <param name="dte">Automation IDE Object</param>
        /// <returns>Return selected Visual C++ project</returns>
        /// <exception cref="ArgumentNullException"></exception>
        public static Project GetSelectedProject(_DTE dte)
        {
            if (dte == null)
            {
                throw new ArgumentNullException("dte");
            }

            var projects = ( Array )dte.ActiveSolutionProjects;

            foreach (var project in projects)
            {
                return(( Project )project);
            }

            return(dte.ActiveWindow.Project);
        }
Esempio n. 31
0
        /// <summary>
        /// In general a key processor applies to a specific IWpfTextView but
        /// by not making use of it, the fallback processor can be reused for
        /// multiple text views
        /// </summary>
        internal FallbackKeyProcessor(IVsShell vsShell, _DTE dte, IKeyUtil keyUtil, IVimApplicationSettings vimApplicationSettings, ITextView textView, IVimBuffer vimBuffer, ScopeData scopeData)
        {
            _vsShell = vsShell;
            _dte = dte;
            _keyUtil = keyUtil;
            _vimApplicationSettings = vimApplicationSettings;
            _vimBuffer = vimBuffer;
            _scopeData = scopeData;
            _fallbackCommandList = Enumerable.Empty<FallbackCommand>().ToLookup(x => 'a');

            // Register for key binding changes and get the current bindings
            _vimApplicationSettings.SettingsChanged += OnSettingsChanged;
            GetKeyBindings();

            textView.Closed += OnTextViewClosed;
        }
Esempio n. 32
0
        /// <summary>
        /// Retrieves the project currently selected, if any.
        /// </summary>
        public static Project GetSelectedProject(_DTE vs)
        {
            if (vs == null)
            {
                throw new ArgumentNullException("vs");
            }
            foreach (object obj in (object[])vs.ActiveSolutionProjects)
            {
                if (obj is Project)
                {
                    return(obj as Project);
                }
            }

            return(null);
        }
Esempio n. 33
0
        /// <summary>
        /// In general a key processor applies to a specific IWpfTextView but
        /// by not making use of it, the fallback processor can be reused for
        /// multiple text views
        /// </summary>
        internal FallbackKeyProcessor(IVsShell vsShell, _DTE dte, IKeyUtil keyUtil, IVimApplicationSettings vimApplicationSettings, ITextView textView, IVimBuffer vimBuffer, ScopeData scopeData)
        {
            _vsShell = vsShell;
            _dte     = dte;
            _keyUtil = keyUtil;
            _vimApplicationSettings = vimApplicationSettings;
            _vimBuffer           = vimBuffer;
            _scopeData           = scopeData;
            _fallbackCommandList = Enumerable.Empty <FallbackCommand>().ToLookup(x => 'a');

            // Register for key binding changes and get the current bindings
            _vimApplicationSettings.SettingsChanged += OnSettingsChanged;
            GetKeyBindings();

            textView.Closed += OnTextViewClosed;
        }
Esempio n. 34
0
        private static TelemetryClient CreateClient(_DTE dte, string instrumentationKey)
        {
            var config = TelemetryConfiguration.CreateDefault();
            var client = new TelemetryClient(config);

            client.InstrumentationKey = instrumentationKey;
            client.Context.User.Id    = GetUserId();
            client.Context.Session.Id = Guid.NewGuid().ToString();
            client.Context.Properties.Add("Host", dte.Application.Edition);
            client.Context.Properties.Add("HostVersion", dte.Version);
            client.Context.Properties.Add("HostFullVersion", GetFullHostVersion());
            client.Context.Component.Version = VimConstants.VersionNumber;
            client.Context.Properties.Add("AppVersion", VimConstants.VersionNumber);
            client.Context.Device.OperatingSystem = Environment.OSVersion.ToString();
            return(client);
        }
Esempio n. 35
0
 // Functions ------------------------------------------------------
 public AddinInit( _DTE a)
 {
     cmdBars = (_CommandBars)a.CommandBars;
     cmds    = a.Commands;
     try {
     cmdProjectContext = FindCommandBar
         (new Guid("{D309F791-903F-11D0-9EFC-00A0C911004F}"), 1026);
     cmdSolutionContext = FindCommandBar
         (new Guid("{D309F791-903F-11D0-9EFC-00A0C911004F}"), 1043);
     cmdItemContext = FindCommandBar
         (new Guid("{D309F791-903F-11D0-9EFC-00A0C911004F}"), 1072);
     }
     catch{
     //MessageBox.Show( e.Message );
     }
 }
Esempio n. 36
0
 internal VsVimHost(
     IVsAdapter adapter,
     ITextBufferUndoManagerProvider undoManagerProvider,
     IVsEditorAdaptersFactoryService editorAdaptersFactoryService,
     ITextManager textManager,
     ITextDocumentFactoryService textDocumentFactoryService,
     IEditorOperationsFactoryService editorOperationsFactoryService,
     IWordUtilFactory wordUtilFactory,
     SVsServiceProvider serviceProvider)
     : base(textDocumentFactoryService, editorOperationsFactoryService)
 {
     _adapter = adapter;
     _editorAdaptersFactoryService = editorAdaptersFactoryService;
     _wordUtilFactory = wordUtilFactory;
     _dte             = (_DTE)serviceProvider.GetService(typeof(_DTE));
     _textManager     = textManager;
 }
        public VsDebuggerAttacher(ILogger logger, int processId)
        {
            _logger = logger;
            _visualStudioProcess = Process.GetProcessById(processId);

            _DTE visualStudioInstance;

            if (NativeMethods.TryGetVsInstance(_visualStudioProcess.Id, out visualStudioInstance))
            {
                _visualStudioInstance = visualStudioInstance;
            }
            else
            {
                logger.LogError("Could not find Visual Studio instance");
                throw new InvalidOperationException("Could not find Visual Studio instance");
            }
        }
Esempio n. 38
0
        public override void OnCommand(_DTE application, OutputWindowPane pane)
        {
            ThreadPool.QueueUserWorkItem(
                o =>
            {
                ThreadHelper.ThrowIfNotOnUIThread();

                string file = GitCommands.RunGitExWait("searchfile", application.Solution.FullName);

                if (string.IsNullOrEmpty(file?.Trim()))
                {
                    return;
                }

                application.ExecuteCommand("File.OpenFile", file);
            });
        }
Esempio n. 39
0
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            Cursor.Current = Cursors.WaitCursor;

            /*
             * if(list != null)
             * {
             * return new StandardValuesCollection(list.ToArray());
             * }
             */

            list = new List <NameValueItem>();

            if (context != null)
            {
                _DTE service = (_DTE)context.GetService(typeof(_DTE));

                ManagementClass MgmtClass = new ManagementClass("Win32_Process");
                foreach (ManagementObject mo in MgmtClass.GetInstances())
                {
                    try
                    {
                        if (mo["Name"].ToString() == "w3wp.exe")
                        {
                            string apppool = mo["CommandLine"].ToString();
                            apppool = apppool.Substring(apppool.IndexOf("-ap") + 5);
                            apppool = apppool.Substring(0, apppool.IndexOf("\""));

                            NameValueItem item = new NameValueItem();
                            item.Name        = mo["ProcessId"].ToString();
                            item.Value       = mo["ProcessId"].ToString();
                            item.ItemType    = "Process";
                            item.Description = apppool; // mo["Name"].ToString();
                            list.Add(item);
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }

            Cursor.Current = Cursors.Default;

            return(new StandardValuesCollection(list.ToArray()));
        }
        internal IssueTagger(_DTE dte, TaggerProvider provider, ITextBuffer buffer, ITextDocument document, IList <IContentType> contentTypes)
        {
            this.dte             = dte;
            this.provider        = provider;
            this.textBuffer      = buffer;
            this.contentTypes    = contentTypes;
            this.currentSnapshot = buffer.CurrentSnapshot;
            this.dirtySpans      = new NormalizedSnapshotSpanCollection();

            this.document    = document;
            this.FilePath    = document.FilePath;
            this.ProjectItem = dte.Solution.FindProjectItem(this.FilePath);
            this.Charset     = document.Encoding.WebName;
            this.Factory     = new SnapshotFactory(new IssuesSnapshot(this.ProjectItem.ContainingProject.Name, this.FilePath, 0, new List <IssueMarker>()));

            this.Initialize();
        }
Esempio n. 41
0
        // Need to execute: "regsvr32 VSUserControlHost.dll"

        public void ShowToolWindow(_DTE applicationObject, AddIn addInInstance)
        {
            try
            {
                object objTemp = null;

                String guidstr = "{FDB416EB-2AC8-4714-96BC-8D39E8C9E063}";

                if (windowToolWindow == null)
                {
                    windowToolWindow = applicationObject.Windows.CreateToolWindow(addInInstance, "VSUserControlHost.VSUserControlHostCtl", "C# Tool window", guidstr, ref objTemp);

                    //When using the hosting control, you must set visible to true before calling HostUserControl,
                    // otherwise the UserControl cannot be hosted properly.
                    windowToolWindow.Visible    = true;
                    windowToolWindow.IsFloating = false;
                    windowToolWindow.Linkable   = true;
                    if (windowToolWindow.LinkedWindowFrame == null)
                    {
                        windowToolWindow.Width  = 1024;
                        windowToolWindow.Height = 768;
                    }
                    objControl = (VSUserControlHostLib.IVSUserControlHostCtl)objTemp;

                    //System.Reflection.Assembly asm = System.Reflection.Assembly.LoadFrom( @"C:\Documents and Settings\chris\Desktop\classes\InfoViz\SourceVis\Erato\bin\Debug\Prototype.dll" );
                    //Prototype.Controls.Class_Container.SourceVisPanel ctrl = (Prototype.Controls.Class_Container.SourceVisPanel)objControl.HostUserControl(asm.Location, "Prototype.Controls.Class_Container.SourceVisPanel");
                    //ctrl.InitSource( applicationObject );
                    //m_visPanel = ctrl;

                    Assembly asm = Assembly.GetExecutingAssembly();
                    m_frm = (TestForm)objControl.HostUserControl(asm.Location, "SmellFinder.TestForm");
                }
                else
                {
//					windowToolWindow.Visible    = true;
//					windowToolWindow.IsFloating = false;
//					windowToolWindow.Linkable   = true;
//					windowToolWindow.Width      = 1024;
//					windowToolWindow.Height     = 768;
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
Esempio n. 42
0
        internal VsVimHost(
            IVsAdapter adapter,
            ITextBufferFactoryService textBufferFactoryService,
            ITextEditorFactoryService textEditorFactoryService,
            ITextDocumentFactoryService textDocumentFactoryService,
            ITextBufferUndoManagerProvider undoManagerProvider,
            IVsEditorAdaptersFactoryService editorAdaptersFactoryService,
            IEditorOperationsFactoryService editorOperationsFactoryService,
            ISmartIndentationService smartIndentationService,
            ITextManager textManager,
            ISharedServiceFactory sharedServiceFactory,
            IVimApplicationSettings vimApplicationSettings,
            IExtensionAdapterBroker extensionAdapterBroker,
            IProtectedOperations protectedOperations,
            IMarkDisplayUtil markDisplayUtil,
            IControlCharUtil controlCharUtil,
            ICommandDispatcher commandDispatcher,
            SVsServiceProvider serviceProvider,
            IClipboardDevice clipboardDevice)
            : base(textBufferFactoryService, textEditorFactoryService, textDocumentFactoryService, editorOperationsFactoryService)
        {
            _vsAdapter = adapter;
            _editorAdaptersFactoryService = editorAdaptersFactoryService;
            _dte                     = (_DTE)serviceProvider.GetService(typeof(_DTE));
            _vsExtensibility         = (IVsExtensibility)serviceProvider.GetService(typeof(IVsExtensibility));
            _textManager             = textManager;
            _sharedService           = sharedServiceFactory.Create();
            _vsMonitorSelection      = serviceProvider.GetService <SVsShellMonitorSelection, IVsMonitorSelection>();
            _vimApplicationSettings  = vimApplicationSettings;
            _smartIndentationService = smartIndentationService;
            _extensionAdapterBroker  = extensionAdapterBroker;
            _runningDocumentTable    = serviceProvider.GetService <SVsRunningDocumentTable, IVsRunningDocumentTable>();
            _vsShell                 = (IVsShell)serviceProvider.GetService(typeof(SVsShell));
            _protectedOperations     = protectedOperations;
            _commandDispatcher       = commandDispatcher;
            _clipboardDevice         = clipboardDevice;

            _vsMonitorSelection.AdviseSelectionEvents(this, out uint selectionCookie);
            _runningDocumentTable.AdviseRunningDocTableEvents(this, out uint runningDocumentTableCookie);

            InitOutputPane();

            _settingsSync = new SettingsSync(vimApplicationSettings, markDisplayUtil, controlCharUtil, _clipboardDevice);
            _settingsSync.SyncFromApplicationSettings();
        }
 public Project FindProject(_DTE vs, Predicate <Project> match)
 {
     Guard.ArgumentNotNull(vs, "vs");
     Guard.ArgumentNotNull(match, "match");
     foreach (Project project in vs.Solution.Projects)
     {
         if (match(project))
         {
             return(project);
         }
         Project project2 = FindProjectInternal(project.ProjectItems, match);
         if (project2 != null)
         {
             return(project2);
         }
     }
     return(null);
 }
Esempio n. 44
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OutputWindowWriter"/> class.
        /// </summary>
        /// <param name="applicationObject">The application object.</param>
        public OutputWindowWriter(_DTE applicationObject)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            Window       window       = applicationObject.Windows.Item(Constants.vsWindowKindOutput);
            OutputWindow outputWindow = (OutputWindow)window.Object;

            outputWindowPane = outputWindow.OutputWindowPanes
                               .OfType <OutputWindowPane>()
                               .Where(p =>
            {
                ThreadHelper.ThrowIfNotOnUIThread();
                return(p.Name == "WSCF.blue");
            })
                               .FirstOrDefault() ?? outputWindow.OutputWindowPanes.Add("WSCF.blue");

            outputWindowPane.Clear();
            outputWindowPane.Activate();
        }
Esempio n. 45
0
        public SolutionComponent CreateModel(_DTE app)
        {
            m_app = app;

            string            name = Path.GetFileNameWithoutExtension(app.Solution.FileName);
            SolutionComponent sol  = new SolutionComponent(app.Solution.FullName, name);

            foreach (Project p in app.Solution)
            {
                ProjectComponent project = new ProjectComponent(p.FullName, p.Name);
                if (p.ProjectItems != null)
                {
                    WalkProjectItems(project, p.ProjectItems);
                    sol.Visit(project);
                }
            }
            return(sol);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="GitExtCommands"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        private GitExtCommands(Package package, _DTE dte, IMenuCommandService menuCommandService)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            _package        = package ?? throw new ArgumentNullException(nameof(package));
            _application    = dte;
            _commandService = menuCommandService;

            try
            {
                RegisterCommands();
                PluginHelpers.AllowCaptionUpdate = true;
            }
            catch (Exception ex)
            {
                OutputPane?.OutputString("Error adding commands: " + ex);
            }
        }
Esempio n. 47
0
		public SolutionComponent CreateModel( _DTE app )
		{
			m_app = app;

			string name = Path.GetFileNameWithoutExtension(app.Solution.FileName);
			SolutionComponent sol = new SolutionComponent( app.Solution.FullName, name );

			foreach( Project p in app.Solution )
			{
				ProjectComponent project = new ProjectComponent( p.FullName, p.Name );
				if( p.ProjectItems != null )
				{
					WalkProjectItems( project, p.ProjectItems );
					sol.Visit( project );
				}
			}
			return sol;
		}
Esempio n. 48
0
        /// <summary>
        /// Selects the solution in the solution explorer.
        /// </summary>
        /// <returns>Whether the selection was successful.</returns>
        public static bool SelectSolution(_DTE vs)
        {
            Guard.ArgumentNotNull(vs, "vs");

            UIHierarchy     hier;
            UIHierarchyItem sol;

            try
            {
                GetAndSelectSolutionExplorerHierarchy(vs, out hier, out sol);
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 49
0
        private void Initialize(_DTE dte, Dictionary <string, string> parameters)
        {
            string wizardData = null;

            if (parameters.TryGetValue(PARAMETER_NAME_WIZARD_DATA, out wizardData))
            {
                XmlDocument xd = new XmlDocument();
                xd.LoadXml(wizardData);
                this.extensionConfiguration = XMLHelper.ConvertToObject <ProjectExtension>(xd, Assembly.GetExecutingAssembly(), String.Format("{0}.Schema.ExtensionData.xsd", this.GetType().Namespace));
            }

            Solution s    = dte.Solution;
            string   path = s.FileName;

            if (!String.IsNullOrEmpty(path))
            {
                this.solutionPath = Path.GetDirectoryName(path);
            }
        }
        public override void Initialize(IPendingCheckin pendingCheckin)
        {
            if (this._taskProvider != null)
            {
                this._taskProvider.Clear();
            }
            else
            {
                _DTE dte = (_DTE)pendingCheckin.GetService(typeof(_DTE));

                if (dte != null && dte.Application != null)
                {
                    this._taskProvider =
                        new ViolationTaskProvider(new ServiceProvider((IServiceProvider)dte.Application));
                }
            }

            base.Initialize(pendingCheckin);
        }
Esempio n. 51
0
        // Execute is the main entry point for a project wizard.  It has to follow this template.
        // contextParams:
        // 0: some GUID
        // 1: Project Name
        // 2: Project Path
        // 3: location of visual studio exe
        // 4: Create New Solution : true..... Add to existing solution: false
        // 5: Solution Name--- Will be empty string if not selected to create solution
        // 6: false
        // 7: "4.0"
        public void Execute(object Application, int hwndOwner, ref object[] contextParams, ref object[] customParams, ref EnvDTE.wizardResult retval)
        {
            try
            {
                fMain f = new fMain((string)contextParams[1]);
                if (f.ShowDialog() == DialogResult.OK)
                {
                    // Set all our member variables based on input:
                    //TODO: Organize and validate input
                    this.dte               = (_DTE)Application;
                    this.wz                = f.GetWizardData();
                    this.solutionName      = (string)contextParams[5];
                    this.projectName       = (string)contextParams[1];
                    this.path              = (string)contextParams[2];
                    this.projectType       = (ProjectType)wz.Type.ProjectTemplate;
                    this.createNewSolution = (bool)contextParams[4];

                    // Parse project path and solution path from "path"
                    //TODO: Can "path" be null/empty?
                    this.projectPath = this.path;
                    if (this.createNewSolution)
                    {
                        this.solutionPath = path.Substring(0, this.path.Length - this.projectName.Length - 1);
                    }
                    else
                    {
                        this.solutionPath = Path.GetDirectoryName(this.dte.Solution.FullName);
                    }

                    // Create a Project based on all our input:
                    retval = createProject() ? wizardResult.wizardResultSuccess : wizardResult.wizardResultFailure;
                }
                else
                {
                    retval = wizardResult.wizardResultCancel;
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("Exception: " + ex.Message, "Error");
                retval = wizardResult.wizardResultBackOut;
            }
        }
        public static ProjectItem AddFileToProject(this _DTE dte, Project project, string file, string itemType = null)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (!File.Exists(file))
            {
                return(null);
            }

            ProjectItem item = dte.Solution.FindProjectItem(file);

            if (item == null)
            {
                item = project.ProjectItems.AddFromFile(file);
                item.SetItemType(itemType);
            }

            return(item);
        }
Esempio n. 53
0
        public static IProject GetProject(this _DTE dte, Document currentDoc, string code)
        {
            Project instantProject = new Project();

            instantProject.Sources.Add(Either <FileInfo, string> .B(code));

            EnvDTE.Project project = currentDoc.ProjectItem.ContainingProject;

            EnvDTE.Properties properties = project.ConfigurationManager.ActiveConfiguration.Properties;

            instantProject.DefinedConstants = (string)properties.Item("DefineConstants").Value;
            instantProject.AllowUnsafe      = (bool)properties.Item("AllowUnsafeBlocks").Value;
            instantProject.Optimize         = (bool)properties.Item("Optimize").Value;

            AddFiles(instantProject, project.ProjectItems, currentDoc);
            AddReferences(instantProject, ((VSProject)project.Object).References);

            return(instantProject);
        }
Esempio n. 54
0
        /// <summary>
        /// Removes existing event entries
        /// </summary>
        /// <param name="sender"> </param>
        /// <param name="e"> </param>
        private void OnPurgeEvents(object sender, EventArgs e)
        {
            try
            {
                _DTE dteObj = (_DTE)GetNodeSite().GetService(typeof(_DTE));

                if (outputPane == null)
                {
                    OutputWindow ouputWindow = (OutputWindow)dteObj.Windows.Item(EnvDTE.Constants.vsWindowKindOutput).Object;
                    outputPane = ouputWindow.OutputWindowPanes.Item("{1BD8A850-02D1-11d1-bee7-00a0c913d1f8}");
                }

                outputPane.Clear();
            }
            catch (Exception exc)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", exc.Message, exc.StackTrace));
            }
        }
Esempio n. 55
0
        /// <summary>
        /// Search Running Object Table for a given process
        /// </summary>
        /// <param name="processId">The ID of the process for which to search</param>
        /// <param name="instance">The returned _DTE object</param>
        /// <returns>True if a matching _DTE object was found</returns>
        public static bool GetVSInstance(int processId, out _DTE instance)
        {
            IRunningObjectTable runningObjectTable;

            GetRunningObjectTable(0, out runningObjectTable);

            IEnumMoniker monikerEnumerator;

            runningObjectTable.EnumRunning(out monikerEnumerator);
            monikerEnumerator.Reset();

            IMoniker[] monikers   = new IMoniker[1];
            IntPtr     numFetched = IntPtr.Zero;

            while (monikerEnumerator.Next(1, monikers, numFetched) == 0)
            {
                IBindCtx ctx;
                CreateBindCtx(0, out ctx);

                string runningObjectName;
                monikers[0].GetDisplayName(ctx, null, out runningObjectName);
                if (runningObjectName.StartsWith("!VisualStudio"))
                {
                    object runningObjectVal;
                    runningObjectTable.GetObject(monikers[0], out runningObjectVal);

                    if (runningObjectVal is _DTE)
                    {
                        int currentProcessId = int.Parse(runningObjectName.Split(':')[1]);

                        if (currentProcessId == processId)
                        {
                            instance = (_DTE)runningObjectVal;
                            return(true);
                        }
                    }
                }
            }

            instance = null;
            return(false);
        }
Esempio n. 56
0
        public static IEnumerable <string> GetProjects(_DTE dte)
        {
            var projects = new List <string>();

            var solutionProjects = dte.Solution.Projects;

            if (solutionProjects == null)
            {
                return(projects);
            }

            var projs = solutionProjects.Cast <Project>();

            if (projs == null)
            {
                return(projects);
            }

            return(projs.Select(p => p.Name).ToArray());
        }
Esempio n. 57
0
        /// <summary>
        /// Turns the file name received into a path relative to the containing solution.
        /// </summary>
        public static string GetFilePathRelative(_DTE vs, string file)
        {
            Guard.ArgumentNotNull(vs, "vs");
            Guard.ArgumentNotNull(file, "file");

            if (!file.StartsWith(Path.GetDirectoryName(vs.Solution.FullName)))
            {
                throw new ArgumentException(String.Format(
                                                System.Globalization.CultureInfo.CurrentCulture,
                                                Properties.Resources.DteHelper_PathNotRelativeToSln,
                                                file, vs.Solution.FullName));
            }
            string relative = file.Replace(Path.GetDirectoryName(vs.Solution.FullName), "");

            if (relative.StartsWith(Path.DirectorySeparatorChar.ToString()))
            {
                relative = relative.Substring(1);
            }
            return(relative);
        }
        private static object QueryService(_DTE dte, Type serviceType)
        {
            IntPtr ptr;
            Guid   gUID = serviceType.GUID;
            Guid   riid = gUID;

            Microsoft.VisualStudio.OLE.Interop.IServiceProvider provider = dte as Microsoft.VisualStudio.OLE.Interop.IServiceProvider;
            if (provider.QueryService(ref gUID, ref riid, out ptr) != 0)
            {
                return(null);
            }
            object objectForIUnknown = null;

            if (ptr != IntPtr.Zero)
            {
                objectForIUnknown = Marshal.GetObjectForIUnknown(ptr);
                Marshal.Release(ptr);
            }
            return(objectForIUnknown);
        }
Esempio n. 59
0
 /// <summary>
 /// Turns the relative file name received into full path, based on the containing solution location.
 /// </summary>
 public static string GetPathFull(_DTE vs, string file)
 {
     if (vs == null)
     {
         throw new ArgumentNullException("vs");
     }
     if (file == null)
     {
         throw new ArgumentNullException("file");
     }
     if (Path.IsPathRooted(file) &&
         !file.StartsWith(Path.GetDirectoryName(vs.Solution.FullName)))
     {
         throw new ArgumentException(String.Format(
                                         System.Globalization.CultureInfo.CurrentCulture,
                                         Properties.Resources.DteHelper_PathNotRelativeToSln,
                                         file, vs.Solution.FullName));
     }
     return(Path.Combine(Path.GetDirectoryName(vs.Solution.FullName), file));
 }
Esempio n. 60
0
        private BuildRequestData CreateBuildRequestData(Project proj, string target, _DTE dte)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            var globalProperties = new Dictionary <string, string>();

            if (proj.ConfigurationManager != null)
            {
                var config = proj.ConfigurationManager.ActiveConfiguration;
                globalProperties["Configuration"] = config.ConfigurationName;
                globalProperties["Platform"]      = config.PlatformName.Replace(" ", "");
            }

            var solutionDir = Path.GetDirectoryName(dte.Solution.FullName);

            globalProperties["SolutionDir"] = solutionDir;

            return(new BuildRequestData(proj.FullName, globalProperties, null, new[] { target }, null,
                                        BuildRequestDataFlags.ReplaceExistingProjectInstance));
        }