Exemplo n.º 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();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Add new Educational Level
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ButtonAddEducationalLevel_Click(object sender, RoutedEventArgs e)
        {
            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;
                    string               icon    = control.GetSelectedIcon();
                    EducationalLevelType type    = control.GetSelectedEducationalLevel();
                    if (icon != "")
                    {
                        if (_selectedLanguage != null)
                        {
                            long id = _contentManager.AddEducationalLevel(_courseImagesCache[_selectedLanguage.Name], icon, type);
                            if (id > 0) //new edu level created
                            {
                                Image image = new Image()
                                {
                                    Source     = new BitmapImage(new Uri(icon)),
                                    RenderSize = new Size(100, 100),
                                    MaxHeight  = 100,
                                    MaxWidth   = 100,
                                    Margin     = new Thickness(15),
                                    Opacity    = 0.5,
                                    Name       = "Icon_" + id
                                };
                                image.MouseUp += delegate(object senderImage, MouseButtonEventArgs eventArgs)
                                {
                                    ImageEducationaLevel_Click(senderImage as Image);
                                };
                                if (!_educationalLevelDictionary.ContainsKey(image.Name))
                                {
                                    _educationalLevelDictionary[image.Name] = id;
                                    WrapPanelEducationaLevel.Children.Add(image);
                                    ImageEducationaLevel_Click(image);
                                    AddGrade.IsEnabled               = true;
                                    EditEducationalLevel.IsEnabled   = true;
                                    DeleteEducationalLevel.IsEnabled = true;
                                }
                                else
                                {
                                    image = null;
                                }
                            }// -1 - error; 0 - already exists
                        }
                    }
                    window.Close();
                };
            };
            window.ShowDialog();
        }