예제 #1
0
		protected override async Task OpenMayOverrideAsync(object args = null)
		{
			if (!_isLight) await GetCreateBindersDirectoryAsync().ConfigureAwait(false);
			await LoadAsync().ConfigureAwait(false);
			if (!_isLight) await LoadDbNames().ConfigureAwait(false);

			_runtimeData = RuntimeData.GetInstance(this, _isLight);
			await _runtimeData.OpenAsync().ConfigureAwait(false);
			if (!_isLight) RaisePropertyChanged_UI(nameof(RuntimeData)); // notify the UI once the data has been loaded

			_metaBriefcase = MetaBriefcase.GetInstance(_runtimeData, this);
			if (_isLight) return;

			var mbcOpenParams = new MetaBriefcase.OpenParameters(null, false, IsWantToUseOneDrive);
			await _metaBriefcase.OpenAsync(mbcOpenParams).ConfigureAwait(false);
			RaisePropertyChanged_UI(nameof(MetaBriefcase)); // notify the UI once the data has been loaded

			_isWantAndCanUseOneDrive = IsWantToUseOneDrive && mbcOpenParams.IsLocalSyncedOnceSinceLastOpen && _runtimeData.IsConnectionAvailable;
			RaisePropertyChanged_UI(nameof(IsWantAndCanUseOneDrive));
			_isWantAndCannotUseOneDrive = _isWantToUseOneDrive && !_isWantAndCanUseOneDrive;
			RaisePropertyChanged_UI(nameof(IsWantAndCannotUseOneDrive));

			_runtimeData.PropertyChanged += OnRuntimeData_PropertyChanged;

			await UpdateCurrentBinder2Async(false).ConfigureAwait(false);
		}
예제 #2
0
		public Task<bool> ImportSettingsAsync(StorageFile fromFile)
		{
			return RunFunctionIfOpenAsyncTB(async delegate
			{
				if (fromFile == null) return false;

				bool wasOpen = await CloseCurrentBinder2Async().ConfigureAwait(false);

				await _metaBriefcase.CloseAsync().ConfigureAwait(false);
				// do not replace the instance or you may screw the binding. Close, change and reopen will do.
				//_metaBriefcase.SetSourceFileJustOnce(fromFile);
				var mbcOpenParams = new MetaBriefcase.OpenParameters(fromFile, true, false);
				await _metaBriefcase.OpenAsync(mbcOpenParams).ConfigureAwait(false);
				RaisePropertyChanged_UI(nameof(MetaBriefcase)); // notify the UI once the data has been loaded

				// update the current binder, whichever it is, and open it if it was open before
				await UpdateCurrentBinder2Async(wasOpen).ConfigureAwait(false);
				return true;
			});
		}
예제 #3
0
		private async Task UpdateIsWantAndCanUseOneDrive2Async(bool isLoadFromOneDriveThisOneTime = true, bool force = false)
		{
			if (_isWantToUseOneDrive && _isWantAndCanUseOneDrive && !force) return;

			if (_isWantToUseOneDrive)
			{
				if (_runtimeData.IsConnectionAvailable)
				{
					bool wasOpen = await CloseCurrentBinder2Async().ConfigureAwait(false);
					await _metaBriefcase.CloseAsync().ConfigureAwait(false);

					var mbcOpenParams = new MetaBriefcase.OpenParameters(null, true, isLoadFromOneDriveThisOneTime);
					await _metaBriefcase.OpenAsync(mbcOpenParams).ConfigureAwait(false);
					RaisePropertyChanged_UI(nameof(MetaBriefcase)); // notify the UI once the data has been loaded
																	// update the current binder, whichever it is, and open it if it was open before
					await UpdateCurrentBinder2Async(wasOpen).ConfigureAwait(false);

					_isWantAndCanUseOneDrive = mbcOpenParams.IsLocalSyncedOnceSinceLastOpen;
				}
				else
				{
					_isWantAndCanUseOneDrive = false;
				}
			}
			else
			{
				_isWantAndCanUseOneDrive = false;
			}
			RaisePropertyChanged_UI(nameof(IsWantAndCanUseOneDrive));

			_isWantAndCannotUseOneDrive = _isWantToUseOneDrive && !_isWantAndCanUseOneDrive;
			RaisePropertyChanged_UI(nameof(IsWantAndCannotUseOneDrive));
		}