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); }
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 OnTextChanged(object sender, TextChangedEventArgs e) { if (ignoreUpdate) { ignoreUpdate = false; return; } var tb = sender as TextBox; // Don't change selection when text is selected or no text if (!string.IsNullOrEmpty(tb.Text) && string.IsNullOrEmpty(tb.SelectedText)) { var currentText = tb.Text; // Clear the existing selections and cancel any background work SourceItems.Clear(); suggestions.Clear(); foreach (var worker in workers) { worker.CancelAsync(); } workers.Clear(); // Start udpate process foreach (var suggestionProvider in SuggestionProvidersCollection) { // Set up a background worker var bw = new BackgroundWorker { WorkerReportsProgress = true, WorkerSupportsCancellation = true }; workers.Add(bw); bw.DoWork += GetSuggestions_DoWork; bw.ProgressChanged += GetSuggestions_ProgressChanged; bw.RunWorkerCompleted += GetSuggestions_RunWorkerCompleted; bw.RunWorkerAsync(new BackgroundWorkerArguments { Provider = suggestionProvider, SearchText = currentText, CurrentValue = SelectedValue }); } } // Set focus on the text box tb.Focus(); }
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); }
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; } }