コード例 #1
0
        /// <summary>
        /// Initialize a new instance of the VisualPopup class.
        /// </summary>
        /// <param name="viewManager">View manager instance for managing view display.</param>
        /// <param name="renderer">Drawing renderer.</param>
        /// <param name="shadow">Does the popup need a shadow effect.</param>
        public VisualPopup(ViewManager viewManager,
                           IRenderer renderer,
                           bool shadow)
        {
            #region Default ControlStyle Values
            // Default style values for Control are:-
            //    True  - AllPaintingInWmPaint
            //    False - CacheText
            //    False - ContainerControl
            //    False - EnableNotifyMessage
            //    False - FixedHeight
            //    False - FixedWidth
            //    False - Opaque
            //    False - OptimizedDoubleBuffer
            //    False - ResizeRedraw
            //    False - Selectable
            //    True  - StandardClick
            //    True  - StandardDoubleClick
            //    False - SupportsTransparentBackColor
            //    False - UserMouse
            //    True  - UserPaint
            //    True  - UseTextForAccessibility
            #endregion

            // 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);

            // Cannot select control by using mouse to click it
            SetStyle(ControlStyles.Selectable, false);

            // Cache incoming references
            Renderer    = renderer;
            ViewManager = viewManager;

            // Setup the need paint delegate
            NeedPaintDelegate = OnNeedPaint;

            // Setup the invokes
            _refreshCall = OnPerformRefresh;

            // Default other properties
            _layoutDirty = true;
            _refresh     = true;

            // Create the shadow control
            if (shadow)
            {
                _shadow = new VisualPopupShadow();
            }
        }