Exemple #1
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();
                    });
                });
            }
        }
        public void Play(string path)
        {
            NSUrl       url         = NSUrl.FromFilename("Sounds/tap.aif");
            SystemSound systemSound = new SystemSound(url);

            systemSound.PlaySystemSound();
        }
Exemple #3
0
        public void Play(string mediaName)
        {
            var url         = NSUrl.FromFilename(@"Sounds/" + mediaName);
            var systemSound = new SystemSound(url);

            systemSound.PlaySystemSound();
        }
        private void Animate()
        {
            if (stopAnim)
            {
                return;
            }

            if (locationAnimations != null)
            {
                AnimationImage.Layer.RemoveAnimation("locAnim");
            }

            var locationAnimation = CABasicAnimation.FromKeyPath("opacity");

            locationAnimation.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseInEaseOut);
            locationAnimation.From           = NSNumber.FromFloat(GetAlpha());
            locationAnimation.To             = NSNumber.FromFloat(0.05f);

            var scaleAnimation = CABasicAnimation.FromKeyPath("transform.scale");

            scaleAnimation.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseInEaseOut);
            scaleAnimation.From           = NSNumber.FromFloat(1.1f);
            scaleAnimation.To             = NSNumber.FromFloat(1);;

            locationAnimations                   = CAAnimationGroup.CreateAnimation();
            locationAnimations.Duration          = GetAnimationDuration();
            locationAnimations.AutoReverses      = true;
            locationAnimations.Animations        = new CAAnimation[] { scaleAnimation, locationAnimation };
            locationAnimations.AnimationStopped += (sender, e) => {
                Animate();
            };

            AnimationImage.Layer.AddAnimation(locationAnimations, "locAnim");
            systemSound.PlaySystemSound();
        }
        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 ();
            };
        }
        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);
                    });
                }
            }
        }
        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();
            };
        }
Exemple #8
0
 public void PlayVibrate()
 {
     if (_vibe == null)
     {
         _vibe = new SystemSound(1519);
     }
     _vibe.PlaySystemSound();
 }
Exemple #9
0
 public void PlayBeep()
 {
     if (_beep == null)
     {
         _beep = new SystemSound(1103);
     }
     _beep.PlaySystemSound();
 }
Exemple #10
0
 public void PlayNG()
 {
     if (_ng == null)
     {
         _ng = new SystemSound(1105);
     }
     _ng.PlaySystemSound();
 }
Exemple #11
0
 private void PostNotification()
 {
     if (isStarted && sound != null)
     {
         sound.PlaySystemSound();
         ion.PostToMainDelayed(PostNotification, TimeSpan.FromSeconds(3));
     }
 }
Exemple #12
0
        public static void TriggerSoundAndViber(string audio)
        {
            NSUrl url = NSUrl.FromFilename(audio);
            //SystemSound notificationSound = SystemSound.FromFile(NotificationSoundPath);
            SystemSound mySound = new SystemSound(url);

            mySound.AddSystemSoundCompletion(SystemSound.Vibrate.PlaySystemSound);
            mySound.PlaySystemSound();
        }
Exemple #13
0
		public bool PlayWavFile(string fileName)
		{
			var url = NSUrl.FromFilename (fileName);

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

			return true;
		}
        // this only works if(full access is enabled;
        void playKeySound()
        {
            if (!NSUserDefaults.StandardUserDefaults.BoolForKey(kKeyboardClicks))
            {
                return;
            }
            SystemSound clickSound = new SystemSound(1104);

            clickSound.PlaySystemSound();
        }
 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 ();
     }
 }
Exemple #16
0
        public void PlaySystemSound()
        {
            AVAudioSession audioSession = AVAudioSession.SharedInstance();
            NSError        error;

            audioSession.OverrideOutputAudioPort(AVAudioSessionPortOverride.Speaker, out error);

            sound = new SystemSound(1151); //1304 (Alarm)
            sound.PlaySystemSound();
        }
        private void corruptController(int index)
        {
            var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            var directory = Directory.GetFiles(documents, "*.pdf");

            UIAlertController corruptAlert = UIAlertController.Create("Corrupt file cannot be opened!", "'" + Path.GetFileName(directory[index]) + "'" + " cannot be opened because it appears to be corrupt. Would you like to delete this file?", UIAlertControllerStyle.Alert);

            UIAlertAction confirmed = UIAlertAction.Create("No", UIAlertActionStyle.Destructive, (UIAlertAction obj) => {
                corruptAlert.Dispose();
            });

            UIAlertAction deleteFile = UIAlertAction.Create("Delete file", UIAlertActionStyle.Cancel, (UIAlertAction obj) => {
                File.Delete(directory[index]);
                this.pdfList.RemoveAt(index);
                this.creationDate.RemoveAt(index);
                this.thumbnailImage.RemoveAt(index);

                int indexCorrupt  = this.pdfList.IndexOf(this.pdfList[index]);
                int indexOfficial = this.corruptIndex.IndexOf(indexCorrupt);

                this.corruptIndex.RemoveAt(indexOfficial);
                this.TableView.ReloadData();

                //	this.corruptIndex.Clear();


                //why do i need to call on view didload again in order to proces any other corrupt files with broken packets
                //	this.ViewDidLoad();
            });

            corruptAlert.AddAction(confirmed);
            corruptAlert.AddAction(deleteFile);

            if (this.PresentedViewController == null)
            {
                this.PresentViewController(corruptAlert, true, () =>
                {
                    SystemSound sound = new SystemSound(4095);
                    sound.PlaySystemSound();
                });
            }
            else
            {
                this.PresentedViewController.DismissViewController(true, () =>
                {
                    this.PresentedViewController.Dispose();
                    this.PresentViewController(corruptAlert, true, () => {
                        SystemSound sound = new SystemSound(4095);
                        sound.PlaySystemSound();
                    });
                });
            }
        }
 /// <summary>
 /// iOS vibration support is quite limited,
 /// we can produce only very short vibration and one second vibration
 /// </summary>
 /// <param name="duration"></param>
 public async void Vibrate(TimeSpan duration)
 {
     if (duration.TotalMilliseconds < 200)
     {
         var pop = new SystemSound(PopSoundId);
         pop.PlaySystemSound();
     }
     else
     {
         SystemSound.Vibrate.PlaySystemSound();
     }
 }
Exemple #19
0
 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();
     });
 }
Exemple #20
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();
            }
        }
Exemple #21
0
		// 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;
		}
        private void NotificationSoundPicker_ValueChanged()
        {
            var sound = NotificationSoundPicker.Text.DehumanizeTo <Constants.NotificationSounds>();

            if (sound == Constants.NotificationSounds.SystemDefault)
            {
                return;
            }

            var soundFile    = Constants.NotificaitonSoundsMap[sound];
            var soundFileUrl = NSUrl.FromFilename(soundFile);
            var systemSound  = new SystemSound(soundFileUrl);

            systemSound.PlaySystemSound();
        }
 void CollisionHappend(SKNode Node1, SKNode Node2)
 {
     if (Node1.Name == "Bullet" && Node1.Parent == Application.GameSceneViewer)
     {
         Node1.RemoveFromParent();
         SKSpriteNode ExplosionNode = new SKSpriteNode("Explosion");
         ExplosionNode.Size     = new CGSize(20, 20);
         ExplosionNode.Position = Node1.Position;
         Application.GameSceneViewer.AddChild(ExplosionNode);
         CreateTimer((sender, e) => RemoveNodeFromParent(ExplosionNode), 200);
         int playerno = (Node2.Name == "Player1") ? 0 : 1;
         if (Node2.Name == "Player1" || Node2.Name == "Player2")
         {
             if (Players.PlayerLife[playerno] <= 1)
             {
                 Node2.RemoveFromParent();
                 SKSpriteNode RocketExplosionNode = new SKSpriteNode("Explosion");
                 RocketExplosionNode.Size     = new CGSize(50, 60);
                 RocketExplosionNode.Position = Node2.Position;
                 Application.GameSceneViewer.AddChild(RocketExplosionNode);
                 CreateTimer((sender, e) => RemoveNodeFromParent(RocketExplosionNode), 500);
                 /// end of game here
                 SystemSound systemSound = new SystemSound(1351);
                 systemSound.PlaySystemSound();
                 ///
                 CreateTimer(NextLevel, Application.GameSettings.TimeTillNextLevel);
             }
             Application.GameSceneViewer.ChangeLifeIndicator(playerno, Players.PlayerLife[playerno] - 1);
         }
     }
     if (Node1.Name == "Player1" || Node1.Name == "Player2")
     {
         int PlayerNo = (Node1.Name == "Player1") ? 0 : 1;
         if (Node2.Name == "DoubleGun" || Node2.Name == "Shield")
         {
             Node2.RemoveFromParent();
             if (Node2.Name == "DoubleGun")
             {
                 PlayerWepons[PlayerNo] = 2;
             }
         }
     }
 }
        //battery state to notify of a fully charged battery
        public void batteryStateNotifier()
        {
            UIDevice.CurrentDevice.BatteryMonitoringEnabled = true;

            switch (UIDevice.CurrentDevice.BatteryState)
            {
            case UIDeviceBatteryState.Full:
                if (UIDevice.CurrentDevice.BatteryLevel == 1.0)
                {
                    SystemSound fullBattery = new SystemSound(1006);
                    fullBattery.PlaySystemSound();
                    NSDate.FromTimeIntervalSinceNow(1.5);
                    englishAIBackground("Your device is fully charged");
                }
                break;

            default:
                break;
            }
        }
        private void OnSingleTap(object sender, EventArgs e)
        {
#if DEBUG
            Debug.WriteLine("OnSingleTap to " + mFlowView.Selected);
#endif

            mWaitCursor.StartAnimating();
            if (mPlaySounds)
            {
                mDrawStartSound.PlaySystemSound();
            }

            var thumbPath = mImgMgr.Thumbs(mFlowView.Selected);
            var imgPath   = mImgMgr.ImageByThumb(thumbPath);
            mDISVC.LoadImageByName(imgPath);

            mWaitCursor.StopAnimating();

            PresentModalViewController(mDISVC, true);
        }
Exemple #26
0
        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();
        }
        public override void ViewDidLoad()
        {
            this.NavigationController.NavigationBar.BackgroundColor = UIColor.White;
            this.NavigationItem.Title          = "My Documents";
            this.TableView.RowHeight           = 70.0f;
            this.appDelegate.documentsWord     = this;
            this.appDelegate.resultsStringWord = this.pdfList;
            UIStoryboard story = UIStoryboard.FromName("Main", NSBundle.MainBundle);

            this.appDelegate.PDF = story.InstantiateViewController("PDFReader") as PDFReader;

            this.searchController = new UISearchController(new resultsControllerWord());
            this.searchController.SearchResultsUpdater                 = new searchUpdatorWord(this);
            this.searchController.DimsBackgroundDuringPresentation     = true;
            this.searchController.HidesNavigationBarDuringPresentation = true;

            this.search = this.searchController.SearchBar;
            this.EdgesForExtendedLayout = UIRectEdge.None;

            this.search.Frame             = new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width - 5.0f, 50.0f);
            this.search.SpellCheckingType = UITextSpellCheckingType.No;
            this.search.BarStyle          = UIBarStyle.Default;
            this.search.SearchBarStyle    = UISearchBarStyle.Prominent;
            this.search.Placeholder       = "Search...";

            this.search.CancelButtonClicked += (object sender, EventArgs e) =>
            {
                this.search.ResignFirstResponder();
            };
            this.search.TextChanged += (object sender, UISearchBarTextChangedEventArgs e) =>
            {
                SystemSound keyboardClick = new SystemSound(1105);
                keyboardClick.PlaySystemSound();
            };

            this.search.SearchButtonClicked += (object sender, EventArgs e) =>
            {
                search.ResignFirstResponder();
            };

            this.TableView.TableHeaderView = search;

            var documents       = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            var directory       = Directory.GetFiles(documents, "*.doc");
            var directoryWord_2 = Directory.GetFiles(documents, "*.dot");
            var directoryWord_3 = Directory.GetFiles(documents, "*.odt");
            var directoryWord_4 = Directory.GetFiles(documents, "*.rtf");



            //other formats

            //excel
            var directoryExcel   = Directory.GetFiles(documents, "*.xsl");
            var directoryExcel_2 = Directory.GetFiles(documents, "*.xlt");

            //powerpoint
            var directoryPower = Directory.GetFiles(documents, "*.ppt");



            var fileName = Path.Combine(documents, "*.doc");

            this.appDelegate.directories = directory;

            NSError error = new NSError();

            try
            {
                if (NSFileManager.DefaultManager.GetDirectoryContent(documents, out error).Length == 0)
                {
                    throw new FileNotFoundException();
                }
                else
                {
                    //word formats
                    //.doc
                    for (int i = 0; i <= directory.Length - 1; i++)
                    {
                        try
                        {
                            if (directory[i] == null)
                            {
                                throw new ArgumentOutOfRangeException();
                            }
                            else
                            {
                                this.pdfList.Add(Path.GetFileName(directory[i]));
                                this.creationDate.Add(Convert.ToString(Directory.GetCreationTime(directory[i])));
                                addImageContext(directory, i);
                            }
                        }
                        catch (ArgumentOutOfRangeException)
                        {
                            Console.WriteLine("File does not exist");
                        }
                    }
                    //.dot
                    for (int i = 0; i <= directoryWord_2.Length - 1; i++)
                    {
                        try
                        {
                            if (directoryWord_2[i] == null)
                            {
                                throw new ArgumentOutOfRangeException();
                            }
                            else
                            {
                                this.pdfList.Add(Path.GetFileName(directoryWord_2[i]));
                                this.creationDate.Add(Convert.ToString(Directory.GetCreationTime(directoryWord_2[i])));
                                addImageContext(directoryWord_2, i);
                            }
                        }
                        catch (ArgumentOutOfRangeException)
                        {
                            Console.WriteLine("File does not exist");
                        }
                    }

                    //.odt
                    for (int i = 0; i <= directoryWord_3.Length - 1; i++)
                    {
                        try
                        {
                            if (directoryWord_3[i] == null)
                            {
                                throw new ArgumentOutOfRangeException();
                            }
                            else
                            {
                                this.pdfList.Add(Path.GetFileName(directoryWord_3[i]));
                                this.creationDate.Add(Convert.ToString(Directory.GetCreationTime(directoryWord_3[i])));
                                addImageContext(directoryWord_3, i);
                            }
                        }
                        catch (ArgumentOutOfRangeException)
                        {
                            Console.WriteLine("File does not exist");
                        }
                    }

                    //.rtf
                    for (int i = 0; i <= directoryWord_4.Length - 1; i++)
                    {
                        try
                        {
                            if (directoryWord_4[i] == null)
                            {
                                throw new ArgumentOutOfRangeException();
                            }
                            else
                            {
                                this.pdfList.Add(Path.GetFileName(directoryWord_4[i]));
                                this.creationDate.Add(Convert.ToString(Directory.GetCreationTime(directoryWord_4[i])));
                                addImageContext(directoryWord_4, i);
                            }
                        }
                        catch (ArgumentOutOfRangeException)
                        {
                            Console.WriteLine("File does not exist");
                        }
                    }

                    //excel formats
                    //.xsl

                    for (int i = 0; i <= directoryExcel.Length - 1; i++)
                    {
                        try
                        {
                            if (directoryExcel[i] == null)
                            {
                                throw new ArgumentOutOfRangeException();
                            }
                            else
                            {
                                this.pdfList.Add(Path.GetFileName(directoryExcel[i]));
                                this.creationDate.Add(Convert.ToString(Directory.GetCreationTime(directoryExcel[i])));
                                addImageContext(directoryExcel, i);
                            }
                        }
                        catch (ArgumentOutOfRangeException)
                        {
                            Console.WriteLine("File does not exist");
                        }
                    }

                    //xlt
                    for (int i = 0; i <= directoryExcel_2.Length - 1; i++)
                    {
                        try
                        {
                            if (directoryExcel_2[i] == null)
                            {
                                throw new ArgumentOutOfRangeException();
                            }
                            else
                            {
                                this.pdfList.Add(Path.GetFileName(directoryExcel_2[i]));
                                this.creationDate.Add(Convert.ToString(Directory.GetCreationTime(directoryExcel_2[i])));
                                addImageContext(directoryExcel_2, i);
                            }
                        }
                        catch (ArgumentOutOfRangeException)
                        {
                            Console.WriteLine("File does not exist");
                        }
                    }


                    //power points
                    //.ppt
                    for (int i = 0; i <= directoryPower.Length - 1; i++)
                    {
                        try
                        {
                            if (directoryPower[i] == null)
                            {
                                throw new ArgumentOutOfRangeException();
                            }
                            else
                            {
                                this.pdfList.Add(Path.GetFileName(directoryPower[i]));
                                this.creationDate.Add(Convert.ToString(Directory.GetCreationTime(directoryPower[i])));
                                addImageContext(directoryPower, i);
                            }
                        }
                        catch (ArgumentOutOfRangeException)
                        {
                            Console.WriteLine("File does not exist");
                        }
                    }
                }
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("Cannot find the specified pdf file in the library");
            }
        }
 partial void playSystemSound(NSObject sender)
 {
     Sound.PlaySystemSound();
 }
Exemple #29
0
        public override void ViewDidLoad()
        {
            this.applicationDelegate.instructionsShared = 1;

            this.applicationDelegate.passwordLog = this.passwordTextField;
            //this.applicationDelegate.navBar.Frame = new CGRect(0, this.View.Bounds.Top, UIScreen.MainScreen.Bounds.Width, this.applicationDelegate.navBar.Bounds.Height + 20);
            //this.View.AddSubview(this.applicationDelegate.navBar);

            this.NavigationController.SetNavigationBarHidden(false, false);

            if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
            {
                if (UIDevice.CurrentDevice.Orientation == UIDeviceOrientation.LandscapeLeft || UIDevice.CurrentDevice.Orientation == UIDeviceOrientation.LandscapeRight)
                {
                    this.passwordTextField.Frame = new CGRect(this.View.Bounds.Left + 5, this.View.Bounds.Top + 60.0f, UIScreen.MainScreen.Bounds.Width - 10.0f, 50);
                    lockImage.Frame = new CGRect(this.View.Center.X - 50.0f, this.View.Center.Y - 50.0f, 100, 100);
                    this.View.AddSubview(lockImage);
                }
                else if (UIDevice.CurrentDevice.Orientation == UIDeviceOrientation.Portrait || UIDevice.CurrentDevice.Orientation == UIDeviceOrientation.PortraitUpsideDown)
                {
                    this.passwordTextField.Frame = new CGRect(this.View.Bounds.Left + 5, this.View.Bounds.Top + 80.0f, UIScreen.MainScreen.Bounds.Width - 10.0f, 50);
                    lockImage.Frame = new CGRect(this.View.Center.X - 50.0f, this.View.Center.Y - 50.0f, 100, 100);
                    this.View.AddSubview(lockImage);
                }
            }
            else if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
            {
                if (UIDevice.CurrentDevice.Orientation == UIDeviceOrientation.LandscapeLeft || UIDevice.CurrentDevice.Orientation == UIDeviceOrientation.LandscapeRight)
                {
                    this.passwordTextField.Frame = new CGRect(this.View.Bounds.Left + 5, this.View.Bounds.Top + 80.0f, UIScreen.MainScreen.Bounds.Width - 10.0f, 50);
                }
                else if (UIDevice.CurrentDevice.Orientation == UIDeviceOrientation.Portrait || UIDevice.CurrentDevice.Orientation == UIDeviceOrientation.PortraitUpsideDown)
                {
                    this.passwordTextField.Frame = new CGRect(this.View.Bounds.Left + 5, this.View.Bounds.Top + 80.0f, UIScreen.MainScreen.Bounds.Width - 10.0f, 50);
                }
            }

            this.passwordTextField.EditingChanged += (object sender, EventArgs e) =>
            {
                SystemSound keyboardSound = new SystemSound(1105);
                keyboardSound.PlaySystemSound();
            };

            this.passwordTextField.ReturnKeyType = UIReturnKeyType.Go;

            this.passwordTextField.ShouldReturn += (UITextField textField) => {
                var memoryCache      = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                var filePathPassword = System.IO.Path.Combine(memoryCache, "password.txt");

                if (this.passwordTextField.Text != System.IO.File.ReadAllText(filePathPassword))
                {
                    //shared audio player must be set as a play and record setting

                    this.incorrectCount++;
                    if (this.incorrectCount <= 2)
                    {
                        passwordIncorrect("Incorrect password", "Please try again");
                    }
                    else if (this.incorrectCount == 3)
                    {
                        this.incorrectCount = 0;
                        this.passwordTextField.ResignFirstResponder();
                        this.passwordTextField.Text = "\ud83d\udd12 LOCKED";
                        passwordIncorrect("Vault is locked!", "Your vault is locked! You will have to wait 30 seconds for your vault to unlock again");
                        SystemSound alertSound = new SystemSound(1005);
                        if (this.PresentedViewController != null)
                        {
                            for (int i = 0; i <= 10000; i++)
                            {
                                alertSound.PlaySystemSound();
                                this.passwordTextField.UserInteractionEnabled = false;
                                this.passwordTextField.ResignFirstResponder();

                                if (i >= 10000)
                                {
                                    SystemSound unlockVault = new SystemSound(1101);
                                    unlockVault.PlaySystemSound();
                                    this.passwordTextField.Text = "";
                                    this.passwordTextField.UserInteractionEnabled = true;
                                    //passwordIncorrect("Vault is unlocked!", "You can now try to log in again");
                                }
                            }
                        }
                        else
                        {
                            Console.WriteLine("Controller is not yet presented");
                        }
                    }
                }
                else
                {
                    UIStoryboard story_2 = UIStoryboard.FromName("Main", NSBundle.MainBundle);

                    TabMaster vault = story_2.InstantiateViewController("TabMaster") as TabMaster;
                    this.NavigationController.PushViewController(vault, true);
                }
                return(true);
            };

            UIBarButtonItem confirmed = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (sender, e) =>
            {
                var memoryCache      = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                var filePathPassword = System.IO.Path.Combine(memoryCache, "password.txt");

                if (this.passwordTextField.Text != System.IO.File.ReadAllText(filePathPassword))
                {
                    //shared audio player must be set as a play and record setting

                    this.incorrectCount++;
                    if (this.incorrectCount <= 2)
                    {
                        passwordIncorrect("Incorrect password", "Please try again");
                    }
                    else if (this.incorrectCount == 3)
                    {
                        this.incorrectCount = 0;
                        this.passwordTextField.ResignFirstResponder();
                        this.passwordTextField.Text = "\ud83d\udd12 LOCKED";
                        passwordIncorrect("Vault is locked!", "Your vault is locked! You will have to wait 30 seconds for your vault to unlock again");
                        SystemSound alertSound = new SystemSound(1005);
                        if (this.PresentedViewController != null)
                        {
                            for (int i = 0; i <= 10000; i++)
                            {
                                alertSound.PlaySystemSound();
                                this.passwordTextField.UserInteractionEnabled = false;
                                this.passwordTextField.ResignFirstResponder();

                                if (i >= 10000)
                                {
                                    SystemSound unlockVault = new SystemSound(1101);
                                    unlockVault.PlaySystemSound();
                                    this.passwordTextField.Text = "";
                                    this.passwordTextField.UserInteractionEnabled = true;
                                    //passwordIncorrect("Vault is unlocked!", "You can now try to log in again");
                                }
                            }
                        }
                        else
                        {
                            Console.WriteLine("Controller is not yet presented");
                        }
                    }
                }
                else
                {
                    UIStoryboard story_2 = UIStoryboard.FromName("Main", NSBundle.MainBundle);

                    TabMaster vault = story_2.InstantiateViewController("TabMaster") as TabMaster;
                    this.NavigationController.PushViewController(vault, true);
                }
            });

            this.passwordTextField.Placeholder     = "Password";
            this.passwordTextField.ClearButtonMode = UITextFieldViewMode.Always;
            this.passwordTextField.SecureTextEntry = true;
            //this.applicationDelegate.password = this.passwordTextField.Text;

            this.passwordTextField.SpellCheckingType      = UITextSpellCheckingType.No;
            this.passwordTextField.AutocorrectionType     = UITextAutocorrectionType.No;
            this.passwordTextField.AutocapitalizationType = UITextAutocapitalizationType.None;
            this.passwordTextField.BorderStyle            = UITextBorderStyle.RoundedRect;

            this.passwordTextField.Layer.BorderWidth  = 0.2f;
            this.passwordTextField.Layer.BorderColor  = UIColor.Black.CGColor;
            this.passwordTextField.Layer.CornerRadius = 0.2f;

            this.View.BackgroundColor = UIColor.GroupTableViewBackgroundColor;

            this.NavigationItem.Title = "Vault Login";
            this.NavigationItem.SetRightBarButtonItem(confirmed, false);


            this.View.AddSubview(passwordTextField);
        }
Exemple #30
0
        public void PlaySystemSound()
        {
            var sound = new SystemSound(1000);

            sound.PlaySystemSound();
        }
Exemple #31
0
        public override void ViewDidLoad()
        {
            this.NavigationController.NavigationBar.BackgroundColor = UIColor.White;
            this.NavigationItem.Title           = "My Photos & Videos";
            this.TableView.RowHeight            = 70.0f;
            this.appDelegate.photo              = this;
            this.appDelegate.resultsStringPhoto = this.pdfList;
            UIStoryboard story = UIStoryboard.FromName("Main", NSBundle.MainBundle);

            this.appDelegate.photoReader = story.InstantiateViewController("PhotosReader") as PhotosReader;

            this.searchController = new UISearchController(new resultsControllerPhoto());
            this.searchController.SearchResultsUpdater                 = new searchUpdatorPhoto(this);
            this.searchController.DimsBackgroundDuringPresentation     = true;
            this.searchController.HidesNavigationBarDuringPresentation = true;

            this.search = this.searchController.SearchBar;
            this.EdgesForExtendedLayout = UIRectEdge.None;

            this.search.Frame             = new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width - 5.0f, 50.0f);
            this.search.SpellCheckingType = UITextSpellCheckingType.No;
            this.search.BarStyle          = UIBarStyle.Default;
            this.search.SearchBarStyle    = UISearchBarStyle.Prominent;
            this.search.Placeholder       = "Search...";

            this.search.CancelButtonClicked += (object sender, EventArgs e) =>
            {
                this.search.ResignFirstResponder();
            };
            this.search.TextChanged += (object sender, UISearchBarTextChangedEventArgs e) =>
            {
                SystemSound keyboardClick = new SystemSound(1105);
                keyboardClick.PlaySystemSound();
            };

            this.search.SearchButtonClicked += (object sender, EventArgs e) =>
            {
                search.ResignFirstResponder();
            };

            this.TableView.TableHeaderView = search;

            var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            var directoryJPG = Directory.GetFiles(documents, "*.jpg");
            var directoryPNG = Directory.GetFiles(documents, "*.png");
            var directoryGIF = Directory.GetFiles(documents, "*.gif");
            var directorySVG = Directory.GetFiles(documents, "*.svg");
            var directoryICO = Directory.GetFiles(documents, "*.ico");


            this.appDelegate.directories = directoryJPG;

            NSError error = new NSError();

            try
            {
                if (NSFileManager.DefaultManager.GetDirectoryContent(documents, out error).Length == 0)
                {
                    throw new FileNotFoundException();
                }
                else
                {
                    //Photo formats
                    //.jpg
                    for (int i = 0; i <= directoryJPG.Length - 1; i++)
                    {
                        try
                        {
                            if (directoryJPG[i] == null)
                            {
                                throw new ArgumentOutOfRangeException();
                            }
                            else
                            {
                                this.pdfList.Add(Path.GetFileName(directoryJPG[i]));
                                this.creationDate.Add(Convert.ToString(Directory.GetCreationTime(directoryJPG[i])));
                                addImageContext(directoryJPG, i);
                            }
                        }
                        catch (ArgumentOutOfRangeException)
                        {
                            Console.WriteLine("File does not exist");
                        }
                    }

                    //.png
                    for (int i = 0; i <= directoryPNG.Length - 1; i++)
                    {
                        try
                        {
                            if (directoryPNG[i] == null)
                            {
                                throw new ArgumentOutOfRangeException();
                            }
                            else
                            {
                                this.pdfList.Add(Path.GetFileName(directoryPNG[i]));
                                this.creationDate.Add(Convert.ToString(Directory.GetCreationTime(directoryPNG[i])));
                                addImageContext(directoryPNG, i);
                            }
                        }
                        catch (ArgumentOutOfRangeException)
                        {
                            Console.WriteLine("File does not exist");
                        }
                    }

                    //gif
                    for (int i = 0; i <= directoryGIF.Length - 1; i++)
                    {
                        try
                        {
                            if (directoryGIF[i] == null)
                            {
                                throw new ArgumentOutOfRangeException();
                            }
                            else
                            {
                                this.pdfList.Add(Path.GetFileName(directoryGIF[i]));
                                this.creationDate.Add(Convert.ToString(Directory.GetCreationTime(directoryGIF[i])));
                                addImageContext(directoryGIF, i);
                            }
                        }
                        catch (ArgumentOutOfRangeException)
                        {
                            Console.WriteLine("File does not exist");
                        }
                    }

                    //.svg
                    for (int i = 0; i <= directorySVG.Length - 1; i++)
                    {
                        try
                        {
                            if (directorySVG[i] == null)
                            {
                                throw new ArgumentOutOfRangeException();
                            }
                            else
                            {
                                this.pdfList.Add(Path.GetFileName(directorySVG[i]));
                                this.creationDate.Add(Convert.ToString(Directory.GetCreationTime(directorySVG[i])));
                                addImageContext(directorySVG, i);
                            }
                        }
                        catch (ArgumentOutOfRangeException)
                        {
                            Console.WriteLine("File does not exist");
                        }
                    }

                    //.ico
                    for (int i = 0; i <= directoryICO.Length - 1; i++)
                    {
                        try
                        {
                            if (directoryICO[i] == null)
                            {
                                throw new ArgumentOutOfRangeException();
                            }
                            else
                            {
                                this.pdfList.Add(Path.GetFileName(directoryICO[i]));
                                this.creationDate.Add(Convert.ToString(Directory.GetCreationTime(directoryICO[i])));
                                addImageContext(directoryICO, i);
                            }
                        }
                        catch (ArgumentOutOfRangeException)
                        {
                            Console.WriteLine("File does not exist");
                        }
                    }
                }
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("Cannot find the specified pdf file in the library");
            }

            if (this.pdfList.Count == 0)
            {
                emptyPDF = new UIView();

                emptyImage = new UIImageView();

                this.description      = new UILabel();
                this.description.Text = "This page contains no passwords. To get started adding";
                this.description.Font = UIFont.FromName("Georgia-Italic", 26.0f);

                this.description_2      = new UILabel();
                this.description_2.Text = "your own passwords click \ud83d\udcdd";
                this.description_2.Font = UIFont.FromName("Georgia-Italic", 26.0f);

                this.description_2.AdjustsFontSizeToFitWidth = true;
                this.description.AdjustsFontSizeToFitWidth   = true;

                this.titleDescription      = new UILabel();
                this.titleDescription.Text = "No Photos";
                this.titleDescription.Font = UIFont.SystemFontOfSize(26.0f);
                this.titleDescription.Font = UIFont.FromName("AmericanTypewriter-Bold", 26.0f);

                if (UIApplication.SharedApplication.StatusBarHidden == true)
                {
                    emptyPDF.Frame = new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height);

                    emptyImage.Frame = new CGRect(emptyPDF.Center.X - 100.0f, emptyPDF.Center.Y - 200.0f, 200, 200);

                    this.description.Frame   = new CGRect(this.View.Center.X - 315.0f, this.View.Center.Y, UIScreen.MainScreen.Bounds.Width - 50.0f, 50.0f);
                    this.description_2.Frame = new CGRect(this.View.Center.X - 155.0f, this.View.Center.Y + 50.0f, UIScreen.MainScreen.Bounds.Width - 210.0f, 50.0f);

                    this.titleDescription.Frame = new CGRect(this.View.Center.X - 70.0f, this.View.Center.Y - 180.0f, UIScreen.MainScreen.Bounds.Width - 50.0f, 300.0f);
                }
                else
                {
                    emptyPDF.Frame = new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height);

                    emptyImage.Frame = new CGRect(emptyPDF.Center.X - 100.0f, emptyPDF.Center.X - 95.0f, 200, 200);

                    this.description.Frame      = new CGRect(this.View.Center.X - 190.0f, this.View.Center.Y, UIScreen.MainScreen.Bounds.Width - 50.0f, 50.0f);
                    this.description_2.Frame    = new CGRect(this.View.Center.X - 95.0f, this.View.Center.Y + 50.0f, UIScreen.MainScreen.Bounds.Width - 210.0f, 50.0f);
                    this.titleDescription.Frame = new CGRect(this.View.Center.X - 70.0f, this.View.Center.Y - 240.0f, UIScreen.MainScreen.Bounds.Width - 50.0f, 300.0f);
                }

                emptyImage.Image = new UIImage("EmptyScreen.png");

                emptyPDF.AddSubview(emptyImage);
                emptyPDF.AddSubview(this.description);
                emptyPDF.AddSubview(this.description_2);
                emptyPDF.AddSubview(this.titleDescription);

                this.TableView.SeparatorColor  = UIColor.GroupTableViewBackgroundColor;
                this.TableView.TintColor       = UIColor.GroupTableViewBackgroundColor;
                this.TableView.TableHeaderView = null;

                this.Add(emptyPDF);
                this.View.BringSubviewToFront(emptyPDF);
            }
            else
            {
                this.TableView.SeparatorColor = UIColor.LightGray;
                this.TableView.TintColor      = UIColor.LightGray;

                //this.TableView.TableHeaderView = this.search;
                emptyPDF = new UIView();

                emptyImage = new UIImageView();

                emptyPDF.RemoveFromSuperview();
                emptyImage.RemoveFromSuperview();
            }
            this.emptyPDF.BackgroundColor = UIColor.GroupTableViewBackgroundColor;

            this.NavigationController.SetToolbarHidden(false, true);
            this.NavigationController.Toolbar.BarTintColor    = UIColor.White;
            this.NavigationController.Toolbar.BackgroundColor = UIColor.White;
            this.NavigationController.Toolbar.TintColor       = UIColor.Blue;

            UIBarButtonItem bin = new UIBarButtonItem(UIBarButtonSystemItem.Trash, (sender, e) =>
            {
                //pushes the password reader controller which allows the user to enter
                var documents_2 = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                //var passwordDirectory_2 = Path.Combine(documents, "Passwords");

                var directoryJPG_2 = Directory.GetFiles(documents, "*.jpg");
                var directoryPNG_2 = Directory.GetFiles(documents, "*.png");
                var directoryGIF_2 = Directory.GetFiles(documents, "*.gif");
                var directorySVG_2 = Directory.GetFiles(documents, "*.svg");
                var directoryICO_2 = Directory.GetFiles(documents, "*.ico");


                NSError error_2 = new NSError();
                if (this.pdfList.Count == 0)
                {
                    UIAlertController emptyPasswords = UIAlertController.Create("Nothing to delete", "You have no passwords listed here to delete", UIAlertControllerStyle.Alert);

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

                    emptyPasswords.AddAction(confirmed);

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

                //files do exist in the directory
                else
                {
                    if (this.TableView.Editing == false)
                    {
                        UIAlertController emptyPasswords = UIAlertController.Create("Clear your photos?", "Are you sure you want to clear the whole list of your photos?", UIAlertControllerStyle.Alert);

                        UIAlertAction confirmed = UIAlertAction.Create("Yes", UIAlertActionStyle.Destructive, (UIAlertAction obj) =>
                        {
                            //delete list for the table
                            //delete files contained inside the directory
                            this.pdfList.Clear();
                            this.creationDate.Clear();

                            Console.WriteLine("Number of files: " + NSFileManager.DefaultManager.GetDirectoryContent(documents_2, out error_2).Length);

                            //.jpg
                            for (int j = 0; j <= directoryJPG_2.Length - 1; j++)
                            {
                                File.Delete(directoryJPG_2[j]);
                            }

                            /*try
                             * {
                             *      if (String.IsNullOrEmpty(directoryJPG_2[NSFileManager.DefaultManager.GetDirectoryContent(documents_2, out error_2).Length - 1]) == true)
                             *      {
                             *              throw new IndexOutOfRangeException();
                             *      }
                             *      else {
                             *              File.Delete(directoryJPG_2[NSFileManager.DefaultManager.GetDirectoryContent(documents_2, out error_2).Length - 1]);
                             *      }
                             * }
                             * catch (IndexOutOfRangeException)
                             * {
                             *      Console.WriteLine("File does not exist inside this directory");
                             * }*/

                            //.png
                            for (int j = 0; j <= directoryPNG_2.Length - 1; j++)
                            {
                                File.Delete(directoryPNG_2[j]);
                            }

                            //.gif
                            for (int j = 0; j <= directoryGIF_2.Length - 1; j++)
                            {
                                File.Delete(directoryGIF_2[j]);
                            }

                            //.svg
                            for (int j = 0; j <= directorySVG_2.Length - 1; j++)
                            {
                                File.Delete(directorySVG_2[j]);
                            }

                            //.ico
                            for (int j = 0; j <= directoryICO_2.Length - 1; j++)
                            {
                                File.Delete(directoryICO_2[j]);
                            }

                            this.NavigationController.PopViewController(true);
                            emptyPasswords.Dispose();
                        });

                        UIAlertAction denied = UIAlertAction.Create("No", UIAlertActionStyle.Cancel, (UIAlertAction obj) =>
                        {
                            emptyPasswords.Dispose();
                        });

                        emptyPasswords.AddAction(confirmed);
                        emptyPasswords.AddAction(denied);

                        if (this.PresentedViewController == null)
                        {
                            this.PresentViewController(emptyPasswords, true, () =>
                            {
                                SystemSound soundError = new SystemSound(4095);
                                soundError.PlaySystemSound();
                            });
                        }
                        else
                        {
                            this.PresentedViewController.DismissViewController(true, () =>
                            {
                                this.PresentedViewController.Dispose();
                                this.PresentViewController(emptyPasswords, true, () =>
                                {
                                    SystemSound soundError = new SystemSound(4095);
                                    soundError.PlaySystemSound();
                                });
                            });
                        }
                    }
                    //table view is in editing mode
                    else
                    {
                        //bar button item will clear only the values that match the index chosen
                        for (int i = 0; i <= this.selectedCellsToRemove.Count - 1; i++)
                        {
                            this.pdfList.RemoveAt(i);
                            this.creationDate.RemoveAt(i);

                            Console.WriteLine("Contents: " + Directory.GetFiles(documents_2)[i]);
                            File.Delete(Directory.GetFiles(documents_2)[i]);
                            this.NavigationController.PopViewController(true);
                        }
                    }
                }
            });

            this.SetToolbarItems(new UIBarButtonItem[] { bin }, true);

            UIBarButtonItem cancelEditing = new UIBarButtonItem(UIBarButtonSystemItem.Done, (sender, e) =>
            {
                this.selectedCellsToRemove.Clear();
                this.TableView.SetEditing(false, true);
                this.NavigationItem.SetRightBarButtonItem(this.appDelegate.editPassword, true);
            });

            //nav bar items
            UIBarButtonItem edit = new UIBarButtonItem(UIBarButtonSystemItem.Edit, (object sender, EventArgs e) =>
            {
                //pushes the password reader controller which allows the user to enter
                var documents_2 = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

                var directoryJPG_3 = Directory.GetFiles(documents_2, "*.jpg");
                var directoryPNG_3 = Directory.GetFiles(documents_2, "*.png");
                var directoryGIF_3 = Directory.GetFiles(documents_2, "*.gif");
                var directorySVG_3 = Directory.GetFiles(documents_2, "*.svg");
                var directoryICO_3 = Directory.GetFiles(documents_2, "*.ico");

                NSError error_2 = new NSError();
                if (this.pdfList.Count == 0)
                {
                    UIAlertController emptyPasswords = UIAlertController.Create("Nothing to delete", "You have no passwords listed here to delete", UIAlertControllerStyle.Alert);

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

                    emptyPasswords.AddAction(confirmed);

                    if (this.PresentedViewController == null)
                    {
                        this.PresentViewController(emptyPasswords, true, () =>
                        {
                            SystemSound soundError = new SystemSound(4095);
                            soundError.PlaySystemSound();
                        });
                    }
                    else
                    {
                        this.PresentedViewController.DismissViewController(true, () =>
                        {
                            this.PresentedViewController.Dispose();
                            this.PresentViewController(emptyPasswords, true, () =>
                            {
                                SystemSound soundError = new SystemSound(4095);
                                soundError.PlaySystemSound();
                            });
                        });
                    }
                }
                else
                {
                    this.TableView.SetEditing(true, true);
                    this.NavigationItem.SetRightBarButtonItem(cancelEditing, true);
                }
            });

            this.appDelegate.editPassword = edit;
            this.NavigationItem.SetRightBarButtonItem(edit, false);

            this.TableView.AllowsSelection = true;
            this.TableView.AllowsSelectionDuringEditing         = true;
            this.TableView.AllowsMultipleSelectionDuringEditing = true;
            this.TableView.AllowsMultipleSelection = true;
        }
        public override void DidEnterBackground(UIApplication application)
        {
            UIStoryboard story = UIStoryboard.FromName("Main", NSBundle.MainBundle);
            VaultInstructionsController vaultInstructions = story.InstantiateViewController("VaultInstructionsController") as VaultInstructionsController;

            if (this.navMaster.VisibleViewController == vaultInstructions)
            {
                vaultInstructions.DismissViewController(true, null);
            }

            SystemSound soundLock = new SystemSound(1100);

            soundLock.PlaySystemSound();
            // Use this method to release shared resources, save user data, invalidate timers and store the application state.
            // If your application supports background exection this method is called instead of WillTerminate when the user quits.
            var memoryCache      = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            var filePathPassword = System.IO.Path.Combine(memoryCache, "password.txt");

            try
            {
                if (filePathPassword == null)
                {
                    throw new FileNotFoundException();
                }
                else
                {
                    if (String.IsNullOrEmpty(File.ReadAllText(filePathPassword)) == true)
                    {
                        if (this.navMaster.VisibleViewController != this.passwordFirstControl)
                        {
                            this.navMaster.PopToViewController(this.passwordFirstControl, true);
                        }
                        else
                        {
                            Console.WriteLine("Controller already exists");
                        }
                    }
                    else
                    {
                        if (this.navMaster.ViewControllers.Contains(this.password) == true)
                        {
                            if (this.navMaster.VisibleViewController != this.password)
                            {
                                this.passwordLog.Text = "";
                                this.passwordLog.ResignFirstResponder();
                                this.navMaster.PopToViewController(this.password, true);
                            }
                            else
                            {
                                Console.WriteLine("Controller already exists");
                            }
                        }
                        else
                        {
                            this.navMaster.PushViewController(this.password, true);
                        }
                    }
                }
            }
            catch (FileNotFoundException)
            {
                if (this.navMaster.VisibleViewController != this.passwordFirstControl)
                {
                    this.navMaster.PushViewController(this.passwordFirstControl, true);
                }
                else
                {
                    Console.WriteLine("Controller already exists");
                }
            }
        }
Exemple #33
0
using AVFoundation;
using ClubManagement.IBLL;
using Foundation;
using Radar.iOS;
using System;
using System.Collections.Generic;

using Xamarin.Forms;
using ClubManagement.Model;
using AudioToolbox;
using System.Threading.Tasks;
using CoreMedia;
using UIKit;

[assembly: Dependency(typeof(AudioiOS))]

namespace Radar.iOS
{
    public class AudioiOS : IAudio
    {
        float _volume = 15;
        AudioCanalEnum _canal = AudioCanalEnum.Nenhum;
        IList<string> _audioAtual = new List<string>();
        int _audioIndex = 0;
        AVAudioPlayer _player;

        public AudioCanalEnum Canal
        {
            get {
                return _canal;
            }

            set
            {
                _canal = value;
            }
        }

        public float Volume {
            get {
                return _volume;
            }
            set {
                _volume = value;
            }
        }

		 AVAudioPlayer criarAudio(string arquivo)
		{
			//UIApplicationState sharedApplication = new UIApplicationState();
			NSUrl songURL = new NSUrl(arquivo);
			NSError err;

			var state = UIApplication.SharedApplication.ApplicationState;
			if (state.ToString() != "Background")
			{
				AVAudioPlayer player = new AVAudioPlayer(songURL, "wav", out err);
				player.Volume = Volume;
				player.NumberOfLoops = 0;
				return player;
			}
			else {

				NSUrl url = NSUrl.FromFilename(arquivo);
				//SystemSound notificationSound = SystemSound.FromFile(NotificationSoundPath);
				SystemSound mySound = new SystemSound(url);

				mySound.AddSystemSoundCompletion(SystemSound.Vibrate.PlaySystemSound);
				var asset = AVAsset.FromUrl(NSUrl.FromFilename(arquivo));

				CMTime audioDuration = asset.Duration;
				double tempo = audioDuration.Value / audioDuration.TimeScale;

				mySound.PlaySystemSound();
				esperaFinalizarSom(tempo);
			}

			return null;
		}

		public void esperaFinalizarSom(double tempo)
		{
			int tempoInt = Convert.ToInt32(tempo);
			if (tempoInt > 5 )
			{
				tempoInt = Convert.ToInt32(tempo) * 1000 + 1000;
			}
			else {
				tempoInt = Convert.ToInt32(tempo) * 1000 + 1000;
			}

			Task.Delay(tempoInt).Wait();
		}

		  void playProximo()
		{
			if (_audioAtual != null && _audioIndex < _audioAtual.Count)
			{
				string arquivo = _audioAtual[_audioIndex];
				_audioIndex++;
				_player = criarAudio(arquivo);
				var state = UIApplication.SharedApplication.ApplicationState;
				if (state.ToString() != "Background")
				{
					_player.FinishedPlaying += (sender, e) =>
					{
						playProximo();

					} ;
					_player.Play();
				}
				else {
					playProximo();
				}


			}
			else {
				//_player.Dispose();
				_player = null;
			}
		}

		public void play(string[] arquivos)
        {
            _audioIndex = 0;
            _audioAtual = null;
           if (_player != null)
            {
                if (_player.Playing)
                    _player.Stop();
                _player.Dispose();
               _player = null;
            }
            _audioIndex = 0;
			if(arquivos != null)
            _audioAtual = arquivos;
            playProximo();
        }

        public void play(string arquivo)
        {
			var player = criarAudio(arquivo);
			//criarAudio(arquivo);
			var state = UIApplication.SharedApplication.ApplicationState;
			if (state.ToString() != "Background")
			{
				player.Play();
			}
        }
    }
}


Exemple #34
0
 public void PlayCountDown()
 {
     var sound = new SystemSound(new NSUrl("sounds/boxing_bell.m4v"));
     sound.PlaySystemSound();
 }
Exemple #35
0
 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();
 }
Exemple #36
0
 public void Play()
 {
     sound.PlaySystemSound();
 }
 public void PlayMp3File(string fileName)
 {
     var url = NSUrl.FromFilename (fileName);
     var systemSound = new SystemSound (url);
     systemSound.PlaySystemSound ();
 }
        public override void OnResignActivation(UIApplication application)
        {
            UIStoryboard story = UIStoryboard.FromName("Main", NSBundle.MainBundle);
            VaultInstructionsController vaultInstructions = story.InstantiateViewController("VaultInstructionsController") as VaultInstructionsController;

            if (this.navMaster.VisibleViewController == vaultInstructions)
            {
                vaultInstructions.DismissViewController(true, null);
            }

            SystemSound soundLock = new SystemSound(1100);

            soundLock.PlaySystemSound();
            var memoryCache      = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            var filePathPassword = System.IO.Path.Combine(memoryCache, "password.txt");

            try
            {
                if (filePathPassword == null)
                {
                    throw new FileNotFoundException();
                }
                else
                {
                    if (String.IsNullOrEmpty(File.ReadAllText(filePathPassword)) == true)
                    {
                        if (this.navMaster.VisibleViewController != this.passwordFirstControl)
                        {
                            this.navMaster.PopToViewController(this.passwordFirstControl, true);
                        }
                        else
                        {
                            Console.WriteLine("Controller already exists");
                        }
                    }
                    else
                    {
                        if (this.navMaster.ViewControllers.Contains(this.password) == true)
                        {
                            if (this.navMaster.VisibleViewController != this.password)
                            {
                                this.passwordLog.Text = "";
                                this.passwordLog.ResignFirstResponder();
                                this.navMaster.PopToViewController(this.password, true);
                            }
                            else
                            {
                                Console.WriteLine("Controller already exists");
                            }
                        }
                        else
                        {
                            this.navMaster.PushViewController(this.password, true);
                        }
                    }
                }
            }
            catch (FileNotFoundException)
            {
                if (this.navMaster.VisibleViewController != this.passwordFirstControl)
                {
                    this.navMaster.PushViewController(this.passwordFirstControl, true);
                }
                else
                {
                    Console.WriteLine("Controller already exists");
                }
            }
        }
Exemple #39
0
        public void Play()
        {
            var s = new SystemSound(alermSoundId);

            s.PlaySystemSound();
        }