Пример #1
0
        private void DoStat(IRasterDataProvider dataProvider, int[] bandNos, int[] aoi)
        {
            Dictionary <int, RasterQuickStatResult> results;
            IProgressMonitor progress = _smartSession.ProgressMonitorManager.DefaultProgressMonitor;

            try
            {
                progress.Reset("正在执行直方图统计...", 100);
                progress.Start(false);
                IRasterQuickStatTool stat = new RasterQuickStatTool();
                results = stat.Compute(dataProvider, aoi, bandNos,
                                       (idx, tip) =>
                {
                    progress.Boost(idx, "正在执行直方图统计...");
                });
            }
            finally
            {
                progress.Finish();
            }
            /*using (*/
            frmRasterQuickStat frm = new frmRasterQuickStat();//)
            {
                frm.Owner         = _smartSession.SmartWindowManager.MainForm as Form;
                frm.StartPosition = FormStartPosition.CenterScreen;
                frm.Apply(dataProvider.fileName, results);
                frm.Show();
            }
        }
Пример #2
0
        private void DoStat(IRasterDataProvider dataProvider, int[] bandNos)
        {
            IRasterQuickStatTool stat = new RasterQuickStatTool();
            Dictionary <int, RasterQuickStatResult> results = stat.Compute(dataProvider, null, bandNos,
                                                                           (idx, tip) =>
            {
                Text = tip + ":" + idx.ToString() + "%";
            });

            using (frmRasterQuickStat frm = new frmRasterQuickStat())
            {
                frm.StartPosition = FormStartPosition.CenterScreen;
                frm.Apply(dataProvider.fileName, results);
                frm.ShowDialog();
            }
        }
Пример #3
0
 private void DoWork()
 {
     try
     {
         bool reverse;//标识最大是否<最小值
         if (!CheckArgsIsOk(out reverse))
         {
             return;
         }
         string[] lfiles = GetFileNames(listBox1);
         if (lfiles.Length < 1)
         {
             throw new ArgumentException("待统计文件为空!");
         }
         int[] leftBandNum = GetBandNo(lvBands);
         if (leftBandNum == null)
         {
             throw new ArgumentException("待统计波段为空!");
         }
         if (checkBox1.Checked && leftBandNum.Length > 1)
         {
             throw new ArgumentException("分区段统计只适用于单一波段,请重新选择!");
         }
         string[] fillvalue = null;
         if (!string.IsNullOrEmpty(txtFillvalues.Text))
         {
             string[] parts = txtFillvalues.Text.Split(',');
             double   fv;
             foreach (string part in parts)
             {
                 if (double.TryParse(part, out fv))
                 {
                     throw new ArgumentException("填充值设置无效!" + part);
                 }
             }
             if (parts.Length > 0)
             {
                 fillvalue = parts;
             }
         }
         CloudParaFileStatics st = new CloudParaFileStatics();
         Dictionary <int, RasterQuickStatResult> results = null;
         if (Path.GetExtension(lfiles[0]) == ".000")
         {
             if (!checkBox1.Checked)//全部统计
             {
                 results = st.MicapsHistoStat(lfiles, leftBandNum, fillvalue, _state as Action <int, string>);
             }
             else//分区段
             {
                 if (!reverse)
                 {
                     results = st.MicapsHistoStatBetween(lfiles, leftBandNum, fillvalue, txtMin.Text, txtMax.Text, _state as Action <int, string>);
                 }
                 else
                 {
                     results = st.MicapsHistoStatBetween(lfiles, leftBandNum, fillvalue, txtMax.Text, txtMin.Text, _state as Action <int, string>);
                 }
             }
         }
         else
         {
             if (!checkBox1.Checked)//全部统计
             {
                 results = st.FilesHistoStat(lfiles, leftBandNum, fillvalue, _state as Action <int, string>);
             }
             else//分区段
             {
                 if (!reverse)
                 {
                     results = st.FilesHistoStatBetween(lfiles, leftBandNum, fillvalue, txtMin.Text, txtMax.Text, _state as Action <int, string>);
                 }
                 else
                 {
                     results = st.FilesHistoStatBetween(lfiles, leftBandNum, fillvalue, txtMax.Text, txtMin.Text, _state as Action <int, string>);
                 }
             }
         }
         if (results != null)
         {
             frmRasterQuickStat frm = new frmRasterQuickStat();//)
             {
                 frm.Owner         = _smartSession.SmartWindowManager.MainForm as Form;
                 frm.StartPosition = FormStartPosition.CenterScreen;
                 frm.Apply(lfiles[0], results);
                 frm.Show();
             }
         }
     }
     catch (Exception ex)
     {
         Action <int, string> process = _state as Action <int, string>;
         if (process != null)
         {
             process(0, ex.Message);
         }
     }
 }