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


C# TextBlock.GetHashCode方法代码示例

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


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

示例1: MeasureText

		public TextExtents MeasureText(ref TextBlock block, TextQuality quality)
		{
			// First, check if we have cached this text block. Do not use block_cache.TryGetValue, to avoid thrashing
			// the user's TextBlockExtents struct.
			int hashcode = block.GetHashCode();
			if (block_cache.ContainsKey(hashcode))
				return block_cache[hashcode];

			// If this block is not cached, we have to measure it and (potentially) place it in the cache.
			TextExtents extents = MeasureTextExtents(ref block, quality);

			if ((block.Options & TextPrinterOptions.NoCache) == 0)
				block_cache.Add(hashcode, extents);

			return extents;
		}
开发者ID:treytomes,项目名称:ASCIIWorld2,代码行数:16,代码来源:GdiPlusGlyphRasterizer.cs

示例2: Print

        public void Print(ref TextBlock block, Color color, IGlyphRasterizer rasterizer)
        {
            GL.PushAttrib(AttribMask.CurrentBit | AttribMask.TextureBit | AttribMask.EnableBit | AttribMask.ColorBufferBit | AttribMask.DepthBufferBit);

            GL.Enable(EnableCap.Texture2D);
            GL.Enable(EnableCap.Blend);
            SetBlendFunction();

            GL.Disable(EnableCap.DepthTest);

            GL.TexEnv(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvMode, (int)All.Modulate);
            GL.TexEnv(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvColor, new Color4(0, 0, 0, 0));

            GL.Disable(EnableCap.TextureGenQ);
            GL.Disable(EnableCap.TextureGenR);
            GL.Disable(EnableCap.TextureGenS);
            GL.Disable(EnableCap.TextureGenT);

            RectangleF position;

            SetColor(color);
            
            int block_hash = block.GetHashCode();
            if (block_cache.ContainsKey(block_hash))
            {
                GL.CallList(block_cache[block_hash]);
            }
            else
            {
                using (TextExtents extents = rasterizer.MeasureText(ref block))
                {
                    // Build layout
                    int current = 0;
                    foreach (Glyph glyph in block)
                    {
                        // Do not render whitespace characters or characters outside the clip rectangle.
                        if (glyph.IsWhiteSpace || extents[current].Width == 0 || extents[current].Height == 0)
                        {
                            current++;
                            continue;
                        }
                        else if (!Cache.Contains(glyph))
                            Cache.Add(glyph, rasterizer, TextQuality);

                        CachedGlyphInfo info = Cache[glyph];
                        position = extents[current++];

                        // Use the real glyph width instead of the measured one (we want to achieve pixel perfect output).
                        position.Size = info.Rectangle.Size;

                        if (!active_lists.ContainsKey(info.Texture))
                        {
                            if (inactive_lists.Count > 0)
                            {
                                List<Vector2> list = inactive_lists.Dequeue();
                                list.Clear();
                                active_lists.Add(info.Texture, list);
                            }
                            else
                            {
                                active_lists.Add(info.Texture, new List<Vector2>());
                            }
                        }

                        {
                            // Interleaved array: Vertex, TexCoord, Vertex, ...
                            List<Vector2> current_list = active_lists[info.Texture];
                            current_list.Add(new Vector2(info.RectangleNormalized.Left, info.RectangleNormalized.Top));
                            current_list.Add(new Vector2(position.Left, position.Top));
                            current_list.Add(new Vector2(info.RectangleNormalized.Left, info.RectangleNormalized.Bottom));
                            current_list.Add(new Vector2(position.Left, position.Bottom));
                            current_list.Add(new Vector2(info.RectangleNormalized.Right, info.RectangleNormalized.Bottom));
                            current_list.Add(new Vector2(position.Right, position.Bottom));

                            current_list.Add(new Vector2(info.RectangleNormalized.Right, info.RectangleNormalized.Bottom));
                            current_list.Add(new Vector2(position.Right, position.Bottom));
                            current_list.Add(new Vector2(info.RectangleNormalized.Right, info.RectangleNormalized.Top));
                            current_list.Add(new Vector2(position.Right, position.Top));
                            current_list.Add(new Vector2(info.RectangleNormalized.Left, info.RectangleNormalized.Top));
                            current_list.Add(new Vector2(position.Left, position.Top));
                        }
                    }
                }

                // Render
                int display_list = 0;
                if ((block.Options & TextPrinterOptions.NoCache) == 0)
                {
                    display_list = GL.GenLists(1);
                    // Mesa Indirect gerates an InvalidOperation error right after
                    // GL.EndList() when using ListMode.CompileAndExecute.
                    // Using ListMode.Compile as a workaround.
                    GL.NewList(display_list, ListMode.Compile);
                }
                foreach (Texture2D key in active_lists.Keys)
                {
                    List<Vector2> list = active_lists[key];

                    key.Bind();

//.........这里部分代码省略.........
开发者ID:dakahler,项目名称:alloclave,代码行数:101,代码来源:GL1TextOutputProvider.cs


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