Пример #1
0
 public EducationalLevel FindEducationLevel(EducationalLevelType type)
 {
     if (Components.Exists(x => ((EducationalLevel)x).Level == type))
     {
         return(Components.Find(x => ((EducationalLevel)x).Level == type) as EducationalLevel);
     }
     return(null);
 }
Пример #2
0
 /// <summary>
 /// Creates new EducationalLevel object and sets all properties.
 /// </summary>
 /// <param name="id">ID of component.</param>
 /// <param name="level">EducationalLevel type.</param>
 /// <param name="icon">EducationalLevel icon.</param>
 /// <returns>New EducationalLevel object.</returns>
 public static Component CreateCompositeComponent(long id, long parent, EducationalLevelType level, string icon)
 {
     return(new EducationalLevel()
     {
         ID = id,
         ParentID = parent,
         Level = level,
         Icon = icon
     });
 }
Пример #3
0
 public void EditEducationalLevel(long id, string iconURI, EducationalLevelType levelType)
 {
     if (ComponentsCache != null && ComponentsCache.ContainsKey(id))
     {
         EducationalLevel level = ComponentsCache[id] as EducationalLevel;
         if (level != null)
         {
             level.Icon  = iconURI ?? level.Icon;
             level.Level = levelType;
             LogChange(level, ContentStatus.Edit);
         }
     }
 }
Пример #4
0
 public GradeSelection(EducationalLevelType type)
 {
     InitializeComponent();
     if (type == EducationalLevelType.Nursery)
     {
         EnableNursery();
     }
     else if (type == EducationalLevelType.Primary)
     {
         EnablePrimary();
     }
     else if (type == EducationalLevelType.Secondary)
     {
         EnableSecondary();
     }
 }
Пример #5
0
 public long AddEducationalLevel(long parentID, string iconURI, EducationalLevelType type)
 {
     if (ComponentsCache.ContainsKey(parentID)) //check for course
     {
         EducationalLevel level = (ComponentsCache[parentID] as Course).FindEducationLevel(type);
         if (level == null) //there is no existing edu level
         {
             long ID = GetID();
             level = ContentFactory.CreateCompositeComponent(ID, parentID, type, iconURI) as EducationalLevel;
             (ComponentsCache[parentID] as Course).Add(level);
             ComponentsCache[ID] = level;
             LogChange(level, ContentStatus.Add);
             return(ID);
         }
         return(0);
     }
     return(-1);
 }
Пример #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void EditGrade_Click(object sender, RoutedEventArgs e)
        {
            bool   exitCancel = false;
            bool   normalExit = true;
            Window window     = new Window()
            {
                Title                 = "Create grade",
                ResizeMode            = ResizeMode.NoResize,
                WindowStartupLocation = WindowStartupLocation.CenterScreen
            };

            window.Loaded += delegate(object o, RoutedEventArgs args)
            {
                if (_selectedEducationalLevel != null)
                {
                    EducationalLevelType type =
                        (_contentManager.GetComponent(_educationalLevelDictionary[_selectedEducationalLevel.Name])
                         as EducationalLevel).Level;
                    GradeSelection grade = new GradeSelection(type)
                    {
                        VerticalAlignment   = VerticalAlignment.Stretch,
                        HorizontalAlignment = HorizontalAlignment.Stretch,
                    };
                    window.Width        = grade.Width + 35;
                    window.Height       = grade.Height + 40;
                    window.Content      = grade;
                    grade.button.Click += delegate(object obj, RoutedEventArgs Args)
                    {
                        GradeSelection control   = window.Content as GradeSelection;
                        long           id        = _gradesDictionary[_selectedGrade.Name];
                        string         icon      = control.GetSelectedIcon();
                        GradeType      gradeType = control.GetSelectedGrade();
                        if (icon != "")
                        {
                            if (_selectedEducationalLevel != null)
                            {
                                if (!ExistingGrade(_selectedGrade.Name))
                                {
                                    _contentManager.EditGrade(id, icon, gradeType);
                                    _selectedGrade.Source = new BitmapImage(new Uri(icon));
                                    exitCancel            = false;
                                    normalExit            = false;
                                    window.Close();
                                }
                                else
                                {
                                    MessageBox.Show("Grade already exists!");
                                    exitCancel = true;
                                    normalExit = true;
                                }
                            }
                        }
                    };
                }
                else
                {
                    window.Close();
                }
            };
            window.Closing += delegate(object o, CancelEventArgs args)
            {
                if (!normalExit)
                {
                    if (exitCancel)
                    {
                        args.Cancel = true;
                    }
                }
            };
            window.ShowDialog();
        }
Пример #7
0
        /// <summary>
        /// Add new Grade
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ButtonAddGrade_Click(object sender, RoutedEventArgs e)
        {
            Window window = new Window()
            {
                Title                 = "Create grade",
                ResizeMode            = ResizeMode.NoResize,
                WindowStartupLocation = WindowStartupLocation.CenterScreen
            };

            window.Loaded += delegate(object o, RoutedEventArgs args)
            {
                if (_selectedEducationalLevel != null)
                {
                    long                 value     = _educationalLevelDictionary[_selectedEducationalLevel.Name];
                    Component            component = _contentManager.GetComponent(value);
                    EducationalLevelType type      = (component as EducationalLevel).Level;
                    GradeSelection       grade     = new GradeSelection(type)
                    {
                        VerticalAlignment   = VerticalAlignment.Stretch,
                        HorizontalAlignment = HorizontalAlignment.Stretch,
                    };
                    window.Width        = grade.Width + 35;
                    window.Height       = grade.Height + 40;
                    window.Content      = grade;
                    grade.button.Click += delegate(object obj, RoutedEventArgs Args)
                    {
                        GradeSelection control   = window.Content as GradeSelection;
                        string         icon      = control.GetSelectedIcon();
                        GradeType      gradeType = control.GetSelectedGrade();
                        if (icon != "")
                        {
                            if (_selectedEducationalLevel != null)
                            {
                                long id = _contentManager.AddGrade(_educationalLevelDictionary[_selectedEducationalLevel.Name], icon, gradeType);
                                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       = "Image_" + id
                                    };
                                    image.MouseUp += delegate(object senderImage, MouseButtonEventArgs eventArgs)
                                    {
                                        ImageGrade_Click(senderImage as Image);
                                    };
                                    if (!_gradesDictionary.ContainsKey(image.Name))
                                    {
                                        _gradesDictionary[image.Name] = id;
                                        WrapPanelGrades.Children.Add(image);
                                        ImageGrade_Click(image);
                                    }
                                    else
                                    {
                                        image = null;
                                    }
                                }// -1 - error; 0 - already exists
                            }
                        }
                        window.Close();
                    };
                }
                else
                {
                    window.Close();
                }
            };
            window.ShowDialog();
        }
Пример #8
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();
        }
Пример #9
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();
        }