Esempio n. 1
0
 ///<summary>
 /// Assign item to current page
 ///</summary>
 ///<param name="node"></param>
 public void SetPageItem([NotNull] ItemType node)
 {
     SuspendLayout();
     try
     {
         if (HtmlPage != null)
         {
             HtmlPage.Parent = null;
         }
         HtmlPage p = HtmlPage.GetPage(node);
         if (p == null)
         {
             p = HtmlPage = CreateHtmlPage();
             p.SetPageItem(node);
             p.ParseHtmlFile(node.PageHref, ControlControlParsed);
         }
         else
         {
             HtmlPage = p;
         }
         HtmlPage.Parent = this;
         UpdateUndoRedoState();
     }
     finally
     {
         ResumeLayout(true);
     }
 }
Esempio n. 2
0
        ///<summary>
        /// Run validation
        ///</summary>
        ///<returns></returns>
        public bool Validate()
        {
            _Errors      = new StringBuilder();
            _CurrentList = new ErrorsCollection();
            foreach (var i in Course.Organization.Items)
            {
                if (i.PageType == PageType.Question)
                {
                    var p = HtmlPageBase.GetPage(i);
                    if (p == null)
                    {
                        using (var page = new HtmlPage {
                            Parent = new Form()
                        })
                        {
                            page.Name = i.Title;
                            page.SetPageItem(i);
                            page.ParseHtmlFile(i.PageHref, (htmlPage, control) => { });
                            page.ReValidate();
                            _CurrentList.AddRange(page.Errors);
                        }
                    }
                    else
                    {
                        p.ReValidate();
                        _CurrentList.AddRange(p.Errors);
                    }

                    foreach (var error in _CurrentList)
                    {
                        if (_Errors.Length > 0)
                        {
                            _Errors.AppendLine();
                        }
                        _Errors.Append(i.GetFullPath());
                        if (error.Source != i)
                        {
                            _Errors.Append("/" + error.Source.Title);
                        }
                        _Errors.Append(": ");
                        _Errors.Append(error.Message);
                    }
                }

                foreach (string error in i.Errors)
                {
                    this._Errors.AppendLine(error);
                }
            }
            return(_Errors.Length == 0);
        }
Esempio n. 3
0
        ///<summary>
        /// Run validation
        ///</summary>
        ///<returns></returns>
        public bool Validate()
        {
            _Errors = new StringBuilder();
            _CurrentList = new ErrorsCollection();
            foreach (var i in Course.Organization.Items)
            {
                if (i.PageType == PageType.Question)
                {
                    var p = HtmlPageBase.GetPage(i);
                    if (p == null)
                    {
                        using (var page = new HtmlPage { Parent = new Form() })
                        {
                            page.Name = i.Title;
                            page.SetPageItem(i);
                            page.ParseHtmlFile(i.PageHref, (htmlPage, control) => { });
                            page.ReValidate();
                            _CurrentList.AddRange(page.Errors);
                        }
                    }
                    else
                    {
                        p.ReValidate();
                        _CurrentList.AddRange(p.Errors);
                    }

                    foreach (var error in _CurrentList)
                    {
                        if (_Errors.Length > 0)
                        {
                            _Errors.AppendLine();
                        }
                        _Errors.Append(i.GetFullPath());
                        if (error.Source != i)
                        {
                            _Errors.Append("/" + error.Source.Title);
                        }
                        _Errors.Append(": ");
                        _Errors.Append(error.Message);
                    }
                }

                foreach (string error in i.Errors)
                {
                    this._Errors.AppendLine(error);
                }
            }
            return _Errors.Length == 0;
        }