OLD | NEW |
| (Empty) |
1 /// Copyright (c) Microsoft Corporation. All rights reserved. | |
2 | |
3 using System; | |
4 using System.Diagnostics.CodeAnalysis; | |
5 using System.Runtime.InteropServices; | |
6 using System.Text; | |
7 using Microsoft.VisualStudio; | |
8 using OleConstants = Microsoft.VisualStudio.OLE.Interop.Constants; | |
9 using VsCommands = Microsoft.VisualStudio.VSConstants.VSStd97CmdID; | |
10 using VsCommands2K = Microsoft.VisualStudio.VSConstants.VSStd2KCmdID; | |
11 | |
12 namespace Microsoft.VisualStudio.Project | |
13 { | |
14 /// <summary> | |
15 /// Defines the logic for all dependent file nodes (solution explorer ic
on, commands etc.) | |
16 /// </summary> | |
17 [CLSCompliant(false)] | |
18 [ComVisible(true)] | |
19 public class DependentFileNode : FileNode | |
20 { | |
21 #region fields | |
22 /// <summary> | |
23 /// Defines if the node has a name relation to its parent node | |
24 /// e.g. Form1.ext and Form1.resx are name related (until first
occurence of extention separator) | |
25 /// </summary> | |
26 #endregion | |
27 | |
28 #region Properties | |
29 public override int ImageIndex | |
30 { | |
31 get { return (this.CanShowDefaultIcon() ? (int)ProjectNo
de.ImageName.DependentFile : (int)ProjectNode.ImageName.MissingFile); } | |
32 } | |
33 #endregion | |
34 | |
35 #region ctor | |
36 /// <summary> | |
37 /// Constructor for the DependentFileNode | |
38 /// </summary> | |
39 /// <param name="root">Root of the hierarchy</param> | |
40 /// <param name="e">Associated project element</param> | |
41 public DependentFileNode(ProjectNode root, ProjectElement elemen
t) | |
42 : base(root, element) | |
43 { | |
44 this.HasParentNodeNameRelation = false; | |
45 } | |
46 | |
47 | |
48 #endregion | |
49 | |
50 #region overridden methods | |
51 /// <summary> | |
52 /// Disable rename | |
53 /// </summary> | |
54 /// <param name="label">new label</param> | |
55 /// <returns>E_NOTIMPLE in order to tell the call that we do not
support rename</returns> | |
56 public override string GetEditLabel() | |
57 { | |
58 throw new NotImplementedException(); | |
59 } | |
60 | |
61 /// <summary> | |
62 /// Gets a handle to the icon that should be set for this node | |
63 /// </summary> | |
64 /// <param name="open">Whether the folder is open, ignored here.
</param> | |
65 /// <returns>Handle to icon for the node</returns> | |
66 public override object GetIconHandle(bool open) | |
67 { | |
68 return this.ProjectMgr.ImageHandler.GetIconHandle(this.I
mageIndex); | |
69 } | |
70 | |
71 /// <summary> | |
72 /// Disable certain commands for dependent file nodes | |
73 /// </summary> | |
74 protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd
, IntPtr pCmdText, ref QueryStatusResult result) | |
75 { | |
76 if(cmdGroup == VsMenus.guidStandardCommandSet97) | |
77 { | |
78 switch((VsCommands)cmd) | |
79 { | |
80 case VsCommands.Copy: | |
81 case VsCommands.Paste: | |
82 case VsCommands.Cut: | |
83 case VsCommands.Rename: | |
84 result |= QueryStatusResult.NOTS
UPPORTED; | |
85 return VSConstants.S_OK; | |
86 | |
87 case VsCommands.ViewCode: | |
88 case VsCommands.Open: | |
89 case VsCommands.OpenWith: | |
90 result |= QueryStatusResult.SUPP
ORTED | QueryStatusResult.ENABLED; | |
91 return VSConstants.S_OK; | |
92 } | |
93 } | |
94 else if(cmdGroup == VsMenus.guidStandardCommandSet2K) | |
95 { | |
96 if((VsCommands2K)cmd == VsCommands2K.EXCLUDEFROM
PROJECT) | |
97 { | |
98 result |= QueryStatusResult.NOTSUPPORTED
; | |
99 return VSConstants.S_OK; | |
100 } | |
101 } | |
102 else | |
103 { | |
104 return (int)OleConstants.OLECMDERR_E_UNKNOWNGROU
P; | |
105 } | |
106 return base.QueryStatusOnNode(cmdGroup, cmd, pCmdText, r
ef result); | |
107 } | |
108 | |
109 /// <summary> | |
110 /// DependentFileNodes node cannot be dragged. | |
111 /// </summary> | |
112 /// <returns>null</returns> | |
113 protected internal override StringBuilder PrepareSelectedNodesFo
rClipBoard() | |
114 { | |
115 return null; | |
116 } | |
117 | |
118 protected override NodeProperties CreatePropertiesObject() | |
119 { | |
120 return new DependentFileNodeProperties(this); | |
121 } | |
122 | |
123 /// <summary> | |
124 /// Redraws the state icon if the node is not excluded from sour
ce control. | |
125 /// </summary> | |
126 [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBe
SpelledCorrectly", MessageId = "Scc")] | |
127 protected internal override void UpdateSccStateIcons() | |
128 { | |
129 if(!this.ExcludeNodeFromScc) | |
130 { | |
131 this.Parent.ReDraw(UIHierarchyElement.SccState); | |
132 } | |
133 } | |
134 #endregion | |
135 | |
136 } | |
137 } | |
OLD | NEW |