Exemplo n.º 1
0
        public void LoadFile(string szFileName)
        {
            FileStream   fp = new FileStream(szFileName, FileMode.Open);
            BinaryReader br = new BinaryReader(fp);

            m_LDataFile.Clear();

            int count = br.ReadInt32();

            DataFile data = new DataFile();

            for (int i = 0; i < count; ++i)
            {
                string mapfile = br.ReadString();
                if (mapfile.Equals("null"))
                {
                    m_szMapFileName = null;
                }
                else
                {
                    m_szMapFileName = mapfile;
                }

                int Count = br.ReadInt32();
                data.m_LPoint = new List <Point>();

                for (int j = 0; j < Count; ++j)
                {
                    int x = br.ReadInt32();
                    int y = br.ReadInt32();

                    data.m_LPoint.Add(new Point(x, y));
                }

                m_LDataFile.Add(data);
            }

            fp.Close();
            br.Close();
        }
Exemplo n.º 2
0
        // 불러오기
        private void LoadFile_Click(object sender, EventArgs e)
        {
            this.openFileDialog1.InitialDirectory = Directory.GetCurrentDirectory();
            this.openFileDialog1.DefaultExt       = "SaveFile";
            this.openFileDialog1.Filter           = "Save Files(*.sav)|*.sav";

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                FileManager.Instance.LoadFile(this.openFileDialog1.FileName);

                // 맵 파일이 있다면 불러오기
                if (FileManager.Instance.m_szMapFileName != null)
                {
                    m_szMapFilePath = FileManager.Instance.m_szMapFileName;
                    if (m_kMapImage != null)
                    {
                        m_kMapImage.Dispose();
                    }

                    m_kMapImage = new Bitmap(m_szMapFilePath);
                }

                m_LDrawLine.Clear();
                for (int i = 0; i < FileManager.Instance.m_LDataFile.Count; ++i)
                {
                    DataFile data = FileManager.Instance.m_LDataFile[i];

                    DrawLine draw = new DrawLine();
                    draw.m_ControlPoints = data.m_LPoint;

                    // 곡선 재 계산
                    draw.RecalcSpline();

                    m_LDrawLine.Add(draw);
                }
            }
        }
Exemplo n.º 3
0
        public void WirteFile(string szFileName)
        {
            FileStream   fp = new FileStream(szFileName, FileMode.Create);
            BinaryWriter br = new BinaryWriter(fp);

            if (m_LDataFile.Count <= 0)
            {
                MessageBox.Show("데이터가 없다");
                return;
            }

            br.Write(m_LDataFile.Count);
            for (int i = 0; i < m_LDataFile.Count; ++i)
            {
                DataFile data = m_LDataFile[i];

                if (m_szMapFileName != null)
                {
                    br.Write(m_szMapFileName);
                }
                else
                {
                    br.Write("null");
                }

                br.Write(data.m_LPoint.Count);
                foreach (Point pt in data.m_LPoint)
                {
                    br.Write(pt.X);
                    br.Write(pt.Y);
                }
            }

            fp.Close();
            br.Close();
        }