Initial testing - issues, questions

Jun 26, 2009 at 9:13 PM
Edited Jun 26, 2009 at 10:52 PM

Hi

First of all appreciations for extending original Superlist. Using the Test harness provided with the source:

1. Tried to populate the list with 2500K items ( 3 columns each), even after waiting 5 minutes the population never finished. Using the original Superlist with Person class (6 columns), it took about 4 seconds to populate the list. Modified Test harness snippet below. Please let me know if I am doing something wrong here or certain option/property need to be set to speed up the population.

                    for (int i = 0; i < 100000; i++)
                    {

                        //25 items in array
                        c.Items.AddRange(
                            new string[][]{
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" }
                            }
                           
                            );

 

2. Is it possible to have .NET 3.0 compatible version. I see .NET 3.5 was used for printing related extension methods and LINQ. I commented those parts of the code (of course losing print functionality) and  the superlistEx worked fine. Any ideas how to add print functionality without using .NET 3.5/LINQ.

3. Regarding the new functionality, can you please provide a snippet on how to change color of a specific row using new delegates.

 

Also, if you could enhance Test program on how to use new properties/methods. That would be great.

Thanks again for your efforts!

Regards

Rudra

 

 

Coordinator
Jun 27, 2009 at 5:24 AM

1) The best way to handle this is to add all the items to the list at once.

 

//if you want to add large number of items, add them all at once
            List<string[]> toadd = new List<string[]>();

            for (int i = 0; i < 100000; i++)
            {
                //25 items in array
                toadd.AddRange(
                    new string[][]{
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" },
                            new string[] { "Name1", "LName1", "1" }
                            }
                    );
            }
            c.Items.AddRange(toadd);


This only took about 30 seconds for me

2) You would have to redo certain parts of the print routine
  1. Re implement extension methods as regular static methods or move into list control (TableExtensions.cs)
  2. Remove linq query at line 351 and replace with equivalent maybe something like (PrintTable.cs)
    List<PrintColumn> currPage2 = new List<PrintColumn>();
          foreach (int i in PageColumns.Values)
              if (i == _printSettings.currentPartialPage)
                    currPage2.Add(PageColumns.Keys.ElementAt(i)); 
  3. modify iteration at line 356 to iterate through that collection (PrintTable.cs)
  4. Change all item initializes to older method for example at line 491 and 502 (PrintTable.cs)
3) The new delegate are used as follows
public void Foo()
{
	SuperListEx.ListControl c = new SuperListEx.ListControl();
	
	//add columns
	Column col = new Column("First Name", "First Name", 150, delegate(object item)
	{
		return ((string[])item)[0];
	});

	Column col2 = new Column("Last Name", "Last Name", 150, delegate(object item)
		{
			return ((string[])item)[1];
		});

	Column col3 = new Column("Position", "Position", 150, delegate(object item)
		{
			return ((string[])item)[2];
		});
				
				
	c.Columns.Add(col);
	c.Columns.Add(col2);
	c.Columns.Add(col3);
	
	//add items
	c.Items.Add(new string[] { "Name1", "LName1", "1" });
	c.Items.Add(new string[] { "Name2", "LName1", "2" });
	c.Items.Add(new string[] { "Name3", "LName2", "1" });
	c.Items.Add(new string[] { "Name4", "LName3", "1" });
	c.Items.Add(new string[] { "Name5", "LName4", "3" });
	c.Items.Add(new string[] { "Name6", "LName5", "4" });
			
	//new delegates examples
	c.CustomBackgroundColorAccessor = GetBColor;
	c.CustomForegroundColorAccessor = GetFColor;
	c.CustomFontAccessor = GetFont;
}

public Color GetBColor(object o)
{//logic here to decide bgcolor based on row data
	string[] data = (string[])o;
	if (data[2] == "1")
		return Color.Pink;
	else
		return Color.Red;
}

public Color GetFColor(object o)
{//logic here to decide fgcolor based on row data
	string[] data = (string[])o;
	if (data[2] == "1")
		return Color.Blue;
	else
		return Color.Black;
}

public Font GetFont(object o)
{//logic here to decide font based on row data
	string[] data = (string[])o;
	if (data[2] == "1")
		return SystemFonts.MessageBoxFont;
	else
		return SystemFonts.StatusFont;
}

Hope that helps
-Daniel