public void ModifyOverlay(bool fApplyTag, IVwOverlay pvo, int itag) { CheckDisposed(); if (m_rootb == null) return; Debug.WriteLine("WARNING: RootSite.ModifyOverlay() isn't tested yet"); int hvo; uint clrFore; uint clrBack; uint clrUnder; int unt; bool fHidden; string uid; using (ArrayPtr arrayPtr = MarshalEx.StringToNative((int)VwConst1.kcchGuidRepLength + 1, true)) { pvo.GetDbTagInfo(itag, out hvo, out clrFore, out clrBack, out clrUnder, out unt, out fHidden, arrayPtr); uid = MarshalEx.NativeToString(arrayPtr, (int)VwConst1.kcchGuidRepLength, false); } IVwSelection vwsel; ITsTextProps[] vttp; IVwPropertyStore[] vvps; if (EditingHelper.GetCharacterProps(out vwsel, out vttp, out vvps)) { int cttp = vttp.Length; for (int ittp = 0; ittp < cttp; ittp++) { string strGuid = vttp[ittp].GetStrPropValue( (int)FwTextPropType.ktptTags); // REVIEW (EberhardB): I'm not sure if this works int cGuids = strGuid.Length / Marshal.SizeOf(typeof(Guid)); List<string> guids = new List<string>(); for (int i = 0; i < cGuids; i++) guids.Add(strGuid.Substring(i, Marshal.SizeOf(typeof(Guid)))); if (fApplyTag) { // Add the tag if it does not exist if (guids.BinarySearch(uid) >= 0) { // The tag has already been applied to the textprop, so it doesn't // need to be modified. vttp[ittp] = null; continue; } else { // We need to add the tag to the textprop. guids.Add(uid); guids.Sort(); } } else { // Remove the tag from the textprop. guids.Remove(uid); } ITsPropsBldr tpb = vttp[ittp].GetBldr(); tpb.SetStrPropValue((int)FwTextPropType.ktptTags, guids.ToString()); vttp[ittp] = tpb.GetTextProps(); } vwsel.SetSelectionProps(cttp, vttp); /* * ENHANCE (EberhardB): Implement this if we need it. It probably should be * implemented in a derived class (view class for DataNotebook?) // Update the RnGenericRec_PhraseTags table as necessary. // (Yes, this is special case code!) AfDbInfo * pdbi = NULL; AfMainWnd * pamw = m_pwndSubclass->MainWindow(); if (pamw) { AfMdiMainWnd * pammw = dynamic_cast<AfMdiMainWnd *>(pamw); AfLpInfo * plpi = NULL; if (pammw) { plpi = pammw->GetLpInfo(); if (plpi) pdbi = plpi->GetDbInfo(); } } if (pdbi) { int clevEnd; int clevAnchor; HVO hvoEnd; HVO hvoAnchor; PropTag tagEnd; PropTag tagAnchor; int ihvo; int cpropPrev; IVwPropertyStorePtr qvps; CheckHr(qvwsel->CLevels(true, &clevEnd)); Assert(clevEnd >= 1); CheckHr(qvwsel->CLevels(false, &clevAnchor)); Assert(clevAnchor >= 1); CheckHr(qvwsel->PropInfo(true, clevEnd - 1, &hvoEnd, &tagEnd, &ihvo, &cpropPrev, &qvps)); CheckHr(qvwsel->PropInfo(false, clevAnchor - 1, &hvoAnchor, &tagAnchor, &ihvo, &cpropPrev, &qvps)); IOleDbEncapPtr qode; pdbi->GetDbAccess(&qode); DbStringCrawler::UpdatePhraseTagsTable(kflidRnGenericRec_PhraseTags, fApplyTag, qode, hvo, hvoEnd, hvoAnchor); } */ } if (FindForm() == Form.ActiveForm) Focus(); }
/// <summary> /// Converts a List of integers into a comma-delimited string of numbers. /// </summary> /// <param name="hvoList"></param> /// <returns></returns> private string ConvertHvoListToString(List<int> hvoList) { return hvoList.ToString(","); }