Пример #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Generate the SystemSound instance with the NSUrl
            systemSound = new AudioToolbox.SystemSound(NSUrl.FromFilename("Sounds/tap.aif"));
        }
Пример #2
0
        private void TimerOnTick(object state)
        {
            if (!_start)
            {
                return;
            }

            // Do in UI Thread
            InvokeOnMainThread(() =>
            {
                _remain = _remain.Add(TimeSpan.FromMilliseconds(-100));

                // if not remain (= zero seconds), change button status and alert
                if (_remain.TotalSeconds <= 0)
                {
                    _start  = !_start;
                    _remain = new TimeSpan(0);
                    StartButton.SetTitle("Start", UIControlState.Normal);

                    // alert
                    var sound = new AudioToolbox.SystemSound(1005); // 1005 is alert
                    sound.PlayAlertSound();
                }

                // update remain time
                ShowRemain();
            });
        }
Пример #3
0
        public static void Error()
        {
#if __ANDROID__
            Android.Media.ToneGenerator toneGenerator = new Android.Media.ToneGenerator(Android.Media.Stream.Music, 100);
            toneGenerator.StartTone(Android.Media.Tone.CdmaPip, 150);
#elif __IOS__
            AudioToolbox.SystemSound systemSound = systemSound = new AudioToolbox.SystemSound(1000);
            systemSound.PlaySystemSound();
#endif
        }
Пример #4
0
        //タイマーイベント
        private void Timer_OnTick(object state)
        {
            if (!_isStart)
            {
                return;
            }

            InvokeOnMainThread(() =>
            {
                _remainingTime = _remainingTime.Add(TimeSpan.FromMilliseconds(-100));
                if (_remainingTime.TotalSeconds <= 0)
                {
                    //0秒になった
                    _isStart       = false;
                    _remainingTime = new TimeSpan(0);
                    StartButton.SetTitle("スタート", UIControlState.Normal);

                    //アラームを鳴らす
                    var sound = new AudioToolbox.SystemSound(1005);
                    sound.PlayAlertSound();
                }
                ShowRemainingTime();
            });
        }
Пример #5
0
        public override void CommitEditingStyle(UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath)
        {
            if (editingStyle == UITableViewCellEditingStyle.Insert)
            {
                //user clicks the bar button item whateevr he has already favourit as in whaterver exists withint the applications delegate list if the strin already exist the editing saccessory style becomes delete

                if (this.application.localizedTextFamily.Count((string arg) => arg.ToString() == this.familyDict[indexPath.Row]) >= 1)
                {
                    UIAlertController alreadyFavourited = UIAlertController.Create("Already favourited!", "You have already favourited this phrase!", UIAlertControllerStyle.Alert);

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

                    alreadyFavourited.AddAction(confirmed);


                    if (this.PresentedViewController == null)
                    {
                        this.PresentViewController(alreadyFavourited, true, () =>
                        {
                            AudioToolbox.SystemSound sound = new AudioToolbox.SystemSound(4095);
                            sound.PlaySystemSound();
                        });
                    }
                    else
                    {
                        this.PresentedViewController.DismissViewController(true, () =>
                        {
                            this.PresentedViewController.Dispose();
                            this.PresentViewController(alreadyFavourited, true, () =>
                            {
                                AudioToolbox.SystemSound sound = new AudioToolbox.SystemSound(4095);
                                sound.PlaySystemSound();
                            });
                        });
                    }

                    Console.WriteLine("The object already exists inside the list");
                }

                else if (this.application.localizedTextFamily.Count((string arg) => arg.ToString() == this.familyDict[indexPath.Row]) == 0)
                {
                    this.application.localizedTextFamily.Add(this.familyDict[indexPath.Row]);
                    this.application.frenchTextFamily.Add(this.familyTranslatedDict[indexPath.Row]);
                    this.application.indexPathsRegister.Add(indexPath);
                    this.application.indexPathsInt.Add(indexPath.Row);
                    this.favouritesIndicator = new UILabel();

                    this.favouritesIndicator.Text                      = this.favouritesButton.Title;
                    this.favouritesIndicator.MinimumFontSize           = 20.0f;
                    this.favouritesIndicator.AdjustsFontSizeToFitWidth = true;
                    this.favouritesIndicator.Frame                     = new CoreGraphics.CGRect(0, 20, 40, 40);


                    NSIndexPath        index       = indexPath;
                    List <NSIndexPath> indexChosen = new List <NSIndexPath>()
                    {
                    };
                    indexChosen.Add(index);

                    List <int> indexInt = new List <int>()
                    {
                    };
                    indexInt.Add(indexPath.Row);

                    this.application.indexIntFamily.Add(indexPath.Row);

                    this.application.indexTableFamily = index;

                    this.TableView.ReloadData();
                }
            }
            else if (editingStyle == UITableViewCellEditingStyle.Delete)
            {
                if (this.application.indexIntFamily.Contains(indexPath.Row) == true)
                {
                    this.application.localizedTextFamily.RemoveAll((string obj) => obj == this.familyDict[indexPath.Row]);
                    this.application.indexIntFamily.RemoveAll((int obj) => obj == indexPath.Row);

                    this.application.favourites.RemoveAll((string obj) => obj == this.familyDict[indexPath.Row]);
                    this.application.favouritesFrench.RemoveAll((string obj) => obj == this.familyTranslatedDict[indexPath.Row]);

                    if (this.application.indexTableFamily.Row == indexPath.Row || this.application.indexTableFamily.Row != indexPath.Row)
                    {
                        this.application.cellFamily.AccessoryView        = null;
                        this.application.cellFamily.EditingAccessoryView = null;
                        this.TableView.ReloadData();
                    }

                    if (this.application.localizedTextFamily.Count == 1)
                    {
                        this.TableView.ReloadData();
                    }

                    if (this.application.cellFamily.EditingStyle == UITableViewCellEditingStyle.Insert)
                    {
                        this.application.cellFamily.AccessoryView        = null;
                        this.application.cellFamily.EditingAccessoryView = null;
                        this.TableView.ReloadData();
                    }

                    /*if (this.application.localizedText.Count == 0)
                     * {
                     *      if (this.application.cellBusiness.AccessoryView != null)
                     *      {
                     *              this.application.cellBusiness.AccessoryView = null;
                     *              this.application.cellBusiness.EditingAccessoryView = null;
                     *              this.TableView.ReloadData();
                     *      }
                     * }*/
                }
                else
                {
                    this.application.cellFamily.AccessoryView        = null;
                    this.application.cellFamily.EditingAccessoryView = null;
                    this.TableView.ReloadData();
                }
                //this.application.localizedText.RemoveAt(this.companyDict.IndexOf(this.companyDict[indexPath.Row]));
                //this.application.indexInt.RemoveAt(this.companyDict.IndexOf(this.companyDict[indexPath.Row]));
                //tableView.ReloadData();
                this.TableView.ReloadData();
            }
        }