private void NotifyOldViewModel() { var rng = RandomInt((int)DateTime.UtcNow.Ticks); var msg = "Showing old ViewModel."; _mvxLog.Trace($"Showing notification to trigger OldViewModel with args \"{msg}\" \"{rng}\""); _notificationService.NotifyOldViewModel(new NotificationModel { Message = msg, RandomNumber = rng }); }
protected override async Task <Boolean> ShowContentView(FrameworkElement element, MvxContentPresentationAttribute attribute, MvxViewModelRequest request) { try { // Everything that passes here should be a view IMvxView view = element as IMvxView; IMesManager manager = Mvx.IoCProvider.Resolve <IMesManager>(); // from which we can now get the view model. switch (view.ViewModel) { case IMesDocument document: // Try to set view, this is needed for DocumentManager IMesDocument docViewModel = (IMesDocument)view.ViewModel; docViewModel.View = view; // Needed for Binding with AvalonDock docViewModel.ViewAppearing(); docViewModel.ViewAppeared(); // Add to manager model manager.Documents.Add(docViewModel); _log.Trace($"Add {document.ToString()} to IManager.Documents"); return(true); case IMesTool tool: // Try to set view, this is needed for DocumentManager IMesTool toolViewModel = (IMesTool)view.ViewModel; toolViewModel.View = view; // Needed for Binding with AvalonDock toolViewModel.ViewAppearing(); toolViewModel.ViewAppeared(); // Add to manager model manager.Tools.Add(toolViewModel); _log.Trace($"Add {tool.ToString()} to IManager.Tools"); return(true); default: _log.Trace($"Passing to parent {view.ViewModel.ToString()}"); return(await base.ShowContentView(element, attribute, request)); } } catch (Exception exception) { if (_log == null) { _log = Mvx.IoCProvider.Resolve <IMvxLog>(); } _log.ErrorException("Error seen during navigation request to {0} - error {1}", exception, request.ViewModelType.Name, exception.ToLongString()); return(false); } }
public OldViewModel(IMvxLogProvider logProvider) { _mvxLog = logProvider.GetLogFor <OldViewModel>(); _mvxLog.Trace("OldViewModel.ctor called"); CloseCommand = new MvxCommand(OnClose); }
public NewViewModel(IMvxNavigationService mvxNavigationService, IMvxLogProvider logProvider) { _mvxNavigationService = mvxNavigationService; _mvxLog = logProvider.GetLogFor <NewViewModel>(); _mvxLog.Trace("NewViewModel.ctor called"); CloseCommand = new MvxAsyncCommand(OnCloseAsync); }
//private readonly Stack<FrameworkElement> _navigationStack = new Stack<FrameworkElement>(); //private HomeView _homeView; public MesWpfPresenter(ContentControl mainWindow) : base(mainWindow) { IMvxLogProvider provider = Mvx.IoCProvider.Resolve <IMvxLogProvider>(); _log = provider.GetLogFor <MesWpfPresenter>(); _log.Trace("Setup: Creating Presenter"); _mainWindow = mainWindow; }
/// <summary> /// Tries to connect device. /// </summary> /// <returns>The to connect device.</returns> /// <param name="deviceViewModel">Device view model.</param> /// <param name="showPrompt">If set to <c>true</c> show prompt.</param> private async Task <bool> TryToConnectDevice(int index = -1, bool showPrompt = true) { try { CancellationTokenSource tokenSource = new CancellationTokenSource(); var config = new ProgressDialogConfig() { Title = $"Trying to establish connection with '{DeviceName}'", CancelText = "Cancel", IsDeterministic = false, MaskType = MaskType.None, OnCancel = tokenSource.Cancel }; bool didConnect = false; using (var progress = _userDialogs.Progress(config)) { progress.Show(); if (index > -1) { didConnect = await _bluetoothService.ConnectDevice(SensorDevice, tokenSource, index); } else { didConnect = await _bluetoothService.ConnectDevice(SensorDevice, tokenSource, -1); } } tokenSource.Dispose(); if (!didConnect) { return(false); } _userDialogs.Toast($"\tConnected to {SensorDevice.Name}"); RaisePropertyChanged("ConnectOrDisposeActionString"); RaisePropertyChanged("ImageSource"); return(true); } catch (Exception ex) { _userDialogs.Alert(ex.Message, "Connection error"); _log.Trace(ex.Message); return(false); } finally { _userDialogs.HideLoading(); Update(); } }
public override UICollectionReusableView GetViewForSupplementaryElement(UICollectionView collectionView, NSString elementKind, NSIndexPath indexPath) { mvxLog.Trace("SupplementaryCollectionViewSource GetViewForSupplementaryElement started"); if (elementKind == UICollectionElementKindSectionKey.Header && !HeaderReuseID.IsNullOrEmtpy()) { mvxLog.Trace("SupplementaryCollectionViewSource GetViewForSupplementaryElement HEADER resolving started"); if (_headerDataContext != null) { var headerView = collectionView.DequeueReusableSupplementaryView(elementKind, HeaderReuseID, indexPath); mvxLog.Trace("SupplementaryCollectionViewSource GetViewForSupplementaryElement HEADER in process"); SetupReusableView(headerView, elementKind, indexPath, _headerDataContext); return(headerView); } mvxLog.Warn("SupplementaryCollectionViewSource GetViewForSupplementaryElement _headerDataContext is NULL"); mvxLog.Trace("SupplementaryCollectionViewSource GetViewForSupplementaryElement HEADER resolving ended"); } else { mvxLog.Warn("SupplementaryCollectionViewSource GetViewForSupplementaryElement HEADER ID NULL"); } if (elementKind == UICollectionElementKindSectionKey.Footer && !FooterReuseID.IsNullOrEmtpy()) { mvxLog.Trace("SupplementaryCollectionViewSource GetViewForSupplementaryElement FOOTER resolving started"); if (_footerDataContext != null) { var footerView = collectionView.DequeueReusableSupplementaryView(elementKind, FooterReuseID, indexPath); mvxLog.Trace("SupplementaryCollectionViewSource GetViewForSupplementaryElement FOOTER in process"); SetupReusableView(footerView, elementKind, indexPath, _headerDataContext); return(footerView); } mvxLog.Warn("SupplementaryCollectionViewSource GetViewForSupplementaryElement _footerDataContext is NULL"); mvxLog.Trace("SupplementaryCollectionViewSource GetViewForSupplementaryElement FOOTER resolving ended"); } else { mvxLog.Warn("SupplementaryCollectionViewSource GetViewForSupplementaryElement FOOTER ID NULL"); } mvxLog.Trace("SupplementaryCollectionViewSource GetViewForSupplementaryElement ended"); return(null); }
public override void Prepare(NotificationModel parameter) { RandomNumber = parameter.RandomNumber; NotificationMessage = parameter.Message; _mvxLog.Trace("NewViewModel.Prepare(NotificationModel parameter) called"); }
public virtual void Resume() { _log.Trace("Resume {0}", GetType().Name); }
public void Init(int randomNumber, string notificationMessage) { RandomNumber = randomNumber; NotificationMessage = notificationMessage; _mvxLog.Trace("OldViewModel.Init called"); }
public void Load() { _log.Trace("Loading bluetooth low energy plugin"); Mvx.IoCProvider.LazyConstructAndRegisterSingleton <IBluetoothLE>(() => CrossBluetoothLE.Current); Mvx.IoCProvider.LazyConstructAndRegisterSingleton <IAdapter>(() => Mvx.IoCProvider.Resolve <IBluetoothLE>().Adapter); }
public override void ViewAppeared() { _log.Trace("ViewAppeared {0}", GetType().Name); }
protected override void OnStart() { base.OnStart(); _log.Trace("App Start"); }