Beispiel #1
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);
            });
        }
Beispiel #2
0
        public void SavePage(Locknote.Helpers.Objects.Page page, AsymmetricCipherKeyPair keypair, bool background)
        {
            Xamarin.Forms.Page oldPage = App.Current.MainPage;

            if (!background)
            {
                //create the activity indicator layout
                ContentPage actPage   = new ContentPage();
                StackLayout actLayout = new StackLayout()
                {
                    VerticalOptions = LayoutOptions.CenterAndExpand
                };
                ActivityIndicator actInd = new ActivityIndicator();;
                actLayout.Children.Add(actInd);
                actLayout.Children.Add(new Label()
                {
                    Text = "Saving Page", TextColor = Color.DarkGray, HorizontalTextAlignment = TextAlignment.Center
                });
                actPage.Content = actLayout;

                //show wait animation
                actInd.IsRunning     = true;
                App.Current.MainPage = actPage;
            }

            Thread t = new Thread(new ParameterizedThreadStart((o) =>
            {
                page.Save(keypair);
                if (!background)
                {
                    Device.BeginInvokeOnMainThread(() => { App.Current.MainPage = oldPage; });
                }
            }));

            t.Start();
        }