private async void btn_save_Click(object sender, RoutedEventArgs e)
        {
            string url = this.tb_url.Text.Trim();

            if (string.IsNullOrWhiteSpace(url))
            {
                MessageBox.Show("URL不能为空", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                tb_url.Focus();
                tb_url.SelectAll();
                return;
            }
            try
            {
                progressBar.Visibility = Visibility.Visible;
                btn_save.IsEnabled     = false;
                BookmarkModel model        = this.DataContext as BookmarkModel;
                BookmarkView  bookmarkView = await BookmarkService.Update(ObjectMapper.Map <BookmarkModel, Bookmark>(model));

                this.DoBookmarkGridViewModel.DoBookmarkViewModel = ObjectMapper.Map <BookmarkView, BookmarkViewModel>(bookmarkView);
                progressBar.Visibility = Visibility.Hidden;
                this.DialogResult      = true;
                btn_save.IsEnabled     = true;
            }
            catch (Exception ex)
            {
                progressBar.Visibility = Visibility.Hidden;
                btn_save.IsEnabled     = true;
                MessageBox.Show(ex.Message, "提示", MessageBoxButton.OK, MessageBoxImage.Error);
                tb_url.Focus();
                tb_url.SelectAll();
            }
        }
Exemplo n.º 2
0
        public ActionResult Delete(BookmarkView bookmarkView)
        {
            bool     updating = true;
            Bookmark bookmark = Bookmark.FromBookmarkView(bookmarkView, updating);

            return(View(bookmark));
        }
Exemplo n.º 3
0
        public ActionResult Delete(BookmarkView bookmarkView)
        {
            User loggedUser = OnlineUsers.GetSessionUser();

            Bookmark bookmark = new Bookmark();

            bookmark.Id = bookmarkView.Id;
            DB.Delete(bookmark);
            return(RedirectToAction("Index", "Home"));
        }
Exemplo n.º 4
0
        public ActionResult Create(BookmarkView bookmarkview)
        {
            User loggedUser = OnlineUsers.GetSessionUser();

            Bookmark bookmark = Bookmark.FromBookmarkView(bookmarkview);

            DB.Bookmarks.Add(bookmark);

            DB.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 5
0
        private void loadBookmark(int index)
        {
            Console.WriteLine("load bookmark index: " + index);
            currentlyVisibleBookmark = currentBookmarks[index];

            currentlyVisibleBookmark.GetText(delegate(IAsyncResult res)
            {
                Console.WriteLine("bookmark text loaded");
                BookmarkView.DocumentText = currentlyVisibleBookmark.HtmlText;
                BookmarkView.Select();
                StarBookmarkButton.Text = currentlyVisibleBookmark.Starred ? "Unstar" : "Star";
            });
        }
Exemplo n.º 6
0
        public ActionResult Delete(int Id)
        {
            Bookmark     bookmarkFound = DB.Bookmarks.Where(u => u.Id == Id).FirstOrDefault();
            BookmarkView bookmark      = new BookmarkView();

            bookmark.OwnerId     = Id;
            bookmark.Name        = bookmarkFound.Name;
            bookmark.Url         = bookmarkFound.Url;
            bookmark.Shared      = bookmarkFound.Shared;
            bookmark.newCategory = bookmarkFound.Category.Name;
            bookmark.CategoryId  = bookmarkFound.Category.Id;
            return(View(bookmark));
        }
Exemplo n.º 7
0
        public ActionResult Edit(BookmarkView bookmarkView)
        {
            if (ModelState.IsValid)
            {
                bool     updating = true;
                Bookmark bookmark = Bookmark.FromBookmarkView(bookmarkView, updating);



                DB.Update(bookmark);

                DB.SaveChanges();
            }
            return(View(bookmarkView));
        }
Exemplo n.º 8
0
        public ActionResult Create(BookmarkView bookmarkView) // id, ownerid
        {
            User loggedUser = OnlineUsers.GetSessionUser();

            if (ModelState.IsValid)
            {
                Bookmark bookmarkFound = DB.Bookmarks.Where(u => u.Name == bookmarkView.Name).FirstOrDefault();
                if (bookmarkFound != null)
                {
                    ModelState.AddModelError("Bookmark", "This Bookmark is already taken");
                    return(View());
                }
                Bookmark bookmark = Models.Bookmark.FromBookmarkView(bookmarkView);
                bookmark.UserId = loggedUser.Id;
                DB.Add(bookmark);
                return(Redirect("../Home"));
            }
            return(View());
        }
Exemplo n.º 9
0
        public ActionResult Edit(BookmarkView bookmarkView)
        {
            User loggedUser = OnlineUsers.GetSessionUser();

            if (ModelState.IsValid)
            {
                Bookmark bookmark = new Bookmark();
                bookmark.Id            = bookmarkView.Id;
                bookmark.Name          = bookmarkView.Name;
                bookmark.Url           = bookmarkView.Url;
                bookmark.Shared        = bookmarkView.Shared;
                bookmark.Category      = new Category();
                bookmark.Category.Id   = (int)bookmarkView.CategoryId;
                bookmark.Category.Name = bookmarkView.newCategory;
                bookmark.UserId        = loggedUser.Id;
                bookmark.CategoryId    = bookmarkView.CategoryId;
                DB.Update(bookmark);
                return(RedirectToAction("Index", "Home"));
            }
            return(View(bookmarkView));
        }
Exemplo n.º 10
0
        /// <summary>
        /// 剪切数据
        /// </summary>
        public static async Task <List <BookmarkView> > Cut(ClipboardData data, CatalogModel model)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }
            List <BookmarkView> bookmarks = new List <BookmarkView>();

            using (DbHelper db = new DbHelper())
            {
                using (var trans = db.BeginTransaction())
                {
                    try
                    {
                        foreach (var item in data.BookmarkList)
                        {
                            await db.ExecuteNonQuery("UPDATE [Bookmark] SET [CatalogId]=@CatalogId WHERE [Id]=@Id;", new { CatalogId = model.Id, Id = item });
                        }
                        trans.Commit();
                        foreach (var item in data.BookmarkList)
                        {
                            BookmarkView bookmarkView = await db.SelectOne <BookmarkView>("select * from [BookmarkView] where Id=@Id;", new { Id = item });

                            bookmarks.Add(bookmarkView);
                        }
                    }
                    catch (Exception)
                    {
                        trans.Rollback();
                        throw;
                    }
                }
            }
            return(bookmarks);
        }
Exemplo n.º 11
0
        internal Client (bool loadFiles)
        {
            app_count++;

            Window = new Gtk.Window (Gtk.WindowType.Toplevel) { Title = Catalog.GetString ("PDF Mod") };
            Window.SetSizeRequest (640, 480);
            Window.DeleteEvent += delegate (object o, DeleteEventArgs args) {
                Quit ();
                args.RetVal = true;
            };

            // PDF Icon View
            IconView = new DocumentIconView (this);
            var iconview_sw = new Gtk.ScrolledWindow ();
            iconview_sw.AddWithViewport (IconView);

            query_box = new QueryBox (this) { NoShowAll = true };
            query_box.Hide ();

            // ActionManager
            ActionManager = new Hyena.Gui.ActionManager ();
            Window.AddAccelGroup (ActionManager.UIManager.AccelGroup);
            Actions = new Actions (this, ActionManager);

            // Status bar
            StatusBar = new Gtk.Statusbar () { HasResizeGrip = true };
            status_label = new Label () { Xalign = 0.0f };
            StatusBar.PackStart (status_label, true, true, 6);
            StatusBar.ReorderChild (status_label, 0);

            var zoom_slider = new ZoomSlider (this);
            StatusBar.PackEnd (zoom_slider, false, false, 0);
            StatusBar.ReorderChild (zoom_slider, 1);

            // Properties editor box
            EditorBox = new MetadataEditorBox (this) { NoShowAll = true };
            EditorBox.Hide ();

            // Menubar
            menu_bar = ActionManager.UIManager.GetWidget ("/MainMenu") as MenuBar;

            // Toolbar
            HeaderToolbar = ActionManager.UIManager.GetWidget ("/HeaderToolbar") as Gtk.Toolbar;
            HeaderToolbar.ShowArrow = false;
            HeaderToolbar.ToolbarStyle = ToolbarStyle.Icons;
            HeaderToolbar.Tooltips = true;
            HeaderToolbar.NoShowAll = true;
            HeaderToolbar.Visible = Configuration.ShowToolbar;

            // BookmarksView
            BookmarkView = new BookmarkView (this);
            BookmarkView.NoShowAll = true;
            BookmarkView.Visible = false;

            var vbox = new VBox ();
            vbox.PackStart (menu_bar, false, false, 0);
            vbox.PackStart (HeaderToolbar, false, false, 0);
            vbox.PackStart (EditorBox, false, false, 0);
            vbox.PackStart (query_box, false, false, 0);

            var hbox = new HPaned ();
            hbox.Add1 (BookmarkView);
            hbox.Add2 (iconview_sw);
            vbox.PackStart (hbox, true, true, 0);

            vbox.PackStart (StatusBar, false, true, 0);
            Window.Add (vbox);

            Window.ShowAll ();

            if (loadFiles) {
                RunIdle (LoadFiles);
                Application.Run ();
            }
        }
Exemplo n.º 12
0
        private static void OnLoad()
        {
            App.Navbar.SearchBox.Filters.Clear();

            App.Navbar.SearchBox.Filters.AddRange(new[]
            {
                new SearchRequestFilter("Papers", "search", "#0049b2", "Search on papers", (sr) => { sr.SetBeforeTypesFacet(Schema.N.Paper); return(true); }),
                new SearchRequestFilter("Diseases", "disease", "#0049b2", "Search on diseases", (sr) => { sr.SetBeforeTypesFacet(Schema.N.Disease); return(true); }),
                new SearchRequestFilter("Everything", "search", "#0049b2", "Search on papers, authors, journals & affiliations", (sr) => { sr.SetBeforeTypesFacet(Schema.N.Affiliation, Schema.N.Author, Schema.N.Journal, Schema.N.Location, Schema.N.Paper, Schema.N.Disease); return(true); }),
                new SearchRequestFilter("Bookmarks", "bookmark", "#0049b2", "Search on my bookmarks", (sr) => { BookmarkView.NavigateToSearch(sr); return(false); }),
                new SearchRequestFilter("History", "history", "#0049b2", "Search on my history", (sr) => { TimelineView.NavigateToSearch(sr); return(false); }),
            });

            App.Navbar.SearchBox.RefreshFilters();

            App.Navbar.SearchBox.RemoveFilter("Files");
            App.Navbar.SearchBox.RemoveFilter("My Files");

            // Any code to run after the system loads should go here
            // You can also register custom routes here as well, using Router.Register(...)
        }
Exemplo n.º 13
0
 public ActionResult Details(BookmarkView bookmarkView)
 {
     return(View(bookmarkView));
 }