protected void ValidateControl(object sender, CancelEventArgs e) { try { ValidateProperties(); } catch (PropertyPageArgumentException ex) { IServiceProvider serviceProvider = ParentPropertyPage.Site; string message = ex.Message; string title = "Dart Project Error"; OLEMSGICON icon = OLEMSGICON.OLEMSGICON_CRITICAL; OLEMSGBUTTON button = OLEMSGBUTTON.OLEMSGBUTTON_OK; OLEMSGDEFBUTTON defaultButton = OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST; if (serviceProvider != null) { VsShellUtilities.ShowMessageBox(serviceProvider, message, title, icon, button, defaultButton); } e.Cancel = true; } }
protected virtual void HandleTextBufferChangedLowPriority(object sender, TextContentChangedEventArgs e) { if (_failedTimeout) { if (!_timeoutReported) { IServiceProvider serviceProvider = null; string message = null; string title = null; OLEMSGICON icon = OLEMSGICON.OLEMSGICON_CRITICAL; OLEMSGBUTTON button = OLEMSGBUTTON.OLEMSGBUTTON_OK; OLEMSGDEFBUTTON defaultButton = OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST; if (serviceProvider != null) { _timeoutReported = true; VsShellUtilities.ShowMessageBox(serviceProvider, message, title, icon, button, defaultButton); } } return; } if (e.After == _textBuffer.CurrentSnapshot) { ClassifierState classifierState = _lineStatesCache.GetValue(e.After, CreateClassifierState); if (classifierState._firstChangedLine.HasValue && classifierState._lastChangedLine.HasValue) { int startLine = classifierState._firstChangedLine.Value; int endLine = Math.Min(classifierState._lastChangedLine.Value, e.After.LineCount - 1); classifierState._firstChangedLine = null; classifierState._lastChangedLine = null; ForceReclassifyLines(classifierState, startLine, endLine); } } }
public override int DebugLaunch(uint aLaunch) { LogUtility.LogString("Cosmos.VS.Package.VSProjectConfig debugger launching"); try { // Second param is ResetCache. Must be called one time. Dunno why. // Also dunno if this comment is still valid/needed: // On first call, reset the cache, following calls will use the cached values // Think we will change this to a dummy program when we get our debugger working // This is the program that gest launched after build var xDeployment = (DeploymentType)Enum.Parse(typeof(DeploymentType), GetConfigurationProperty(BuildPropertyNames.DeploymentString, true)); var xLaunch = (LaunchType)Enum.Parse(typeof(LaunchType), GetConfigurationProperty(BuildPropertyNames.LaunchString, false)); var xVSDebugPort = GetConfigurationProperty(BuildPropertyNames.VisualStudioDebugPortString, false); string xOutputAsm = ProjectMgr.GetOutputAssembly(ConfigName); string xOutputPath = Path.GetDirectoryName(xOutputAsm); string xIsoFile = Path.ChangeExtension(xOutputAsm, ".iso"); string xBinFile = Path.ChangeExtension(xOutputAsm, ".bin"); if (xDeployment == DeploymentType.ISO) { IsoMaker.Generate(xBinFile, xIsoFile); } else if (xDeployment == DeploymentType.USB) { Process.Start(Path.Combine(CosmosPaths.Tools, "Cosmos.Deploy.USB.exe"), "\"" + xBinFile + "\""); } else if (xDeployment == DeploymentType.PXE) { string xPxePath = Path.Combine(CosmosPaths.Build, "PXE"); string xPxeIntf = GetConfigurationProperty(BuildPropertyNames.PxeInterfaceString, false); File.Copy(xBinFile, Path.Combine(xPxePath, "Cosmos.bin"), true); Process.Start(Path.Combine(CosmosPaths.Tools, "Cosmos.Deploy.Pixie.exe"), xPxeIntf + " \"" + xPxePath + "\""); } else if (xDeployment == DeploymentType.BinaryImage) { // prepare? } else { throw new Exception("Unknown deployment type."); } if (xLaunch == LaunchType.None && xDeployment == DeploymentType.ISO) { Process.Start(xOutputPath); } else { // http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.shell.interop.vsdebugtargetinfo_members.aspx var xInfo = new VsDebugTargetInfo(); xInfo.cbSize = (uint)Marshal.SizeOf(xInfo); xInfo.dlo = DEBUG_LAUNCH_OPERATION.DLO_CreateProcess; xInfo.fSendStdoutToOutputWindow = 0; // App keeps its stdout xInfo.grfLaunch = aLaunch; // Just pass through for now. xInfo.bstrRemoteMachine = null; // debug locally var xValues = new NameValueCollection(); xValues.Add("ProjectFile", Path.Combine(ProjectMgr.ProjectFolder, ProjectMgr.ProjectFile)); xValues.Add("ISOFile", xIsoFile); xValues.Add("BinFormat", GetConfigurationProperty("BinFormat", false)); foreach (var xName in BuildProperties.PropNames) { xValues.Add(xName, GetConfigurationProperty(xName, false)); } xInfo.bstrExe = NameValueCollectionHelper.DumpToString(xValues); // Select the debugger xInfo.clsidCustom = new Guid("{FA1DA3A6-66FF-4c65-B077-E65F7164EF83}"); // Debug engine identifier. // ??? This identifier doesn't seems to appear anywhere else in souce code. xInfo.clsidPortSupplier = new Guid("{708C1ECA-FF48-11D2-904F-00C04FA302A1}"); VsShellUtilities.LaunchDebugger(ProjectMgr.Site, xInfo); } } catch (Exception ex) { LogUtility.LogException(ex, true); return(Marshal.GetHRForException(ex)); } return(VSConstants.S_OK); }
public void GotoLocation(Location loc, string caption, bool asReadonly) { //TODO: VladD2: Разобраться почему этот код вызывает вылет //IVsUIShell uiShell = this.GetService(typeof(SVsUIShell)) as IVsUIShell; //if (uiShell != null) //{ // IVsWindowFrame frame; // string data; // object unknown; // ErrorHandler.ThrowOnFailure(uiShell.GetCurrentBFNavigationItem(out frame, out data, out unknown)); // ErrorHandler.ThrowOnFailure(uiShell.AddNewBFNavigationItem(frame, data, unknown, 0)); //} TextSpan span = new TextSpan(); span.iStartLine = loc.Line - 1; span.iStartIndex = loc.Column - 1; span.iEndLine = loc.EndLine - 1; span.iEndIndex = loc.EndColumn - 1; uint itemID; IVsUIHierarchy hierarchy; IVsWindowFrame docFrame; IVsTextView textView; if (loc.FileIndex == 0) { return; } VsShell.OpenDocument(Site, loc.File, VSConstants.LOGVIEWID_Code, out hierarchy, out itemID, out docFrame, out textView); if (asReadonly) { IVsTextLines buffer; ErrorHandler.ThrowOnFailure(textView.GetBuffer(out buffer)); IVsTextStream stream = (IVsTextStream)buffer; stream.SetStateFlags((uint)BUFFERSTATEFLAGS.BSF_USER_READONLY); } if (caption != null) { ErrorHandler.ThrowOnFailure(docFrame.SetProperty((int)__VSFPROPID.VSFPROPID_OwnerCaption, caption)); } ErrorHandler.ThrowOnFailure(docFrame.Show()); if (textView != null && loc.Line != 0) { try { ErrorHandler.ThrowOnFailure(textView.SetCaretPos(span.iStartLine, span.iStartIndex)); TextSpanHelper.MakePositive(ref span); ErrorHandler.ThrowOnFailure(textView.SetSelection(span.iStartLine, span.iStartIndex, span.iEndLine, span.iEndIndex)); ErrorHandler.ThrowOnFailure(textView.EnsureSpanVisible(span)); } catch (Exception ex) { Trace.WriteLine(ex.Message); } } }