Пример #1
0
		public SettingsScreen ()
		{
			Intent = TableIntent.Settings;
			var cell = new TextCell { Text = "Coverflow", Detail = "Value 1" };

			var boolCell = new SwitchCell { Text = "Off" };
			boolCell.OnChanged += (sender, arg) => boolCell.Text = boolCell.On ? "On" : "Off";

			var root = new TableRoot () {
				new TableSection () {
					cell,
					new TextCell { Text = "Cell 2", Detail = "Value 2" },
					new EntryCell {
						Label = "Label",
						Placeholder = "Placeholder 1",
						HorizontalTextAlignment = TextAlignment.Center,
						Keyboard = Keyboard.Numeric
					},
					new ImageCell { Text = "Hello", Detail = "World", ImageSource = "cover1.jpg" }
				},
				new TableSection ("Styles") {
					boolCell,
					new EntryCell {
						Label = "Label2",
						Placeholder = "Placeholder 2",
						HorizontalTextAlignment = TextAlignment.Center,
						Keyboard = Keyboard.Chat
					},
				},
				new TableSection ("Custom Cells") {
					new ViewCell { View = new Button (){ Text = "Hi" } },
				}
			};
			Root = root;
		}
Пример #2
0
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="model">the model of the copy</param>
 public TextCell(TextCell model)
     : base(model)
 {
     // call the init after setting the orientation (in the base copy constructor)
     // to compute the image in the right orientation
     // the init method will initialize mImage because setting the Font will call an update of the image
     init(model.Text, model.Font, model.FontColor, model.TextAlignment);
 }
Пример #3
0
		public UnevenListGallery ()
		{
			Padding = new Thickness (0, 20, 0, 0);

			var list = new ListView {
				HasUnevenRows = true
			};

			bool next = true;
			list.ItemTemplate = new DataTemplate (() => {
				bool tall = next;
				next = !next;
				
				var cell = new TextCell {
					Height = (tall) ? 88 : 44
				};

				cell.SetBinding (TextCell.TextProperty, ".");
				return cell;
			});

			list.ItemsSource = new[] { "Tall", "Short", "Tall", "Short" };

			var listViewCellDynamicHeight = new ListView {
				HasUnevenRows = true,
				AutomationId= "unevenCellListGalleryDynamic"
			};

			listViewCellDynamicHeight.ItemsSource = new [] { 
				@"That Flesh is heir to? 'Tis a consummation
Devoutly to be wished. To die, to sleep,
To sleep, perchance to Dream; Aye, there's the rub,
For in that sleep of death, what dreams may come,That Flesh is heir to? 'Tis a consummation
Devoutly to be wished. To die, to sleep,
To sleep, perchance to Dream; Aye, there's the rub,
For in that sleep of death, what dreams may come",
			};

			listViewCellDynamicHeight.ItemTemplate = new DataTemplate (typeof(UnevenRowsCell));

			listViewCellDynamicHeight.ItemTapped += (sender, e) => {
				if (e == null)
					return; // has been set to null, do not 'process' tapped event
				((ListView)sender).SelectedItem = null; // de-select the row
			};

			var grd = new Grid ();

			grd.RowDefinitions.Add (new RowDefinition ());
			grd.RowDefinitions.Add (new RowDefinition ());
		
			grd.Children.Add (listViewCellDynamicHeight);
			grd.Children.Add (list);
		
			Grid.SetRow (list, 1);
		
			Content =  grd;
		}
Пример #4
0
		public void TestTapped ()
		{
			var cell = new TextCell ();
			bool tapped = false;
			cell.Tapped += (sender, args) => tapped = true;

			cell.OnTapped();
			Assert.True (tapped);
		}
Пример #5
0
		protected override void Init()
		{
			TextCell cell1 = new TextCell
			{
				Text = "ListView: TextCell"
			};
			cell1.Tapped += async delegate (object sender, EventArgs e)
			{
				await Navigation.PushAsync(new ListViewTextCellPage());
			};
			TextCell cell2 = new TextCell
			{
				Text = "ListView: CustomCell"
			};
			cell2.Tapped += async delegate (object sender, EventArgs e)
			{
				await Navigation.PushAsync(new ListViewCustomCellPage(ListViewCachingStrategy.RetainElement));
			};
			TextCell cell3 = new TextCell
			{
				Text = "TableView: TextCell"
			};
			cell3.Tapped += async delegate (object sender, EventArgs e)
			{
				await Navigation.PushAsync(new TableViewTextCellPage());
			};
			TextCell cell4 = new TextCell
			{
				Text = "TableView: CustomCell"
			};
			cell4.Tapped += async delegate (object sender, EventArgs e)
			{
				await Navigation.PushAsync(new TableViewCustomCellPage());
			};

			TextCell cell5 = new TextCell
			{
				Text = "ListView: CustomCell RecycleElement"
			};
			cell5.Tapped += async delegate (object sender, EventArgs e)
			{
				await Navigation.PushAsync(new ListViewCustomCellPage(ListViewCachingStrategy.RecycleElement));
			};
			TableView tableV = new TableView
			{
				Root = new TableRoot {
					new TableSection {
						cell1,
						cell2,
						cell3,
						cell4,
						cell5
					}
				}
			};
			Content = tableV;
		}
Пример #6
0
			static TextCell MakeIssueCell (string text, string detail, Action tapped)
			{
				PageToAction[text] = tapped;
				if (detail != null)
					PageToAction[detail] = tapped;

				var cell = new TextCell { Text = text, Detail = detail };
				cell.Tapped += (s, e) => tapped();
				return cell;
			}
Пример #7
0
		public void Contains ()
		{
			var section = new TableSection ();
			TextCell first, second;
			section.Add (first = new TextCell { Text = "Text" });
			section.Add (second = new TextCell { Text = "Text" });

			Assert.True (section.Contains (first));
			Assert.True (section.Contains (second));
		}
Пример #8
0
		public void Add ()
		{
			var section = new TableSection ();
			TextCell first, second;
			section.Add (first = new TextCell { Text = "Text" });
			section.Add (second = new TextCell { Text = "Text" });

			Assert.That (section, NContains.Item (first));
			Assert.That (section, NContains.Item (second));
		}
Пример #9
0
		public void TestCommand()
		{
			bool executed = false;

			var cmd = new Command (() => executed = true);
			var cell = new TextCell();
			cell.Command = cmd;
			cell.OnTapped();

			Assert.IsTrue (executed, "Command was not executed");
		}
Пример #10
0
		public void Remove ()
		{
			var section = new TableSection ();
			TextCell first;
			section.Add (first = new TextCell { Text = "Text" });
			section.Add (new TextCell { Text = "Text" });

			var result = section.Remove (first);
			Assert.True (result);
			Assert.That (section, Has.No.Contains (first));
		}
Пример #11
0
        private void PrescriptionDetailPage_BindingContextChanged(object sender, EventArgs e)
        {
            var model = BindingContext as PrescriptionViewModel;

            if (model == null || model.Issues == null || !model.Issues.Any())
            {
                return;
            }

            foreach (var issue in model.Issues)
            {
                var textCell = new TextCell()
                {
                    Text = issue.ToString(), TextColor = Color.Gray
                };
                textCell.IsEnabled = false;
                //IssuesSection.Add(textCell);
            }
        }
Пример #12
0
        Cell GetNewGroupHeaderCell(ITemplatedItemsList <Cell> group)
        {
            var groupHeaderCell = _listView.TemplatedItems.GroupHeaderTemplate?.CreateContent(group.ItemsSource, _listView) as Cell;

            if (groupHeaderCell != null)
            {
                groupHeaderCell.BindingContext = group.ItemsSource;
            }
            else
            {
                groupHeaderCell = new TextCell();
                groupHeaderCell.SetBinding(TextCell.TextProperty, nameof(group.Name));
                groupHeaderCell.BindingContext = group;
            }

            groupHeaderCell.Parent = _listView;
            groupHeaderCell.SetIsGroupHeader <ItemsView <Cell>, Cell>(true);
            return(groupHeaderCell);
        }
Пример #13
0
		public void TestCommandParameter()
		{
			bool executed = false;

			object obj = new object();
			var cmd = new Command (p => {
				Assert.AreSame (obj, p);
				executed = true;
			});

			var cell = new TextCell {
				Command = cmd,
				CommandParameter = obj
			};

			cell.OnTapped();

			Assert.IsTrue (executed, "Command was not executed");
		}
Пример #14
0
        /*
         * Constructor which initialises the entries of the medications listview.
         */
        public SingleMedicationPage(Medication medication)
        {
            InitializeComponent();
            AddMedicationLayout.IsVisible = false;
            UserViewLayout.IsVisible      = true;
            this.Title     = "Viewing Medication";
            NameEntry.Text = medication.name;
            IDEntry.Text   = medication.Id.ToString();

            foreach (string item in medication.activeIngredients)
            {
                TextCell cell = new TextCell();
                cell.Text      = item;
                cell.TextColor = Color.Gray;
                activeIngredientsTableSection.Add(cell);
            }

            foreach (string item in medication.history)
            {
                TextCell    cell      = new TextCell();
                StackLayout tmpLayout = new StackLayout
                {
                    Orientation = StackOrientation.Vertical,
                    Padding     = new Thickness(15, 0, 0, 0),
                    Children    =
                    {
                        new Label
                        {
                            Text            = item,
                            TextColor       = Color.Gray,
                            FontSize        = 15,
                            VerticalOptions = LayoutOptions.Center
                        }
                    }
                };

                ViewCell viewCell = new ViewCell
                {
                    View = tmpLayout
                };
                historyTableSection.Add(viewCell);
            }
        }
Пример #15
0
        public void Bz27229()
        {
            var totalCheckTime = new TextCell {
                Text = "Total Check Time"
            };

            totalCheckTime.BindingContext = new Bz27229ViewModel();
            totalCheckTime.SetBinding(TextCell.DetailProperty, "Member.Result.Text");
            Assert.AreEqual("foo", totalCheckTime.Detail);

            totalCheckTime = new TextCell {
                Text = "Total Check Time"
            };
            totalCheckTime.BindingContext = new Bz27229ViewModel();
            totalCheckTime.SetBinding <Bz27229ViewModel>(TextCell.DetailProperty, vm =>
                                                         ((Generic <Label>)vm.Member).Result.Text);

            Assert.AreEqual("foo", totalCheckTime.Detail);
        }
Пример #16
0
        public void TestCommandParameter()
        {
            bool executed = false;

            object obj = new object();
            var    cmd = new Command(p => {
                Assert.AreSame(obj, p);
                executed = true;
            });

            var cell = new TextCell {
                Command          = cmd,
                CommandParameter = obj
            };

            cell.OnTapped();

            Assert.IsTrue(executed, "Command was not executed");
        }
Пример #17
0
        public void ChainsBindingContextToNewlyAdded()
        {
            var section        = new TableSection();
            var bindingContext = "bindingContext";

            section.BindingContext = bindingContext;

            TextCell first, second;

            section.Add(first = new TextCell {
                Text = "Text"
            });
            section.Add(second = new TextCell {
                Text = "Text"
            });

            Assert.AreEqual(bindingContext, first.BindingContext);
            Assert.AreEqual(bindingContext, second.BindingContext);
        }
Пример #18
0
        protected override void Init()
        {
            var list = new ListView
            {
                ItemsSource = new List <string>
                {
                    "Cat",
                    "Dog",
                    "Rat"
                },
                ItemTemplate = new DataTemplate(() =>
                {
                    var cell = new TextCell();
                    cell.SetBinding(TextCell.TextProperty, ".");
                    cell.ContextActions.Add(new MenuItem
                    {
                        Text            = "Action",
                        IconImageSource = "icon",
                        IsDestructive   = true,
                        Command         = new Command(() => DisplayAlert("TITLE", "Context action invoked", "Ok")),
                    });
                    return(cell);
                }),
            };

            Content = new StackLayout
            {
                Children =
                {
                    new Button
                    {
                        Text    = "Go to next page",
                        Command = new Command(() => Navigation.PushAsync(new ContentPage{
                            Title = "Next Page", Content = new Label{
                                Text = "Here"
                            }
                        }))
                    },
                    list
                }
            };
        }
Пример #19
0
        public LoadResourceJson()
        {
            #region How to load an Json file embedded resource
            var    assembly = IntrospectionExtensions.GetTypeInfo(typeof(LoadResourceText)).Assembly;
            Stream stream   = assembly.GetManifestResourceStream("WorkingWithFiles.LibJsonResource.json");

            Earthquake[] earthquakes;
            using (var reader = new StreamReader(stream))
            {
                var json       = reader.ReadToEnd();
                var rootobject = JsonConvert.DeserializeObject <Rootobject>(json);
                earthquakes = rootobject.earthquakes;
            }
            #endregion

            var listView = new ListView();
            listView.ItemTemplate = new DataTemplate(() =>
            {
                var textCell = new TextCell();
                textCell.SetBinding(TextCell.TextProperty, "Data");
                return(textCell);
            });
            listView.ItemsSource = earthquakes;

            Content = new StackLayout
            {
                Margin          = new Thickness(20),
                VerticalOptions = LayoutOptions.StartAndExpand,
                Children        =
                {
                    new Label {
                        Text           = "Embedded Resource JSON File",
                        FontSize       = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                        FontAttributes = FontAttributes.Bold
                    }, listView
                }
            };

            // NOTE: use for debugging, not in released app code!
            //foreach (var res in assembly.GetManifestResourceNames())
            //	System.Diagnostics.Debug.WriteLine("found resource: " + res);
        }
Пример #20
0
        public LoadResourceXml()
        {
            #region How to load an XML file embedded resource
            var    assembly = IntrospectionExtensions.GetTypeInfo(typeof(LoadResourceText)).Assembly;
            Stream stream   = assembly.GetManifestResourceStream("RussianFlashCards.Russian.xml");

            List <Item> monkeys;
            using (var reader = new StreamReader(stream))
            {
                var serializer = new XmlSerializer(typeof(List <Item>));
                monkeys = (List <Item>)serializer.Deserialize(reader);
            }
            #endregion

            var listView = new ListView();
            listView.ItemTemplate = new DataTemplate(() =>
            {
                var textCell = new TextCell();
                textCell.SetBinding(TextCell.TextProperty, "Name");
                textCell.SetBinding(TextCell.DetailProperty, "Location");
                return(textCell);
            });
            listView.ItemsSource = monkeys;

            Content = new StackLayout
            {
                Margin          = new Thickness(20),
                VerticalOptions = LayoutOptions.StartAndExpand,
                Children        =
                {
                    new Label {
                        Text           = "Embedded Resource XML File",
                        FontSize       = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                        FontAttributes = FontAttributes.Bold
                    }, listView
                }
            };

            // NOTE: use for debugging, not in released app code!
            //foreach (var res in assembly.GetManifestResourceNames())
            //	System.Diagnostics.Debug.WriteLine("found resource: " + res);
        }
        Cell GetGraphCell(string title)
        {
            var cell = new TextCell {
                Text = title
            };

            cell.Tapped += (sender, ea) => {
                var ei = exampleInfoList
                         .Where(e => e.Title == title)
                         .FirstOrDefault();

                var gp = new GraphViewPage(ei)
                {
                    Title = title
                };

                Navigation.PushAsync(gp);
            };
            return(cell);
        }
Пример #22
0
        protected async override void OnAppearing()
        {
            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 = (StackLayout)Content;

            stack.Children.Add(list);

            base.OnAppearing();
        }
Пример #23
0
        private void CreateCell(ref TextCell cell, object value, string binding = "", int bindingIndex = -1, Color?back = null, Color?font = null, OnMouseEnterDelegate onMouseEnter = null, OnClickDelegate onClick = null, bool enable = false, string format = "", object tag = null)
        {
            if (cell != null)
            {
                return;
            }
            Color bc = back == null ? Color.White : (Color)back;
            Color fc = font == null ? Color.Black : (Color)font;

            cell = new TextCell(value, value.GetType())
            {
                DefaultBackColor = bc, DefaultFontColor = fc, Enable = enable, HasBorder = true, Border = Border, Format = format, FontName = CellBase.FontName.Verdana, FontSize = 8, Tag = tag
            };
            if (!string.IsNullOrEmpty(binding))
            {
                cell.SetDataBinding(this.GetType(), binding, this, bindingIndex);
            }
            cell.OnClick      += onClick;
            cell.OnMouseEnter += onMouseEnter;
        }
Пример #24
0
        /// <summary>
        /// Called when the user taps on a word in the list.
        /// </summary>
        /// <param name="sender">The object sending the event.</param>
        /// <param name="e">The event parameters.</param>
        private async void TableWord_Tapped(object sender, EventArgs e)
        {
            if (await ConnectivityCheck.AskToEnableConnectivity(this))
            {
                TextCell senderCell = sender as TextCell;
                if (senderCell == null)
                {
                    return;
                }

                if (senderCell.BindingContext is IWord)
                {
                    await this.CallSearchPage(((IWord)senderCell.BindingContext).Term);
                }
                else
                {
                    await this.CallSearchPage(senderCell.Text);
                }
            }
        }
Пример #25
0
        public German()
        {
            var    assembly = IntrospectionExtensions.GetTypeInfo(typeof(LoadResourceText)).Assembly;
            Stream stream   = assembly.GetManifestResourceStream("ObjectivoF.Data.GermanPhraseBook.xml");

            List <Phrases> phrases;

            using (var reader = new StreamReader(stream))
            {
                var serializer = new XmlSerializer(typeof(List <Phrases>));
                phrases = (List <Phrases>)serializer.Deserialize(reader);
            }

            var listView = new ListView();

            listView.ItemTemplate = new DataTemplate(() =>
            {
                var textCell = new TextCell();
                textCell.SetBinding(TextCell.TextProperty, "Name");

                return(textCell);
            });

            listView.ItemsSource = phrases;
            var image = new Image {
                Source = "german.jpg"
            };

            Content = new StackLayout
            {
                Padding         = new Thickness(0, 20, 0, 0),
                VerticalOptions = LayoutOptions.StartAndExpand,
                Children        =
                {
                    new Image {
                        Source = "german.jpg"
                    },
                    listView
                }
            };
        }
Пример #26
0
        public NewNoteTableView()
        {
            this.Title = "Create";
            var table = new TableView()
            {
                Intent = TableIntent.Form
            };
            var root     = new TableRoot();
            var section1 = new TableSection()
            {
                Title = "first section"
            };
            var section2 = new TableSection()
            {
                Title = "second section"
            };

            var textCell = new TextCell()
            {
                Text = "Create a new reminder", Detail = "Enter info below to create a new notification"
            };
            var entryCell = new EntryCell()
            {
                Placeholder = "Enter your reminder text"
            };
            var switchCell = new SwitchCell()
            {
                Text = "Select reminder mode"
            };

            section1.Add(textCell);
            section1.Add(entryCell);

            section2.Add(switchCell);

            table.Root = root;
            root.Add(section1);
            root.Add(section2);

            Content = table;
        }
Пример #27
0
        public CommitmentPage(CommitmentViewModel commitment)
        {
            _commitment = commitment;

            BackgroundColor = Constants.HtBoxDarkBrown;
            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",
                TextColor       = Constants.HtBoxTan,
                BackgroundColor = Constants.HtBoxDarkBrown
            };

            plannedLabel.SetValue(Grid.RowProperty, 0);

            var plannedTextCell = new TextCell
            {
            };

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

            Content = grid;
        }
        public PassedTestPage(User user, IEnumerable <Tasks> tasks, IEnumerable <Tests> tasksName)
        {
            InitializeComponent();
            TableView    tableView = new TableView();
            int          i         = 0;
            List <Tasks> tasksList = tasks.ToList();

            foreach (var taskName in tasksName)
            {
                TableSection tableSection = new TableSection();
                TextCell     textCell     = new TextCell();

                tableSection.Add(textCell);

                tableView.Root.Add(tableSection);
                textCell.Text = taskName.Name;

                if (tasksList[i].Sum >= tasksList[i].Pass)
                {
                    textCell.TextColor = Color.Green;
                }
                else
                {
                    textCell.TextColor = Color.Red;
                }

                textCell.Tapped += async delegate
                {
                    ApplicationViewModel applicationViewModel = new ApplicationViewModel();

                    await applicationViewModel.GetTaskAnswersQuestion(user.Login, user.Password, tasks.ToList().Where(t => t.Test == taskName.Id).FirstOrDefault().Id);

                    await applicationViewModel.GetTaskAnswers(user.Login, user.Password, tasks.ToList().Where(t => t.Test == taskName.Id).FirstOrDefault().Id);

                    var passedQuestionPage = new PassedQuestionPage(user, tasks.ToList().Where(t => t.Test == taskName.Id).FirstOrDefault(), applicationViewModel.taskAnswersQuestion, applicationViewModel.taskAnswers);
                    await Navigation.PushModalAsync(passedQuestionPage);
                };
            }

            Content = tableView;
        }
Пример #29
0
        public Page3(int predmetID)
        {
            InitializeComponent();
            string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);

            path = Path.Combine(path, "test.db");
            TableCreator    tableCreator = new TableCreator(path);
            DatabaseManager dbManager    = new DatabaseManager(path);
            var             predmety     = tableCreator.NacistListPredmetu();
            var             radky        = tableCreator.VytvoritTabulku();

            var radek = radky[predmetID];

            double soucet    = 0;
            double soucetVah = 0;

            foreach (var item in radek)
            {
                soucet    += item.Hodnota * item.Vaha;
                soucetVah += item.Vaha;
            }

            double prumer = soucet / soucetVah;

            prumer = Math.Round(prumer, 2);

            TextCell cell = new TextCell {
                Text = predmety[predmetID].Nazev + " (průměr: " + prumer + ")"
            };

            TableZnamky.Add(cell);

            foreach (var item in radek)
            {
                TextCell cell2 = new TextCell {
                    Text = item.Hodnota + " (váha: " + item.Vaha + ")", StyleId = item.ID.ToString()
                };
                cell2.Tapped += ViewCellTapped;
                TableZnamky.Add(cell2);
            }
        }
Пример #30
0
        public void Overwrite()
        {
            var      section = new TableSection();
            TextCell second;

            section.Add(new TextCell {
                Text = "Text"
            });
            section.Add(second = new TextCell {
                Text = "Text"
            });

            var third = new TextCell {
                Text = "Text"
            };

            section[1] = third;

            Assert.AreEqual(third, section[1]);
            Assert.That(section, Has.No.Contains(second));
        }
Пример #31
0
        protected override void Init()
        {
            var tableView    = new TableView();
            var tableSection = new TableSection();
            var switchCell   = new TextCell
            {
                Text = "Cell"
            };

            var menuItem = new MenuItem
            {
                Text          = "Self-Deleting item",
                Command       = new Command(() => switchCell.ContextActions.RemoveAt(0)),
                IsDestructive = true
            };

            switchCell.ContextActions.Add(menuItem);
            tableSection.Add(switchCell);
            tableView.Root.Add(tableSection);
            Content = tableView;
        }
Пример #32
0
        public void MenuItemsGetBindingContext()
        {
            var cell = new TextCell {
                ContextActions =
                {
                    new MenuItem()
                }
            };

            object bc = new object();

            cell.BindingContext = bc;
            Assert.That(cell.ContextActions [0].BindingContext, Is.SameAs(bc));

            cell = new TextCell {
                BindingContext = new object()
            };
            cell.ContextActions.Add(new MenuItem());

            Assert.That(cell.ContextActions [0].BindingContext, Is.SameAs(cell.BindingContext));
        }
Пример #33
0
        public MyPage()
        {
            Padding = new Thickness(5, 20);

            Button button = new Button {
                Text = "Run Tests"
            };

            button.Clicked += OnStartTest;

            Content = new ListView {
                ItemsSource  = data,
                Header       = button,
                ItemTemplate = new DataTemplate(() => {
                    var cell = new TextCell();
                    cell.SetBinding(TextCell.TextProperty, "LockType");
                    cell.SetBinding(TextCell.DetailProperty, "Elapsed");
                    return(cell);
                })
            };
        }
Пример #34
0
        public ContactsPage()
        {
            InitializeComponent();
            wardPicker = new Picker {
                Title = "Choose Ward Number"
            };
            wardPicker.SelectedIndexChanged += WardPicker_SelectedIndexChanged;;

            wardList = DataService.getDataService().getAllWardNumbers();
            wardList.ForEach(x => { wardPicker.Items.Add("Ward Number" + x.ToString()); });

            listView = new ListView
            {
                ItemsSource   = new List <DisplayItem>(),
                HasUnevenRows = true,
                ItemTemplate  = new DataTemplate(() =>
                {
                    TextCell cell = new TextCell();
                    cell.SetBinding(TextCell.TextProperty, new Binding("Text"));
                    cell.SetBinding(TextCell.DetailProperty, new Binding("Detail"));
                    cell.TextColor = Color.Red;
                    cell.Height    = 50;
                    return(cell);
                }),
                SeparatorColor = Color.Black,
            };
            listView.SeparatorColor = Color.Blue;
            listView.ItemSelected  += ListView_ItemSelected;

            // Build the page.
            this.Content = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                Children    =
                {
                    wardPicker,
                    listView
                },
            };
        }
Пример #35
0
        public HomePageCS()
        {
            BindingContext = new HomePageViewModel();

            var listView = new ListView();

            listView.SetBinding(ItemsView <Cell> .ItemsSourceProperty, "People");
            listView.ItemTemplate = new DataTemplate(() =>
            {
                var textCell = new TextCell();
                textCell.SetBinding(TextCell.TextProperty, "Name");
                return(textCell);
            });
            listView.Behaviors.Add(new EventToCommandBehavior
            {
                EventName = "ItemSelected",
                Command   = ((HomePageViewModel)BindingContext).OutputAgeCommand,
                Converter = new SelectedItemEventArgsToSelectedItemConverter()
            });

            var selectedItemLabel = new Label();

            selectedItemLabel.SetBinding(Label.TextProperty, "SelectedItemText");

            Content = new StackLayout
            {
                Margin   = new Thickness(20),
                Children =
                {
                    new Label {
                        Text              = "Behaviors Demo",
                        FontAttributes    = FontAttributes.Bold,
                        HorizontalOptions = LayoutOptions.Center
                    },
                    listView,
                    selectedItemLabel
                }
            };
        }
Пример #36
0
        public ThirdPartyPage()
        {
            Title = AppResources.ThirdPartyTitle;

            var template = new DataTemplate(() =>
            {
                var text = new TextCell();
                text.SetBinding(TextCell.TextProperty, "ProjectName");
                return(text);
            });

            var libraryLicensesListView = new ListView(ListViewCachingStrategy.RecycleElement)
            {
                ItemTemplate  = template,
                HeightRequest = 40
            };

            libraryLicensesListView.SetBinding(ListView.ItemsSourceProperty, "LicensesList");
            libraryLicensesListView.SetBinding(ListView.SelectedItemProperty, "SelectedLicense");

            Content = libraryLicensesListView;
        }
Пример #37
0
        public ProgressPage()
        {
            ProgressViewModel viewModel;

            BindingContext = viewModel = new ProgressViewModel();
            ListView listView = new ListView
            {
                ItemTemplate = new DataTemplate(() =>
                {
                    var textCell = new TextCell {
                        TextColor = Color.Black
                    };
                    textCell.SetBinding(TextCell.TextProperty, "Title");
                    textCell.SetBinding(TextCell.DetailProperty, "Exercises");
                    return(textCell);
                })
            };

            listView.SetBinding(ListView.ItemsSourceProperty, "Workouts");
            listView.ItemSelected += async(s, e) =>
            {
                var item = e.SelectedItem as ProgressInfo;
                if (item != null)
                {
                    await Navigation.PushAsync(new DetailedProgressPage(item.ExerciseDetails, viewModel));

                    listView.SelectedItem = null;
                }
            };
            Title   = "Progress Overview";
            Padding = new Thickness(10, 0);
            Content = new StackLayout
            {
                Children =
                {
                    listView
                }
            };
        }
Пример #38
0
        protected virtual void HandlePropertyChanged(object sender, PropertyChangedEventArgs args)
        {
            CellTableViewCell cell      = (CellTableViewCell)sender;
            TextCell          entryCell = (TextCell)cell.Cell;

            if (args.PropertyName == TextCell.TextProperty.PropertyName)
            {
                cell.TextField.StringValue = ((TextCell)cell.Cell).Text;

                cell.TextField.SizeToFit();
            }

            /*
             * else if (args.PropertyName == TextCell.DetailProperty.PropertyName)
             * {
             *      cell.DetailTextLabel.Text = ((TextCell)cell.Cell).Detail;
             *      cell.DetailTextLabel.SizeToFit ();
             * }
             */
            else if (args.PropertyName == TextCell.TextColorProperty.PropertyName)
            {
                cell.TextField.TextColor = ColorExtensions.ToUIColor(entryCell.TextColor, TextCellRenderer.DefaultTextColor);
            }

            /*
             * else if (args.PropertyName == TextCell.DetailColorProperty.PropertyName)
             * {
             *      cell.DetailTextLabel.TextColor = ColorExtensions.ToUIColor (entryCell.DetailColor, TextCellRenderer.DefaultTextColor);
             * }
             */
            else
            {
                if (!(args.PropertyName == Cell.IsEnabledProperty.PropertyName))
                {
                    return;
                }
                TextCellRenderer.UpdateIsEnabled(cell, entryCell);
            }
        }
Пример #39
0
        public MainPage()
        {
            InitializeComponent();

            //Set binding context
            vm             = new MainPageViewModel(this);
            BindingContext = vm;

            // Hook up event handlers
            PlanetListView.SelectionMode = ListViewSelectionMode.Single;   //Default
            PlanetListView.ItemTapped   += PlanetListView_ItemTapped;      //User tapped
            PlanetListView.ItemSelected += PlanetListView_ItemSelected;    //Selection changed

            // *****************************************************************
            // DATA TEMPLATE
            // *****************************************************************

            //Data template will instantiate a cell "when required"

            //Two options: I like the second but the first is more common

            //DataTemplate DataTemplate = new DataTemplate(typeof(TextCell));
            DataTemplate dataTemplate = new DataTemplate(() =>
            {
                //Return a subclass of Cell
                TextCell cell = new TextCell();
                return(cell);
            });

            //Binding proxy: When the DataTemplate instantiates a cell, it will also set up the binding as specified below
            //The source will be a data elelement
            dataTemplate.SetBinding(TextCell.TextProperty, "Name");
            dataTemplate.SetBinding(TextCell.DetailProperty, "Distance");

            //Finally, set the ItemTemplate property (type DataTemplate)
            PlanetListView.ItemTemplate = dataTemplate;
            // *****************************************************************
        }
Пример #40
0
        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);
        }
Пример #41
0
        private void StackLayout_LayoutChanged(object sender, EventArgs e)
        {
            {
                try {
                    StackLayout slModify = sender as StackLayout;
                    children = slModify.Children;
                    foreach (View v in children)
                    {
                        if (children[0].GetType() == typeof(TableView) && tvSelectAirshow == null)
                        {
                            airshowNames    = database.AirshowNames;
                            tvSelectAirshow = children[0] as TableView;
                            tvSelectAirshow.Root.Clear();
                            Airshows = tvSelectAirshow.Root;
                            TableSection Airshow = new TableSection();

                            foreach (String name in airshowNames)
                            {
                                TextCell AirshowName = new TextCell();
                                AirshowName.Text      = name;
                                AirshowName.TextColor = Color.Black;
                                Airshow.Add(AirshowName);
                                AirshowName.Tapped += AirshowClicked;
                            }
                            Airshows.Add(Airshow);
                            tvSelectAirshow.Root = Airshows;
                        }
                        if (children[1].GetType() == typeof(TableView))
                        {
                        }
                    }
                    Airshows.Clear();
                }
                catch (Exception E)
                {
                }
            }
        }
Пример #42
0
		public void IndexOf ()
		{
			var section = new TableSection ();
			TextCell first, second;
			section.Add (first = new TextCell { Text = "Text" });
			section.Add (second = new TextCell { Text = "Text" });

			Assert.AreEqual (0, section.IndexOf (first));
			Assert.AreEqual (1, section.IndexOf (second));
		}
Пример #43
0
		public void TestCommandCanExecuteDisables()
		{
			var cmd = new Command (() => { }, () => false);
			var cell = new TextCell { Command = cmd };
			Assert.IsFalse (cell.IsEnabled, "Cell was not disabled");
		}
Пример #44
0
		public void TestCommandCanExecuteChanged()
		{
			bool first = true;
			var cmd = new Command (() => { }, () => {
				if (first) {
					first = false;
					return false;
				} else {
					return true;
				}
			});
			
			var cell = new TextCell { Command = cmd };
			Assert.IsFalse (cell.IsEnabled, "Cell was not disabled");

			cmd.ChangeCanExecute();

			Assert.IsTrue (cell.IsEnabled, "Cell was not reenabled");
		}
Пример #45
0
		public void Insert ()
		{
			var section = new TableSection ();
			section.Add (new TextCell { Text = "Text" });
			section.Add (new TextCell { Text = "Text" });

			var third = new TextCell { Text = "Text" };
			section.Insert (1, third);
			Assert.AreEqual (third, section[1]);
		}
Пример #46
0
		public void HasContextActions()
		{
			bool changed = false;

			var cell = new TextCell();
			cell.PropertyChanged += (sender, args) => {
				if (args.PropertyName == "HasContextActions")
					changed = true;
			};

			Assert.That (cell.HasContextActions, Is.False);
			Assert.That (changed, Is.False);

			var collection = cell.ContextActions;

			Assert.That (cell.HasContextActions, Is.False);
			Assert.That (changed, Is.False);

			collection.Add (new MenuItem());

			Assert.That (cell.HasContextActions, Is.True);
			Assert.That (changed, Is.True);
		}
Пример #47
0
        private void HandlePrintableKey(KeyEventArgs e)
        {
            DebugHelper.Trace();

            bool isControlKey;
            var key = KeyHelper.GetCharFromKey(e.Key, out isControlKey).ToString();

            if (isControlKey)
            {
                return;
            }

            var isNewLine = false;
            var row = _document[_currentRow];
            TextCell cell;

            if (_currentColumn != row.Count)
            {
                cell = row[_currentColumn];
            }
            else if (_currentColumn == 0 && _document.Count == 1)
            {
                cell = new TextCell() { Index = 0 };
            }
            else if (_currentColumn != 0)
            {
                cell = new TextCell() { Index = row[_currentColumn - 1].Index + 1 };
            }
            else
            {
                row = _document[_currentRow - 1];
                cell = new TextCell() { Index = row.Last().Index + 1 };
            }

            switch (key)
            {
                case "\r":
                case "\n":
                case "\r\n":
                    if (!AcceptsReturn)
                    {
                        return;
                    }

                    key = "\n";
                    isNewLine = true;
                    break;

                case "\t":
                    key = "    ";
                    _currentColumn += 3;
                    break;
            }

            _text = _text != null ? _text.Insert(cell.Index, key) : key;

            if (!isNewLine)
            {
                _currentColumn++;
            }
            else
            {
                _currentColumn = 0;
                _currentRow++;
            }

            MoveCaretToCurrentCell();
            UpdateDocument();
            e.Handled = true;
        }
Пример #48
0
		public void MenuItemsGetBindingContext()
		{
			var cell = new TextCell {
				ContextActions = {
					new MenuItem ()
				}
			};

			object bc = new object ();

			cell.BindingContext = bc;
			Assert.That (cell.ContextActions [0].BindingContext, Is.SameAs (bc));

			cell = new TextCell { BindingContext = new object () };
			cell.ContextActions.Add (new MenuItem ());

			Assert.That (cell.ContextActions [0].BindingContext, Is.SameAs (cell.BindingContext));
		}
Пример #49
0
		public void RenderHeightINPCFromParent()
		{
			var lv = new ListView();
			var cell = new TextCell();
			cell.Parent = lv;

			int changing = 0, changed = 0;
			cell.PropertyChanging += (sender, args) => {
				if (args.PropertyName == "RenderHeight")
					changing++;
			};

			cell.PropertyChanged += (sender, args) => {
				if (args.PropertyName == "RenderHeight")
					changed++;
			};

			lv.RowHeight = 5;

			Assume.That (cell.RenderHeight, Is.EqualTo (5));

			Assert.That (changing, Is.EqualTo (1));
			Assert.That (changed, Is.EqualTo (1));
		}
Пример #50
0
		static void UpdateIsEnabled(CellTableViewCell cell, TextCell entryCell)
		{
			cell.UserInteractionEnabled = entryCell.IsEnabled;
			cell.TextLabel.Enabled = entryCell.IsEnabled;
			cell.DetailTextLabel.Enabled = entryCell.IsEnabled;
		}
Пример #51
0
		public void CopyTo ()
		{
			var section = new TableSection ();
			TextCell first, second;
			section.Add (first = new TextCell { Text = "Text" });
			section.Add (second = new TextCell { Text = "Text" });

			Cell[] cells = new Cell[2];
			section.CopyTo (cells, 0);

			Assert.AreEqual (first, cells[0]);
			Assert.AreEqual (second, cells[1]);
		}
Пример #52
0
		public void ChainsBindingContextToNewlyAdded ()
		{
			var section = new TableSection ();
			var bindingContext = "bindingContext";
			section.BindingContext = bindingContext;

			TextCell first, second;
			section.Add (first = new TextCell { Text = "Text" });
			section.Add (second = new TextCell { Text = "Text" });

			Assert.AreEqual (bindingContext, first.BindingContext);
			Assert.AreEqual (bindingContext, second.BindingContext);
		}
Пример #53
0
		public void Overwrite ()
		{
			var section = new TableSection ();
			TextCell second;
			section.Add (new TextCell { Text = "Text" });
			section.Add (second = new TextCell { Text = "Text" });

			var third = new TextCell { Text = "Text" };
			section[1] = third;

			Assert.AreEqual (third, section[1]);
			Assert.That (section, Has.No.Contains (second));
		}
Пример #54
0
		public void RemoveAt ()
		{
			var section = new TableSection ();
			TextCell first, second;
			section.Add (first = new TextCell { Text = "Text" });
			section.Add (second = new TextCell { Text = "Text" });

			section.RemoveAt (0);
			Assert.That (section, Has.No.Contains (first));
		}
Пример #55
0
		Cell GetCellForPosition(int position, out bool isHeader, out bool nextIsHeader)
		{
			isHeader = false;
			nextIsHeader = false;

			int sectionCount = _view.Model.GetSectionCount();

			for (var sectionIndex = 0; sectionIndex < sectionCount; sectionIndex ++)
			{
				int size = _view.Model.GetRowCount(sectionIndex) + 1;

				if (position == 0)
				{
					isHeader = true;
					nextIsHeader = size == 0 && sectionIndex < sectionCount - 1;

					Cell header = _view.Model.GetHeaderCell(sectionIndex);

					Cell resultCell = null;
					if (header != null)
						resultCell = header;

					if (resultCell == null)
						resultCell = new TextCell { Text = _view.Model.GetSectionTitle(sectionIndex) };

					resultCell.Parent = _view;

					return resultCell;
				}

				if (position < size)
				{
					nextIsHeader = position == size - 1;
					return (Cell)_view.Model.GetItem(sectionIndex, position - 1);
				}

				position -= size;
			}

			return null;
		}
Пример #56
0
		private TextCell(TextCell cell) { this.value = cell.value; }