

private void OnMenuMyDropDownCombo (object sender, EventArgs e)
{
if (e == EventArgs.Empty)
{
throw (new ArgumentException ());
}
OleMenuCmdEventArgs eventArgs = e as OleMenuCmdEventArgs;
if (eventArgs! = null)
{
string newChoice = eventArgs.InValue as string;
IntPtr vOut = eventArgs.OutValue;
if (vOut! = IntPtr.Zero && newChoice! = null)
{
throw (new ArgumentException ());
}
else if (vOut! = IntPtr.Zero)
{
Marshal.GetNativeVariantForObject (
this.currentDropDownComboChoice, vOut);
}
else if (newChoice! = null)
{
bool validInput = false;
int indexInput = -1;
for (indexInput = 0;
indexInput <dropDownComboChoices.Length;
indexInput ++)
{
if (String.Compare (
dropDownComboChoices [indexInput], newChoice,
true) == 0)
{
validInput = true;
break;
}
}
if (validInput)
{
this.currentDropDownComboChoice =
dropDownComboChoices [indexInput];
if (currentDropDownComboChoice ==
Resources.Viva64)
UseViva64Analysis (null, null);
else if (currentDropDownComboChoice ==
Resources.GeneralAnalysis)
UseGeneralAnalysis (null, null);
else if (currentDropDownComboChoice ==
Resources.VivaMP)
UseVivaMPAnalysis (null, null);
else
{
throw (new ArgumentException ());
}
}
else
{
throw (new ArgumentException ());
}
}
else
{
throw (new ArgumentException ());
}
}
else
{
throw (new ArgumentException ());
}
} public void OpenDocumentAndNavigateTo (string path, int line,
int column)
{
IVsUIShellOpenDocument openDoc =
Package.GetGlobalService (
typeof (IVsUIShellOpenDocument))
as IVsUIShellOpenDocument;
if (openDoc == null)
return;
IVsWindowFrame frame;
Microsoft.VisualStudio.OLE.Interop.IServiceProvider sp;
IVsUIHierarchy hier;
uint itemid;
Guid logicalView = VSConstants.LOGVIEWID_Code;
if (ErrorHandler.Failed (
openDoc.OpenDocumentViaProject (path, ref logicalView,
out sp, out hier, out itemid, out frame))
|| frame == null)
return;
object docData;
frame.GetProperty ((int) __ VSFPROPID.VSFPROPID_DocData,
out docData);
VsTextBuffer buffer = docData as VsTextBuffer;
if (buffer == null)
{
IVsTextBufferProvider bufferProvider =
docData as IVsTextBufferProvider;
if (bufferProvider! = null)
{
IVsTextLines lines;
ErrorHandler.ThrowOnFailure (
bufferProvider.GetTextBuffer (out lines));
buffer = lines as VsTextBuffer;
if (buffer == null)
return;
}
}
IVsTextManager mgr =
Package.GetGlobalService (typeof (VsTextManagerClass))
as IVsTextManager;
if (mgr == null)
return;
mgr.NavigateToLineAndColumn (
buffer, ref logicalView, line, column, line, column);
} public static DateTime Time_T2DateTime (long time_t)
{
// 116444736000000000 - this is 1600
long win32FileTime = 10000000 * time_t + 116444736000000000;
return DateTime.FromFileTime (win32FileTime);
} Solution2 solution = PVSStudio.DTE.Solution as Solution2;
SolutionBuild2 solutionBuild =
(SolutionBuild2) solution.SolutionBuild;
SolutionContexts projectContexts =
solutionBuild.ActiveConfiguration.SolutionContexts;
int prjCount = projectContexts.Count;
for (int i = 1; i <= prjCount; i ++)
{
SolutionContext projectContext = null;
try
{
projectContext = projectContexts.Item (i);
}
catch (Exception)
{
// try / catch block is a workaround.
// It was needed for correct working on solution
// with unloaded projects.
continue;
}
... Source: https://habr.com/ru/post/106935/
All Articles