Exemple #1
0
        public void TestFixtureSetup()
        {
            Gtk.Application.Init();

            List <TestPerson> list = new List <TestPerson>();

            for (int i = 0; i < 12; ++i)
            {
                list.Add(TestPerson.GetRandomPerson());
            }
            treeview = new TreeViewAdaptorIList(list);
            treeview.AppendColumn("Name", new Gtk.CellRendererText());
            treeview.ColumnTypes.Add(GLib.GType.String);
            treeview.AppendColumn("Number", new Gtk.CellRendererText());
            treeview.ColumnTypes.Add(GLib.GType.Int);
            treeview.AppendColumn("Gender", new Gtk.CellRendererText());
            treeview.ColumnTypes.Add(GLib.GType.String);

            treeview.GetValueStrategy = delegate(object o, int column)
            {
                TestPerson p = (TestPerson)o;
                switch (column)
                {
                case 0:
                    return(p.Name);

                case 1:
                    return(p.Number);

                case 2:
                    if (p.Gender == TestPerson.GenderType.Male)
                    {
                        return("Male");
                    }
                    return("Female");

                default:
                    Assert.Fail("Invalid column number passed to GetValueStrategy");
                    break;
                }
                return(o);
            };
            treeview.Activate();
        }
Exemple #2
0
		public void TestFixtureSetup()
		{
			Gtk.Application.Init();

			List<TestPerson> list = new List<TestPerson>();
			for (int i = 0; i < 12; ++i)
			{
				list.Add(TestPerson.GetRandomPerson());
			}
			treeview = new TreeViewAdaptorIList(list);
			treeview.AppendColumn("Name", new Gtk.CellRendererText());
			treeview.ColumnTypes.Add(GLib.GType.String);
			treeview.AppendColumn("Number", new Gtk.CellRendererText());
			treeview.ColumnTypes.Add(GLib.GType.Int);
			treeview.AppendColumn("Gender", new Gtk.CellRendererText());
			treeview.ColumnTypes.Add(GLib.GType.String);

			treeview.GetValueStrategy = delegate(object o, int column)
				{
					TestPerson p = (TestPerson)o;
					switch (column)
					{
						case 0:
							return p.Name;
						case 1:
							return p.Number;
						case 2:
							if (p.Gender == TestPerson.GenderType.Male)
							{
								return "Male";
							}
							return "Female";
						default:
							Assert.Fail("Invalid column number passed to GetValueStrategy");
							break;
					}
					return o;
				};
			treeview.Activate();
		}