コード例 #1
0
ファイル: ChatViewController.cs プロジェクト: llenroc/chatty
        public override void ViewWillDisappear(bool animated)
        {
            base.ViewWillDisappear(animated);

            if (_cts0 != null)
            {
                _cts0.Cancel();
            }

            if (_cts1 != null)
            {
                _cts1.Cancel();
            }

            if (_cts2 != null)
            {
                _cts2.Cancel();
            }

            if (_sound != null)
            {
                _sound.Dispose();
                _sound = null;
            }

            this.SendButton.TouchUpInside -= SendButton_TouchUpInside;

            ((AppDelegate)UIApplication.SharedApplication.Delegate).PushNotificationReceived -= Application_PushNotificationReceived;
        }
コード例 #2
0
 internal void BeepOrVibrate()
 {
     if (!_isSilent)
     {
         SystemSound.FromFile("Sounds/beep.wav").PlayAlertSound();
     }
 }
コード例 #3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            // Generate the NSUrl to the sound file
            var url = NSUrl.FromFilename ("Sounds/tap.aif");

            // Generate the SystemSound instance with the NSUrl
            SystemSound newSound = new SystemSound (url);

            // This handles the playSystemButton being pressed
            playSystemButton.TouchUpInside += (object sender, EventArgs e) => {
                // Plays the sound
                newSound.PlaySystemSound();

            };

            // This handles the playAlertButton being pressed
            playAlertButton.TouchUpInside += (object sender, EventArgs e) => {
                // PlayAlertSound Plays the sound as well as vibrates
                newSound.PlayAlertSound();

            };

            // This handles the VibrateButton being pressed
            VibrateButton.TouchUpInside += (object sender, EventArgs e) => {
                // Just vibrates the device
                SystemSound.Vibrate.PlaySystemSound ();
            };
        }
コード例 #4
0
        protected override void OnDetached()
        {
            _toucheController.TouchBegin  -= OnTouchBegin;
            _toucheController.TouchEnd    -= OnTouchEnd;
            _toucheController.TouchCancel -= OnTouchEnd;

            _view.RemoveGestureRecognizer(_touchRecognizer);
            _touchRecognizer.Delegate?.Dispose();
            _touchRecognizer.Delegate = null;
            _touchRecognizer.Dispose();

            _touchRecognizer  = null;
            _toucheController = null;

            _layer.RemoveFromSuperview();
            _layer.Dispose();
            _layer = null;

            _clickSound?.Dispose();
            _clickSound = null;

            _view = null;

            System.Diagnostics.Debug.WriteLine($"Detached {GetType().Name} from {Element.GetType().FullName}");
        }
コード例 #5
0
        public void Play(string mediaName)
        {
            var url         = NSUrl.FromFilename(@"Sounds/" + mediaName);
            var systemSound = new SystemSound(url);

            systemSound.PlaySystemSound();
        }
コード例 #6
0
        public void FromFile()
        {
#if MONOMAC
            var path = NSBundle.MainBundle.PathForResource("1", "caf", "AudioToolbox");
#else
            var path = Path.GetFullPath(Path.Combine("AudioToolbox", "1.caf"));

            if (Runtime.Arch == Arch.SIMULATOR)
            {
                Assert.Ignore("PlaySystemSound doesn't work in the simulator");
            }
#endif

            using (var ss = SystemSound.FromFile(NSUrl.FromFilename(path))) {
                var       completed = false;
                const int timeout   = 10;

                Assert.AreEqual(AudioServicesError.None, ss.AddSystemSoundCompletion(delegate {
                    completed = true;
                }));

                ss.PlaySystemSound();
                Assert.IsTrue(MonoTouchFixtures.AppDelegate.RunAsync(DateTime.Now.AddSeconds(timeout), async() => { }, () => completed), "PlaySystemSound");
            }
        }
コード例 #7
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Generate the NSUrl to the sound file
            var url = NSUrl.FromFilename("Sounds/tap.aif");

            // Generate the SystemSound instance with the NSUrl
            SystemSound newSound = new SystemSound(url);


            // This handles the playSystemButton being pressed
            playSystemButton.TouchUpInside += (object sender, EventArgs e) => {
                // Plays the sound
                newSound.PlaySystemSound();
            };


            // This handles the playAlertButton being pressed
            playAlertButton.TouchUpInside += (object sender, EventArgs e) => {
                // PlayAlertSound Plays the sound as well as vibrates
                newSound.PlayAlertSound();
            };

            // This handles the VibrateButton being pressed
            VibrateButton.TouchUpInside += (object sender, EventArgs e) => {
                // Just vibrates the device
                SystemSound.Vibrate.PlaySystemSound();
            };
        }
コード例 #8
0
 private void Toast(string msg, Color background, Color foreground, SystemSound sound = null)
 {
     if (Height <= 100)
     {
         return;
     }
     if (_toasting)
     {
         return;
     }
     _toasting = true;
     if (cbToastSounds.Checked)
     {
         if (sound == null)
         {
             sound = SystemSounds.Asterisk;
         }
         sound.Play();
     }
     toastMsg.InvokeIfRequired(() => {
         toastMsg.Text      = msg;
         toastMsg.ForeColor = foreground;
         toast.InvokeIfRequired(() => {
             toast.BackColor = background;
             toast.Show();
             toast.SlideToDestination(430, 2, () => {
                 Thread.Sleep(3000);
                 toast.SlideToDestination(520, 2, () => { _toasting = false; });
             });
         });
     });
 }
コード例 #9
0
        public void Asterisk_Get_ReturnsExpected()
        {
            SystemSound sound = SystemSounds.Asterisk;

            Assert.NotNull(sound);
            Assert.Same(sound, SystemSounds.Asterisk);
        }
コード例 #10
0
ファイル: UserDialog.cs プロジェクト: ywjb/Honorbuddy-434
        // We know this is clumsy, but its a .NET-ism --
        // Form widgets can *only* be controlled by the thread that creates them.
        // Thus, we make this guarantee by wrapping all creation & processing actions
        // in a method called by just one thread.  <sigh>
        private static void PopupDialogViaDelegate(AsyncCompletionToken completionToken,
                                                   string toonName,
                                                   string dialogTitle,
                                                   string dialogMessage,
                                                   string expiryActionName,
                                                   int expiryRemainingInSeconds,
                                                   bool isBotStopAllowed,
                                                   bool isStopOnContinue,
                                                   SystemSound soundCue,
                                                   int soundPeriodInSeconds)
        {
            UserDialogForm dialogForm = new UserDialogForm(completionToken,
                                                           toonName,
                                                           dialogTitle,
                                                           dialogMessage,
                                                           expiryActionName,
                                                           expiryRemainingInSeconds,
                                                           isBotStopAllowed,
                                                           isStopOnContinue,
                                                           soundCue,
                                                           soundPeriodInSeconds);

            // Popup the window--
            // We'd *really* like to make this dialog a child of the main Honorbuddy window.
            // By doing such, the dialog would be 'brought to the front' any time te Honorbuddy main
            // window was.
            // Alas, C#/WindowsForms disallows this because the main HB GUI and this dialog are
            // on separate threads.
            dialogForm.TopMost = true;
            dialogForm.Activate();
            dialogForm.ShowDialog();
        }
コード例 #11
0
        public static void Show(Window parent, string message, string header, string details, MessageBoxImage icon)
        {
            Icon        image = null;
            SystemSound sound = null;

            switch (icon)
            {
            case MessageBoxImage.Asterisk:
                image = SystemIcons.Asterisk;
                sound = SystemSounds.Asterisk;
                break;

            case MessageBoxImage.Error:
                image = SystemIcons.Error;
                sound = SystemSounds.Beep;
                break;

            case MessageBoxImage.Exclamation:
                image = SystemIcons.Exclamation;
                sound = SystemSounds.Exclamation;
                break;

            case MessageBoxImage.Question:
                image = SystemIcons.Question;
                sound = SystemSounds.Question;
                break;
            }
            var window = new DetailedMessageBox(parent, message, header, details, image.ToBitmap(), sound);

            window.ShowDialog();
        }
コード例 #12
0
        // We know this is clumsy, but its a .NET-ism --
        // Form widgets can *only* be controlled by the thread that creates them.
        // Thus, we make this guarantee by wrapping all creation & processing actions
        // in a method called by just one thread.  <sigh>
        private static void PopupDialogViaDelegate(AsyncCompletionToken completionToken,
                                                   string toonName,
                                                   string dialogTitle,
                                                   string dialogMessage,
                                                   string expiryActionName,
                                                   int expiryRemainingInSeconds,
                                                   bool isBotStopAllowed,
                                                   bool isStopOnContinue,
                                                   SystemSound soundCue,
                                                   int soundPeriodInSeconds)
        {
            UserDialogForm dialogForm = new UserDialogForm(completionToken,
                                                           toonName,
                                                           dialogTitle,
                                                           dialogMessage,
                                                           expiryActionName,
                                                           expiryRemainingInSeconds,
                                                           isBotStopAllowed,
                                                           isStopOnContinue,
                                                           soundCue,
                                                           soundPeriodInSeconds);

            // Making the main Honorbuddy window the popup's parent--
            // This will bring the popup window to the front any time Honorbuddy is brought to the front.
            Form windowParent = (Form)Control.FromHandle(Process.GetCurrentProcess().MainWindowHandle);

            // Popup the window
            dialogForm.Activate();
            dialogForm.ShowDialog(windowParent);
        }
コード例 #13
0
ファイル: UserDialog.cs プロジェクト: ywjb/Honorbuddy-434
        public AsyncCompletionToken(string toonName,
                                    string dialogTitle,
                                    string dialogMessage,
                                    string expiryActionName,
                                    int expiryRemainingInSeconds,
                                    bool isBotStopAllowed,
                                    bool isStopOnContinue,
                                    SystemSound soundCue,
                                    int soundPeriodInSeconds)
        {
            _dialogDelegate  = new UserDialogDelegate(PopupDialogViaDelegate);
            _isAutoDefend    = true;
            _popdownRequest  = PopdownReason.UNKNOWN;
            _popdownResponse = PopdownReason.UNKNOWN;

            _actResult = _dialogDelegate.BeginInvoke(this,
                                                     toonName,
                                                     dialogTitle,
                                                     dialogMessage,
                                                     expiryActionName,
                                                     expiryRemainingInSeconds,
                                                     isBotStopAllowed,
                                                     isStopOnContinue,
                                                     soundCue,
                                                     soundPeriodInSeconds,
                                                     null,
                                                     null);
        }
コード例 #14
0
        public void Beep_Get_ReturnsExpected()
        {
            SystemSound sound = SystemSounds.Beep;

            Assert.NotNull(sound);
            Assert.Same(sound, SystemSounds.Beep);
        }
コード例 #15
0
        public void Play(string path)
        {
            NSUrl       url         = NSUrl.FromFilename("Sounds/tap.aif");
            SystemSound systemSound = new SystemSound(url);

            systemSound.PlaySystemSound();
        }
コード例 #16
0
        public void Hand_Get_ReturnsExpected()
        {
            SystemSound sound = SystemSounds.Hand;

            Assert.NotNull(sound);
            Assert.Same(sound, SystemSounds.Hand);
        }
コード例 #17
0
        public override void MotionEnded(UIEventSubtype motion, UIEvent evt)
        {
            if (evt.Type == UIEventType.Motion)
            {
                UIAlertController helpControl = UIAlertController.Create("Need Help?", "On this page you will learn over 500 French phrases. Simply choose a category and have fun", UIAlertControllerStyle.Alert);

                UIAlertAction confirmed = UIAlertAction.Create("Cool", UIAlertActionStyle.Default, (Action) =>
                {
                    helpControl.Dispose();
                });

                helpControl.AddAction(confirmed);

                if (this.PresentedViewController == null)
                {
                    SystemSound sound = new SystemSound(4095);
                    sound.PlaySystemSound();
                    this.PresentViewController(helpControl, true, null);
                }
                else if (this.PresentedViewController != null)
                {
                    this.PresentedViewController.DismissViewController(true, () =>
                    {
                        this.PresentedViewController.Dispose();
                        SystemSound sound = new SystemSound(4095);
                        sound.PlaySystemSound();
                        this.PresentViewController(helpControl, true, null);
                    });
                }
            }
        }
コード例 #18
0
        /// <summary>
        /// Plays the given system sound.
        /// </summary>
        /// <param name="sound"></param>
        public static void PlaySound(SystemSound sound)
        {
            switch (sound)
            {
            case SystemSound.Error:
                PlaySound("SystemHand");
                break;

            case SystemSound.SystemExit:
                PlaySound("SystemExit");
                break;

            case SystemSound.SystemStart:
                PlaySound("SystemStart");
                break;

            case SystemSound.Beep:
                PlaySound("SystemDefault");
                break;

            case SystemSound.Warning:
                PlaySound("SystemExclamation");
                break;

            case SystemSound.Question:
                PlaySound("SystemQuestion");
                break;

            default:
                throw new NotSupportedException(string.Format("Cannot handle '{0}' ({1}).", sound, sound.GetType()));
            }
        }
コード例 #19
0
        public void Question_Get_ReturnsExpected()
        {
            SystemSound sound = SystemSounds.Question;

            Assert.NotNull(sound);
            Assert.Same(sound, SystemSounds.Question);
        }
コード例 #20
0
        public static void PlaySound(string uri)
        {
            // Play the file
            var sound = SystemSound.FromFile(uri);

            sound.PlaySystemSound();
        }
コード例 #21
0
        //handles the event if the user entered the wrong password
        private void passwordIncorrect(string title, string message)
        {
            UIAlertController passwordIncController = UIAlertController.Create(title, message, UIAlertControllerStyle.Alert);

            UIAlertAction confirmed = UIAlertAction.Create("Ok", UIAlertActionStyle.Default, (UIAlertAction obj) =>
            {
                this.passwordTextField.Text = "";
                passwordIncController.Dispose();
            });

            passwordIncController.AddAction(confirmed);

            if (this.PresentedViewController == null)
            {
                this.PresentViewController(passwordIncController, true, () =>
                {
                    SystemSound errorSound = new SystemSound(4095);
                    errorSound.PlaySystemSound();
                });
            }
            else
            {
                this.PresentedViewController.DismissViewController(true, () =>
                {
                    this.PresentedViewController.Dispose();
                    this.PresentViewController(passwordIncController, true, () =>
                    {
                        SystemSound errorSound = new SystemSound(4095);
                        errorSound.PlaySystemSound();
                    });
                });
            }
        }
コード例 #22
0
 private void PlaySound()
 {
     if (!((Selectable)this).IsInteractable() || this.ClickSound < 0)
     {
         return;
     }
     SystemSound.Play((SystemSound.ECue) this.ClickSound);
 }
コード例 #23
0
ファイル: DeviceService.cs プロジェクト: uemegu/FNO
 public void PlayBeep()
 {
     if (_beep == null)
     {
         _beep = new SystemSound(1103);
     }
     _beep.PlaySystemSound();
 }
コード例 #24
0
 public void PlaySystemSound(SystemSound systemSound)
 {
     if (systemSound == null)
     {
         throw ExceptionUtils.GetArgumentNullException("systemSound");
     }
     systemSound.Play();
 }
コード例 #25
0
ファイル: ButtonEvent.cs プロジェクト: zunaalabaya/TAC-BOT
 public void PlaySe(ButtonEvent.Event ev)
 {
     if (ev.se < 0)
     {
         return;
     }
     SystemSound.Play((SystemSound.ECue)ev.se);
 }
コード例 #26
0
ファイル: DeviceService.cs プロジェクト: uemegu/FNO
 public void PlayVibrate()
 {
     if (_vibe == null)
     {
         _vibe = new SystemSound(1519);
     }
     _vibe.PlaySystemSound();
 }
コード例 #27
0
        public static bool PlaySound(SystemSound eSound)
        {
            //This uses PlaySound rather than MessageBeep because MessageBeep doesn't
            //work on Windows XP (at least not for me).
            string strFileName = GetSoundFileName(eSound);

            return(PlaySound(strFileName));
        }
コード例 #28
0
ファイル: DeviceService.cs プロジェクト: uemegu/FNO
 public void PlayNG()
 {
     if (_ng == null)
     {
         _ng = new SystemSound(1105);
     }
     _ng.PlaySystemSound();
 }
コード例 #29
0
ファイル: AudioHelper.cs プロジェクト: 15831944/winform-1
 /// <summary>
 /// 播放系统声音
 /// </summary>
 public static void PlaySystemSound(SystemSound systemSound)
 {
     if (systemSound == null)
     {
         throw new ArgumentNullException("systemSound");
     }
     systemSound.Play();
 }
コード例 #30
0
 /// <summary>
 ///     Plays a specific sound n times with delay of 500ms between them
 /// </summary>
 /// <param name="ss"></param>
 /// <param name="times"></param>
 public static void Play(this SystemSound ss, int times)
 {
     for (int i = 0; i < times; i++)
     {
         ss.Play();
         Thread.Sleep(500);
     }
 }
コード例 #31
0
 /// <summary>
 /// Called by the alert when it is stopped.
 /// </summary>
 protected override void OnStop()
 {
     if (sound != null)
     {
         sound.Close();
     }
     sound = null;
 }
コード例 #32
0
ファイル: AudioService.cs プロジェクト: kimuraeiji214/Keys
		public bool PlayWavFile(string fileName)
		{
			var url = NSUrl.FromFilename (fileName);

				systemSound = new SystemSound (url);
				systemSound.PlaySystemSound ();

			return true;
		}
コード例 #33
0
 public static void PlaySound(bool withVibrate, string fileName)
 {
     NSUrl	url = NSUrl.FromFilename (fileName);
     SystemSound systemSound = new SystemSound (url);
     if (withVibrate) {
         systemSound.PlayAlertSound ();
     } else {
         systemSound.PlaySystemSound ();
     }
 }
コード例 #34
0
        //prepares the audio
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            //enable audio
            AudioSession.Initialize();

            //load the sound
            Sound = SystemSound.FromFile("Sounds/tap.aif");
        }
コード例 #35
0
		//prepares the audio
		public override void ViewDidLoad () {
			base.ViewDidLoad ();
			
			//enable audio
			AudioSession.Initialize();
			
			//load the sound
			var url = NSBundle.MainBundle.URLForResource("tap", "aif");
			this._Sound = SystemSound.FromFile(url);
    		
		}
コード例 #36
0
ファイル: AudioService.cs プロジェクト: kimuraeiji214/Keys
		// Generate the SystemSound instance with the NSUrl

		public bool PlayMp3File(string fileName)
		{
			string newfilename=fileName.Replace("!","");
			var url = NSUrl.FromFilename (newfilename);
			//UIAlertView alert=new UIAlertView("title",newfilename,null,"cancel");
		//	alert.Show ();
			if (System.IO.File.Exists (newfilename)) {
				systemSound = new SystemSound (url);
				systemSound.PlaySystemSound ();
			} 
			 

			return true;
		}
コード例 #37
0
ファイル: Vibrator.cs プロジェクト: wnf0000/Wood
 public Vibrator()
 {
     vibrator = SystemSound.Vibrate;
     vibrator.CompletePlaybackIfAppDies = true;
     var cancel = false;
     AddMethod("vibrate", (core, args) =>
     {
         cancel = false;
         var pattern = args.GetPn<long[]>(0, null);
         if (pattern != null)
         {
             var repeat = args.GetPn(1, -1);
             var sleepArray = GetSleepArray(pattern);
             Task.Run(() =>
             {
                 for (int sleepIndex = 0; sleepIndex < sleepArray.Length; sleepIndex++)
                 {
                     if (cancel) break;
                     vibrator.PlaySystemSound();
                     if (sleepIndex == sleepArray.Length - 1)
                     {
                         if (repeat < 0) break;
                         sleepIndex = 0;
                     }
                 }
             });
         }
         else
         {
             //var duration = args.GetPn(0, 0);
             vibrator.PlaySystemSound();
         }
     });
     AddMethod("cancel", (core, args) =>
     {
         cancel = true;
         vibrator.Close();
     });
 }
コード例 #38
0
ファイル: SoundPlayer.cs プロジェクト: roblillack/monoberry
 private static string GetSoundName(SystemSound sound)
 {
     switch (sound) {
     case SystemSound.InputKeypress: return "input_keypress";
     case SystemSound.NotificationSapphire: return "notification_sapphire";
     case SystemSound.AlarmBattery: return "alarm_battery";
     case SystemSound.EventBrowserStart: return "event_browser_start";
     case SystemSound.EventCameraShutter: return "event_camera_shutter";
     case SystemSound.EventRecordingStart: return "event_recording_start";
     case SystemSound.EventRecordingStop: return "event_recording_stop";
     case SystemSound.EventDeviceLock: return "event_device_lock";
     case SystemSound.EventDeviceUnlock: return "event_device_unlock";
     case SystemSound.EventDeviceTether: return "event_device_tether";
     case SystemSound.EventDeviceUntether: return "event_device_untether";
     case SystemSound.EventVideoCall: return "event_video_call";
     case SystemSound.EventVideoCallOutgoing: return "event_video_call_outgoing";
     case SystemSound.SystemMasterVolumeReference: return "system_master_volume_reference";
     case SystemSound.NotificationGeneral:
     default:
         return "notification_general";
     }
 }
コード例 #39
0
ファイル: LightButton.cs プロジェクト: ogub4/Simon
        public async void doPush(int term)
        {
            if (this.cancelTokenSource != null)
            {
                this.cancelTokenSource.Cancel();
            }
            doLightOn();
            SystemSound systemSound = new SystemSound(this.soundFile);
            systemSound.PlaySystemSound();

            this.cancelTokenSource = new CancellationTokenSource();

            try 
            {
                await Task.Delay(term, cancelTokenSource.Token);
            }
            catch (OperationCanceledException ex)
            {

            }


            doLightOff();
        }
コード例 #40
0
        public void PlaySound(SystemSound sound)
        {
            string filename = null;

            switch (sound)
            {
                case SystemSound.WheelOut:
                    filename = "Sound_Wheel_Out.mp3";
                    break;
                case SystemSound.WheelIn:
                    filename = "Sound_Wheel_In.mp3";
                    break;
                case SystemSound.WheelJump:
                    filename = "Sound_Wheel_Jump.mp3";
                    break;
                case SystemSound.ScreenClick:
                    filename = "Sound_Screen_Click.mp3";
                    break;
                case SystemSound.ScreenIn:
                    filename = "Sound_Screen_In.mp3";
                    break;
                case SystemSound.ScreenOut:
                    filename = "Sound_Screen_Out.mp3";
                    break;
                case SystemSound.LetterClick:
                    filename = "Sound_Letter_Click.mp3";
                    break;
                default:
                    throw new Exception("Unsupported SystemSound: " + sound);
            }

            if (filename == null) throw new Exception("filename not set");

            _mediaElement.Source = new Uri(string.Format("{0}\\{1}", _sourceDir.TrimEnd(new char[] { '\\', '/' }), filename.TrimStart(new char[] { '\\', '/' })), UriKind.Absolute);
            _mediaElement.Play();
        }
コード例 #41
0
 public void PlayMp3File(string fileName)
 {
     var url = NSUrl.FromFilename (fileName);
     var systemSound = new SystemSound (url);
     systemSound.PlaySystemSound ();
 }
コード例 #42
0
ファイル: SoundPlayer.cs プロジェクト: roblillack/monoberry
 public static void Prepare(SystemSound sound)
 {
     soundplayer_prepare_sound (GetSoundName (sound));
 }
コード例 #43
0
ファイル: SoundService.cs プロジェクト: mwfricke/interval
 public void PlayCountDown()
 {
     var sound = new SystemSound(new NSUrl("sounds/boxing_bell.m4v"));
     sound.PlaySystemSound();
 }
コード例 #44
0
ファイル: SoundService.cs プロジェクト: mwfricke/interval
 public void PlayStart()
 {
     var sound = new SystemSound(new NSUrl("sounds/start.m4a"));
     //var sound = new SystemSound(new NSUrl("sounds/interval-startup-up.m4a"));
     sound.PlaySystemSound();
 }
コード例 #45
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            //enable audio
            AudioSession.Initialize();

            bombSound = SystemSound.FromFile("Bomb.wav");
            winSound = SystemSound.FromFile("success.wav");

            highScore = Convert.ToInt32(preferences.Get(HIGHSCOREKEY) ?? "0");

            blankTile = UIImage.FromBundle ("tile.png");
            mineTile = UIImage.FromBundle ("mine.png");
            flag = UIImage.FromBundle ("flag.png");
            coveredTile = UIImage.FromBundle ("covered.png");
            flaggedTile = UIImage.FromBundle ("flagged.png");
            cheatTile = UIImage.FromBundle ("cheat.png");
            redmineTile = UIImage.FromBundle ("redmine.png");
            flaggedCheatTile = UIImage.FromBundle ("flaggedcheat.png");
            questionTile = UIImage.FromBundle ("question.png");
            questionCheatTile = UIImage.FromBundle ("questioncheat.png");
            cheatIcon = UIImage.FromBundle ("magnifying_glass_20.png");

            numberTiles[0] = UIImage.FromBundle ("blank.png");
            numberTiles[1] = UIImage.FromBundle ("one.png");
            numberTiles[2] = UIImage.FromBundle ("two.png");
            numberTiles[3] = UIImage.FromBundle ("three.png");
            numberTiles[4] = UIImage.FromBundle ("four.png");
            numberTiles[5] = UIImage.FromBundle ("five.png");
            numberTiles[6] = UIImage.FromBundle ("six.png");
            numberTiles[7] = UIImage.FromBundle ("seven.png");
            numberTiles[8] = UIImage.FromBundle ("eight.png");

            cheatButton.TouchDown += delegate {
                cheating = true;
                game.ForceRedraw ();
            };

            cheatButton.TouchUpInside += delegate {
                cheating = false;
                game.ForceRedraw ();
            };

            cheatButton.TouchUpOutside += delegate {
                cheating = false;
                game.ForceRedraw ();
            };

            cheatButton.SetImage(cheatIcon, UIControlState.Normal);

            for (int col = 0; col < NUMCOLS; col++) {
                for (int row = 0; row < NUMROWS; row++) {
                    var frame = new RectangleF (STARTX + (col * (TILESIZE + GAPSIZE)), STARTY + (row * (TILESIZE + GAPSIZE)), TILESIZE, TILESIZE);
                    UIButton iv = UIButton.FromType(UIButtonType.Custom);
                    iv.Frame = frame;
                    tiles [col, row] = iv;
                    iv.BackgroundColor = UIColor.White;
                    View.Add (iv);
                    iv.UserInteractionEnabled = true;
                    iv.Tag = TagForTile (col, row);

                    iv.TouchDown += (sender, ea) => {
                        if (!gameOver) {
                            pressedTag = ((UIButton)sender).Tag;
                            pressTimer = new Timer(400);
                            pressTimer.Elapsed += OnTimerElapsed;
                            pressTimer.Start ();
                            pressType = SHORTPRESS;
                        }
                    };

                    iv.TouchUpInside += (sender, ea) => {
                        if (gameOver) {
                            StartGame ();
                        } else {
                            InvokeOnMainThread (() => flagImage.Image = blankTile);
                            if (pressTimer != null) {
                                pressTimer.Close();
                                pressTimer.Dispose();
                            }
                            HandlePress();
                        }
                    };

                    //iv.TouchesCancelled += (sender, ea) => {
                    //
                    //};

                    iv.TouchUpOutside += (sender, ea) => {
                        if (gameOver) {
                            StartGame ();
                        } else {
                            InvokeOnMainThread (() => flagImage.Image = blankTile);
                            if (pressTimer != null) {
                                pressTimer.Close();
                                pressTimer.Dispose();
                            }
                        }
                    };

                }
            }

            StartGame ();
        }
コード例 #46
0
ファイル: Utilities.cs プロジェクト: necora/ank_git
 public static bool PlaySound(SystemSound eSound)
 {
     //This uses PlaySound rather than MessageBeep because MessageBeep doesn't
     //work on Windows XP (at least not for me).
     string strFileName = GetSoundFileName(eSound);
     return PlaySound(strFileName);
 }
コード例 #47
0
ファイル: SoundPlayer.cs プロジェクト: roblillack/monoberry
 public static void Play(SystemSound sound)
 {
     soundplayer_play_sound (GetSoundName (sound));
 }
コード例 #48
0
ファイル: Utilities.cs プロジェクト: necora/ank_git
 private static string GetSoundFileName(SystemSound eSound)
 {
     switch (eSound)
     {
         case SystemSound.Error: return "SystemHand";
         case SystemSound.Question: return "SystemQuestion";
         case SystemSound.Warning: return "SystemExclamation";
         case SystemSound.Information: return "SystemAsterisk";
         case SystemSound.Default: return "SystemDefault";
         default: return ".Default";
     }
 }
コード例 #49
0
		public SoundEffect (string path)
		{
			sound = SystemSound.FromFile (new NSUrl (path, false));
		}
コード例 #50
0
		protected override void Dispose (bool disposing)
		{
			((IDisposable) sound).Dispose ();
			sound = null;
		}