Exemplo n.º 1
0
 public void SavePage(object sender, EventArgs e)
 {
     webview.Get_HTML(new EventHandler((o, e2) =>
     {
         string html  = (string)o;
         m_pg.Content = html;
         LocknoteMgr.GetInstance().SavePage(m_pg, false);
     }));
 }
Exemplo n.º 2
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);
     }
 }
Exemplo n.º 3
0
        public PagesPage(Section sec)
        {
            InitializeComponent();

            mnu_new_page.Clicked += Mnu_new_page_Clicked;

            this.ListView = listview;
            m_sec         = sec;

            listview.ItemTapped += new EventHandler((o, e) =>
            {
                Locknote.Helpers.Objects.Page p = (Locknote.Helpers.Objects.Page)o;
                PageEditor pe = new PageEditor(p);
                pe.Title      = p.Title;
                ((NavigationPage)((HomeMDP)Application.Current.MainPage).Detail).PushAsync(pe);
            });

            listview.ItemLongTapped += new LNListView.ItemLongTappedHandler((o, e) =>
            {
                Locknote.Helpers.Objects.Page pg = (Locknote.Helpers.Objects.Page)o;
                EditNotebookPrompt p             = new EditNotebookPrompt()
                {
                    Title = pg.Title, PromptTitle = "Edit Page", Placeholder = "A Page", IsNavPage = true
                };
                p.OnPromptSaved += new Prompt.PromptClosedEventListener(() =>
                {
                    pg.Title = p.Title;
                    LocknoteMgr.GetInstance().SaveNotebooks(true);
                    listview.ItemsSource = m_sec.Pages;
                });
                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(() =>
                    {
                        sec.DeletePage(pg);
                        p.Dismiss();
                    });
                    p2.Show(((HomeMDP)Application.Current.MainPage).Detail);
                });
                p.Show(((HomeMDP)Application.Current.MainPage).Detail);
            });
        }
Exemplo n.º 4
0
        public SectionsPage(Notebook nb)
        {
            InitializeComponent();

            m_nb = nb;

            mnu_new_section.Clicked += Mnu_new_section_Clicked;

            listview.ItemTapped += new EventHandler((o, e) =>
            {
                Section sec             = (Section)o;
                PagesPage pp            = new PagesPage(sec);
                pp.Title                = sec.Title + " | Pages";
                pp.ListView.ItemsSource = sec.Pages;
                ((NavigationPage)((HomeMDP)Application.Current.MainPage).Detail).PushAsync(pp);
            });

            listview.ItemLongTapped += new LNListView.ItemLongTappedHandler((o, e) =>
            {
                Section sec          = (Section)o;
                EditNotebookPrompt p = new EditNotebookPrompt()
                {
                    Title = sec.Title, PromptTitle = "Edit Section", Placeholder = "A Section", IsNavPage = true
                };
                p.OnPromptSaved += new Prompt.PromptClosedEventListener(() =>
                {
                    sec.Title = p.Title;
                    LocknoteMgr.GetInstance().SaveNotebooks(true);
                    listview.ItemsSource = m_nb.Sections;
                });
                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(() =>
                    {
                        m_nb.DeleteSection(sec);
                        p.Dismiss();
                    });
                    p2.Show(((HomeMDP)Application.Current.MainPage).Detail);
                });
                p.Show(((HomeMDP)Application.Current.MainPage).Detail);
            });
        }
Exemplo n.º 5
0
        public SettingsPage()
        {
            InitializeComponent();

            m_config = ConfigFactory.GetInstance();

            //initialize to the current settings
            chk_lock_on_suspend.IsToggled = m_config.LockOnSuspend;
            chk_save_on_suspend.IsToggled = m_config.SaveOnSuspend;
            chk_fingerprint.IsToggled     = m_config.UseFingerprint;

            //we need to handle the fingerprint enable separately
            chk_fingerprint.Toggled += new EventHandler <ToggledEventArgs>((o, e) =>
            {
                if (chk_fingerprint.IsToggled)
                {
                    IFingerprint fp = FingerprintFactory.GetInstance();
                    fp.InitReader();
                    if (fp.IsReady())
                    {
                        PasswordPrompt pmt = new PasswordPrompt()
                        {
                            IsNavPage = true, PromptTitle = "Verify your Password", PositiveButtonText = "Verify", RestorePage = true
                        };
                        pmt.OnPromptSaved += new Prompt.PromptClosedEventListener(() =>
                        {
                            if (pmt.Password == null || pmt.Password.Length == 0)
                            {
                                return;
                            }

                            //attempt to decrypt the private key, just as a verification method
                            if (!LocknoteMgr.GetInstance().DecryptPrivateKey(pmt.Password))
                            { //decryption failed, incorrect password was entered
                                NotificationFactory.ShortAlert("Password is incorrect");
                                pmt.Show(((NavigationPage)((HomeMDP)Application.Current.MainPage).Detail));
                                return;
                            }

                            //we verified the password is correct, now we can prompt the user to scan a fingerprint
                            Page back = Application.Current.MainPage;
                            Application.Current.MainPage = new FingerprintPage(new EventHandler((oo, ee) =>
                            {
                                byte[] data = (byte[])oo; //page returns the encrypted password
                                if (data != null)
                                {                         //only if was not skipped
                                  //encrypt the password and save it
                                    ConfigFactory.GetInstance().EncryptedPassword = data;
                                    ConfigFactory.GetInstance().UseFingerprint    = true;
                                    NotificationFactory.ShortAlert("Fingerprint unlock enabled");
                                }
                                else
                                {
                                    ConfigFactory.GetInstance().EncryptedPassword = new byte[] { 0 };
                                    ConfigFactory.GetInstance().UseFingerprint    = false;
                                    chk_fingerprint.IsToggled = false;
                                }
                                Application.Current.MainPage = back;
                            }), fp, pmt.Password);
                        });
                        pmt.OnPromptDismissed += new Prompt.PromptClosedEventListener(() =>
                        {
                            chk_fingerprint.IsToggled = false;
                        });
                        pmt.Show(((NavigationPage)((HomeMDP)Application.Current.MainPage).Detail));
                    }
                }
                else
                {
                    ConfigFactory.GetInstance().EncryptedPassword = new byte[] { 0 };
                    ConfigFactory.GetInstance().UseFingerprint    = false;
                }
            });

            //set the button handlers
            btn_save.Clicked += new EventHandler((o, e) =>
            {
                m_config.LockOnSuspend = chk_lock_on_suspend.IsToggled;
                m_config.SaveOnSuspend = chk_save_on_suspend.IsToggled;

                NotificationFactory.ShortAlert("Settings Saved!");
            });
            btn_change_password.Clicked += new EventHandler((o, e) =>
            {
                PasswordEntryView pep = new PasswordEntryView();
                pep.OnSave           += new EventHandler((oo, ee) =>
                {
                    LocknoteMgr.GetInstance().ReencryptPrivateKey(pep.Text);
                    ((NavigationPage)((HomeMDP)Application.Current.MainPage).Detail).PopAsync();
                    NotificationFactory.ShortAlert("Password changed");
                });
                Xamarin.Forms.ContentPage pg = new ContentPage();
                pg.Content = pep;
                ((NavigationPage)((HomeMDP)Application.Current.MainPage).Detail).PushAsync(pg);
            });
        }
Exemplo n.º 6
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;
            });
        }