예제 #1
0
        public void addGrid(int rCnt, int cCnt, object[,] data, DataGridView dataGridView2, ComboBox combo_st, ComboBox combo_end, TextBox textBox_folder, ProgressBar progressBar1)
        {
            int countList;
            // Raster class create instance
            RasterLayerInfo rasterLayerInfo_dem = new RasterLayerInfo(Properties.Settings.Default.DEM);

            for (int i = 2; i < rCnt; ++i)
            {
                rList.Clear();
                for (int j = 1; j < cCnt; ++j)
                {
                    string rData = Convert.ToString(data[i, j]);
                    rList.Add(rData);
                }
                double raster_X = Convert.ToDouble(rList[2]);
                double raster_Y = Convert.ToDouble(rList[3]);
                double raster_Z = Convert.ToDouble(rList[4]);
                double oilDepth = rasterLayerInfo_dem.getHeight(raster_X, raster_Y);
                double qDep     = oilDepth - raster_Z;
                qDep = Math.Abs(qDep);
                String dep_st = Convert.ToString(qDep);
                if (rList[0] == "")
                {
                    break;
                }
                dataGridView2.Rows.Add(rList[0], rList[1], rList[2], rList[3], rList[4], oilDepth, dep_st);
                keyList.Add(rList[0] + " " + rList[1]);
                if (!combo_st.Items.Contains(rList[0]))
                {
                    combo_st.Items.Add(rList[0]);
                }
                if (!combo_end.Items.Contains(rList[1]))
                {
                    combo_end.Items.Add(rList[1]);
                }
            }
            countList = keyList.Count();
            keyList   = keyList.Distinct().ToList();
            int keyListInt = Convert.ToInt32(keyList.Count());

            progressBar1.Step = (100 / keyListInt) - 1;
        }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            comboStart = combo_st.SelectedItem as string;
            comboEnd   = combo_end.SelectedItem as string;

            Excel.Application ap        = new Microsoft.Office.Interop.Excel.Application();
            string            directory = Properties.Settings.Default.EXCEL;

            workbook = ap.Workbooks.Open(Filename: directory);
            Excel.Worksheet worksheet = (Excel.Worksheet)workbook.Worksheets.get_Item(1);

            //첫번째 Worksheet를 선택합니다.
            Excel.Range rng   = worksheet.UsedRange;
            DataTable   table = new DataTable();

            // 현재 Worksheet에서 사용된 셀 전체를 선택합니다.
            object[,] data = rng.Value;

            int           rCnt = rng.Rows.Count;
            int           cCnt = rng.Columns.Count;
            List <string> rList = new List <string>();
            double        dem = 0.0, d_z = 0.0;
            string        rData = "";

            RasterLayerInfo rasterLayerInfo = new RasterLayerInfo(Properties.Settings.Default.DEM);

            Thread thread = new Thread(new ThreadStart(delegate() // thread create
            {
                this.Invoke(new Action(delegate()                 //this == Form  ,  Form이 아닌 컨트롤의 Invoke를 직접호출해도 무방
                {
                    for (int i = 2; i < rCnt; ++i)
                    {
                        rList.Clear();
                        for (int j = 1; j < cCnt; ++j)
                        {
                            if (j == 7)
                            {
                                break;
                            }
                            if (j == 5)
                            {
                                d_z = Convert.ToDouble(data[i, j]);
                            }
                            else if (j == 6)
                            {
                                dem = Convert.ToDouble(data[i, j]);
                            }
                            rData = Convert.ToString(data[i, j]);

                            rList.Add(rData);
                        }
                        if (rList[0] == comboStart && rList[1] == comboEnd)
                        {
                            double raster_X = Convert.ToDouble(rList[2]);
                            double raster_Y = Convert.ToDouble(rList[3]);

                            dem           = rasterLayerInfo.getHeight(raster_X, raster_Y);
                            double dep    = dem - d_z;
                            dep           = Math.Abs(dep);
                            string dep_st = Convert.ToString(dep);
                            rList.Add(dep_st);
                            dataGridView1.Rows.Add(rList[0], rList[1], rList[2], rList[3], rList[4], dem, dep_st);
                        }
                        filtering = true;
                    }
                }));
            }));

            thread.Start();   // thread 실행하여 병렬작업 시작
            wbclose = true;
        }