コード例 #1
0
        public MainViewModel(IModel model)
        {
            _model = model;

            InitializeIdentityManager();
            InitializeModelEvents();
            InitializeViews();
            InitializeRelayCommands();
            InitializeAppIdHandlerEvents();
            IsUserLoggedIn = false;

            _startScreenView = new StartScreenView();

            _model.TriggerChangeViewEvent(View.StartScreenView, View.MainView, false);
            _model.SetUserNameInfo(DEFAULT_NO_USERNAME_INFO);
            _model.SetLoadedMapNameInfo(DEFAULT_NO_MAPNAME_INFO);
            _loadedMapType = LoadedMapType.None;

            IsNetworkAvailable = _model.CheckIsNetworkAvailable();
            IsSyncPossible = IsNetworkAvailable && IsUserLoggedIn && _model.IsSyncPossible;
            IsArcGisPortalWebMapItemsSearchPossible = IsNetworkAvailable && IsUserLoggedIn;
            Messages = new ObservableCollection<string>();
        }
コード例 #2
0
		public void SetLoadedMapTypeInfo(LoadedMapType loadedMapTypeInfo)
		{
			ChangeMapTypeInfo(loadedMapTypeInfo);
		}
コード例 #3
0
        private void InitializeModelEvents()
        {
            _model.OAuth2TokenTokenReceived += p =>
            {
                if (p == null)
                {
                    IsUserLoggedIn = false;
                    IsSyncPossible = IsNetworkAvailable && IsUserLoggedIn && _model.IsSyncPossible;
                    IsArcGisPortalWebMapItemsSearchPossible = IsNetworkAvailable && IsUserLoggedIn;
                    return;
                }
                IsUserLoggedIn = true;
                IsSyncPossible = IsNetworkAvailable && IsUserLoggedIn && _model.IsSyncPossible;
                IsArcGisPortalWebMapItemsSearchPossible = IsNetworkAvailable && IsUserLoggedIn;
                UpdateIdentityManager(p);
                _model.DoResetArcGisPortalItemsView();
                _model.SetUserNameInfo(p.UserName);
                _model.SetMessageInfo(UserNameInfo + DEFAULT_LOGGED_IN_INFO);
            };

            _model.ChangeMessageInfo += p =>
            {
                if (p != string.Empty)
                {
                    Messages.Insert(0, p);
                }

                MessageInfo = p;
            };

            _model.ChangeUserNameInfo += p => { UserNameInfo = p; };

            _model.ChangeMapNameInfo += p => { LoadedMapNameInfo = p; };

            _model.ChangeMapTypeInfo += p =>
            {
                _loadedMapType = p;

                switch (p)
                {
                    case LoadedMapType.Online:
                        LoadedMapTypeInfo = "[online map]";
                        break;
                    case LoadedMapType.Offline:
                        LoadedMapTypeInfo = "[offline map]";
                        break;
                    case LoadedMapType.None:
                        LoadedMapTypeInfo = string.Empty;
                        break;
                }
            };

            _model.ChangeView += (newView, sourceView, changeBackToSource) =>
            {
                if (_changeBackToPredecessorView)
                {
                    SetView(_predecessorView);
                    _predecessorView = View.MainView;
                    _changeBackToPredecessorView = false;
                    return;
                }

                _predecessorView = sourceView;
                _changeBackToPredecessorView = changeBackToSource;
                SetView(newView);
            };

            _model.ChangeRibbonTabSelectedState += p =>
            {
                switch (p)
                {
                    case RibbonTabState.Config:
                        RibbonTabSelectedIndex = 0;
                        break;
                    case RibbonTabState.Map:
                        RibbonTabSelectedIndex = 1;
                        break;
                }
            };

            _model.NetworkStatusAvailabilityChanged += p =>
            {
                IsNetworkAvailable = p;
                IsSyncPossible = IsNetworkAvailable && IsUserLoggedIn && _model.IsSyncPossible;
                IsArcGisPortalWebMapItemsSearchPossible = IsNetworkAvailable && IsUserLoggedIn;
            };

            _model.SyncStateChanged += () => { IsSyncPossible = IsNetworkAvailable && IsUserLoggedIn && _model.IsSyncPossible; };
        }