本文整理汇总了C#中VSITEMSELECTION类的典型用法代码示例。如果您正苦于以下问题:C# VSITEMSELECTION类的具体用法?C# VSITEMSELECTION怎么用?C# VSITEMSELECTION使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VSITEMSELECTION类属于命名空间,在下文中一共展示了VSITEMSELECTION类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetProjectsOfCurrentSelections
static public IList<IVsProject> GetProjectsOfCurrentSelections()
{
List<IVsProject> results = new List<IVsProject>();
int hr = VSConstants.S_OK;
var selectionMonitor = _serviceProvider.GetService(typeof(SVsShellMonitorSelection)) as IVsMonitorSelection;
if (selectionMonitor == null)
{
Debug.Fail("Failed to get SVsShellMonitorSelection service.");
return results;
}
IntPtr hierarchyPtr = IntPtr.Zero;
uint itemID = 0;
IVsMultiItemSelect multiSelect = null;
IntPtr containerPtr = IntPtr.Zero;
hr = selectionMonitor.GetCurrentSelection(out hierarchyPtr, out itemID, out multiSelect, out containerPtr);
if (IntPtr.Zero != containerPtr)
{
Marshal.Release(containerPtr);
containerPtr = IntPtr.Zero;
}
Debug.Assert(hr == VSConstants.S_OK, "GetCurrentSelection failed.");
if (itemID == (uint)VSConstants.VSITEMID.Selection)
{
uint itemCount = 0;
int fSingleHierarchy = 0;
hr = multiSelect.GetSelectionInfo(out itemCount, out fSingleHierarchy);
Debug.Assert(hr == VSConstants.S_OK, "GetSelectionInfo failed.");
VSITEMSELECTION[] items = new VSITEMSELECTION[itemCount];
hr = multiSelect.GetSelectedItems(0, itemCount, items);
Debug.Assert(hr == VSConstants.S_OK, "GetSelectedItems failed.");
foreach (VSITEMSELECTION item in items)
{
IVsProject project = GetProjectOfItem(item.pHier, item.itemid);
if (!results.Contains(project))
{
results.Add(project);
}
}
}
else
{
// case where no visible project is open (single file)
if (hierarchyPtr != IntPtr.Zero)
{
IVsHierarchy hierarchy = (IVsHierarchy)Marshal.GetUniqueObjectForIUnknown(hierarchyPtr);
results.Add(GetProjectOfItem(hierarchy, itemID));
}
}
return results;
}
开发者ID:CaulyKan,项目名称:VSSDK-Extensibility-Samples,代码行数:56,代码来源:ProjectUtilities.cs
示例2: SourceImage
public SourceImage(VSITEMSELECTION item)
{
this.item = item;
this.features = new ObservableCollection<OutputFeature>();
InitSourcePathAndScale();
InitSourceImage();
OutputHelpers.PopulateFeatures(this);
this.PostInitialize();
}
开发者ID:spadapet,项目名称:universal-image-scaler,代码行数:11,代码来源:SourceImage.cs
示例3: GetSelectedProjects
public Project[] GetSelectedProjects()
{
IntPtr hierarchyPointer, selectionContainerPointer;
IVsMultiItemSelect multiItemSelect;
uint projectItemId;
MonitorSelectionService.GetCurrentSelection(out hierarchyPointer, out projectItemId, out multiItemSelect, out selectionContainerPointer);
if (projectItemId == (uint)VSConstants.VSITEMID.Selection)
{
// Multiple projects are selected
uint numberOfSelectedItems;
int isSingleHieracrchy;
multiItemSelect.GetSelectionInfo(out numberOfSelectedItems, out isSingleHieracrchy);
var selectedItems = new VSITEMSELECTION[numberOfSelectedItems];
multiItemSelect.GetSelectedItems(0, numberOfSelectedItems, selectedItems);
var result = new Project[numberOfSelectedItems];
for (int i = 0; i < numberOfSelectedItems; i++)
{
object selectedObject = null;
ErrorHandler.ThrowOnFailure(selectedItems[i].pHier.GetProperty(selectedItems[i].itemid, (int)__VSHPROPID.VSHPROPID_ExtObject, out selectedObject));
result[i] = selectedObject as Project;
}
return result;
}
else
{
// Only one project is selected
object selectedObject = null;
IVsHierarchy selectedHierarchy = null;
try
{
selectedHierarchy = Marshal.GetTypedObjectForIUnknown(hierarchyPointer, typeof(IVsHierarchy)) as IVsHierarchy;
}
catch (Exception)
{
return null;
}
if (selectedHierarchy != null)
{
ErrorHandler.ThrowOnFailure(selectedHierarchy.GetProperty(projectItemId, (int)__VSHPROPID.VSHPROPID_ExtObject, out selectedObject));
}
Project selectedProject = selectedObject as Project;
return new Project[] { selectedProject };
}
}
开发者ID:rodolfograve,项目名称:TEAM.ProjectMerger,代码行数:53,代码来源:MonitorSelection.cs
示例4: GetSelection
public IEnumerable<IVsHierarchyItem> GetSelection ()
{
return asyncManager.Run (async () => {
await asyncManager.SwitchToMainThread ();
var selHier = IntPtr.Zero;
uint selId;
IVsMultiItemSelect selMulti;
try {
ErrorHandler.ThrowOnFailure (hierarchyWindow.GetCurrentSelection (out selHier, out selId, out selMulti));
// There may be no selection at all.
if (selMulti == null && selHier == IntPtr.Zero)
return Enumerable.Empty<IVsHierarchyItem> ();
// This is a single item selection.
if (selMulti == null) {
return new[] { hierarchyManager.GetHierarchyItem (
(IVsHierarchy)Marshal.GetTypedObjectForIUnknown (selHier, typeof (IVsHierarchy)), selId) };
}
// This is a multiple item selection.
uint selCount;
int singleHier;
ErrorHandler.ThrowOnFailure (selMulti.GetSelectionInfo (out selCount, out singleHier));
var selection = new VSITEMSELECTION[selCount];
ErrorHandler.ThrowOnFailure (selMulti.GetSelectedItems (0, selCount, selection));
return selection.Where (sel => sel.pHier != null)
.Select (sel => hierarchyManager.GetHierarchyItem (sel.pHier, sel.itemid))
.ToArray ();
} finally {
if (selHier != IntPtr.Zero)
Marshal.Release (selHier);
}
});
}
开发者ID:kzu,项目名称:clide,代码行数:41,代码来源:VsSolutionSelection.cs
示例5: PackageSelectionDataObject
DataObject PackageSelectionDataObject(bool cutHighlightItems){
CleanupSelectionDataObject(false, false, false);
IVsUIHierarchyWindow w = this.projectMgr.GetIVsUIHierarchyWindow(VsConstants.Guid_SolutionExplorer);
IVsSolution solution = this.GetService(typeof(IVsSolution)) as IVsSolution;
IVsMonitorSelection ms = this.GetService(typeof(IVsMonitorSelection)) as IVsMonitorSelection;
IntPtr psel;
IVsMultiItemSelect itemSelect;
IntPtr psc;
uint vsitemid;
StringBuilder sb = new StringBuilder();
ms.GetCurrentSelection(out psel, out vsitemid, out itemSelect, out psc);
IVsHierarchy sel = (IVsHierarchy)Marshal.GetTypedObjectForIUnknown(psel, typeof(IVsHierarchy));
ISelectionContainer sc = (ISelectionContainer)Marshal.GetTypedObjectForIUnknown(psc, typeof(ISelectionContainer));
const uint GSI_fOmitHierPtrs = 0x00000001;
if ((sel != (IVsHierarchy)this) || (vsitemid == VsConstants.VSITEMID_ROOT) || (vsitemid == VsConstants.VSITEMID_NIL))
throw new InvalidOperationException();
if ((vsitemid == VsConstants.VSITEMID_SELECTION) && (itemSelect != null)){
int singleHierarchy;
uint pcItems;
itemSelect.GetSelectionInfo(out pcItems, out singleHierarchy);
if (singleHierarchy != 0) // "!BOOL" == "!= 0" ?
throw new InvalidOperationException();
this.itemsDragged = new ArrayList();
VSITEMSELECTION[] items = new VSITEMSELECTION[pcItems];
itemSelect.GetSelectedItems(GSI_fOmitHierPtrs, pcItems, items);
for (uint i = 0; i < pcItems; i++){
if (items[i].itemid == VsConstants.VSITEMID_ROOT){
this.itemsDragged.Clear();// abort
break;
}
this.itemsDragged.Add(items[i].pHier);
string projref;
solution.GetProjrefOfItem((IVsHierarchy)this, items[i].itemid, out projref);
if ((projref == null) || (projref.Length == 0)){
this.itemsDragged.Clear(); // abort
break;
}
sb.Append(projref);
sb.Append('\0'); // separated by nulls.
}
} else if (vsitemid != VsConstants.VSITEMID_ROOT){
this.itemsDragged = new ArrayList();
this.itemsDragged.Add(this.projectMgr.NodeFromItemId(vsitemid));
string projref;
solution.GetProjrefOfItem((IVsHierarchy)this, vsitemid, out projref);
sb.Append(projref);
}
if (sb.ToString() == "" || this.itemsDragged.Count == 0)
return null;
sb.Append('\0'); // double null at end.
_DROPFILES df = new _DROPFILES();
int dwSize = Marshal.SizeOf(df);
Int16 wideChar = 0;
int dwChar = Marshal.SizeOf(wideChar);
IntPtr ptr = Marshal.AllocHGlobal(dwSize + ((sb.Length + 1) * dwChar));
df.pFiles = dwSize;
df.fWide = 1;
IntPtr data = DataObject.GlobalLock(ptr);
Marshal.StructureToPtr(df, data, false);
IntPtr strData = new IntPtr((long)data + dwSize);
DataObject.CopyStringToHGlobal(sb.ToString(), strData);
DataObject.GlobalUnLock(data);
DataObject dobj = new DataObject();
FORMATETC fmt = DragDropHelper.CreateFormatEtc();
dobj.SetData(fmt, ptr);
if (cutHighlightItems){
bool first = true;
foreach (HierarchyNode node in this.itemsDragged){
w.ExpandItem((IVsUIHierarchy)this.projectMgr, node.hierarchyId, first ? EXPANDFLAGS.EXPF_CutHighlightItem : EXPANDFLAGS.EXPF_AddCutHighlightItem);
first = false;
}
}
return dobj;
}
开发者ID:hesam,项目名称:SketchSharp,代码行数:85,代码来源:Hierarchy.cs
示例6: GetSelectedItems
/// <summary>
/// Gets all of the currently selected items.
/// </summary>
/// <returns></returns>
private IEnumerable<VSITEMSELECTION> GetSelectedItems() {
IVsMonitorSelection monitorSelection = _package.GetService(typeof(IVsMonitorSelection)) as IVsMonitorSelection;
IntPtr hierarchyPtr = IntPtr.Zero;
IntPtr selectionContainer = IntPtr.Zero;
try {
uint selectionItemId;
IVsMultiItemSelect multiItemSelect = null;
ErrorHandler.ThrowOnFailure(monitorSelection.GetCurrentSelection(out hierarchyPtr, out selectionItemId, out multiItemSelect, out selectionContainer));
if (selectionItemId != VSConstants.VSITEMID_NIL && hierarchyPtr != IntPtr.Zero) {
IVsHierarchy hierarchy = Marshal.GetObjectForIUnknown(hierarchyPtr) as IVsHierarchy;
if (selectionItemId != VSConstants.VSITEMID_SELECTION) {
// This is a single selection. Compare hirarchy with our hierarchy and get node from itemid
if (Utilities.IsSameComObject(this, hierarchy)) {
yield return new VSITEMSELECTION() { itemid = selectionItemId, pHier = hierarchy };
}
} else if (multiItemSelect != null) {
// This is a multiple item selection.
// Get number of items selected and also determine if the items are located in more than one hierarchy
uint numberOfSelectedItems;
int isSingleHierarchyInt;
ErrorHandler.ThrowOnFailure(multiItemSelect.GetSelectionInfo(out numberOfSelectedItems, out isSingleHierarchyInt));
bool isSingleHierarchy = (isSingleHierarchyInt != 0);
// Now loop all selected items and add to the list only those that are selected within this hierarchy
if (!isSingleHierarchy || (isSingleHierarchy && Utilities.IsSameComObject(this, hierarchy))) {
Debug.Assert(numberOfSelectedItems > 0, "Bad number of selected itemd");
VSITEMSELECTION[] vsItemSelections = new VSITEMSELECTION[numberOfSelectedItems];
uint flags = (isSingleHierarchy) ? (uint)__VSGSIFLAGS.GSI_fOmitHierPtrs : 0;
ErrorHandler.ThrowOnFailure(multiItemSelect.GetSelectedItems(flags, numberOfSelectedItems, vsItemSelections));
foreach (VSITEMSELECTION vsItemSelection in vsItemSelections) {
yield return new VSITEMSELECTION() { itemid = vsItemSelection.itemid, pHier = hierarchy };
}
}
}
}
} finally {
if (hierarchyPtr != IntPtr.Zero) {
Marshal.Release(hierarchyPtr);
}
if (selectionContainer != IntPtr.Zero) {
Marshal.Release(selectionContainer);
}
}
}
开发者ID:CforED,项目名称:Node.js-Tools-for-Visual-Studio,代码行数:53,代码来源:NodejsProject.cs
示例7: GetItemType
internal static Guid GetItemType(VSITEMSELECTION vsItemSelection) {
Guid typeGuid;
try {
ErrorHandler.ThrowOnFailure(
vsItemSelection.pHier.GetGuidProperty(
vsItemSelection.itemid,
(int)__VSHPROPID.VSHPROPID_TypeGuid,
out typeGuid
)
);
} catch (System.Runtime.InteropServices.COMException) {
return Guid.Empty;
}
return typeGuid;
}
开发者ID:CforED,项目名称:Node.js-Tools-for-Visual-Studio,代码行数:15,代码来源:NodejsProject.cs
示例8: TestSccMenuCommands
public void TestSccMenuCommands()
{
int result = 0;
Guid badGuid = new Guid();
Guid guidCmdGroup = GuidList.guidSccProviderCmdSet;
OLECMD[] cmdAddToScc = new OLECMD[1];
cmdAddToScc[0].cmdID = CommandId.icmdAddToSourceControl;
OLECMD[] cmdCheckin = new OLECMD[1];
cmdCheckin[0].cmdID = CommandId.icmdCheckin;
OLECMD[] cmdCheckout = new OLECMD[1];
cmdCheckout[0].cmdID = CommandId.icmdCheckout;
OLECMD[] cmdUseSccOffline = new OLECMD[1];
cmdUseSccOffline[0].cmdID = CommandId.icmdUseSccOffline;
OLECMD[] cmdViewToolWindow = new OLECMD[1];
cmdViewToolWindow[0].cmdID = CommandId.icmdViewToolWindow;
OLECMD[] cmdToolWindowToolbarCommand = new OLECMD[1];
cmdToolWindowToolbarCommand[0].cmdID = CommandId.icmdToolWindowToolbarCommand;
OLECMD[] cmdUnsupported = new OLECMD[1];
cmdUnsupported[0].cmdID = 0;
// Initialize the provider, etc
SccProviderService target = GetSccProviderServiceInstance;
// Mock a service implementing IVsMonitorSelection
BaseMock monitorSelection = MockIVsMonitorSelectionFactory.GetMonSel();
serviceProvider.AddService(typeof(IVsMonitorSelection), monitorSelection, true);
// Commands that don't belong to our package should not be supported
result = _sccProvider.QueryStatus(ref badGuid, 1, cmdAddToScc, IntPtr.Zero);
Assert.AreEqual((int)Microsoft.VisualStudio.OLE.Interop.Constants.OLECMDERR_E_NOTSUPPORTED, result);
// The command should be invisible when there is no solution
VerifyCommandStatus(OLECMDF.OLECMDF_SUPPORTED | OLECMDF.OLECMDF_INVISIBLE, cmdAddToScc);
// Activate the provider and test the result
target.SetActive();
Assert.AreEqual(true, target.Active, "Microsoft.Samples.VisualStudio.SourceControlIntegration.SccProvider.SccProviderService.Active was not reported correctly.");
// The commands should be invisible when there is no solution
VerifyCommandStatus(OLECMDF.OLECMDF_SUPPORTED | OLECMDF.OLECMDF_INVISIBLE, cmdAddToScc);
VerifyCommandStatus(OLECMDF.OLECMDF_SUPPORTED | OLECMDF.OLECMDF_INVISIBLE, cmdCheckin);
VerifyCommandStatus(OLECMDF.OLECMDF_SUPPORTED | OLECMDF.OLECMDF_INVISIBLE, cmdCheckout);
VerifyCommandStatus(OLECMDF.OLECMDF_SUPPORTED | OLECMDF.OLECMDF_INVISIBLE, cmdUseSccOffline);
// Commands that don't belong to our package should not be supported
result = _sccProvider.QueryStatus(ref guidCmdGroup, 1, cmdUnsupported, IntPtr.Zero);
Assert.AreEqual((int)Microsoft.VisualStudio.OLE.Interop.Constants.OLECMDERR_E_NOTSUPPORTED, result);
// Deactivate the provider and test the result
target.SetInactive();
Assert.AreEqual(false, target.Active, "Microsoft.Samples.VisualStudio.SourceControlIntegration.SccProvider.SccProviderService.Active was not reported correctly.");
// Create a solution
solution.SolutionFile = Path.GetTempFileName();
MockIVsProject project = new MockIVsProject(Path.GetTempFileName());
project.AddItem(Path.GetTempFileName());
solution.AddProject(project);
// The commands should be invisible when the provider is not active
VerifyCommandStatus(OLECMDF.OLECMDF_SUPPORTED | OLECMDF.OLECMDF_INVISIBLE, cmdAddToScc);
VerifyCommandStatus(OLECMDF.OLECMDF_SUPPORTED | OLECMDF.OLECMDF_INVISIBLE, cmdCheckin);
VerifyCommandStatus(OLECMDF.OLECMDF_SUPPORTED | OLECMDF.OLECMDF_INVISIBLE, cmdCheckout);
VerifyCommandStatus(OLECMDF.OLECMDF_SUPPORTED | OLECMDF.OLECMDF_INVISIBLE, cmdUseSccOffline);
VerifyCommandStatus(OLECMDF.OLECMDF_SUPPORTED | OLECMDF.OLECMDF_INVISIBLE, cmdViewToolWindow);
VerifyCommandStatus(OLECMDF.OLECMDF_SUPPORTED | OLECMDF.OLECMDF_INVISIBLE, cmdToolWindowToolbarCommand);
// Activate the provider and test the result
target.SetActive();
Assert.AreEqual(true, target.Active, "Microsoft.Samples.VisualStudio.SourceControlIntegration.SccProvider.SccProviderService.Active was not reported correctly.");
// The command should be visible but disabled now, except the toolwindow ones
VerifyCommandStatus(OLECMDF.OLECMDF_SUPPORTED, cmdAddToScc);
VerifyCommandStatus(OLECMDF.OLECMDF_SUPPORTED, cmdCheckin);
VerifyCommandStatus(OLECMDF.OLECMDF_SUPPORTED, cmdCheckout);
VerifyCommandStatus(OLECMDF.OLECMDF_SUPPORTED, cmdUseSccOffline);
VerifyCommandStatus(OLECMDF.OLECMDF_SUPPORTED | OLECMDF.OLECMDF_ENABLED, cmdViewToolWindow);
VerifyCommandStatus(OLECMDF.OLECMDF_SUPPORTED | OLECMDF.OLECMDF_ENABLED, cmdToolWindowToolbarCommand);
// Set selection to solution node
VSITEMSELECTION selSolutionRoot;
selSolutionRoot.pHier = _solution as IVsHierarchy;
selSolutionRoot.itemid = VSConstants.VSITEMID_ROOT;
monitorSelection["Selection"] = new VSITEMSELECTION[] { selSolutionRoot };
// The add command should be available, rest should be disabled
VerifyCommandStatus(OLECMDF.OLECMDF_SUPPORTED | OLECMDF.OLECMDF_ENABLED, cmdAddToScc);
VerifyCommandStatus(OLECMDF.OLECMDF_SUPPORTED, cmdCheckin);
VerifyCommandStatus(OLECMDF.OLECMDF_SUPPORTED, cmdCheckout);
VerifyCommandStatus(OLECMDF.OLECMDF_SUPPORTED, cmdUseSccOffline);
// Still solution hierarchy, but other way
selSolutionRoot.pHier = null;
selSolutionRoot.itemid = VSConstants.VSITEMID_ROOT;
monitorSelection["Selection"] = new VSITEMSELECTION[] { selSolutionRoot };
// The add command should be available, rest should be disabled
VerifyCommandStatus(OLECMDF.OLECMDF_SUPPORTED | OLECMDF.OLECMDF_ENABLED, cmdAddToScc);
VerifyCommandStatus(OLECMDF.OLECMDF_SUPPORTED, cmdCheckin);
VerifyCommandStatus(OLECMDF.OLECMDF_SUPPORTED, cmdCheckout);
//.........这里部分代码省略.........
开发者ID:rsweeney21,项目名称:VisualGit,代码行数:101,代码来源:SccProviderServiceTest.cs
示例9: Name
internal static string Name(VSITEMSELECTION item) {
return GetItemName(item.pHier, item.itemid);
}
开发者ID:CforED,项目名称:Node.js-Tools-for-Visual-Studio,代码行数:3,代码来源:NodejsProject.cs
示例10: GetSelectedNodes
/// <summary>
/// Gets the list of directly selected VSITEMSELECTION objects
/// </summary>
/// <returns>A list of VSITEMSELECTION objects</returns>
private IList<VSITEMSELECTION> GetSelectedNodes()
{
// Retrieve shell interface in order to get current selection
IVsMonitorSelection monitorSelection = _sccProvider.GetService(typeof(IVsMonitorSelection)) as IVsMonitorSelection;
Debug.Assert(monitorSelection != null, "Could not get the IVsMonitorSelection object from the services exposed by this project");
if (monitorSelection == null)
{
throw new InvalidOperationException();
}
List<VSITEMSELECTION> selectedNodes = new List<VSITEMSELECTION>();
IntPtr hierarchyPtr = IntPtr.Zero;
IntPtr selectionContainer = IntPtr.Zero;
try
{
// Get the current project hierarchy, project item, and selection container for the current selection
// If the selection spans multiple hierachies, hierarchyPtr is Zero
uint itemid;
IVsMultiItemSelect multiItemSelect = null;
ErrorHandler.ThrowOnFailure(monitorSelection.GetCurrentSelection(out hierarchyPtr, out itemid, out multiItemSelect, out selectionContainer));
if (itemid != VSConstants.VSITEMID_SELECTION)
{
// We only care if there are nodes selected in the tree
if (itemid != VSConstants.VSITEMID_NIL)
{
if (hierarchyPtr == IntPtr.Zero)
{
// Solution is selected
VSITEMSELECTION vsItemSelection;
vsItemSelection.pHier = null;
vsItemSelection.itemid = itemid;
selectedNodes.Add(vsItemSelection);
}
else
{
IVsHierarchy hierarchy = (IVsHierarchy)Marshal.GetObjectForIUnknown(hierarchyPtr);
// Single item selection
VSITEMSELECTION vsItemSelection;
vsItemSelection.pHier = hierarchy;
vsItemSelection.itemid = itemid;
selectedNodes.Add(vsItemSelection);
}
}
}
else
{
if (multiItemSelect != null)
{
// This is a multiple item selection.
//Get number of items selected and also determine if the items are located in more than one hierarchy
uint numberOfSelectedItems;
int isSingleHierarchyInt;
ErrorHandler.ThrowOnFailure(multiItemSelect.GetSelectionInfo(out numberOfSelectedItems, out isSingleHierarchyInt));
bool isSingleHierarchy = (isSingleHierarchyInt != 0);
// Now loop all selected items and add them to the list
Debug.Assert(numberOfSelectedItems > 0, "Bad number of selected itemd");
if (numberOfSelectedItems > 0)
{
VSITEMSELECTION[] vsItemSelections = new VSITEMSELECTION[numberOfSelectedItems];
ErrorHandler.ThrowOnFailure(multiItemSelect.GetSelectedItems(0, numberOfSelectedItems, vsItemSelections));
foreach (VSITEMSELECTION vsItemSelection in vsItemSelections)
{
selectedNodes.Add(vsItemSelection);
}
}
}
}
}
finally
{
if (hierarchyPtr != IntPtr.Zero)
{
Marshal.Release(hierarchyPtr);
}
if (selectionContainer != IntPtr.Zero)
{
Marshal.Release(selectionContainer);
}
}
return selectedNodes;
}
开发者ID:elovelan,项目名称:Git-Source-Control-Provider,代码行数:91,代码来源:SccProviderService.cs
示例11: GetSelectedSourceImage
public static VSITEMSELECTION GetSelectedSourceImage(this IVsMonitorSelection monitorSelection)
{
VSITEMSELECTION sel = new VSITEMSELECTION();
if (monitorSelection != null)
{
IntPtr hierarchyPtr = IntPtr.Zero;
IntPtr selectionContainerPtr = IntPtr.Zero;
try
{
IVsMultiItemSelect multiSelect;
if (monitorSelection.GetCurrentSelection(out hierarchyPtr, out sel.itemid, out multiSelect, out selectionContainerPtr) >= 0)
{
sel.pHier = Marshal.GetObjectForIUnknown(hierarchyPtr) as IVsHierarchy;
if (sel.pHier != null && multiSelect != null)
{
uint items;
int singleHierarchy;
if (multiSelect.GetSelectionInfo(out items, out singleHierarchy) >= 0 && items != 1)
{
// Must have only one item selected
sel.pHier = null;
}
}
}
}
finally
{
if (hierarchyPtr != IntPtr.Zero)
{
Marshal.Release(hierarchyPtr);
hierarchyPtr = IntPtr.Zero;
}
if (selectionContainerPtr != IntPtr.Zero)
{
Marshal.Release(selectionContainerPtr);
selectionContainerPtr = IntPtr.Zero;
}
}
}
bool isImage = false;
if (sel.pHier != null)
{
object nameObj;
if (sel.pHier.GetProperty(sel.itemid, (int)__VSHPROPID.VSHPROPID_Name, out nameObj) >= 0)
{
isImage = ImageHelpers.IsSourceImageFile(nameObj as string);
}
}
if (!isImage)
{
sel = new VSITEMSELECTION();
}
return sel;
}
开发者ID:spadapet,项目名称:universal-image-scaler,代码行数:61,代码来源:SelectionHelpers.cs
示例12: GetExtensionObject
internal static EnvDTE.ProjectItem GetExtensionObject(VSITEMSELECTION selection) {
object project;
ErrorHandler.ThrowOnFailure(
selection.pHier.GetProperty(
selection.itemid,
(int)__VSHPROPID.VSHPROPID_ExtObject,
out project
)
);
return (project as EnvDTE.ProjectItem);
}
开发者ID:wenh123,项目名称:PTVS,代码行数:13,代码来源:MLPackage.cs
示例13: RefreshSourceControlGlyphs
private void RefreshSourceControlGlyphs(VSITEMSELECTION node)
{
var project = node.pHier as IVsSccProject2;
if (project != null)
{
// Refresh all the glyphs in the project; the project will call back GetSccGlyphs()
// with the files for each node that will need new glyph
project.SccGlyphChanged(0, null, null, null);
}
else if (node.itemid == VSConstants.VSITEMID_ROOT)
{
// Note: The solution's hierarchy does not implement IVsSccProject2, IVsSccProject interfaces
// It may be a pain to treat the solution as special case everywhere; a possible workaround is
// to implement a solution-wrapper class, that will implement IVsSccProject2, IVsSccProject and
// IVsHierarhcy interfaces, and that could be used in provider's code wherever a solution is needed.
// This approach could unify the treatment of solution and projects in the provider's code.
// Until then, solution is treated as special case
var sccService = _serviceProvider.GetService<SourceControlProvider>();
string directory, fileName, userFile;
ErrorHandler.ThrowOnFailure(_vsSolution.GetSolutionInfo(out directory, out fileName, out userFile));
var rgpszFullPaths = new[] {fileName};
var rgsiGlyphs = new VsStateIcon[1];
sccService.GetSccGlyph(1, rgpszFullPaths, rgsiGlyphs, new uint[1]);
// Set the solution's glyph directly in the hierarchy
((IVsHierarchy)_vsSolution).SetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_StateIconIndex, rgsiGlyphs[0]);
}
}
开发者ID:resnikb,项目名称:GitWorkflows,代码行数:31,代码来源:SolutionService.cs
示例14: AddToNewFile
private static void AddToNewFile(VSITEMSELECTION item, AddAzureServiceDialog dlg) {
var code = dlg.GenerateServiceCode();
var tempFile = Path.GetTempFileName();
File.WriteAllText(tempFile, code);
var projectItem = GetProjectItems(item).AddFromTemplate(
tempFile,
dlg.ServiceName.Text + ".py"
);
var window = projectItem.Open();
window.Activate();
}
开发者ID:wenh123,项目名称:PTVS,代码行数:12,代码来源:MLPackage.cs
示例15: GetProjectItems
internal static EnvDTE.ProjectItems GetProjectItems(VSITEMSELECTION selection) {
object project;
ErrorHandler.ThrowOnFailure(
selection.pHier.GetProperty(
selection.itemid,
(int)__VSHPROPID.VSHPROPID_ExtObject,
out project
)
);
if (project is EnvDTE.ProjectItem) {
return ((EnvDTE.ProjectItem)project).ProjectItems;
}
return ((EnvDTE.Project)project).ProjectItems;
}
开发者ID:wenh123,项目名称:PTVS,代码行数:16,代码来源:MLPackage.cs
示例16: CreateAddServiceDialog
private static AddAzureServiceDialog CreateAddServiceDialog(VSITEMSELECTION item) {
switch (GetProjectKind(item)) {
case ProjectKind.Bottle:
return new AddAzureServiceDialog("views", true);
default:
return new AddAzureServiceDialog(null, false);
}
}
开发者ID:wenh123,项目名称:PTVS,代码行数:8,代码来源:MLPackage.cs
示例17: IsCommandDisabledForFile
private static bool IsCommandDisabledForFile(VSITEMSELECTION? item) {
if (item.Value.IsFile() &&
String.Equals(Path.GetExtension(item.Value.GetCanonicalName()), ".py", StringComparison.OrdinalIgnoreCase)) {
return false;
}
return true;
}
开发者ID:wenh123,项目名称:PTVS,代码行数:7,代码来源:MLPackage.cs
示例18: GetSelectedItems
public int GetSelectedItems(uint grfGSI, uint cItems, VSITEMSELECTION[] rgItemSel) {
var flags = (__VSGSIFLAGS)grfGSI;
for (int i = 0; i < cItems && i < _items.Length; i++) {
rgItemSel[i].itemid = _items[i].ItemId;
if (!flags.HasFlag(__VSGSIFLAGS.GSI_fOmitHierPtrs)) {
rgItemSel[i].pHier = _items[i].Hierarchy;
}
}
return VSConstants.S_OK;
}
开发者ID:omnimark,项目名称:PTVS,代码行数:10,代码来源:MockVsUIHierarchyWindow.cs
示例19:
int IVsSimpleObjectList2.GetMultipleSourceItems(uint index, uint grfGSI, uint cItems, VSITEMSELECTION[] rgItemSel)
{
return VSConstants.E_NOTIMPL;
}
开发者ID:ufosky-server,项目名称:MultiversePlatform,代码行数:4,代码来源:LibraryNode.cs
示例20: GetSelectedNodes
/// <summary>
/// Gets the list of selected HierarchyNode objects
/// </summary>
/// <returns>A list of HierarchyNode objects</returns>
protected internal virtual IList<HierarchyNode> GetSelectedNodes()
{
// Retrieve shell interface in order to get current selection
IVsMonitorSelection monitorSelection = this.GetService(typeof(IVsMonitorSelection)) as IVsMonitorSelection;
if (monitorSelection == null)
{
throw new InvalidOperationException();
}
List<HierarchyNode> selectedNodes = new List<HierarchyNode>();
IntPtr hierarchyPtr = IntPtr.Zero;
IntPtr selectionContainer = IntPtr.Zero;
try
{
// Get the current project hierarchy, project item, and selection container for the current selection
// If the selection spans multiple hierachies, hierarchyPtr is Zero
uint itemid;
IVsMultiItemSelect multiItemSelect = null;
ErrorHandler.ThrowOnFailure(monitorSelection.GetCurrentSelection(out hierarchyPtr, out itemid, out multiItemSelect, out selectionContainer));
// We only care if there are one ore more nodes selected in the tree
if (itemid != VSConstants.VSITEMID_NIL && hierarchyPtr != IntPtr.Zero)
{
IVsHierarchy hierarchy = Marshal.GetObjectForIUnknown(hierarchyPtr) as IVsHierarchy;
if (itemid != VSConstants.VSITEMID_SELECTION)
{
// This is a single selection. Compare hirarchy with our hierarchy and get node from itemid
if (Utilities.IsSameComObject(this, hierarchy))
{
HierarchyNode node = this.NodeFromItemId(itemid);
if (node != null)
{
selectedNodes.Add(node);
}
}
else
{
NestedProjectNode node = this.GetNestedProjectForHierarchy(hierarchy);
if (node != null)
{
selectedNodes.Add(node);
}
}
}
else if (multiItemSelect != null)
{
// This is a multiple item selection.
//Get number of items selected and also determine if the items are located in more than one hierarchy
uint numberOfSelectedItems;
int isSingleHierarchyInt;
ErrorHandler.ThrowOnFailure(multiItemSelect.GetSelectionInfo(out numberOfSelectedItems, out isSingleHierarchyInt));
bool isSingleHierarchy = (isSingleHierarchyInt != 0);
// Now loop all selected items and add to the list only those that are selected within this hierarchy
if (!isSingleHierarchy || (isSingleHierarchy && Utilities.IsSameComObject(this, hierarchy)))
{
Debug.Assert(numberOfSelectedItems > 0, "Bad number of selected itemd");
VSITEMSELECTION[] vsItemSelections = new VSITEMSELECTION[numberOfSelectedItems];
uint flags = (isSingleHierarchy) ? (uint)__VSGSIFLAGS.GSI_fOmitHierPtrs : 0;
ErrorHandler.ThrowOnFailure(multiItemSelect.GetSelectedItems(flags, numberOfSelectedItems, vsItemSelections));
foreach (VSITEMSELECTION vsItemSelection in vsItemSelections)
{
if (isSingleHierarchy || Utilities.IsSameComObject(this, vsItemSelection.pHier))
{
HierarchyNode node = this.NodeFromItemId(vsItemSelection.itemid);
if (node != null)
{
selectedNodes.Add(node);
}
}
}
}
}
}
}
finally
{
if (hierarchyPtr != IntPtr.Zero)
{
Marshal.Release(hierarchyPtr);
}
if (selectionContainer != IntPtr.Zero)
{
Marshal.Release(selectionContainer);
}
}
return selectedNodes;
}
开发者ID:IntelliTect,
|
请发表评论