Inheritance: VisualControlBase, ISupportInitializeNotification
示例#1
0
        /// <summary>
        /// Gets and sets the root control for point translation and message dispatch.
        /// </summary>
        /// <param name="parent">Parent control.</param>
        public void UpdateParent(Control parent)
        {
            // Keep looking till we run out of parents
            while (parent != null)
            {
                // We can hook into a visual control derived class
                if (parent is VisualControl)
                {
                    _rootControl = (VisualControl)parent;
                    _rootPopup   = null;
                    break;
                }

                // We can hook into a visual popup derived class
                if (parent is VisualPopup)
                {
                    _rootControl = null;
                    _rootPopup   = (VisualPopup)parent;
                    break;
                }

                // Move up another level
                parent = parent.Parent;
            }
        }
示例#2
0
        /// <summary>
        /// Initialize a new instance of the ViewControl class.
        /// </summary>
        /// <param name="rootControl">Top level visual control.</param>
        public ViewControl(VisualControl rootControl)
        {
            Debug.Assert(rootControl != null);

            // We use double buffering to reduce drawing flicker
            SetStyle(ControlStyles.OptimizedDoubleBuffer |
                     ControlStyles.AllPaintingInWmPaint |
                     ControlStyles.UserPaint, true);

            // We need to repaint entire control whenever resized
            SetStyle(ControlStyles.ResizeRedraw, true);

            // We are not selectable
            SetStyle(ControlStyles.Selectable, false);

            // Default
            _transparentBackground = false;
            _inDesignMode          = false;

            // Remember incoming references
            _rootControl = rootControl;

            // Create delegate so child elements can request a repaint
            _needPaintDelegate = new NeedPaintHandler(OnNeedPaint);
        }
        /// <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);
        }
示例#4
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);
        }
示例#5
0
        /// <summary>
        /// Initialize a new instance of the ViewControl class.
        /// </summary>
        /// <param name="rootControl">Top level visual control.</param>
        public ViewControl(VisualControl rootControl)
        {
            Debug.Assert(rootControl != null);

            // We use double buffering to reduce drawing flicker
            SetStyle(ControlStyles.OptimizedDoubleBuffer |
                     ControlStyles.AllPaintingInWmPaint |
                     ControlStyles.UserPaint, true);

            // We need to repaint entire control whenever resized
            SetStyle(ControlStyles.ResizeRedraw, true);

            // We are not selectable
            SetStyle(ControlStyles.Selectable, false);

            // Default
            _transparentBackground = false;
            _inDesignMode = false;

            // Remember incoming references
            _rootControl = rootControl;

            // Create delegate so child elements can request a repaint
            _needPaintDelegate = new NeedPaintHandler(OnNeedPaint);
        }
 /// <summary>
 /// Initialize a new instance of the ViewLayoutOutlookFull class.
 /// </summary>
 /// <param name="viewBuilder">View builder reference.</param>
 /// <param name="rootControl">Top level visual control.</param>
 /// <param name="viewportFiller">View element to place inside viewport.</param>
 /// <param name="paletteBorderEdge">Palette for use with the border edge.</param>
 /// <param name="paletteMetrics">Palette source for metrics.</param>
 /// <param name="metricPadding">Metric used to get view padding.</param>
 /// <param name="metricOvers">Metric used to get overposition.</param>
 /// <param name="orientation">Orientation for the viewport children.</param>
 /// <param name="alignment">Alignment of the children within the viewport.</param>
 /// <param name="animateChange">Animate changes in the viewport.</param>
 /// <param name="vertical">Is the viewport vertical.</param>
 /// <param name="needPaintDelegate">Delegate for notifying paint requests.</param>
 public ViewLayoutOutlookFull(ViewBuilderOutlookBase viewBuilder,
                              VisualControl rootControl,
                              ViewBase viewportFiller,
                              PaletteBorderEdge paletteBorderEdge,
                              IPaletteMetric paletteMetrics,
                              PaletteMetricPadding metricPadding,
                              PaletteMetricInt metricOvers,
                              VisualOrientation orientation,
                              RelativePositionAlign alignment,
                              bool animateChange,
                              bool vertical,
                              NeedPaintHandler needPaintDelegate)
     : base(rootControl, viewportFiller, paletteBorderEdge, paletteMetrics, 
            metricPadding, metricOvers, orientation, alignment, animateChange, 
            vertical, needPaintDelegate)
 {
     Debug.Assert(viewBuilder != null);
     _viewBuilder = viewBuilder;
 }
示例#7
0
 /// <summary>
 /// Initialize a new instance of the ViewLayoutControl class.
 /// </summary>
 /// <param name="rootControl">Top level visual control.</param>
 /// <param name="viewChild">View used to size and position the child control.</param>
 public ViewLayoutControl(VisualControl rootControl,
                          ViewBase viewChild)
     : this(new ViewControl(rootControl), rootControl, viewChild)
 {
 }
        /// <summary>
        /// Initialize a new instance of the ViewLayoutScrollViewport class.
        /// </summary>
        /// <param name="rootControl">Top level visual control.</param>
        /// <param name="viewportFiller">View element to place inside viewport.</param>
        /// <param name="paletteBorderEdge">Palette for use with the border edge.</param>
        /// <param name="paletteMetrics">Palette source for metrics.</param>
        /// <param name="metricPadding">Metric used to get view padding.</param>
        /// <param name="metricOvers">Metric used to get overposition.</param>
        /// <param name="orientation">Orientation for the viewport children.</param>
        /// <param name="alignment">Alignment of the children within the viewport.</param>
        /// <param name="animateChange">Animate changes in the viewport.</param>
        /// <param name="vertical">Is the viewport vertical.</param>
        /// <param name="needPaintDelegate">Delegate for notifying paint requests.</param>
        public ViewLayoutScrollViewport(VisualControl rootControl,
                                        ViewBase viewportFiller,
                                        PaletteBorderEdge paletteBorderEdge,
                                        IPaletteMetric paletteMetrics,
                                        PaletteMetricPadding metricPadding,
                                        PaletteMetricInt metricOvers,
                                        VisualOrientation orientation,
                                        RelativePositionAlign alignment,
                                        bool animateChange,
                                        bool vertical,
                                        NeedPaintHandler needPaintDelegate)
        {
            Debug.Assert(rootControl != null);
            Debug.Assert(viewportFiller != null);
            Debug.Assert(needPaintDelegate != null);

            // We need a way to notify changes in layout
            _needPaintDelegate = needPaintDelegate;

            // By default we are showing the contained viewport in vertical scrolling
            _viewportVertical = vertical;

            // Our initial visual orientation should match the parameter
            Orientation = orientation;

            // Create the child viewport
            _viewport = new ViewLayoutViewport(paletteMetrics, metricPadding,
                                               metricOvers, ViewportOrientation(_viewportVertical),
                                               alignment, animateChange)
            {
                // Default to same alignment for both directions
                CounterAlignment = alignment,

                // We always want the viewport to fill any remainder space
                FillSpace = true
            };

            // Put the provided element inside the viewport
            _viewport.Add(viewportFiller);

            // Hook into animation step events
            _viewport.AnimateStep += new EventHandler(OnAnimateStep);

            // To prevent the contents of the viewport from being able to draw outside
            // the viewport (such as having child controls) we use a ViewLayoutControl
            // that uses a child control to restrict the drawing region.
            _viewControl = new ViewLayoutControl(rootControl, _viewport)
            {
                InDesignMode = rootControl.InDesignMode
            };

            // Create the scrollbar and matching border edge
            _scrollbarV  = new ViewDrawScrollBar(true);
            _scrollbarH  = new ViewDrawScrollBar(false);
            _borderEdgeV = new ViewDrawBorderEdge(paletteBorderEdge, System.Windows.Forms.Orientation.Vertical);
            _borderEdgeH = new ViewDrawBorderEdge(paletteBorderEdge, System.Windows.Forms.Orientation.Horizontal);

            // Hook into scroll position changes
            _scrollbarV.ScrollChanged += new EventHandler(OnScrollVChanged);
            _scrollbarH.ScrollChanged += new EventHandler(OnScrollHChanged);

            // Add with appropriate docking style
            Add(_viewControl, ViewDockStyle.Fill);
            Add(_borderEdgeV, ViewDockStyle.Right);
            Add(_borderEdgeH, ViewDockStyle.Bottom);
            Add(_scrollbarV, ViewDockStyle.Right);
            Add(_scrollbarH, ViewDockStyle.Bottom);
        }
 /// <summary>
 /// Initialize a new instance of the ViewLayoutControl class.
 /// </summary>
 /// <param name="rootControl">Top level visual control.</param>
 /// <param name="viewChild">View used to size and position the child control.</param>
 public ViewLayoutControl(VisualControl rootControl,
                          ViewBase viewChild)
     : this(new ViewControl(rootControl), rootControl, viewChild)
 {
 }
示例#10
0
        /// <summary>
        /// Gets and sets the root control for point translation and message dispatch. 
        /// </summary>
        /// <param name="parent">Parent control.</param>
        public void UpdateParent(Control parent)
        {
            // Keep looking till we run out of parents
            while (parent != null)
            {
                // We can hook into a visual control derived class
                if (parent is VisualControl)
                {
                    _rootControl = (VisualControl)parent;
                    _rootPopup = null;
                    break;
                }

                // We can hook into a visual popup derived class
                if (parent is VisualPopup)
                {
                    _rootControl = null;
                    _rootPopup = (VisualPopup)parent;
                    break;
                }

                // Move up another level
                parent = parent.Parent;
            }
        }
        /// <summary>
        /// Initialize a new instance of the ViewLayoutScrollViewport class.
        /// </summary>
        /// <param name="rootControl">Top level visual control.</param>
        /// <param name="viewportFiller">View element to place inside viewport.</param>
        /// <param name="paletteBorderEdge">Palette for use with the border edge.</param>
        /// <param name="paletteMetrics">Palette source for metrics.</param>
        /// <param name="metricPadding">Metric used to get view padding.</param>
        /// <param name="metricOvers">Metric used to get overposition.</param>
        /// <param name="orientation">Orientation for the viewport children.</param>
        /// <param name="alignment">Alignment of the children within the viewport.</param>
        /// <param name="animateChange">Animate changes in the viewport.</param>
        /// <param name="vertical">Is the viewport vertical.</param>
        /// <param name="needPaintDelegate">Delegate for notifying paint requests.</param>
        public ViewLayoutScrollViewport(VisualControl rootControl,
                                        ViewBase viewportFiller,
                                        PaletteBorderEdge paletteBorderEdge,
                                        IPaletteMetric paletteMetrics,
                                        PaletteMetricPadding metricPadding,
                                        PaletteMetricInt metricOvers,
                                        VisualOrientation orientation,
                                        RelativePositionAlign alignment,
                                        bool animateChange,
                                        bool vertical,
                                        NeedPaintHandler needPaintDelegate)
        {
            Debug.Assert(rootControl != null);
            Debug.Assert(viewportFiller != null);
            Debug.Assert(needPaintDelegate != null);

            // We need a way to notify changes in layout
            _needPaintDelegate = needPaintDelegate;

            // By default we are showing the contained viewport in vertical scrolling
            _viewportVertical = vertical;

            // Our initial visual orientation should match the parameter
            Orientation = orientation;

            // Create the child viewport
            _viewport = new ViewLayoutViewport(paletteMetrics, metricPadding,
                                               metricOvers, ViewportOrientation(_viewportVertical),
                                               alignment, animateChange);

            // Default to same alignment for both directions
            _viewport.CounterAlignment = alignment;

            // We always want the viewport to fill any remainder space
            _viewport.FillSpace = true;

            // Put the provided element inside the viewport
            _viewport.Add(viewportFiller);

            // Hook into animation step events
            _viewport.AnimateStep += new EventHandler(OnAnimateStep);

            // To prevent the contents of the viewport from being able to draw outside
            // the viewport (such as having child controls) we use a ViewLayoutControl
            // that uses a child control to restrict the drawing region.
            _viewControl = new ViewLayoutControl(rootControl, _viewport);
            _viewControl.InDesignMode = rootControl.InDesignMode;

            // Create the scrollbar and matching border edge
            _scrollbarV = new ViewDrawScrollBar(true);
            _scrollbarH = new ViewDrawScrollBar(false);
            _borderEdgeV = new ViewDrawBorderEdge(paletteBorderEdge, System.Windows.Forms.Orientation.Vertical);
            _borderEdgeH = new ViewDrawBorderEdge(paletteBorderEdge, System.Windows.Forms.Orientation.Horizontal);

            // Hook into scroll position changes
            _scrollbarV.ScrollChanged += new EventHandler(OnScrollVChanged);
            _scrollbarH.ScrollChanged += new EventHandler(OnScrollHChanged);

            // Add with appropriate docking style
            Add(_viewControl, ViewDockStyle.Fill);
            Add(_borderEdgeV, ViewDockStyle.Right);
            Add(_borderEdgeH, ViewDockStyle.Bottom);
            Add(_scrollbarV, ViewDockStyle.Right);
            Add(_scrollbarH, ViewDockStyle.Bottom);
        }