Ejemplo n.º 1
0
 private void Control_EndResize(HtmlDesignMovableControl c)
 {
     if (c.Control.Size != _PreviousSize)
     {
         HtmlPage.AddUndoOperation(HtmlControlModification.GetResized(c, _PreviousSize));
         UpdateUndoRedoState();
     }
 }
Ejemplo n.º 2
0
 private void ControlProperty_ValueChanging(object control, string propertyName, object oldValue, object newValue)
 {
     if (!_IsUndoRedoState)
     {
         HtmlPage.AddUndoOperation(HtmlControlModification.GetPropertyChanged((HtmlControl)control, propertyName, oldValue));
         UpdateUndoRedoState();
     }
 }
Ejemplo n.º 3
0
        ///<summary>
        /// Gets page assigned to <see cref="item" />
        ///</summary>
        ///<param name="item">Item which assigned to page we need to find</param>
        ///<returns></returns>
        new public static HtmlPage GetPage(ItemType item)
        {
            HtmlPage resultPage = (HtmlPage)HtmlPageBase.GetPage(item);

            if (resultPage != null)
            {
            }
            return(resultPage);
        }
Ejemplo n.º 4
0
 ///<summary>
 /// Binds control to <see cref="page" />
 ///</summary>
 ///<param name="page">Instance of <see cref="HtmlPage" /> control needs to bind to</param>
 public void Bind([NotNull] HtmlPage page)
 {
     if (IsBinded)
     {
         UnBind();
     }
     page.ErrorFixed    += Page_ErrorFixed;
     page.ErrorFound    += Page_ErrorFound;
     page.BeginValidate += Page_BeginValidate;
     page.EndValidate   += Page_EndValidate;
     _Page = page;
     UpdateSummary();
 }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        private void miDelete_Click(object sender, EventArgs e)
        {
#if CHECKERS
            if (IsSelectionEmpty)
            {
                throw new InvalidOperationException();
            }
#endif
            var  b       = new StringBuilder();
            bool isFirst = true;
            foreach (var c in _selectionList)
            {
                if (!isFirst)
                {
                    b.Append(", ");
                }
                else
                {
                    isFirst = false;
                }
                b.Append(c.Owner.Title);
            }

            if (Extenders.ConfirmDelete(b.ToString()))
            {
                var list = _selectionList.ToArray();
                UnSelectAll();
                var mg = new ModificationCollection <HtmlControlModification>();
                foreach (var c in list)
                {
                    FreeResources(c.Owner);
                    HtmlDesignMovableControl owner = c.Owner;
                    owner.NotifyDelete();

                    mg.Add(HtmlControlModification.GetRemoved(owner));

                    owner.Parent = null;
                }
                if (mg.Count > 0)
                {
                    HtmlPage.AddUndoOperation(mg.Count == 1 ? (IModification)mg[0] : mg);
                }
                else
                {
                    throw new InvalidOperationException();
                }
                UpdateUndoRedoState();
            }
        }
Ejemplo n.º 7
0
        private HtmlPage CreateHtmlPage()
        {
            var p = new HtmlPage {
                Parent = this
            };
            var c   = p.Control;
            var top = tsComponents.Top + tsComponents.Height + 1;

            c.Top    = top;
            c.Width  = ClientSize.Width;
            c.Height = ClientSize.Height - top;
            c.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
            c.Click += PanelClick;
            if (PageCreated != null)
            {
                PageCreated(p);
            }
            return(p);
        }
Ejemplo n.º 8
0
 private void PanelClick(object sender, EventArgs e)
 {
     if (CheckedButton != null)
     {
         var c = ((Type)CheckedButton.Tag).Create <HtmlDesignMovableControl>();
         c.Parent           = HtmlPage;
         c.Control.Location = HtmlPage.Control.PointToClient(MousePosition);
         SetUpControl(c);
         UnSelectAllInternal();
         SelectControl(c);
         CheckedButton = null;
         c.Control.Focus();
         HtmlPage.AddUndoOperation(HtmlControlModification.GetAdded(c));
         UpdateUndoRedoState();
     }
     else
     {
         HtmlPage.Control.Focus();
         UnSelectAll();
         Forms.PropertyEditor.SetContext(HtmlPage, GetScope(), PropertyEditorSelectedObjectChanged).ValueChanging += ControlProperty_ValueChanging;
     }
 }
Ejemplo n.º 9
0
        private void Control_EndMove(HtmlDesignMovableControl c)
        {
            IModification m;

            if (_selectionList.Count == 1)
            {
                HtmlDesignMovableControl o = _selectionList[0].Owner;
                Point previousLocation     = _PreviousLocations[o];
                m = previousLocation != o.Control.Location ? HtmlControlModification.GetMoved(o, previousLocation) : (IModification)null;
            }
            else
            {
                var list = new ModificationCollection <HtmlControlModification>();
                foreach (var bc in _selectionList)
                {
                    HtmlDesignMovableControl o = bc.Owner;
                    Point previousLocation     = _PreviousLocations[o];
                    if (previousLocation != o.Control.Location)
                    {
                        list.Add(HtmlControlModification.GetMoved(o, previousLocation));
                    }
                }
                if (list.Count == 1)
                {
                    m = list[0];
                }
                else
                {
                    m = list.Count > 0 ? list : null;
                }
            }
            if (m != null)
            {
                HtmlPage.AddUndoOperation(m);
                UpdateUndoRedoState();
            }
            c.Control.LocationChanged -= Control_LocationChanged;
        }
Ejemplo n.º 10
0
 private HtmlPage CreateHtmlPage()
 {
     var p = new HtmlPage { Parent = this };
     var c = p.Control;
     var top = tsComponents.Top + tsComponents.Height + 1;
     c.Top = top;
     c.Width = ClientSize.Width;
     c.Height = ClientSize.Height - top;
     c.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
     c.Click += PanelClick;
     if (PageCreated != null)
     {
         PageCreated(p);
     }
     return p;
 }
Ejemplo n.º 11
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);
     }
 }
Ejemplo n.º 12
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;
        }