public static StatContent[] LoadStatContents()
        {
            string   filename = System.AppDomain.CurrentDomain.BaseDirectory + FileName;
            XElement xml      = XElement.Load(filename);
            IEnumerable <XElement> xStatContents = xml.Elements("StatContent");
            List <StatContent>     statItems     = new List <StatContent>();

            foreach (XElement item in xStatContents)
            {
                string identify = item.Attribute("identify").Value;
                string filter   = item.Attribute("layerfilter").Value;
                Dictionary <string, int> statItem = ParseStatItem(item);
                StatContent statContent           = new StatContent();
                statContent.Identify    = identify;
                statContent.LayerFilter = filter;
                statContent.StatItems   = statItem;
                statItems.Add(statContent);
            }
            return(statItems.ToArray());
        }
Example #2
0
        private ICanvasViewer _activeViewer = null;//用于统计的窗口windows。

        /// <summary>
        /// 窗口切换
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="oldWindow"></param>
        /// <param name="newWindow"></param>
        void ActiveWindowChanged(object sender, ISmartWindow oldWindow, ISmartWindow newWindow)
        {
            _extractedPixels = null;
            if (newWindow == null || !(newWindow is ICanvasViewer))
            {
                return;
            }
            if (_activeViewer == newWindow)
            {
                return;
            }
            if (_filters != null)
            {
                _filters.Clear();
            }
            if (_activeViewer != null)
            {
                if (oldWindow != null && oldWindow is ICanvasViewer)
                {
                    ClearFeature(oldWindow as ICanvasViewer);
                }
                else
                {
                    ClearFeature(_activeViewer);
                }
                _activeViewer.Canvas.Refresh(enumRefreshType.VectorLayer);
            }
            _activeViewer = newWindow as ICanvasViewer;
            _activeViewer.OnWindowClosed =
                (wSender, e) =>
            {
                Free();
                _activeViewer = null;
            };
            StatContent statContent = null;

            GeoDo.RSS.Core.DrawEngine.ILayer[] layers = _activeViewer.Canvas.LayerContainer.Layers.ToArray();
            foreach (GeoDo.RSS.Core.DrawEngine.ILayer layer in layers)
            {
                if (layer is BinaryBitmapLayer)//二值图层
                {
                    IExtractingSession se = (_session.MonitoringSession as MonitoringSession).ExtractingSession;
                    _extractedPixels = se.GetBinaryValuesMapper(se.CurrentProduct.Identify, se.CurrentSubProduct.Identify);
                    if (_extractedPixels == null)
                    {
                        continue;
                    }
                    string layerName = layer.Name;
                    statContent = FeatureListStatConfig.MatchStatContent(layerName);
                }
                else if (layer is IRasterLayer)
                {
                    IRasterLayer rasterLayer = layer as IRasterLayer;
                    if (rasterLayer == null)
                    {
                        continue;
                    }

                    IRasterDrawing rasterDrawing = rasterLayer.Drawing as IRasterDrawing;
                    if (rasterDrawing == null)
                    {
                        continue;
                    }
                    string layerName = layer.Name;
                    statContent = FeatureListStatConfig.MatchStatContent(layerName);
                }
            }
            if (statContent != null)
            {
                Dictionary <string, Func <short, bool> > filters = new Dictionary <string, Func <short, bool> >();
                Dictionary <string, int> sataItems = statContent.StatItems;
                string[] statKeys   = sataItems.Keys.ToArray();
                int[]    statValues = sataItems.Values.ToArray();
                for (int i = 0; i < statKeys.Length; i++)
                {
                    string key   = statKeys[i];
                    int    value = statValues[i];
                    filters.Add(key, (val) => { return(val == value); });
                }
                InitStatContent(filters);
            }
            if (_filters == null || _filters.Count == 0)
            {
                SataSimpleArea();
            }
            else
            {
                StatFilterAreas();
            }
        }