Ejemplo n.º 1
0
 private void MapPath_Click(object sender, RoutedEventArgs e)
 {
     //CAD文件转换所得xml文件
     if (MapPath_comboBox.SelectedIndex == 0)
     {
         OpenFileDialog dialog = new OpenFileDialog();
         dialog.InitialDirectory = "d:\\";
         dialog.RestoreDirectory = true;
         dialog.Filter           = "Xml文件 (*.xml) | *.xml";
         if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             MapPath_textBox.Text = dialog.FileName;
             mapPath    = dialog.FileName;
             cadXmlFile = new CadXmlFile(mapPath);
         }
     }
     //数字地图
     else if (MapPath_comboBox.SelectedIndex == 1)
     {
         FolderBrowserDialog dialog = new FolderBrowserDialog();
         if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             string path = dialog.SelectedPath;
             if (!PrjItem.isDirectoryValid(path))
             {
                 System.Windows.MessageBox.Show("当前路径不符合数字地图文件要求", "错误");
                 return;
             }
             prjItem = new PrjItem(path);
             //获取选中的文件夹
             this.MapPath_textBox.Text = dialog.SelectedPath;
             mapPath = dialog.SelectedPath;
         }
     }
 }
Ejemplo n.º 2
0
        //初始化View---事件
        private void initView()
        {
            //获取数字地图文件路径
            btnChooseDigitalMap.Click += delegate
            {
                FolderBrowserDialog dialog = new FolderBrowserDialog();
                if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    string path = dialog.SelectedPath;
                    if (!PrjItem.isDirectoryValid(path))
                    {
                        System.Windows.MessageBox.Show("当前路径不符合数字地图文件要求", "错误");
                        return;
                    }
                    //获取选中的文件夹
                    this.tboxDigitalPath.Text = dialog.SelectedPath;
                    digitalFilePath           = dialog.SelectedPath;
                }
            };

            //获取输出路径
            btnChooseOutputPath.Click += delegate(object sender, RoutedEventArgs args)
            {
                var saveFileDialog = new SaveFileDialog();
                saveFileDialog.Filter = "数据库文件|*.db";
                if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    //获取得到的path
                    var path = saveFileDialog.FileName;
                    if (path != null && path.Length != 0)
                    {
                        outputPath          = path;
                        tboxOutputPath.Text = path;
                    }
                }
            };

            //生成数据库文件的按钮
            this.btnGenerateDBFile.Click += delegate(object sender, RoutedEventArgs args)
            {
                //需要先选择数字地图文件夹
                if (digitalFilePath == null)
                {
                    System.Windows.MessageBox.Show("请先选择数字地图文件夹!");
                    return;
                }
                if (outputPath == null)
                {
                    System.Windows.MessageBox.Show("请先选择输出路径!");
                    return;
                }
                //启动线程---生成数据库文件
                Thread thread = new Thread(new ThreadStart(generateDbFile));
                thread.Start();
            };
        }