Ejemplo n.º 1
0
        /// <summary>
        /// Set List of Characters to print.
        /// </summary>
        public async Task SetCharacters(CancellationToken token = default, params Character[] lstCharacters)
        {
            token.ThrowIfCancellationRequested();
            IAsyncDisposable objLocker = await _lstCharacters.LockObject.EnterWriteLockAsync(token);

            try
            {
                token.ThrowIfCancellationRequested();
                foreach (Character objCharacter in _lstCharacters)
                {
                    objCharacter.PropertyChanged         -= ObjCharacterOnPropertyChanged;
                    objCharacter.SettingsPropertyChanged -= ObjCharacterOnSettingsPropertyChanged;
                }
                await _lstCharacters.ClearAsync();

                if (lstCharacters != null)
                {
                    await _lstCharacters.AddRangeAsync(lstCharacters);
                }
                foreach (Character objCharacter in _lstCharacters)
                {
                    objCharacter.PropertyChanged         += ObjCharacterOnPropertyChanged;
                    objCharacter.SettingsPropertyChanged += ObjCharacterOnSettingsPropertyChanged;
                }
            }
            finally
            {
                await objLocker.DisposeAsync();
            }

            await UpdateWindowTitleAsync(token);

            token.ThrowIfCancellationRequested();
            bool blnOldLoading = _blnLoading;

            try
            {
                _blnLoading = true;
                // Populate the XSLT list with all of the XSL files found in the sheets directory.
                await LanguageManager.PopulateSheetLanguageListAsync(cboLanguage, _strSelectedSheet, _lstCharacters);
                await PopulateXsltList(token);
                await RefreshCharacters(token);
            }
            finally
            {
                _blnLoading = blnOldLoading;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Set List of Characters to print.
        /// </summary>
        public async ValueTask SetCharacters(params Character[] lstCharacters)
        {
            IAsyncDisposable objLocker = await _lstCharacters.LockObject.EnterWriteLockAsync();

            try
            {
                foreach (Character objCharacter in _lstCharacters)
                {
                    objCharacter.PropertyChanged -= ObjCharacterOnPropertyChanged;
                }

                await _lstCharacters.ClearAsync();

                if (lstCharacters != null)
                {
                    await _lstCharacters.AddRangeAsync(lstCharacters);
                }
                foreach (Character objCharacter in _lstCharacters)
                {
                    objCharacter.PropertyChanged += ObjCharacterOnPropertyChanged;
                }
            }
            finally
            {
                await objLocker.DisposeAsync();
            }

            bool blnOldLoading = _blnLoading;

            try
            {
                _blnLoading = true;
                // Populate the XSLT list with all of the XSL files found in the sheets directory.
                await LanguageManager.PopulateSheetLanguageListAsync(cboLanguage, _strSelectedSheet, _lstCharacters);
                await PopulateXsltList();
                await RefreshCharacters();
            }
            finally
            {
                _blnLoading = blnOldLoading;
            }
        }