Пример #1
0
        public static List <string> ExtractParamers(string queryStr)
        {
            var  result     = new List <string>();
            bool inTag      = false;
            var  nameBuffer = new FastString();

            foreach (var s in queryStr)
            {
                if (s == '@')
                {
                    inTag = true;
                    nameBuffer.Clear();
                    continue;
                }

                if (inTag)
                {
                    if (s >= 'A' && s <= 'z' || s == '_' || s >= '0' && s <= '9')
                    {
                        nameBuffer.Append(s);
                    }
                    else
                    {
                        if (!nameBuffer.IsEmpty())
                        {
                            result.Add(nameBuffer.ToString());
                            nameBuffer.Clear();
                        }
                        inTag = false;
                    }
                }
            }

            return(result);
        }
Пример #2
0
        public TableQuery Reset()
        {
            whereStr.Clear();
            whereArgs.Clear();

            values.Clear();
            orderBy.Clear();
            groupBy     = string.Empty;
            limit       = 0;
            limitOffset = 0;
            isDistict   = false;
            return(this);
        }
Пример #3
0
        private void LayerShape(FastString Page, ShapeObject obj, FastString text)
        {
            int    styleindex = UpdateCSSTable(obj);
            string style      = GetStyleTag(styleindex);
            string old_text   = String.Empty;

            float      Width, Height;
            string     pic      = GetLayerPicture(obj, out Width, out Height);
            FastString addstyle = new FastString(64);

            if (obj.Shape == ShapeKind.Rectangle || obj.Shape == ShapeKind.RoundRectangle)
            {
                if (obj.FillColor.A != 0)
                {
                    addstyle.Append("background:").Append(System.Drawing.ColorTranslator.ToHtml(obj.FillColor)).Append(";");
                }
                addstyle.Append("border-style:solid;");
                if (obj.Border.Width != 3)
                {
                    addstyle.Append("border-width:").Append(ExportUtils.FloatToString(obj.Border.Width)).Append("px;");
                }
                addstyle.Append("border-color:").Append(System.Drawing.ColorTranslator.ToHtml(obj.Border.Color)).Append(";");
                if (obj.Shape == ShapeKind.RoundRectangle)
                {
                    addstyle.Append("border-radius:15px;");
                }
            }

            float x = obj.Width > 0 ? obj.AbsLeft : (obj.AbsLeft + obj.Width);
            float y = obj.Height > 0 ? hPos + obj.AbsTop : (hPos + obj.AbsTop + obj.Height);

            Layer(Page, obj, x, y, obj.Width, obj.Height, text, style, addstyle);
            addstyle.Clear();
        }
Пример #4
0
    void NewStringFast()
    {
        for (int i = 0; i < Times; i++)
        {
            //m_fs.Replace("123456789", "123456789");
            //m_fs.Replace("1", "1");
            //m_fs.ToString();

            m_fs.Clear();

            m_fs.Append(123).Append(456).Append(789);
            m_fs.Replace("123456789", "123456789");
        }
    }
Пример #5
0
    public void ViewSpellTab(int pawnId)
    {
        for (int j = 0; j < viewPawnImages.Length; j++)
        {
            if (viewPawnImages[j] != null)
            {
                viewPawnImages[j].isVisible = j == pawnId;
            }
        }
        spellPane.OpenTab(pawnId);
        infoPane.OpenTab(0);
        PlayerPawn pawn = battle.allies[pawnId] as PlayerPawn;

        playerName.SetText(pawn.GetName());
        string     affText = "";
        FastString perc    = new FastString(3);

        double affTotal = pawn.GetAffinityTotal();

        for (int i = 0; i < 6; i++)
        {
            perc.Clear();
            double aff = pawn.GetAffinity(i);
            perc.Append((int)(aff / affTotal * 100), 2, FastString.FILL_SPACES);
            affText += "\n" /*+ Element.All[i].GetColorHex()*/ + pawn.GetAffinity(i) + " (" + perc + "%)";
        }
        affinities.SetText(affText);

        foreach (Text text in currentItemTexts)
        {
            RemoveUIObj(text);
        }
        string[] eq       = pawn.GetEquipment();
        int      currentY = size.height - 58;

        for (int i = 0; i < eq.Length; i++)
        {
            Equipment e    = Equipments.Get(eq[i]);
            Text      text = new Text(new Vector2i(5, currentY), new Vector2i(), RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, e.GetName());
            text.FitSizeToText(1);
            text.SetTooltip(e.GetDescription());
            currentY += text.size.height + 2;
            AddUIObj(text);
            currentItemTexts.Add(text);
            bottomPane.AddToTab(1, text);
        }
        UpdateContext();
    }
Пример #6
0
        private void ExportHTMLPageFinalWeb(FastString CSS, FastString Page, HTMLData d, float MaxWidth, float MaxHeight)
        {
            CalcPageSize(pages[d.CurrentPage], MaxWidth, MaxHeight);

            if (Page != null)
            {
                pages[d.CurrentPage].PageText = Page.ToString();
                Page.Clear();
            }
            if (CSS != null)
            {
                pages[d.CurrentPage].CSSText = CSS.ToString();
                CSS.Clear();
            }
            pages[d.CurrentPage].PageEvent.Set();
        }
Пример #7
0
        private void WriteMHTHeader(Stream Stream, string FileName)
        {
            FastString sb = new FastString(256);
            string     s  = "=?utf-8?B?" + System.Convert.ToBase64String(Encoding.UTF8.GetBytes(FileName)) + "?=";

            sb.Append("From: ").AppendLine(s);
            sb.Append("Subject: ").AppendLine(s);
            sb.Append("Date: ").AppendLine(ExportUtils.GetRFCDate(SystemFake.DateTime.Now));
            sb.AppendLine("MIME-Version: 1.0");
            sb.Append("Content-Type: multipart/related; type=\"text/html\"; boundary=\"").Append(boundary).AppendLine("\"");
            sb.AppendLine();
            sb.AppendLine("This is a multi-part message in MIME format.");
            sb.AppendLine();
            ExportUtils.Write(Stream, sb.ToString());
            sb.Clear();
        }
        /// <summary>
        /// Get a string describing all entities at given position
        /// </summary>
        /// <param name="pos">Position</param>
        /// <param name="outStr">Entity string</param>
        public static void GetEntitiesStringAtTile(Vector2i pos, FastString outStr)
        {
            var game = (RetroDungeoneerGame)RB.Game;

            outStr.Clear();

            for (int i = RenderFunctions.renderOrderList.Length - 1; i >= 0; i--)
            {
                var currentRenderOrder = RenderFunctions.renderOrderList[i];
                if (currentRenderOrder == RenderFunctions.RenderOrder.HIDDEN)
                {
                    continue;
                }

                var entityList = GetEntitiesAtPos(pos);
                if (entityList == null)
                {
                    continue;
                }

                for (int j = 0; j < entityList.Count; j++)
                {
                    var e = entityList[j].e;

                    if (e != null && e.renderOrder == currentRenderOrder && game.map.IsInFOV(e.pos))
                    {
                        if (outStr.Length > 0)
                        {
                            outStr.Append('\n');
                        }

                        if (currentRenderOrder == RenderFunctions.RenderOrder.CORPSE)
                        {
                            outStr.Append(C.STR_COLOR_CORPSE).Append(e.name).Append("@-");
                        }
                        else if (currentRenderOrder == RenderFunctions.RenderOrder.ACTOR)
                        {
                            outStr.Append(C.STR_COLOR_NAME).Append(e.name).Append("@-");
                        }
                        else
                        {
                            outStr.Append(e.name);
                        }
                    }
                }
            }
        }
Пример #9
0
        private void ExportHTMLPageStart(FastString Page, int PageNumber, int CurrentPage)
        {
            if (webMode)
            {
                if (!layers)
                {
                    pages[CurrentPage].CSSText = Page.ToString();
                    Page.Clear();
                }
                pages[CurrentPage].PageNumber = PageNumber;
            }

            if (!webMode && !singlePage)
            {
                Page.AppendLine(BODY_BEGIN);
            }
        }
Пример #10
0
 private void DoPage(Stream stream, string documentTitle, FastString CSS, FastString Page)
 {
     if (!singlePage)
     {
         ExportUtils.Write(stream, String.Format(templates.PageTemplateTitle, documentTitle));
     }
     if (CSS != null)
     {
         ExportUtils.Write(stream, CSS.ToString());
         CSS.Clear();
     }
     if (Page != null)
     {
         ExportUtils.Write(stream, Page.ToString());
         Page.Clear();
     }
     if (!singlePage)
     {
         ExportUtils.Write(stream, templates.PageTemplateFooter);
     }
 }
Пример #11
0
        private void WriteMimePart(Stream stream, string mimetype, string charset, string filename)
        {
            FastString sb = new FastString();

            sb.Append("--").AppendLine(boundary);
            sb.Append("Content-Type: ").Append(mimetype).Append(";");
            if (charset != String.Empty)
            {
                sb.Append(" charset=\"").Append(charset).AppendLine("\"");
            }
            else
            {
                sb.AppendLine();
            }
            string body;

            byte[] buff = new byte[stream.Length];
            stream.Position = 0;
            stream.Read(buff, 0, buff.Length);
            if (mimetype == "text/html")
            {
                sb.AppendLine("Content-Transfer-Encoding: quoted-printable");
                body = ExportUtils.QuotedPrintable(buff);
            }
            else
            {
                sb.AppendLine("Content-Transfer-Encoding: base64");
                body = System.Convert.ToBase64String(buff, Base64FormattingOptions.InsertLineBreaks);
            }
            sb.Append("Content-Location: ").AppendLine(ExportUtils.HtmlURL(filename));
            sb.AppendLine();
            sb.AppendLine(body);
            sb.AppendLine();
            Stream.Write(Encoding.ASCII.GetBytes(sb.ToString()), 0, sb.Length);
            sb.Clear();
        }
Пример #12
0
        /// <summary>
        /// Highlight code in given string
        /// </summary>
        /// <param name="inStr">Input string</param>
        /// <param name="outStr">Output string</param>
        /// <param name="highlightSymbols">Highlight symbols</param>
        /// <returns>Highlighted code</returns>
        public static FastString HighlightCode(FastString inStr, FastString outStr, bool highlightSymbols = true)
        {
            var game = (DemoReel)RB.Game;

            var buf = inStr.Buf;

            outStr.Clear();

            int lastColor = -1;

            for (int i = 0; i < inStr.Length; i++)
            {
                if (buf[i] == '@')
                {
                    i++;
                    switch (buf[i])
                    {
                    case 'I':     // Indexed color
                        int colorIndex = ((int)(buf[i + 1] - '0') * 10) + (int)(buf[i + 2] - '0');

                        Color32 rgb = IndexToRGB(colorIndex);
                        IndexToColorString(21, outStr).Append("new");
                        IndexToColorString(22, outStr).Append(" Color32");
                        IndexToColorString(3, outStr).Append("(");
                        IndexToColorString(24, outStr).Append(rgb.r);
                        IndexToColorString(5, outStr).Append(", ");
                        IndexToColorString(24, outStr).Append(rgb.g);
                        IndexToColorString(5, outStr).Append(", ");
                        IndexToColorString(24, outStr).Append(rgb.b);
                        IndexToColorString(5, outStr).Append(", ");
                        IndexToColorString(24, outStr).Append(255);
                        IndexToColorString(3, outStr).Append(")");

                        i += 2;

                        break;

                    case 'K':     // Keyword
                        IndexToColorString(21, outStr);
                        lastColor = 21;
                        break;

                    case 'M':     // Class or Method
                        IndexToColorString(22, outStr);
                        lastColor = 22;
                        break;

                    case 'L':     // Literal
                        IndexToColorString(24, outStr);
                        lastColor = 24;
                        break;

                    case 'C':     // Comment
                        IndexToColorString(25, outStr);
                        lastColor = 25;
                        break;

                    case 'S':     // String literal
                        IndexToColorString(15, outStr);
                        lastColor = 15;
                        break;

                    case 's':     // String escape code
                        IndexToColorString(14, outStr);
                        lastColor = 14;
                        break;

                    case 'E':
                        IndexToColorString(23, outStr);
                        lastColor = 23;
                        break;

                    case 'N':     // Normal/Other
                        IndexToColorString(5, outStr);
                        lastColor = 5;
                        break;

                    case 'D':     // Dark
                        IndexToColorString(3, outStr);
                        lastColor = 3;
                        break;

                    case '@':
                        outStr.Append("@@");
                        break;

                    default:
                        IndexToColorString(5, outStr);
                        lastColor = 5;
                        break;
                    }
                }
                else
                {
                    var c = buf[i];

                    var symbolFound = false;

                    // Don't check for symbol color if in comment, or in string literal
                    if (highlightSymbols && lastColor != 25 && lastColor != 15)
                    {
                        for (int j = 0; j < mSymbols.Length; j++)
                        {
                            if (c == mSymbols[j])
                            {
                                symbolFound = true;
                                break;
                            }
                        }
                    }

                    if (symbolFound)
                    {
                        IndexToColorString(3, outStr);
                        outStr.Append(c);
                        IndexToColorString(5, outStr);
                    }
                    else
                    {
                        outStr.Append(buf[i]);
                    }
                }
            }

            return(outStr);
        }
Пример #13
0
 private string FastString()
 {
     m_strCustom.Clear();
     m_strCustom.Append("PI=").Append(Mathf.PI).Append("_373=").Append(373).Replace("373", "5428");
     return(m_strCustom.ToString());
 }
Пример #14
0
        public static JSONNode Parse(string aJSON)
        {
            Stack <JSONNode> stack = new Stack <JSONNode>();
            JSONNode         ctx = null;
            int i = 0, len = aJSON.Length;
            //string Token = "";
            string TokenName = "";
            bool   QuoteMode = false;

            FastString Token = new FastString(128);

            while (i < len)
            {
                switch (aJSON[i])
                {
                case '{':
                    if (QuoteMode)
                    {
                        Token.Append(aJSON [i]);
                        break;
                    }
                    stack.Push(new JSONClass());
                    if (ctx != null)
                    {
                        TokenName = TokenName.Trim();
                        if (ctx is JSONArray)
                        {
                            ctx.Add(stack.Peek());
                        }
                        else if (TokenName != "")
                        {
                            ctx.Add(TokenName, stack.Peek());
                        }
                    }
                    TokenName = "";
                    Token.Clear();
                    ctx = stack.Peek();
                    break;

                case '[':
                    if (QuoteMode)
                    {
                        Token.Append(aJSON[i]);
                        break;
                    }

                    stack.Push(new JSONArray());
                    if (ctx != null)
                    {
                        TokenName = TokenName.Trim();
                        if (ctx is JSONArray)
                        {
                            ctx.Add(stack.Peek());
                        }
                        else if (TokenName != "")
                        {
                            ctx.Add(TokenName, stack.Peek());
                        }
                    }
                    TokenName = "";
                    Token.Clear();
                    ctx = stack.Peek();
                    break;

                case '}':
                case ']':
                    if (QuoteMode)
                    {
                        Token.Append(aJSON[i]);
                        break;
                    }
                    if (stack.Count == 0)
                    {
                        throw new Exception("JSON Parse: Too many closing brackets");
                    }

                    stack.Pop();
                    if (!Token.IsEmpty())
                    {
                        TokenName = TokenName.Trim();
                        if (ctx is JSONArray)
                        {
                            ctx.Add(Token.ToString());
                        }
                        else if (TokenName != "")
                        {
                            ctx.Add(TokenName, Token.ToString());
                        }
                    }
                    TokenName = "";
                    Token.Clear();
                    if (stack.Count > 0)
                    {
                        ctx = stack.Peek();
                    }
                    break;

                case ':':
                    if (QuoteMode)
                    {
                        Token.Append(aJSON[i]);
                        break;
                    }
                    TokenName = Token.ToString();
                    Token.Clear();
                    break;

                case '"':
                    QuoteMode ^= true;
                    break;

                case ',':
                    if (QuoteMode)
                    {
                        Token.Append(aJSON[i]);
                        break;
                    }

                    if (!Token.IsEmpty())
                    {
                        if (ctx is JSONArray)
                        {
                            ctx.Add(Token.ToString());
                        }
                        else if (TokenName != "")
                        {
                            ctx.Add(TokenName, Token.ToString());
                        }
                    }
                    TokenName = "";
                    Token.Clear();
                    break;

                case '\r':
                case '\n':
                    break;

                case ' ':
                case '\t':
                    if (QuoteMode)
                    {
                        Token.Append(aJSON[i]);
                    }
                    break;

                case '\\':
                    ++i;
                    if (QuoteMode)
                    {
                        char C = aJSON[i];
                        switch (C)
                        {
                        case 't': Token.Append('\t'); break;

                        case 'r': Token.Append('\r'); break;

                        case 'n': Token.Append('\n'); break;

                        case 'b': Token.Append('\b'); break;

                        case 'f': Token.Append('\f'); break;

                        case 'u':
                        {
                            string s = aJSON.Substring(i + 1, 4);
                            Token.Append((char)int.Parse(s, System.Globalization.NumberStyles.AllowHexSpecifier));
                            i += 4;
                            break;
                        }

                        default: Token.Append(C); break;
                        }
                    }
                    break;

                default:
                    Token.Append(aJSON[i]);
                    break;
                }
                ++i;
            }
            if (QuoteMode)
            {
                throw new Exception("JSON Parse: Quotation marks seems to be messed up.");
            }
            return(ctx);
        }
Пример #15
0
        private void ExportHTMLPageFinal(FastString CSS, FastString Page, HTMLThreadData d, float MaxWidth, float MaxHeight)
        {
            if (!webMode)
            {
                if (!singlePage)
                {
                    Page.AppendLine(BODY_END);
                }
                if (d.PagesStream == null)
                {
                    if (saveStreams)
                    {
                        string FPageFileName;
                        if (singlePage)
                        {
                            FPageFileName = singlePageFileName;
                        }
                        else
                        {
                            FPageFileName = targetIndexPath + targetFileName + d.PageNumber.ToString() + ".html";
                        }
                        int    i = GeneratedFiles.IndexOf(FPageFileName);
                        Stream OutStream;
                        if (i == -1)
                        {
                            OutStream = new MemoryStream();
                        }
                        else
                        {
                            OutStream = generatedStreams[i];
                        }
                        if (!singlePage)
                        {
                            ExportUtils.Write(OutStream, String.Format(templates.PageTemplateTitle, documentTitle));
                        }
                        if (CSS != null)
                        {
                            ExportUtils.Write(OutStream, CSS.ToString());
                            CSS.Clear();
                        }
                        if (Page != null)
                        {
                            ExportUtils.Write(OutStream, Page.ToString());
                            Page.Clear();
                        }
                        if (!singlePage)
                        {
                            ExportUtils.Write(OutStream, templates.PageTemplateFooter);
                        }
                        GeneratedUpdate(FPageFileName, OutStream);
                    }
                    else
                    {
                        string FPageFileName = targetIndexPath + targetFileName + d.PageNumber.ToString() + ".html";
                        GeneratedFiles.Add(FPageFileName);
                        using (FileStream OutStream = new FileStream(FPageFileName, FileMode.Create))
                            using (StreamWriter Out = new StreamWriter(OutStream))
                            {
                                if (!singlePage)
                                {
                                    Out.Write(String.Format(templates.PageTemplateTitle, documentTitle));
                                }
                                if (CSS != null)
                                {
                                    Out.Write(CSS.ToString());
                                    CSS.Clear();
                                }
                                if (Page != null)
                                {
                                    Out.Write(Page.ToString());
                                    Page.Clear();
                                }
                                if (!singlePage)
                                {
                                    Out.Write(templates.PageTemplateFooter);
                                }
                            }
                    }
                }
                else
                {
                    if (!singlePage)
                    {
                        ExportUtils.Write(d.PagesStream, String.Format(templates.PageTemplateTitle, documentTitle));
                    }
                    if (CSS != null)
                    {
                        ExportUtils.Write(d.PagesStream, CSS.ToString());
                        CSS.Clear();
                    }
                    if (Page != null)
                    {
                        ExportUtils.Write(d.PagesStream, Page.ToString());
                        Page.Clear();
                    }
                    if (!singlePage)
                    {
                        ExportUtils.Write(d.PagesStream, templates.PageTemplateFooter);
                    }
                }
            }
            else
            {
                if (!layers)
                {
                    pages[d.CurrentPage].Width  = MaxWidth / Zoom;
                    pages[d.CurrentPage].Height = MaxHeight / Zoom;
                }
                else
                {
                    pages[d.CurrentPage].Width  = MaxWidth;
                    pages[d.CurrentPage].Height = MaxHeight;
                }

                if (Page != null)
                {
                    pages[d.CurrentPage].PageText = Page.ToString();
                    Page.Clear();
                }
                if (CSS != null)
                {
                    pages[d.CurrentPage].CSSText = CSS.ToString();
                    CSS.Clear();
                }
                pages[d.CurrentPage].PageEvent.Set();
            }
        }
Пример #16
0
        /// <summary>
        /// Highlight code in given string
        /// </summary>
        /// <param name="inStr">Input string</param>
        /// <param name="outStr">Output string</param>
        /// <returns>Highlighted code</returns>
        public static FastString HighlightCode(FastString inStr, FastString outStr)
        {
            DemoReel game = (DemoReel)RB.Game;

            var buf = inStr.Buf;

            outStr.Clear();

            for (int i = 0; i < inStr.Length; i++)
            {
                if (buf[i] == '@')
                {
                    i++;
                    switch (buf[i])
                    {
                    case 'I':     // Indexed color
                        int colorIndex = ((int)(buf[i + 1] - '0') * 10) + (int)(buf[i + 2] - '0');

                        Color32 rgb = IndexToRGB(colorIndex);
                        IndexToColorString(21, outStr).Append("new");
                        IndexToColorString(22, outStr).Append(" Color32");
                        IndexToColorString(5, outStr).Append("(");
                        IndexToColorString(24, outStr).Append(rgb.r);
                        IndexToColorString(5, outStr).Append(", ");
                        IndexToColorString(24, outStr).Append(rgb.g);
                        IndexToColorString(5, outStr).Append(", ");
                        IndexToColorString(24, outStr).Append(rgb.b);
                        IndexToColorString(5, outStr).Append(", ");
                        IndexToColorString(24, outStr).Append(255);
                        IndexToColorString(5, outStr).Append(")");

                        i += 2;

                        break;

                    case 'K':     // Keyword
                        IndexToColorString(21, outStr);
                        break;

                    case 'M':     // Class or Method
                        IndexToColorString(22, outStr);
                        break;

                    case 'L':     // Literal
                        IndexToColorString(24, outStr);
                        break;

                    case 'C':     // Comment
                        IndexToColorString(25, outStr);
                        break;

                    case 'S':     // String literal
                        IndexToColorString(15, outStr);
                        break;

                    case 's':     // String escape code
                        IndexToColorString(14, outStr);
                        break;

                    case 'E':
                        IndexToColorString(23, outStr);
                        break;

                    case 'N':     // Normal/Other
                        IndexToColorString(5, outStr);
                        break;

                    case 'D':     // Dark
                        IndexToColorString(3, outStr);
                        break;

                    case '@':
                        outStr.Append("@@");
                        break;

                    default:
                        IndexToColorString(5, outStr);
                        break;
                    }
                }
                else
                {
                    outStr.Append(buf[i]);
                }
            }

            return(outStr);
        }