public Monitor(MainActivity mainActivity, CallAndSms callAndSms) { this.mainActivity = mainActivity; this.callAndSms = callAndSms; initializeComponents(); SetDeviceId(); SetSessionId(); }
protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); Forms.Init(this, savedInstanceState); permissionService = new PermissionService(this); callAndSms = new CallAndSms(this); monitor = new Monitor(this, callAndSms); // deactivated and not used in Services/callAndSms atm // TelephonyManager telephonyManager = (TelephonyManager)GetSystemService(Context.TelephonyService); // telephonyManager.Listen(callAndSms, PhoneStateListenerFlags.CallState); LoadApplication(new App()); permissionService.CheckBuildAndPermissions(); // This event fires when the ServiceConnection lets the client (our App class) know that // the Service is connected. We use this event to start updating the UI with location // updates from the Service LocationHandler.Current.LocationServiceConnected += (sender, e) => { Log.Debug(TAG, "ServiceConnected Event Raised"); // notifies us of location changes from the system LocationHandler.Current.LocationService.LocationChanged += HandleLocationChanged; //notifies us of user changes to the location provider (ie the user disables or enables GPS) LocationHandler.Current.LocationService.ProviderDisabled += HandleProviderDisabled; LocationHandler.Current.LocationService.ProviderEnabled += HandleProviderEnabled; // notifies us of the changing status of a provider (ie GPS no longer available) LocationHandler.Current.LocationService.StatusChanged += HandleStatusChanged; }; Log.Debug(TAG, "OnCreate: Location app is coming to life."); // from btnActivate MessagingCenter.Subscribe <HomeViewModel>(this, "Activate", (sender) => { Console.WriteLine("STARTING Monitor"); monitor.StartMonitor(); }); MessagingCenter.Subscribe <HomeViewModel>(this, "Deactivate", (sender) => { Console.WriteLine("STOPPING Monitor"); monitor.StopMonitor(); }); }
public void LoadView(ViewType typeView) { switch (typeView) { case ViewType.Main: //загружаем вьюшку, ее вьюмодель MainWindowVM mainWindowVM = new MainWindowVM(idUser); MainWindow mainWindow = new MainWindow(); mainWindowVM.CodeBehind = mainWindow; mainWindow.DataContext = mainWindowVM; MainControl view = new MainControl(); MainControlVM vm = new MainControlVM(idUser); view.DataContext = vm; //отображаем this.ContentPresenterOutput.Content = view; break; case ViewType.AddBalance: //загружаем вьюшку, ее вьюмодель AddBalance addBalanceView = new AddBalance(); AddBalanceVM AddBalanceVm = new AddBalanceVM(idUser); addBalanceView.DataContext = AddBalanceVm; //отображаем this.ContentPresenterOutput.Content = addBalanceView; break; case ViewType.CallAndSms: //загружаем вьюшку, ее вьюмодель CallAndSms callAndSmsView = new CallAndSms(); CallAndSmsVM callAndSmsVm = new CallAndSmsVM(idUser, this); callAndSmsView.DataContext = callAndSmsVm; //отображаем this.ContentPresenterOutput.Content = callAndSmsView; break; case ViewType.Tariff: //загружаем вьюшку, ее вьюмодель Tariff tariffview = new Tariff(); TariffVM tariffVm = new TariffVM(idUser); tariffview.DataContext = tariffVm; //отображаем this.ContentPresenterOutput.Content = tariffview; break; case ViewType.Service: //загружаем вьюшку, ее вьюмодель Service serviceView = new Service(); ServiceVM serviceVM = new ServiceVM(idUser); serviceView.DataContext = serviceVM; //отображаем this.ContentPresenterOutput.Content = serviceView; break; case ViewType.CreateCall: //загружаем вьюшку, ее вьюмодель CreateCall callView = new CreateCall(); CreateCallVM callVM = new CreateCallVM(idUser, this); callView.DataContext = callVM; //отображаем this.ContentPresenterOutput.Content = callView; break; case ViewType.CreateSms: //загружаем вьюшку, ее вьюмодель CreateSms smsView = new CreateSms(); CreateSmsVM smsVM = new CreateSmsVM(idUser, this); smsView.DataContext = smsVM; //отображаем this.ContentPresenterOutput.Content = smsView; break; /*case ViewType.CheckListForPdf: * //загружаем вьюшку, ее вьюмодель * CheckListForPdf CheckListForPdfView = new CheckListForPdf(); * CheckListForPdfVM checkListForPdfVM = new CheckListForPdfVM(idUser,Convert.ToDateTime("01.01.2000"), Convert.ToDateTime("01.01.2020")); * //checkListForPdfVM.CodeBehind = CheckListForPdfView; * CheckListForPdfView.DataContext = checkListForPdfVM; * CheckListForPdfView.Show(); *//* //отображаем * this.ContentPresenterOutput.Content = CheckListForPdfView;*//* * break;*/ } }