private void button_Click(object sender, RoutedEventArgs e) { Window window = new Window() { Title = "Edit lessons", ResizeMode = ResizeMode.NoResize, WindowStartupLocation = WindowStartupLocation.CenterScreen }; window.Loaded += delegate(object o, RoutedEventArgs args) { LessonsCreation lessonsCreation = new LessonsCreation(0, _contentManager, true) { VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Stretch, }; window.Width = lessonsCreation.Width + 35; window.Height = lessonsCreation.Height + 40; window.Content = lessonsCreation; lessonsCreation.Button.Click += delegate(object obj, RoutedEventArgs Args) { LessonsCreation control = window.Content as LessonsCreation; if (!control.IsEmpty() && control.IsSaved()) { int num = _contentManager.GetNoOfTopicsLessons(); NoOfLessons.Text = num.ToString(); if (num > 0) { EditFiles.IsEnabled = true; } } window.Close(); }; }; window.Closing += delegate(object o, CancelEventArgs args) { if (window.Content != null) { bool empty = (window.Content as LessonsCreation).IsEmpty(); bool ctrl = (window.Content as LessonsCreation).IsSaved(); if (!empty && !ctrl) { args.Cancel = true; MessageBox.Show("Progress is not saved!!!"); } } }; window.ShowDialog(); }
public void LoadParentComponents() { if (_topics) { parentComponents = _contentManager.GetAllTopics(); numOfLessons = _contentManager.GetNoOfTopicsLessons(); } else { parentComponents = _contentManager.GetAllWeeks(_contentManager.GetComponent(_selectedGrade)); numOfLessons = _contentManager.GetNoOfLessons(_selectedGrade); } listBox.ItemsSource = parentComponents; listBox.DisplayMemberPath = "Title"; listBox.Items.Refresh(); for (int i = 0; i < 100; i++) { comboBox.Items.Add((i + 1).ToString()); } comboBox.Text = 1.ToString(); }