Esempio n. 1
0
        /// <summary>
        /// Loads tests to the list
        /// </summary>
        public void LoadItems()
        {
            var ItemsOnHardDrive = new List <Test>();

            try
            {
                // Try to load the list of every test from bin files
                ItemsOnHardDrive = TestFileReader.ReadFile <Test>();
            }
            catch (Exception ex)
            {
                // If an error occured, show info to the user
                DI.UI.ShowMessage(new MessageBoxDialogViewModel
                {
                    Title   = "Błąd wczytywania",
                    Message = "Nie udało się wczytać dostępnych testów." +
                              "\nTreść błędu: " + ex.Message,
                    OkText = "Ok"
                });

                DI.Logger.Log("Unable to read tests from local folder, error message: " + ex.Message);
            }

            // Rewrite list to the collection
            Items = new ObservableCollection <TestListItemViewModel>();
            for (var i = 0; i < ItemsOnHardDrive.Count; i++)
            {
                Items.Add(new TestListItemViewModel()
                {
                    ID   = i,
                    Test = ItemsOnHardDrive[i],
                });
            }

            mCurrentlySelectedItemIndex = NothingSelected;
            SelectedItem  = null;
            IsAnySelected = false;

            SelectionChanged.Invoke();
        }