Exemplo n.º 1
0
        static void Main()
        {
            InitialiseDatabases();


            ItemDatabase itemDatabase;
            UserDatabase userDatabase;

            StreamReader streamReader = new StreamReader(Directory.GetCurrentDirectory() + USER_FILENAME);

            try
            {
                userDatabase = new UserDatabase(streamReader);
                streamReader.Close();

                streamReader = new StreamReader(Directory.GetCurrentDirectory() + ITEM_FILENAME);
                itemDatabase = new ItemDatabase(streamReader);
                streamReader.Close();
            }
            catch (Exception e)
            {
                //Cannot close in a finally block because needs to return when error is caught
                streamReader.Close();
                MessageBox.Show("Error Reading File: " + e.Message);
                return;
            }

            InitialiseControllers(itemDatabase, userDatabase);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Application.Run(new LoginScreen());

            Application.ExitThread();
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initialises the primary controllers with UserDatabase and ItemDatabases
 /// </summary>
 /// <param name="itemDatabase"></param>
 /// <param name="userDatabase"></param>
 static void InitialiseControllers(ItemDatabase itemDatabase, UserDatabase userDatabase)
 {
     UIController.ItemDatabase          = itemDatabase;
     ProcessUserController.UserDatabase = userDatabase;
 }