コード例 #1
0
        private Size DrawEventList(ListBox lb, int index, Graphics g, Rectangle listbounds, bool isWithDraw)
        {
            if (index < 0 || index >= this.ErrorList.Count || this.MapID == U.NOT_FOUND)
            {
                return(new Size(listbounds.X, listbounds.Y));
            }

            FELint.ErrorSt est = this.ErrorList[index];

            SolidBrush brush      = new SolidBrush(lb.ForeColor);
            SolidBrush errorBrush = new SolidBrush(OptionForm.Color_Error_ForeColor());

            Font normalFont = lb.Font;
            Font boldFont   = new Font(lb.Font, FontStyle.Bold);

            Rectangle bounds = listbounds;

            int lineHeight = (int)lb.Font.Height;
            int maxWidth   = 0;

            string text = TypeToString(est.DataType, est.Addr, est.Tag);

            U.DrawText(text, g, boldFont, errorBrush, isWithDraw, bounds);
            if (Program.LintCache.CheckFast(est.Addr))
            {
                string comment = "//" + R._("このエラーは非表示になっています。理由:「{0}」", Program.LintCache.At(est.Addr));

                bounds.X = listbounds.X + (lineHeight * 25);

                SolidBrush commentBrush = new SolidBrush(OptionForm.Color_Comment_ForeColor());
                bounds.X += U.DrawText(comment, g, normalFont, commentBrush, isWithDraw, bounds);
                commentBrush.Dispose();

                maxWidth = Math.Max(maxWidth, bounds.X);
            }
            bounds.Y += lineHeight;

            text     = est.ErrorMessage;
            bounds.X = listbounds.X;
            Size size = U.DrawTextMulti(text, g, normalFont, brush, isWithDraw, bounds);

            bounds.X += size.Width;

            maxWidth = Math.Max(maxWidth, bounds.X);

            brush.Dispose();
            boldFont.Dispose();

            bounds.X  = maxWidth;
            bounds.Y += size.Height + lineHeight;
            return(new Size(bounds.X, bounds.Y));
        }
コード例 #2
0
        public static Size DrawASM(ListBox lb, int index, Graphics g, Rectangle listbounds, bool isWithDraw)
        {
            if (index < 0 || index >= lb.Items.Count)
            {
                return(new Size(listbounds.X, listbounds.Y));
            }
            string text       = lb.Items[index].ToString();
            int    commentPos = text.IndexOf("//");

            if (commentPos < 0)
            {
                commentPos = text.IndexOf("# pointer:");
            }

            string mainText;
            string commentText;

            if (commentPos < 0)
            {
                mainText    = text;
                commentText = "";
            }
            else
            {
                mainText    = text.Substring(0, commentPos);
                commentText = text.Substring(commentPos);
            }

            SolidBrush brush      = new SolidBrush(lb.ForeColor);
            Font       normalFont = lb.Font;
            Rectangle  bounds     = listbounds;

            int lineHeight = (int)lb.Font.Height;

            bounds.X += U.DrawText(mainText, g, normalFont, brush, isWithDraw, bounds);
            brush.Dispose();

            //コメントの表示
            if (commentPos >= 0)
            {
                SolidBrush commentBrush = new SolidBrush(OptionForm.Color_Comment_ForeColor());
                bounds.X += U.DrawText(commentText, g, normalFont, commentBrush, isWithDraw, bounds);
                commentBrush.Dispose();
            }



            bounds.Y += lineHeight;
            return(new Size(bounds.X, bounds.Y));
        }
コード例 #3
0
        public static Size DrawTextCategory(ListBox lb, int index, Graphics g, Rectangle listbounds, bool isWithDraw)
        {
            if (index < 0 || index >= lb.Items.Count)
            {
                return(new Size(listbounds.X, listbounds.Y));
            }
            string text = lb.Items[index].ToString();

            SolidBrush brush      = new SolidBrush(lb.ForeColor);
            Font       normalFont = lb.Font;
            Rectangle  bounds     = listbounds;

            int lineHeight = (int)lb.Font.Height;

            string[] sp = text.Split(new string[] { "[", "//" }, StringSplitOptions.None);
            bounds.X += U.DrawText(sp[0], g, normalFont, brush, isWithDraw, bounds);
            for (int i = 1; i < sp.Length - 1; i++)
            {
                bounds.X += U.DrawText("[", g, normalFont, brush, isWithDraw, bounds);
                bounds.X += U.DrawText(sp[i], g, normalFont, brush, isWithDraw, bounds);
            }

            //コードをコメント形式で描画
            if (sp.Length > 0)
            {
                int        i            = sp.Length - 1;
                SolidBrush commentBrush = new SolidBrush(OptionForm.Color_Comment_ForeColor());
                if (bounds.X < 500)
                {
                    bounds.X = 500;
                }
                bounds.X += U.DrawText("//" + sp[i], g, normalFont, commentBrush, isWithDraw, bounds);
                commentBrush.Dispose();
            }
            brush.Dispose();
            bounds.Y += lineHeight;
            return(new Size(bounds.X, bounds.Y));
        }
コード例 #4
0
ファイル: ListBoxEx.cs プロジェクト: MrMeow76/FEBuilderGBA
        public static Size DrawEventCategory(ListBox lb, int index, Graphics g, Rectangle listbounds, bool isWithDraw)
        {
            if (index < 0 || index >= lb.Items.Count)
            {
                return(new Size(listbounds.X, listbounds.Y));
            }
            string text = lb.Items[index].ToString();

            SolidBrush brush      = new SolidBrush(lb.ForeColor);
            Font       normalFont = lb.Font;
            Rectangle  bounds     = listbounds;

            int lineHeight = (int)lb.Font.Height;

            string[] sp = text.Split(new string[] { "[", "//" }, StringSplitOptions.None);
            bounds.X += U.DrawText(sp[0], g, normalFont, brush, isWithDraw, bounds);
            for (int i = 1; i < sp.Length - 1; i++)
            {
                bounds.X += U.DrawText("[", g, normalFont, brush, isWithDraw, bounds);

                string nn = sp[i];
                int    p  = nn.IndexOf(':');
                if (p < 0)
                {
                    bounds.X += U.DrawText(nn, g, normalFont, brush, isWithDraw, bounds);
                    continue;
                }

                string item = nn.Substring(0, p);

                Bitmap bitmap = null;
                if (item == "UNIT")
                {
                    bitmap = UnitForm.DrawUnitMapFacePicture(1);
                }
                else if (item == "CLASS")
                {
                    bitmap = ClassForm.DrawWaitIcon(3);
                }
                else if (item == "POINTER_PROCS")
                {
                    bitmap = ImageSystemIconForm.WeaponIcon(4);
                }
                else if (item == "POINTER_ASM")
                {
                    bitmap = ImageSystemIconForm.WeaponIcon(8);
                }
                else if (item == "POINTER_UNIT")
                {
                    bitmap = ClassForm.DrawWaitIcon(7);
                }
                else if (item == "POINTER_EVENT")
                {//サブルーチンは目立つ緑のアイコン
                    bitmap = ImageSystemIconForm.MusicIcon(3);
                }
                else if (item == "MUSIC")
                {
                    bitmap = ImageSystemIconForm.MusicIcon(6);
                }
                else if (item == "SOUND")
                {
                    bitmap = ImageSystemIconForm.MusicIcon(7);
                }
                else if (item == "ITEM")
                {//アイテムアイコン
                    bitmap = ImageSystemIconForm.WeaponIcon(8);
                }
                else if (item == "FLAG")
                {
                    bitmap = ImageSystemIconForm.FlagIcon();
                }
                else if (item == "WMLOCATION")
                {//拠点
                    bitmap = WorldMapImageForm.DrawWorldMapIcon(0xB);
                }
                else if (item == "WMPATH")
                {//道
                    bitmap = WorldMapImageForm.DrawWorldMapIcon(0xB);
                }
                if (bitmap != null)
                {
                    U.MakeTransparent(bitmap);

                    Rectangle b = bounds;
                    b.Width  = lineHeight;
                    b.Height = lineHeight;

                    bounds.X += U.DrawPicture(bitmap, g, isWithDraw, b);
                    bitmap.Dispose();

                    bounds.X += U.DrawText(nn.Substring(p), g, normalFont, brush, isWithDraw, bounds);
                }
                else
                {
                    bounds.X += U.DrawText(nn.Substring(p + 1), g, normalFont, brush, isWithDraw, bounds);
                }
            }

            //コードをコメント形式で描画
            if (sp.Length > 0)
            {
                int        i            = sp.Length - 1;
                SolidBrush commentBrush = new SolidBrush(OptionForm.Color_Comment_ForeColor());
                if (bounds.X < 700)
                {
                    bounds.X = 700;
                }
                bounds.X += U.DrawText("//" + sp[i], g, normalFont, commentBrush, isWithDraw, bounds);
                commentBrush.Dispose();
            }
            brush.Dispose();
            bounds.Y += lineHeight;
            return(new Size(bounds.X, bounds.Y));
        }
コード例 #5
0
        public void SimpleKeywordHighLight(RichTextBoxEx target)
        {
            target.LockWindowUpdate();
            Color keywordBackColor = OptionForm.Color_Keyword_BackColor();
            Color keywordForeColor = OptionForm.Color_Keyword_ForeColor();

            Color commentBackColor = OptionForm.Color_Input_BackColor();
            Color commentForeColor = OptionForm.Color_Comment_ForeColor();

            string[] keywords = new string[] { "LSL", "LSR", "ASR", "ADD", "SUB", "MOV", "CMP", "AND", "EOR", "ADC", "SBC", "ROR", "TST", "NEG", "CMP", "CMN", "ORR", "BIC", "MVN", "BX", "LDR", "LDRH", "LDRB", "STR", "STRH", "STRB", "LDSB", "LDSH", "PUSH", "POP", "STMIA", "LDMIA", "BEQ", "BNE", "BCS", "BCC", "BMI", "BPL", "BVS", "BVC", "BHI", "BLS", "BGE", "BLT", "BGT", "BLE", "SWI", "B", "BL", ".THUMB", ".ORG", ".EQU", ".LTORG" };

            //ハイライトを解除.
            target.SelectionStart     = 0;
            target.SelectionLength    = target.TextLength;
            target.SelectionColor     = OptionForm.Color_Input_ForeColor();
            target.SelectionBackColor = OptionForm.Color_Input_BackColor();
            //改行コードが違うので、必ず取得しなおす
            string text   = target.Text;
            int    length = text.Length;

            for (int i = 0; i < length;)
            {
                if (U.Wordrap(text[i]))
                {
                    i++;
                    continue;
                }

                int start = i;
                for (i = i + 1; i < length; i++)
                {
                    if (U.Wordrap(text[i]))
                    {
                        break;
                    }
                }

                string token = text.Substring(start, i - start);
                if (token.IndexOf('@') == 0)
                {//コメント
                    int term = text.IndexOf("\n", i);
                    if (term > 0)
                    {
                        i = term;
                    }

                    target.SelectionStart     = start;
                    target.SelectionLength    = i - start;
                    target.SelectionColor     = commentForeColor;
                    target.SelectionBackColor = commentBackColor;
                    continue;
                }

                token = token.ToUpper();
                foreach (string k in keywords)
                {
                    if (token == k)
                    {//キーワード
                        target.SelectionStart     = start;
                        target.SelectionLength    = i - start;
                        target.SelectionColor     = keywordForeColor;
                        target.SelectionBackColor = keywordBackColor;
                        break;
                    }
                }
            }

            target.UnLockWindowUpdate();
        }