Beispiel #1
0
        private ObservableCollection <MazeBoxViewModel> MakeBoxList()
        {
            ObservableCollection <MazeBoxViewModel> bList = new ObservableCollection <MazeBoxViewModel>();
            string mazeStr = data.Maze;


            MazeDimensions dims = AppViewModel.GetMazeDimensions();
            int            height = dims.height;
            int            length = dims.length;
            int            i, j;

            for (i = 0; i < height; i++)
            {
                for (j = 0; j < length; j++)
                {
                    char currChar = mazeStr[j + i * length];
                    if (currChar == '1')
                    {
                        bList.Add(new MazeBoxViewModel()
                        {
                            colorImg = @"/Pictures/blacksquare.jpg"
                        });
                    }
                    else
                    {
                        bList.Add(new MazeBoxViewModel()
                        {
                            colorImg = @"/Pictures/greensquare.png"
                        });
                    }
                }
            }
            return(bList);
        }
Beispiel #2
0
        public static void ConfigureInfo()
        {
            currentGameIsMulti = false;
            string ip      = null;
            string portStr = null;
            int    port;
            string file = @"../settings.txt";

            if (File.Exists(file))
            {
                try
                {
                    StreamReader sr = new StreamReader(file);
                    ip      = sr.ReadLine();
                    portStr = sr.ReadLine();
                    sr.Close();
                }
                catch (Exception e)
                {
                    Console.WriteLine("Exception: " + e.Message);
                }
            }
            else
            {
                ip      = ConfigurationManager.AppSettings["IP address"];
                portStr = ConfigurationManager.AppSettings["port number"];
            }
            if (ip != null && portStr != null)
            {
                port    = Int32.Parse(portStr);
                info    = new SettingsInfo(ip, port);
                speaker = new ServerSpeaker(info);
            }
            string heightStr = ConfigurationManager.AppSettings["maze height"];
            string lengthStr = ConfigurationManager.AppSettings["maze length"];
            int    height    = Int32.Parse(heightStr);
            int    len       = Int32.Parse(lengthStr);

            dims = new MazeDimensions(height, len);
        }