示例#1
0
 private void FreeResources(HtmlDesignMovableControl c)
 {
     if ((c as HtmlCodeSnippet) != null)
     {
         (c.Control as CodeSnippet).DeleteResources();
     }
 }
示例#2
0
        private void SelectControl(HtmlDesignMovableControl c)
        {
#if CHECKERS
            if (IsControlSelected(c))
            {
                throw new FireFlyException("{0} is already selected", c.Title);
            }
#endif
            _selectionList.Add(new BoundControl(c));
            Control winControl = c.Control;
            winControl.KeyUp += ControlKeyUp;
            c.BeginMove      += Control_BeginMove;
            c.EndMove        += Control_EndMove;
            c.BeginResize    += Control_BeginResize;
            c.EndResize      += Control_EndResize;
            Action d = () =>
            {
                if (IsControlSelected(c))
                {
                    UnSelectControl(c);
                }
            };
            c.Deleting += d;
            c.Disposed += d;
            if (c is HtmlCodeSnippet)
            {
                Forms.Main.RegisterToolBoxButton(winControl, miEditInMSWord)(true);
            }
            Forms.Main.RegisterToolBoxButton(winControl, miProperties)(true);
            Forms.Main.RegisterToolBoxButton(winControl, miDelete)(true);
            Debug.WriteLine("PageEditor: '" + c.Title + "' - Selected");
            SelectionChanged();
        }
示例#3
0
 private void Control_EndResize(HtmlDesignMovableControl c)
 {
     if (c.Control.Size != _PreviousSize)
     {
         HtmlPage.AddUndoOperation(HtmlControlModification.GetResized(c, _PreviousSize));
         UpdateUndoRedoState();
     }
 }
示例#4
0
 private void Control_BeginMove(HtmlDesignMovableControl c)
 {
     foreach (var bc in _selectionList)
     {
         HtmlDesignMovableControl owner = bc.Owner;
         _PreviousLocations[owner] = owner.Control.Location;
     }
     c.Control.LocationChanged += Control_LocationChanged;
 }
示例#5
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();
            }
        }
示例#6
0
        private void Control_LocationChanged(object sender, EventArgs e)
        {
            var   winControl       = (Control)sender;
            var   activeControl    = (HtmlDesignMovableControl)winControl.Tag;
            Point previousLocation = _PreviousLocations[activeControl];
            var   offset           = new Point(winControl.Location.X - previousLocation.X, winControl.Location.Y - previousLocation.Y);

            foreach (var bc in _selectionList)
            {
                HtmlDesignMovableControl c = bc.Owner;
                if (c != activeControl)
                {
                    var pl = _PreviousLocations[c];
                    pl.Offset(offset);
                    c.Control.Location = pl;
                }
            }
        }
示例#7
0
        private void UnSelectControlInternal(HtmlDesignMovableControl c)
        {
            int index = _selectionList.FindIndex(bc => bc.Owner.Equals(c));

#if CHECKERS
            if (index < 0)
            {
                throw new FireFlyException("{0} is not selected", c.Title);
            }
#endif
            Control winControl = c.Control;
            winControl.KeyUp -= ControlKeyUp;
            c.BeginMove      -= Control_BeginMove;
            c.EndMove        -= Control_EndMove;
            c.BeginResize    -= Control_BeginResize;
            c.EndResize      -= Control_EndResize;
            Forms.Main.UnRegisterToolBoxItems(winControl);
            _selectionList[index].Dispose();
            _selectionList.RemoveAt(index);
            Debug.WriteLine("PageEditor: '" + c.Title + "' - DeSelected");
        }
示例#8
0
        ///<summary>
        /// Creates new instance of <see cref="BoundControl" /> binded to <see cref="c" />
        ///</summary>
        ///<param name="c">Instance of Movable control that new control should bind to</param>
        public BoundControl([NotNull] HtmlDesignMovableControl c)
        {
            Debug.Assert(c != null);
            Owner       = c;
            c.Disposed += Dispose;
            c.Deleting += Dispose;
            Control control = c.Control;

            Location = control.Location;
            Size     = control.Size;
            Parent   = control.Parent;

            _ResizeBounds = new BoundsInfo(ClientRectangle);
            Region        = _ResizeBounds.GetBoundRegion();

            c.BindEvents(this);
            control.LocationChanged += Owner_LocationChanged;
            control.SizeChanged     += Owner_SizeChanged;
            Show();
            BringToFront();
        }
示例#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;
        }
示例#10
0
 private void UnSelectControl(HtmlDesignMovableControl c)
 {
     UnSelectControlInternal(c);
     SelectionChanged();
     c.Control.Focus();
 }
示例#11
0
 private void Control_BeginResize(HtmlDesignMovableControl c)
 {
     _PreviousSize = c.Control.Size;
 }