Example #1
0
	    private void ScanComplete(object sender, EventArgs e)
	    {
            // Xam Forms requires us to redraw the table root to add new content
	        var tr = new TableRoot();
	        var fs = new TableSection("Test Assemblies");

	        foreach (var ta in viewModel.TestAssemblies)
	        {
	            var ts = new TextCell {BindingContext = ta};
	            ts.SetBinding(TextCell.TextProperty, "DisplayName");
	            ts.SetBinding(TextCell.DetailProperty, "DetailText");
	            ts.SetBinding(TextCell.DetailColorProperty, "DetailColor");

	            ts.Command = viewModel.NavigateToTestAssemblyCommand;
	            ts.CommandParameter = ts.BindingContext;
                
                fs.Add(ts);
	        }
	        tr.Add(fs); // add the first section

	        var run = new TextCell
	        {
	            Text = "Run Everything",
	            Command = viewModel.RunEverythingCommand,
	        };

	        table.Root.Skip(1)
                .First()
	             .Insert(0, run);
	        tr.Add(table.Root.Skip(1)); // Skip the first section and add the others

	        table.Root = tr;

	    }
        public ActivityPage(Activity act)
        {
            theAct = act;
            Title = act.FullName;
            fullDescription = string.Format ("{0}, worth {1} points", act.FullName, act.Score);
            Label subTitle = new Label () {
                FontAttributes = FontAttributes.Italic,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
            };
            if (act.OneTimeOnly) {
                subTitle.Text = string.Format ("Worth {0} points (one time only)", act.Score);
            } else {
                subTitle.Text = string.Format ("Worth {0} points (each)", act.Score);
            }

            var listTemplate = new DataTemplate (() => {
                var cell = new TextCell ();
                cell.SetBinding<Task> (TextCell.TextProperty, t => t.DT);
                cell.SetBinding<Task> (TextCell.DetailProperty, t => t.Notes);
                return cell;
            });

            // There might be multiple task-completions here, so use a scrolling ListView
            listCurrentTasks = new ListView ();
            listCurrentTasks.ItemTemplate = listTemplate;
            listCurrentTasks.ItemSelected += HandleSelect;

            // There might be multiple task-completions here, so use a scrolling ListView
            listTaskHistory = new ListView ();
            listTaskHistory.ItemTemplate = listTemplate;
            listTaskHistory.ItemSelected += HandleSelect;

            btnAdd = new Button () { Text = "Tap to Record Completion", BorderWidth = 2, };
            btnAdd.Clicked += HandleAdd;

            var layout = new StackLayout ();
            layout.Children.Add (subTitle);
            layout.Children.Add (btnAdd);
            tapToDeleteOrUpdate = new Label { Text = "Tap below to Delete or Add Notes", TextColor = Color.Teal, };
            tapToDeleteOrUpdate.IsVisible = false;
            layout.Children.Add (tapToDeleteOrUpdate);

            layout.Children.Add (listCurrentTasks);
            var lineSeparator = new BoxView () { Color = Color.Blue, WidthRequest = 100, HeightRequest = 8 };
            layout.Children.Add (lineSeparator);
            layout.Children.Add (new Label { Text = "History (not included in current score):", TextColor = Color.Teal, });
            layout.Children.Add (listTaskHistory);
            //layout.HorizontalOptions = LayoutOptions.Center;
            Content = layout;
        }
Example #3
0
        public CommitmentPage(Commitment commitment)
        {
            _commitment = commitment;
            BindingContext = commitment;

            var grid = new Grid() {
                RowDefinitions = new RowDefinitionCollection {
                    new RowDefinition(),
                    new RowDefinition(),
                },
                ColumnDefinitions = new ColumnDefinitionCollection {
                    new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) },
                    new ColumnDefinition { Width = new GridLength(2, GridUnitType.Star) },
                }
            };

            var plannedLabel = new Label {
                Text = "I am"
            };
            plannedLabel.SetValue(Grid.RowProperty, 0);

            var plannedTextCell = new TextCell {

            };
            plannedTextCell.SetBinding(TextCell.TextProperty, "Status");
            grid.Children.Add(plannedLabel);

            Content = grid;
        }
Example #4
0
    protected async override void OnAppearing()
    {
      if (!_loaded)
      {
        _loaded = true;
        var projects = await Library.ProjectList.GetProjectListAsync();
        var list = new ListView();
        list.ItemTemplate = new DataTemplate(() =>
        {
          var cell = new TextCell();
          cell.SetBinding<Library.ProjectInfo>(TextCell.TextProperty, m => m.Name);
          return cell;
        });
        list.ItemsSource = projects;
        list.ItemTapped += async (a, b) => 
        {
          var info = (Library.ProjectInfo)((ListView)a).SelectedItem;
          var project = await Library.ProjectEdit.GetProjectAsync(info.Id);
          await Navigation.PushAsync(new ProjectEdit(project));
        };

        var stack = new StackLayout();
        stack.Children.Add(list);
        Content = stack;
      }
      base.OnAppearing();
    }
        public PublicRoomsPage(ViewModelBase viewModel)
            : base(viewModel)
        {
            var listView = new BindableListView
                {
                    ItemTemplate = new DataTemplate(() =>
                        {
                        var textCell = new TextCell();
                            textCell.SetBinding(TextCell.TextProperty, new Binding("Name"));
                            textCell.TextColor = Styling.BlackText;
                            //textCell.SetBinding(TextCell.DetailProperty, new Binding("Description"));
                            return textCell;
                        }),
                    SeparatorVisibility = SeparatorVisibility.None
                };

            listView.SetBinding(ListView.ItemsSourceProperty, new Binding("PublicRooms"));
            listView.SetBinding(BindableListView.ItemClickedCommandProperty, new Binding("SelectRoomCommand"));

            var loadingIndicator = new ActivityIndicator ();
            loadingIndicator.SetBinding(ActivityIndicator.IsRunningProperty, new Binding("IsBusy"));
            loadingIndicator.SetBinding(ActivityIndicator.IsVisibleProperty, new Binding("IsBusy"));

            Content = new StackLayout
            {
                Children =
                        {
                            loadingIndicator,
                            listView
                        }
            };
        }
        public HistoryPage()
        {
            Title = "Score History";

            var periodList = new ListView ();
            var lblDesc = new Label ();
            lblDesc.Text = "Score / For Period Beginning";

            periodList.ItemTemplate = new DataTemplate (() => {
                var cell = new TextCell ();
                cell.SetBinding<Period> (TextCell.TextProperty, p => p.Score);
                cell.SetBinding<Period> (TextCell.DetailProperty, p => p.StartDT);
                return cell;
            });

            var periodHistory = App.Database.ListPeriods ();
            periodList.ItemsSource = periodHistory;

            var layout = new StackLayout ();
            layout.Children.Add (lblDesc);
            layout.Children.Add (periodList);
            Content = layout;
        }
Example #7
0
        public SwitchPageCS()
        {
            SwitchPageViewModel vm = new SwitchPageViewModel();
            BindingContext = vm;

            var sw0 = new SwitchCell { Text = "Toggle sw1 & sw2" };
            sw0.SetBinding(SwitchCell.OnProperty, "SwAllValue", BindingMode.OneWayToSource);
            var sw1 = new SwitchCell { Text = "Toggle sw1" };
            sw1.SetBinding(SwitchCell.OnProperty, "Sw1Value", BindingMode.TwoWay);
            var sw2 = new SwitchCell { Text = "Toggle sw2" };
            sw2.SetBinding(SwitchCell.OnProperty, "Sw2Value", BindingMode.TwoWay);
            var tc1 = new TextCell { Text = "sw1 value" };
            tc1.SetBinding(TextCell.DetailProperty, "Sw1Value");
            var tc2 = new TextCell { Text = "sw2 value" };
            tc2.SetBinding(TextCell.DetailProperty, "Sw2Value");

            var tv = new TableView
            {
                Intent = TableIntent.Menu,
                Root = new TableRoot
                {
                    new TableSection("Toggle all")
                    {
                        sw0,
                    },

                    new TableSection("Toggle each")
                    {
                        sw1,
                        sw2,
                    },
                    new TableSection("Values of ViewModel")
                    {
                        tc1,
                        tc2,
                    }
                }
            };

            Content = new StackLayout
            {
                Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0),
                Children =
                {
                    tv,
                }
            };
        }
Example #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,
                }
            };
        }
Example #9
0
    protected async override void OnAppearing()
    {
      var projects = await Library.ProjectList.GetProjectListAsync();
      var list = new ListView();
      list.ItemTemplate = new DataTemplate(() =>
      {
        var cell = new TextCell();
        cell.SetBinding<Library.ProjectInfo>(TextCell.TextProperty, m => m.Name);
        return cell;
      });
      list.ItemsSource = projects;

      var stack = (StackLayout)Content;
      stack.Children.Add(list);

      base.OnAppearing();
    }
        public BlogPostSelectorPage(ApplicationViewModel applicationViewModel)
        {
            if (applicationViewModel == null) throw new ArgumentNullException(nameof(applicationViewModel));

            Title = "Blog posts";
            BindingContext = applicationViewModel;
            listView = new ListView
            {
                ItemsSource = applicationViewModel.BlogPosts,
                ItemTemplate = new DataTemplate(() =>
                {
                    var textCell = new TextCell();
                    textCell.SetBinding(TextCell.TextProperty, nameof(BlogPostViewModel.Title));
                    return textCell;
                })
            };

            listView.SetBinding(ListView.SelectedItemProperty, nameof(ApplicationViewModel.SelectedBlogPost));

            Content = listView;
        }
Example #11
0
    protected async override void OnAppearing()
    {
      if (!_loaded)
      {
        _loaded = true;
        var resources = await Library.ResourceList.GetResourceListAsync();
        var list = new ListView();
        list.ItemTemplate = new DataTemplate(() =>
        {
          var cell = new TextCell();
          cell.SetBinding<Library.ResourceInfo>(TextCell.TextProperty, m => m.Name);
          return cell;
        });
        list.ItemsSource = resources;

        var stack = new StackLayout();
        stack.Children.Add(list);
        Content = stack;
      }
      base.OnAppearing();
    }
        private void Init()
        {

            OsmNominatim.Instance.CountryCodes.Add("de");

            this._autoCompleteListView = new ListView
            {
                IsVisible = false,
                RowHeight = 40,
                HeightRequest = 0,
                BackgroundColor = Color.White
            };
            this._autoCompleteListView.ItemTemplate = new DataTemplate(() =>
            {
                var cell = new TextCell();
                cell.SetBinding(ImageCell.TextProperty, "Description");

                return cell;
            });

            View searchView;
            if (this._useSearchBar)
            {
                this._searchBar = new SearchBar
                {
                    Placeholder = "Search for address..."
                };
                this._searchBar.TextChanged += SearchTextChanged;
                this._searchBar.SearchButtonPressed += SearchButtonPressed;

                searchView = this._searchBar;

            }
            else
            {
                this._entry = new Entry
                {
                    Placeholder = "Sarch for address"
                };
                this._entry.TextChanged += SearchTextChanged;

                searchView = this._entry;
            }
            this.Children.Add(searchView,
                Constraint.Constant(0),
                Constraint.Constant(0),
                widthConstraint: Constraint.RelativeToParent(l => l.Width));

            this.Children.Add(
                this._autoCompleteListView,
                Constraint.Constant(0),
                Constraint.RelativeToView(searchView, (r, v) => v.Y + v.Height));

            this._autoCompleteListView.ItemSelected += ItemSelected;

            this._textChangeItemSelected = false;
        }
Example #13
0
        public MenuPage()
        {
            InitializeComponent();

            _chosenItemCmd = new Command(obj =>
            {
                var mic = MenuItemChanged;
                if (mic != null)
                {
                    mic.Invoke(this, new MenuItemChangedEventArg()
                    {
                        SelectedMenuItem = obj as MenuItem,
                    });
                }
            });

            _calcMenuItems = new List<MenuItem>()
            {
                new MenuItem("Introduction", () => new IntroPage()),
                new MenuItem("Step 1", () => new Step1Page()),
                new MenuItem("Step 2", () => new Step2Page()),
                new MenuItem("Step 3", () => new Step3Page()),
                new MenuItem("Step 4", () => new Step4Page()),
                new MenuItem("Step 5", () => new ContentPage()),
            };

            _appMenuItems = new List<MenuItem>()
            {
                new MenuItem("About", () => new ContentPage()),
                new MenuItem("Settings", () => new ContentPage()),
                new MenuItem("Help", () => new ContentPage()),
            };

            _subMenu.ItemsSource = _calcMenuItems;

            _subMenu.ItemSelected += (object sender, SelectedItemChangedEventArgs e) =>
            {
                if (e.SelectedItem != null)
                {
                    var mi = (MenuItem)e.SelectedItem;
                    _subMenu.SelectedItem = null;
                    _chosenItemCmd.Execute(mi);
                }
            };

            _subMenu.ItemTemplate = new DataTemplate(() =>
            {
                var tc = new TextCell();
                tc.SetBinding(TextCell.TextProperty, "MenuTitle");

                return tc;
            });
        }
        internal static Cell UserCell(PropertyInfo property, IContact context, Page parent = null)
        {
            var label = CreateLabel(property);
            var cell = new TextCell();
            cell.BindingContext = parent.BindingContext;
            cell.SetValue(TextCell.DetailProperty, label);
            cell.SetBinding(
                TextCell.TextProperty, 
                new Binding(
                    path: "SelectedModel." + property.Name,
                    mode: BindingMode.OneWay,
                    converter: OwnerConverter, 
                    converterParameter: parent.BindingContext
                )
            );
            cell.SetValue(TextCell.CommandProperty, new Command(async (a)=>{
                var cellTemplate = new DataTemplate(typeof(TextCell));
                cellTemplate.SetBinding(TextCell.TextProperty, new Binding(".", converter: OwnerConverter));
                var list = new ListView {
                    ItemTemplate = cellTemplate,
                };
                list.SetBinding(ItemsView<Cell>.ItemsSourceProperty, "Users");
                list.SetBinding(ListView.SelectedItemProperty, "SelectedModel." + property.Name);
                list.ItemSelected += async (sender, e)=>
                {
                    await parent.Navigation.PopAsync();
                };
                var page = new ContentPage {
                    Title = "Change Owner",
                    Content = list
                };
                page.BindingContext = parent.BindingContext;

                await parent.Navigation.PushAsync(page);
            }));
            return cell;
        }
 internal static Cell UserCell(PropertyInfo property, IContact context, Page parent = null)
 {
     var label = CreateLabel(property);
     var cell = new TextCell();
     cell.SetValue(TextCell.TextProperty, label);
     cell.SetBinding(TextCell.DetailProperty, new Binding(property.Name, converter: OwnerConverter));
     cell.SetValue(TextCell.CommandProperty, new Command(async (a)=>
         {
             var service = DependencyService.Get<UserRepository>();
             var users = await service.All();
             var cellTemplate = new DataTemplate(typeof(TextCell));
             cellTemplate.SetBinding(TextCell.TextProperty, new Binding(".", converter: OwnerConverter));
             var list = new ListView {
                 ItemTemplate = cellTemplate,
                 ItemsSource = users
             };
             list.ItemSelected += async (sender, e)=>
             {
                 context.Owner = e.SelectedItem as IUser;
                 await parent.Navigation.PopAsync();
             };
             var page = new ContentPage {
                 Title = "Change Owner",
                 Content = list
             };
             await parent.Navigation.PushAsync(page);
     }));
     cell.BindingContext = context;
     return cell;
 }
Example #16
0
		protected override Cell CreateDefault(object item)
		{
			TextCell textCell = new TextCell();
			textCell.SetBinding(TextCell.TextProperty, ".", converter: _toStringValueConverter);
			return textCell;
		}