Example #1
0
 public override void Execute()
 {
     try
     {
         base.Execute();
         RasterClip s = new RasterClip();
         BlockDef[] envelopes;
         string     inputFilename = TryGetInfoFromActiveView(out envelopes);
         string     outdir        = Path.GetDirectoryName(inputFilename);
         if (string.IsNullOrWhiteSpace(inputFilename) || envelopes == null || envelopes.Length == 0 || envelopes.Length == 1)
         {
             frmImageClip frm = new frmImageClip(_smartSession);
             if (frm.ShowDialog() == DialogResult.OK)
             {
                 BlockDef outEnvelope;
                 Size     size;
                 frm.GetArgs(out outEnvelope, out size, out outdir, out inputFilename);
                 envelopes = new BlockDef[] { outEnvelope };
             }
             else
             {
                 return;
             }
         }
         List <BlockDef> blockList = new List <BlockDef>();
         for (int i = 0; i < envelopes.Length; i++)
         {
             blockList.Add(envelopes[i]);
         }
         string[] put = s.RasterClipT(inputFilename, blockList.ToArray(), outdir, _smartSession.ProgressMonitorManager.DefaultProgressMonitor, "Clip");
         for (int i = 0; i < put.Length; i++)
         {
             OpenFileToWindows(put[i]);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #2
0
        public override void Execute()
        {
            try
            {
                List <string> _cutfiles = new List <string>();
                base.Execute();
                RasterClip             s = new RasterClip();
                BlockDefWithAOI[]      envelopes;
                string                 inputFilename = TryGetInfoFromActiveView(out envelopes);
                string                 outdir        = Path.GetDirectoryName(inputFilename);
                int[]                  aoiIndex      = null;
                List <BlockDefWithAOI> blockList     = new List <BlockDefWithAOI>();
                frmImageClip           frm           = new frmImageClip(_smartSession);
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    _cutfiles.AddRange(frm.InputFiles);
                    _cutfiles.AddRange(frm.CustomSelectFiles);
                    BlockDefWithAOI outEnvelope;
                    Size            size;
                    frm.GetArgs(out outEnvelope, out size, out outdir, out inputFilename);
                    envelopes = new BlockDefWithAOI[] { outEnvelope };
                    aoiIndex  = frm.GetFeatureAOIIndex();
                    blockList.AddRange(envelopes);
                    if (aoiIndex != null && aoiIndex.Length != 0)
                    {
                        blockList[0].AOIIndexes = aoiIndex;
                    }
                }
                else
                {
                    return;
                }
                if (blockList[0].AOIIndexes == null)
                {
                    blockList[0].AOIIndexes = _smartSession.SmartWindowManager.ActiveCanvasViewer.AOIProvider.GetIndexes();
                }
                string[] put = s.RasterClipT(inputFilename, blockList.ToArray(), outdir, _smartSession.ProgressMonitorManager.DefaultProgressMonitor, "Cut");
                _cutfiles = _cutfiles.Distinct().ToList();
                foreach (string file in _cutfiles)
                {
                    s.RasterClipT(file, blockList.ToArray(), outdir, _smartSession.ProgressMonitorManager.DefaultProgressMonitor, "Cut");
                }
                ISmartViewer         viewer        = _smartSession.SmartWindowManager.ActiveViewer;
                int[]                selectBands   = null;
                List <IRgbProcessor> rgbProcessors = null;
                if (viewer != null)
                {
                    ICanvasViewer canViewer = viewer as ICanvasViewer;
                    if (canViewer == null)
                    {
                        return;
                    }
                    IRasterDrawing rd = canViewer.ActiveObject as IRasterDrawing;
                    if (rd == null || rd.RgbProcessorStack == null)
                    {
                        return;
                    }

                    rgbProcessors = new List <IRgbProcessor>();
                    foreach (IRgbProcessor processor in rd.RgbProcessorStack.Processors)
                    {
                        rgbProcessors.Add(processor);
                    }
                    rgbProcessors.Reverse();
                    selectBands = rd.SelectedBandNos;
                }
                for (int i = 0; i < put.Length; i++)
                {
                    OpenFileToWindows(put[i]);
                    if (selectBands == null)
                    {
                        continue;
                    }
                    IRasterDrawing draw = _smartSession.SmartWindowManager.ActiveViewer.ActiveObject as IRasterDrawing;
                    draw.SelectedBandNos = selectBands;
                    if (rgbProcessors != null && rgbProcessors.Count > 0)
                    {
                        draw.RgbProcessorStack.Clear();
                        foreach (IRgbProcessor processor in rgbProcessors)
                        {
                            draw.RgbProcessorStack.Process(processor);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }