Inheritance: System.Windows.Forms.Control
Exemplo n.º 1
0
        /// <summary>
        /// Initialize a new instance of the ViewLayoutControl class.
        /// </summary>
        /// <param name="viewControl">View control to use as child.</param>
        /// <param name="rootControl">Top level visual control.</param>
        /// <param name="viewChild">View used to size and position the child control.</param>
        public ViewLayoutControl(ViewControl viewControl,
                                 VisualControl rootControl,
                                 ViewBase viewChild)
        {
            Debug.Assert(viewControl != null);
            Debug.Assert(rootControl != null);
            Debug.Assert(viewChild != null);

            // Default values
            _layoutOffset = Point.Empty;

            // Remember the view
            _viewChild = viewChild;

            // Ensure the child is hooked into the hierarchy of elements
            _viewChild.Parent = this;

            // Create the view control instance
            _viewControl = viewControl;

            // Back reference hookup
            _viewControl.ViewLayoutControl = this;

            // Start off invisible until first layed out
            _viewControl.Visible = false;

            // Ensure that all view elements inside here use our control
            OwningControl = _viewControl;

            // Add our new control to the provided parent collection
            CommonHelper.AddControlToParent(rootControl, _viewControl);
        }
 /// <summary>
 /// Make the provided control parented to ourself.
 /// </summary>
 /// <param name="c">Control to reparent.</param>
 public void MakeParent(Control c)
 {
     // Ask the view control to perform reparenting
     ViewControl.MakeParent(c);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Release unmanaged and optionally managed resources.
        /// </summary>
        /// <param name="disposing">Called from Dispose method.</param>
        protected override void Dispose(bool disposing)
        {
            // If called from explicit call to Dispose
            if (disposing)
            {
                if (_viewControl != null)
                {
                    try
                    {
                        ViewControl vc = _viewControl;
                        _viewControl = null;
                        CommonHelper.RemoveControlFromParent(vc);
                    }
                    catch { }
                }

                if (_viewChild != null)
                {
                    _viewChild.Dispose();
                    _viewChild = null;
                }
            }

            base.Dispose(disposing);
        }