Ejemplo n.º 1
0
		GridView CreateGrid()
		{
			var control = new GridView
			{
				Size = new Size(300, 100)
			};
			LogEvents(control);

			var dropDown = MyDropDown("DropDownKey");
			control.Columns.Add(new GridColumn { DataCell = new CheckBoxCell("Check"), AutoSize = true, Resizable = false });
			control.Columns.Add(new GridColumn { HeaderText = "Image", DataCell = new ImageViewCell("Image") });
			control.Columns.Add(new GridColumn { HeaderText = "ImageText", DataCell = new ImageTextCell("Image", "Text") });
			control.Columns.Add(new GridColumn { HeaderText = "Text", DataCell = new TextBoxCell("Text"), Sortable = true });
			control.Columns.Add(new GridColumn { HeaderText = "Progress", DataCell = new ProgressCell("Progress") });
			control.Columns.Add(new GridColumn { HeaderText = "Drop Down", DataCell = dropDown, Sortable = true });

			if (Platform.Supports<DrawableCell>())
			{
				var drawableCell = new DrawableCell();
				drawableCell.Paint += (sender, e) =>
				{
					var m = e.Item as MyGridItem;
					if (m != null)
					{
						if (e.CellState.HasFlag(DrawableCellStates.Selected))
							e.Graphics.FillRectangle(Colors.Blue, e.ClipRectangle);
						else
							e.Graphics.FillRectangle(Brushes.Cached(m.Color), e.ClipRectangle);
						var rect = e.ClipRectangle;
						rect.Inflate(-5, -5);
						e.Graphics.DrawRectangle(Colors.White, rect);
						e.Graphics.DrawLine(Colors.White, rect.Left, rect.Bottom, rect.MiddleX, rect.Top);
						e.Graphics.DrawLine(Colors.White, rect.Right, rect.Bottom, rect.MiddleX, rect.Top);
					}
				};
				control.Columns.Add(new GridColumn
				{
					HeaderText = "Owner drawn",
					DataCell = drawableCell
				});
			}

			return control;
		}
Ejemplo n.º 2
0
 /// <summary>
 /// Raises the paint event.
 /// </summary>
 public void OnPaint(DrawableCell widget, DrawableCellPaintEventArgs e)
 {
     widget.Platform.Invoke(() => widget.OnPaint(e));
 }
Ejemplo n.º 3
0
		GridView Default(bool addItems = true)
		{
			var control = new GridView
			{
				Size = new Size(300, 100)
			};
			LogEvents(control);

			var dropDown = MyDropDown("DropDownKey");
			control.Columns.Add(new GridColumn { DataCell = new CheckBoxCell("Check"), Editable = true, AutoSize = true, Resizable = false });
			control.Columns.Add(new GridColumn { HeaderText = "Image", DataCell = new ImageViewCell("Image") });
			control.Columns.Add(new GridColumn { HeaderText = "Text", DataCell = new TextBoxCell("Text"), Editable = true, Sortable = true });
			control.Columns.Add(new GridColumn { HeaderText = "Drop Down", DataCell = dropDown, Editable = true, Sortable = true });

#if Windows // Drawable cells - need to implement on other platforms.
			var drawableCell = new DrawableCell
			{
				PaintHandler = args => {
					var m = args.Item as MyGridItem;
					if (m != null)
						args.Graphics.FillRectangle(Brushes.Cached(m.Color) as SolidBrush, args.CellBounds);
				}
			};
			control.Columns.Add(new GridColumn { HeaderText = "Owner drawn", DataCell = drawableCell });
#endif

			if (addItems)
			{
				var items = new DataStoreCollection();
				var rand = new Random();
				for (int i = 0; i < 10000; i++)
				{
					items.Add(new MyGridItem(rand, i, dropDown));
				}
				control.DataStore = items;
			}

			return control;
		}
Ejemplo n.º 4
0
 /// <summary>
 /// Raises the paint event.
 /// </summary>
 public void OnPaint(DrawableCell widget, DrawableCellPaintEventArgs e)
 {
     using (widget.Platform.Context)
         widget.OnPaint(e);
 }
Ejemplo n.º 5
0
			/// <summary>
			/// Raises the paint event.
			/// </summary>
			public void OnPaint(DrawableCell widget, DrawableCellPaintEventArgs e)
			{
				widget.Platform.Invoke(() => widget.OnPaint(e));
			}