示例#1
0
        public static void SaveMapDatabase(String filePath4MapDescriptor, MapDatabase mapDatabase)
        {
            try
            {
                MemoryStream memoryStream = new MemoryStream();
                _xmlSerializer.Serialize(memoryStream, mapDatabase);

                byte[] buffer = memoryStream.ToArray();
                File.WriteAllBytes(filePath4MapDescriptor, buffer);
            }
            catch (Exception ex)
            {
                ErrorMessageBox.Show(ex);
            }
        }
示例#2
0
        public void SetControl(String filePath4MapDescriptor)
        {
            _mapDatabase = Dal.GetMapDatabase(filePath4MapDescriptor);
            SelectCanvas(0);
            SetDataInControl4CurCanvas();

            InkCanvas.SetLeft(_counterTerroristStartPos, _mapDatabase.CounterTerroristStartPos.Center.X);
            InkCanvas.SetTop(_counterTerroristStartPos, _mapDatabase.CounterTerroristStartPos.Center.Y);

            InkCanvas.SetLeft(_terroristStartPos, _mapDatabase.TerroristStartPos.Center.X);
            InkCanvas.SetTop(_terroristStartPos, _mapDatabase.TerroristStartPos.Center.Y);

            _counterTerroristStartPos.Width  = _mapDatabase.CounterTerroristStartPos.Width;
            _counterTerroristStartPos.Height = _mapDatabase.CounterTerroristStartPos.Height;

            _terroristStartPos.Width  = _mapDatabase.TerroristStartPos.Width;
            _terroristStartPos.Height = _mapDatabase.TerroristStartPos.Height;

            SetMode(InkCanvasEditingMode.Select, EditorMode.Select);
        }
示例#3
0
        public static MapDatabase GetMapDatabase(String filePath4MapDescriptor)
        {
            MapDatabase mapDatabase = new MapDatabase();
            string absolutePath = AppDomain.CurrentDomain.BaseDirectory + filePath4MapDescriptor;
            try
            {
                if (!File.Exists(absolutePath))
                {
                    InfoMessageBox.Show("File not exists " + filePath4MapDescriptor);
                    return mapDatabase;
                }
                byte[] buffer = File.ReadAllBytes(absolutePath);
                MemoryStream memoryStream = new MemoryStream(buffer);
                mapDatabase = (MapDatabase)_xmlSerializer.Deserialize(memoryStream);

                return mapDatabase;
            }
            catch (Exception ex)
            {
                ErrorMessageBox.Show(ex);
                return mapDatabase;
            }
        }
示例#4
0
        public static MapDatabase GetMapDatabase(String filePath4MapDescriptor)
        {
            MapDatabase mapDatabase  = new MapDatabase();
            string      absolutePath = AppDomain.CurrentDomain.BaseDirectory + filePath4MapDescriptor;

            try
            {
                if (!File.Exists(absolutePath))
                {
                    InfoMessageBox.Show("File not exists " + filePath4MapDescriptor);
                    return(mapDatabase);
                }
                byte[]       buffer       = File.ReadAllBytes(absolutePath);
                MemoryStream memoryStream = new MemoryStream(buffer);
                mapDatabase = (MapDatabase)_xmlSerializer.Deserialize(memoryStream);

                return(mapDatabase);
            }
            catch (Exception ex)
            {
                ErrorMessageBox.Show(ex);
                return(mapDatabase);
            }
        }
        public void SetControl(String filePath4MapDescriptor)
        {
            _mapDatabase = Dal.GetMapDatabase(filePath4MapDescriptor);
            SelectCanvas(0);
            SetDataInControl4CurCanvas();

            InkCanvas.SetLeft(_counterTerroristStartPos,_mapDatabase.CounterTerroristStartPos.Center.X);
            InkCanvas.SetTop(_counterTerroristStartPos,_mapDatabase.CounterTerroristStartPos.Center.Y);

            InkCanvas.SetLeft(_terroristStartPos,_mapDatabase.TerroristStartPos.Center.X);
            InkCanvas.SetTop(_terroristStartPos, _mapDatabase.TerroristStartPos.Center.Y);

            _counterTerroristStartPos.Width = _mapDatabase.CounterTerroristStartPos.Width;
            _counterTerroristStartPos.Height = _mapDatabase.CounterTerroristStartPos.Height;

            _terroristStartPos.Width = _mapDatabase.TerroristStartPos.Width;
            _terroristStartPos.Height = _mapDatabase.TerroristStartPos.Height;

            SetMode(InkCanvasEditingMode.Select, EditorMode.Select);
        }