当前位置: 首页>>代码示例>>C#>>正文


C# IVwEnv.AddPictureWithCaption方法代码示例

本文整理汇总了C#中IVwEnv.AddPictureWithCaption方法的典型用法代码示例。如果您正苦于以下问题:C# IVwEnv.AddPictureWithCaption方法的具体用法?C# IVwEnv.AddPictureWithCaption怎么用?C# IVwEnv.AddPictureWithCaption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IVwEnv的用法示例。


在下文中一共展示了IVwEnv.AddPictureWithCaption方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DisplayEmbeddedObject

		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);
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:43,代码来源:FwBaseVc.cs

示例2: DisplayEmbeddedObject

		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Display the specified object (from an ORC embedded in a string). The default
		/// here knows how to display IPictures.
		/// </summary>
		/// <param name="vwenv"></param>
		/// <param name="hvo"></param>
		/// -----------------------------------------------------------------------------------
		public virtual void DisplayEmbeddedObject(IVwEnv vwenv, int hvo)
		{
			CheckDisposed();
			// See if it is a CmPicture.
			ISilDataAccess sda = vwenv.DataAccess;
			int clsid = sda.get_IntProp(hvo, (int)CmObjectFields.kflidCmObject_Class);
			if (clsid != CmPicture.kclsidCmPicture)
				return; // don't know how to deal with it.
			int hvoFile = sda.get_ObjectProp(hvo, (int)CmPicture.CmPictureTags.kflidPictureFile);
			if (hvoFile == 0)
				return;
			string path;
			string fileName = sda.get_UnicodeProp(hvoFile, (int)CmFile.CmFileTags.kflidInternalPath);
			if (Path.IsPathRooted(fileName))
			{
				path = fileName;
			}
			else
			{
				if (m_hvoLangProject == 0)
					TryToSetLangProjectHvo(sda, hvo);
				string externalRoot = sda.get_UnicodeProp(m_hvoLangProject, (int)LangProject.LangProjectTags.kflidExtLinkRootDir);
				if (String.IsNullOrEmpty(externalRoot))
					path = Path.Combine(DirectoryFinder.FWDataDirectory, fileName);
				else
					path = Path.Combine(externalRoot, fileName);
			}
			vwenv.set_IntProperty((int)FwTextPropType.ktptAlign,
				(int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalCenter);
			Image image;
			try
			{
				image = Image.FromFile(FileUtils.ActualFilePath(path));
			}
			catch
			{
				// unable to read image. set to default image that indicates an invalid image.
				image = ResourceHelper.ImageNotFoundX;
			}
			stdole.IPicture picture;
			try
			{
				picture = (stdole.IPicture)OLECvt.ToOLE_IPictureDisp(image);
			}
			catch
			{
				// conversion to OLE format from current image format is not supported (e.g. WMF file)
				// try to convert it to a bitmap and convert it to OLE format again.
				// TODO: deal with transparency
				// We could just do the following line (creating a new bitmap) instead of going
				// through a memory stream, but then we end up with an image that is too big.
				//image = new Bitmap(image, image.Size);
				using (MemoryStream imageStream = new MemoryStream())
				{
					image.Save(imageStream, ImageFormat.Png);
					image = Image.FromStream(imageStream, true);
				}
				picture = (stdole.IPicture)OLECvt.ToOLE_IPictureDisp(image);
			}
			// -1 is ktagNotAnAttr. 0 width & height mean use natural width/height.
			vwenv.AddPictureWithCaption(picture, -1, CaptionProps, hvoFile, m_wsDefault, 0, 0, this);
			image.Dispose();
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:71,代码来源:VwBaseVc.cs


注:本文中的IVwEnv.AddPictureWithCaption方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。