public void LoadDatabySort() { if (HIOStaticValues.CheckSyncingData()) { return; } #region Sort Data List <TAccountItem> items = SourceItems.ToList(); SourceItems.Clear(); if (SortByField.IsNullOrEmpty() || "Name".Equals(SortByField, StringComparison.InvariantCultureIgnoreCase)) { items = items.OrderBy(t => t.Name).ToList(); } else if ("Date".Equals(SortByField, StringComparison.InvariantCultureIgnoreCase)) { items = items.OrderByDescending(t => t.Date).ToList(); } else if ("Popularity".Equals(SortByField, StringComparison.InvariantCultureIgnoreCase)) { items = items.OrderByDescending(t => t.Popularity).ToList(); } #endregion #region Add Data foreach (var item in items) { SourceItems.Add(item); } #endregion OnPropertyChanged(nameof(Items)); }
private void LoadData(List <LoginFieldS> lf) { SourceItems.Clear(); if (lf != null && lf.Count > 0) { Converts conv = new Converts(); foreach (LoginFieldS fields in lf) { DrawingImage tmpDraw = new DrawingImage(); if (fields.imageData == null || fields.imageData.Length == 0) { tmpDraw = HIOStaticValues.PutTextInImage(fields.url.Substring(0, 1)); } else { tmpDraw = conv.BitmapImageToDrawingImage(conv.byteArrayToImage(fields.imageData)); } SourceItems.Add(new TLinkItem(fields.title, fields.userName, tmpDraw, Int32.Parse(fields.rowid), fields.url)); } } OnPropertyChanged(() => Items); }
public void PopulateItems() { if ((MetroManager.Current.RailwayIds == null) || !MetroManager.Current.RailwayIds.Any()) { return; } foreach (var railwayId in MetroManager.Current.RailwayIds) { var existingItem = SourceItems .FirstOrDefault(x => x.RailwayIds .Select(y => y.Replace("Branch", String.Empty)) .Contains(railwayId.Replace("Branch", String.Empty))); // For MarunouchiBranch if (existingItem != null) { existingItem.RailwayIds.Add(railwayId); } else { var newItem = new RailwayItemViewModel { RailwayIds = new List <string> { railwayId } }; SourceItems.Add(newItem); } } if ((Settings.Current.RailwayIdPriority == null) || !Settings.Current.RailwayIdPriority.Any()) { SelectedIndices = Enumerable.Range(0, SourceItems.Count).ToArray(); } else { var indices = new List <int>(); int order = 0; foreach (var railwayId in Settings.Current.RailwayIdPriority) { int index = 0; foreach (var item in SourceItems) { if (item.RailwayIds[0] == railwayId) { item.IsSelected = true; item.Order = order; indices.Add(index); break; } index++; } order++; } SelectedIndices = indices.ToArray(); } }
public async Task AddGroupToSource() { var result = await OpenNameEditingWindow(""); if (!string.IsNullOrWhiteSpace(result)) { SourceItems.Add(new ConditionGroupsEditorData(result)); } }
public void AddGroupToSource() { var result = ""; OpenNameEditingWindow("", out result); if (!string.IsNullOrWhiteSpace(result)) { SourceItems.Add(new SmartDataGroupsEditorData(result)); } }
private async void ResetItems() { var newOwner = Playlist; using (var releaser = await _PlaylistUpdateLock.LockAsync()) { PlayedItems.Clear(); _ItemsObservaeDisposer?.Dispose(); _ItemsObservaeDisposer = null; ResetRandmizedItems(SourceItems); if (newOwner is INotifyCollectionChanged playlistNotifyCollectionChanged) { _ItemsObservaeDisposer = playlistNotifyCollectionChanged.CollectionChangedAsObservable() .Subscribe(async _ => { using (var releaser2 = await _PlaylistUpdateLock.LockAsync()) { // 再生中アイテムが削除された時のプレイリストの動作 // 動画プレイヤーには影響を与えないこととする // 連続再生動作の継続性が確保できればOK SourceItems.Clear(); foreach (var newItem in newOwner.Select(x => new PlaylistItem() { ContentId = x, Owner = newOwner, Type = PlaylistItemType.Video, })) { SourceItems.Add(newItem); } ResetRandmizedItems(SourceItems); if (PlaylistSettings.IsShuffleEnable) { CurrentIndex = 0; } else { CurrentIndex = Current == null ? 0 : SourceItems.IndexOf(Current); } RaisePropertyChanged(nameof(CanGoBack)); RaisePropertyChanged(nameof(CanGoNext)); } }); } RaisePropertyChanged(nameof(CanGoBack)); RaisePropertyChanged(nameof(CanGoNext)); } }
private void LoadData(List <LoginFieldS> listlp) { SourceItems.Clear(); SourceAllItems.Clear(); DataBase db = new DataBase(); List <LoginFieldS> llp = db.getInfoFromDB("*", "", ""); Converts conv = new Converts(); if (listlp != null && listlp.Any()) { foreach (LoginFieldS lf in listlp) { DrawingImage tmpDraw = new DrawingImage(); if (lf.imageData == null || lf.imageData.Length == 0) { tmpDraw = HIOStaticValues.PutTextInImage(lf.url.Substring(0, 1)); } else { tmpDraw = conv.BitmapImageToDrawingImage(conv.byteArrayToImage(lf.imageData)); } SourceItems.Add(new TLinkItem { Title = lf.title, Description = lf.userName, ImageData = tmpDraw, Id = Int32.Parse(lf.rowid), Url = url }); } } if (llp != null && llp.Any()) { foreach (LoginFieldS lf in llp) { DrawingImage tmpDraw = new DrawingImage(); if (lf.imageData == null || lf.imageData.Length == 0) { tmpDraw = HIOStaticValues.PutTextInImage(lf.url.Substring(0, 1)); } else { tmpDraw = conv.BitmapImageToDrawingImage(conv.byteArrayToImage(lf.imageData)); } SourceAllItems.Add(new TLinkItem { Title = lf.title, Description = lf.userName, ImageData = tmpDraw, Id = Int32.Parse(lf.rowid), Url = lf.url }); } } OnPropertyChanged(() => Items); }
private void CellEditEnding(DataGridCellEditEndingEventArgs e) { var columnDisplayIndex = (DataGridColumns)e.Column.DisplayIndex; if (DataGridSelectedItem is Transaction selectedTransaction) { if (columnDisplayIndex == DataGridColumns.MoneySourceField) { if (!SourceItems.Contains(selectedTransaction.MoneySource)) { SourceItems.Add(selectedTransaction.MoneySource); } } } }
private void LoadBase() { var baseItems = db.GetItems(); ExpensesItems.Clear(); foreach (var transaction in baseItems) { ExpensesItems.Add(transaction); if (!SourceItems.Contains(transaction.MoneySource)) { SourceItems.Add(transaction.MoneySource); } } RaisePropertyChanged(nameof(ExpensesItems)); }
private void loadProducts(Trade trade) { foreach (var item in trade.TradeProducts.ToList()) { TradeSideEnum side = trade.GetTradeSide(item.EntityID); if (side == TradeSideEnum.Destination) { DestinationItems.Add(new ProductForTradeViewModel(item, TradeStatus)); } else { SourceItems.Add(new ProductForTradeViewModel(item, TradeStatus)); } } }
private void loadMoney(Trade trade) { foreach (var money in trade.TradeMoneys.ToList()) { TradeSideEnum side = trade.GetTradeSide(money.EntityID); if (side == TradeSideEnum.Destination) { DestinationItems.Add(new MoneyForTradeViewModel(money, TradeStatus)); } else { SourceItems.Add(new MoneyForTradeViewModel(money, TradeStatus)); } } }
private async Task OpenEditor(ConditionJsonData item, bool isCreating) { var vm = new ConditionEditorViewModel(in item, windowManager, parameterFactory); if (await windowManager.ShowDialog(vm) && !vm.IsEmpty()) { if (isCreating) { SourceItems.Add(vm.Source.ToConditionJsonData()); } else { if (SelectedIndex >= 0) { SourceItems[SelectedIndex] = vm.Source.ToConditionJsonData(); } } } }
private void GetSuggestions_ProgressChanged(object sender, ProgressChangedEventArgs e) { var workerSuggestion = e.UserState as BackgroundWorkerSuggestion; if (workers.Contains(workerSuggestion.Worker)) { var newSuggestions = workerSuggestion.Suggestions; foreach (var suggestion in newSuggestions) { suggestions.Add(suggestion); } // Update suggestions foreach (var s in suggestions.OrderBy(s => s.Probability).Reverse()) { SourceItems.Add(s); } // Open or close dropdown of the ComboBox according to whether there are sourceItems in the // filtered result. IsDropDownOpen = suggestions.Any(); EditableTextBox.SelectionStart = EditableTextBox.Text.Length; } }
void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { switch (e.Action) { case NotifyCollectionChangedAction.Add: if (e.NewStartingIndex < 0) { goto case NotifyCollectionChangedAction.Reset; } // if a NewStartingIndex that's too high is passed in just add the items. // I realize this is enforcing bad behavior but prior to this synchronization // code being added it wouldn't cause the app to crash whereas now it does // so this code accounts for that in order to ensure smooth sailing for the user if (e.NewStartingIndex >= SourceItems.Count) { for (int i = 0; i < e.NewItems.Count; i++) { SourceItems.Add((e.NewItems[i] as BindableObject).BindingContext); } } else { for (int i = e.NewItems.Count - 1; i >= 0; i--) { SourceItems.Insert(e.NewStartingIndex, (e.NewItems[i] as BindableObject).BindingContext); } } break; case NotifyCollectionChangedAction.Remove: for (int i = e.OldItems.Count - 1; i >= 0; i--) { SourceItems.RemoveAt(e.OldStartingIndex); } break; case NotifyCollectionChangedAction.Move: for (var i = 0; i < e.OldItems.Count; i++) { var oldi = e.OldStartingIndex; var newi = e.NewStartingIndex; if (e.NewStartingIndex < e.OldStartingIndex) { oldi += i; newi += i; } SourceItems.Move(oldi, newi); } break; case NotifyCollectionChangedAction.Replace: case NotifyCollectionChangedAction.Reset: default: ClearSizeEstimate(); ReloadData(); break; } Device.BeginInvokeOnMainThread(() => List.UpdateLayout()); }
internal async void PlayStarted(PlaylistItem item) { if (item == null) { throw new Exception(); } using (var releaser = await _PlaylistUpdateLock.LockAsync()) { // 新たにプレイリストが指定された場合に // 連続再生をセットアップする if (item.Owner != null) { if (item.Owner != Playlist) { Playlist = item.Owner; } } SourceItems.Clear(); foreach (var newItem in Playlist.Select(x => new PlaylistItem() { ContentId = x, Owner = Playlist, Type = PlaylistItemType.Video, })) { SourceItems.Add(newItem); } RaisePropertyChanged(nameof(CanGoBack)); RaisePropertyChanged(nameof(CanGoNext)); // Current = SourceItems.First(x => item.ContentId == x.ContentId); // GoNext/GoBack内でCurrentが既に変更済みの場合はスキップ // Playlist外から直接PlaylistItemが変更された場合にのみ // 現在再生位置の更新を行う if (Current != item) { Current = item; if (SourceItems != null) { CurrentIndex = PlaylistSettings.IsShuffleEnable ? 0 : SourceItems.IndexOf(Current); } else { CurrentIndex = 0; } // ランダム再生かつ先頭の再生を行う場合は // ランダムアイテムの先頭が現在再生中アイテムになるように // ランダムアイテムリストを修正する // この修正によって、シャッフル再生が先頭しか再生されない問題を回避できる if (CurrentIndex == 0 && PlaylistSettings.IsShuffleEnable) { if (RandamizedItems.FirstOrDefault() != Current) { RandamizedItems.Remove(Current); RandamizedItems.Insert(0, Current); } } } } }
public async Task LoadingAsync() { try { if (HIOStaticValues.CheckSyncingData()) { SyncronizingState = SyncronizingStateEnum.Syncronizing; Trace.WriteLine("SyncronizingState in dashboard:" + SyncronizingState); Trace.WriteLine("percent in dashboard:" + ProgressPercent); DispatcherTimer dt = new DispatcherTimer(); dt.Interval = TimeSpan.FromSeconds(1); dt.Tick += Dt_Tick; dt.Start(); return; } App.Current.Dispatcher.Invoke(new Action(() => { SourceItems.Clear(); })); Converts conv = new Converts(); DataBase db = new DataBase(); // HIOStaticValues.commandQ.Add(()=> QBatteryandSignalCheckAsync()); Commands ic = new Commands(); HIOStaticValues.commandQ.Add(() => { BatteryValue = ic.GetBatteryStatus(); }); HIOStaticValues.commandQ.Add(() => { Commands cmd = new Backend.Commands(); cmd.GetRssi(); App.Current.Dispatcher.Invoke(new Action(() => { SignalValue = cmd.GetSignalStatus(HIOStaticValues.blea.rssi); })); }); HIOStaticValues.commandQ.Add(() => { App.Current.Dispatcher.Invoke(new Action(async() => { SyncronizingState = ic.AmISync(); if (SyncronizingState == SyncronizingStateEnum.NotSynced) { await Syncronize(); } })); }); App.Current.Dispatcher.Invoke(new Action(async() => { //READ DATA lp = await Task.Run(() => { return(db.ReadData()); }); if (lp != null) { ItemCounter = (lp.Count > 1) ? lp.Count + " Items" : lp.Count + " Item"; } //Note : lp may be null if (lp != null && lp.Any()) { #region Load Data List <TAccountItem> items = new List <TAccountItem>(); foreach (var item in lp) { DrawingImage tmpDraw = new DrawingImage(); if (item.imageData == null || item.imageData.Length == 0) { tmpDraw = HIOStaticValues.PutTextInImage(item.url.Substring(0, 1)); } else { tmpDraw = conv.BitmapImageToDrawingImage(conv.byteArrayToImage(item.imageData)); } items.Add(new TAccountItem(this) { UserID = item.rowid, Name = item.title, Username = item.userName, Url = item.url, ImageData = tmpDraw, AppID = item.appID, SubTitle1 = item.userName, SubTitle2 = conv.GetPrettyDate(item.last_used), Popularity = item.popularity, Date = item.last_used }); // items.Add(new User() { Title = listlp[i].title, Username = listlp[i].userName, rowid = listlp[i].rowid }); } #endregion #region Sort Data if (SortByField.IsNullOrEmpty() || "Name".Equals(SortByField, StringComparison.InvariantCultureIgnoreCase)) { items = items.OrderBy(t => t.Name).ToList(); } else if ("Date".Equals(SortByField, StringComparison.InvariantCultureIgnoreCase)) { items = items.OrderByDescending(t => t.Date).ToList(); } else if ("Popularity".Equals(SortByField, StringComparison.InvariantCultureIgnoreCase)) { items = items.OrderByDescending(t => t.Popularity).ToList(); } #endregion #region Add Data foreach (var item in items) { SourceItems.Add(item); } #endregion } OnPropertyChanged(nameof(Items)); })); } catch (Exception ex) { } finally { NotifyItemsChanged(); } }
public async Task LoadData() { try { App.Current.Dispatcher.Invoke(new Action(async() => { SourceItems.Clear(); DataBase db = new DataBase(); Converts conv = new Converts(); lp = await Task.Run(() => { return(db.ReadData()); }); if (lp != null) { ItemCounter = (lp.Count > 1) ? lp.Count + " Items" : lp.Count + " Item"; } //Note : lp may be null if (lp != null && lp.Any()) { #region Load Data List <TAccountItem> items = new List <TAccountItem>(); foreach (var item in lp) { DrawingImage tmpDraw = new DrawingImage(); if (item.imageData == null || item.imageData.Length == 0) { tmpDraw = HIOStaticValues.PutTextInImage(item.url.Substring(0, 1)); } else { tmpDraw = conv.BitmapImageToDrawingImage(conv.byteArrayToImage(item.imageData)); } items.Add(new TAccountItem(this) { UserID = item.rowid, Name = item.title, Username = item.userName, Url = item.url, ImageData = tmpDraw, AppID = item.appID, SubTitle1 = item.userName, SubTitle2 = conv.GetPrettyDate(item.last_used), Popularity = item.popularity, Date = item.last_used }); // items.Add(new User() { Title = listlp[i].title, Username = listlp[i].userName, rowid = listlp[i].rowid }); } #endregion #region Sort Data if (SortByField.IsNullOrEmpty() || "Name".Equals(SortByField, StringComparison.InvariantCultureIgnoreCase)) { items = items.OrderBy(t => t.Name).ToList(); } else if ("Date".Equals(SortByField, StringComparison.InvariantCultureIgnoreCase)) { items = items.OrderByDescending(t => t.Date).ToList(); } else if ("Popularity".Equals(SortByField, StringComparison.InvariantCultureIgnoreCase)) { items = items.OrderByDescending(t => t.Popularity).ToList(); } #endregion #region Add Data foreach (var item in items) { SourceItems.Add(item); } #endregion } OnPropertyChanged(nameof(Items)); })); } catch { } finally { // NotifyItemsChanged(); // SyncronizingState = SyncronizingStateEnum.Completed; } }