Exemple #1
0
		public GridViewSection()
		{
			var layout = new DynamicLayout();

			layout.AddRow(new Label { Text = "Default" }, Default());
			layout.AddRow(new Label { Text = "No Header,\nNon-Editable" }, NoHeader());
#if DESKTOP
			layout.BeginHorizontal();
			layout.Add(new Label { Text = "Context Menu\n&& Multi-Select\n&& Filter" });
			layout.BeginVertical();
			layout.Add(filterText = new SearchBox { PlaceholderText = "Filter" });
			var withContextMenuAndFilter = WithContextMenuAndFilter();
			layout.Add(withContextMenuAndFilter);
			layout.EndVertical();
			layout.EndHorizontal();

			var selectionGridView = Default(addItems: false);
			layout.AddRow(new Label { Text = "Selected Items" }, selectionGridView);

			// hook up selection of main grid to the selection grid
			withContextMenuAndFilter.SelectionChanged += (s, e) =>
			{
				var items = new DataStoreCollection();
				items.AddRange(withContextMenuAndFilter.SelectedItems);
				selectionGridView.DataStore = items;
			};
#endif

			Content = layout;
		}
		SearchBox CreateSearchBox(SelectableFilterCollection<MyGridItem> filtered)
		{
			var filterText = new SearchBox { PlaceholderText = "Filter" };
			filterText.TextChanged += (s, e) =>
			{
				var filterItems = (filterText.Text ?? "").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

				if (filterItems.Length == 0)
					filtered.Filter = null;
				else
					filtered.Filter = i =>
				{
					// Every item in the split filter string should be within the Text property
					foreach (var filterItem in filterItems)
					{
						if (i.Text.IndexOf(filterItem, StringComparison.OrdinalIgnoreCase) == -1)
						{
							return false;
						}
					}
					return true;
				};
			};
			return filterText;
		}
Exemple #3
0
		public UnitTestSection()
		{
			startButton = new Button { Text = "Start Tests", Size = new Size(200, 80) };
			useTestPlatform = new CheckBox { Text = "Use Test Platform" };
			var buttons = new StackLayout
			{
				Padding = new Padding(10),
				Spacing = 5,
				HorizontalContentAlignment = HorizontalAlignment.Center,
				Items = { startButton, useTestPlatform }
			};

			if (Platform.Supports<TreeView>())
			{

				search = new SearchBox();
				search.Focus();
				search.KeyDown += (sender, e) =>
				{
					if (e.KeyData == Keys.Enter)
					{	
						startButton.PerformClick();
						e.Handled = true;
					}
				};

				var timer = new UITimer();
				timer.Interval = 0.5;
				timer.Elapsed += (sender, e) =>
				{
					timer.Stop();
					PopulateTree(search.Text);
				};
				search.TextChanged += (sender, e) => {
					if (timer.Started)
						timer.Stop();
					timer.Start();
				};

				tree = new TreeView();

				tree.Activated += (sender, e) =>
				{
					var item = (TreeItem)tree.SelectedItem;
					if (item != null)
					{
						RunTests(item.Tag as CategoryFilter);
					}
				};

				Content = new StackLayout
				{
					Spacing = 5,
					HorizontalContentAlignment = HorizontalAlignment.Stretch,
					Items = { buttons, search, new StackLayoutItem(tree, expand: true) }
				};
			}
			else
				Content = buttons;

			startButton.Click += (s, e) => RunTests();
		}
Exemple #4
0
            public FindObjectPanel()
            {
                _layout = new DynamicLayout();
                _search = new SearchBox();
                _search.PlaceholderText = Constants.ObjectNameSearchPlaceholder;
                _search.TextChanged += _searchChanged;
                _grid = new GridView();

                // helps drastically with layout performance,
                // specifically on WPF
                _grid.RowHeight = 19;

                _grid.AllowMultipleSelection = false;

                _grid.Columns.Add(new GridColumn()
                {
                    HeaderText = "Device",
                    Editable = false,
                    Width = 100,
                    DataCell = new TextBoxCell()
                    {
                        Binding = new LambdaBinding<ObjectInfo, string>(oi => oi.DeviceInstance.ToString())
                    }
                });

                _grid.Columns.Add(new GridColumn()
                {
                    HeaderText = Constants.ObjectTypeHeaderText,
                    Editable = false,
                    Width = 100,
                    DataCell = new TextBoxCell()
                    {
                        Binding = new LambdaBinding<ObjectInfo, string>(
                            oi => ((ObjectType)oi.ObjectIdentifier.Type).ToString())
                    }
                });

                _grid.Columns.Add(new GridColumn()
                {
                    HeaderText = Constants.ObjectInstanceHeaderText,
                    Editable = false,
                    Width = 75,
                    DataCell = new TextBoxCell()
                    {
                        Binding = new LambdaBinding<ObjectInfo, string>(
                            oi => oi.ObjectIdentifier.Instance.ToString())
                    }
                });

                _grid.Columns.Add(new GridColumn()
                {
                    HeaderText = Constants.ObjectNameHeaderText,
                    Editable = false,
                    DataCell = new TextBoxCell()
                    {
                        Binding = new LambdaBinding<ObjectInfo, string>(
                            oi => oi.Name)
                    }
                });

                _grid.SelectedItemsChanged += delegate (object s, EventArgs e)
                {
                    var item = _grid.SelectedItem as ObjectInfo;
                    if (item != null)
                    {
                        var stack = MainForm.Current.Stack;
                        stack.PopUntil<FindObjectPanel>();
                        stack.Push(new ObjectPanel(item));
                    }
                };

                _layout.BeginVertical();
                _layout.AddRow(_search);
                _layout.AddRow(_grid);
                _layout.EndVertical();

                this.Content = _layout;
            }
Exemple #5
0
		public PropertyCellSection()
		{
			var infoColumn = new GridColumn
			{
				HeaderText = "Name",
				Editable = false,
				DataCell = new TextBoxCell { Binding = Binding.Property((MyModel m) => m.Name) }
			};
			var valueProperty = Binding.Property((MyModel m) => m.Value);

			var propertyCell = new PropertyCell
			{ 
				TypeBinding = Binding.Property((MyModel m) => (object)m.Type),
				Types =
				{
					new PropertyCellTypeBoolean { ItemBinding = valueProperty.OfType<bool?>() },
					new PropertyCellTypeString { ItemBinding = valueProperty.OfType<string>() },
					new PropertyCellTypeColor { ItemBinding = valueProperty.OfType<Color>() },
					new PropertyCellTypeDateTime { ItemBinding = valueProperty.OfType<DateTime?>() },
					new PropertyCellTypeEnum<Orientation> { ItemBinding = valueProperty.OfType<Orientation>() }
				}
			};

			var filtered = new FilterCollection<MyModel>(new []
			{
				new MyModel { Name = "Bool Property (checked)", Type = typeof(bool?), Value = true },
				new MyModel { Name = "Bool Property", Type = typeof(bool), Value = false },
				new MyModel { Name = "String Property", Type = typeof(string), Value = "hello" },
				new MyModel { Name = "Color Property", Type = typeof(Color), Value = Colors.Blue },
				new MyModel { Name = "DateTime Property", Type = typeof(DateTime), Value = DateTime.Today },
				new MyModel { Name = "Enum Property", Type = typeof(Orientation), Value = Orientation.Vertical }
			});

			var valueColumn = new GridColumn
			{
				AutoSize = true,
				Editable = true,
				HeaderText = "Value",
				DataCell = propertyCell,
			};

			var grid = new GridView
			{
				Columns = { infoColumn, valueColumn }
			};


			grid.DataStore = filtered;


			var searchBox = new SearchBox();
			searchBox.TextChanged += (sender, e) => filtered.Filter = m => m.Name.IndexOf(searchBox.Text, StringComparison.OrdinalIgnoreCase) >= 0;

			Content = new StackLayout
			{
				HorizontalContentAlignment = HorizontalAlignment.Stretch,
				Spacing = 5,
				Padding = 10,
				Items =
				{
					searchBox,
					new StackLayoutItem(grid, expand: true)
				}
			};
		}