Пример #1
0
        private bool ReadVMAFile(ref string ErrMSG)
        {
            //Check the file if exist
            if ((string.IsNullOrEmpty(VMAFilePath)) || (!File.Exists(VMAFilePath)))
            {
                ErrMSG = "File not found (" + VMAFilePath + ") !";
                return(false);
            }

            //**** Datei einlesen ****
            VMAdata = new VMA();
            using (StreamReader r = new StreamReader(VMAFilePath))
            {
                try
                {
                    string json = r.ReadToEnd();
                    VMAdata = JsonConvert.DeserializeObject <VMA>(json);
                }
                catch
                {
                    ErrMSG = "Error during file read! " + "(" + VMAFilePath + ")";
                    return(false);
                }
            }

            // Return value
            return(true);
        }
    public MainWindow()
    {
        InitializeComponent();
        var rnd = new Random();
        var vm  = new VM();

        this.DataContext = vm;
        //enum "A"
        foreach (var a in Enum.GetNames(typeof(A)))
        {
            var vma = new VMA();
            vma.Title = a;
            vm.AItems.Add(vma);
            //enum "B"
            foreach (var b in Enum.GetNames(typeof(B)))
            {
                var vmb = new VMB();
                vmb.Title = b;
                vmb.Value = rnd.Next(1000).ToString();
                vma.BItems.Add(vmb);
            }
        }
    }