Esempio n. 1
0
        /// <summary>
        /// Use this instead of VsShellUtilities.ShowMessageBox because VSU uses ThreadHelper which
        /// uses a private interface that can't be mocked AND goes to the global service provider.
        /// </summary>
        public static int ShowMessageBox(IServiceProvider serviceProvider, string message, string title, OLEMSGICON icon, OLEMSGBUTTON msgButton, OLEMSGDEFBUTTON defaultButton) {
            IVsUIShell uiShell = serviceProvider.GetService(typeof(IVsUIShell)) as IVsUIShell;
            Debug.Assert(uiShell != null, "Could not get the IVsUIShell object from the services exposed by this serviceprovider");
            if (uiShell == null) {
                throw new InvalidOperationException();
            }

            Guid emptyGuid = Guid.Empty;
            int result = 0;

            serviceProvider.GetUIThread().Invoke(() => {
                ErrorHandler.ThrowOnFailure(uiShell.ShowMessageBox(
                    0,
                    ref emptyGuid,
                    title,
                    message,
                    null,
                    0,
                    msgButton,
                    defaultButton,
                    icon,
                    0,
                    out result));
            });
            return result;
        }
        public GoToDefinitionFilterProvider(
            [Import(typeof(SVsServiceProvider))] System.IServiceProvider serviceProvider,
            IVsEditorAdaptersFactoryService editorFactory,
            IEditorOptionsFactoryService editorOptionsFactory,
            ITextDocumentFactoryService textDocumentFactoryService,
            [Import(typeof(DotNetReferenceSourceProvider))] ReferenceSourceProvider referenceSourceProvider,
            VSLanguageService fsharpVsLanguageService,
            ProjectFactory projectFactory)
        {
            _serviceProvider = serviceProvider;
            _editorFactory = editorFactory;
            _editorOptionsFactory = editorOptionsFactory;
            _textDocumentFactoryService = textDocumentFactoryService;
            _referenceSourceProvider = referenceSourceProvider;
            _fsharpVsLanguageService = fsharpVsLanguageService;
            _projectFactory = projectFactory;

            var dte = serviceProvider.GetService(typeof(SDTE)) as DTE;
            var events = dte.Events as Events2;
            if (events != null)
            {
                _solutionEvents = events.SolutionEvents;
                _solutionEvents.AfterClosing += Cleanup;
            }
        }
 internal VsKeyProcessorAdditional(VsHost host, IVsTextView view,  System.IServiceProvider provider)
 {
     _host = host;
     _textView = view;
     _serviceProvider = provider;
     var hr = view.AddCommandFilter(this, out _nextTarget);
 }
Esempio n. 4
0
 internal VsCommandFilter(IVimBuffer buffer, IVsTextView view, IServiceProvider provider)
 {
     _buffer = buffer;
     _textView = view;
     _serviceProvider = provider;
     var hr = view.AddCommandFilter(this, out _nextTarget);
 }
        public VisualStudioLogger(System.IServiceProvider serviceProvider)
        {
            if(serviceProvider==null)
                throw new ArgumentNullException();

            _serviceProvider = serviceProvider;
        }
 /// <summary>
 /// Attaches events for invoking Statement completion 
 /// </summary>
 /// <param name="subjectBuffers"></param>
 /// <param name="textView"></param>
 /// <param name="completionBrokerMap"></param>
 internal CompletionController(IList<ITextBuffer> subjectBuffers, ITextView textView, ICompletionBroker completionBrokerMap, System.IServiceProvider serviceProvider)
 {
     this.subjectBuffers = subjectBuffers;
     this.textView = textView;
     this.completionBrokerMap = completionBrokerMap;
     this.serviceProvider = serviceProvider;
 }
        /// <include file='doc\VsShellUtilities.uex' path='docs/doc[@for="VsShellUtilities.EmptyTaskList"]/*' />
        /// <devdoc>
        /// Empty the task list.
        /// </devdoc>
        /// <param name="serviceProvider">The service provider.</param>
        /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code. </returns>
        public static int EmptyTaskList(IServiceProvider serviceProvider)
        {
            if (serviceProvider == null)
            {
                throw new ArgumentException("serviceProvider");
            }

            IVsTaskList taskList = serviceProvider.GetService(typeof(IVsTaskList)) as IVsTaskList;

            if (taskList == null)
            {
                throw new InvalidOperationException();
            }

            IVsEnumTaskItems enumTaskItems;
            int result = VSConstants.S_OK;
            try
            {
                ErrorHandler.ThrowOnFailure(taskList.EnumTaskItems(out enumTaskItems));

                if (enumTaskItems == null)
                {
                    throw new InvalidOperationException();
                }

                // Retrieve the task item text and check whether it is equal with one that supposed to be thrown.

                uint[] fetched = new uint[1];
                do
                {
                    IVsTaskItem[] taskItems = new IVsTaskItem[1];

                    result = enumTaskItems.Next(1, taskItems, fetched);

                    if (fetched[0] == 1)
                    {
                        IVsTaskItem2 taskItem = taskItems[0] as IVsTaskItem2;
                        if (taskItem != null)
                        {
                            int canDelete;
                            ErrorHandler.ThrowOnFailure(taskItem.CanDelete(out canDelete));
                            if (canDelete == 1)
                            {
                                ErrorHandler.ThrowOnFailure(taskItem.OnDeleteTask());
                            }
                        }
                    }

                } while (result == VSConstants.S_OK && fetched[0] == 1);

            }
            catch (COMException e)
            {
                Trace.WriteLine("Exception : " + e.Message);
                result = e.ErrorCode;
            }

            return result;
        }
Esempio n. 8
0
        /// <summary>
        /// Rename document in the running document table from oldName to newName.
        /// </summary>
        /// <param name="provider">The service provider.</param>
        /// <param name="oldName">Full path to the old name of the document.</param>		
        /// <param name="newName">Full path to the new name of the document.</param>		
        /// <param name="newItemId">The new item id of the document</param>		
        public static void RenameDocument(IServiceProvider site, string oldName, string newName, uint newItemId)
        {
            if(site == null)
            {
                throw new ArgumentNullException("site");
            }

            if(String.IsNullOrEmpty(oldName))
            {
                throw new ArgumentException(SR.GetString(SR.ParameterCannotBeNullOrEmpty, CultureInfo.CurrentUICulture), "oldName");
            }

            if(String.IsNullOrEmpty(newName))
            {
                throw new ArgumentException(SR.GetString(SR.ParameterCannotBeNullOrEmpty, CultureInfo.CurrentUICulture), "newName");
            }

            if(newItemId == VSConstants.VSITEMID_NIL)
            {
                throw new ArgumentNullException("newItemId");
            }

            IVsRunningDocumentTable pRDT = site.GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable;
            IVsUIShellOpenDocument doc = site.GetService(typeof(SVsUIShellOpenDocument)) as IVsUIShellOpenDocument;

            if(pRDT == null || doc == null) return;

            IVsHierarchy pIVsHierarchy;
            uint itemId;
            IntPtr docData;
            uint uiVsDocCookie;
            ErrorHandler.ThrowOnFailure(pRDT.FindAndLockDocument((uint)_VSRDTFLAGS.RDT_NoLock, oldName, out pIVsHierarchy, out itemId, out docData, out uiVsDocCookie));

            if(docData != IntPtr.Zero)
            {
                try
                {
                    IntPtr pUnk = Marshal.GetIUnknownForObject(pIVsHierarchy);
                    Guid iid = typeof(IVsHierarchy).GUID;
                    IntPtr pHier;
                    Marshal.QueryInterface(pUnk, ref iid, out pHier);
                    try
                    {
                        ErrorHandler.ThrowOnFailure(pRDT.RenameDocument(oldName, newName, pHier, newItemId));
                    }
                    finally
                    {
                        if(pHier != IntPtr.Zero)
                            Marshal.Release(pHier);
                        if(pUnk != IntPtr.Zero)
                            Marshal.Release(pUnk);
                    }
                }
                finally
                {
                    Marshal.Release(docData);
                }
            }
        }
 public SpringQuickInfoSource(ITextBuffer textBuffer, ITextStructureNavigatorSelectorService textStructureNavigatorSelectorService,
     IVsEditorAdaptersFactoryService vsEditorAdaptersFactoryService, System.IServiceProvider serviceProvider)
 {
     this.textBuffer = textBuffer;
     this.textStructureNavigatorSelectorService = textStructureNavigatorSelectorService;
     this.vsEditorAdaptersFactoryService = vsEditorAdaptersFactoryService;
     this.serviceProvider = serviceProvider;
 }
Esempio n. 10
0
        protected ProjectFactory(Microsoft.VisualStudio.Shell.Package package)
        {
            this.package = package;
            this.site = package;

            // Please be aware that this methods needs that ServiceProvider is valid, thus the ordering of calls in the ctor matters.
            this.buildEngine = Utilities.InitializeMsBuildEngine(this.buildEngine, this.site);
        }
Esempio n. 11
0
 /// <include file='doc\ToolWindowPane.uex' path='docs/doc[@for="ToolWindowPane.ToolWindowPane"]/*' />
 /// <summary>
 /// Constructor
 /// </summary>
 protected ToolWindowPane(IServiceProvider provider)
     : base(provider)
 {
     toolClsid = Guid.Empty;
     bitmapIndex = -1;
     bitmapResourceID = -1;
     toolBarLocation = VSTWT_LOCATION.VSTWT_TOP;
 }
Esempio n. 12
0
 public void Dispose(){
   ClearErrors();
   if (this.taskList != null && dwCookie != 0){
     OnTaskListFinalRelease(this.taskList);
   }
   this.site = null;
   this.taskList = null;
 }
Esempio n. 13
0
 public TaskProvider(IServiceProvider site){
   this.site = site;
   this.taskList = (IVsTaskList)this.site.GetService(typeof(SVsTaskList));
   items = new ArrayList();
   RegisterProvider();
   taskTokens = new TaskTokens(site);
   taskTokens.Refresh();
 }
        public CogaenEditProjectFactory(Microsoft.VisualStudio.Shell.Package package)
        {
            Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering constructor for: {0}", this.ToString()));
            this.package = package;
            this.site = package;

            // Please be aware that this methods needs that ServiceProvider is valid, thus the ordering of calls in the ctor matters.
            this.buildEngine = Utilities.InitializeMsBuildEngine(this.buildEngine, this.site);
        }
Esempio n. 15
0
 internal TextManager(
     IVsAdapter adapter,
     SVsServiceProvider serviceProvider)
 {
     _adapter = adapter;
     _serviceProvider = serviceProvider;
     _textManager = _serviceProvider.GetService<SVsTextManager, IVsTextManager>();
     _table = new RunningDocumentTable(_serviceProvider);
 }
        protected AbstractObjectBrowserLibraryManager(string languageName, Guid libraryGuid, IServiceProvider serviceProvider)
            : base(libraryGuid, serviceProvider)
        {
            _languageName = languageName;

            var componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel));
            this.Workspace = componentModel.GetService<VisualStudioWorkspace>();
            this.Workspace.WorkspaceChanged += OnWorkspaceChanged;
        }
 /// <include file='doc\OleMenuCommandService.uex' path='docs/doc[@for="OleMenuCommandService.OleMenuCommandService1"]/*' />
 /// <devdoc>
 ///     Creates a new menu command service.
 /// </devdoc>
 public OleMenuCommandService(IServiceProvider serviceProvider, IOleCommandTarget parentCommandTarget)
     : base(serviceProvider)
 {
     if (parentCommandTarget == null) {
         throw new ArgumentNullException("parentCommandTarget");
     }
     _parentTarget = parentCommandTarget;
     _provider = serviceProvider;
 }
        internal XmlResourceCompletionController(System.IServiceProvider serviceProvider, IVsTextView vsTextView, ITextView textView, ICompletionBroker completionBroker, ITextStructureNavigatorSelectorService textStructureNavigatorSelectorService)
        {
            this.serviceProvider = serviceProvider;
            this.textView = textView;
            this.completionBroker = completionBroker;

            //add the command to the command chain
            vsTextView.AddCommandFilter(this, out nextCommandTarget);
        }
Esempio n. 19
0
		public AdminCommandTarget(IServiceProvider provider) : base(provider)
		{
			_siteUrl =
				() =>
					provider
						.GetRequiredService<IWebConnectionService>()
						.GetConfig()
						.SiteUrl;
		}
Esempio n. 20
0
		private static int GetForumId(IServiceProvider provider, int? forumId)
		{
			if (forumId != null)
				return forumId.Value;

			var currentForum = provider
				.GetRequiredService<IActiveForumService>()
				.ActiveForum;
			return currentForum?.ID ?? -1;
		}
Esempio n. 21
0
        public TextViewFilter(IServiceProvider serviceProvider, IVsTextView vsTextView) {
            var compModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel));
            _vsEditorAdaptersFactoryService = compModel.GetService<IVsEditorAdaptersFactoryService>();
            _debugger = (IVsDebugger)serviceProvider.GetService(typeof(IVsDebugger));

            vsTextView.GetBuffer(out _vsTextLines);
            _wpfTextView = _vsEditorAdaptersFactoryService.GetWpfTextView(vsTextView);

            ErrorHandler.ThrowOnFailure(vsTextView.AddCommandFilter(this, out _next));
        }
        /// <include file='doc\DialogContainerWithToolbar.uex' path='docs/doc[@for="DialogContainerWithToolbar.DialogContainerWithToolbar"]/*' />
        /// <devdoc>
        /// Constructor of the DialogContainerWithToolbar. This constructor allow the caller to set a IServiceProvider,
        /// the conatined control and an additional IOleCommandTarget implementation that will be chained to the one
        /// implemented by OleMenuCommandTarget.
        /// </devdoc>
        public DialogContainerWithToolbar(IServiceProvider sp, Control contained, IOleCommandTarget parentCommandTarget)
        {
            if (null == contained)
                throw new ArgumentNullException("contained");

            if (null == sp)
                throw new ArgumentNullException("sp");

            PrivateInit(sp, contained, parentCommandTarget);
        }
Esempio n. 23
0
        public EditFilter(ITextView textView, IEditorOperations editorOps, IServiceProvider serviceProvider)
        {
            _textView = textView;
            _textView.Properties[typeof(EditFilter)] = this;
            _editorOps = editorOps;
            _serviceProvider = serviceProvider;
            //_componentModel = _serviceProvider.GetComponentModel();

            //BraceMatcher.WatchBraceHighlights(textView, _componentModel);
        }
Esempio n. 24
0
        protected SolutionListener(IServiceProvider serviceProviderParameter)
        {
            Utilities.ArgumentNotNull("serviceProviderParameter", serviceProviderParameter);

            this.serviceProvider = serviceProviderParameter;
            this.solution = this.serviceProvider.GetService(typeof(SVsSolution)) as IVsSolution;

            Debug.Assert(this.solution != null, "Could not get the IVsSolution object from the services exposed by this project");
            Utilities.CheckNotNull(this.solution);
        }
        protected AbstractObjectBrowserLibraryManager(string languageName, Guid libraryGuid, __SymbolToolLanguage preferredLanguage, IServiceProvider serviceProvider)
            : base(libraryGuid, serviceProvider)
        {
            _languageName = languageName;
            _preferredLanguage = preferredLanguage;

            var componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel));
            this.Workspace = componentModel.GetService<VisualStudioWorkspace>();
            this.LibraryService = this.Workspace.Services.GetLanguageServices(languageName).GetService<ILibraryService>();
            this.Workspace.WorkspaceChanged += OnWorkspaceChanged;
        }
 internal SpringCompletionSource(ITextBuffer textBuffer, IGlyphService glyphService,
     IVsEditorAdaptersFactoryService vsEditorAdaptersFactoryService,
     ITextStructureNavigatorSelectorService textStructureNavigatorSelectorService,
     System.IServiceProvider serviceProvider)
 {
     this.textBuffer = textBuffer;
     this.glyphService = glyphService;
     this.vsEditorAdaptersFactoryService = vsEditorAdaptersFactoryService;
     this.textStructureNavigatorSelectorService = textStructureNavigatorSelectorService;
     this.serviceProvider = serviceProvider;
 }
Esempio n. 27
0
        /// <summary>
        /// Look in the registry under the current hive for the path
        /// of MSBuild
        /// </summary>
        /// <returns></returns>

        /// <summary>
        /// Is Visual Studio in design mode.
        /// </summary>
        /// <param name="serviceProvider">The service provider.</param>
        /// <returns>true if visual studio is in design mode</returns>
        public static bool IsVisualStudioInDesignMode(IServiceProvider site) {
            Utilities.ArgumentNotNull("site", site);

            IVsMonitorSelection selectionMonitor = site.GetService(typeof(IVsMonitorSelection)) as IVsMonitorSelection;
            uint cookie = 0;
            int active = 0;
            Guid designContext = VSConstants.UICONTEXT_DesignMode;
            ErrorHandler.ThrowOnFailure(selectionMonitor.GetCmdUIContextCookie(ref designContext, out cookie));
            ErrorHandler.ThrowOnFailure(selectionMonitor.IsCmdUIContextActive(cookie, out active));
            return active != 0;
        }
Esempio n. 28
0
        protected SolutionListener(IServiceProvider serviceProvider)
        {
            this.serviceProvider = serviceProvider;
            this.solution = serviceProvider.GetService(typeof(SVsSolution)) as IVsSolution;

            Debug.Assert(this.solution != null, "Could not get the IVsSolution object from the services exposed by this project");

            if (this.solution == null)
            {
                throw new InvalidOperationException();
            }
        }
Esempio n. 29
0
 public KeyBindingCommandFilter(
   IWpfTextView     wpfTextView,
   IServiceProvider serviceProvider,
   TextViewModel    textViewModel
   )
 {
   _serviceProvider = serviceProvider;
   _wpfTextView     = wpfTextView;
   _textViewModel   = textViewModel;
   var path = wpfTextView.TextBuffer.GetFilePath();
   AddCommandFilter(wpfTextView.ToVsTextView());
 }
        public GoToDefinitionFilterProvider([Import(typeof(SVsServiceProvider))] System.IServiceProvider serviceProvider)
        {
            this.serviceProvider = serviceProvider;

            var dte = serviceProvider.GetService(typeof(SDTE)) as DTE;
            var events = dte.Events as Events2;
            if (events != null)
            {
                this.solutionEvents = events.SolutionEvents;
                this.solutionEvents.AfterClosing += Cleanup;
            }
        }
Esempio n. 31
0
        /// <summary>
        /// Initialize the build engine. Sets the build enabled property to true. The engine is initialzed if the passed in engine is null or does not have its bin path set.
        /// </summary>
        /// <param name="engine">An instance of MSBuild.ProjectCollection build engine, that will be checked if initialized.</param>
        /// <param name="engine">The service provider.</param>
        /// <returns>The buildengine to use.</returns>
        internal static MSBuild.ProjectCollection InitializeMsBuildEngine(MSBuild.ProjectCollection existingEngine, IServiceProvider serviceProvider)
        {
            if (serviceProvider == null)
            {
                throw new ArgumentNullException("serviceProvider");
            }

            if (existingEngine == null)
            {
                MSBuild.ProjectCollection buildEngine = MSBuild.ProjectCollection.GlobalProjectCollection;
                return(buildEngine);
            }

            return(existingEngine);
        }
Esempio n. 32
0
 public CodeWindowManager(IServiceProvider serviceProvider, IVsCodeWindow codeWindow)
 {
     _serviceProvider = serviceProvider;
     _window          = codeWindow;
     _pyService       = _serviceProvider.GetPythonToolsService();
 }
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            var edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService));

            var entity  = (context.Instance as EntityShape).ModelElement as Entity;
            var popupUI = new SecurityFunctionForm();

            popupUI.Entity = entity;
            if (edSvc.ShowDialog(popupUI) == System.Windows.Forms.DialogResult.OK)
            {
                context.OnComponentChanged();
            }
            return(value);
        }
Esempio n. 34
0
 /// <summary>
 /// Constructor for SingleFileGeneratorFactory
 /// </summary>
 /// <param name="projectGuid">The project type guid of the associated project.</param>
 /// <param name="serviceProvider">A service provider.</param>
 public SingleFileGeneratorFactory(Guid projectType, System.IServiceProvider serviceProvider)
 {
     this.projectType     = projectType;
     this.serviceProvider = serviceProvider;
 }
Esempio n. 35
0
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            if (!(value is string))
            {
                return(value);
            }

            strResult = value as string;

            edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (edSvc != null)
            {
                box1.Items.Clear();
                box1.BorderStyle = BorderStyle.None;

                box1.Items.AddRange(new object[] {
                    "[Value]->[Count]",
                    "[Count]<-[Value]",
                    "[Value]:[Count]",
                    "[Count]:[Value]",
                    "[Count]",
                }
                                    );
                edSvc.DropDownControl(box1);

                return(strResult);
            }
            return(value);
        }
Esempio n. 36
0
 public static string GetMsBuildPath(IServiceProvider serviceProvider)
 {
     return(GetMsBuildPath(serviceProvider, defaultMSBuildVersion));
 }
 internal SolutionListenerForProjectEvents(IServiceProvider serviceProvider)
     : base(serviceProvider)
 {
 }
Esempio n. 38
0
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            var edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService));

            var popupUI = new SQLForm();

            popupUI.Text = "Enter SQL";
            popupUI.SQL  = (string)value;
            if (edSvc.ShowDialog(popupUI) == System.Windows.Forms.DialogResult.OK)
            {
                value = popupUI.SQL;
                context.OnComponentChanged();
            }

            return(value);
        }
        // public delegate QueryHandler Factory(IServiceProvider _provider); //not useful for now

        public QueryHandlerFactory(System.IServiceProvider provider)
        {
            this._provider = provider;
        }
        void OpenCalcPropertiesDialog()
        {
            Form form1 = null; //should be a CalcPropertiesEditorForm which is private
            Cube cube  = (Cube)this.ApplicationObject.ActiveWindow.ProjectItem.Object;

            System.IServiceProvider provider = (System.IServiceProvider) this.ApplicationObject.ActiveWindow.ProjectItem.ContainingProject;
            using (WaitCursor cursor1 = new WaitCursor())
            {
                IUserPromptService oService = (IUserPromptService)provider.GetService(typeof(IUserPromptService));

                foreach (Type t in System.Reflection.Assembly.GetAssembly(typeof(Scripts)).GetTypes())
                {
                    if (t.FullName == "Microsoft.AnalysisServices.Design.Calculations.CalcPropertiesEditorForm")
                    {
                        form1 = (Form)t.GetConstructor(new Type[] { typeof(IUserPromptService) }).Invoke(new object[] { oService });
                        break;
                    }
                }
                if (form1 == null)
                {
                    throw new Exception("Couldn't create instance of CalcPropertiesEditorForm");
                }

                object script1 = null; //should be a Microsoft.AnalysisServices.MdxCodeDom.MdxCodeScript object
                try
                {
                    //validate the script because deploying an invalid script makes cube unusable
                    Scripts scripts = new Scripts(cube);
                    System.Reflection.BindingFlags getflags = System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.GetField | System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Instance;
                    script1 = scripts.GetType().InvokeMember("mdxCodeScript", getflags, null, scripts, null);
                }
                catch (Microsoft.AnalysisServices.Design.ScriptParsingFailed ex)
                {
                    string throwaway = ex.Message; //prevents a warning during compile
                    MessageBox.Show("MDX Script in " + cube.Name + " is not valid.", "Problem Deploying MDX Script");
                    return;
                }

                if (cube.MdxScripts.Count == 0)
                {
                    MessageBox.Show("There is no MDX script defined in this cube yet.");
                    return;
                }

                System.Reflection.BindingFlags getmethodflags = System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Instance;
                form1.GetType().InvokeMember("Initialize", getmethodflags, null, form1, new object[] { cube.MdxScripts[0], script1, cube, null });

                //now make custom changes to the form
                Button okButton = (Button)form1.Controls.Find("okButton", true)[0];
                Panel  panel    = (Panel)form1.Controls.Find("gridPanel", true)[0];

                Button descButton = new Button();
                descButton.Text   = "Edit Description";
                descButton.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
                descButton.Left   = panel.Left;
                descButton.Top    = okButton.Top;
                descButton.Width += 40;
                descButton.Click += new EventHandler(descButton_Click);
                form1.Controls.Add(descButton);
            }

            if (Microsoft.DataWarehouse.DataWarehouseUtilities.ShowDialog(form1, provider) == DialogResult.OK)
            {
                using (WaitCursor cursor2 = new WaitCursor())
                {
                    System.Reflection.BindingFlags getflags    = System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Instance;
                    CalculationPropertyCollection  collection1 = (CalculationPropertyCollection)form1.GetType().InvokeMember("GetResultProperties", getflags, null, form1, new object[] { });

                    DesignerTransaction transaction1 = null;
                    try
                    {
                        IDesignerHost host1 = (IDesignerHost)ApplicationObject.ActiveWindow.Object;
                        transaction1 = host1.CreateTransaction("BidsHelperCalcPropertiesUndoBatchDesc");
                        IComponentChangeService service1 = (IComponentChangeService)ApplicationObject.ActiveWindow.Object;
                        service1.OnComponentChanging(cube.MdxScripts[0].CalculationProperties, null);
                        cube.MdxScripts[0].CalculationProperties.Clear();
                        for (int num1 = collection1.Count - 1; num1 >= 0; num1--)
                        {
                            CalculationProperty property1 = collection1[num1];
                            collection1.RemoveAt(num1);
                            cube.MdxScripts[0].CalculationProperties.Insert(0, property1);
                        }
                        service1.OnComponentChanged(cube.MdxScripts[0].CalculationProperties, null, null, null);
                    }
                    catch (CheckoutException exception1)
                    {
                        if (transaction1 != null)
                        {
                            transaction1.Cancel();
                        }
                        if (exception1 != CheckoutException.Canceled)
                        {
                            throw;
                        }
                    }
                    finally
                    {
                        if (transaction1 != null)
                        {
                            transaction1.Commit();
                        }
                    }
                }
            }
        }
Esempio n. 41
0
 /// <include file='doc\OleMenuCommandService.uex' path='docs/doc[@for="OleMenuCommandService.OleMenuCommandService"]/*' />
 /// <devdoc>
 ///     Creates a new menu command service.
 /// </devdoc>
 public OleMenuCommandService(IServiceProvider serviceProvider) : base(serviceProvider)
 {
     _provider = serviceProvider;
 }
Esempio n. 42
0
        /// <summary>
        /// Initialize the build engine. Sets the build enabled property to true. The engine is initialzed if the passed in engine is null or does not have its bin path set.
        /// </summary>
        /// <param name="engine">An instance of MSBuild.ProjectCollection build engine, that will be checked if initialized.</param>
        /// <param name="engine">The service provider.</param>
        /// <returns>The buildengine to use.</returns>
        internal static MSBuild.ProjectCollection InitializeMsBuildEngine(MSBuild.ProjectCollection existingEngine, IServiceProvider serviceProvider)
        {
            Utilities.ArgumentNotNull("serviceProvider", serviceProvider);

            if (existingEngine == null)
            {
                MSBuild.ProjectCollection buildEngine = MSBuild.ProjectCollection.GlobalProjectCollection;
                return(buildEngine);
            }

            return(existingEngine);
        }
 public BackspaceDeleteKeyFilter(DisplayWindowHelper displayHelper, IWpfTextView textView, IServiceProvider provider)
     : base(displayHelper, textView, provider)
 {
 }
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (edSvc != null)
            {
                edSvc.CloseDropDown();
                ImageSelectControl isc = new ImageSelectControl((IImageList)context.Instance, edSvc);
                edSvc.DropDownControl(isc);
                if (isc.ImageIDSelected != null)
                {
                    return(isc.ImageIDSelected);
                }
            }
            return(value);
        }
        // Displays the UI for value selection.
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            PropertiesUtils.PropertyWrapper pw;
            if ((pw = context.PropertyDescriptor as PropertiesUtils.PropertyWrapper) == null)
            {
                return(value);
            }

            DependencyObject depObj = pw.ControlledObject as DependencyObject;

            DependencyPropertyDescriptor dpd = DependencyPropertyDescriptor.FromProperty(pw.ControlledProperty);

            if (depObj == null || dpd == null)
            {
                return(value);
            }
            DependencyProperty depProp = dpd.DependencyProperty;
            //if (!(depProp is System.Windows.Controls.ContentControl)  )
            //  return value;

            IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (edSvc != null)
            {
                ContentEditorDialog dlg = new ContentEditorDialog(true);
                System.Windows.Forms.DialogResult res = edSvc.ShowDialog(dlg);

                if (res == System.Windows.Forms.DialogResult.OK && dlg.ImagesList.Count > 0)
                {
                    if (depObj is AnimatedImage)
                    {
                        depObj.SetValue(depProp, dlg.ImagesList[0]);
                    }
                    else if (depObj is System.Windows.Controls.ContentControl)
                    {
                        AnimatedImage ai = new AnimatedImage();
                        ai.ImageName       = dlg.ImagesList[0];
                        ai.AnimatedControl = true;
                        System.ComponentModel.TypeDescriptor.AddAttributes(ai, new Attribute[] { new System.Windows.Markup.RuntimeNamePropertyAttribute(ai.ImageName) });
                        depObj.SetValue(depProp, ai);
                    }
                }
            }

            return(value);
        }
Esempio n. 46
0
 public FillParagraphCommand(System.IServiceProvider serviceProvider)
 {
     _serviceProvider = serviceProvider;
 }
Esempio n. 47
0
 /// <devdoc>
 ///     Creates a new container using the given service provider.
 /// </devdoc>
 internal PackageContainer(System.IServiceProvider provider)
 {
     _provider = provider;
 }
 public StartWithoutDebuggingCommand(System.IServiceProvider serviceProvider)
     : base(serviceProvider)
 {
 }
Esempio n. 49
0
        /// <summary>
        /// Displays a file open dialog box to allow the user to edit the specified path (value).
        /// Sets the initial directory of the file open dialog box to be the path, if it's valid.</summary>
        /// <param name="context">Type descriptor context</param>
        /// <param name="provider">Service provider</param>
        /// <param name="value">Path to edit</param>
        /// <returns>Edited path</returns>
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            // An exception thrown here will be unhandled by PropertyEditingControl and will bring down the app,
            //  so it seems prudent to not let that happen due to the feature of setting the initial directory
            //  or due to problems with the .Net OpenFileDialog. Different kinds of exceptions can be thrown:
            // System.ArgumentException -- Path.GetDirectoryName() if the path contains invalid characters.
            // System.IO.PathTooLongException -- Path.GetDirectoryName() if the path is too long.
            // InvalidOperationException -- System.Windows.Forms.OpenFileDialog if the path is badly formed or
            //  contains invalid characters, on Windows XP.
            try
            {
                // Try to set the initial directory to be the path that's in 'value'.
                // Also, fix up the path by removing forward slashes. This is critical for Windows XP.
                m_initialDirectory = null;

                // Can't use the property descriptor to convert to a string because we need the LocalPath
                //  if possible.
                //string path = context.PropertyDescriptor.Converter.ConvertToString(value);
                string path = value as string;
                if (path == null)
                {
                    Uri uri = value as Uri;
                    if (uri != null)
                    {
                        if (uri.IsAbsoluteUri)
                        {
                            path = uri.LocalPath;
                        }
                        else
                        {
                            path = uri.OriginalString;
                        }
                    }
                }

                if (!string.IsNullOrEmpty(path))
                {
                    string fixedPath = path.Replace('/', '\\');
                    if (fixedPath != path)
                    {
                        value = context.PropertyDescriptor.Converter.ConvertFromString(fixedPath);
                    }

                    if (File.Exists(fixedPath))
                    {
                        string directory = Path.GetDirectoryName(fixedPath);
                        if (!string.IsNullOrEmpty(directory))
                        {
                            m_initialDirectory = directory;
                        }
                    }
                }

                if (m_dialog != null &&
                    !string.IsNullOrEmpty(m_initialDirectory))
                {
                    m_dialog.InitialDirectory = m_initialDirectory;
                }

                return(base.EditValue(context, provider, value));
            }
            catch (Exception e)
            {
                Outputs.WriteLine(OutputMessageType.Error, e.Message);
                return(value);
            }
        }
Esempio n. 50
0
 public RemoveImportsCommand(System.IServiceProvider serviceProvider)
 {
     _serviceProvider = serviceProvider;
 }
Esempio n. 51
0
        // Displays the UI for value selection.
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            PropertiesUtils.PropertyWrapper pw;
            if ((pw = context.PropertyDescriptor as PropertiesUtils.PropertyWrapper) == null)
            {
                return(value);
            }

            DependencyObject             depObj = pw.ControlledObject as DependencyObject;
            DependencyPropertyDescriptor dpd    = DependencyPropertyDescriptor.FromProperty(pw.ControlledProperty);

            if (depObj == null || dpd == null)
            {
                return(value);
            }
            DependencyProperty         depProp = dpd.DependencyProperty;
            IWindowsFormsEditorService edSvc   = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (edSvc != null)
            {
                using (ListBox lb = new ListBox())
                {
                    StylesLibrary.StylesLibrary sl = StylesLibrary.StylesLibrary.Instance;
                    if (sl[depObj.GetType()] != null)
                    {
                        foreach (String name in sl[depObj.GetType()].Keys)
                        {
                            lb.Items.Add(name);
                        }

                        lb.SelectedIndexChanged += new EventHandler((x, y) => { edSvc.CloseDropDown(); });
                        edSvc.DropDownControl(lb);
                        if (lb.SelectedItem != null)
                        {
                            depObj.SetValue(depProp, sl[depObj.GetType()][lb.SelectedItem.ToString()]);
                        }
                    }
                }
            }

            return(value);
        }
Esempio n. 52
0
 public override object ProvideValue(System.IServiceProvider serviceProvider)
 {
     return(this);
 }
Esempio n. 53
0
        /// <summary>
        /// Updates the ServiceDefinition.csdef file in
        /// <paramref name="project"/> to include the default startup and
        /// runtime tasks for Python projects.
        /// </summary>
        /// <param name="project">
        /// The Cloud Service project to update.
        /// </param>
        /// <param name="roleType">
        /// The type of role being added, either "Web" or "Worker".
        /// </param>
        /// <param name="projectName">
        /// The name of the role. This typically matches the Caption property.
        /// </param>
        /// <param name="site">
        /// VS service provider.
        /// </param>
        internal static void UpdateServiceDefinition(
            IVsHierarchy project,
            string roleType,
            string projectName,
            System.IServiceProvider site
            )
        {
            Utilities.ArgumentNotNull("project", project);

            object obj;

            ErrorHandler.ThrowOnFailure(project.GetProperty(
                                            (uint)VSConstants.VSITEMID.Root,
                                            (int)__VSHPROPID.VSHPROPID_FirstChild,
                                            out obj
                                            ));

            uint id;

            while (TryGetItemId(obj, out id))
            {
                Guid   itemType;
                string mkDoc;

                if (ErrorHandler.Succeeded(project.GetGuidProperty(id, (int)__VSHPROPID.VSHPROPID_TypeGuid, out itemType)) &&
                    itemType == VSConstants.GUID_ItemType_PhysicalFile &&
                    ErrorHandler.Succeeded(project.GetProperty(id, (int)__VSHPROPID.VSHPROPID_Name, out obj)) &&
                    "ServiceDefinition.csdef".Equals(obj as string, StringComparison.InvariantCultureIgnoreCase) &&
                    ErrorHandler.Succeeded(project.GetCanonicalName(id, out mkDoc)) &&
                    !string.IsNullOrEmpty(mkDoc)
                    )
                {
                    // We have found the file
                    var rdt = site.GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable;

                    IVsHierarchy docHier;
                    uint         docId, docCookie;
                    IntPtr       pDocData;

                    var updateFileOnDisk = true;

                    if (ErrorHandler.Succeeded(rdt.FindAndLockDocument(
                                                   (uint)_VSRDTFLAGS.RDT_EditLock,
                                                   mkDoc,
                                                   out docHier,
                                                   out docId,
                                                   out pDocData,
                                                   out docCookie
                                                   )))
                    {
                        try
                        {
                            if (pDocData != IntPtr.Zero)
                            {
                                try
                                {
                                    // File is open, so edit it through the document
                                    UpdateServiceDefinition(
                                        Marshal.GetObjectForIUnknown(pDocData) as IVsTextLines,
                                        roleType,
                                        projectName
                                        );

                                    ErrorHandler.ThrowOnFailure(rdt.SaveDocuments(
                                                                    (uint)__VSRDTSAVEOPTIONS.RDTSAVEOPT_ForceSave,
                                                                    docHier,
                                                                    docId,
                                                                    docCookie
                                                                    ));

                                    updateFileOnDisk = false;
                                }
                                catch (ArgumentException)
                                {
                                }
                                catch (InvalidOperationException)
                                {
                                }
                                catch (COMException)
                                {
                                }
                                finally
                                {
                                    Marshal.Release(pDocData);
                                }
                            }
                        }
                        finally
                        {
                            ErrorHandler.ThrowOnFailure(rdt.UnlockDocument(
                                                            (uint)_VSRDTFLAGS.RDT_Unlock_SaveIfDirty | (uint)_VSRDTFLAGS.RDT_RequestUnlock,
                                                            docCookie
                                                            ));
                        }
                    }

                    if (updateFileOnDisk)
                    {
                        // File is not open, so edit it on disk
                        FileStream stream = null;
                        try
                        {
                            UpdateServiceDefinition(mkDoc, roleType, projectName);
                        }
                        finally
                        {
                            if (stream != null)
                            {
                                stream.Close();
                            }
                        }
                    }

                    break;
                }

                if (ErrorHandler.Failed(project.GetProperty(id, (int)__VSHPROPID.VSHPROPID_NextSibling, out obj)))
                {
                    break;
                }
            }
        }
Esempio n. 54
0
 internal static void NavigateTo(System.IServiceProvider serviceProvider, string filename, Guid docViewGuidType, int line, int col)
 {
     VsUtilities.NavigateTo(serviceProvider, filename, docViewGuidType, line, col);
 }
Esempio n. 55
0
 internal static void OpenNoInterpretersHelpPage(System.IServiceProvider serviceProvider, string page = null)
 {
     OpenVsWebBrowser(serviceProvider, page ?? PythonToolsInstallPath.GetFile("NoInterpreters.mht"));
 }
 public StartScriptCommand(System.IServiceProvider serviceProvider)
 {
     _serviceProvider = serviceProvider;
 }
Esempio n. 57
0
 /// <include file='doc\WindowPane.uex' path='docs/doc[@for="WindowPane.WindowPane"]' />
 /// <devdoc>
 ///     Creates a new window pane.  The window pane can accept a service provider
 ///     to use when resolving services.  This provider can be null.
 /// </devdoc>
 protected WindowPane(IServiceProvider provider)
     : this()
 {
     _parentProvider = provider;
 }
Esempio n. 58
0
        private void ShowDiff(string oldFile, string newFile, bool bIgnoreCase, bool bIgnoreEOL, bool bIgnoreWhiteSpace, string sOldFileName, string sNewFileName)
        {
            string sCustomDiffViewer = CustomDiffViewer;

            if (!string.IsNullOrEmpty(sCustomDiffViewer))
            {
                try
                {
                    int iOldFile = sCustomDiffViewer.IndexOf('?');
                    int iNewFile = sCustomDiffViewer.LastIndexOf('?');
                    sCustomDiffViewer = sCustomDiffViewer.Substring(0, iOldFile) + '"' + oldFile + '"' + sCustomDiffViewer.Substring(iOldFile + 1, iNewFile - iOldFile - 1) + '"' + newFile + '"' + sCustomDiffViewer.Substring(iNewFile + 1);
                    Microsoft.VisualBasic.Interaction.Shell(sCustomDiffViewer, Microsoft.VisualBasic.AppWinStyle.MaximizedFocus, true, -1);
                    return;
                }
                catch (Exception ex)
                {
                    throw new Exception("There was a problem using the custom diff viewer: " + sCustomDiffViewer, ex);
                }
            }


            //try the VS2012 built-in diff viewer
            string sVS2012Error = string.Empty;

            if (this.ApplicationObject.Version.CompareTo("11.") == 1 || this.ApplicationObject.Version.CompareTo("12.") == 1)
            {
                try
                {
                    System.Reflection.Assembly vsAssembly = System.Reflection.Assembly.Load(VS2012_SHELL_INTEROP_ASSEMBLY_FULL_NAME);

                    UIHierarchy     solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                    UIHierarchyItem hierItem    = (UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0);
                    ProjectItem     projItem    = (ProjectItem)hierItem.Object;
                    string          sTabName    = projItem.Name + " (BIDS Helper Smart Diff)";

                    System.IServiceProvider provider = null;
                    if (projItem.ContainingProject is System.IServiceProvider)
                    {
                        provider = (System.IServiceProvider)projItem.ContainingProject;
                    }
                    else
                    {
                        provider = TabularHelpers.GetTabularServiceProviderFromBimFile(hierItem, false);
                    }
                    //TODO: test .rdlc inside C# projects

                    Type   t = vsAssembly.GetType("Microsoft.VisualStudio.Shell.Interop.IVsDifferenceService");
                    object oVsDifferenceService = provider.GetService(vsAssembly.GetType("Microsoft.VisualStudio.Shell.Interop.SVsDifferenceService"));
                    Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame frame = (Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame)t.InvokeMember("OpenComparisonWindow2", System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance, null, oVsDifferenceService, new object[] { oldFile, newFile, sTabName, "BIDS Helper Smart Diff", sOldFileName, sNewFileName, "", "", (uint)0 });

                    return;
                }
                catch (Exception exVS2012)
                {
                    sVS2012Error = exVS2012.Message;
                }
            }

            int    fFlags = 0;
            string sFlags = "";

            if (bIgnoreCase)
            {
                fFlags |= 1;
                sFlags += " -ic";
            }
            if (bIgnoreEOL)
            {
                fFlags |= 4;
                sFlags += " -ie";
            }
            if (bIgnoreWhiteSpace)
            {
                fFlags |= 2;
                sFlags += " -iw";
            }

            try
            {
                MSDiff_ShowDiffUI(IntPtr.Zero, oldFile, newFile, fFlags, sOldFileName, sNewFileName);
                MSDiff_Cleanup();
            }
            catch (Exception exMSDiff)
            {
                //couldn't use MSDiff (which gets intalled with TFS2010 and below)
                //try VSS EXE
                try
                {
                    string sVSSDir = VSSInstallDir;
                    if (string.IsNullOrEmpty(sVSSDir))
                    {
                        throw new Exception("");
                    }
                    else
                    {
                        Microsoft.VisualBasic.Interaction.Shell("\"" + sVSSDir + "ssexp.exe\" /diff" + sFlags + " \"" + oldFile + "\" \"" + newFile + "\"", Microsoft.VisualBasic.AppWinStyle.MaximizedFocus, true, -1);
                    }
                }
                catch (Exception exVSS)
                {
                    if (!string.IsNullOrEmpty(sVS2012Error))
                    {
                        sVS2012Error = "\r\n\r\nCould not use the built-in Visual Studio diff viewer:\r\n" + sVS2012Error;
                    }
                    throw new Exception("Could not start Microsoft Visual SourceSafe 2005 to view diff. " + exVSS.Message + "\r\n\r\nCould not utilize Microsoft Team Foundation Server to view diff. " + exMSDiff.Message + sVS2012Error);
                }
            }
        }
Esempio n. 59
0
 public KeybindingResetDetector(VisualStudioWorkspace workspace, SVsServiceProvider serviceProvider)
 {
     _workspace       = workspace;
     _serviceProvider = serviceProvider;
 }
Esempio n. 60
0
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            if (value.GetType() != typeof(Color))
            {
                return(value);
            }

            // Uses the IWindowsFormsEditorService to display a
            // drop-down UI in the Properties window.
            IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (edSvc != null)
            {
                ColorEditorControl editor = new ColorEditorControl((Color)value);
                edSvc.DropDownControl(editor);

                // Return the value in the appropraite data format.
                if (value.GetType() == typeof(Color))
                {
                    return(editor.color);
                }
            }
            return(value);
        }