Пример #1
0
    protected override void OnAppearing()
    {
      base.OnAppearing();

      if (BindingContext == null)
      {
        BindingContext = _project;

        var grid = new Grid();
        grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
        grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
        grid.RowDefinitions.Add(new RowDefinition { Height = 150 });
        grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
        grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
        grid.VerticalOptions = LayoutOptions.StartAndExpand;
        grid.Children.Add(new Label { Text = "Name" }, 0, 0);
        var editor = new Editor();
        editor.SetBinding(Editor.TextProperty, "Name");
        grid.Children.Add(editor, 1, 0);
        label.IsVisible = false;
        label.Text = "Error in value";
        label.TextColor = Color.Red;
        grid.Children.Add(label, 1, 1);
        grid.Children.Add(new Label { Text = "Description" }, 0, 2);
        grid.Children.Add(new Editor { Text = _project.Description }, 1, 2);
        grid.Children.Add(new Label { Text = "Started" }, 0, 3);
        grid.Children.Add(new Editor { Text = _project.Started.HasValue ? _project.Started.GetValueOrDefault().ToShortDateString() : string.Empty }, 1, 3);
        grid.Children.Add(new Label { Text = "Ended" }, 0, 4);
        grid.Children.Add(new Editor { Text = _project.Ended.HasValue ? _project.Ended.GetValueOrDefault().ToShortDateString() : string.Empty }, 1, 4);
        Content = grid;
      }
    }
Пример #2
0
        } //end ctor

        private StackLayout BuildView()
        {
            Editor editor = new Editor();
            editor.SetBinding(Editor.TextProperty, "Account.Notes");
         
            TableView tblView = new TableView() 
            {
                Root = new TableRoot() 
                {
                    new TableSection("NOTES")
                }
            };

            StackLayout stack = new StackLayout()
            {
                Padding = 10,
                VerticalOptions = LayoutOptions.FillAndExpand,
                Children = 
                {
                    tblView,
                    editor
                }
            };

            return stack;
        } //end BuildView
Пример #3
0
        private void AddDescriptionSection(TableView table)
        {
            const int HEIGHT = 150;

            var descriptionSection = new TableSection ("Description");

            var descriptionGrid = new Grid {
                Padding = new Thickness(10),
                HeightRequest = HEIGHT,
                VerticalOptions = LayoutOptions.FillAndExpand,
                ColumnDefinitions = {
                    new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) }
                }
            };

            var descriptionEntry = new Editor {
                HeightRequest = HEIGHT
            };

            descriptionEntry.SetBinding (Editor.TextProperty, "Description");

            descriptionGrid.Children.Add (descriptionEntry, 0, 0);

            descriptionSection.Add (new ViewCell {
                View = descriptionGrid,
                Height = HEIGHT
            });

            table.Root.Add (descriptionSection);
        }
Пример #4
0
        public CSPage()
        {
            BindingContext = new ViewModel.PageViewModel();

            var editor = new Editor { Text = "", HorizontalOptions = LayoutOptions.FillAndExpand };
            editor.SetBinding(Editor.TextProperty, "Message");

            switcher = new Switch {  };
            //switcher.SetBinding(Switch.IsToggledProperty, "Toggled");
            switcher.PropertyChanged += (object sender, PropertyChangedEventArgs e) =>
            {
                sclabel.SetBinding(Label.TextProperty,
                new Binding("Message",
                    converter: new Converters.StringCaseConverter(),
                    converterParameter: switcher.IsToggled));
            };

            var label = new Label
            {
                Text = "",
                HorizontalOptions = LayoutOptions.FillAndExpand,
                FontSize = 30
            };
            label.SetBinding(Label.TextProperty, "Message");

            sclabel = new Label
            {
                Text = "",
                HorizontalOptions = LayoutOptions.FillAndExpand,
                FontSize = 30
            };

            var sllabel = new Label
            {
                Text = "",
                HorizontalOptions = LayoutOptions.FillAndExpand,
                FontSize = 30
            };
            sllabel.SetBinding(Label.TextProperty,
                new Binding("Message",
                    converter: new Converters.StringToLengthConverter(),
                    stringFormat: "{0} letters"));

            Title = "Mvvm w/ C#";
            Content = new StackLayout
            {
                Padding = new Thickness(20, 5),
                Children = {
                    editor,
                    switcher,
                    label,
                    sclabel,
                    sllabel
                }
            };
        }
Пример #5
0
        public CSViewModelConverterPage()
        {
            BindingContext = new ViewModel.CommonViewModel();

            var editor = new Editor
            {
                Text = "",
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };
            editor.SetBinding(Editor.TextProperty, "Message");
            var label = new Label
            {
                Text = "",
                FontSize = 30,
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };
            label.SetBinding(Label.TextProperty, "Message");
            var sclabel = new Label
            {
                Text = "",
                FontSize = 30,
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };
            sclabel.SetBinding(Label.TextProperty,
                new Binding("Message",
                    converter: new Converters.StringCaseConverter(),
                    converterParameter: "True"));
            var sllabel = new Label
            {
                Text = "",
                FontSize = 30,
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };
            sllabel.SetBinding(Label.TextProperty,
                new Binding("Message",
                    converter: new Converters.StringToLengthConverter(),
                    stringFormat: "{0} letters"));

            var stack = new StackLayout
            {
                Spacing = 20,
                Children = {
                    editor,
                    label,
                    sclabel,
                    sllabel,
                },
            };

            Padding = 30;
            Title = "ViewModel bindig (C#)";
            Content = stack;
        }
        /// <summary>
        /// Method that creates the page content
        /// </summary>
        public void SetContent()
        {
            var header = new Label
            {
                Text = "Bemærkning",
                TextColor = Color.FromHex(Definitions.TextColor),
                FontSize = Definitions.HeaderFontSize,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                YAlign = TextAlignment.Center,
            };
            
            var backButton = new BackButton(SendBackMessage);
            var saveButton = new SaveButton(SendSaveMessage);

            var headerstack = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                BackgroundColor = Color.FromHex(Definitions.PrimaryColor),
                HeightRequest = Definitions.HeaderHeight,
                Children =
                {
                    backButton,
                    header,
                    saveButton
                }
            };
            _editor = new Editor
            {
                HeightRequest = Definitions.ScreenHeight - Definitions.HeaderHeight - 2 * Definitions.Padding,
                WidthRequest = Definitions.ScreenWidth,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.FillAndExpand
            };
            _editor.SetBinding(Editor.TextProperty, RemarkViewModel.RemarkProperty);

            var editorStack = new StackLayout
            {
                BackgroundColor = Color.FromHex(Definitions.BackgroundColor),
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.FillAndExpand,
                Padding = Definitions.Padding,
                Children = { _editor }
            };
            
            var layout = new StackLayout
            {
                BackgroundColor = Color.FromHex(Definitions.BackgroundColor),
                Children = { headerstack, editorStack}
            };

            this.Content = layout;
        }
        public TaskDetailPage(string fullDescription)
        {
            Title = fullDescription;

            NavigationPage.SetHasNavigationBar (this, true);

            var notesLabel = new Label { Text = "You can add notes about this Task Completion here:" };
            var notesEntry = new Editor ();

            // cannot get just the right "look" that will be satisfactory for both Android and iOS
            //notesEntry.BackgroundColor = new Color (0, 0x10, 0x10);

            notesEntry.SetBinding (Editor.TextProperty, "Notes");

            var saveButton = new Button { Text = "Save Notes", BorderWidth = 2, };
            saveButton.Clicked += (sender, e) => {
                var taskItem = (Task)BindingContext;
                App.Database.SaveTask (taskItem);
                this.Navigation.PopAsync ();
            };

            var deleteButton = new Button { Text = "Delete this entry and deduct points", BorderWidth = 2, };

            deleteButton.Clicked += (sender, e) => {
                var taskItem = (Task)BindingContext;
                App.Database.DeleteTask (taskItem.ID);
                this.Navigation.PopAsync ();
            };

            var cancelButton = new Button { Text = "Cancel", BorderWidth = 2, };
            cancelButton.Clicked += (sender, e) => {
                this.Navigation.PopAsync ();
            };

            var lineSeparator = new BoxView () { Color = Color.Black, WidthRequest = 100, HeightRequest = 2 };

            Content = new StackLayout {
                //Orientation = StackOrientation.Horizontal,
                //HorizontalOptions = LayoutOptions.Center,

                Padding = new Thickness (5),
                Children = {
                    notesLabel, notesEntry,
                    lineSeparator,
                    saveButton,
                    deleteButton,
                    //	speakNotes,
                    cancelButton,
                }
            };
        }
Пример #8
0
        public TestPage()
        {
            this.BindingContext = new TestPageViewModel();

            var ed = new Editor { Text = "BindingTo TextValue" };
            ed.SetBinding(Editor.TextProperty, "TextValue", mode: BindingMode.OneWayToSource);
            var lb = new Label { Text = "" };
            lb.SetBinding(Label.TextProperty, "TextValue");

            var sw = new Switch();
            sw.SetBinding(Switch.IsToggledProperty, "BoolValue", mode: BindingMode.TwoWay);

            var sc = new SwitchCell { Text = "BindingTo BoolValue" };
            sc.SetBinding(SwitchCell.OnProperty, "BoolValue", mode: BindingMode.TwoWay);

            var tc = new TextCell { Text = "" };
            tc.SetBinding(TextCell.TextProperty, "BoolValue", stringFormat:"Value: {0}");

            var tv = new TableView
            {
                Intent = TableIntent.Settings,
                Root = new TableRoot
                {
                    new TableSection("TableView")
                    {
                        sc,
                        tc,
                    },
                }
            };

            Content = new StackLayout
            {
                Padding = 20,
                Children = {
                    new Label {
                        Text = "INotifyPropertyChanged Test",
                        FontSize = 30,
                    },
                    ed,
                    lb,
                    sw,
                    tv,
                }
            };
        }
Пример #9
0
		public AddReviewView ()
		{
			viewModel = new AddReviewsViewModel (Navigation);
			BindingContext = viewModel;

			Title = "Add New Review";

			var email = new Entry () { Placeholder = "Email Address" };
			email.SetBinding (Entry.TextProperty, "Email");

			var cheeseType = new Entry () { Placeholder = "Cheese Type" };
			cheeseType.SetBinding (Entry.TextProperty, "CheeseType");

			var dairy = new Entry () { Placeholder = "Dairy" };
			dairy.SetBinding (Entry.TextProperty, "DairyName");

			var comments = new Editor ();
			comments.BackgroundColor = Color.FromRgb (255, 255, 229);
			comments.VerticalOptions = LayoutOptions.FillAndExpand;
			comments.SetBinding (Editor.TextProperty, "Comments");

			var saveButton = new ToolbarItem () { Text = "Save" };

			saveButton.SetBinding (ToolbarItem.CommandProperty, "AddCommand");
					
			ToolbarItems.Add (saveButton);
					
			Content = new StackLayout { 
				Padding= new Thickness(10,10,10,10),
				Children = {					
					email,
					cheeseType,
					dairy,
					new Label{ Text = "Comments:" },
					comments
				}
			};
		}
Пример #10
0
    protected override void OnAppearing()
    {
      base.OnAppearing();

      if (BindingContext == null)
      {
        BindingContext = _project;

        var grid = new Grid();
        grid.VerticalOptions = LayoutOptions.StartAndExpand;
        grid.Children.Add(new Label { Text = "Name" }, 0, 0);
        var editor = new Editor();
        editor.SetBinding(Editor.TextProperty, "Name");
        grid.Children.Add(editor, 1, 0);
        grid.Children.Add(new Label { Text = "Description" }, 0, 1);
        grid.Children.Add(new Editor { Text = _project.Description }, 1, 1);
        grid.Children.Add(new Label { Text = "Started" }, 0, 2);
        grid.Children.Add(new Editor { Text = _project.Started.ToString() }, 1, 2);
        grid.Children.Add(new Label { Text = "Ended" }, 0, 3);
        grid.Children.Add(new Editor { Text = _project.Ended.ToString() }, 1, 3);
        Content = grid;
      }
    }
Пример #11
0
        public NotePage(Note note)
        {
            this.note = note;
            Title = "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.
            this.Content = new StackLayout
            {
                Children = 
                {
                    new Label { Text = "Title:" },
                    entry,
                    new Label { Text = "Note:" },
                    editor,
                }
            };
        }
Пример #12
0
        public TaxaListPage(string title)
        {
            Title = title;
               //InitializeComponent();
               ToolbarItem editItem = new ToolbarItem { Text = "EDIT" };
               ToolbarItems.Add(editItem);
               editItem.Clicked += EditItem_Clicked;

               ListView listView = new ListView
               {
                    ItemsSource = Application.TaxaList,
                    ItemTemplate = new DataTemplate(() =>
                    {

                         Label taxonNameLbl = new Label();
                         taxonNameLbl.SetBinding(Label.TextProperty, "Name");
                         taxonNameLbl.HorizontalTextAlignment = TextAlignment.Start;

                         Editor taxonEditor = new Editor();
                         taxonEditor.SetBinding(Editor.TextProperty, "Data", BindingMode.TwoWay);
                         taxonEditor.Keyboard = Keyboard.Text;
                         taxonEditor.Focused += TaxonEditor_Focused;
                         taxonEditor.Completed += TaxonEditor_Completed;
                         taxonEditor.HorizontalOptions = LayoutOptions.FillAndExpand;
                         taxonEditor.VerticalOptions = LayoutOptions.FillAndExpand;
                         taxonEditor.HeightRequest = 75;
                         //taxonEditor.WidthRequest = ;

                         BoxView colorBox = new BoxView();
                         colorBox.WidthRequest = 10;
                         colorBox.HeightRequest = 75;
                         //colorBox.VerticalOptions = LayoutOptions.FillAndExpand;
                         colorBox.SetBinding(BoxView.ColorProperty, "Color");

                         return new ViewCell
                         {
                              View = new StackLayout
                              {
                                   Padding = new Thickness(0, 5),
                                   Spacing = 5,
                                   //HeightRequest = 300,
                                   IsClippedToBounds = true,
                                   Orientation = StackOrientation.Horizontal,
                                   VerticalOptions = LayoutOptions.FillAndExpand,
                                   Children = {
                                        colorBox,
                                        new StackLayout {
                                             Orientation = StackOrientation.Vertical,
                                             //HeightRequest = 200,
                                             HorizontalOptions = LayoutOptions.FillAndExpand,
                                             VerticalOptions = LayoutOptions.FillAndExpand,
                                             Spacing = 5,

                                             Children = { taxonNameLbl, taxonEditor }
                                        }
                                   }
                              }
                         };
                    })
               };
               //listView.VerticalOptions = LayoutOptions.FillAndExpand;
               listView.HasUnevenRows = true;
               listView.IsPullToRefreshEnabled = true;
               listView.Refreshing += ListView_Refreshing;
               Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);
               Content = new StackLayout { Children = { listView } };
        }
Пример #13
0
        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;
        }
Пример #14
0
        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;
        }
Пример #15
0
 private static Editor GenerateEditor()
 {
     var editor = new Editor { Keyboard = Keyboard.Chat, TextColor = DefaultAppStyles.DefaultTextColor };
     editor.SetBinding(Editor.TextProperty, CommentsViewModel.CommentPropertyName);
     return editor;
 }
Пример #16
0
        public static View CreateEditorFor(string propertyName, LayoutOptions layout)
        {
            Editor iiEditTextBox = new Editor
            {
                HorizontalOptions = layout,
                BackgroundColor = Helper.Color.iiPurple.ToFormsColor(),
                HeightRequest = 200,
                WidthRequest = 400,

            };

            iiEditTextBox.SetBinding(Editor.TextProperty, propertyName);
            return iiEditTextBox;
        }
        public NoteTaker5Page()
        {
            // 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.
            Note note = new Note();
            this.BindingContext = note;
            entry.SetBinding(Entry.TextProperty, "Title");
            editor.SetBinding(Editor.TextProperty, "Text");

            // Create Save and Load buttons.
            Button saveButton = new Button
            {
                Text = "Save",
                HorizontalOptions = LayoutOptions.CenterAndExpand
            };

            Button loadButton = new Button
            {
                Text = "Load",
                IsEnabled = false,
                HorizontalOptions = LayoutOptions.CenterAndExpand
            };

            // Set Clicked handlers.
            saveButton.Clicked += (sender, args) =>
                {
                    note.Save(FILENAME);
                    loadButton.IsEnabled = true;
                };

            loadButton.Clicked += (sender, args) => note.Load(FILENAME);

            // Check if the file is available.
            FileHelper.Exists(FILENAME, (exists) =>
                {
                    loadButton.IsEnabled = exists;
                });

            // Assemble page.
            this.Padding =
                new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 0);

            this.Content = new StackLayout
            {
                Children = 
                {
                    new Label 
                    { 
                        Text = "Title:" 
                    },
                    entry,
                    new Label 
                    { 
                        Text = "Note:" 
                    },
                    editor,
                    new StackLayout
                    {
                        Orientation = StackOrientation.Horizontal,
                        Children = 
                        {
                            saveButton,
                            loadButton
                        }
                    }
                }
            };
        }