public override void DisplayEmbeddedObject(IVwEnv vwenv, int hvo) { // See if it is a CmPicture. ISilDataAccess sda = vwenv.DataAccess; int clsid = sda.get_IntProp(hvo, (int)CmObjectFields.kflidCmObject_Class); if (clsid != CmPictureTags.kClassId) { // don't know how to deal with it. Maybe the base implementation does. base.DisplayEmbeddedObject(vwenv, hvo); return; } int hvoFile = sda.get_ObjectProp(hvo, CmPictureTags.kflidPictureFile); if (hvoFile == 0) { return; } string path; string fileName = sda.get_UnicodeProp(hvoFile, CmFileTags.kflidInternalPath); if (Path.IsPathRooted(fileName)) { path = fileName; } else { if (m_hvoLangProject == 0) { // REVIEW (TimS/TomB): Hvo is for a CmPicture which means it might not be owned. // If it's not owned, there will be no way to walk up the owner tree to find the // Language Project. Review all clients to see if they have embedded objects. // If so, they need to set the cache. TryToSetLangProjectHvo(sda, hvo); } string linkedFilesRoot = sda.get_UnicodeProp(m_hvoLangProject, LangProjectTags.kflidLinkedFilesRootDir); if (String.IsNullOrEmpty(linkedFilesRoot)) { path = Path.Combine(DirectoryFinder.FWDataDirectory, fileName); } else { path = Path.Combine(linkedFilesRoot, fileName); } } vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalCenter); IPicture picture = new PictureWrapper(path); // -1 is ktagNotAnAttr. 0 width & height mean use natural width/height. vwenv.AddPictureWithCaption(picture, -1, CaptionProps, hvoFile, m_wsDefault, 0, 0, this); }
public override void DisplayEmbeddedObject(IVwEnv vwenv, int hvo) { // See if it is a CmPicture. ISilDataAccess sda = vwenv.DataAccess; int clsid = sda.get_IntProp(hvo, (int)CmObjectFields.kflidCmObject_Class); if (clsid != CmPictureTags.kClassId) { // don't know how to deal with it. Maybe the base implementation does. base.DisplayEmbeddedObject(vwenv, hvo); return; } int hvoFile = sda.get_ObjectProp(hvo, CmPictureTags.kflidPictureFile); if (hvoFile == 0) return; string path; string fileName = sda.get_UnicodeProp(hvoFile, CmFileTags.kflidInternalPath); if (Path.IsPathRooted(fileName)) { path = fileName; } else { if (m_hvoLangProject == 0) { // REVIEW (TimS/TomB): Hvo is for a CmPicture which means it might not be owned. // If it's not owned, there will be no way to walk up the owner tree to find the // Language Project. Review all clients to see if they have embedded objects. // If so, they need to set the cache. TryToSetLangProjectHvo(sda, hvo); } string linkedFilesRoot = sda.get_UnicodeProp(m_hvoLangProject, LangProjectTags.kflidLinkedFilesRootDir); if (String.IsNullOrEmpty(linkedFilesRoot)) path = Path.Combine(FwDirectoryFinder.DataDirectory, fileName); else path = Path.Combine(linkedFilesRoot, fileName); } vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalCenter); IPicture picture = new PictureWrapper(path); // -1 is ktagNotAnAttr. 0 width & height mean use natural width/height. vwenv.AddPictureWithCaption(picture, -1, CaptionProps, hvoFile, m_wsDefault, 0, 0, this); }