private void PlayAndAddToRecent(ItemEx item) { var items = _dataService.AddToRecentlyPlayedList(item); RecentlyPlayedChannels.Clear(); foreach (var tempItem in items) { if (RecentlyPlayedChannels.FirstOrDefault(o => o.chlink == tempItem.chlink) == null) { RecentlyPlayedChannels.Add(tempItem); } } if (RecentlyPlayedChannels.Count > 0) { AreRecentChannelsPresent = true; } else { AreRecentChannelsPresent = false; } DependencyObject rootGrid = VisualTreeHelper.GetChild(Window.Current.Content, 0); if (rootGrid != null) { var mediaPlayer = (MediaElement)VisualTreeHelper.GetChild(rootGrid, 0); if (mediaPlayer != null) { mediaPlayer.Source = new Uri(SelectedChannel.chlink, UriKind.RelativeOrAbsolute); mediaPlayer.Play(); } } }
public List <ItemEx> AddToRecentlyPlayedList(ItemEx item) { if (_recentlyPlayedChannels == null) { _recentlyPlayedChannels = new List <ItemEx>(); } else { _recentlyPlayedChannels.Reverse(); if (_recentlyPlayedChannels.FirstOrDefault(o => o.chlink == item.chlink) == null) { if (_recentlyPlayedChannels.Count > 9) { _recentlyPlayedChannels.RemoveAt(0); } _recentlyPlayedChannels.Add(item); } else { if (_recentlyPlayedChannels.Count > 9) { _recentlyPlayedChannels.RemoveAt(0); } _recentlyPlayedChannels.Remove(item); _recentlyPlayedChannels.Add(item); } } AppHelper.Instance.SetRecentChannels(_recentlyPlayedChannels); _recentlyPlayedChannels.Reverse(); return(_recentlyPlayedChannels); }
public bool UpdateItemInTable(Item item) { bool updated = false; try { using (var db = new SQLiteConnection(dbPath)) { string query = string.Format("select * from ItemEx where chlink = '{0}'", item.chlink); var existing = db.Query <ItemEx>(query).FirstOrDefault(); if (existing == null) { db.RunInTransaction(() => { ItemEx newItem = new ItemEx(); newItem.category = item.category; newItem.chcat = item.chcat; newItem.chdescription = item.chdescription; newItem.chlink = item.chlink; newItem.chtype = item.chtype; newItem.title = item.title; db.Insert(newItem, typeof(ItemEx)); updated = true; }); } else { db.RunInTransaction(() => { try { existing.category = item.category; existing.chcat = item.chcat; existing.chdescription = item.chdescription; if (existing.chlink != item.chlink) { existing.chlink = item.chlink; } existing.chtype = item.chtype; existing.title = item.title; db.Update(existing, typeof(ItemEx)); updated = true; } catch (Exception ex) { Debug.WriteLine("venkat:" + ex.ToString()); } }); } db.Commit(); db.Close(); } } catch (Exception e) { Debug.WriteLine("venkat1: " + e.ToString()); } return(updated); }
public List <ItemEx> RemoveFromFavChannels(ItemEx item) { if (_favChannels != null && _favChannels.Contains(item)) { _favChannels.Remove(item); } SQLiteWrapper.Instance.UpdateItemExInTable(item); return(_favChannels); }
public void FixedUpdate() { if (_FollowCursor) { for (int i = 0; i < _Representation.Count; ++i) { ItemEx dir = _Representation[i]; Vector2 pos = dir.DesktopPosition; Vector2 target = Vector2.Lerp(pos, _CursorPos, 0.5f + (float)i / (float)(_Representation.Count * 2)); dir.DesktopPosition = target.ToIntVec(); } } }
private async Task DownloadFromCloud() { var newChannels = new List <Item>(); string remoteConfigFileUrl = "https://thehinduadrotator.blob.core.windows.net/adrotator/Channels.json"; HttpClientHandler handler = new HttpClientHandler(); handler.AutomaticDecompression = System.Net.DecompressionMethods.Deflate | System.Net.DecompressionMethods.GZip; HttpClient client = new HttpClient(handler); string remotConfiguration = await client.GetStringAsync(remoteConfigFileUrl); if (!string.IsNullOrEmpty(remotConfiguration)) { var remoteRootObject = await Task.Factory.StartNew(() => JsonConvert.DeserializeObject <RootObject>(remotConfiguration)); //var remoteRootObject = JsonConvert.DeserializeObject<RootObject>(remotConfiguration); if (remoteRootObject != null && remoteRootObject.rss != null && remoteRootObject.rss.channel != null) { newChannels = remoteRootObject.rss.channel.item; } } bool isTableCreated = await SQLiteWrapper.Instance.CreateTableIfNot(); if (isTableCreated == true) { foreach (var channel in newChannels) { SQLiteWrapper.Instance.UpdateItemInTable(channel); } _channels = SQLiteWrapper.Instance.GetAllItems(); } else { foreach (var channel in newChannels) { if (_channels.Find(o => o.chlink == channel.chlink) == null) { ItemEx item = new ItemEx(); item.category = channel.category; item.chcat = channel.chcat; item.chdescription = channel.chdescription; item.chlink = channel.chlink; item.chtype = channel.chtype; item.title = channel.title; _channels.Add(item); } } } }
public List <ItemEx> AddToFavChannels(ItemEx item) { if (_favChannels != null && !_favChannels.Contains(item)) { _favChannels.Add(item); } else if (_favChannels == null) { _favChannels = new List <ItemEx>(); _favChannels.Add(item); } SQLiteWrapper.Instance.UpdateItemExInTable(item); return(_favChannels); }
public void CreateAndLinkThumbnail(ItemEx item, Action <FileStream> streamWriter, out FileInfo file, out FileItemLinkChangeset linkCs, FileItemLink?linkSource = null) { var relativeThumbnailPath = item.GenerateRelativeThumbnailPath(); var root = item.RootPath; var absolutePath = Path.Combine(root, relativeThumbnailPath); createThumbnailDir(absolutePath); using (var fs = File.OpenWrite(absolutePath)) { streamWriter(fs); fs.Close(); } LinkThumbnail(item, absolutePath, out file, out linkCs, linkSource); }
public void CreateAndLinkThumbnail(ItemEx item) { try { var imgPath = item.GenerateAbsoluteThumbnailPath(); var itemPath = item.LatestFilePath; this.CreateAndLinkThumbnail(item, fs => { createThumbnail(itemPath, fs); }, out var file, out var linkCs); fileItemLinkService.Patch(linkCs); } catch (Exception ex) { throw new ThumbnailException("Thumbnail Could not be created", ex); } }
public void LinkThumbnail(ItemEx item, string thumbnailPath, out FileInfo file, out FileItemLinkChangeset linkCs, FileItemLink?linkSource = null) { FileHash hash = fileManagement.HashFile(thumbnailPath); file = new FileInfoChangeset(item.DirectorySetups.FirstOrDefault(), new SysFileInfo(thumbnailPath), hash).ToEntity(); var existing = fileDataService.GetExtendedByHash().Lookup(file.HashKey.Value); if (existing.HasValue) { file = existing.Value.FileInfo; } linkCs = new FileItemLinkChangeset(linkSource ?? item.LatestVersionedFile.Value.Link.Link) { ThumbnailKey = file.HashKey }; this.fileDataService.Post(file); }
private void btnOk_Click(object sender, EventArgs e) { if (cboUnit.SelectedIndex == -1) { MessageBox.Show("请选择要更换的单位", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (lblOldUnit.Text.Trim() == cboUnit.Text.Trim()) { this.DialogResult = DialogResult.Cancel; this.Close(); } DataRow row = ((DataRowView)cboUnit.SelectedItem).Row; dwbl = Convert.ToInt32(row["dwbl"]); selectedUnit = new ItemEx(); selectedUnit.Text = row["DWMC"].ToString().Trim(); selectedUnit.Value = Convert.ToInt32(row["ID"]); this.DialogResult = DialogResult.OK; this.Close(); }
public ItemTreeEntry(ItemEx item) { this.Item = item; this.Name = item.Name; }