protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Gain Access to all views and controls in our layout navBar = FindViewById <ACNavBar> (Resource.Id.navBar); viewHome = FindViewById <ImageView> (Resource.Id.viewHome); //Are we rehydrating after a state change? if (bundle != null) { //Yes, attempt to restore the previously selected NavBar button navBar.rehydrationId = bundle.GetInt("SelectedButton"); navBar.Hidden = bundle.GetBoolean("Hidden"); } // Style bar navBar.appearance.border = Color.LightGray; //--------------------------------------------- // Add buttons to the top of the bar //--------------------------------------------- // The first button added to the top collection will automatically be selected ACNavBarButton home = navBar.top.AddButton(Resource.Drawable.house, true, false); // Wire up request for this button's view home.RequestNewView += responder => { // Attach view to the button responder.attachedView = viewHome; }; // Add an action to the home button home.Touched += responder => { // Hide warning notification in NavBar if (warning != null) { warning.Hidden = true; } // Disable the delete button if (delete != null) { delete.Enabled = false; } }; // Add Bar Chart navBar.top.AddAutoDisposingButton(Resource.Drawable.barchart, true, false).RequestNewView += (responder) => { // Bring view into existance viewBarChart = (View)LayoutInflater.Inflate(Resource.Layout.ViewBarChart, null); // Attach view to the button responder.attachedView = viewBarChart; }; // Add Org Chart navBar.top.AddAutoDisposingButton(Resource.Drawable.orgchart, true, false).RequestNewView += (responder) => { // Bring view into existance viewOrgChart = (View)LayoutInflater.Inflate(Resource.Layout.ViewOrgChart, null); // Attach view to the button responder.attachedView = viewOrgChart; }; // Add ticket ticket = navBar.top.AddAutoDisposingButton(Resource.Drawable.ticket, true, false); ticket.RequestNewView += responder => { // Bring view into existance viewTicket = (View)LayoutInflater.Inflate(Resource.Layout.ViewTIcket, null); // Attach view to the button responder.attachedView = viewTicket; }; ticket.Touched += responder => { // Enable the delete button if (delete != null) { delete.Enabled = true; } }; //-------------------------------------------- // Add buttons to the middle of the bar //-------------------------------------------- navBar.middle.AddTool(Resource.Drawable.printer, true, false).Touched += (responder) => { // Inform user (dialogMessage defined as a global variable) ACAlert.ShowAlertOK(this, "Nav Bar", "Sorry but printing is not supported at this time."); // Display warning notification in NavBar if (warning != null) { warning.Hidden = false; } }; delete = navBar.middle.AddTool(Resource.Drawable.trash, false, false); delete.Touched += (responder) => { // Inform user (dialogMessage defined as a global variable) ACAlert.ShowAlertOK(this, "Nav Bar", "Are you sure you what to delete the item?"); }; //----------------------------------------- // Add buttons to the bottom of the bar //----------------------------------------- warning = navBar.bottom.AddNotification(Resource.Drawable.warning, null, true); navBar.bottom.AddAutoDisposingButton(Resource.Drawable.gear, true, false).RequestNewView += responder => { // Bring view into existance viewSettings = (View)LayoutInflater.Inflate(Resource.Layout.ViewSettings, null); // Attach view to the button responder.attachedView = viewSettings; // grab show/hide button showHideNavBar = FindViewById <Button> (Resource.Id.showHideButton); //----------------------------------------- // Wireup button action //----------------------------------------- if (showHideNavBar != null) { showHideNavBar.Click += (sender, e) => { //Is the NavBar visible? navBar.Hidden = (!navBar.Hidden); }; } }; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Create a new download manager downloadManager = new ACDownloadManager(); // Get all of our interface items ProgressBar bar = FindViewById <ProgressBar> (Resource.Id.progressBar); TextView title = FindViewById <TextView> (Resource.Id.progressText); Button startDowload = FindViewById <Button> (Resource.Id.startDownload); Button cancel = FindViewById <Button> (Resource.Id.cancel); // Create path to hold downloaded files string directory = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); Console.WriteLine("Directory: {0}", directory); // Wireup progress bar downloadManager.FileDownloadProgressPercent += (percentage) => { // Adjust percentage and display RunOnUiThread(() => { percentage *= 100f; bar.Progress = (int)percentage; }); }; // Wireup completion handler downloadManager.AllDownloadsCompleted += () => { // Run on UI Thread RunOnUiThread(() => { // Inform caller ACAlert.ShowAlertOK(this, "Download Manager", "All files have been downloaded"); // Update GUI startDowload.Enabled = true; title.Visibility = ViewStates.Invisible; bar.Visibility = ViewStates.Invisible; cancel.Visibility = ViewStates.Invisible; }); }; // Wireup error handler downloadManager.DownloadError += (message) => { // Run on UI Thread RunOnUiThread(() => { // Update GUI startDowload.Enabled = true; title.Visibility = ViewStates.Invisible; bar.Visibility = ViewStates.Invisible; cancel.Visibility = ViewStates.Invisible; // Inform caller ACAlert.ShowAlertOK(this, "Download Error", message); }); }; // Wireup start button startDowload.Click += (sender, e) => { // Update GUI startDowload.Enabled = false; title.Visibility = ViewStates.Visible; bar.Visibility = ViewStates.Visible; cancel.Visibility = ViewStates.Visible; // Queue up files to download downloadManager.QueueFile("http://appracatappra.com/wp-content/uploads/et_temp/ssh-140751_232x117.jpg", directory); downloadManager.QueueFile("http://appracatappra.com/wp-content/uploads/et_temp/4-TD-web-5-662620_960x332.png", directory); // Start the download process ThreadPool.QueueUserWorkItem((callback) => { downloadManager.StartDownloading(); }); }; // Wireup cancel button cancel.Click += (sender, e) => { // Stop any running downloads downloadManager.AbortDownload(); // Update GUI startDowload.Enabled = true; title.Visibility = ViewStates.Invisible; bar.Visibility = ViewStates.Invisible; cancel.Visibility = ViewStates.Invisible; // Inform user ACAlert.ShowAlertOK(this, "Download Manager", "User has aborted all downloads"); }; }
/// <summary> /// Displays the alert for the current alertNum /// </summary> private void DisplayAlert() { // Close any existing alert if (_alert != null) { _alert.Hide(); _alert = null; } // Take action based on the current alert selected switch (alertNum) { case 0: ACAlert.ShowAlert(this, "ActionAlert", "A cross platform Alert, Dialog and Notification system for iOS and Android."); break; case 1: ACAlert.ShowAlert(this, "ActionAlert", ""); break; case 2: ACAlert.ShowAlert(this, "", "A cross platform Alert, Dialog and Notification system for iOS and Android."); break; case 3: ACAlert.ShowAlert(this, Resource.Drawable.ActionAlert_57, "ActionAlert", "A cross platform Alert, Dialog and Notification system for iOS and Android."); break; case 4: ACAlert.ShowAlertOK(this, "ActionAlert", "A cross platform Alert, Dialog and Notification system for iOS and Android."); break; case 5: ACAlert.ShowAlertOK(this, Resource.Drawable.ActionAlert_57, "ActionAlert", "A cross platform Alert, Dialog and Notification system for iOS and Android."); break; case 6: _alert = ACAlert.ShowAlertOKCancel(this, "ActionAlert", "A cross platform Alert, Dialog and Notification system for iOS and Android."); //Respond to the OK button being tapped _alert.ButtonReleased += (button) => { if (button.title == "OK") { ACAlert.ShowAlert(this, ACAlertLocation.Top, "You tapped the OK button.", ""); } }; break; case 7: _alert = ACAlert.ShowAlert(this, "ActionAlert", "A cross platform Alert, Dialog and Notification system for iOS and Android.", "Cancel,Maybe,OK"); //Respond to any button being tapped _alert.ButtonReleased += (button) => { _alert.Hide(); ACAlert.ShowAlert(this, ACAlertLocation.Top, String.Format("You tapped the {0} button.", button.title), ""); }; break; case 8: _alert = ACAlert.ShowActivityAlert(this, "Activity Alert", "Displays a notification to the user that some long running process has started. This one is being displayed non-modal so the user can still interact with the app.", false); break; case 9: _alert = ACAlert.ShowActivityAlert(this, "Activity Alert", "", false); break; case 10: _alert = ACAlert.ShowActivityAlert(this, "", "Displays a notification to the user that some long running process has started. This alert has been set to be movable by the user.", false); //Adjust the alert so it can be moved by the user var layout = new RelativeLayout.LayoutParams(_alert.LayoutWidth, _alert.LayoutHeight); layout.LeftMargin = 20; layout.TopMargin = 20; _alert.LayoutParameters = layout; _alert.draggable = true; break; case 11: _alert = ACAlert.ShowActivityAlertCancel(this, "Activity Alert", "Displays a notification to the user that some long running process has started and allows the user to cancel the process.", true); break; case 12: _alert = ACAlert.ShowActivityAlertMedium(this, "Waiting...", false); break; case 13: _alert = ACAlert.ShowActivityAlertMediumCancel(this, "Waiting...", true); break; case 14: _alert = ACAlert.ShowProgressAlert(this, "Progress Alert", "Displays an Alert for a process with a known length and gives feedback to the user.", false); _alert.progressView.Progress = 50; break; case 15: _alert = ACAlert.ShowProgressAlert(this, "Waiting on Process...", "", false); _alert.progressView.Progress = 10; break; case 16: _alert = ACAlert.ShowProgressAlert(this, "", "Displays an Alert for a process with a known length and gives feedback to the user.", false); _alert.progressView.Progress = 80; break; case 17: _alert = ACAlert.ShowProgressAlert(this, Resource.Drawable.ActionAlert_57, "Progress Alert", "Displays an Alert for a process with a known length and gives feedback to the user.", false); _alert.progressView.Progress = 80; break; case 18: _alert = ACAlert.ShowProgressAlertCancel(this, "Progress Alert", "Displays an Alert for a process with a known length and allos the user to cancel the process.", false); _alert.progressView.Progress = 20; break; case 19: _alert = ACAlert.ShowProgressAlert(this, "Progress Alert", "Displays an Alert for a process with a known length and allos the user to cancel the process.", "Abort,Pause", true); _alert.progressView.Progress = 30; // Respond to any button being tapped _alert.ButtonReleased += (button) => { _alert.Hide(); }; break; case 20: _alert = ACAlert.ShowAlert(this, "ActionAlert", "A cross platform Alert, Dialog and Notification system for iOS and Android.", "Cancel,Maybe,OK"); _alert.Flatten(); // Respond to any button being tapped _alert.ButtonReleased += (button) => { _alert.Hide(); }; break; case 21: _alert = ACAlert.ShowAlert(this, Resource.Drawable.ActionAlert_57, "ActionAlert is Customizable", "You can 'square off' one or more of the corners and ajust all of the colors and styles by using properties of the alert.", "No,Yes"); _alert.appearance.background = Color.Orange; _alert.buttonAppearance.background = Color.Orange; _alert.buttonAppearanceHighlighted.titleColor = Color.Orange; _alert.appearance.roundBottomLeftCorner = false; // Respond to any button being tapped _alert.ButtonReleased += (button) => { _alert.Hide(); }; break; case 22: // Create subview var lp = new RelativeLayout.LayoutParams(278, 50); var flp = new RelativeLayout.LayoutParams(278, 50); var rl = new RelativeLayout(this); var field1 = new EditText(this); // Initialize subview rl.LayoutParameters = lp; // Initialize field and add to subview flp.TopMargin = 0; flp.RightMargin = 0; field1.LayoutParameters = flp; field1.Text = "Default Value"; rl.AddView(field1); // Create alert _alert = new ACAlert(this, ACAlertType.Subview, ACAlertLocation.Middle, "Custom Subview", rl, "Cancel,OK"); _alert.Show(); // Respond to any button being tapped _alert.ButtonReleased += (button) => { _alert.Hide(); }; break; } }
/// <summary> /// Shows the alert. /// </summary> private void AlertUser() { // Close any existing alert if (_alert != null) { _alert.Hide(); _alert = null; } // Take action based on the stepper value switch ((int)AlertSelection.Value) { case 0: ACAlert.ShowAlert("ActionAlert", "A cross platform Alert, Dialog and Notification system for iOS and Android."); break; case 1: ACAlert.ShowAlert("ActionAlert", ""); break; case 2: ACAlert.ShowAlert("", "A cross platform Alert, Dialog and Notification system for iOS and Android."); break; case 3: ACAlert.ShowAlert(UIImage.FromBundle("ActionAlertIcon"), "ActionAlert", "A cross platform Alert, Dialog and Notification system for iOS and Android."); break; case 4: ACAlert.ShowAlertOK("ActionAlert", "A cross platform Alert, Dialog and Notification system for iOS and Android."); break; case 5: ACAlert.ShowAlertOK(UIImage.FromBundle("ActionAlertIcon"), "ActionAlert", "A cross platform Alert, Dialog and Notification system for iOS and Android."); break; case 6: _alert = ACAlert.ShowAlertOKCancel("ActionAlert", "A cross platform Alert, Dialog and Notification system for iOS and Android."); //Respond to the OK button being tapped _alert.ButtonReleased += (button) => { if (button.title == "OK") { ACAlert.ShowAlert(ACAlertLocation.Top, "You tapped the OK button.", ""); } }; break; case 7: _alert = ACAlert.ShowAlert("ActionAlert", "A cross platform Alert, Dialog and Notification system for iOS and Android.", "Cancel,Maybe,OK"); //Respond to any button being tapped _alert.ButtonReleased += (button) => { _alert.Hide(); ACAlert.ShowAlert(ACAlertLocation.Top, String.Format("You tapped the {0} button.", button.title), ""); }; break; case 8: _alert = ACAlert.ShowActivityAlert("Activity Alert", "Displays a notification to the user that some long running process has started. This one is being displayed non-modal so the user can still interact with the app.", false); break; case 9: _alert = ACAlert.ShowActivityAlert("Activity Alert", "", false); break; case 10: _alert = ACAlert.ShowActivityAlert("", "Displays a notification to the user that some long running process has started. This alert has been set to be movable by the user.", false); _alert.draggable = true; break; case 11: _alert = ACAlert.ShowActivityAlertCancel("Activity Alert", "Displays a notification to the user that some long running process has started and allows the user to cancel the process.", true); break; case 12: _alert = ACAlert.ShowActivityAlertMedium("Waiting...", false); break; case 13: _alert = ACAlert.ShowActivityAlertMediumCancel("Waiting...", true); break; case 14: _alert = ACAlert.ShowProgressAlert("Progress Alert", "Displays an Alert for a process with a known length and gives feedback to the user.", false); _alert.progressView.Progress = 0.5f; break; case 15: _alert = ACAlert.ShowProgressAlert("Waiting on Process...", "", false); _alert.progressView.Progress = 0.1f; break; case 16: _alert = ACAlert.ShowProgressAlert("", "Displays an Alert for a process with a known length and gives feedback to the user.", false); _alert.progressView.Progress = 0.8f; break; case 17: _alert = ACAlert.ShowProgressAlert(UIImage.FromBundle("ActionAlertIcon"), "Progress Alert", "Displays an Alert for a process with a known length and gives feedback to the user.", false); _alert.progressView.Progress = 0.8f; break; case 18: _alert = ACAlert.ShowProgressAlertCancel("Progress Alert", "Displays an Alert for a process with a known length and allos the user to cancel the process.", false); _alert.progressView.Progress = 0.2f; break; case 19: _alert = ACAlert.ShowProgressAlert("Progress Alert", "Displays an Alert for a process with a known length and allos the user to cancel the process.", "Abort,Pause", true); _alert.progressView.Progress = 0.3f; //Respond to any button being tapped _alert.ButtonReleased += (button) => { _alert.Hide(); }; break; case 20: _alert = ACAlert.ShowAlert("ActionAlert", "A cross platform Alert, Dialog and Notification system for iOS and Android.", "Cancel,Maybe,OK"); _alert.Flatten(); //Respond to any button being tapped _alert.ButtonReleased += (button) => { _alert.Hide(); }; break; case 21: _alert = ACAlert.ShowAlert(UIImage.FromBundle("ActionAlertIcon"), "ActionAlert is Customizable", "You can 'square off' one or more of the corners and ajust all of the colors and styles by using properties of the alert.", "No,Yes"); _alert.appearance.background = UIColor.Orange; _alert.buttonAppearance.background = UIColor.Orange; _alert.buttonAppearanceHighlighted.titleColor = UIColor.Orange; _alert.appearance.roundBottomLeftCorner = false; // Respond to any button being tapped _alert.ButtonReleased += (button) => { _alert.Hide(); }; break; case 22: // Build a custom view for this alert UITextField field1 = new UITextField(new CGRect(13, 41, 278, 29)) { BorderStyle = UITextBorderStyle.RoundedRect, TextColor = UIColor.DarkGray, Font = UIFont.SystemFontOfSize(14f), Placeholder = "Name", Text = "DefaultValue", BackgroundColor = UIColor.White, AutocorrectionType = UITextAutocorrectionType.No, KeyboardType = UIKeyboardType.Default, ReturnKeyType = UIReturnKeyType.Done, ClearButtonMode = UITextFieldViewMode.WhileEditing, Tag = 0, Enabled = true }; field1.ShouldReturn = delegate(UITextField field) { field.ResignFirstResponder(); return(true); }; field1.ShouldEndEditing = delegate(UITextField field) { field.ResignFirstResponder(); return(true); }; // Create the new alert and attach the new field _alert = new ACAlert(ACAlertType.Subview, ACAlertLocation.Middle, "Custom Subview", field1, "Cancel,OK"); _alert.Show(); // Respond to any button being tapped _alert.ButtonReleased += (button) => { field1.ResignFirstResponder(); _alert.Hide(); }; break; } }
public override void ViewDidLoad() { base.ViewDidLoad(); //Call base base.ViewDidLoad(); // Build a download manager downloadManager = new ACDownloadManager(); //Wireup progress bar downloadManager.FileDownloadProgressPercent += delegate(float percentage) { //Update GUI using (var pool = new NSAutoreleasePool()) { pool.BeginInvokeOnMainThread(delegate { //Set current percentage DownloadingProgress.Progress = percentage; }); } }; //Wireup completion handler downloadManager.AllDownloadsCompleted += delegate() { //Update GUI using (var pool = new NSAutoreleasePool()) { pool.BeginInvokeOnMainThread(delegate { //Display Alert Dialog Box ACAlert.ShowAlertOK("Download Manager", "All files have been downloaded."); //Update GUI DownloadingProgress.Hidden = true; DownloadingActivity.StopAnimating(); DownloadButton.Enabled = true; CancelButton.Enabled = false; DownloadingLabel.Hidden = true; }); } }; //Wireup download error event downloadManager.DownloadError += delegate(string message) { //Update GUI using (var pool = new NSAutoreleasePool()) { pool.BeginInvokeOnMainThread(delegate { //Display Alert Dialog Box ACAlert.ShowAlertOK("Download Error", message); //Update GUI DownloadingProgress.Hidden = true; DownloadingActivity.StopAnimating(); DownloadButton.Enabled = true; CancelButton.Enabled = false; DownloadingLabel.Hidden = true; }); } }; // Perform any additional setup after loading the view, typically from a nib. DownloadingProgress.Hidden = true; DownloadingActivity.StopAnimating(); DownloadButton.Enabled = true; CancelButton.Enabled = false; }