public void SaveCode() { //Create Alert var textInputAlertController = UIAlertController.Create("Save Your Code", "Fill Out These Fields", UIAlertControllerStyle.Alert); //Add Text Input textInputAlertController.AddTextField(textField => { textField.Placeholder = "Enter File Name"; }); //Add Text Input textInputAlertController.AddTextField(textField => { textField.Placeholder = "Enter Your Name"; }); //Add Actions var cancelAction = UIAlertAction.Create ("Cancel", UIAlertActionStyle.Cancel, alertAction => Console.WriteLine ("Cancel was Pressed")); var okayAction = UIAlertAction.Create ("Save !", UIAlertActionStyle.Default, alertAction => { Console.WriteLine ("The user entered '{0}'", textInputAlertController.TextFields[0].Text); GlobalSupport.LastNameInput = textInputAlertController.TextFields[1].Text; Code code = new Code(); code.CodeString = txtCodeField.Text; code.Author = textInputAlertController.TextFields[1].Text; code.FileName = textInputAlertController.TextFields[0].Text; code.Date = DateTime.Now; code.LevelName = GlobalSupport.GameLevel.Substring(0,GlobalSupport.GameLevel.LastIndexOf('.')); code.Language = GlobalSupport.GameLanguage; codeDatabase.Insert(code); }); textInputAlertController.AddAction(cancelAction); textInputAlertController.AddAction(okayAction); //Present Alert PresentViewController(textInputAlertController, true, null); }
public void SaveCode() { int getLastID = codeDatabase.SelectAll<Code>().Count + 1; LinearLayout layout = new LinearLayout(this); layout.Orientation = Orientation.Vertical; EditText inputFileName = new EditText(this); inputFileName.Hint = "FileName"; layout.AddView (inputFileName); EditText inputAuthor = new EditText(this); inputAuthor.Hint = "Author"; layout.AddView (inputAuthor); inputAuthor.Text = GlobalSupport.LastNameInput; AlertDialog ad = new AlertDialog.Builder (this).Create(); ad.SetTitle ("Enter name"); ad.SetMessage ("Please enter a file name and your name."); ad.SetView (layout); ad.SetButton ("Save",(senderAlert, args) => { //Save File GlobalSupport.LastNameInput = inputAuthor.Text; Code code = new Code(); code.CodeString = txtCodeField.Text; code.Author = inputAuthor.Text; code.FileName = inputFileName.Text; code.Date = DateTime.Now; code.LevelName = GlobalSupport.GameLevel.Substring(0,GlobalSupport.GameLevel.LastIndexOf('.')); code.Language = GlobalSupport.GameLanguage; codeDatabase.Insert(code); }); ad.SetButton2 ("Cancel", (senderAlert, args) => { // cancels (Do nothing) }); ad.Show (); }