Esempio n. 1
0
        private void openFileMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            String current = Directory.GetCurrentDirectory();
            dialog.InitialDirectory = current + @"\projects\" + projectName + @"\data";

            if(dialog.ShowDialog() == DialogResult.OK) {
                floorMap.dispose();
                floorMap = new FloorMap(device);

                EditorConfig editorConfig = new EditorConfig();
                Boolean result = editorConfig.fromFile(dialog.FileName);
                if(!result) {
                    MessageBox.Show("ファイルの読み込みが正常に終了しませんでした。");
                }

                drawFloorModel = editorConfig.drawFloorModel;
                showAlwaysFloorMap = editorConfig.showAlwaysFloorMap;

                floorMap.setX(editorConfig.mapXsize);
                floorMap.setY(editorConfig.mapYsize);
                mapSizeX.Value = editorConfig.mapXsize;
                mapSizeY.Value = editorConfig.mapYsize;

                //コントロールの読み込み
                showFloorModelcheckBox.Checked = drawFloorModel;
                showAlwaysFloorModelcheckBox.Checked = showAlwaysFloorMap;
                mapSizeX.Enabled = !editorConfig.lockMapSize;
                mapSizeY.Enabled = !editorConfig.lockMapSize;
                encountRatioUpDown.Value = editorConfig.encounterRatio;

                //enableの構築
                for (int i = 0; i < editorConfig.mapXsize - 1; i++)
                {
                    List<Boolean> bl = editorConfig.edgeXListEnable.ElementAt(i);
                    List<MapEdge> el = floorMap.MapPosition.EdgeXList.ElementAt(i);
                    for (int j = 0; j < editorConfig.mapYsize; j++)
                    {
                        Boolean b = bl.ElementAt(j);
                        el.ElementAt(j).Enabled = b;
                    }
                }
                for (int i = 0; i < editorConfig.mapXsize; i++ )
                {
                    List<Boolean> bl = editorConfig.edgeYListEnable.ElementAt(i);
                    List<MapEdge> el = floorMap.MapPosition.EdgeYList.ElementAt(i);
                    for (int j = 0; j < editorConfig.mapYsize - 1; j++)
                    {
                        Boolean b = bl.ElementAt(j);
                        el.ElementAt(j).Enabled = b;
                    }

                }
            }
        }