Пример #1
0
        private void LoadContentInfo(long id)
        {
            Component content = _contentManager.GetComponent(id);

            if (content.GetType().Name == "ContentFile")
            {
                textBoxTitle.Text       = ((ContentFile)content).Title;
                TextBoxURI.Text         = ((ContentFile)content).URI;
                textBoxDescription.Text = ((ContentFile)content).Description;
                Size.Text = ((ContentFile)content).Size.ToString();
                switch (((ContentFile)content).ComponentType)
                {
                case ComponentType.Audio:
                    radioButtonAudio.IsChecked = true;
                    break;

                case ComponentType.Video:
                    radioButtonVideo.IsChecked = true;
                    break;

                case ComponentType.Document:
                    radioButtonDocument.IsChecked = true;
                    break;
                }
                Edit.IsEnabled   = true;
                Delete.IsEnabled = true;
                DisableQuizInfo();
            }
            else if (content.GetType().Name == "Quiz")
            {
                textBoxQuizTitle.Text  = (content as Quiz).Title;
                textBoxTitle.IsEnabled = true;
                EditQuiz.IsEnabled     = true;
                DeleteQuiz.IsEnabled   = true;
                DisableContentFileInfo();
            }
        }
Пример #2
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();
        }