/// <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()
        {
            //按钮事件加载
            GetTKKCommand.Initialize(this);
            TranslateCommand.Initialize(this);
            ToggleAutoTranslateCommand.Initialize(this);
            base.Initialize();

            //加载配置项
            Settings.ReloadSetting((OptionPageGrid)GetDialogPage(typeof(OptionPageGrid)));


            //创建连接返回翻译内容
            if (Settings.RequestMode == RequestMode.Api)
            {
                TranslateClient = new TranslateClient(Settings);//new TranslateClient(Settings);
            }
            else
            {
                TranslateClient = new HtmlAnalysisTranslateClient(Settings);
            }

            DTE            = (DTE2)GetService(typeof(DTE));
            Events         = DTE.Events;
            DocumentEvents = Events.DocumentEvents;
            WindowEvents   = Events.WindowEvents;

            DocumentEvents.DocumentOpened += DocumentEvents_DocumentOpened;
            DocumentEvents.DocumentSaved  += DocumentEvents_DocumentSaved;
            WindowEvents.WindowActivated  += WindowEvents_WindowActivated;
        }
        /// <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()
        {
            TranslateCommand.Initialize(this);
            ToggleAutoTranslateCommand.Initialize(this);
            base.Initialize();

            //Load settting
            Settings.ReloadSetting((OptionPageGrid)GetDialogPage(typeof(OptionPageGrid)));

            //Create client
            TranslateClient = new TranslateClient(Settings);

            DTE            = (DTE2)GetService(typeof(DTE));
            Events         = DTE.Events;
            DocumentEvents = Events.DocumentEvents;
            WindowEvents   = Events.WindowEvents;

            DocumentEvents.DocumentOpened += DocumentEvents_DocumentOpened;
            DocumentEvents.DocumentSaved  += DocumentEvents_DocumentSaved;
            WindowEvents.WindowActivated  += WindowEvents_WindowActivated;
        }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes the singleton instance of the command.
 /// </summary>
 /// <param name="package">Owner package, not null.</param>
 public static void Initialize(Package package)
 {
     Instance = new TranslateCommand(package);
 }