www.pudn.com > BackscatterMap.rar > Form1.cs, change:2009-07-08,size:7434b


using System; 
using System.Drawing; 
using System.Drawing.Drawing2D; 
using System.Collections; 
using System.Collections.Generic; 
using System.Windows.Forms; 
using System.Text; 
using System.Data.SqlTypes; 
using System.IO; 
 
 
namespace WindowsApplication4 
{ 
    public partial class Form1 : Form 
    { 
        static public int rowNum; 
        static public int colNum; 
        static public double theta; 
        bool[,] sign; 
        double[,] backscatter; 
        double unit; 
        shadowing myshadowing = new shadowing(); 
        calBackscatter mycb = new calBackscatter(); 
         
 
        public Form1() 
        { 
            InitializeComponent(); 
            rowNum = shadowing.rowNum; 
            colNum = shadowing.colNum; 
            theta = shadowing.theta; 
            sign = myshadowing.shadow(); 
            unit = (double)150 / rowNum; 
            backscatter = mycb.calScatter(); 
             
        } 
 
        public void button1_Click(object sender, System.EventArgs e) 
        { 
             
            Graphics gra = this.pictureBox1.CreateGraphics(); 
            Pen myPen = new Pen(Color.Black); 
            gra.DrawEllipse(myPen, 50, 50, 300, 300); 
            gra.DrawLine(myPen, 50, 200, 350, 200); 
            gra.DrawLine(myPen, 200, 50, 200, 350); 
 
 
            //for (int i = 0; i < rowNum; i++) 
            //{ 
            //    for (int j = 0; j < colNum; j++) 
            //    { 
            //        backscatter[i,j] 
            //    } 
            //} 
                #region cycle1 
                for (int i = 0; i < rowNum; i++) 
                { 
                    if (sign[i, 0] == false) 
                    { 
                        GraphicsPath myGP = new GraphicsPath(); 
                        PointF point0 = new PointF(200f, 200f); 
                        PointF point1 = new PointF((float)(200 + unit * Math.Cos(i * theta)), (float)(200 - unit * Math.Sin(i * theta))); 
                        PointF point2 = new PointF((float)(200 + unit * Math.Cos((i + 1) * theta)), (float)(200 - unit * Math.Sin((i + 1) * theta))); 
                        myGP.AddLine(point0, point1); 
                        myGP.AddLine(point0, point2); 
                        RectangleF myRcf = new RectangleF((float)(200 - unit), (float)(200 - unit), (float)(unit * 2), (float)(unit * 2)); 
                        myGP.AddArc(myRcf, (float)(360 - (i + 1) * theta * 180 / Math.PI), (float)(theta * 180 / Math.PI)); 
                        Color myColor1 = Color.FromArgb(0, 0, 0); 
                        Color myColor2 = Color.FromArgb(50, 50, 50); 
                        Color myColor3 = Color.FromArgb(90, 90, 90); 
                        Color myColor4 = Color.FromArgb(130, 130, 130); 
                        Color myColor5 = Color.FromArgb(188, 188, 188); 
                        Brush mySb1 = new SolidBrush(myColor1); 
                        Brush mySb2 = new SolidBrush(myColor2); 
                        Brush mySb3 = new SolidBrush(myColor3); 
                        Brush mySb4 = new SolidBrush(myColor4); 
                        Brush mySb5 = new SolidBrush(myColor5); 
                        Brush mySb6 = new SolidBrush(Color.White); 
                        if (backscatter[i, 0] > -10) 
                            gra.FillPath(mySb1, myGP); 
                        else if (backscatter[i, 0] > -20 && backscatter[i, 0] <= -10) 
                            gra.FillPath(mySb2, myGP); 
                        else if (backscatter[i, 0] > -30 && backscatter[i, 0] <= -20) 
                            gra.FillPath(mySb3, myGP); 
                        else if (backscatter[i, 0] > -40 && backscatter[i, 0] <= -30) 
                            gra.FillPath(mySb4, myGP); 
                        else if (backscatter[i, 0] > -50 && backscatter[i, 0] <= -40) 
                            gra.FillPath(mySb5, myGP); 
                        else 
                            gra.FillPath(mySb6, myGP); 
                    } 
                } 
            #endregion 
 
            #region cycle2 
 
            for (int i = 0; i < rowNum; i++) 
            { 
                for (int j = 1; j < colNum; j++) 
                { 
                    if (sign[i, j] == false) 
                    { 
 
                        GraphicsPath myGP = new GraphicsPath(); 
                        Brush mySb = new SolidBrush(Color.Black); 
                        PointF point1 = new PointF((float)(200 + unit * j * Math.Cos(i * theta)), (float)(200 - unit * j * Math.Sin(i * theta))); 
                        PointF point2 = new PointF((float)(200 + unit * (j + 1) * Math.Cos(i * theta)), (float)(200 - unit * (j + 1) * Math.Sin(i * theta))); 
                        PointF point3 = new PointF((float)(200 + unit * j * Math.Cos((i + 1) * theta)), (float)(200 - unit * j * Math.Sin((i + 1) * theta))); 
                        PointF point4 = new PointF((float)(200 + unit * (j + 1) * Math.Cos((i + 1) * theta)), (float)(200 - unit * (j + 1) * Math.Sin((i + 1) * theta))); 
                        myGP.AddLine(point1, point2); 
                        myGP.AddLine(point3, point4); 
                        RectangleF myRcf1 = new RectangleF((float)(200 - unit * j), (float)(200 - unit * j), (float)(unit * 2 * j), (float)(unit * 2 * j)); 
                        RectangleF myRcf2 = new RectangleF((float)(200 - unit * (j + 1)), (float)(200 - unit * (j + 1)), (float)(2 * unit * (j + 1)), (float)(2 * unit * (j + 1))); 
                        myGP.AddArc(myRcf1, (float)(360 - (i + 1) * theta * 180 / Math.PI), (float)(theta * 180 / Math.PI)); 
                        myGP.AddArc(myRcf2, (float)(360 - (i + 1) * theta * 180 / Math.PI), (float)(theta * 180 / Math.PI)); 
 
                        Color myColor1 = Color.FromArgb(0,0,0); 
                        Color myColor2 = Color.FromArgb(50, 50, 50); 
                        Color myColor3 = Color.FromArgb(90, 90, 90); 
                        Color myColor4 = Color.FromArgb(130, 130, 130); 
                        Color myColor5 = Color.FromArgb(188, 188, 188); 
                        Brush mySb1 = new SolidBrush(myColor1); 
                        Brush mySb2 = new SolidBrush(myColor2); 
                        Brush mySb3 = new SolidBrush(myColor3); 
                        Brush mySb4 = new SolidBrush(myColor4); 
                        Brush mySb5 = new SolidBrush(myColor5); 
                        Brush mySb6 = new SolidBrush(Color.White); 
                        if (backscatter[i, j] > -10) 
                            gra.FillPath(mySb1, myGP); 
                        else if (backscatter[i, j] > -20 && backscatter[i, j] <= -10) 
                            gra.FillPath(mySb2, myGP); 
                        else if (backscatter[i, j] > -30 && backscatter[i, j] <= -20) 
                            gra.FillPath(mySb3, myGP); 
                        else if (backscatter[i,j] > -40 && backscatter[i, j] <= -30) 
                            gra.FillPath(mySb4, myGP); 
                        else if (backscatter[i, j] > -50 && backscatter[i, j] <= -40) 
                            gra.FillPath(mySb5, myGP); 
                        else 
                            gra.FillPath(mySb6, myGP); 
                    } 
                } 
            } 
            #endregion 
            gra.Dispose();  
        } 
 
    } 
}