Hi, bin relativ neu in C#, hab bisher nur C für Mikrocontroller programmiert.
Dies soll ein kleines KonfigTool für einen Mikrocontroller werden.
hab ewig rum probiert, bekomme aber bei meinem XML Serializer keine ausgabe zustande. zumindest stehen die gewollten Daten nicht im XML File.
Das eigentliche problem besteht darin, dass mir die GUI einen streich spielt, kennt jemand einen ausweg?
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142:
| namespace ConfigTool { public partial class ChooseMethode : Form { public int Field4; public string _path = @"c:\Modules.xml"; public List<MSModule> Module;
public ChooseMethode() { InitializeComponent();
Module = new List<MSModule>(); }
public void SetButton_Click(object sender, EventArgs e) { read(); }
public void read() { Field4 = 0; if (checkBox1.Checked) { Field4 = Field4 + 1; } if (checkBox2.Checked) { Field4 = Field4 + 2; } if (checkBox3.Checked) { Field4 = Field4 + 4; } if (checkBox4.Checked) { Field4 = Field4 + 8; } if (checkBox5.Checked) { Field4 = Field4 + 16; } if (checkBox6.Checked) { Field4 = Field4 + 32; } if (checkBox7.Checked) { Field4 = Field4 + 64; } if (checkBox8.Checked) { Field4 = Field4 + 128; } string var2 = Convert.ToString(Field4, 2);
MSModule Part1 = new MSModule{ ModulArt = ChooseArt.Text, ModulNr = ChooseNumber.Text, IDAdress = IDAdress.Text, Field4 = var2, PWMSelect = PWMSelect.Text};
ChooseMethode Tema = new ChooseMethode(); Tema.add(Part1);
}
public void add(MSModule a) { try { Module.Add(a); } catch (Exception e) { } }
private void ConfiguredModulesTable_Paint(object sender, PaintEventArgs e) {
}
private void listView1_SelectedIndexChanged(object sender, EventArgs e) {
}
public void ExportXML_Click(object sender, EventArgs e) { read(); XmlSerializer Out = new XmlSerializer(typeof(List<MSModule>)); FileStream file = new FileStream(@"c:\Modules.xml", FileMode.Create, FileAccess.Write); Out.Serialize(file,this.Module); file.Close(); } }
public class MSModule { private string _ModulArt; private string _ModulNr; private string _IDAdress; private string _Field4; private string _PWMSelect;
public string ModulArt { get { return _ModulArt; } set { _ModulArt = value; } }
public string ModulNr { get { return _ModulNr; } set { _ModulNr = value; } }
public string IDAdress { get { return _IDAdress; } set { _IDAdress = value; } }
public string Field4 { get { return _Field4; } set { _Field4 = value; } }
public string PWMSelect { get { return _PWMSelect; } set { _PWMSelect = value; } } } } |
vllt kann mir jemand helfen das ganze gangbar zu machen, dass ich eine korrekte XML ausgabe bekomme