Ejemplo n.º 1
0
        public override async Task<List<IStorageItem>> PasteEntriesAsync(StorageFolder destFolder) {
            var newEntries = await base.PasteEntriesAsync(destFolder);

            // 执行Copy操作
            if (newEntries.Count > 0) {
                var firstFileIndex = ObservableExtension.FirstIndex(entries, p => p.EntryType == StorageEntryType.File);

                List<StorageEntry> newFiles = new List<StorageEntry>(), newFolders = new List<StorageEntry>();
                foreach (var storageItem in newEntries) {
                    var newEntry = new StorageEntry(storageItem, StorageEntryUsage.TilesFieldItem);
                    if (storageItem.IsOfType(StorageItemTypes.File)) {
                        newFiles.Add(newEntry);
                    } else {
                        newFolders.Add(newEntry);
                    }
                }
                // 首先插入文件
                newFiles.ForEach(p => entries.Add(p));
                // 然后插入文件夹
                for(int i = 0; i < newFolders.Count; i++) {
                    entries.Insert(firstFileIndex + i, newFolders[i]);
                }
            }

            return newEntries;
        }
Ejemplo n.º 2
0
        public IObservable <float> ReactToData(IEntity entity)
        {
            var healthComponent = entity.GetComponent <HealthComponent>();

            return(ObservableExtension.WithValueChanges(healthComponent.Health).Select(CalculateDamageTaken));
            //return healthComponent.Health.WithValueChanges<float>().Select(CalculateDamageTaken);
        }
Ejemplo n.º 3
0
        private void InitializeData()
        {
            this.accessGroups = new ObservableCollection <ObservableMPathAccessGroup>();
            this.agency.AccessGroups.ForEach(p => this.accessGroups.Add(
                                                 new ObservableMPathAccessGroup {
                Title = p.Title, itemLists = ObservableExtension.ToObserCollection(p.itemLists), IsExpand = p.IsExpand
            }));

            this.deviceItems = new ObservableCollection <MDeviceAccessItem>();
            this.agency.DrivesItems.ForEach(p => this.deviceItems.Add(p));
        }
        private async Task RefreshAsync()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                var authToken = _settingsService.AuthAccessToken;

                var trList = await _transactionService.GetTransactionsByDate(authToken, StartDate.ToUniversalTime(), EndDate.ToUniversalTime());

                var trViewModelList = ObservableExtension.ToTransactionViewModels(trList);
                TransactionsList = trViewModelList.OrderByDescending(c => c.OperationDateTime)
                                   .GroupBy(c => c.OperationDateView)
                                   .Select(c => new Grouping <string, TransactionViewModel>(c.Key, c))
                                   .ToObservableCollection();
            }
            catch (ServiceAuthenticationException ex)
            {
                Debug.WriteLine($"[RetrieveData] Error Retrieve Data: {ex}");
                await LogoutAsync();
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"[RetrieveData] Error Retrieve Data: {ex}");
                DialogService.ShowInformationUserMessage(this, "unable to retrieve data, check for Internet availability", "Cancel");
            }
            finally
            {
                IsBusy = false;
            }
        }