Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void EditEducationalLevel_Click(object sender, RoutedEventArgs e)
        {
            bool   exitCancel = false;
            bool   normalExit = true;
            Window window     = new Window()
            {
                Title                 = "Create educatinal level",
                ResizeMode            = ResizeMode.NoResize,
                WindowStartupLocation = WindowStartupLocation.CenterScreen
            };

            window.Loaded += delegate(object o, RoutedEventArgs args)
            {
                LevelSelection level = new LevelSelection()
                {
                    VerticalAlignment   = VerticalAlignment.Stretch,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                };
                window.Width        = level.Width + 15;
                window.Height       = level.Height + 40;
                window.Content      = level;
                level.button.Click += delegate(object obj, RoutedEventArgs Args)
                {
                    LevelSelection       control = window.Content as LevelSelection;
                    long                 id      = _educationalLevelDictionary[_selectedEducationalLevel.Name];
                    string               icon    = control.GetSelectedIcon();
                    EducationalLevelType type    = control.GetSelectedEducationalLevel();
                    if (icon != "")
                    {
                        if (_selectedLanguage != null)
                        {
                            if (!ExistingEducationalLevel(_selectedEducationalLevel.Name))
                            {
                                _contentManager.EditEducationalLevel(id, icon, type);
                                _selectedEducationalLevel.Source = new BitmapImage(new Uri(icon));
                                exitCancel = false;
                                normalExit = false;
                                window.Close();
                            }
                            else
                            {
                                MessageBox.Show("Educational level already exists!");
                                exitCancel = true;
                                normalExit = true;
                            }
                        }
                    }
                };
            };
            window.Closing += delegate(object o, CancelEventArgs args)
            {
                if (!normalExit)
                {
                    if (exitCancel)
                    {
                        args.Cancel = true;
                    }
                }
            };
            window.ShowDialog();
        }