void getresult()
        {
            MPLB.ItemsSource = null; //clear the ItemsSource
            _mpsResult.Clear();      //clear the previous results of analysis

            //Get result
            _prj = Globals.project;
            _monitoringDomain = _prj.getDomain(DomainType.Monitoring);
            _allMPs           = _monitoringDomain.getObjects("MonPoint");
            _mps = _allMPs.merge();
            int    count    = 0;
            string _message = "";

            foreach (DGObject mp in _mps)
            {
                MonPoint _mp = mp as MonPoint;
                foreach (string key in _mp.readingsDict.Keys)
                {
                    List <MonReading> a = _mp.readingsDict[key];
                    foreach (MonReading b in a)
                    {
                        if (System.Math.Abs(b.value) > mptb)
                        {
                            count++;
                        }
                    }
                    _message = string.Format("{0} of the {1} value exceed the limit value {2}", count, _mp.Name, mptb);
                }
                _mpsResult.Add(_message);
            }
            MPLB.ItemsSource = _mpsResult;
        }
예제 #2
0
        //在view中加载图形,和同步图形
        void SyncToView()
        {
            IView view = InputCB.SelectedItem as IView;

            //为图形赋值“Name”属性,以便图形和数据关联
            foreach (int monID in _MonGraphics.Keys)
            {
                MonPoint           mp = _allMons[monID] as MonPoint;
                IGraphicCollection gc = _MonGraphics[monID];
                foreach (IGraphic g in gc)
                {
                    g.Attributes["Name"] = mp.name;
                }
            }

            //将图形添加到view中
            string         layerID = "DemoLayer";                 //图层ID
            IGraphicsLayer gLayer  = getDemoLayer(view, layerID); //获取图层函数

            foreach (int id in _MonGraphics.Keys)
            {
                IGraphicCollection gc = _MonGraphics[id];
                gLayer.addGraphics(gc);
            }

            //使数据与图形关联
            List <DGObject> sls = _allMons.merge();

            gLayer.syncObjects(sls);

            //计算新建图形范围,并在地图中显示该范围
            IEnvelope ext = null;

            foreach (IGraphicCollection gc in _MonGraphics.Values)
            {
                IEnvelope itemExt = GraphicsUtil.GetGraphicsEnvelope(gc);
                if (ext == null)
                {
                    ext = itemExt;
                }
                else
                {
                    ext = ext.Union(itemExt);
                }
            }
            _mainFrame.activeView = view;
            view.zoomTo(ext);
        }
        public DemoWindow()
        {
            InitializeComponent();

            //Initialize global variables
            _prj = Globals.project;
            _monitoringDomain = _prj.getDomain(DomainType.Monitoring);
            _allMPs           = _monitoringDomain.getObjects("MonPoint");
            _mps       = _allMPs.merge();
            _mainFrame = Globals.mainframe;
            _monpoints = new Dictionary <string, IEnumerable <DGObject> >();
            mptb       = 0.002;

            Loaded += DemoWindow_Loaded1;
            getresult();
        }