Пример #1
0
 private void Mnu_new_page_Clicked(object sender, EventArgs e)
 {
     if (sender == mnu_new_page)
     {
         TextEntryPrompt p = new TextEntryPrompt()
         {
             IsNavPage = true, PositiveButtonText = "Create", NegativeButtonText = "Cancel", PromptTitle = "New Page", Hint = "A Page"
         };
         p.OnPromptSaved += new Prompt.PromptClosedEventListener(() =>
         {
             m_sec.NewPage(p.Text);
             LocknoteMgr.GetInstance().SaveNotebooks(true);
         });
         p.Show(((HomeMDP)Application.Current.MainPage).Detail);
     }
 }
Пример #2
0
        public HomeMDPMaster()
        {
            InitializeComponent();

            ListView = lst_notebooks;

            object version = "";

            App.Current.Resources.TryGetValue("version", out version);
            lbl_version.Text = version.ToString();

            mst_lock_unlock.Clicked += new EventHandler((o, e) =>
            {
                LocknoteMgr.GetInstance().SecureErase();
                ((App)Application.Current).ResumeApp();
            });
            mst_settings.Clicked += new EventHandler((o, e) =>
            {
                ((NavigationPage)((HomeMDP)Application.Current.MainPage).Detail).PushAsync(new SettingsPage());
                ((HomeMDP)Application.Current.MainPage).IsPresented = false;
            });
            mst_new_notebook.Clicked += new EventHandler((o, e) =>
            {
                TextEntryPrompt p = new TextEntryPrompt()
                {
                    IsNavPage = true, PositiveButtonText = "Create", NegativeButtonText = "Cancel", PromptTitle = "New Notebook", Hint = "A Notebook"
                };
                p.OnPromptSaved += new Prompt.PromptClosedEventListener(() =>
                {
                    LocknoteMgr.GetInstance().NoteManager.NewNotebook(p.Text);
                    LocknoteMgr.GetInstance().SaveNotebooks(true);
                    ((HomeMDP)Application.Current.MainPage).IsPresented = true;
                });
                p.Show(((HomeMDP)Application.Current.MainPage).Detail);
                ((HomeMDP)Application.Current.MainPage).IsPresented = false;
            });

            lst_notebooks.ItemTapped += new EventHandler((o, e) =>
            {
                Notebook nb             = (Notebook)o;
                SectionsPage sp         = new SectionsPage(nb);
                sp.Title                = nb.Title + " | Sections";
                sp.ListView.ItemsSource = nb.Sections;
                ((HomeMDP)Application.Current.MainPage).Detail      = new NavigationPage(sp);
                ((HomeMDP)Application.Current.MainPage).IsPresented = false;
            });

            lst_notebooks.ItemLongTapped += new LNListView.ItemLongTappedHandler((o, e) =>
            {
                Notebook nb          = (Notebook)o;
                EditNotebookPrompt p = new EditNotebookPrompt()
                {
                    Title = nb.Title, IsNavPage = true
                };
                Xamarin.Forms.Page pg = ((NavigationPage)((HomeMDP)Application.Current.MainPage).Detail).CurrentPage;
                p.OnPromptSaved      += new Prompt.PromptClosedEventListener(() =>
                {
                    nb.Title = p.Title;
                    if (pg.GetType() == typeof(SectionsPage))
                    {
                        pg.Title = p.Title + " | Sections";
                    }
                    LocknoteMgr.GetInstance().SaveNotebooks(true);
                    lst_notebooks.ItemsSource = LocknoteMgr.GetInstance().NoteManager.Notebooks;
                });
                p.DeleteClicked += new EventHandler((o2, e2) =>
                {
                    Prompt p2 = new Prompt()
                    {
                        PromptTitle = "Are you sure?", PositiveButtonText = "Yes", NegativeButtonText = "No", IsNavPage = true
                    };
                    p2.OnPromptSaved += new Prompt.PromptClosedEventListener(() =>
                    {
                        LocknoteMgr.GetInstance().NoteManager.DeleteNotebook(nb);
                        p.Dismiss();
                    });
                    p2.Show(((HomeMDP)Application.Current.MainPage).Detail);
                });
                p.Show(((HomeMDP)Application.Current.MainPage).Detail);
                ((HomeMDP)Application.Current.MainPage).IsPresented = false;
            });
        }