private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            if (MediaPlayer.State == MediaState.Playing)
            {
                if (settings["mostrarMensajeMusica"].ToString() == "false")
                {
                    RadMessageBox.Show("Antes que nada", MessageBoxButtons.YesNo, "Si presionas si," +
                                       " se pondra en stop el reproductor de musica, " +
                                       "debido a que lo necesitamos para el juego", closedHandler: (arg) =>
                    {
                        int indexBoton = arg.ButtonIndex;
                        switch (indexBoton)
                        {
                        case 0:

                            FrameworkDispatcher.Update();
                            MediaPlayer.Stop();
                            settings["colocarMusicaFondo"] = "True";
                            settings["volumenMusicaFondo"] = 0.5f;
                            NavigationService.Navigate(new Uri("/Niveles.xaml", UriKind.Relative));
                            break;

                        case 1:
                            settings["colocarMusicaFondo"] = "False";
                            settings["volumenMusicaFondo"] = 0.5f;
                            NavigationService.Navigate(new Uri("/Niveles.xaml", UriKind.Relative));
                            break;
                        }
                    });
                }
                else
                {
                    FrameworkDispatcher.Update();
                    MediaPlayer.Stop();
                    NavigationService.Navigate(new Uri("/Niveles.xaml", UriKind.Relative));
                }
            }
            else
            {
                NavigationService.Navigate(new Uri("/Niveles.xaml", UriKind.Relative));
            }

            //
            //NavigationService.Navigate(new Uri("/Imagenes1.xaml", UriKind.Relative));
        }
Example #2
0
        public GamePage()
        {
            InitializeComponent();

            // Get the content manager from the application
            contentManager = (Application.Current as App).Content;

            IDevice dev = new DeviceFacadeWP8(this, contentManager);

            omichGame = new GameFacade(dev);

            // Create a timer for this page
            timer = new GameTimer();
            timer.UpdateInterval = TimeSpan.FromTicks(333333);
            timer.Update        += OnUpdate;
            timer.Draw          += OnDraw;
            FrameworkDispatcher.Update();
        }
 private void DoPlaySoundEffect(PlaySoundEffectMessage message)
 {
     if (SoundName == message.SoundName)
     {
         Dispatcher.BeginInvoke(() =>
         {
             using (var stream = TitleContainer.OpenStream(SoundFileLocation))
             {
                 if (stream != null)
                 {
                     var effect = SoundEffect.FromStream(stream);
                     FrameworkDispatcher.Update();
                     effect.Play();
                 }
             }
         });
     }
 }
        public static void VibrationSound()
        {
            //consider writing the bit that makes the text flash
            Microsoft.Xna.Framework.Audio.SoundEffect sound = SoundEffect.FromStream(TitleContainer.OpenStream("Assets/sound.wav"));

            AppSettings settings = new AppSettings();

            if (settings.ToggleSwitchVibration)
            {
                Microsoft.Devices.VibrateController testVibrateController = Microsoft.Devices.VibrateController.Default;
                testVibrateController.Start(TimeSpan.FromSeconds(3));
            }
            if (settings.ToggleSwitchSound)
            {
                FrameworkDispatcher.Update();
                sound.Play();
            }
        }
Example #5
0
        void intervalTimer_Tick(object sender, EventArgs e)
        {
            try { FrameworkDispatcher.Update(); }
            catch { }

            if (wasapiIsEnabled)
            {
                // XnaAudio stores the buffer in callback method.
                // Buffer is retrieved manually when recording using WASAPI.
                byte[] bytes = null;
                int    size  = wasapiAudio.ReadBytes(out bytes);

                if (size > 0)
                {
                    OnBufferReady(bytes);
                }
            }
        }
Example #6
0
        private void ViewModel_TimingStarted(ViewModels.TimerViewModel sender, object args)
        {
            FrameworkDispatcher.Update();
            if (!MediaPlayer.GameHasControl)
            {
                App.ViewModel.NeedToResumeMusic = true;
                MediaPlayer.Pause();
            }

            Dispatcher.BeginInvoke(async() =>
            {
                metTimingStarted.Play();
                var currentBackground = LayoutRoot.Background;
                LayoutRoot.Background = this.Resources[AppConstants.RESOURCE_BRUSH_PHONECONTRASTBACKGROUND] as Brush;
                await Task.Delay(1000);
                LayoutRoot.Background = currentBackground;
            });
        }
 private void DTimer_Tick(object sender, EventArgs e)
 {
     try
     {
         FrameworkDispatcher.Update();
         if (Bool_Play == true)
         {
             Slider_Time.Value = MediaPlayer.PlayPosition.TotalSeconds;
             TimeCurrent       = Get_String_Time(MediaPlayer.PlayPosition.Minutes, MediaPlayer.PlayPosition.Seconds);
         }
         else
         {
             Slider_Time.Value = BackgroundAudioPlayer.Instance.Position.TotalSeconds;
             TimeCurrent       = Get_String_Time(BackgroundAudioPlayer.Instance.Position.Minutes, BackgroundAudioPlayer.Instance.Position.Seconds);
         }
     }
     catch { }
 }
        public SettingsPage()
        {
            InitializeComponent();
            PageTitle.Text = Strings.Settings;
            MusicVolumeSettingsLabel.Text  = Strings.MusicVolume;
            SoundsVolumeSettingsLabel.Text = Strings.SoundEffectsVolume;
            VibrationSettingsLabel.Text    = Strings.VibrationSettingsLabel;

            content = (Application.Current as App).Content;
            bark    = content.Load <SoundEffect>("bark");
            FrameworkDispatcher.Update();

            settings = IsolatedStorageSettings.ApplicationSettings;

            MusicSettingsSlider.Value   = (float)settings["MusicVolume"];
            SoundsSettingsSlider.Value  = (float)settings["SoundsVolume"];
            VibrationCheckBox.IsChecked = (bool)settings["Vibration"];
        }
Example #9
0
        /// <summary>
        /// Updates the XNA FrameworkDispatcher and checks to see if a sound is playing.
        /// If sound has stopped playing, it updates the UI.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void dt_Tick(object sender, EventArgs e)
        {
            try { FrameworkDispatcher.Update(); }
            catch { }

            if (true == soundIsPlaying)
            {
                if (soundInstance.State != SoundState.Playing)
                {
                    // Audio has finished playing
                    soundIsPlaying = false;

                    // Update the UI to reflect that the 
                    // sound has stopped playing
                    SetButtonStates(true, true, false, true);
                    //StatusImage.Source = blankImage;
                }
            }
        }
Example #10
0
        // Updates the XNA FrameworkDispatcher and checks to see if a sound is playing.
        // If sound has stopped playing, it updates the UI.
        void dt_Tick(object sender, EventArgs e)
        {
            try { FrameworkDispatcher.Update(); }
            catch { }

            if (true == soundIsPlaying)
            {
                if (soundInstance.State != SoundState.Playing)
                {
                    // Audio has finished playing
                    soundIsPlaying = false;

                    // Update the UI to reflect that the
                    // sound has stopped playing
                    SetButtonStates(true, true, false);
                    textOutput.Text = "press play\nor record";
                }
            }
        }
Example #11
0
        private void Tick()
        {
            this.updated = false;

            if (this.stopWatch.ElapsedMilliseconds > 20L)
            {
                this.stopWatch.Restart();
                this.updated = true;
            }
            if (this.updated)
            {
                //base.Invalidate();
                FrameworkDispatcher.Update();
                if (!Onloa)
                {
                    Onloa = true;
                }
            }
        }
Example #12
0
        public GraphicsDeviceServiceMock()
        {
            SDL.SDL_SetMainReady();
            SDL.SDL_Init(SDL.SDL_INIT_VIDEO);
            _Handle = SDL.SDL_CreateWindow(string.Empty, 0, 0, 1, 1, _WindowFlags);

            var Parameters = new PresentationParameters()
            {
                BackBufferWidth    = 1,
                BackBufferHeight   = 1,
                DeviceWindowHandle = _Handle,
                IsFullScreen       = false
            };

            AudioManager.DisableSound();
            FrameworkDispatcher.Update();

            _GraphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.HiDef, Parameters);
        }
Example #13
0
        private void DisplayResult(Result resultReader)
        {
            if (resultReader == null)
            {
                return;
            }

            result            = new ScannerResult(Microsoft.Phone.Tasks.TaskResult.OK);
            result.ScanCode   = resultReader.Text;
            result.ScanFormat = resultReader.BarcodeFormat.ToString();

            FrameworkDispatcher.Update();
            scanEffect.Play();

            if (this.NavigationService.CanGoBack)
            {
                this.NavigationService.GoBack();
            }
        }
Example #14
0
        private void translator_SpeakCompleted(object sender, SpeakCompletedEventArgs e)
        {
            var client = new WebClient();

            lock (client)
            {
                client.OpenReadCompleted += ((s, args) =>
                {
                    FrameworkDispatcher.Update();
                    SoundEffect se = SoundEffect.FromStream(args.Result);
                    lock (se)
                    {
                        se.Play();
                    }
                }
                                             );
                client.OpenReadAsync(new Uri(e.Result));
            }
        }
Example #15
0
        // Constructor
        public MainPage()
        {
            InitializeComponent();

            // Timer starten, um die XNA-Internas ausführen zu können (MediaPlayer ist vom XNA-Framework)
            DispatcherTimer dt = new DispatcherTimer();

            dt.Interval = TimeSpan.FromMilliseconds(33);
            dt.Tick    += (sender, e) =>
            {
                try
                {
                    FrameworkDispatcher.Update();
                }
                catch { }
            };

            // Media Player Buttons ein-/ausschalten in Abhängigkeit von Wiedergabe
            MediaPlayer.MediaStateChanged += new EventHandler <EventArgs>(MediaPlayer_MediaStateChanged);
        }
        public MainPage()
        {
            InitializeComponent();

            content = (Application.Current as App).Content;
            FrameworkDispatcher.Update();

            Strings.Culture          = Thread.CurrentThread.CurrentCulture;
            PlayButton.Content       = Strings.PlayButton;
            ScoresButton.Content     = Strings.ScoresButton;
            HowToButton.Content      = Strings.HowToButton;
            SettingsButton.Content   = Strings.Settings;
            CreditsButton.Content    = Strings.CreditsButton;
            ScoresBackButton.Content = Strings.ScoresBackButton;
            ScoresTitleTextBox.Text  = Strings.ScoresButton;
            NoScoresTextBlock.Text   = Strings.NoScores;

            ResetStoryBoard.Completed += new EventHandler(ResetStoryBoard_Completed);
            listBox.SelectionChanged  += new System.Windows.Controls.SelectionChangedEventHandler(listBox_SelectionChanged);
        }
        private void SetupDispatcherTimer()
        {
            if (_dispatcherTimer == null)
            {
                _dispatcherTimer = new DispatcherTimer
                {
                    Interval = TimeSpan.FromMilliseconds(33)
                };
                _dispatcherTimer.Tick += delegate
                {
                    FrameworkDispatcher.Update();
                    UpdateCurrentTone();
                };
            }

            if (_dispatcherTimer.IsEnabled)
            {
                _dispatcherTimer.Stop();
            }
        }
Example #18
0
        /// <summary>
        /// 为了模拟xBox游戏的消息处理
        /// 必须循环调用FrameworkDispatcher.Update方法
        /// 以更新消息处理
        /// </summary>
        public static void InitTimer()
        {
            DispatcherTimer MyTimer;

            MyTimer          = new DispatcherTimer();
            MyTimer.Interval = TimeSpan.FromMilliseconds(30);
            MyTimer.Tick    += (sd, arg) =>
            {
                try
                {
                    FrameworkDispatcher.Update();
                }
                catch     /*(Exception ex)*/
                {
                    // 调试阶段可以通过该语句了解异常信息
                    //System.Diagnostics.Debug.WriteLine(ex.Message);
                }
            };
            MyTimer.Start();
        }
Example #19
0
        private void imgFavs_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            BitmapImage bm = new BitmapImage(new Uri(@"/images/Favorite-S.png", UriKind.RelativeOrAbsolute));

            imgFavs.Source      = bm;
            Grid_Fav.Visibility = Visibility.Visible;

            BitmapImage bm1 = new BitmapImage(new Uri(@"/images/NumberPad.png", UriKind.RelativeOrAbsolute));

            imgKeypad.Source = bm1;
            BitmapImage bm2 = new BitmapImage(new Uri(@"/images/ContactList.png", UriKind.RelativeOrAbsolute));

            imgContacts.Source       = bm2;
            Grid_Keypad.Visibility   = Visibility.Collapsed;
            Grid_Contacts.Visibility = Visibility.Collapsed;


            ObservableCollection <ToDoItemViewModel> _todoItems = new ObservableCollection <ToDoItemViewModel>();

            using (var db = new SQLiteConnection(dbPath))
            {
                List <Person> existing = db.Query <Person>("select * from Person where isFav = 1").ToList();
                if (existing != null)
                {
                    for (int i = 0; i < existing.Count; i++)
                    {
                        BitmapImage b = BytesToImage(existing[i].Images);
                        _todoItems.Add(new ToDoItemViewModel {
                            Text = existing[i].Names, Text1 = existing[i].Numbers, Text2 = b, Text3 = existing[i].Id.ToString()
                        });
                    }
                }
            }

            FavList.DataContext = _todoItems;
            var swipeInteraction = new SwipeInteraction();

            swipeInteraction.Initialise(FavList, _todoItems);
            _interactionManager.AddInteraction(swipeInteraction);
            FrameworkDispatcher.Update();
        }
        void PlaySong()
        {
            try
            {
                if (List_NowPlaying.Count() == 0)
                {
                    return;
                }
                if (Current_NowPlaying < 0 || Current_NowPlaying > List_NowPlaying.Count - 1)
                {
                    return;
                }
                Init_Songs(List_NowPlaying[Current_NowPlaying]);
                DTimer.Start();

                DTO_Class.CopySong(List_NowPlaying[Current_NowPlaying]);
                Lyric = List_NowPlaying[Current_NowPlaying].Lyric;

                if (List_NowPlaying[Current_NowPlaying].Stream != null)
                {
                    FrameworkDispatcher.Update();
                    MediaPlayer.Stop();
                    Bool_Play = false;

                    BackgroundAudioPlayer.Instance.Track = List_NowPlaying[Current_NowPlaying].Offline_Track;
                    BackgroundAudioPlayer.Instance.Play();
                }
                else
                {
                    FrameworkDispatcher.Update();
                    BackgroundAudioPlayer.Instance.Close();
                    Bool_Play = true;
                    MediaPlayer.Play(List_NowPlaying[Current_NowPlaying].OfflineSong);
                }
            }
            catch { }
            finally
            {
                DTimerWait.Start();
            }
        }
Example #21
0
        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            if (!loaded)
            {
                if (!App.HasBeenStarted)
                {
                    MessageBox.Show(Langs.AppResources.MsgBoxStart);
                    App.HasBeenStarted = true;
                }
                toMorse            = true;
                radioT2m.IsChecked = true;
                txtToMorsefy_TextChanged(null, null);

                dot    = SoundEffect.FromStream(TitleContainer.OpenStream("Sound/dot.wav"));
                dash   = SoundEffect.FromStream(TitleContainer.OpenStream("Sound/dash.wav"));
                shortp = SoundEffect.FromStream(TitleContainer.OpenStream("Sound/smpause.wav"));
                FrameworkDispatcher.Update();

                loaded = true;
            }
        }
Example #22
0
        /// <summary>
        /// Updates the XNA FrameworkDispatcher and checks to see if a sound is playing.
        /// If sound has stopped playing, it updates the UI.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void dt_Tick(object sender, EventArgs e)
        {
            try { FrameworkDispatcher.Update(); }
            catch
            { }

            if (_soundIsPlaying)
            {
                if (_soundInstance.State != SoundState.Playing)
                {
                    // Audio has finished playing
                    _soundIsPlaying = false;

                    // Update the UI to reflect that the
                    // sound has stopped playing
                    SetButtonStates(true, true, false, true);
                    UserHelp.Text      = "press play or save to exit";
                    StatusImage.Source = _blankImage;
                }
            }
        }
Example #23
0
        public void SetBackgroundMusic(Song song)
        {
            if (!song.Equals(music))
            {
                music = song;
                if (IsMusic)
                {
                    try
                    {
#if WP7
                        FrameworkDispatcher.Update();
#endif
                        MediaPlayer.Volume = 0;
                        MediaPlayer.Play(music);
                        MediaPlayer.Pause();
                        state = MusicState.Pause;
                    }
                    catch { }
                }
            }
        }
        /// <summary>
        /// Constructor for the Application object.
        /// </summary>
        public App()
        {
            xnaTimer = new DispatcherTimer {
                Interval = TimeSpan.FromMilliseconds(16)
            };
            xnaTimer.Tick += (sender, e) => FrameworkDispatcher.Update();
            xnaTimer.Start();

            // Global handler for uncaught exceptions.
            UnhandledException += Application_UnhandledException;

            // Standard XAML initialization
            InitializeComponent();

            // Phone-specific initialization
            InitializePhoneApplication();

            // Language display initialization
            InitializeLanguage();

            // Show graphics profiling information while debugging.
            if (Debugger.IsAttached)
            {
                // Display the current frame rate counters.
                Application.Current.Host.Settings.EnableFrameRateCounter = true;

                // Show the areas of the app that are being redrawn in each frame.
                //Application.Current.Host.Settings.EnableRedrawRegions = true;

                // Enable non-production analysis visualization mode,
                // which shows areas of a page that are handed off to GPU with a colored overlay.
                //Application.Current.Host.Settings.EnableCacheVisualization = true;

                // Prevent the screen from turning off while under the debugger by disabling
                // the application's idle detection.
                // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
                // and consume battery power when the user is not using the phone.
                PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
            }
        }
        private void Checkbox_Reve_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                FrameworkDispatcher.Update();
                Random rand = new Random();
                Current_NowPlaying = rand.Next() % List_NowPlaying.Count;
                if (Bool_Play == true)
                {
                    switch (MediaPlayer.State)
                    {
                    case MediaState.Paused:
                    case MediaState.Playing:
                        Btn_Play.Content = ";";
                        PlaySong();
                        break;

                    case MediaState.Stopped:
                        break;
                    }
                }
                else
                {
                    switch (BackgroundAudioPlayer.Instance.PlayerState)
                    {
                    case PlayState.Paused:
                    case PlayState.Playing:
                        Btn_Play.Content = ";";
                        DTimer.Start();
                        PlaySong();
                        break;

                    case PlayState.Stopped:
                        break;
                    }
                }
            }
            catch { }
        }
Example #26
0
        private SoundUtilities()
        {
            LoadSound("Resources/Sounds/appbar.clicked.wav", out _appbarClickedSound);
            LoadSound("Resources/Sounds/note.wav", out _noteSound);
            LoadSound("Resources/Sounds/slipping.wav", out _slippingSound);
            LoadSound("Resources/Sounds/calendar.panel.start.wav", out _calendarPanelStart);
            LoadSound("Resources/Sounds/calendar.panel.end.wav", out _calendarPanelEnd);
            LoadSound("Resources/Sounds/school.bell.wav", out _schoolBellSound);
            LoadSound("Resources/Sounds/chaotic.wav", out _chaoticSound);
            LoadSound("Resources/Sounds/ding.tone.wav", out _dingToneSound);

            // Timer to simulate the XNA game loop (SoundEffect classes are from the XNA Framework)
            DispatcherTimer XnaDispatchTimer = new DispatcherTimer();

            XnaDispatchTimer.Interval = TimeSpan.FromMilliseconds(50);

            // Call FrameworkDispatcher.Update to update the XNA Framework internals.
            XnaDispatchTimer.Tick += delegate { try { FrameworkDispatcher.Update(); } catch { } };

            // Start the DispatchTimer running.
            XnaDispatchTimer.Start();
        }
Example #27
0
        private void RetrieveAudio(object sender, EventArgs e)
        {
            try { FrameworkDispatcher.Update(); }
            catch
            {
                // ignored
            }

            if (!wasapiIsEnabled)
            {
                return;
            }

            // XnaAudio stores the buffer in callback method.
            // Buffer is retrieved manually when recording using WASAPI.
            byte[] bytes;
            var    size = wasapiAudio.ReadBytes(out bytes);

            if (size > 0)
            {
                OnAudioReported(bytes);
            }
        }
        public void CallOnAnotherThread()
        {
            // Ensure that FrameworkDispatcher is initialized on the main thread.
            FrameworkDispatcher.Update();

            _callOnAnotherThreadResult = CallOnAnotherThreadTestResult.NotRun;

            var thread = new Thread(() => {
                _callOnAnotherThreadResult = CallOnAnotherThreadTestResult.Exception;
                FrameworkDispatcher.Update();

                // If executing this line, no exception was thrown.
                _callOnAnotherThreadResult = CallOnAnotherThreadTestResult.NoException;
            });

            thread.Start();
            if (!thread.Join(1000))
            {
                Assert.Fail("Secondary thread did not terminate in time.");
            }

            Assert.AreEqual(CallOnAnotherThreadTestResult.NoException, _callOnAnotherThreadResult);
        }
        public RoadMode()
        {
            InitializeComponent();
            geoWatcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
            geoWatcher.MovementThreshold = 10.0f;
            clearLayer();
            loadDictionary();
            tbxStatus.Visibility = Visibility.Collapsed;
            new Thread(startLocServInBackground).Start();
            Location location = new Location();

            LoadSound("Resources/Sound/Alight.wav", out alarmSound);
            DispatcherTimer XnaDispatchTimer = new DispatcherTimer();

            XnaDispatchTimer.Interval = TimeSpan.FromMilliseconds(50);
            XnaDispatchTimer.Tick    += delegate { try { FrameworkDispatcher.Update(); } catch { } };
            XnaDispatchTimer.Start();
            setLang();
            lbxStart.Visibility       = Visibility.Collapsed;
            lbxDestination.Visibility = Visibility.Collapsed;
            lbxIternary.Visibility    = Visibility.Collapsed;
            gdShow.Visibility         = Visibility.Collapsed;
        }
Example #30
0
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            InitializeField();

            disImgPath = new string[11] {
                "1.jpg", "2.jpg", "3.jpg", "4.jpg", "5.jpg", "6.jpg", "7.jpg", "8.jpg", "9.jpg", "10.jpg", "11.jpg"
            };
            imgPath = new string[11] {
                "H1.jpg", "H2.jpg", "H3.jpg", "H4.jpg", "H5.jpg", "H6.jpg", "H7.jpg", "H8.jpg", "H9.jpg", "H10.jpg", "H11.jpg"
            };

            lstImg = new Image[44] {
                img02, img03, img05, img06, img08, img09, img10, img11, img12, img13, img14, img15, img16, img17, img18, img19, img20, img21, img22, img23, img24, img25, img26, img27, img28, img29, img30, img31, img32, img33, img34, img35, img36, img37, img38, img39, img40, img41, img42, img44, img45, img46, img47, img48,
            };

            effectPutDown   = SoundEffect.FromStream(TitleContainer.OpenStream("Audio/putdown.wav"));
            effectWaterDown = SoundEffect.FromStream(TitleContainer.OpenStream("Audio/waterdown.wav"));
            FrameworkDispatcher.Update();
            ShowPicReady();

            ChooseGameLevel();
        }