/// <summary> /// Remove a bookmark from the bookmarks list. Used to lighten the /// methods using such an operation. /// </summary> /// <param name="bookmark">Bookmark to be removed</param> public void RemoveBookmark(Bookmark bookmark) { if (BookmarkList.Contains(bookmark)) { BookmarkList.Remove(bookmark); } }
/// <summary> /// Deletes the given BookmarkList and all contained articles from disk. /// </summary> /// <param name="bookmarkList">The bookmark list to be deleted.</param> public async Task DeleteBookmarkList(BookmarkList masterList, BookmarkList bookmarkList) { StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder; foreach (var bookmark in bookmarkList.Bookmarks) { if (masterList.Bookmarks.Contains(bookmark)) { var targetBookmark = masterList.Bookmarks.First(mlBookmark => bookmark.Id == mlBookmark.Id); var folder = await local.CreateFolderAsync(targetBookmark.Article.Id, CreationCollisionOption.OpenIfExists); masterList.Bookmarks.Remove(bookmark); await folder.DeleteAsync(); } } var file = await local.CreateFileAsync("bookmarks", CreationCollisionOption.ReplaceExisting); var fileStream = await file.OpenStreamForWriteAsync(); using (var writer = new BsonWriter(new BinaryWriter(fileStream))) { var serializer = new JsonSerializer(); serializer.Serialize(writer, masterList); } }
/// <summary> /// Merges the two lists and downloads their articles. /// </summary> /// <param name="readabilityClient">The readabilty client to use to request the documents.</param> /// <param name="masterList">The list that will contain the final list of bookmarks.</param> /// <param name="bookmarkList">The bookmark list to be saved.</param> /// <returns>An awaitable task.</returns> public async Task MergeSaveBookmarkList(MainViewModel mainViewModel, BookmarkList bookmarkList) { mainViewModel.ProgressValue = 0; mainViewModel.ProgressIndeterminate = false; mainViewModel.ProgressText = "Syncing..."; StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder; var tasks = new List <Task>(); foreach (var bookmark in bookmarkList.Bookmarks) { var saveCompleteAction = new Action(() => { int position = mainViewModel.BookmarkList.Bookmarks.IndexOf(bookmark); mainViewModel.BookmarkList.Bookmarks.Remove(bookmark); if (position == -1) { mainViewModel.BookmarkList.Bookmarks.Add(bookmark); } else { mainViewModel.BookmarkList.Bookmarks.Insert(position, bookmark); } mainViewModel.ProgressValue += ((double)1 / (double)bookmarkList.Bookmarks.Count); }); tasks.Add(SaveArticle(bookmark, mainViewModel.ReadabilityClient, local, saveCompleteAction)); } await Task.WhenAll(tasks); mainViewModel.ProgressIndeterminate = true; mainViewModel.ProgressText = "Almost done..."; await SaveBookmarkList(mainViewModel.ReadabilityClient, mainViewModel.BookmarkList); }
public async Task <bool> Handle(CreateBookmarkListCommand message, CancellationToken cancellationToken) { var bookmarkList = new BookmarkList(message.Name, message.UserId); //todo add user details to bookmarking list class _bookmarkListRepository.Add(bookmarkList); return(await _bookmarkListRepository.UnitOfWork.SaveEntitiesAsync()); }
// 创建书签 private void barButtonItem19_ItemClick(object sender, ItemClickEventArgs e) { using (frmBookmarkAdd frm = new frmBookmarkAdd()) { if (frm.ShowDialog() == DialogResult.OK) { // 创建书签 ISceneBookmarks pBookmarks = MainCtrl.GlobeMapContainer.globeCtrl.axGlobeControl1.Globe.GlobeDisplay.Scene as ISceneBookmarks; ICamera camera = MainCtrl.GlobeMapContainer.globeCtrl.axGlobeControl1.Globe.GlobeDisplay.ActiveViewer.Camera; string name = frm.GetName(); string remark = frm.GetRemark(); IBookmark3D pBookmark3D = new Bookmark3DClass(); pBookmark3D.Name = name; pBookmark3D.Capture(camera); pBookmarks.AddBookmark(pBookmark3D); // 保存书签 Bookmark bm = new Bookmark(); bm.Altitude = camera.Observer.Z; bm.Azimuth = camera.Azimuth; bm.Inclination = camera.Inclination; bm.Latitude = camera.Observer.Y; bm.Longitude = camera.Observer.X; bm.Name = name; bm.Remark = remark; bm.RollAngle = camera.RollAngle; bm.Show = "true"; bm.ViewFieldAngle = camera.ViewFieldAngle; bm.ViewingDistance = camera.ViewingDistance; string xmlFile = AppDomain.CurrentDomain.BaseDirectory + "Config\\Bookmark.xml"; BookmarkList bookmarkList = null; if (File.Exists(xmlFile)) { bookmarkList = XmlHelper.XmlDeserializeFromFile <BookmarkList>(xmlFile, Encoding.UTF8); } if (bookmarkList == null) { bookmarkList = new BookmarkList(); bookmarkList.BookmarkArr.Add(bm); } else { bookmarkList.BookmarkArr.Add(bm); } // 发布事件,通知主窗体添加按钮 EventPublisher.PublishShowBookmarkEvent(this, new ShowBookmarkEventArgs() { NameList = new System.Collections.Generic.List <string> { name }, Append = true }); // 将书签信息保存到xml配置文件 XmlHelper.XmlSerializeToFile(bookmarkList, xmlFile, Encoding.UTF8); } } }
public static async Task SaveBookmarkDataAsync() { if (BookmarkList.Count > 100) { BookmarkList.RemoveRange(0, BookmarkList.Count - 100); } if (BookmarkList != null) { await SaveToRoamingFolderAsync(BookmarkList, LocalBookmarkFilePath); } }
public void AddBookmark(Bookmark bookmark, bool affectsBusyCount) { if (this.bookmarks == null) { this.bookmarks = new BookmarkList(); } if (affectsBusyCount) { this.BlockingBookmarkCount++; } this.bookmarks.Add(bookmark); }
// 初始化书签 private void InitBookmark() { return; string xmlFile = AppDomain.CurrentDomain.BaseDirectory + "Config\\Bookmark.xml"; if (!File.Exists(xmlFile)) { return; } BookmarkList bookmarkList = XmlHelper.XmlDeserializeFromFile <BookmarkList>(xmlFile, Encoding.UTF8); if (bookmarkList == null || bookmarkList.BookmarkArr == null || bookmarkList.BookmarkArr.Count <= 0) { return; } List <string> names = new List <string>(); foreach (Bookmark mark in bookmarkList.BookmarkArr) { // 创建书签 ISceneBookmarks pBookmarks = axGlobeControl1.Globe.GlobeDisplay.Scene as ISceneBookmarks; IPoint point = new PointClass(); point.X = mark.Longitude; point.Y = mark.Latitude; point.Z = mark.Altitude; ICamera camera = new CameraClass(); camera.ProjectionType = esri3DProjectionType.esriPerspectiveProjection; camera.Inclination = mark.Inclination; camera.Azimuth = mark.Azimuth; camera.RollAngle = mark.RollAngle; camera.ViewFieldAngle = mark.ViewFieldAngle; camera.ViewingDistance = mark.ViewingDistance; camera.Observer = point; IBookmark3D pBookmark3D = new Bookmark3DClass(); pBookmark3D.Name = mark.Name; pBookmark3D.Capture(camera); pBookmarks.AddBookmark(pBookmark3D); // 发布事件,通知主窗体添加按钮 EventPublisher.PublishShowBookmarkEvent(this, new ShowBookmarkEventArgs() { NameList = new System.Collections.Generic.List <string> { mark.Name }, Append = true }); } }
public static async Task PullBookmarkFromUserFavoriteAsync(bool forectRefresh = false, bool forceSyncFromCloud = false) { if (BookmarkList == null) { await LoadBookmarkDataAsync(); } if (User != null) { // guard about login data return; await User.SyncFavoriteListAsync(forectRefresh); var favList = from fav in User.FavoriteList orderby fav.VolumeId group fav by fav.SeriesTitle; bool Changed = false; if (forceSyncFromCloud) { for (int i = 0; i < BookmarkList.Count; i++) { var bk = BookmarkList[i]; if (!favList.Any(g => g.First().SeriesTitle == bk.SeriesTitle)) { BookmarkList.RemoveAt(i--); Changed = true; } } } foreach (var series in favList) { var vol = series.LastOrDefault(); if (BookmarkList.Any(bk => bk.SeriesTitle == vol.SeriesTitle)) { continue; } var item = new BookmarkInfo { SeriesTitle = vol.SeriesTitle, VolumeTitle = vol.VolumeTitle, ViewDate = vol.FavTime }; item.Position = new NovelPositionIdentifier { /*SeriesId = volume.ParentSeriesId,*/ VolumeId = vol.VolumeId, VolumeNo = -1 }; BookmarkList.Add(item); Changed = true; } if (Changed) { await SaveBookmarkDataAsync(); } } }
/// <summary> /// Saves the given bookmark list to a file and downloads all the articles in those bookmarks. /// </summary> /// <param name="readabilityClient">The readability client to use to request the documents.</param> /// <param name="bookmarkList">The bookmark list to be saved.</param> /// <returns>A simple task to make this awaitable.</returns> public async Task SaveBookmarkList(ReadabilityClient readabilityClient, BookmarkList masterList) { StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder; var file = await local.CreateFileAsync("bookmarks", CreationCollisionOption.ReplaceExisting); var fileStream = await file.OpenStreamForWriteAsync(); using (var writer = new BsonWriter(new BinaryWriter(fileStream))) { var serializer = new JsonSerializer(); serializer.Serialize(writer, masterList); } }
private void loadFolder(String folder_id) { Folder f = new Folder(getConnector()); f.Id = folder_id; f.GetBookmarks(delegate(IAsyncResult res) { BookmarkList.Clear(); for (int i = 0; i < f.Bookmarks.Count; i++) { Bookmark bookmark = f.Bookmarks[i]; BookmarkList.Items.Add(bookmark.Title); Console.WriteLine("Adding Bookmark: " + bookmark.Title); } currentBookmarks = f.Bookmarks; }); }
public void PurgeBookmarks(BookmarkScopeManager bookmarkScopeManager, BookmarkManager bookmarkManager, System.Activities.ActivityInstance owningInstance) { if ((this.bookmarks != null) && (this.bookmarks.Count > 0)) { Bookmark bookmark; IList <Bookmark> list; this.bookmarks.TransferBookmarks(out bookmark, out list); this.bookmarks = null; if (bookmarkScopeManager != null) { bookmarkScopeManager.PurgeBookmarks(bookmarkManager, bookmark, list); } else { bookmarkManager.PurgeBookmarks(bookmark, list); } owningInstance.DecrementBusyCount(this.BlockingBookmarkCount); this.BlockingBookmarkCount = 0; } }
public MainViewModel() { ApiBaseUrl = ""; ConsumerKey = ""; ConsumerSecret = ""; ProgressVisible = false; DataStorage = new DataStorage(); BookmarkList = new BookmarkList(); ReadabilityClient = new ReadabilityApi.ReadabilityClient(ApiBaseUrl, ConsumerKey, ConsumerSecret); Observable.Buffer(Observable.FromEventPattern(this, "ReadingListUpdated").Throttle(TimeSpan.FromSeconds(1)), 1) .Subscribe(e => { ShellTile tile = ShellTile.ActiveTiles.First(); if (tile != null && ReadingList.Count > 0) //Do nothing if there's no tile pinned or there are no items in the list. { var firstArticleInReadingList = ReadingList.First().Article; IconicTileData TileData = new IconicTileData() { Title = "Now Readable", Count = ReadingListCount, WideContent1 = firstArticleInReadingList.Title, WideContent2 = firstArticleInReadingList.Excerpt.Substring(0, 100), WideContent3 = firstArticleInReadingList.Author, SmallIconImage = new Uri("Assets/Tiles/SmallIconImage.png", UriKind.Relative), IconImage = new Uri("Assets/Tiles/IconImage.png", UriKind.Relative), BackgroundColor = System.Windows.Media.Colors.Red }; tile.Update(TileData); } }); }
public Bookmarks() { InitializeComponent(); this.Loaded += (object sender, RoutedEventArgs e) => { if (this.DataContext is BookmarksViewModel) { BookmarksViewModel vm = (BookmarksViewModel)this.DataContext; BookmarkListViewModel view_model = new BookmarkListViewModel(vm.User, vm.WorkStatus, new DialogService(), new WindowService()); Page _mainPage = new BookmarkList(view_model); _mainPage.DataContext = view_model; _mainFrame.Navigate(_mainPage); } else if (this.DataContext is ReferencesViewModel) { ReferencesViewModel vm = (ReferencesViewModel)this.DataContext; ReferenceListViewModel view_model = new ReferenceListViewModel(vm.User, vm.WorkStatus, new DialogService(), new WindowService()); Page _mainPage = new ReferenceList(view_model); _mainPage.DataContext = view_model; _mainFrame.Navigate(_mainPage); } }; }
public BookmarkListCreatedDomainEvent(BookmarkList bookmarkList, string userId) { BookmarkList = bookmarkList; UserId = UserId; }
public BookmarkList Add(BookmarkList bookmarkList) { return(_context.BookmarkLists.Add(bookmarkList).Entity); }
public void Update(BookmarkList bookmarkList) { _context.Entry(bookmarkList).State = EntityState.Modified; }
public void Post([FromBody] BookmarkList value) { lists.Add(value); }
// Methods // ======= /// <summary> /// Add a bookmark to the bookmarks list. Used to lighten the methods /// using such an operation. /// </summary> /// <param name="newBookmark">Bookmark to be added></param> public void AddBookmark(Bookmark newBookmark) { BookmarkList.Add(newBookmark); }
public void Put(int id, [FromBody] BookmarkList value) { }
/// <summary> /// 从配置文件加载书签数据 /// </summary> private void LoadBookmarkFromXml() { dt.Rows.Clear(); string xmlFile = AppDomain.CurrentDomain.BaseDirectory + "Config\\Bookmark.xml"; if (!File.Exists(xmlFile)) { return; } BookmarkList bookmarkList = XmlHelper.XmlDeserializeFromFile <BookmarkList>(xmlFile, Encoding.UTF8); if (bookmarkList == null || bookmarkList.BookmarkArr == null || bookmarkList.BookmarkArr.Count <= 0) { return; } foreach (Bookmark bm in bookmarkList.BookmarkArr) { bool bShow = bm.Show == "true" ? true : false; string name = bm.Name; string remark = bm.Remark; double longitude = bm.Longitude; double latitude = bm.Latitude; double altitude = bm.Altitude; double azimuth = bm.Azimuth; double inclination = bm.Inclination; double viewingDistance = bm.ViewingDistance; double viewFieldAngle = bm.ViewFieldAngle; double rollAngle = bm.RollAngle; DataRow row = dt.NewRow(); row["Show"] = bShow; row["Name"] = name; row["Remark"] = remark; row["Longitude"] = longitude; row["Latitude"] = latitude; row["Altitude"] = altitude; row["Azimuth"] = azimuth; row["Inclination"] = inclination; row["ViewingDistance"] = viewingDistance; row["ViewFieldAngle"] = viewFieldAngle; row["RollAngle"] = rollAngle; dt.Rows.Add(row); } gridControl1.DataSource = dt; #region 读XML的方式 return; XmlDocument doc = new XmlDocument(); doc.Load(xmlFile); XmlNodeList nodeList = doc.SelectSingleNode("./Bookmark").ChildNodes; if (nodeList == null || nodeList.Count <= 0) { return; } foreach (XmlNode node in nodeList) { bool bShow = node.Attributes["Show"].Value == "true" ? true : false; string name = node.Attributes["Name"].Value; string remark = node.Attributes["Remark"].Value; string longitude = node.Attributes["Longitude"].Value; string latitude = node.Attributes["Latitude"].Value; string altitude = node.Attributes["Altitude"].Value; string target = node.Attributes["Target"].Value; string azimuth = node.Attributes["Azimuth"].Value; string inclination = node.Attributes["Inclination"].Value; string viewingDistance = node.Attributes["ViewingDistance"].Value; string viewFieldAngle = node.Attributes["ViewFieldAngle"].Value; string rollAngle = node.Attributes["RollAngle"].Value; DataRow row = dt.NewRow(); row["Show"] = bShow; row["Name"] = name; row["Remark"] = remark; row["Longitude"] = longitude; row["Latitude"] = latitude; row["Altitude"] = altitude; row["Target"] = target; row["Azimuth"] = azimuth; row["Inclination"] = inclination; row["ViewingDistance"] = viewingDistance; row["ViewFieldAngle"] = viewFieldAngle; row["RollAngle"] = rollAngle; dt.Rows.Add(row); } gridControl1.DataSource = dt; #endregion }
// 确定 private void btnOk_Click(object sender, EventArgs e) { try { string xmlFile = AppDomain.CurrentDomain.BaseDirectory + "Config\\Bookmark.xml"; DataTable dtTmp = gridControl1.DataSource as DataTable; if (dtTmp == null || dtTmp.Rows.Count <= 0) { if (File.Exists(xmlFile)) { File.Delete(xmlFile); } this.ParentForm.Close(); EventPublisher.PublishShowBookmarkEvent(this, new ShowBookmarkEventArgs() { NameList = null, Append = false }); return; } BookmarkList bookmarkList = new BookmarkList(); List <string> nameList = new List <string>(); foreach (DataRow row in dtTmp.Rows) { Bookmark bm = new Bookmark(); bm.Show = Convert.ToBoolean(row["Show"]) == true ? "true" : "false"; bm.Name = row["Name"].ToString(); bm.Remark = row["Remark"].ToString(); bm.Longitude = Convert.ToDouble(row["Longitude"]); bm.Latitude = Convert.ToDouble(row["Latitude"]); bm.Altitude = Convert.ToDouble(row["Altitude"]); bm.Azimuth = Convert.ToDouble(row["Azimuth"]); bm.Inclination = Convert.ToDouble(row["Inclination"]); bm.ViewingDistance = Convert.ToDouble(row["ViewingDistance"]); bm.ViewFieldAngle = Convert.ToDouble(row["ViewFieldAngle"]); bm.RollAngle = Convert.ToDouble(row["RollAngle"]); if (string.IsNullOrEmpty(bm.Name)) { MessageBox.Show("书签名称不能为空!"); return; } if (bm.Show == "true") { nameList.Add(bm.Name); } bookmarkList.BookmarkArr.Add(bm); } // 显示书签 EventPublisher.PublishShowBookmarkEvent(this, new ShowBookmarkEventArgs() { NameList = nameList, Append = false }); // 保存到xml文件 XmlHelper.XmlSerializeToFile(bookmarkList, xmlFile, Encoding.UTF8); this.Close(); } catch (Exception ex) { Log4Allen.WriteLog(typeof(frmBookmarkMgr), ex.Message); } }
public void BindSongControls() { PropertiesGroup.Hidden = false; BindBox(UniqueIdBox, typeof(SongEntry).GetProperty("UniqueId")); BindBox(TitleBox, typeof(SongEntry).GetProperty("Title")); BindBox(SubtitleBox, typeof(SongEntry).GetProperty("Subtitle")); BindBox(BackgroundBox, typeof(SongEntry).GetProperty("BackgroundImage")); BindBox(ComposerBox, typeof(SongEntry).GetProperty("Composer")); BindBox(ArrangerBox, typeof(SongEntry).GetProperty("Arranger")); BindBox(CopyrightBox, typeof(SongEntry).GetProperty("Copyright")); BindBox(LicenseBox, typeof(SongEntry).GetProperty("License")); BindBox(MadeFamousByBox, typeof(SongEntry).GetProperty("MadeFamousBy")); BindNumericBox(DifficultyBox, typeof(SongEntry).GetProperty("Difficulty")); BindNumericBox(RatingBox, typeof(SongEntry).GetProperty("Rating")); BindBox(FingerHintBox, typeof(SongEntry).GetProperty("FingerHints")); BindBox(HandsBox, typeof(SongEntry).GetProperty("HandParts")); BindBox(PartsBox, typeof(SongEntry).GetProperty("Parts")); int selectedCount = (int)SongList.SelectedRowCount; SortedDictionary <string, int> tagFrequency = new SortedDictionary <string, int>(); Dictionary <KeyValuePair <int, string>, int> bookmarkFrequency = new Dictionary <KeyValuePair <int, string>, int>(); RetargetButton.Enabled = selectedCount == 1; foreach (SongEntry e in SelectedSongs) { foreach (string tag in e.Tags) { tagFrequency[tag] = tagFrequency.ContainsKey(tag) ? tagFrequency[tag] + 1 : 1; } foreach (var b in e.Bookmarks) { bookmarkFrequency[b] = bookmarkFrequency.ContainsKey(b) ? bookmarkFrequency[b] + 1 : 1; } } Tags.Data.Clear(); foreach (var tag in tagFrequency) { if (tag.Value == selectedCount) { Tags.Data.Add(tag.Key); } } TagList.ReloadData(); Bookmarks.Data.Clear(); foreach (var b in bookmarkFrequency) { if (b.Value == selectedCount) { Bookmarks.Data.Add(new Bookmark(b.Key.Key, b.Key.Value)); } } BookmarkList.ReloadData(); }
public static void RefreshBookmarkList() { BookmarkList?.StopLoading(); BookmarkList = new BookmarkIllustsCollection(); }
void ReleaseDesignerOutlets() { if (AddTagButton != null) { AddTagButton.Dispose(); AddTagButton = null; } if (ArrangerBox != null) { ArrangerBox.Dispose(); ArrangerBox = null; } if (BackgroundBox != null) { BackgroundBox.Dispose(); BackgroundBox = null; } if (BookmarkLabelBox != null) { BookmarkLabelBox.Dispose(); BookmarkLabelBox = null; } if (BookmarkList != null) { BookmarkList.Dispose(); BookmarkList = null; } if (BookmarkMeasureBox != null) { BookmarkMeasureBox.Dispose(); BookmarkMeasureBox = null; } if (ComposerBox != null) { ComposerBox.Dispose(); ComposerBox = null; } if (CopyrightBox != null) { CopyrightBox.Dispose(); CopyrightBox = null; } if (DifficultyBox != null) { DifficultyBox.Dispose(); DifficultyBox = null; } if (FingerHintBox != null) { FingerHintBox.Dispose(); FingerHintBox = null; } if (HandsBox != null) { HandsBox.Dispose(); HandsBox = null; } if (LicenseBox != null) { LicenseBox.Dispose(); LicenseBox = null; } if (MadeFamousByBox != null) { MadeFamousByBox.Dispose(); MadeFamousByBox = null; } if (PartsBox != null) { PartsBox.Dispose(); PartsBox = null; } if (PropertiesGroup != null) { PropertiesGroup.Dispose(); PropertiesGroup = null; } if (RatingBox != null) { RatingBox.Dispose(); RatingBox = null; } if (RemoveBookmarkButton != null) { RemoveBookmarkButton.Dispose(); RemoveBookmarkButton = null; } if (RemoveTagButton != null) { RemoveTagButton.Dispose(); RemoveTagButton = null; } if (RetargetButton != null) { RetargetButton.Dispose(); RetargetButton = null; } if (SongList != null) { SongList.Dispose(); SongList = null; } if (SubtitleBox != null) { SubtitleBox.Dispose(); SubtitleBox = null; } if (TagBox != null) { TagBox.Dispose(); TagBox = null; } if (TagList != null) { TagList.Dispose(); TagList = null; } if (TitleBox != null) { TitleBox.Dispose(); TitleBox = null; } if (UniqueIdBox != null) { UniqueIdBox.Dispose(); UniqueIdBox = null; } }