본문 바로가기

프로그래밍/C#

C# 이전에 그린 Chart Panel에 XValue YValue 표시하기

반응형

public void DrawAxes(System.Windows.Forms.TabPage tab,System.Windows.Forms.Panel panel, int Yquantity, int Xquantity, string[,] measuredata)
        {
            int width = panel.Width;
            int height = panel.Height;
            int locationx = panel.Location.X;
            int locationy = panel.Location.Y;

            m_BaseRGBbmp = new Bitmap(tab.Width, tab.Height);
            Graphics grp = Graphics.FromImage(m_BaseRGBbmp);

            for (int i = 1; i < Yquantity; i++)
            {
                grp.DrawString(measuredata[i, 0], new Font("Verdana", 10), Brushes.Black, new RectangleF(locationx -30, locationy - 8 + 1.0f * (i - 1) * height/(Yquantity-2), 400, 25));
            }

            for (int i = 1; i < Xquantity + 1; i++)
            {
                if ((i-1) % 10 == 0)
                {
                    grp.DrawString(measuredata[0, i], new Font("Verdana", 9), Brushes.Black, new RectangleF(locationx - 10 + 1.0f * (i - 1) * width / (Xquantity - 2), locationy + height+10, 400, 25));
                }
               
            }

            tab.BackgroundImage = (Image)m_BaseRGBbmp;
        }

반응형