コード例 #1
0
        public override int GetProperty(uint itemid, int propid, out object pvar)
        {
            // GetProperty is called many many times for this particular property
            pvar = null;
            var prop = (__VSHPROPID)propid;

            switch (prop)
            {
            case __VSHPROPID.VSHPROPID_Parent:
                if (itemid == ReportsItemId)
                {
                    pvar = VSConstants.VSITEMID_ROOT;
                }
                else if (IsReportItem(itemid))
                {
                    pvar = ReportsItemId;
                }
                break;

            case __VSHPROPID.VSHPROPID_FirstChild:
                if (itemid == VSConstants.VSITEMID_ROOT)
                {
                    pvar = ReportsItemId;
                }
                else if (itemid == ReportsItemId && Reports.Count > 0)
                {
                    pvar = Reports.First().Key;
                }
                else
                {
                    pvar = VSConstants.VSITEMID_NIL;
                }
                break;

            case __VSHPROPID.VSHPROPID_NextSibling:
                pvar = VSConstants.VSITEMID_NIL;
                if (IsReportItem(itemid))
                {
                    var items = Reports.Keys.ToArray();
                    for (int i = 0; i < items.Length; i++)
                    {
                        if (items[i] > (int)itemid)
                        {
                            pvar = itemid + 1;
                            break;
                        }
                    }
                }
                break;

            case __VSHPROPID.VSHPROPID_ItemDocCookie:
                if (itemid == VSConstants.VSITEMID_ROOT)
                {
                    pvar = (int)_docCookie;
                }
                break;

            case __VSHPROPID.VSHPROPID_Expandable:
                if (itemid == VSConstants.VSITEMID_ROOT)
                {
                    pvar = true;
                }
                else if (itemid == ReportsItemId && Reports.Count > 0)
                {
                    pvar = true;
                }
                else
                {
                    pvar = false;
                }
                break;

            case __VSHPROPID.VSHPROPID_ExpandByDefault:
                pvar = true;
                break;

            case __VSHPROPID.VSHPROPID_IconImgList:
            case __VSHPROPID.VSHPROPID_OpenFolderIconHandle:
                pvar = (int)SessionsNode._imageList.Handle;
                break;

            case __VSHPROPID.VSHPROPID_IconIndex:
            case __VSHPROPID.VSHPROPID_OpenFolderIconIndex:
                if (itemid == ReportsItemId)
                {
                    if (_isReportsExpanded)
                    {
                        pvar = (int)TreeViewIconIndex.OpenFolder;
                    }
                    else
                    {
                        pvar = (int)TreeViewIconIndex.CloseFolder;
                    }
                }
                else if (IsReportItem(itemid))
                {
                    pvar = (int)TreeViewIconIndex.GreenNotebook;
                }
                break;

            case __VSHPROPID.VSHPROPID_Caption:
                if (itemid == VSConstants.VSITEMID_ROOT)
                {
                    pvar = Caption;
                }
                else if (itemid == ReportsItemId)
                {
                    pvar = Strings.Reports;
                }
                else if (IsReportItem(itemid))
                {
                    pvar = Path.GetFileNameWithoutExtension(GetReport(itemid).Filename);
                }
                break;

            case __VSHPROPID.VSHPROPID_ParentHierarchy:
                if (itemid == VSConstants.VSITEMID_ROOT)
                {
                    pvar = _parent as IVsHierarchy;
                }
                break;
            }

            if (pvar != null)
            {
                return(VSConstants.S_OK);
            }

            return(VSConstants.DISP_E_MEMBERNOTFOUND);
        }
コード例 #2
0
 private bool IsReportItem(uint itemid)
 {
     return(itemid >= StartingReportId && Reports.ContainsKey(itemid));
 }
コード例 #3
0
ファイル: ProfilingTarget.cs プロジェクト: wenh123/PTVS
 internal Reports Clone() {
     var res = new Reports();
     if (Report != null) {
         res.Report = new Report[Report.Length];
         for (int i = 0; i < res.Report.Length; i++) {
             res.Report[i] = Report[i].Clone();
         }
     }
     return res;
 }