예제 #1
0
        void ModifyCore(BookmarkAndSettings[] settings)
        {
            uiDispatcher.VerifyAccess();
            var bms = new List <BookmarkAndOldSettings>(settings.Length);

            lock (lockObj) {
                foreach (var info in settings)
                {
                    var bmImpl = info.Bookmark as BookmarkImpl;
                    Debug.Assert(!(bmImpl is null));
                    if (bmImpl is null)
                    {
                        continue;
                    }
                    Debug.Assert(bookmarks.Contains(bmImpl));
                    if (!bookmarks.Contains(bmImpl))
                    {
                        continue;
                    }
                    var currentSettings = bmImpl.Settings;
                    if (currentSettings == info.Settings)
                    {
                        continue;
                    }
                    bms.Add(new BookmarkAndOldSettings(bmImpl, currentSettings));
                    bmImpl.WriteSettings_BMThread(info.Settings);
                }
            }
            if (bms.Count > 0)
            {
                BookmarksModified?.Invoke(this, new BookmarksModifiedEventArgs(new ReadOnlyCollection <BookmarkAndOldSettings>(bms)));
            }
        }
예제 #2
0
        public void Clear(bool dontInvokeBookmarksModified = false)
        {
            if (bookmarks != null)
            {
                bookmarks.Clear();
            }

            if (!dontInvokeBookmarksModified)
            {
                BookmarksModified?.Invoke();
            }
        }
예제 #3
0
        public void AddRange(IEnumerable <Bookmark> bookmarksToAdd)
        {
            if (bookmarks == null)
            {
                bookmarks = new List <Bookmark>();
            }

            foreach (var bookmark in bookmarksToAdd)
            {
                if (!bookmarks.Any(bm => bm.Name == bookmark.Name && bm.URI == bookmark.URI))
                {
                    bookmarks.Add(bookmark);
                    System.Diagnostics.Debug.WriteLine("Bookmark added");
                }
            }

            BookmarksModified?.Invoke();
        }
예제 #4
0
 public void Remove(Bookmark bookmark)
 {
     bookmarks.Remove(bookmark);
     BookmarksModified?.Invoke();
 }
예제 #5
0
 public void Swap(int index, int newIndex)
 {
     bookmarks.Swap(index, newIndex);
     BookmarksModified?.Invoke();
 }