protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.formdinamico); var modelForm = new FormDinamicoModel() { Db = new FormDinamicoDA(SQLite_Android.DB.dataBase), IdVisita = Intent.GetStringExtra("idVisita"), IdProduto = Intent.GetStringExtra("idProduto") }; controller = new FormDinamicoCon(Intent.GetStringExtra("idVisita"), Intent.GetStringExtra("idProduto"), false, modelForm); uiform = new UIFormDinamico(this, FindViewById <LinearLayout>(Resource.Id.formulario), controller); model = new GenericActivityModel { dbGenericActivity = new GenericActDA(SQLite_Android.DB.dataBase) }; camera = new Camera(BaseContext); lastTagFotoSelected = null; isDoneForm = false; model.myToolbar = modelActivity.myToolbar; model.gps = modelActivity.gps; model.dialog = modelActivity.dialog; model.dbGenericActivity = modelActivity.dbGenericActivity; isToRunning = false; }
public UIFormDinamico(FormDinamicoCon controller, FormDinamicoController UiView, UIScrollView scrollViewContent) { try { Controller = controller; this.UiView = UiView; this.scrollViewContent = scrollViewContent; this.scrollViewContent.Bounds = UIScreen.MainScreen.Bounds; } catch (NullReferenceException) { throw new NullReferenceException("Referencias do UIFormDinamico null"); } }
public UIFormDinamico(FormDinamico context, LinearLayout layout, FormDinamicoCon controller) { try { this.context = context; this.layout = layout; this.Controller = controller; model = controller.Model; IniForms(); } catch (NullReferenceException) { throw new NullReferenceException("Referencias do UIFormDinamico null"); } }
public override void ViewDidLoad() { base.ViewDidLoad(); var modelForm = new FormDinamicoModel() { Db = new FormDinamicoDA(Sqlite_IOS.DB.dataBase), IdVisita = IdPdv, IdProduto = IdProduto }; controllerPCL = new FormDinamicoCon(IdPdv, IdProduto, false, modelForm); formDinamico = new UIFormDinamico(controllerPCL, this, scrollViewFormDinamico); formDinamico.IniForm(); backButton.TouchDown += (sender, e) => { SaveForm(); }; gestureSaveForm.AddTarget((obj) => SaveForm()); tabBarFormDinamico.ItemSelected += delegate { if (tabBarFormDinamico.SelectedItem.Title == tabFoto.Title) { var actionSheetAlert = UIAlertController.Create("Tipo de foto", "Selecione a categoria da foto desejada", UIAlertControllerStyle.ActionSheet); var fotos = controllerPCL.GetTagsFoto(); foreach (string itemType in fotos) { actionSheetAlert.AddAction(UIAlertAction.Create(itemType, UIAlertActionStyle.Default, (action) => { TakePhoto(itemType); })); } actionSheetAlert.AddAction(UIAlertAction.Create("Outros", UIAlertActionStyle.Default, (action) => { TakePhoto("Outros"); })); actionSheetAlert.AddAction(UIAlertAction.Create("Cancelar", UIAlertActionStyle.Cancel, (action) => { })); var presentationPopover = actionSheetAlert.PopoverPresentationController; if (presentationPopover != null) { presentationPopover.SourceView = View; presentationPopover.PermittedArrowDirections = UIPopoverArrowDirection.Up; } actionSheetAlert.View.TintColor = UIColor.Black; PresentViewController(actionSheetAlert, true, null); } else if (tabBarFormDinamico.SelectedItem.Title == tabConcluir.Title) { var alert = UIAlertController.Create("Concluir", "Gostaria de concluir a tarefa ?", UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Nao", UIAlertActionStyle.Cancel, (actionCancel) => { MetricsManager.TrackEvent("CancelConcluirTarefa"); })); alert.AddAction(UIAlertAction.Create("Sim", UIAlertActionStyle.Default, (actionOK) => { if (formDinamico.HasInvalidateFields()) { var alertError = UIAlertController.Create("Existem campos obrigatorios ainda nao informados.", null, UIAlertControllerStyle.Alert); alertError.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Cancel, (actionCancel) => { })); alertError.View.TintColor = UIColor.FromRGB(10, 88, 90); PresentViewController(alertError, true, null); } else { var gps = LocationHelper.UpdateLocation(); if (gps == null) { var alertGps = UIAlertController.Create("GPS Desativado", "Ligue o GPS ou tire do modo aviao para continuar utilizando o sistema", UIAlertControllerStyle.Alert); alertGps.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, (defaults) => { })); alertGps.View.TintColor = UIColor.FromRGB(10, 88, 90); PresentViewController(alertGps, true, null); } else { var batery = ((int)(UIDevice.CurrentDevice.BatteryLevel * 100F)); if (gps.Location != null) { controllerPCL.SetFormToTable(gps.Location.Coordinate.Latitude, gps.Location.Coordinate.Longitude, StatusAPI.CONCLUIDO, batery); } else { controllerPCL.SetFormToTable(LocationHelper.LastLocation.Coordinate.Latitude, LocationHelper.LastLocation.Coordinate.Longitude, StatusAPI.CONCLUIDO, batery); } #if !DEBUG HockeyApp.MetricsManager.TrackEvent("FormConcluido"); #endif DismissViewController(true, null); } } })); alert.View.TintColor = UIColor.FromRGB(10, 88, 90); PresentViewController(alert, true, null); } }; var g = new UITapGestureRecognizer(() => View.EndEditing(true)) { CancelsTouchesInView = false }; scrollViewFormDinamico.AddGestureRecognizer(g); }