Inheritance: ProjectPackage, IOleComponent
        public override void Initialize()
        {
            base.Initialize();

            generalPropertyPage = new XSharpGeneralPropertyPage();

            customProjectPackage = new XSharpProjectPackage();
            ((IVsPackage)customProjectPackage).SetSite(serviceProvider);

            customProjectFactory = new XSharpProjectFactory(customProjectPackage);

            base.SetMsbuildEngine(customProjectFactory);

            int canCreate;
            if(VSConstants.S_OK == ((IVsProjectFactory)customProjectFactory).CanCreateProject(projectFile, 2, out canCreate))
            {
                PrivateType type = new PrivateType(typeof(XSharpProjectFactory));
                PrivateObject obj = new PrivateObject(customProjectFactory, type);
                projectNode = (XSharpProjectNode)obj.Invoke("PreCreateForOuter", new object[] { IntPtr.Zero });

                Guid iidProject = new Guid();
                int pfCanceled;
                projectNode.Load(projectFile, "", "", 2, ref iidProject, out pfCanceled);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns a standard VS color or a system color, if the VS colors service is not available
        /// </summary>
        /// <param name="visualStudioColor">Color enum</param>
        /// <returns>The color itself</returns>
        internal static Color GetVsColor(Vs2010Color visualStudioColor)
        {
            uint        win32Color = 0;
            IVsUIShell2 vsuiShell2 = XSharpProjectPackage.GetGlobalService(typeof(SVsUIShell)) as IVsUIShell2;

            if (vsuiShell2 != null && vsuiShell2.GetVSSysColorEx((Int32)visualStudioColor, out win32Color) == VSConstants.S_OK)
            {
                Color color = ColorTranslator.FromWin32((int)win32Color);
                return(color);
            }

            // We need to fall back to some reasonable colors when we're not running in VS
            // to keep the forms/property pages editable in the designers
            switch (visualStudioColor)
            {
            //case Vs2010Color.VSCOLOR_BUTTONFACE:
            //    return SystemColors.ButtonFace;

            case Vs2010Color.VSCOLOR_BUTTONTEXT:
                return(SystemColors.ControlText);

            case Vs2010Color.VSCOLOR_WINDOW:
                return(SystemColors.Window);

            default:
                return(Color.Red);
            }
        }
Exemplo n.º 3
0
        public void InitializeTest()
        {
            IVsPackage package = new XSharpProjectPackage();

            int expected = VSConstants.S_OK;
            int actual = package.SetSite(serviceProvider);

            Assert.AreEqual(expected, actual, "SetSite did not return VSConstants.S_OK");

            actual = package.SetSite(null);

            Assert.AreEqual(expected, actual, "SetSite(null) did not return VSConstants.S_OK");
        }
Exemplo n.º 4
0
        // XSharpLanguageService _langService = null;
        #region Overridden Implementation
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            // Give the codemodel a way to talk to the VS Shell
            oShellLink          = new XSharpShellLink();
            XSettings.ShellLink = oShellLink;

            this.RegisterToolWindows();

            XSharpProjectPackage.instance = this;
            this.SolutionListeners.Add(new SolutionEvents(this));
            await base.InitializeAsync(cancellationToken, progress);

            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            // The project selector helps to choose between MPF and CPS projects
            //_projectSelector = new XSharpProjectSelector();
            //await _projectSelector.InitAsync(this);

            this.settings = new XPackageSettings(this);
            VS.Events.BuildEvents.ProjectConfigurationChanged += BuildEvents_ProjectConfigurationChanged;

            this.RegisterProjectFactory(new XSharpProjectFactory(this));
            // Indicate how to open the different source files : SourceCode or Designer ??
            this.RegisterEditorFactory(new XSharpEditorFactory(this));
            this.RegisterProjectFactory(new XSharpWPFProjectFactory(this));

            // editors for the binaries
            base.RegisterEditorFactory(new VOFormEditorFactory(this));
            base.RegisterEditorFactory(new VOMenuEditorFactory(this));
            base.RegisterEditorFactory(new VODBServerEditorFactory(this));
            base.RegisterEditorFactory(new VOFieldSpecEditorFactory(this));

            //this._documentWatcher = new XSharpDocumentWatcher(this);
            _errorList = await VS.GetRequiredServiceAsync <SVsErrorList, IErrorList>();

            _taskList = await VS.GetRequiredServiceAsync <SVsTaskList, ITaskList>();

            var shell = await VS.GetRequiredServiceAsync <SVsShell, IVsShell>();

            if (shell != null)
            {
                shell.AdviseShellPropertyChanges(this, out shellCookie);
            }
            _langservice = await GetServiceAsync(typeof(XSharpLanguageService)) as XSharpLanguageService;

            await this.RegisterCommandsAsync();
            await GetEditorOptionsAsync();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Refreshes the data in the property browser
        /// </summary>
        internal static void RefreshPropertyBrowser()
        {
            IVsUIShell vsuiShell = XSharpProjectPackage.GetGlobalService(typeof(SVsUIShell)) as IVsUIShell;

            if (vsuiShell == null)
            {
                string message = XHelperMethods.SafeStringFormat(CultureInfo.CurrentUICulture, Resources.GetString(Resources.CannotGetService), typeof(IVsUIShell).Name);
                throw new InvalidOperationException(message);
            }
            else
            {
                int hr = vsuiShell.RefreshPropertyBrowser(0);
                if (hr != 0)
                {
                    Marshal.ThrowExceptionForHR(hr);
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XSharpProjectNode"/> class.
        /// </summary>
        /// <param name="package">Value of the project package for initialize internal package field.</param>
        public XSharpProjectNode(XSharpProjectPackage package)
        {
            this.package = package;

            InitializeImageList();

            InitializeCATIDs();

            // Used by (at least) the AddFromTemplate in order (for eg) to have Form1.Designer.Prg depending on Form1.prg
            this.CanFileNodesHaveChilds = true;

            this.CanProjectDeleteItems = true;

            // Gets or sets whether the project uses the Project Designer Editor or the property page frame to edit project properties. 
            // True : New WPF way
            // False: C++-Like Property pages
            this.SupportsProjectDesigner = true;
        }
Exemplo n.º 7
0
        static XSharpXMLDocTools()
        {
            _XMLMemberIndexService = (IVsXMLMemberIndexService)XSharpProjectPackage.GetGlobalService(typeof(SVsXMLMemberIndexService));
            // create default entry so our own xml lookup will work
            var node        = @"HKEY_LOCAL_MACHINE\Software\XSharpBV\XSharp";
            var InstallPath = (string)Microsoft.Win32.Registry.GetValue(node, "XSharpPath", "");
            var assemblies  = Path.Combine(InstallPath, "Assemblies");
            var location    = Path.Combine(assemblies, "XSharp.Core.dll");
            IVsXMLMemberIndex index;

            _XMLMemberIndexService.CreateXMLMemberIndex(location, out index);
            if (index != null)
            {
                _memberIndexes.Add(location, index);
                coreLoc   = location;
                coreIndex = index;
            }
        }
Exemplo n.º 8
0
 public void ConstructorTest()
 {
     XSharpProjectPackage package = new XSharpProjectPackage();
     Assert.IsNotNull(package, "Constructor failed");
 }
Exemplo n.º 9
0
        // XSharpLanguageService _langService = null;
        #region Overridden Implementation
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            // Suspend walking until Solution is opened.
            base.SolutionListeners.Add(new ModelScannerEvents(this));
            await base.InitializeAsync(cancellationToken, progress);

            await JoinableTaskFactory.SwitchToMainThreadAsync();

            _uiThread = new UIThread();
            XSharpProjectPackage.instance      = this;
            XSharpModel.XSolution.OutputWindow = this;
            this.RegisterProjectFactory(new XSharpProjectFactory(this));
            this.settings = new XPackageSettings(this);
            validateVulcanEditors();
            this.RegisterDebuggerEvents();
            // Indicate how to open the different source files : SourceCode or Designer ??
            this.RegisterEditorFactory(new XSharpEditorFactory(this));
            this.RegisterProjectFactory(new XSharpWPFProjectFactory(this));

            // editors for the binaries
            base.RegisterEditorFactory(new VOFormEditorFactory(this));
            base.RegisterEditorFactory(new VOMenuEditorFactory(this));
            base.RegisterEditorFactory(new VODBServerEditorFactory(this));
            base.RegisterEditorFactory(new VOFieldSpecEditorFactory(this));
            XSharp.Project.XSharpMenuItems.Initialize(this);

            // Register a timer to call our language service during
            // idle periods.
            IOleComponentManager mgr = await GetServiceAsync(typeof(SOleComponentManager)) as IOleComponentManager;

            if (m_componentID == 0 && mgr != null)
            {
                OLECRINFO[] crinfo = new OLECRINFO[1];
                crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO));
                crinfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime |
                                   (uint)_OLECRF.olecrfNeedPeriodicIdleTime;
                crinfo[0].grfcadvf = (uint)_OLECADVF.olecadvfModal |
                                     (uint)_OLECADVF.olecadvfRedrawOff |
                                     (uint)_OLECADVF.olecadvfWarningsOff;
                crinfo[0].uIdleTimeInterval = 1000;
                int hr = mgr.FRegisterComponent(this, crinfo, out m_componentID);
            }
            // Initialize Custom Menu Items
            // register property changed event handler


            var shell = await this.GetServiceAsync(typeof(SVsShell)) as IVsShell;

            Assumes.Present(shell);

            shell.AdviseShellPropertyChanges(this, out shellCookie);
            //
            // ObjectBrowser : Add the LibraryManager service as a Service provided by that container
            IServiceContainer      container = this as IServiceContainer;
            ServiceCreatorCallback callback  = new ServiceCreatorCallback(CreateLibraryService);

            //
            container.AddService(typeof(IXSharpLibraryManager), callback, true);
            this._documentWatcher = new XSharpDocumentWatcher(this);

            _txtManager = await GetServiceAsync(typeof(SVsTextManager)) as IVsTextManager4;

            // determine version of VS
            object vers;

            shell.GetProperty((int)__VSSPROPID5.VSSPROPID_ReleaseVersion, out vers);

            VsVersion  = vers.ToString();
            _errorList = await GetServiceAsync(typeof(SVsErrorList)) as IErrorList;

            _taskList = await GetServiceAsync(typeof(SVsTaskList)) as ITaskList;
        }
Exemplo n.º 10
0
        public VODBServerEditorFactory(XSharpProjectPackage package)
            : base()
        {

            this.editorPackage = package;
        }
Exemplo n.º 11
0
        public VOFieldSpecEditorFactory(XSharpProjectPackage package)
            : base()
        {

            this.editorPackage = package;
        }
Exemplo n.º 12
0
 /// <summary>
 /// </summary>
 /// <param name="package">Our Package instance.</param>
 public VOEditorPane(XSharpProjectPackage package)
    : base(null)
 {
     PrivateInit(package);
     
 }
Exemplo n.º 13
0
 public VOMenuEditorPane(XSharpProjectPackage package) : base(package)
 {
     MyExtension = ".xsmnu";
 }
Exemplo n.º 14
0
 public XSharpSignatureHelpSource(ITextBuffer textBuffer)
 {
     m_textBuffer = textBuffer;
     package      = XSharpProjectPackage.Instance;
     optionsPage  = package.GetIntellisenseOptionsPage();
 }
Exemplo n.º 15
0
 public VOFormEditorPane(XSharpProjectPackage package) : base(package)
 {
     MyExtension = ".xsfrm";
 }
Exemplo n.º 16
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            // Suspend walking until Solution is opened.
            base.SolutionListeners.Add(new ModelScannerEvents(this));
            base.Initialize();
            XSharpProjectPackage.instance      = this;
            XSharpModel.XSolution.OutputWindow = this;
            this.RegisterProjectFactory(new XSharpProjectFactory(this));
            this.settings = new XPackageSettings(this);
            validateVulcanEditors();
            this.RegisterDebuggerEvents();
            // Indicate how to open the different source files : SourceCode or Designer ??
            this.RegisterEditorFactory(new XSharpEditorFactory(this));
            this.RegisterProjectFactory(new XSharpWPFProjectFactory(this));

            // editors for the binaries
            base.RegisterEditorFactory(new VOFormEditorFactory(this));
            base.RegisterEditorFactory(new VOMenuEditorFactory(this));
            base.RegisterEditorFactory(new VODBServerEditorFactory(this));
            base.RegisterEditorFactory(new VOFieldSpecEditorFactory(this));
            // Register the language service

            // Proffer the service.
            IServiceContainer     serviceContainer = this as IServiceContainer;
            XSharpLanguageService langService      = new XSharpLanguageService();

            langService.SetSite(this);
            serviceContainer.AddService(typeof(XSharpLanguageService),
                                        langService,
                                        true);

            // Register a timer to call our language service during
            // idle periods.
            IOleComponentManager mgr = GetService(typeof(SOleComponentManager))
                                       as IOleComponentManager;

            if (m_componentID == 0 && mgr != null)
            {
                OLECRINFO[] crinfo = new OLECRINFO[1];
                crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO));
                crinfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime |
                                   (uint)_OLECRF.olecrfNeedPeriodicIdleTime;
                crinfo[0].grfcadvf = (uint)_OLECADVF.olecadvfModal |
                                     (uint)_OLECADVF.olecadvfRedrawOff |
                                     (uint)_OLECADVF.olecadvfWarningsOff;
                crinfo[0].uIdleTimeInterval = 1000;
                int hr = mgr.FRegisterComponent(this, crinfo, out m_componentID);
            }
            // Initialize Custom Menu Items
            XSharp.Project.XSharpMenuItems.Initialize(this);
            // register property changed event handler
            var shell = this.GetService(typeof(SVsShell)) as IVsShell;

            shell.AdviseShellPropertyChanges(this, out shellCookie);
            //
            // LibraryManager : Offers Object Browser and ClassView
            // ObjectBrowser : Add the LibraryManager service as a Service provided by that container
            IServiceContainer      container = this as IServiceContainer;
            ServiceCreatorCallback callback  = new ServiceCreatorCallback(CreateService);

            //
            container.AddService(typeof(IXSharpLibraryManager), callback, true);
            this._documentWatcher = new XSharpDocumentWatcher(this);
        }
Exemplo n.º 17
0
 public XSharpEditorFactory(XSharpProjectPackage package)
 {
     _package = package;
 }
Exemplo n.º 18
0
 public VOFieldSpecEditorPane(XSharpProjectPackage package) : base(package)
 {
     MyExtension = ".xsfs";
 }
Exemplo n.º 19
0
 public VOServerEditorPane(XSharpProjectPackage package) : base(package)
 {
     MyExtension = ".xsdbs";
 }
Exemplo n.º 20
0
 public void IsIVsPackage()
 {
     XSharpProjectPackage package = new XSharpProjectPackage();
     Assert.IsNotNull(package as IVsPackage, "The object does not implement IVsPackage");
 }
Exemplo n.º 21
0
 /// <summary>
 /// Explicit default constructor.
 /// </summary>
 /// <param name="package">Value of the project package for initialize internal package field.</param>
 public XSharpProjectFactory(XSharpProjectPackage package)
     : base(package)
 {
     this.package = package;
 }
Exemplo n.º 22
0
 public XSharpProjectPackage() : base()
 {
     XInstance = this;
     ModelScannerEvents.Start();
 }
Exemplo n.º 23
0
 public VODBServerEditorFactory(XSharpProjectPackage package)
     : base()
 {
     this.editorPackage = package;
 }
Exemplo n.º 24
0
 static XSharpXMLDocTools()
 {
     _XMLMemberIndexService = (IVsXMLMemberIndexService)XSharpProjectPackage.GetGlobalService(typeof(SVsXMLMemberIndexService));
 }
Exemplo n.º 25
0
        /// <summary>
        /// Initialization routine for the Editor. Loads the list of properties for the document 
        /// which will show up in the properties window 
        /// </summary>
        /// <param name="package"></param>
        private void PrivateInit(XSharpProjectPackage package)
        {
            myPackage = package;
            loading = false;
            gettingCheckoutStatus = false;
            trackSel = null;

            Control.CheckForIllegalCrossThreadCalls = false;
            // Create an ArrayList to store the objects that can be selected
            ArrayList listObjects = new ArrayList();

            // Create the object that will show the document's properties
            // on the properties window.
            VOEditorProperties prop = new VOEditorProperties(this);
            listObjects.Add(prop);

            // Create the SelectionContainer object.
            selContainer = new Microsoft.VisualStudio.Shell.SelectionContainer(true, false);
            selContainer.SelectableObjects = listObjects;
            selContainer.SelectedObjects = listObjects;

            // Create and initialize the editor

            this.editorControl = new VOWEDControl();
            this.editorControl.IsDirtyChanged = new EventHandler(IsDirtyChangedHandler);
            this.editorControl.TriggerSave = new EventHandler(TriggerSaveHandler);

            setupCommands();
            this.editorControl.StatusBarMessage = new StatusBarMessageDelegate(StatusBarMessageHandler);
        }
Exemplo n.º 26
0
 /// <summary>
 /// Explicit default constructor.
 /// </summary>
 /// <param name="package">Value of the project package for initialize internal package field.</param>
 public XSharpProjectFactory(XSharpProjectPackage package)
     : base(package)
 {
     this.package = package;
 }
Exemplo n.º 27
0
 public VOFieldSpecEditorFactory(XSharpProjectPackage package)
     : base()
 {
     this.editorPackage = package;
 }
Exemplo n.º 28
0
 public XSharpEditorFactory(XSharpProjectPackage package)
 {
     _package = package;
 }
 public override void Initialize()
 {
     base.Initialize();
     customProjectPackage = new XSharpProjectPackage();
     ((IVsPackage)customProjectPackage).SetSite(serviceProvider);
 }