I have a problem here with the Var "item", i call Method MyItems from a xml loop, and choose the class from Dictionary by key, for some reason the amount is correct but they are all from the same type/values/icons.....
How could i reset , clear, null or whatever "item" after it was added to _list.Add(item) .... New to c#......
*i hope my post code/format is now correct :p
public class ISwitch : Form1
{
private static Dictionary<int, Base> _objectsToList;
private static bool _dicSet = false;
// Build Dictionary
static ISwitch()
{
Debug.Write("-----------------------------------------------------\n");
Debug.Write("dic created\n");
_objectsToList = new Dictionary<int, SenseItemBase>
{
{1, new Control()},
{2, new Control2()},
{3, new MoreItems()},
{4, new MoreItems2()}
};
_dicSet = true;
}
public static void MyItems(int id, int funcid, string _index, string _text, string icongfx, string property, string type, string _function, string _itemtype)
{
if (!_dicSet) return;
Debug.Write("-----------------------------------------------------\n");
Debug.Write("ID : " + id + "\n");
Debug.Write("funcid : " + funcid + "\n");
Debug.Write("Case : " + _index + "\n");
Debug.Write("Property : " + property + "\n");
Debug.Write("Type : " + type + "\n");
Debug.Write("Function : " + _function + "\n");
Debug.Write("Icon : " + icongfx + "\n");
Debug.Write("Text : " + _text + "\n");
Debug.Write("Switch : " + _itemtype + "\n");
XFItemStyle Style;
switch (id)
{
case 1:
if (_objectsToList.ContainsKey(funcid))
{
var item = _objectsToList[funcid];
Debug.Write("-----------------------------------------------------\n");
Debug.Write("- Item-\n");
Debug.Write("_objectsToList : " + item + "\n");
Debug.Write("ID : " + id + "\n");
Debug.Write("funcid : " + funcid + "\n");
item.Style = IStyle.MyStyle(_index, "HelveticaNeue", "HelveticaNeue", out Style);
item.MainText = _text;
item.myIcon = Path + "\\" + icongfx;
_list.Add(item);
}
return;
case 2:
if (_objectsToList.ContainsKey(funcid))
{
var item = _objectsToList[funcid];
Debug.Write("-----------------------------------------------------\n");
Debug.Write("- Item action-\n");
Debug.Write("_objectsToList : " + item + "\n");
Debug.Write("ID : " + id + "\n");
item.Style = IStyle.MyStyle(_index, "HelveticaNeue", "HelveticaNeue", out Style);
item.MainText = _text;
item.SecondaryText = _text;
item.myIcon = Path + "\\" + icongfx;
_list.Add(item);
item = null;
}
return;
}
}
}
thank you