Пример #1
0
        private void InitComponent()
        {
            Resize(600, 600);

            List <BookView> views = new List <BookView>();

            _notebook = new Notebook();
            foreach (var book in Root.Books)
            {
                BookView view = new BookView(book, AppSettings);
                views.Add(view);
                Label viewLabel = new Label {
                    Text = book.ToString()
                };
                viewLabel.SetPadding(10, 2);
                _notebook.AppendPage(view, viewLabel);
            }

            Add(_notebook);

            Destroyed += (o, e) =>
            {
                foreach (var view in views)
                {
                    view.EnsureSaved();
                }
                Application.Quit();
            };

            KeyPressEvent += (sender, args) =>
            {
                BookView currentView = _notebook.CurrentPageWidget as BookView;
                if (currentView == null)
                {
                    return;
                }
                var state = args.Event.State & (Gdk.ModifierType.ShiftMask | Gdk.ModifierType.Mod1Mask |
                                                Gdk.ModifierType.ControlMask);
                if (state == Gdk.ModifierType.None)
                {
                    switch (args.Event.Key)
                    {
                    case Gdk.Key.F12:
                        int found = TitleSearchWindow.RunSearch(this, currentView.Book, AppSettings);
                        if (found >= 0)
                        {
                            currentView.JumpToPage(found);
                        }
                        break;
                    }
                }
            };
        }
Пример #2
0
        public static int RunSearch(Window parent, ScratchBook book, Settings settings)
        {
            using (TitleSearchWindow window = new TitleSearchWindow(book, settings))
            {
                switch (window.ShowModal(parent))
                {
                case ModalResult.OK:
                    return(window.SelectedItem.Value);

                default:
                    return(-1);
                }
            }
        }