Beispiel #1
0
        public override void Dispose()
        {
            foreach (var node in _dirty)
            {
                var ixFileName  = Path.Combine(SessionFactory.Dir, string.Format("{0}.{1}.ix", CollectionId, node.Key));
                var tmpFileName = string.Format("{0}.tmp_ix", Path.GetFileNameWithoutExtension(ixFileName));

                using (var indexStream = new FileStream(
                           tmpFileName, FileMode.Append, FileAccess.Write, FileShare.None))
                {
                    node.Value.Serialize(indexStream, VectorStream, PostingsStream);
                }

                SessionFactory.RefreshIndex(CollectionId, node.Key, node.Value);

                File.Copy(tmpFileName, ixFileName, overwrite: true);
                File.Delete(tmpFileName);
            }

            ValueStream.Flush();
            KeyStream.Flush();
            DocStream.Flush();
            ValueIndexStream.Flush();
            KeyIndexStream.Flush();
            DocIndexStream.Flush();
            PostingsStream.Flush();
            VectorStream.Flush();

            base.Dispose();
        }
Beispiel #2
0
        public override void Dispose()
        {
            foreach (var node in _dirty)
            {
                var fn       = Path.Combine(Dir, node.Key + ".ix");
                var fileMode = File.Exists(fn) ? FileMode.Truncate : FileMode.Append;

                using (var stream = new FileStream(fn, fileMode, FileAccess.Write, FileShare.None))
                {
                    node.Value.Serialize(stream, VectorStream, PostingsStream);
                }
            }

            ValueStream.Flush();
            KeyStream.Flush();
            DocStream.Flush();
            ValueIndexStream.Flush();
            KeyIndexStream.Flush();
            DocIndexStream.Flush();
            PostingsStream.Flush();
            VectorStream.Flush();

            base.Dispose();
        }
Beispiel #3
0
        void PerformLayout()
        {
            // 0-----3
            // |     |
            // |     |
            // 1-----2

            float coordTextWidth;
            float coordTextHeight;

            float xtemp = 0;
            float ytemp = 0;

            Glyph unGlyph;

            if (_TextValue.Length > 8192)
                throw new ArgumentOutOfRangeException("_TextValue", _TextValue.Length, "Text length must be between 1 and 8192 characters");

            _TextValue = texFont.TextFilter(_TextValue);

            PositionStream_.CurrentOffset = 0;
            texCoordStream_.CurrentOffset = 0;

            if (_TextValue.Length > defMaxChars)
                PositionStream_.VariableVertices = defMaxChars * 4;
            else
                PositionStream_.VariableVertices = _TextValue.Length * 4;

            vertices = PositionStream_;
            coordTex = texCoordStream_;

            coordTextHeight = (float)texFont.Font.Height / texFont.TextureDim;

            if (texFont.Font.Size >= 32)
                adjust = 20;
            else
                if (texFont.Font.Size >= 10)
                    adjust = 6;
                else
                    adjust = 2;

            int min = Math.Min(defMaxChars, _TextValue.Length);
            for (int cont = 0; cont < min; cont++)
            {
                char c = _TextValue[cont];
                unGlyph = texFont[(int)c];
                coordTextWidth = (float)(texFont.Font.Size + adjust) / texFont.TextureDim;
                //0
                auxCoordTex.X = unGlyph.coordTex.X;
                auxCoordTex.Y = unGlyph.coordTex.Y;
                coordTex += auxCoordTex;
                auxVertice.X = xtemp;
                auxVertice.Y = ytemp;
                vertices += auxVertice;
                //1
                auxCoordTex.X = unGlyph.coordTex.X;
                auxCoordTex.Y = unGlyph.coordTex.Y - coordTextHeight;
                coordTex += auxCoordTex;
                auxVertice.X = xtemp;
                auxVertice.Y = ytemp + texFont.HeightFont;
                vertices += auxVertice;
                //2
                auxCoordTex.X = unGlyph.coordTex.X + coordTextWidth;
                auxCoordTex.Y = unGlyph.coordTex.Y - coordTextHeight;
                coordTex += auxCoordTex;
                auxVertice.X = xtemp + texFont.Font.Size + adjust;
                auxVertice.Y = ytemp + texFont.HeightFont;
                vertices += auxVertice;
                //3
                auxCoordTex.X = unGlyph.coordTex.X + coordTextWidth;
                auxCoordTex.Y = unGlyph.coordTex.Y;
                coordTex += auxCoordTex;
                auxVertice.X = xtemp + texFont.Font.Size + adjust;
                auxVertice.Y = ytemp;
                vertices += auxVertice;

                xtemp = xtemp + unGlyph.width;
            }
        }
Beispiel #4
0
        void PerformLayout()
        {
            // 0-----3
            // |     |
            // |     |
            // 1-----2

            float coordTextWidth;
            float coordTextHeight;

            float xtemp = 0;
            float ytemp = 0;

            Glyph unGlyph;

            if (_TextValue.Length > 8192)
            {
                throw new ArgumentOutOfRangeException("_TextValue", _TextValue.Length, "Text length must be between 1 and 8192 characters");
            }

            _TextValue = texFont.TextFilter(_TextValue);

            PositionStream_.CurrentOffset = 0;
            texCoordStream_.CurrentOffset = 0;

            if (_TextValue.Length > defMaxChars)
            {
                PositionStream_.VariableVertices = defMaxChars * 4;
            }
            else
            {
                PositionStream_.VariableVertices = _TextValue.Length * 4;
            }

            vertices = PositionStream_;
            coordTex = texCoordStream_;

            coordTextHeight = (float)texFont.Font.Height / texFont.TextureDim;

            if (texFont.Font.Size >= 32)
            {
                adjust = 20;
            }
            else
            if (texFont.Font.Size >= 10)
            {
                adjust = 6;
            }
            else
            {
                adjust = 2;
            }

            int min = Math.Min(defMaxChars, _TextValue.Length);

            for (int cont = 0; cont < min; cont++)
            {
                char c = _TextValue[cont];
                unGlyph        = texFont[(int)c];
                coordTextWidth = (float)(texFont.Font.Size + adjust) / texFont.TextureDim;
                //0
                auxCoordTex.X = unGlyph.coordTex.X;
                auxCoordTex.Y = unGlyph.coordTex.Y;
                coordTex     += auxCoordTex;
                auxVertice.X  = xtemp;
                auxVertice.Y  = ytemp;
                vertices     += auxVertice;
                //1
                auxCoordTex.X = unGlyph.coordTex.X;
                auxCoordTex.Y = unGlyph.coordTex.Y - coordTextHeight;
                coordTex     += auxCoordTex;
                auxVertice.X  = xtemp;
                auxVertice.Y  = ytemp + texFont.HeightFont;
                vertices     += auxVertice;
                //2
                auxCoordTex.X = unGlyph.coordTex.X + coordTextWidth;
                auxCoordTex.Y = unGlyph.coordTex.Y - coordTextHeight;
                coordTex     += auxCoordTex;
                auxVertice.X  = xtemp + texFont.Font.Size + adjust;
                auxVertice.Y  = ytemp + texFont.HeightFont;
                vertices     += auxVertice;
                //3
                auxCoordTex.X = unGlyph.coordTex.X + coordTextWidth;
                auxCoordTex.Y = unGlyph.coordTex.Y;
                coordTex     += auxCoordTex;
                auxVertice.X  = xtemp + texFont.Font.Size + adjust;
                auxVertice.Y  = ytemp;
                vertices     += auxVertice;

                xtemp = xtemp + unGlyph.width;
            }
        }