Exemple #1
0
        // Код для выполнения при запуске приложения (например, из меню "Пуск")
        // Этот код не будет выполняться при повторной активации приложения
        private void Application_Launching(object sender, LaunchingEventArgs e)
        {
            IsolatedStorageSettings isos = IsolatedStorageSettings.ApplicationSettings;
            if(!isos.Contains("firstRun"))
            {
                //Выполнение копирования уровней
                Core core = new Core();
                coins cash = new coins();
                core.add_level("rock_basic", "Рок музыка", "10");
                core.add_level("pop_basic", "Поп музыка", "10");
                core.add_level("rap_basic", "Рэп и хип-хоп", "10");
                IsolatedStorageFile fileStorage = IsolatedStorageFile.GetUserStoreForApplication();
                if (!fileStorage.DirectoryExists("rock_basic"))
                {
                    fileStorage.CreateDirectory("rock_basic");
                }
                if (!fileStorage.DirectoryExists("pop_basic"))
                {
                    fileStorage.CreateDirectory("pop_basic");
                }
                if (!fileStorage.DirectoryExists("rap_basic"))
                {
                    fileStorage.CreateDirectory("rap_basic");
                }
                string DBFile = "/{0}/{1}_{2}.mp3";
                string tmpfile1;
                string tmpfile2;
                string ResFile = "Resources/{0}/{1}_{2}.mp3";
                string dir;
                dir = "rock_basic";
                if (!fileStorage.FileExists("/rock_basic/declare.txt"))
                {
                    CopyFromContentToStorage(fileStorage, "Resources/rock_basic/declare.txt", "/rock_basic/declare.txt");
                }
                if (!fileStorage.FileExists("/pop_basic/declare.txt"))
                {
                    CopyFromContentToStorage(fileStorage, "Resources/pop_basic/declare.txt", "/pop_basic/declare.txt");
                }
                if (!fileStorage.FileExists("/rap_basic/declare.txt"))
                {
                    CopyFromContentToStorage(fileStorage, "Resources/rap_basic/declare.txt", "/rap_basic/declare.txt");
                }
                for (int i = 1; i <= 10; i++)
                {
                    tmpfile1 = String.Format(DBFile,dir, Convert.ToString(i), "1");
                    tmpfile2 = String.Format(ResFile, dir, Convert.ToString(i), "1");
                    if(!fileStorage.FileExists(tmpfile1))
                        {
                        CopyFromContentToStorage(fileStorage, tmpfile2, tmpfile1);
                    }
                    tmpfile1 = String.Format(DBFile, dir, Convert.ToString(i), "2");
                    tmpfile2 = String.Format(ResFile, dir, Convert.ToString(i), "2");
                    if (!fileStorage.FileExists(tmpfile1))
                    {
                        CopyFromContentToStorage(fileStorage, tmpfile2, tmpfile1);
                    }
                    tmpfile1 = String.Format(DBFile, dir, Convert.ToString(i), "3");
                    tmpfile2 = String.Format(ResFile, dir, Convert.ToString(i), "3");
                    if (!fileStorage.FileExists(tmpfile1))
                    {
                        CopyFromContentToStorage(fileStorage, tmpfile2, tmpfile1);
                    }
                }
                dir = "pop_basic";

                for (int i = 1; i <= 10; i++)
                {
                    tmpfile1 = String.Format(DBFile, dir, Convert.ToString(i), "1");
                    tmpfile2 = String.Format(ResFile, dir, Convert.ToString(i), "1");
                    if (!fileStorage.FileExists(tmpfile1))
                    {
                        CopyFromContentToStorage(fileStorage, tmpfile2, tmpfile1);
                    }
                    tmpfile1 = String.Format(DBFile, dir, Convert.ToString(i), "2");
                    tmpfile2 = String.Format(ResFile, dir, Convert.ToString(i), "2");
                    if (!fileStorage.FileExists(tmpfile1))
                    {
                        CopyFromContentToStorage(fileStorage, tmpfile2, tmpfile1);
                    }
                    tmpfile1 = String.Format(DBFile, dir, Convert.ToString(i), "3");
                    tmpfile2 = String.Format(ResFile, dir, Convert.ToString(i), "3");
                    if (!fileStorage.FileExists(tmpfile1))
                    {
                        CopyFromContentToStorage(fileStorage, tmpfile2, tmpfile1);
                    }
                }
                dir = "rap_basic";
                for (int i = 1; i <= 10; i++)
                {
                    tmpfile1 = String.Format(DBFile, dir, Convert.ToString(i), "1");
                    tmpfile2 = String.Format(ResFile, dir, Convert.ToString(i), "1");
                    if (!fileStorage.FileExists(tmpfile1))
                    {
                        CopyFromContentToStorage(fileStorage, tmpfile2, tmpfile1);
                    }
                    tmpfile1 = String.Format(DBFile, dir, Convert.ToString(i), "2");
                    tmpfile2 = String.Format(ResFile, dir, Convert.ToString(i), "2");
                    if (!fileStorage.FileExists(tmpfile1))
                    {
                        CopyFromContentToStorage(fileStorage, tmpfile2, tmpfile1);
                    }
                    tmpfile1 = String.Format(DBFile, dir, Convert.ToString(i), "3");
                    tmpfile2 = String.Format(ResFile, dir, Convert.ToString(i), "3");
                    if (!fileStorage.FileExists(tmpfile1))
                    {
                        CopyFromContentToStorage(fileStorage, tmpfile2, tmpfile1);
                    }
                }
                //Задаем начальный баланс
                cash.count = 100;
                isos.Add("firstRun", "yes");
                isos.Save();
            }
        }
Exemple #2
0
 private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
 {
     string level_ident;
     level_ident = NavigationContext.QueryString["level_ident"];
     core.level_ident = level_ident;
     core.LoadByIdent();
     level_name.Text = core.main_level.name;
     coins cash = new coins();
     coins_count.Text = Convert.ToString(cash.count);
     if(core.get_tracks_count()==1)
     {
         song2.Visibility = Visibility.Collapsed;
         song3.Visibility = Visibility.Collapsed;
         btnHintUnlockTrack.Visibility = Visibility.Collapsed;
     }
     preload();
     load_artist(core.sorted[0]);
 }