Esempio n. 1
0
        Control GridView()
        {
            var control = new GridView {
                Size = new Size(-1, 150)
            };

            control.Columns.Add(new GridColumn {
                DataCell = new ImageViewCell(0), HeaderText = "Image"
            });
            control.Columns.Add(new GridColumn {
                DataCell = new CheckBoxCell(1), HeaderText = "Check", Editable = true
            });
            control.Columns.Add(new GridColumn {
                DataCell = new TextBoxCell(2), HeaderText = "Text", Editable = true
            });
            control.Columns.Add(new GridColumn {
                DataCell = new ComboBoxCell(3)
                {
                    DataStore = ComboCellItems()
                }, HeaderText = "Combo", Editable = true
            });

            var items = new GridItemCollection();

            items.Add(new GridItem(bitmap1, true, "Text in Grid 1", "1"));
            items.Add(new GridItem(icon1, false, "Text in Grid 2", "2"));
            items.Add(new GridItem(bitmap1, null, "Text in Grid 3", "3"));

            control.DataStore = items;

            return(control);
        }
Esempio n. 2
0
        GridView Default()
        {
            var control = new GridView {
                Size = new Size (300, 100)
            };
            LogEvents (control);

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

            var image1 = Bitmap.FromResource ("Eto.Test.TestImage.png");
            var image2 = Icon.FromResource ("Eto.Test.TestIcon.ico");
            var items = new GridItemCollection ();
            var rand = new Random ();
            for (int i = 0; i < 10000; i++) {
                var val = rand.Next (3);
                var boolVal = val == 0 ? (bool?)false : val == 1 ? (bool?)true : null;

                val = rand.Next (3);
                var image = val == 0 ? (Image)image1 : val == 1 ? (Image)image2 : null;

                var txt = string.Format ("Col 1 Row {0}", i);

                val = rand.Next (dropDown.DataStore.Count + 1);
                var combo = val == 0 ? null : dropDown.DataStore [val - 1].Key;

                items.Add (new LogGridItem (boolVal, image, txt, combo){ Row = i });
            }
            control.DataStore = items;

            return control;
        }
Esempio n. 3
0
        GridView Default()
        {
            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
            });

            var items = new GridItemCollection();
            var rand  = new Random();

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

            return(control);
        }
Esempio n. 4
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 GridItemCollection();
                var rand  = new Random();
                for (int i = 0; i < 10000; i++)
                {
                    items.Add(new MyGridItem(rand, i, dropDown));
                }
                control.DataStore = items;
            }

            return(control);
        }
Esempio n. 5
0
        // private static void PrintDebugInfo (GridEntry item)
        // {
        //  if (item.PropertyDescriptor != null) {
        //      Console.WriteLine ("=== [" + item.PropertyDescriptor.Name + "] ===");
        //      try {
        //          TypeConverter converter = item.GetConverter ();
        //          Console.WriteLine ("IsReadOnly: " + item.IsReadOnly);
        //          Console.WriteLine ("IsEditable: " + item.IsEditable);
        //          Console.WriteLine ("PropertyDescriptor.IsReadOnly: " + item.PropertyDescriptor.IsReadOnly);
        //          if (item.ParentEntry != null)
        //              Console.WriteLine ("ParentEntry.IsReadOnly: " + item.ParentEntry.IsReadOnly);
        //          Console.WriteLine ("ImmutableObjectAttribute.Yes: " + TypeDescriptor.GetAttributes (item.PropertyDescriptor.PropertyType)
        //                     [typeof(ImmutableObjectAttribute)].Equals (ImmutableObjectAttribute.Yes));
        //          UITypeEditor editor = item.GetEditor ();
        //          Console.WriteLine ("Editor: " + (editor == null ? "none" : editor.GetType ().Name));
        //          if (editor != null)
        //              Console.WriteLine ("Editor.EditorStyle: " + editor.GetEditStyle ((ITypeDescriptorContext)item));
        //          Console.WriteLine ("Converter: " + (converter == null ? "none" : converter.GetType ().Name));
        //          if (converter != null) {
        //              Console.WriteLine ("Converter.GetStandardValuesSupported: " + converter.GetStandardValuesSupported ((ITypeDescriptorContext)item).ToString ());
        //              Console.WriteLine ("Converter.GetStandardValuesExclusive: " + converter.GetStandardValuesExclusive ((ITypeDescriptorContext)item).ToString ());
        //              Console.WriteLine ("ShouldCreateParentInstance: " + item.ShouldCreateParentInstance);
        //              Console.WriteLine ("CanConvertFrom (string): " + converter.CanConvertFrom ((ITypeDescriptorContext)item, typeof (string)));
        //          }
        //          Console.WriteLine ("IsArray: " + item.PropertyDescriptor.PropertyType.IsArray.ToString ());
        //      } catch { /* Some converters and editor throw NotImplementedExceptions */ }
        //  }
        // }

        private GridItemCollection GetChildGridItems()
        {
            object[]           propertyOwners = this.Values;
            string[]           propertyNames  = GetMergedPropertyNames(propertyOwners);
            GridItemCollection items          = new GridItemCollection();

            foreach (string propertyName in propertyNames)
            {
                PropertyDescriptor[] properties = new PropertyDescriptor[propertyOwners.Length];
                for (int i = 0; i < propertyOwners.Length; i++)
                {
                    properties[i] = GetPropertyDescriptor(propertyOwners[i], propertyName);
                }
                items.Add(new GridEntry(property_grid, properties, this));
            }

            return(items);
        }
Esempio n. 6
0
		GridView Default ()
		{
			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 });
			
			var items = new GridItemCollection ();
			var rand = new Random ();
			for (int i = 0; i < 10000; i++) {
				items.Add (new MyGridItem (rand, i, dropDown));
			}
			control.DataStore = items;

			return control;
		}
Esempio n. 7
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 GridItemCollection();
				var rand = new Random();
				for (int i = 0; i < 10000; i++)
				{
					items.Add(new MyGridItem(rand, i, dropDown));
				}
				control.DataStore = items;
			}

			return control;
		}