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


C# ContentRef.Is方法代码示例

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


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

示例1: CanReImportFile

 public bool CanReImportFile(ContentRef<Resource> r, string srcFile)
 {
     string ext = Path.GetExtension(srcFile);
     if (r.Is<VertexShader>() && string.Equals(ext, SourceFileExtVertex, StringComparison.InvariantCultureIgnoreCase))
         return true;
     else if (r.Is<FragmentShader>() && string.Equals(ext, SourceFileExtFragment, StringComparison.InvariantCultureIgnoreCase))
         return true;
     else
         return false;
 }
开发者ID:sinithwar,项目名称:duality,代码行数:10,代码来源:ShaderFileImporter.cs

示例2: CanReImportFile

 public bool CanReImportFile(ContentRef<Resource> r, string srcFile)
 {
     return r.Is<Font>();
 }
开发者ID:gitMaxim,项目名称:duality,代码行数:4,代码来源:FontFileImporter.cs

示例3: OnResourceModified

		private void OnResourceModified(ContentRef<Resource> resRef)
		{
			List<object> changedObj = null;

			// If a font has been modified, reload it and update all TextRenderers
			if (resRef.Is<Font>())
			{
				if (resRef.IsLoaded)
				{
					Font fnt = resRef.As<Font>().Res;
					if (fnt.NeedsReload)
						fnt.ReloadData();
				}

				foreach (Duality.Components.Renderers.TextRenderer r in Scene.Current.AllObjects.GetComponents<Duality.Components.Renderers.TextRenderer>())
				{
					r.Text.ApplySource();

					if (changedObj == null) changedObj = new List<object>();
					changedObj.Add(r);
				}
			}
			// If its a Pixmap, reload all associated Textures
			else if (resRef.Is<Pixmap>())
			{
				ContentRef<Pixmap> pixRef = resRef.As<Pixmap>();
				foreach (ContentRef<Texture> tex in ContentProvider.GetLoadedContent<Texture>())
				{
					if (!tex.IsAvailable) continue;
					if (tex.Res.BasePixmap == pixRef)
					{
						tex.Res.ReloadData();

						if (changedObj == null) changedObj = new List<object>();
						changedObj.Add(tex.Res);
					}
				}
			}
			// If its a Texture, update all associated RenderTargets
			else if (resRef.Is<Texture>())
			{
				if (resRef.IsLoaded)
				{
					Texture tex = resRef.As<Texture>().Res;
					if (tex.NeedsReload)
						tex.ReloadData();
				}

				ContentRef<Texture> texRef = resRef.As<Texture>();
				foreach (ContentRef<RenderTarget> rt in ContentProvider.GetLoadedContent<RenderTarget>())
				{
					if (!rt.IsAvailable) continue;
					if (rt.Res.Targets.Contains(texRef))
					{
						rt.Res.SetupOpenGLRes();

						if (changedObj == null) changedObj = new List<object>();
						changedObj.Add(rt.Res);
					}
				}
			}
			// If its some kind of shader, update all associated ShaderPrograms
			else if (resRef.Is<AbstractShader>())
			{
				ContentRef<FragmentShader> fragRef = resRef.As<FragmentShader>();
				ContentRef<VertexShader> vertRef = resRef.As<VertexShader>();
				foreach (ContentRef<ShaderProgram> sp in ContentProvider.GetLoadedContent<ShaderProgram>())
				{
					if (!sp.IsAvailable) continue;
					if (sp.Res.Fragment == fragRef ||
						sp.Res.Vertex == vertRef)
					{
						bool wasCompiled = sp.Res.Compiled;
						sp.Res.AttachShaders();
						if (wasCompiled) sp.Res.Compile();

						if (changedObj == null) changedObj = new List<object>();
						changedObj.Add(sp.Res);
					}
				}
			}

			// Notify a change that isn't critical regarding persistence (don't flag stuff unsaved)
			if (changedObj != null)
				DualityEditorApp.NotifyObjPropChanged(this, new ObjectSelection(changedObj as IEnumerable<object>), false);
		}
开发者ID:arajar,项目名称:duality,代码行数:86,代码来源:EditorBasePlugin.cs

示例4: ProcessDataDirEvents

		private static void ProcessDataDirEvents()
		{
			List<ResourceRenamedEventArgs> renameEventBuffer = null;

			// Process events
			while (dataDirEventBuffer.Count > 0)
			{
				FileSystemEventArgs e = FetchFileSystemEvent(dataDirEventBuffer, DualityApp.DataDirectory);
				if (e == null) continue;

				// Determine whether we're dealing with a directory
				bool isDirectory = Directory.Exists(e.FullPath);
				{
					// If this is a deletion, nothing exists anymore, rely on metadata instead.
					DeletedEventArgsExt de = e as DeletedEventArgsExt;
					if (de != null && de.IsDirectory)
						isDirectory = true;
				}

				if (e.ChangeType == WatcherChangeTypes.Changed)
				{
					// Ignore stuff saved by the editor itself
					if (IsPathEditorModified(e.FullPath))
						continue;

					if (Resource.IsResourceFile(e.FullPath) || isDirectory)
					{
						ContentRef<Resource> resRef = new ContentRef<Resource>(null, e.FullPath);

						// Unregister outdated resources, if modified outside the editor
						if (!isDirectory && ContentProvider.HasContent(e.FullPath))
						{
							bool isCurrentScene = resRef.Is<Scene>() && Scene.Current == resRef.Res;
							if (isCurrentScene || DualityEditorApp.IsResourceUnsaved(e.FullPath))
							{
								DialogResult result = MessageBox.Show(
									String.Format(Properties.GeneralRes.Msg_ConfirmReloadResource_Text, e.FullPath), 
									Properties.GeneralRes.Msg_ConfirmReloadResource_Caption, 
									MessageBoxButtons.YesNo,
									MessageBoxIcon.Exclamation);
								if (result == DialogResult.Yes)
								{
									string curScenePath = Scene.CurrentPath;
									ContentProvider.RemoveContent(e.FullPath);
									if (isCurrentScene) Scene.SwitchTo(ContentProvider.RequestContent<Scene>(curScenePath), true);
								}
							}
							else
								ContentProvider.RemoveContent(e.FullPath);
						}

						if (ResourceModified != null)
							ResourceModified(null, new ResourceEventArgs(e.FullPath, isDirectory));
					}
				}
				else if (e.ChangeType == WatcherChangeTypes.Created)
				{
					if (File.Exists(e.FullPath))
					{
						// Register newly detected Resource file
						if (Resource.IsResourceFile(e.FullPath))
						{
							if (ResourceCreated != null)
								ResourceCreated(null, new ResourceEventArgs(e.FullPath, false));
						}
					}
					else if (Directory.Exists(e.FullPath))
					{
						// Register newly detected Resource directory
						if (ResourceCreated != null)
							ResourceCreated(null, new ResourceEventArgs(e.FullPath, true));
					}
				}
				else if (e.ChangeType == WatcherChangeTypes.Deleted)
				{
					// Is it a Resource file or just something else?
					if (Resource.IsResourceFile(e.FullPath) || isDirectory)
					{
						ResourceEventArgs args = new ResourceEventArgs(e.FullPath, isDirectory);

						// Organize the Source/Media directory accordingly
						DeleteSourceMediaFile(args);

						// Unregister no-more existing resources
						if (isDirectory)	ContentProvider.RemoveContentTree(args.Path);
						else				ContentProvider.RemoveContent(args.Path);

						if (ResourceDeleted != null)
							ResourceDeleted(null, args);
					}
				}
				else if (e.ChangeType == WatcherChangeTypes.Renamed)
				{
					// Is it a Resource file or just something else?
					RenamedEventArgs re = e as RenamedEventArgs;
					ResourceRenamedEventArgs args = new ResourceRenamedEventArgs(re.FullPath, re.OldFullPath, isDirectory);
					if (Resource.IsResourceFile(e.FullPath) || isDirectory)
					{
						// Determine which Source / Media files would belong to this Resource - before moving it
						string[] oldMediaPaths = PreMoveSourceMediaFile(args);;
//.........这里部分代码省略.........
开发者ID:Scottyaim,项目名称:duality,代码行数:101,代码来源:FileEventManager.cs


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