/// <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()
        {
            Debug.WriteLine (string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));


            this.solutionListeners.Add(new SolutionListenerForProjectOpen(this));
            this.solutionListeners.Add(new SolutionListenerForProjectEvents(this));

            foreach (SolutionListener solutionListener in this.solutionListeners)
            {
                solutionListener.Init();
            }

            listener = new SolutionEventsListener();

            winmgr = Package.GetGlobalService(typeof(IVsUIShellDocumentWindowMgr)) as IVsUIShellDocumentWindowMgr;

            listener.OnQueryUnloadProject += () =>
            {
                comStream = SaveDocumentWindowPositions(winmgr);
            };
            listener.OnAfterOpenProject += () =>
            {
                int hr = winmgr.ReopenDocumentWindows(comStream);
                comStream = null;
            };

            base.Initialize();

            IVsTextImageUtilities svt = GetService(typeof(IVsTextImageUtilities)) as IVsTextImageUtilities;
            if (null != svt)
            {
                svt.SaveTextImageToFile("newfile.c#",
            }


            // Add our command handlers for menu (commands must exist in the .vsct file)
            OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if ( null != mcs )
            {
                // Create the command for the menu item.
                CommandID menuCommandID = new CommandID(GuidList.guidAppMobiCloudServiceExtensionCmdSet, (int)PkgCmdIDList.cmdidAppMobiCloudServiceCommand);
                //MenuCommand menuItem = new MenuCommand(MenuItemCallback, menuCommandID );
                //mcs.AddCommand( menuItem );
                toolMenuItem1 = new MenuCommand(MenuItemCallback, menuCommandID);
                mcs.AddCommand(toolMenuItem1);      
                
                // Create the command for the tool window
                CommandID toolwndCommandID = new CommandID(GuidList.guidAppMobiCloudServiceExtensionCmdSet, (int)PkgCmdIDList.cmdidAppMobiCloudServiceTool);
                MenuCommand menuToolWin = new MenuCommand(ShowToolWindow, toolwndCommandID);
                mcs.AddCommand( menuToolWin );

                for (int i = PkgCmdIDList.cmdidMCItem1; i <= PkgCmdIDList.cmdidMCItem3; i++)
                {
                    CommandID cmdID = new CommandID(GuidList.guidAppMobiCloudServiceExtensionCmdSet, i);
                    OleMenuCommand mc = new OleMenuCommand(new EventHandler(OnMCItemClicked), cmdID);
                    mc.BeforeQueryStatus += new EventHandler(OnMCItemQueryStatus);
                    mcs.AddCommand(mc);
                    // The first item is, by default, checked.
                    if (PkgCmdIDList.cmdidMCItem1 == i)
                    {
                        mc.Checked = true;
                        this.currentMCCommand = i;
                    }
                }
            
            }
        }
        /// <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()
        {
            Debug.WriteLine (string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));

            this.solutionListeners.Add(new SolutionListenerForProjectOpen(this));
            this.solutionListeners.Add(new SolutionListenerForProjectEvents(this));

            foreach (SolutionListener solutionListener in this.solutionListeners)
            {
                solutionListener.Init();
            }

            listener = new SolutionEventsListener();

            winmgr = Package.GetGlobalService(typeof(IVsUIShellDocumentWindowMgr)) as IVsUIShellDocumentWindowMgr;

            listener.OnQueryUnloadProject += () =>
            {
                comStream = SaveDocumentWindowPositions(winmgr);
            };
            listener.OnAfterOpenProject += () =>
            {
                int hr = winmgr.ReopenDocumentWindows(comStream);
                comStream = null;
            };

            base.Initialize();

            IVsTextImageUtilities svt = GetService(typeof(IVsTextImageUtilities)) as IVsTextImageUtilities;
            if (null != svt)
            {
                svt.SaveTextImageToFile("newfile.c#",
            }

            // Add our command handlers for menu (commands must exist in the .vsct file)
            OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if ( null != mcs )
            {
                // Create the command for the menu item.
                CommandID menuCommandID = new CommandID(GuidList.guidAppMobiCloudServiceExtensionCmdSet, (int)PkgCmdIDList.cmdidAppMobiCloudServiceCommand);
                //MenuCommand menuItem = new MenuCommand(MenuItemCallback, menuCommandID );
                //mcs.AddCommand( menuItem );
                toolMenuItem1 = new MenuCommand(MenuItemCallback, menuCommandID);
                mcs.AddCommand(toolMenuItem1);

                // Create the command for the tool window
                CommandID toolwndCommandID = new CommandID(GuidList.guidAppMobiCloudServiceExtensionCmdSet, (int)PkgCmdIDList.cmdidAppMobiCloudServiceTool);
                MenuCommand menuToolWin = new MenuCommand(ShowToolWindow, toolwndCommandID);
                mcs.AddCommand( menuToolWin );

                for (int i = PkgCmdIDList.cmdidMCItem1; i <= PkgCmdIDList.cmdidMCItem3; i++)
                {
                    CommandID cmdID = new CommandID(GuidList.guidAppMobiCloudServiceExtensionCmdSet, i);
                    OleMenuCommand mc = new OleMenuCommand(new EventHandler(OnMCItemClicked), cmdID);
                    mc.BeforeQueryStatus += new EventHandler(OnMCItemQueryStatus);
                    mcs.AddCommand(mc);
                    // The first item is, by default, checked.
                    if (PkgCmdIDList.cmdidMCItem1 == i)
                    {
                        mc.Checked = true;
                        this.currentMCCommand = i;
                    }
                }

            }
        }

        /// <summary>
        /// This function is the callback used to execute a command when the a menu item is clicked.
        /// See the Initialize method to see how the menu item is associated to this function using
        /// the OleMenuCommandService service and the MenuCommand class.
        /// </summary>
        private void MenuItemCallback(object sender, EventArgs e)
        {
            // Show a Message Box to prove we were here
            IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell));
            Guid clsid = Guid.Empty;
            int result;
            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(uiShell.ShowMessageBox(
                       0,
                       ref clsid,
                       "AppMobiCloudServiceExtension",
                       string.Format(CultureInfo.CurrentCulture, "Inside {0}.MenuItemCallback()", this.ToString()),
                       string.Empty,
                       0,
                       OLEMSGBUTTON.OLEMSGBUTTON_OK,
                       OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST,
                       OLEMSGICON.OLEMSGICON_INFO,
                       0,        // false
                       out result));
        }