当前位置: 首页>>代码示例>>C#>>正文


C# Note.LoadAsync方法代码示例

本文整理汇总了C#中Note.LoadAsync方法的典型用法代码示例。如果您正苦于以下问题:C# Note.LoadAsync方法的具体用法?C# Note.LoadAsync怎么用?C# Note.LoadAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Note的用法示例。


在下文中一共展示了Note.LoadAsync方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetFilesAsync

        async void GetFilesAsync()
        {
            // Sort the filenames.
            IEnumerable<string> filenames =
                from filename in await FileHelper.GetFilesAsync()
                where filename.EndsWith(".note")
                orderby (filename)
                select filename;

            // Store them in the Notes collection.
            foreach (string filename in filenames)
            {
                Note note = new Note(filename);
                await note.LoadAsync();
                this.Notes.Add(note);
            }
        }
开发者ID:karanga,项目名称:xamarin-forms-book-preview,代码行数:17,代码来源:NoteFolder.cs

示例2: NotePage

        public NotePage(Note note, bool isNoteEdit = false)
        {
            this.note = note;
            this.isNoteEdit = isNoteEdit;
            Title = isNoteEdit ? "Edit Note" : "New Note";

            // Create Entry and Editor views.
            Entry entry = new Entry
            {
                Placeholder = "Title (optional)"
            };

            Editor editor = new Editor
            {
                Keyboard = Keyboard.Create(KeyboardFlags.All),
                BackgroundColor = Device.OnPlatform(Color.Default, 
                                                    Color.Default, 
                                                    Color.White),
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            // Set data bindings.
            this.BindingContext = note;
            entry.SetBinding(Entry.TextProperty, "Title");
            editor.SetBinding(Editor.TextProperty, "Text");

            // Assemble page.
            StackLayout stackLayout = new StackLayout
            {
                Children = 
                {
                    new Label { Text = "Title:" },
                    entry,
                    new Label { Text = "Note:" },
                    editor,
                }
            };

            if (isNoteEdit)
            {
                // Cancel button.
                Button cancelButton = new Button
                {
                    Text = "Cancel",
                    HorizontalOptions = LayoutOptions.CenterAndExpand
                };

                cancelButton.Clicked += async (sender, args) =>
                    {
                        bool confirm = await this.DisplayAlert("Note Taker", 
                                                               "Cancel note edit?", 
                                                               "Yes", "No");
                        if (confirm)
                        {
                            // Reload note.
                            await note.LoadAsync();

                            // Return to home page.
                            await this.Navigation.PopAsync();
                        }
                    };

                // Delete button
                Button deleteButton = new Button
                {
                    Text = "Delete",
                    HorizontalOptions = LayoutOptions.CenterAndExpand
                };

                deleteButton.Clicked += async (sender, args) =>
                    {
                        bool confirm = await this.DisplayAlert("Note Taker", 
                                                               "Delete this note?", 
                                                               "Yes", "No");
                        if (confirm)
                        {
                            // Delete Note file and remove from collection.
                            await note.DeleteAsync();
                            App.NoteFolder.Notes.Remove(note);

                            // Return to home page.
                            await this.Navigation.PopAsync();
                        }
                    };

                StackLayout horzStack = new StackLayout
                {
                    Orientation = StackOrientation.Horizontal,
                    Children = 
                    {
                        cancelButton,
                        deleteButton
                    }
                };

                stackLayout.Children.Add(horzStack);
            }

            this.Content = stackLayout;
        }
开发者ID:karanga,项目名称:xamarin-forms-book-preview,代码行数:100,代码来源:NotePage.cs

示例3: NotePage

        public NotePage(Note note, bool isNoteEdit = false)
        {
            // Initialize Note object
            this.note = note;
            this.isNoteEdit = isNoteEdit;
            Title = isNoteEdit ? "Edit Note" : "New Note";

            // Create Entry and Editor views.
            Entry entry = new Entry
            {
                Placeholder = "Title (optional)"
            };

            Editor editor = new Editor
            {
                Keyboard = Keyboard.Create(KeyboardFlags.All),
                BackgroundColor = Device.OnPlatform(Color.Default, 
                                                    Color.Default, 
                                                    Color.White),
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            // Set data bindings.
            this.BindingContext = note;
            entry.SetBinding(Entry.TextProperty, "Title");
            editor.SetBinding(Editor.TextProperty, "Text");

            // Assemble page.
            StackLayout stackLayout = new StackLayout
            {
                Children = 
                {
                    new Label { Text = "Title:" },
                    entry,
                    new Label { Text = "Note:" },
                    editor,
                }
            };

            if (isNoteEdit)
            {
                // Cancel toolbar item.
                ToolbarItem cancelItem = new ToolbarItem
                {
                    Name = "Cancel",
                    Icon = Device.OnPlatform("cancel.png", 
                                             "ic_action_cancel.png", 
                                             "Images/cancel.png"),
                    Order = ToolbarItemOrder.Primary
                };

                cancelItem.Activated += async (sender, args) =>
                    {
                        bool confirm = await this.DisplayAlert("Note Taker", 
                                                               "Cancel note edit?", 
                                                               "Yes", "No");
                        if (confirm)
                        {
                            // Reload note.
                            await note.LoadAsync();

                            // Return to home page.
                            await this.Navigation.PopAsync();
                        }
                    };

                this.ToolbarItems.Add(cancelItem);

                // Delete toolbar item.
                ToolbarItem deleteItem = new ToolbarItem
                {
                    Name = "Delete",
                    Icon = Device.OnPlatform("discard.png", 
                                             "ic_action_discard.png", 
                                             "Images/delete.png"),
                    Order = ToolbarItemOrder.Primary
                };

                deleteItem.Activated += async (sender, args) =>
                    {
                        bool confirm = await this.DisplayAlert("Note Taker", 
                                                               "Delete this note?", 
                                                               "Yes", "No");
                        if (confirm)
                        {
                            // Delete Note file and remove from collection.
                            await note.DeleteAsync();
                            App.NoteFolder.Notes.Remove(note);

                            // Return to home page.
                            await this.Navigation.PopAsync();
                        }
                    };

                this.ToolbarItems.Add(deleteItem);
            }

            this.Content = stackLayout;
        }
开发者ID:karanga,项目名称:xamarin-forms-book-preview,代码行数:99,代码来源:NotePage.cs


注:本文中的Note.LoadAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。