Partly working

This commit is contained in:
unknown
2011-01-10 05:06:24 +05:30
parent e32e9f9e74
commit 853fad0692
26 changed files with 706 additions and 841 deletions

View File

@ -10,39 +10,122 @@ namespace Tanshu.Accounts.Helpers
{
public static class ControlFactory
{
public static void GenerateButtons(ref Panel panel, Rectangle clientArea, int x, int y, int border, List<ProductDisplaySmallBO> list, ButtonClickDelegate bcDelegate)
public static void GenerateButtons(ref Panel panel, ref List<Button> buttonList, Rectangle clientArea, int x, int y, int border, List<ProductDisplaySmallBO> list, ButtonClickDelegate bcDelegate)
{
if (buttonList.Count != 0)
{
for (int i = buttonList.Count - 1; i >= 0; i--)
{
buttonList[i].Dispose();
}
buttonList = new List<Button>();
}
int width = (clientArea.Width - (border * (x - 1))) / x;
int height = (clientArea.Height - (border * (y - 1))) / y;
int left = 0, top = 0, count = 0;
for (int i = 0; i < x; i++)
for (int j = 0; j < y; j++)
{
left = clientArea.Left + (i * (width + border));
for (int j = 0; j < y; j++)
top = clientArea.Top + (j * (height + border));
for (int i = 0; i < x; i++)
{
count++;
if (list.Count < count)
break;
top = clientArea.Top + (j * (height + border));
ProductDisplaySmallBO item = list[(i * x) + j];
left = clientArea.Left + (i * (width + border));
ProductDisplaySmallBO item = list[(j * x) + i];
Button btn = GetButton(string.Format("{0}-{1}", i, j), item.Name, width, height, left, top, item.ProductID, bcDelegate);
panel.Controls.Add(btn);
buttonList.Add(btn);
}
}
}
public static void GenerateButtons(ref Panel panel, Rectangle clientArea, int x, int y, int border, ButtonClickDelegate bcDelegate)
public static void GenerateButtons(ref Panel panel, ref List<Button> buttonList, Rectangle clientArea, int x, int y, int border, int page, List<ProductTypeBO> list, ButtonClickDelegate bcDelegate)
{
if (buttonList.Count != 0)
{
for (int i = buttonList.Count - 1; i >= 0; i--)
{
buttonList[i].Dispose();
}
buttonList = new List<Button>();
}
int width = (clientArea.Width - (border * (x - 1))) / x;
int height = (clientArea.Height - (border * (y - 1))) / y;
for (int i = 0; i < x; i++)
int left = 0, top = 0, count = 0;
if (list.Count > x * y)
{
int left = clientArea.Left + (i * (width + border));
for (int j = 0; j < y; j++)
if (page != 0)
list.RemoveRange(0, y * page);
if (list.Count > y)
list.RemoveRange(y, list.Count - y);
//int pages = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(list.Count / (x * y)))) - 1;
//if (page > 0)
// startButton = true;
//if (page != pages)
// finishButton = true;
//if (startButton)
//{
// list.RemoveRange(0, start);
// list.Insert(0, new ProductTypeBO() { Name = "Previous", ProductTypeID = new Guid() });
//}
//if (finishButton)
//{
// list.RemoveRange((x * y) - 1, list.Count - (x * y) + 1);
// list.Insert(x * y - 1, new ProductTypeBO() { Name = "Next", ProductTypeID = new Guid() });
//}
// the list is long
}
int sJ = 0;
int sI = 0;
//Math.DivRem(start, x, out sI);
//sJ = (start - sI) / y;
//count = start - 1;
for (int j = sJ; j < y; j++)
{
top = clientArea.Top + (j * (height + border));
for (int i = sI; i < x; i++)
{
int top = clientArea.Top + (j * (height + border));
Button btn = GetButton(string.Format("{0}-{1}", i, j), string.Format("{0}-{1}", i, j), width, height, left, top, string.Format("{0}-{1} Clicked", i, j), bcDelegate);
count++;
if (list.Count < count)
break;
left = clientArea.Left + (i * (width + border));
//ProductTypeBO item = list[(j * x) + i];
ProductTypeBO item = list[count - 1];
Button btn = GetButton(string.Format("{0}-{1}", i, j), item.Name, width, height, left, top, item.ProductTypeID, bcDelegate);
panel.Controls.Add(btn);
buttonList.Add(btn);
}
}
}
public static void GenerateButtons(ref Panel panel, ref List<Button> buttonList, Rectangle clientArea, int x, int y, int border, List<FoodTableBO> list, ButtonClickDelegate bcDelegate)
{
if (buttonList.Count != 0)
{
for (int i = buttonList.Count - 1; i >= 0; i--)
{
buttonList[i].Dispose();
}
buttonList = new List<Button>();
}
int width = (clientArea.Width - (border * (x - 1))) / x;
int height = (clientArea.Height - (border * (y - 1))) / y;
int left = 0, top = 0, count = 0;
for (int j = 0; j < y; j++)
{
top = clientArea.Top + (j * (height + border));
for (int i = 0; i < x; i++)
{
count++;
if (list.Count < count)
break;
left = clientArea.Left + (i * (width + border));
//ProductTypeBO item = list[(j * x) + i];
FoodTableBO item = list[count - 1];
Button btn = GetButton(string.Format("{0}-{1}", i, j), item.Name, width, height, left, top, item.TableID, bcDelegate);
panel.Controls.Add(btn);
buttonList.Add(btn);
}
}
}