public static TopMostMode ToMode(IDeviceSettings d)
 {
     if (d.TopMostExtendedMode)
     {
         if (d.DisableTopMost)
         {
             return(TopMostMode.Manual);
         }
         else
         {
             return(TopMostMode.Always);
         }
     }
     else
     {
         if (d.DisableTopMost)
         {
             return(TopMostMode.Never);
         }
         else
         {
             return(TopMostMode.WhenCompact);
         }
     }
 }
示例#2
0
        /// <summary>
        /// Initialises a new instance of the <see cref="Kernel"/> class.
        /// </summary>
        /// <param name="deviceSettings">Platform-specific device settings</param>
        /// <param name="persistedApplicationStateRepository">Platform-specific repository for the application state</param>
        public Kernel(
            IDeviceSettings deviceSettings,
            IPersistedApplicationStateRepository persistedApplicationStateRepository)
        {
            this.deviceSettings = deviceSettings;
            this.persistedApplicationStateRepository = persistedApplicationStateRepository;

            var applicationStateFactory = new CurrentApplicationStateFactory(this.GetCurrentApplicationState);

            this.bootstrap = new Bootstrap(persistedApplicationStateRepository, applicationStateFactory);

            var vectorClock     = new VectorClock();
            var eventStoreState = new EventStoreState();

            this.bootstrap.EventStore.State = eventStoreState;
            this.bootstrap.VectorClock.SetState(vectorClock);
            this.bootstrap.DeviceId.SetDeviceId(deviceSettings.GetDeviceId());

            this.Repositories = new ReadRepositories(this.bootstrap);
            this.CommandBus   = this.bootstrap.CommandBus;

            Messenger.Default.Register <LoadApplicationStateRequested>(this, x => this.LoadApplicationState(x.Location));

            this.ResetReadModelState();
        }
示例#3
0
        /// <summary>
        /// Initialises a new instance of the <see cref="MainDesktopViewModel"/> class.
        /// </summary>
        /// <param name="windowService">The platform's window service.</param>
        /// <param name="deviceSettings">Platform-specific device settings</param>
        public MainDesktopViewModel(IWindowService windowService, IDeviceSettings deviceSettings)
        {
            this.windowService = windowService;

            Messenger.Default.Register <LoadedApplicationState>(
                this,
                (x) =>
            {
                this.RebindReadModels();
            });

            this.applicationKernel = ServiceLocatorWrapper.Current.GetInstance <Kernel>();
            var repositories = ServiceLocatorWrapper.Current.GetInstance <ReadRepositories>();

            // this.RebindReadModels(); // this would cause events while this class is not yet initialised
            // so use local fields instead
            // this.accountList = repositories.AccountListRepository.Find(BudgetId.OffBudgetId); // TODO: use correct budget ids etc later
            this.accountList = repositories.BudgetListRepository.Find().Single(x => BudgetId.OffBudgetId.Equals(x.BudgetId)).Accounts;
            this.InitialiseRelayCommands();

            // Only after everything has been initialised, continue with the application flow
            var autoloaded = deviceSettings.GetAutoloadBudgetIdentifier();

            if (!string.IsNullOrWhiteSpace(autoloaded))
            {
                // TODO: error handling, obviously
                this.applicationKernel.LoadApplicationState(autoloaded); // causes message
            }
            else
            {
                // TODO: navigate to "new or load" view
            }
        }
示例#4
0
 public virtual void Initialization(IDeviceInitializationParams initParams)
 {
     CheckDisposed();
     pollingTimeout = initParams.Settings.PollingTimeout;
     if (pollingTimeout < 1)
     {
         pollingTimeout = 10;
     }
     lockerClient = new object();
     Settings     = initParams.Settings;
     resetWait    = new ManualResetEvent(true);
 }
        public AboutUsViewModel(IGALogger logger, IUserInfoService userInfoService,
                                IHUDProvider hudProvider, IDeviceSettings deviceSettings)
        {
            _userInfoService = userInfoService;
            _hudProvider     = hudProvider;
            _deviceSettings  = deviceSettings;

            PageTitle = AppResources.AboutMenuText;
            _deviceSettings.LoadInfo();
            VersionLabel      = string.Format("{0}:{1}", AppResources.VersionLabel, _deviceSettings.AppVersion);
            AboutUsDetailText = AppResources.AboutUsDetailText;
        }
示例#6
0
 public void Dispose()
 {
     if (View != null)
     {
         View.Dispose();
         _isInit = false;
         Exception ex;
         if (DeleteDeviceSettings(out ex))
         {
             _deviceSettings = null;
             View            = null;
         }
     }
 }
        public void Start()
        {
            var monitorAreas = MonitorHelper.GetMonitorsWorkingAreas();
            var appSettings  = _coreData.ThisDevice.DeviceSettings;

            _started           = true;
            _appSettings       = appSettings;
            _window.ResizeMode = ResizeMode.CanResizeWithGrip;
            _compactRect       = AdjustRectToVisible(appSettings.CompactWnd, monitorAreas, true);
            _normalRect        = AdjustRectToVisible(appSettings.NormalWnd, monitorAreas, false);
            GoToState(appSettings.AppWindowState);

            RefreshButtons(false);
        }
        public ChartViewModel(IGALogger logger, IUserInfoService userInfoService,
                              IHUDProvider hudProvider, IDeviceSettings deviceSettings,
                              IIndicatorRepository indicatorRepository)
        {
            _userInfoService     = userInfoService;
            _hudProvider         = hudProvider;
            _deviceSettings      = deviceSettings;
            _indicatorRepository = indicatorRepository;


            //PageTitle = AppResources.AboutUsPageTitle;
            //_deviceSettings.LoadInfo();
            //VersionLabel = string.Format("{0}:{1}", AppResources.VersionLabel, _deviceSettings.AppVersion);
            //AboutUsDetailText = AppResources.AboutUsDetailText;
        }
示例#9
0
 public void Reinitialization(IDeviceInitializationParams initParams)
 {
     CheckDisposed();
     if (Settings.Equals(initParams))
     {
         bool isBusy = Busy;
         Close();
         Settings  = initParams.Settings;
         resetWait = new ManualResetEvent(true);
         if (isBusy)
         {
             Open();
         }
         Initialization(initParams);
     }
 }
示例#10
0
        /// <summary>
        /// Initialises a new instance of the <see cref="WelcomeViewModel"/> class.
        /// </summary>
        /// <param name="deviceSettings">Device settings</param>
        public WelcomeViewModel(IDeviceSettings deviceSettings)
        {
            // Initialise list of recent budgets
            this.RebindViewModel(deviceSettings);

            // Initialise relay commands
            this.CreateNewBudgetCommand = new RelayCommand(
                () =>
            {
                var navigationService = ServiceLocatorWrapper.Current.GetInstance <INavigationService>();
                navigationService.NavigateTo(ViewModelPageKeys.CreateNewBudget);
            });

            this.OpenExistingBudgetCommand = new RelayCommand(
                () =>
            {
                var navigationService = ServiceLocatorWrapper.Current.GetInstance <INavigationService>();
                navigationService.NavigateTo(ViewModelPageKeys.OpenExistingBudget);
            });

            // Messaging
            Messenger.Default.Register <LoadedApplicationState>(
                this,
                (x) =>
            {
                // TODO: always trigger navigation to primary after opening budget?
                // trigger navigation (if we're still the displayed view)
                var navigationService = ServiceLocatorWrapper.Current.GetInstance <INavigationService>();
                if (navigationService.CurrentPageKey == ViewModelPageKeys.Welcome)
                {
                    navigationService.NavigateTo(ViewModelPageKeys.PrimaryApplication);
                }

                // Also, rebind.
                this.RebindViewModel(deviceSettings);
                this.RaisePropertyChangedForReboundProperties();
            });
        }
示例#11
0
        public void SetSettings(string deviceName, IDeviceSettings deviceSettings)
        {
            var settings = Settings;

            if (deviceSettings is SourceSettings)
            {
                if (settings.SourceSettings == null)
                {
                    settings.SourceSettings = new Dictionary <string, SourceSettings>();
                }
                settings.SourceSettings[deviceName] = (SourceSettings)deviceSettings;
            }
            else if (deviceSettings is AudioSettings)
            {
                if (settings.AudioSettings == null)
                {
                    settings.AudioSettings = new Dictionary <string, AudioSettings>();
                }
                settings.AudioSettings[deviceName] = (AudioSettings)deviceSettings;
            }

            Settings = settings;
        }
示例#12
0
        /// <summary>
        /// (Re)bind the view model to the new application state
        /// </summary>
        /// <param name="deviceSettings">Device settings</param>
        private void RebindViewModel(IDeviceSettings deviceSettings)
        {
            var recentlyUsedBudgets = deviceSettings.GetRecentBudgets() ?? new List <Common.Infrastructure.Persistency.RecentBudget>();

            // Map to viewmodel-specific model
            var viewModelRecentBudgets =
                recentlyUsedBudgets.Select(
                    x => new RecentBudget()
            {
                Name        = x.DisplayName,
                OpenCommand = new RelayCommand(
                    () =>
                {
                    var commandBus = ServiceLocatorWrapper.Current.GetInstance <ICommandBus>();
                    commandBus.Submit(new LoadApplicationState(x.Identifier));

                    // Navigation is done when the corresponding message reaches us (and we're still responsible for the navigation)
                }),
            });

            // Do not use the property right now
            this.recentBudgets = new ObservableCollection <RecentBudget>(viewModelRecentBudgets);
        }
        protected override void OnStart()
        {
            ServiceDeviceSettings = DependencyService.Get <IDeviceSettings>();

            MainPage = new MainPage();
        }
示例#14
0
 public override bool Equals(IDeviceSettings other)
 {
     return(base.Equals(other) && Equals(other as SEDeviceSettings));
 }
        public ObservationViewModel(IGALogger logger, IUserInfoService userInfoService, IObservationRepository observationRep,
                                    IHUDProvider hudProvider, IObservationEntryRepository observationEntryRepository,
                                    IObservationChangeRepository observationChangeRepository,
                                    IObservationCommentRepository observationCommentRepository,
                                    IObservationAttachmentRepository observationAttachmentRepository,
                                    IObservationService ObservationService, IDeviceSettings deviceSettings)
        {
            _userInfoService                 = userInfoService;
            _hudProvider                     = hudProvider;
            _observationRep                  = observationRep;
            _observationEntryRepository      = observationEntryRepository;
            _observationChangeRepository     = observationChangeRepository;
            _observationCommentRepository    = observationCommentRepository;
            _observationAttachmentRepository = observationAttachmentRepository;
            _observationService              = ObservationService;
            _deviceSettings                  = deviceSettings;

            TestDate = DateTime.Now;


            MessagingCenter.Subscribe <ObservationChange>(this, "ChangeScreen", (change) =>
            {
                if (Changes == null)
                {
                    Changes = new ObservableCollection <ObservationChange>();
                }
                var item = Changes.Where(m => m == change).FirstOrDefault();
                if (item != null)
                {
                    Changes.Remove(item);
                    Changes.Add(item);
                }
                else
                {
                    Changes.Add(change);
                }
                if (_Navigation.ModalStack.Count != 0)
                {
                    _Navigation.PopModalAsync();
                }
            });

            MessagingCenter.Subscribe <ObservationAttachment>(this, "AttachmentScreen", (attach) =>
            {
                if (Attachments == null)
                {
                    Attachments = new ObservableCollection <ObservationAttachment>();
                }
                var item = Attachments.Where(m => m == attach).FirstOrDefault();
                if (item != null)
                {
                    Attachments.Remove(item);
                    Attachments.Add(item);
                }
                else
                {
                    Attachments.Add(attach);
                }
            });

            MessagingCenter.Subscribe <ObsViewModel>(this, "NumDemUpdate", (change) =>
            {
                RaisePropertyChanged("IndicatorNumCount");
                RaisePropertyChanged("IndicatorDenCount");
                RaisePropertyChanged("IndicatorCount");
                RaisePropertyChanged("IndicatorCountDisplay");
            });



            MessagingCenter.Subscribe <ObservationAttachment>(this, "AttachmentScreenCancel", (change) =>
            {
                if (_Navigation.ModalStack.Count != 0)
                {
                    _Navigation.PopModalAsync();
                }
            });

            MessagingCenter.Subscribe <ObservationChange>(this, "ChangeScreenCancel", (change) =>
            {
                Changes = Changes;
                if (_Navigation.ModalStack.Count != 0)
                {
                    _Navigation.PopModalAsync();
                }
            });

            MessagingCenter.Subscribe <ObservationComment>(this, "CommentScreen", (comment) =>
            {
                var item = Comments.Where(m => m == comment).FirstOrDefault();
                if (item != null)
                {
                    Comments.Remove(item);
                    Comments.Add(item);
                }
                else
                {
                    var i = Comments.Count();
                    Comments.Add(comment);
                }
                if (_Navigation.ModalStack.Count != 0)
                {
                    _Navigation.PopModalAsync();
                }
            });

            MessagingCenter.Subscribe <ObservationComment>(this, "CommentScreenCancel", (change) =>
            {
                Comments = Comments;
                if (_Navigation.ModalStack.Count != 0)
                {
                    _Navigation.PopModalAsync();
                }
            });
        }
示例#16
0
        public LandingViewModel(IGALogger logger, IUserInfoService userInfoService,
                                IHUDProvider hudProvider, IObservationService observationService, ISiteRepository siteRepository,
                                IActivityRepository activityRepository, IIndicatorRepository indicatoryRepository,
                                ISiteIndicatorRepository siteIndicatoryRepository, IObservationRepository observationRepository,
                                IObservationEntryRepository observationEntryRepository, IObservationChangeRepository observationChangeRepository,
                                IObservationCommentRepository observationCommentRepository, IObservationAttachmentRepository observationAttachmentRepository,
                                IIndicatorAgeRepository indicatoryAgeRepository, IDeviceSettings deviceSettings)
        {
            _userInfoService                 = userInfoService;
            _hudProvider                     = hudProvider;
            _observationService              = observationService;
            _siteRepository                  = siteRepository;
            _activityRepository              = activityRepository;
            _indicatorRepository             = indicatoryRepository;
            _siteIndicatorRepository         = siteIndicatoryRepository;
            _observationRepository           = observationRepository;
            _observationEntryRepository      = observationEntryRepository;
            _observationChangeRepository     = observationChangeRepository;
            _observationCommentRepository    = observationCommentRepository;
            _observationAttachmentRepository = observationAttachmentRepository;
            _indicatorAgeRepository          = indicatoryAgeRepository;
            _deviceSettings                  = deviceSettings;

            DownloadText        = AppResources.DownloadText;
            LastInformationText = AppResources.LastInformationText;
            DownloadButtonText  = AppResources.DownloadButtonText;

            var culture = DependencyService.Get <ILocale>().GetCurrentCultureInfo();

            if (culture.TwoLetterISOLanguageName == "fr")
            {
                LanguageId = 2;
            }
            else if (culture.TwoLetterISOLanguageName == "es")
            {
                LanguageId = 3;
            }
            else
            {
                LanguageId = 1;
            }


            //GetUserInfo
            var userInfo = _userInfoService.GetSavedInfo();

            if (!string.IsNullOrEmpty(userInfo.LastDownload))
            {
                try
                {
                    var last = DateTime.Parse(userInfo.LastDownload);
                    var ci   = DependencyService.Get <ILocale>().GetCurrentCultureInfo();
                    LastInformationTextDate = userInfo.LastDownload;                     //string.Format(ci, "{0}", last);
                }
                catch
                {
                    LastInformationText = AppResources.NoDownloadText;
                }
            }
            else
            {
                LastInformationText = AppResources.NoDownloadText;
            }
        }
示例#17
0
 public virtual bool Equals(IDeviceSettings other)
 {
     return(Equals(other as DeviceSettings));
 }