示例#1
0
文件: Form1.cs 项目: Say-Y/editor
        private void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
            Graphics graphics = e.Graphics;
            Font     drawFont = new Font("monaco", 12);

            string drawString = "";

            sentences = ThisFile.GetText();
            int L = 0, C = 0;
            int count = 0;

            startline = (Line > 31) ? Line - 31 : 0;
            for (int i = startline; i < startline + (((sentences.Count - startline) < 33)? (sentences.Count - startline):33); i++)
            {
                bool searchpoint   = false;
                bool isInstruction = false;
                for (int j = 0; j < sentences[i].Length; j++)
                {
                    drawString = sentences[i][j].ToString();
                    PointF drawPoint = new PointF(C * 10, L * 20);
                    if (j == 11)
                    {
                        isInstruction = true;
                    }
                    if (sentences[i][j] == ' ')
                    {
                        isInstruction = searchpoint = false;
                    }
                    if (count == searchLength)
                    {
                        searchpoint = false;
                    }
                    SolidBrush drawBrush;

                    if (isUCO && j < 10)
                    {
                        drawBrush = new SolidBrush(Color.FromArgb(221, 215, 95));
                    }
                    else if (isUCO && isInstruction)
                    {
                        drawBrush = new SolidBrush(Color.FromArgb(175, 255, 85));
                    }
                    else
                    {
                        drawBrush = new SolidBrush(Color.FromArgb(240, 240, 240));
                    }

                    if (isSearchMode)
                    {
                        LC temp = new LC(L, C);

                        if (StartingPoint.Any(x => x.L == temp.L && x.C == temp.C))
                        {
                            count       = 0;
                            searchpoint = true;
                        }
                        if (searchpoint)
                        {
                            count++;
                            Point      point     = new Point((int)drawPoint.X + 2, (int)drawPoint.Y + 1);
                            Size       sz        = new Size(10, 18);
                            Pen        drawPen   = new Pen(Color.FromArgb(215, 95, 0));
                            SolidBrush sb        = new SolidBrush(Color.FromArgb(215, 95, 0));
                            Rectangle  rectangle = new Rectangle(point, sz);
                            graphics.DrawRectangle(drawPen, rectangle);
                            graphics.FillRectangle(sb, rectangle);
                        }
                    }

                    C++;

                    graphics.DrawString(drawString, drawFont, drawBrush, drawPoint);
                }
                L++;
                C = 0;
                //drawString += (sentences[i] + "\n");
            }
            cursorShow(e.Graphics);
        }