示例#1
0
 public MainMenuCommands(OleMenuCommandService mcs, DTE dte, OptionPageGrid generalOptions, EnvHelper envHelper)
 {
     _dte            = dte;
     _mcs            = mcs;
     _generalOptions = generalOptions;
     _envHelper      = envHelper;
 }
        public void SetUp()
        {
            logSpy = new LogSpy();
            logSpy.Attach();

            var taskContext = new JoinableTaskContext();

            shellMock = Substitute.For <ILLDBShell>();

            commandWindowText = "";

            commandWindowMock = Substitute.For <IVsCommandWindow>();
            commandWindowMock.Print(Arg.Do <string>(x => commandWindowText += x));

            serviceProviderMock = Substitute.For <IServiceProvider>();

            yetiOptions = Substitute.For <OptionPageGrid>();
            var yetiService = new YetiVSIService(yetiOptions);

            serviceProviderMock.GetService(typeof(YetiVSIService)).Returns(yetiService);
            serviceProviderMock.GetService(typeof(SLLDBShell)).Returns(shellMock);
            serviceProviderMock.GetService(typeof(SVsCommandWindow)).Returns(commandWindowMock);

            menuCommandService = new OleMenuCommandService(serviceProviderMock);
            serviceProviderMock.GetService(typeof(IMenuCommandService)).Returns(menuCommandService);

            LLDBShellCommandTarget.Register(taskContext, serviceProviderMock);
        }
示例#3
0
        public static Process StartProcessGui(string application, string args, string title, string branchName = "",
                                              OutputBox outputBox = null, OptionPageGrid options = null, string pushCommand = "")
        {
            var dialogResult = DialogResult.OK;

            if (!StartProcessGit("config user.name") || !StartProcessGit("config user.email"))
            {
                dialogResult = new Credentials().ShowDialog();
            }

            if (dialogResult == DialogResult.OK)
            {
                try
                {
                    var process = new Process
                    {
                        StartInfo =
                        {
                            WindowStyle            = ProcessWindowStyle.Hidden,
                            RedirectStandardOutput = true,
                            RedirectStandardError  = true,
                            UseShellExecute        = false,
                            CreateNoWindow         = true,
                            FileName         = application,
                            Arguments        = args,
                            WorkingDirectory = EnvHelper.SolutionDir
                        },
                        EnableRaisingEvents = true
                    };
                    process.Exited             += process_Exited;
                    process.OutputDataReceived += OutputDataHandler;
                    process.ErrorDataReceived  += OutputDataHandler;

                    if (outputBox == null)
                    {
                        _outputBox = new OutputBox(branchName, options, pushCommand);
                        _outputBox.Show();
                    }
                    else
                    {
                        _outputBox = outputBox;
                    }

                    process.Start();
                    process.BeginOutputReadLine();
                    process.BeginErrorReadLine();

                    _outputBox.Text = title;
                    _outputBox.Show();

                    return(process);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, $"{application} not found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            return(null);
        }
示例#4
0
        public OutputBox(string branchName, OptionPageGrid options, string pushCommand)
        {
            InitializeComponent();

            _branchName = branchName;
            _pushCommand = pushCommand;

            richTextBox.TextChanged += textBox_TextChanged;

            if (string.IsNullOrEmpty(branchName))
            {
                localBranchCheckBox.Visible = false;
                remoteBranchCheckBox.Visible = false;
                pushCheckBox.Visible = false;
                richTextBox.Height += 30;
            }
            else
            {
                remoteBranchCheckBox.Enabled = GitHelper.RemoteBranchExists(branchName);
            }

            if (options != null)
            {
                localBranchCheckBox.Checked = options.DeleteLocalBranch;
                remoteBranchCheckBox.Checked = options.DeleteRemoteBranch;
                pushCheckBox.Checked = options.PushChanges;
            }
        }
        OptionPageGrid CreateVsiOptions()
        {
            var vsiOptions = OptionPageGrid.CreateForTesting();

            vsiOptions.LaunchGameApiFlow = LaunchGameApiFlowFlag.ENABLED;
            return(vsiOptions);
        }
示例#6
0
 public GitSVNMenuCommands(OleMenuCommandService mcs, DTE dte,
                           OptionPageGrid options, EnvHelper envHelper)
 {
     _mcs       = mcs;
     _options   = options;
     _dte       = dte;
     _envHelper = envHelper;
 }
示例#7
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void MenuItemCallback(object sender, EventArgs e)
        {
            OptionPageGrid page = (OptionPageGrid)this.package.GetDialogPage(typeof(OptionPageGrid));

            page.AutoTranslateComment = !page.AutoTranslateComment;
            page.SaveSettingsToStorage();
            page.SaveToSetting();
        }
 public void ReloadSetting(OptionPageGrid page)
 {
     this.TranslateUrl         = page.TranslateUrl;
     this.TranslateFrom        = page.TranslateFrom;
     this.TranslateTo          = page.TranslatetTo;
     this.AutoDetect           = page.AutoDetect;
     this.AutoTranslateComment = page.AutoTranslateComment;
 }
 /// <summary>
 /// 刷新设置的值
 /// </summary>
 /// <param name="page"></param>
 public void ReloadSetting(OptionPageGrid page)
 {
     TranslateUrl         = "";//page.TranslateUrl;
     TranslateFrom        = page.TranslateFrom;
     TranslateTo          = page.TranslatetTo;
     AutoDetect           = page.AutoDetect;
     AutoTranslateComment = page.AutoTranslateComment;
     TKK          = page.TKK;
     AutoTextCopy = page.AutoTextCopy;
 }
示例#10
0
文件: Publish.cs 项目: thxu/TPublish
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void Execute(object sender, EventArgs e)
        {
            try
            {
                ThreadHelper.ThrowIfNotOnUIThread();
                var projInfo = ThreadHelper.JoinableTaskFactory.Run(GetSelectedProjInfoAsync);
                if (projInfo == null)
                {
                    throw new Exception("您还未选中项目");
                }

                if (projInfo.Kind != "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}")
                {
                    throw new Exception("当前插件仅支持C#程序");
                }

                var projModel = projInfo.AnalysisProject();
                if (projModel == null)
                {
                    throw new Exception("项目信息解析失败");
                }

                OptionPageGrid settingInfo = PublishService.GetSettingPage();
                if (string.IsNullOrWhiteSpace(settingInfo?.IpAdress))
                {
                    throw new Exception("请先完善设置信息");
                }

                // 尝试连接服务器
                //var isConnected = PublishService.CheckConnection();
                //if (!isConnected)
                //{
                //    throw new Exception("尝试连接服务器失败");
                //}

                //var publishForm = new PublishForm();
                //publishForm.Show();
                //publishForm.Ini(projModel);

                var form   = new DeployForm();
                var iniRes = form.Ini(projModel);
                if (iniRes.IsSucceed)
                {
                    form.Show();
                }
                else
                {
                    MessageBox.Show(iniRes.Message);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
示例#11
0
        public MediumTestServiceManager(JoinableTaskContext taskContext, OptionPageGrid vsiOptions)
            : base(taskContext)
        {
            var vsiService            = new YetiVSIService(vsiOptions);
            var symbolSettingsManager = new VsDebuggerSymbolSettingsManagerStub();
            var metrics = new MetricsService(taskContext, Versions.Populate(null));

            AddService(typeof(SVsShellDebugger), symbolSettingsManager);
            AddService(typeof(YetiVSIService), vsiService);
            AddService(typeof(SMetrics), metrics);
        }
示例#12
0
        /// <summary>
        /// Fetches the options, this module might be loading up before the package...
        /// so this function waits until the package has been loaded and fetches the options from it
        /// </summary>
        private void FetchOptions()
        {
            SmoothScrollingPackage package = null;

            while (package == null)
            {
                package = SmoothScrollingPackage.Package;
            }

            options = package.GetOptions();
        }
        public void ResetSettings()
        {
            Assert.IsEmpty(_optionPage.SelectedAccount);

            OptionPageGrid page = (OptionPageGrid)_optionPage;

            page.SelectedAccount = "Dummy";
            Assert.AreEqual("Dummy", _optionPage.SelectedAccount);

            page.ResetSettings();
            Assert.IsEmpty(_optionPage.SelectedAccount);
        }
示例#14
0
        public override YetiVSIService GetVsiService()
        {
            if (_vsiService == null)
            {
                var serviceOptions = OptionPageGrid.CreateForTesting();
                serviceOptions.NatvisLoggingLevel = NatvisLoggingLevelFeatureFlag.VERBOSE;

                _vsiService = new YetiVSIService(serviceOptions);
            }

            return(_vsiService);
        }
示例#15
0
文件: Push.cs 项目: radtek/TPublish
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void Execute(object sender, EventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            try
            {
                //string message = string.Format(CultureInfo.CurrentCulture, "Inside {0}.MenuItemCallback()----", this.GetType().FullName);
                //string title = "Push";

                //// Show a message box to prove we were here
                //VsShellUtilities.ShowMessageBox(
                //    this.package,
                //    message,
                //    title,
                //    OLEMSGICON.OLEMSGICON_INFO,
                //    OLEMSGBUTTON.OLEMSGBUTTON_OK,
                //    OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);


                var projInfo = GetSelectedProjInfo();
                if (projInfo == null)
                {
                    throw new Exception("您还未选中项目");
                }

                var projModel = projInfo.AnalysisProject();
                if (projModel == null)
                {
                    throw new Exception("项目信息解析失败");
                }

                OptionPageGrid settingInfo = TPublishService.GetSettingPage();
                if (string.IsNullOrWhiteSpace(settingInfo?.IpAdress))
                {
                    throw new Exception("请先完善设置信息");
                }

                var form   = new DeployForm();
                var iniRes = form.Ini(projModel);
                if (iniRes.IsSucceed)
                {
                    form.Show();
                }
                else
                {
                    MessageBox.Show(iniRes.Message);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
        /// <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("Initialize");
            base.Initialize();
            //AddNextOccurCommand.Initialize(this);

            var dte = GetService(typeof(DTE)) as DTE2;

            documentEvents = dte.Events.DocumentEvents;
            documentEvents.DocumentSaved += OnDocumentSaved;

            Options = (OptionPageGrid)GetDialogPage(typeof(OptionPageGrid));
        }
示例#17
0
 public static List <AppView> GetAllIISAppNames()
 {
     try
     {
         OptionPageGrid setting = GetSettingPage();
         string         url     = $"{setting.GetApiUrl()}/GetAllIISAppView";
         WebClient      client  = new WebClient();
         var            res     = client.DownloadString(url).DeserializeObject <List <AppView> >();
         return(res);
     }
     catch (Exception e)
     {
         return(null);
     }
 }
示例#18
0
        public static List <AppView> GetExeAppView(string appName)
        {
            try
            {
                OptionPageGrid setting = GetSettingPage();
                string         url     = $"{setting.GetApiUrl()}/GetExeAppView?appName={appName}";

                var res = new HttpHelper().HttpGet(url, null, Encoding.UTF8, false, false, 10000);

                return(res.DeserializeObject <List <AppView> >());
            }
            catch (Exception e)
            {
                return(new List <AppView>());
            }
        }
 private static void CopyTextWithoutCodeModel(OptionPageGrid options, TextSelection selection)
 {
     if (options.ClipboardFormat == OptionPageGrid.CopyFormat.Slack)
     {
         string result = string.Format("```\n{0}\n```\nLine {1}", selection.Text.Trim(), selection.CurrentLine);
         System.Windows.Clipboard.SetText(result);
     }
     else if (options.ClipboardFormat == OptionPageGrid.CopyFormat.RTF)
     {
         var rtf = new RichTextBox();
         rtf.Font = new System.Drawing.Font("Consolas", 10);
         rtf.Text = selection.Text.Trim();
         rtf.Font = new System.Drawing.Font("Calibri", 11);
         rtf.AppendText(string.Format("\nLine {0}", selection.CurrentLine));
         System.Windows.Clipboard.SetText(rtf.Rtf, System.Windows.TextDataFormat.Rtf);
     }
 }
示例#20
0
        public void TestDebugEngineConstructor()
        {
            var lldbShell             = TestDummyGenerator.Create <SLLDBShell>();
            var vsiService            = new YetiVSIService(OptionPageGrid.CreateForTesting());
            var metrics               = TestDummyGenerator.Create <IMetrics>();
            var vsOutputWindow        = new OutputWindowStub();
            var symbolSettingsManager = Substitute.For <IVsDebuggerSymbolSettingsManager120A>();
            var serviceManager        = new ServiceManagerStub(metrics, lldbShell, vsiService,
                                                               vsOutputWindow, symbolSettingsManager);
            var compRoot = new MediumTestDebugEngineFactoryCompRoot(
                serviceManager, new JoinableTaskContext(), new GameletClientStub.Factory(),
                TestDummyGenerator.Create <IWindowsRegistry>());

            var factory = compRoot.CreateDebugEngineFactory();

            factory.Create(null);
        }
        DebugEngineFactoryCompRootStub CreateEngineFactoryCompRoot(
            IDebugSessionLauncherFactory debugSessionLauncherFactory, IRemoteDeploy remoteDeploy)
        {
            var compRoot = new DebugEngineFactoryCompRootStub(
                debugSessionLauncherFactory, remoteDeploy, Substitute.For <IGameLauncher>());

            _metrics = Substitute.For <IMetrics>();
            _metrics.NewDebugSessionId().Returns(_debugSessionId);
            ISessionNotifier sessionNotifier = Substitute.For <ISessionNotifier>();
            SLLDBShell       lldbShell       = TestDummyGenerator.Create <SLLDBShell>();
            var vsiService            = new YetiVSIService(OptionPageGrid.CreateForTesting());
            var vsOutputWindow        = new OutputWindowStub();
            var symbolSettingsManager = Substitute.For <IVsDebuggerSymbolSettingsManager120A>();

            compRoot.ServiceManager =
                new ServiceManagerStub(_metrics, lldbShell, vsiService, vsOutputWindow,
                                       symbolSettingsManager, sessionNotifier);
            return(compRoot);
        }
        public void SetUp()
        {
            _optionPageGrid = OptionPageGrid.CreateForTesting();
            _optionPageGrid.NatvisLoggingLevel = NatvisLoggingLevelFeatureFlag.VERBOSE;

            var taskContext    = new JoinableTaskContext();
            var serviceManager = new FakeServiceManager(taskContext);

            serviceManager.AddService(typeof(YetiVSIService), new YetiVSIService(_optionPageGrid));
            _compRoot = new MediumTestDebugEngineFactoryCompRoot(
                serviceManager, taskContext, new GameletClientStub.Factory(),
                TestDummyGenerator.Create <IWindowsRegistry>());

            _varInfoFactory = _compRoot.GetLldbVariableInformationFactory();

            _nLogSpy = _compRoot.GetNatvisDiagnosticLogSpy();
            _nLogSpy.Attach();

            _evaluator = _compRoot.GetNatvisExpressionEvaluator();
        }
示例#23
0
        public override YetiVSIService GetVsiService()
        {
            if (_vsiService != null)
            {
                return(_vsiService);
            }

            if (_serviceManager != null)
            {
                _vsiService = base.GetVsiService();
            }

            if (_vsiService == null)
            {
                OptionPageGrid vsiServiceOptions = OptionPageGrid.CreateForTesting();
                vsiServiceOptions.NatvisLoggingLevel = NatvisLoggingLevelFeatureFlag.VERBOSE;

                _vsiService = new YetiVSIService(vsiServiceOptions);
            }

            return(_vsiService);
        }
        private void CopyCurrentMethod()
        {
            var dte       = Package.GetDTE();
            var selection = GetSelection(dte);

            if (selection == null)
            {
                return;
            }

            var            selectionText = selection.Text.Trim();
            var            txtPoint      = GetCursorTextPoint(dte);
            OptionPageGrid page          = Package.Options;

            if (dte.ActiveDocument.ProjectItem.FileCodeModel == null)
            {
                // no file code model
                CopyTextWithoutCodeModel(page, selection);
                return;
            }

            string location = GetCodeElementNonRecursively(dte.ActiveDocument.ProjectItem.FileCodeModel.CodeElements, txtPoint);

            if (page.ClipboardFormat == OptionPageGrid.CopyFormat.Slack)
            {
                string result = string.Format("```\n{0}\n```\n{2} Line {1}", selectionText, selection.CurrentLine, location);
                System.Windows.Clipboard.SetText(result);
            }
            else if (page.ClipboardFormat == OptionPageGrid.CopyFormat.RTF)
            {
                var rtf = new RichTextBox();
                rtf.Font = new System.Drawing.Font("Consolas", 10);
                rtf.Text = selectionText;
                rtf.Font = new System.Drawing.Font("Calibri", 11);
                rtf.AppendText(string.Format("\n{0}, Line {1}", location, selection.CurrentLine));
                System.Windows.Clipboard.SetText(rtf.Rtf, System.Windows.TextDataFormat.Rtf);
            }
        }
示例#25
0
        private void MenuItemCallback(object sender, EventArgs e)
        {
            try
            {
                var   baseResultHtml = GetResultHtml("https://translate.google.cn/");
                Regex re             = new Regex(@"(tkk:')(.*?)(?=')");                          //此正则返回:tkk:'431119.315913250
                var   tkks           = re.Match(baseResultHtml).ToString().Split('\'');
                var   TKK            = string.IsNullOrWhiteSpace(tkks[1]) ? "" : tkks[1].Trim(); //在返回的HTML中正则匹配TKK的值

                if (!string.IsNullOrWhiteSpace(TKK))
                {
                    try
                    {
                        //处理权限不足无法写入问题
                        Clipboard.SetDataObject(TKK.Trim(), true); //关闭程序保留剪贴板内容
                    }
                    catch (Exception exception)
                    {
                    }

                    OptionPageGrid page = (OptionPageGrid)this.package.GetDialogPage(typeof(OptionPageGrid));
                    page.TKK = TKK;
                    page.SaveSettingsToStorage();
                    page.SaveToSetting();
                    OutputString(Microsoft.VisualStudio.VSConstants.OutputWindowPaneGuid.GeneralPane_guid, string.Format("从https://translate.google.cn/获取的TKK为:{0}", TKK));
                }
                else
                {
                    ShowMessageBox("获取TKK值失败,请打开浏览器手动获取");
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.ToString());
            }
        }
示例#26
0
        public static Process StartProcessGui(string application, string args, string title, string branchName = "", 
            OutputBox outputBox = null, OptionPageGrid options = null, string pushCommand = "")
        {
            var dialogResult = DialogResult.OK;
            if (!StartProcessGit("config user.name") || !StartProcessGit("config user.email"))
            {
                dialogResult = new Credentials().ShowDialog();
            }

            if (dialogResult == DialogResult.OK)
            {
                try
                {
                    var process = new Process
                    {
                        StartInfo =
                        {
                            WindowStyle = ProcessWindowStyle.Hidden,
                            RedirectStandardOutput = true,
                            RedirectStandardError = true,
                            UseShellExecute = false,
                            CreateNoWindow = true,
                            FileName = application,
                            Arguments = args,
                            WorkingDirectory = EnvHelper.SolutionDir
                        },
                        EnableRaisingEvents = true
                    };
                    process.Exited += process_Exited;
                    process.OutputDataReceived += OutputDataHandler;
                    process.ErrorDataReceived += OutputDataHandler;

                    if (outputBox == null)
                    {
                        _outputBox = new OutputBox(branchName, options, pushCommand);
                        _outputBox.Show();
                    }
                    else
                    {
                        _outputBox = outputBox;
                    }

                    process.Start();
                    process.BeginOutputReadLine();
                    process.BeginErrorReadLine();

                    _outputBox.Text = title;
                    _outputBox.Show();

                    return process;
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, $"{application} not found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            return null;
        }
示例#27
0
        void OnDocumentSaved(Document doc)
        {
            if (Options == null)
            {
                Options = (OptionPageGrid)GetDialogPage(typeof(OptionPageGrid));
            }

            if (doc.Kind != "{8E7B96A8-E33D-11D0-A6D5-00C04FB67F6A}")
            {
                return;
            }

            var path   = doc.FullName;
            var stream = new FileStream(path, FileMode.Open);

            string text;

            stream.Position = 0;

            try
            {
                var reader = new StreamReader(stream, new UTF8Encoding(false, true));
                text = reader.ReadToEnd();
            }
            catch (DecoderFallbackException)
            {
                stream.Position = 0;
                var reader = new StreamReader(stream, Encoding.Default, true);
                text = reader.ReadToEnd();
            }
            stream.Close();

            var encoding = new UTF8Encoding(Options.OptionBOM, false);

            switch (Options.OptionCRLF)
            {
            case Config.EnumCRLF.CRLF:
                text = ConvertToCRLF(text);
                break;

            case Config.EnumCRLF.LF:
                text = ConvertToLF(text);
                break;

            case Config.EnumCRLF.Smart:
                var crln = text.Length - text.Replace("\r\n", "\n").Length;
                var ln   = text.Split('\n').Length - 1 - crln;

                if (crln > ln)
                {
                    text = ConvertToCRLF(text);
                }
                else
                {
                    text = ConvertToLF(text);
                }

                break;

            default:
                break;
            }
            stream = File.Open(path, FileMode.Truncate | FileMode.OpenOrCreate);
            var writer = new BinaryWriter(stream);

            writer.Write(encoding.GetPreamble());
            writer.Write(encoding.GetBytes(text));
            writer.Close();
        }
 public void SetUp()
 {
     _optionPage = OptionPageGrid.CreateForTesting();
 }
示例#29
0
 public GitFlowMenuCommands(OleMenuCommandService mcs, OptionPageGrid options)
 {
     _mcs = mcs;
     _options = options;
 }
示例#30
0
 public MainMenuCommands(OleMenuCommandService mcs, DTE dte, OptionPageGrid generalOptions)
 {
     _dte = dte;
     _mcs = mcs;
     _generalOptions = generalOptions;
 }
示例#31
0
 public MainMenuCommands(OleMenuCommandService mcs, DTE dte, OptionPageGrid generalOptions)
 {
     _dte            = dte;
     _mcs            = mcs;
     _generalOptions = generalOptions;
 }
示例#32
0
 public MediumTestServiceManager(JoinableTaskContext taskContext) : this(
         taskContext, OptionPageGrid.CreateForTesting())
 {
 }
示例#33
0
 public GitFlowMenuCommands(OleMenuCommandService mcs, OptionPageGrid options)
 {
     _mcs     = mcs;
     _options = options;
 }