获取布局集合为空,标红处

0 投票

using SuperMap.Data;
using SuperMap.Mapping;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using SuperMap.Layout;
using SuperMap.UI;
using SuperMap.Desktop;
using SuperMap.Realspace;
using Application = SuperMap.Desktop.Application;

namespace zudonghua0705
{
    public partial class Form1 : Form
    {
        
   
        //打开工作空间
        IFormMap m_activefrm = SuperMap.Desktop.Application.ActiveApplication.MainForm.FormManager.ActiveForm as IFormMap;
        Workspace workspace = new Workspace();
        IFormMap formmap = SuperMap.Desktop.Application.ActiveForm as IFormMap;
        int xq = 1;
        public Form1()
        {
            InitializeComponent();
        }

        public void Form1_Load(object sender, EventArgs e)
        {
            String sceneName = "界面";
            WorkspaceConnectionInfo wsInfo = new WorkspaceConnectionInfo(@"D:/SuperMap/规划平台/SampleData/zhangjiajie/澧水流域1.smwu");
            if (Application.ActiveApplication.Workspace.Open(wsInfo))
            {
                //打开场景
                IFormScene sceneForm = Application.ActiveApplication.CreateSceneWindow();
                m_currentScene = sceneForm.SceneControl.Scene;
                if (m_currentScene.Open(sceneName))
                {
                    (sceneForm as Form).Text = sceneName;
                }
            }
            
        }
        private Scene m_currentScene;
       
      
        private void Timer1_Tick(object sender, EventArgs e)
        {
            if (xq < 10)
            {
                Datasource datasource = workspace.Datasources[0];
                Dataset dataset = datasource.Datasets[xq];
                Layers layers = m_activefrm.MapControl.Map.Layers;
                layers.Add(dataset,true);
                Layer layer = m_activefrm.MapControl.Map.Layers.Add(dataset, true);
                m_activefrm.MapControl.Map.Refresh();
                    xq = xq + 1;
            }
            else
            {
                timer1.Stop();
                timer1.Tick -= Timer1_Tick;
               

            }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
          
           
        }

        private void button1_Click(object sender, EventArgs e)
        {
            timer1.Interval = 1000;
            timer1.Start();
            timer1.Tick += Timer1_Tick;

        }

        private void button2_Click(object sender, EventArgs e)
        {
            timer1.Stop();
            timer1.Tick -= Timer1_Tick;
            
        
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }
    }
}

7月 8, 2019 分类:  70次浏览 | 用户: 元亨利贞 才疏学浅 (19 分)
重新分类 7月 8, 2019 用户:华红霞

1个回答

0 投票
 
已采纳
您好,可以检查一下数据源是否在桌面打开,有可能是数据占用了,如果不是占用问题,我这边可以远程帮你看一下
7月 8, 2019 用户: 邬袁凯 名扬四海 (2,429 分)
采纳于 7月 8, 2019 用户:元亨利贞
不是占用问题。怎么联系您?QQ还是?
远程后发现是桌面二次开发问题,已联系桌面二次开发工程师解决
...