/// <summary>
        /// представление курса
        /// </summary>
        /// <param name="_model">курс</param>
        /// <exception cref="ArgumentNullException"></exception>
        public CourseViewModel(ICourseModel _model)
            : base(_model, null)
        {
            model = _model;

            checkedItems = new List <Guid>();

            SetExpanded(this);
        }
        /// <summary>
        /// представление курса
        /// </summary>
        /// <param name="_model">курс</param>
        /// <exception cref="ArgumentNullException"></exception>
        public CourseViewModel(ICourseModel _model)
            : base(_model, null)
        {
            model = _model;

            checkedItems = new List<Guid>();

            SetExpanded(this);
        }
Exemple #3
0
 public void Show(ICourseModel course)
 {
     course.Display();
 }
Exemple #4
0
 public CoursePresenter(ICourseView courseView)
 {
     this.courseView  = courseView;
     this.courseModel = new CourseModel();
 }
Exemple #5
0
 public CoursePresenter()
 {
     this.courseModel = new CourseModel();
 }
        /// <summary>
        /// установить курс
        /// </summary>
        /// <param name="_course">курс</param>
        /// <param name="_absPathToParamsFolder">путь до папки с параметрами</param>
        /// <exception cref="ArgumentNullException"></exception>
        public void SetCourse(ICourseModel _course, string _absPathToParamsFolder)
        {
            if (_course == null || string.IsNullOrEmpty(_absPathToParamsFolder) )
                throw new ArgumentNullException();

            pnlConvParam.IsEnabled = true;

            //XSLTParamFromXML xmlPrm = new XSLTParamFromXML(_absPathToParamsFolder);
            XSLTConvertParams prm = new XSLTConvertParams();
            XSLTParamsView prmv = new XSLTParamsView(prm);
            CourseViewModel ivm = new CourseViewModel(_course);
            XSLTConvertView cv = new XSLTConvertView(ivm, prmv);
            this.DataContext = ivm;
            tree.ItemsSource = ivm.Children;
            convBtn.Command = cv.СonvertCommand;

            Binding bi0 = new Binding();
            bi0.Source = prmv;
            bi0.Path = new PropertyPath("TemplateFilePath");
            bi0.Mode = BindingMode.TwoWay;
            bi0.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;

            tbParam.SetBinding(TextBox.TextProperty, bi0);

            Binding bi1 = new Binding();
            bi1.Source = prmv;
            bi1.Path = new PropertyPath("OutputAbsPath");
            bi1.Mode = BindingMode.TwoWay;
            bi1.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            bi1.ValidationRules.Add(new FolderTryValidation());
            tbPath.SetBinding(TextBox.TextProperty, bi1);

            Binding bi2 = new Binding();
            bi2.Source = prmv;
            bi2.Path = new PropertyPath("IsToScorm");
            bi2.Mode = BindingMode.TwoWay;
            bi2.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            IsScorm.SetBinding(CheckBox.IsCheckedProperty, bi2);
               // Binding bi = new Binding();
              //  bi.Source = _course.Items;
            // bi.Path = new PropertyPath("Sections");
            //  bi.Mode = BindingMode.TwoWay;
            // bi.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            //tvCourse.SetBinding(TreeView.ItemsSourceProperty, bi);
            base.CommandBindings.Add(
               new CommandBinding(
                   ApplicationCommands.Undo,
                   (sender, e) => // Execute
                   {
                       e.Handled = true;
                       ivm.IsChecked = false;
                       this.tree.Focus();
                   },
                   (sender, e) => // CanExecute
                   {
                       e.Handled = true;
                       e.CanExecute = (ivm.IsChecked != false);
                   }));

            base.CommandBindings.Add(
              new CommandBinding(
                  ApplicationCommands.Redo,
                  (sender, e) => // Execute
                  {
                      e.Handled = true;
                      ivm.IsChecked = true;
                      this.tree.Focus();
                  },
                  (sender, e) => // CanExecute
                  {
                      e.Handled = true;
                      e.CanExecute = (ivm.IsChecked != true);
                  }));

            this.tree.Focus();
        }
        /// <summary>
        /// установить курс
        /// </summary>
        /// <param name="_course">курс</param>
        /// <param name="_absPathToParamsFolder">путь до папки с параметрами</param>
        /// <exception cref="ArgumentNullException"></exception>
        public void SetCourse(ICourseModel _course, string _absPathToParamsFolder)
        {
            if (_course == null || string.IsNullOrEmpty(_absPathToParamsFolder))
            {
                throw new ArgumentNullException();
            }

            pnlConvParam.IsEnabled = true;

            //XSLTParamFromXML xmlPrm = new XSLTParamFromXML(_absPathToParamsFolder);
            XSLTConvertParams prm  = new XSLTConvertParams();
            XSLTParamsView    prmv = new XSLTParamsView(prm);
            CourseViewModel   ivm  = new CourseViewModel(_course);
            XSLTConvertView   cv   = new XSLTConvertView(ivm, prmv);

            this.DataContext = ivm;
            tree.ItemsSource = ivm.Children;
            convBtn.Command  = cv.СonvertCommand;

            Binding bi0 = new Binding();

            bi0.Source = prmv;
            bi0.Path   = new PropertyPath("TemplateFilePath");
            bi0.Mode   = BindingMode.TwoWay;
            bi0.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;

            tbParam.SetBinding(TextBox.TextProperty, bi0);

            Binding bi1 = new Binding();

            bi1.Source = prmv;
            bi1.Path   = new PropertyPath("OutputAbsPath");
            bi1.Mode   = BindingMode.TwoWay;
            bi1.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            bi1.ValidationRules.Add(new FolderTryValidation());
            tbPath.SetBinding(TextBox.TextProperty, bi1);

            Binding bi2 = new Binding();

            bi2.Source = prmv;
            bi2.Path   = new PropertyPath("IsToScorm");
            bi2.Mode   = BindingMode.TwoWay;
            bi2.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            IsScorm.SetBinding(CheckBox.IsCheckedProperty, bi2);
            // Binding bi = new Binding();
            //  bi.Source = _course.Items;
            // bi.Path = new PropertyPath("Sections");
            //  bi.Mode = BindingMode.TwoWay;
            // bi.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            //tvCourse.SetBinding(TreeView.ItemsSourceProperty, bi);
            base.CommandBindings.Add(
                new CommandBinding(
                    ApplicationCommands.Undo,
                    (sender, e) => // Execute
            {
                e.Handled     = true;
                ivm.IsChecked = false;
                this.tree.Focus();
            },
                    (sender, e) => // CanExecute
            {
                e.Handled    = true;
                e.CanExecute = (ivm.IsChecked != false);
            }));

            base.CommandBindings.Add(
                new CommandBinding(
                    ApplicationCommands.Redo,
                    (sender, e) => // Execute
            {
                e.Handled     = true;
                ivm.IsChecked = true;
                this.tree.Focus();
            },
                    (sender, e) => // CanExecute
            {
                e.Handled    = true;
                e.CanExecute = (ivm.IsChecked != true);
            }));

            this.tree.Focus();
        }