public static ThemeGraphRegion GetThemeGraphRegion(string productionIdentify)
        {
            if (string.IsNullOrWhiteSpace(productionIdentify))
            {
                return(null);
            }
            string productPath = path + "ThemeGraphRegion_" + productionIdentify + ".xml";

            if (!File.Exists(productPath))
            {
                ThemeGraphRegion region = new ThemeGraphRegion();
                region.Enable          = false;
                region.ProductIdentify = productionIdentify;
                region.SelectedIndex   = -1;
                return(region);
            }
            else
            {
                XElement          xml           = XElement.Load(productPath);
                bool              enabled       = GetAttBool(xml, "enabled");
                int               selectedindex = GetAttInt(xml, "selectedindex");
                PrjEnvelopeItem[] items         = ParseEnvelopes(xml);
                ThemeGraphRegion  region        = new ThemeGraphRegion();
                region.ProductIdentify  = productionIdentify;
                region.Enable           = enabled;
                region.SelectedIndex    = selectedindex;
                region.PrjEnvelopeItems = items;
                return(region);
            }
        }
        private void InitThemeGraphRegion()
        {   //初始化当前区域设置为“无范围应用”
            ThemeGraphRegion newRegion = ThemeGraphRegionSetting.GetThemeGraphRegion(_productIdentify);

            newRegion.Enable = false;
            ThemeGraphRegionSetting.SaveThemeGraphRegion(newRegion);
        }
        void cancelRegion_Click(object sender, EventArgs e)
        {
            _btnSetThemeGraphRegion.Text = "无范围应用";
            ThemeGraphRegion region = (sender as RadMenuItem).Tag as ThemeGraphRegion;

            region.Enable = false;
            ThemeGraphRegionSetting.SaveThemeGraphRegion(region);
        }
        void menu_Click(object sender, EventArgs e)
        {
            int?index = (sender as RadMenuItem).Tag as int?;
            ThemeGraphRegion region = ((sender as RadMenuItem).Owner as RadDropDownButtonElement).Tag as ThemeGraphRegion;

            region.Enable                = true;
            region.SelectedIndex         = index.Value;
            _btnSetThemeGraphRegion.Text = region.PrjEnvelopeItems[index.Value].Name;
            ThemeGraphRegionSetting.SaveThemeGraphRegion(region);
        }
        private void UpdateSession()
        {
            string           productIdentify = (_session.MonitoringSession as IMonitoringSession).ActiveMonitoringProduct.Identify;
            ThemeGraphRegion newRegion       = ThemeGraphRegionSetting.GetThemeGraphRegion(productIdentify);

            _region = newRegion;

            if (_region.PrjEnvelopeItems != null && _region.PrjEnvelopeItems.Length != 0)
            {
                _items = new List <PrjEnvelopeItem>(_region.PrjEnvelopeItems);
            }
            LoadUserDefinedRegion();
        }
        private void UpdateBtn()
        {
            ThemeGraphRegion newRegion = ThemeGraphRegionSetting.GetThemeGraphRegion(_productIdentify);

            if (newRegion == null || !newRegion.Enable || newRegion.PrjEnvelopeItems == null || newRegion.SelectedIndex >= newRegion.PrjEnvelopeItems.Length)
            {
                _btnSetThemeGraphRegion.Text = "无范围应用";
            }
            else
            {
                _btnSetThemeGraphRegion.Text = newRegion.PrjEnvelopeItems[newRegion.SelectedIndex].Name;
            }
        }
        void regionFromAoi_Click(object sender, EventArgs e)
        {
            if (_session.SmartWindowManager.ActiveCanvasViewer == null)
            {
                return;
            }
            AOIItem[] aoiItems = _session.SmartWindowManager.ActiveCanvasViewer.AOIProvider.GetAOIItems();
            if (aoiItems == null || aoiItems.Length == 0)
            {
                return;
            }
            CoordEnvelope    env    = aoiItems[0].GeoEnvelope;
            ThemeGraphRegion region = (sender as RadMenuItem).Tag as ThemeGraphRegion;

            region.Add(new PrjEnvelopeItem("AOI", new PrjEnvelope(env.MinX, env.MaxX, env.MinY, env.MaxY)));
            ThemeGraphRegionSetting.SaveThemeGraphRegion(region);
            UpdateBtn();
        }
        public static void SaveThemeGraphRegion(ThemeGraphRegion region)
        {
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            XElement xml = new XElement("ThemeGraphRegion",
                                        new XAttribute("enabled", region.Enable),
                                        new XAttribute("selectedindex", region.SelectedIndex),
                                        from block in region.PrjEnvelopeItems
                                        select new XElement("EnvelopeItem",
                                                            new XAttribute("name", block.Name),
                                                            new XAttribute("minLongitude", block.PrjEnvelope.MinX),
                                                            new XAttribute("minLatitude", block.PrjEnvelope.MinY),
                                                            new XAttribute("maxLongitude", block.PrjEnvelope.MaxX),
                                                            new XAttribute("maxLatitude", block.PrjEnvelope.MaxY)));
            string productPath = path + "ThemeGraphRegion_" + region.ProductIdentify + ".xml";

            xml.Save(productPath, SaveOptions.None);
        }
        private void LoadThemeGraphRegion()
        {
            _btnSetThemeGraphRegion.Items.Clear();
            ThemeGraphRegion region = ThemeGraphRegionSetting.GetThemeGraphRegion(_productIdentify);

            _btnSetThemeGraphRegion.Tag = region;
            if (region != null)
            {
                bool enable             = region.Enable;
                int  selectedIndex      = region.SelectedIndex;
                PrjEnvelopeItem[] items = region.PrjEnvelopeItems;
                if (items != null)
                {
                    for (int i = 0; i < items.Length; i++)
                    {
                        PrjEnvelopeItem item = items[i];
                        RadMenuItem     menu = new RadMenuItem();
                        menu.Text   = item.Name;
                        menu.Tag    = i;
                        menu.Click += new EventHandler(menu_Click);
                        if (enable && selectedIndex == i)
                        {
                            _btnSetThemeGraphRegion.Text = item.Name;
                            menu.IsChecked = true;
                        }
                        _btnSetThemeGraphRegion.Items.Add(menu);
                    }
                    _btnSetThemeGraphRegion.Items.Add(new RadMenuSeparatorItem());
                    RadMenuItem cancelRegion = new RadMenuItem("取消范围应用");
                    cancelRegion.Tag    = region;
                    cancelRegion.Click += new EventHandler(cancelRegion_Click);
                    _btnSetThemeGraphRegion.Items.Add(cancelRegion);
                }
            }
            _btnSetThemeGraphRegion.Items.Add(new RadMenuSeparatorItem());
            RadMenuItem editRegion = new RadMenuItem("编辑范围");

            editRegion.Click += new EventHandler(editRegion_Click);
            editRegion.Tag    = region;
            _btnSetThemeGraphRegion.Items.Add(editRegion);
        }
 private void LoadUserDefinedRegion()
 {
     _tree.Nodes.Clear();
     _region = ThemeGraphRegionSetting.GetThemeGraphRegion(_region.ProductIdentify);
     PrjEnvelopeItem[] items = _region.PrjEnvelopeItems;
     if (_region.PrjEnvelopeItems != null && _region.PrjEnvelopeItems.Length != 0)
     {
         _items = new List <PrjEnvelopeItem>(_region.PrjEnvelopeItems);
     }
     foreach (PrjEnvelopeItem item in _items)
     {
         RadTreeNode node = new RadTreeNode(item.Name);
         node.Tag = item;
         _tree.Nodes.Add(node);
     }
     if (_tree.Nodes.Count != 0)
     {
         _tree.SelectedNode = _tree.Nodes[0];
     }
     _tree.ExpandAll();
 }