/// <summary>
            /// Update visual feedback based on the current screen position of the mouse.
            /// </summary>
            /// <param name="screenPt">Latest mouse screen position.</param>
            /// <param name="dragFeedback">Type of drag feedback required.</param>
            public DragTarget Feedback(Point screenPt, PaletteDragFeedback dragFeedback)
            {
                if (ScreenRect.Contains(screenPt))
                {
                    // Create the docking indicators the first time needed
                    _indicators ??= dragFeedback switch
                    {
                        PaletteDragFeedback.Rounded => new DropDockingIndicatorsRounded(_paletteDragDrop, _renderer,
                                                                                        _hintToTarget.ContainsKey(DragTargetHint.EdgeLeft),
                                                                                        _hintToTarget.ContainsKey(DragTargetHint.EdgeRight),
                                                                                        _hintToTarget.ContainsKey(DragTargetHint.EdgeTop),
                                                                                        _hintToTarget.ContainsKey(DragTargetHint.EdgeBottom),
                                                                                        _hintToTarget.ContainsKey(DragTargetHint.Transfer)),
                        _ => new DropDockingIndicatorsSquare(_paletteDragDrop, _renderer,
                                                             _hintToTarget.ContainsKey(DragTargetHint.EdgeLeft),
                                                             _hintToTarget.ContainsKey(DragTargetHint.EdgeRight),
                                                             _hintToTarget.ContainsKey(DragTargetHint.EdgeTop),
                                                             _hintToTarget.ContainsKey(DragTargetHint.EdgeBottom),
                                                             _hintToTarget.ContainsKey(DragTargetHint.Transfer))
                    };

                    // Ensure window is Displayed in correct location
                    _indicators.ShowRelative(ScreenRect);

                    // Hit test against indicators and update display
                    return(_indicators.ScreenMouseMove(screenPt) switch
                    {
                        0x0040 => _hintToTarget[DragTargetHint.EdgeLeft],
                        0x0080 => _hintToTarget[DragTargetHint.EdgeRight],
                        0x0100 => _hintToTarget[DragTargetHint.EdgeTop],
                        0x0200 => _hintToTarget[DragTargetHint.EdgeBottom],
                        0x0400 => _hintToTarget[DragTargetHint.Transfer],
                        _ => null // Mouse is not over any of the targets
                    });
Пример #2
0
        /// <summary>
        /// Initialize a new instance of the PaletteBase class.
        /// </summary>
        public PaletteBase()
        {
            // We need to notice when system color settings change
            SystemEvents.UserPreferenceChanged += new UserPreferenceChangedEventHandler(OnUserPreferenceChanged);

            // Inherit means we need to calculate the value next time it is requested
            _dragFeedback = PaletteDragFeedback.Inherit;
        }
        /// <summary>
        /// Initialize a new instance of the PaletteDragDrop class.
        /// </summary>
        /// <param name="inherit">Source for inheriting values.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public PaletteDragDrop(IPalette inherit,
                               NeedPaintHandler needPaint)
        {
            // Remember inheritance
            _inherit = inherit;

            // Store the provided paint notification delegate
            NeedPaint = needPaint;

            // Set default values
            _feedback         = PaletteDragFeedback.Inherit;
            _solidBack        = Color.Empty;
            _solidBorder      = Color.Empty;
            _solidOpacity     = -1.0f;
            _dropDockBack     = Color.Empty;
            _dropDockBorder   = Color.Empty;
            _dropDockActive   = Color.Empty;
            _dropDockInactive = Color.Empty;
        }
Пример #4
0
        /// <summary>
        /// Initialize a new instance of the PaletteDragDrop class.
        /// </summary>
        /// <param name="inherit">Source for inheriting values.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public PaletteDragDrop(IPalette inherit,
                               NeedPaintHandler needPaint)
        {
            // Remember inheritance
            _inherit = inherit;

            // Store the provided paint notification delegate
            NeedPaint = needPaint;

            // Set default values
            _feedback = PaletteDragFeedback.Inherit;
            _solidBack = Color.Empty;
            _solidBorder = Color.Empty;
            _solidOpacity = -1.0f;
            _dropDockBack = Color.Empty;
            _dropDockBorder = Color.Empty;
            _dropDockActive = Color.Empty;
            _dropDockInactive = Color.Empty;
        }
Пример #5
0
        private void ResolveDragFeedback()
        {
            ClearDragFeedback();

            // Start with the provided value
            PaletteDragFeedback dragFeedback = _stateCommon.GetDragDropFeedback();

            // Should never be 'inherit'
            if (dragFeedback == PaletteDragFeedback.Inherit)
            {
                dragFeedback = PaletteDragFeedback.Rounded;
            }

            // Check if the rounded style is possible
            if (dragFeedback == PaletteDragFeedback.Rounded)
            {
                // Rounded feedback uses a per-pixel alpha blending and so we need to be on a machine that supports
                // more than 256 colors and also allows the layered windows feature. If not then revert to sqaures
                if ((OSFeature.Feature.GetVersionPresent(OSFeature.LayeredWindows) == null) || (CommonHelper.ColorDepth() <= 8))
                {
                    dragFeedback = PaletteDragFeedback.Square;
                }
            }

            switch (dragFeedback)
            {
            case PaletteDragFeedback.Rounded:
            case PaletteDragFeedback.Square:
                _dragFeedback = new DragFeedbackDocking(dragFeedback);
                break;

            default:
                _dragFeedback = new DragFeedbackSolid();
                break;
            }
        }
Пример #6
0
 /// <summary>
 /// Measure the drag and drop docking glyphs.
 /// </summary>
 /// <param name="dragData">Set of drag docking data.</param>
 /// <param name="dragDropPalette">Palette source of drawing values.</param>
 /// <param name="feedback">Feedback requested.</param>
 public abstract void MeasureDragDropDockingGlyph(RenderDragDockingData dragData,
                                                  IPaletteDragDrop dragDropPalette,
                                                  PaletteDragFeedback feedback);
Пример #7
0
 /// <summary>
 /// Draw a solid area glyph suitable for a drag drop area.
 /// </summary>
 /// <param name="context">Render context.</param>
 /// <param name="dragData">Set of drag docking data.</param>
 /// <param name="dragDropPalette">Palette source of drawing values.</param>
 /// <param name="feedback">Feedback requested.</param>
 public abstract void DrawDragDropDockingGlyph(RenderContext context,
                                               RenderDragDockingData dragData,
                                               IPaletteDragDrop dragDropPalette,
                                               PaletteDragFeedback feedback);
Пример #8
0
 /// <summary>
 /// Initialize a new instance of the DockCluster class.
 /// </summary>
 /// <param name="dragFeedback">Type of drag feedback required.</param>
 public DragFeedbackDocking(PaletteDragFeedback dragFeedback)
 {
     _clusters     = new DockClusterList();
     _dragFeedback = dragFeedback;
 }
Пример #9
0
            /// <summary>
            /// Update visual feedback based on the current screen position of the mouse.
            /// </summary>
            /// <param name="screenPt">Latest mouse screen position.</param>
            /// <param name="dragFeedback">Type of drag feedback required.</param>
            public DragTarget Feedback(Point screenPt, PaletteDragFeedback dragFeedback)
            {
                if (ScreenRect.Contains(screenPt))
                {
                    // Create the docking indicators the first time needed
                    if (_indicators == null)
                    {
                        switch (dragFeedback)
                        {
                        case PaletteDragFeedback.Rounded:
                            _indicators = new DropDockingIndicatorsRounded(_paletteDragDrop, _renderer,
                                                                           _hintToTarget.ContainsKey(DragTargetHint.EdgeLeft),
                                                                           _hintToTarget.ContainsKey(DragTargetHint.EdgeRight),
                                                                           _hintToTarget.ContainsKey(DragTargetHint.EdgeTop),
                                                                           _hintToTarget.ContainsKey(DragTargetHint.EdgeBottom),
                                                                           _hintToTarget.ContainsKey(DragTargetHint.Transfer));
                            break;

                        case PaletteDragFeedback.Square:
                        default:
                            _indicators = new DropDockingIndicatorsSquare(_paletteDragDrop, _renderer,
                                                                          _hintToTarget.ContainsKey(DragTargetHint.EdgeLeft),
                                                                          _hintToTarget.ContainsKey(DragTargetHint.EdgeRight),
                                                                          _hintToTarget.ContainsKey(DragTargetHint.EdgeTop),
                                                                          _hintToTarget.ContainsKey(DragTargetHint.EdgeBottom),
                                                                          _hintToTarget.ContainsKey(DragTargetHint.Transfer));
                            break;
                        }
                    }

                    // Ensure window is displayed in correct location
                    _indicators.ShowRelative(ScreenRect);

                    // Hit test against indicators and update display
                    switch (_indicators.ScreenMouseMove(screenPt))
                    {
                    case 0x0040:
                        return(_hintToTarget[DragTargetHint.EdgeLeft]);

                    case 0x0080:
                        return(_hintToTarget[DragTargetHint.EdgeRight]);

                    case 0x0100:
                        return(_hintToTarget[DragTargetHint.EdgeTop]);

                    case 0x0200:
                        return(_hintToTarget[DragTargetHint.EdgeBottom]);

                    case 0x0400:
                        return(_hintToTarget[DragTargetHint.Transfer]);

                    default:
                        // Mouse is not over any of the targets
                        return(null);
                    }
                }
                else
                {
                    if (_indicators != null)
                    {
                        _indicators.MouseReset();
                        _indicators.Hide();
                    }

                    // Mouse is not over any of the targets
                    return(null);
                }
            }
Пример #10
0
        /// <summary>
        /// Draw a solid area glyph suitable for a drag drop area.
        /// </summary>
        /// <param name="context">Render context.</param>
        /// <param name="dragData">Set of drag docking data.</param>
        /// <param name="dragDropPalette">Palette source of drawing values.</param>
        /// <param name="feedback">Feedback requested.</param>
        public override void DrawDragDropDockingGlyph(RenderContext context,
                                                      RenderDragDockingData dragData,
                                                      IPaletteDragDrop dragDropPalette,
                                                      PaletteDragFeedback feedback)
        {
            Debug.Assert(context != null);
            Debug.Assert(dragData != null);
            Debug.Assert(dragDropPalette != null);

            if (feedback == PaletteDragFeedback.Rounded)
                DrawDragDockingRounded(context, dragData, dragDropPalette);
            else
                DrawDragDockingSquares(context, dragData, dragDropPalette);
        }
Пример #11
0
        /// <summary>
        /// Measure the drag and drop docking glyphs.
        /// </summary>
        /// <param name="dragData">Set of drag docking data.</param>
        /// <param name="dragDropPalette">Palette source of drawing values.</param>
        /// <param name="feedback">Feedback requested.</param>
        public override void MeasureDragDropDockingGlyph(RenderDragDockingData dragData,
                                                         IPaletteDragDrop dragDropPalette,
                                                         PaletteDragFeedback feedback)
        {
            Debug.Assert(dragData != null);
            Debug.Assert(dragDropPalette != null);

            if (feedback == PaletteDragFeedback.Rounded)
                MeasureDragDockingRounded(dragData, dragDropPalette);
            else
                MeasureDragDockingSquares(dragData, dragDropPalette);
        }
Пример #12
0
 /// <summary>
 /// Resets the Feedback property to its default value.
 /// </summary>
 public void ResetFeedback()
 {
     Feedback = PaletteDragFeedback.Inherit;
 }
Пример #13
0
        /// <summary>
        /// Gets the feedback drawing method used.
        /// </summary>
        /// <returns>Feedback enumeration value.</returns>
        public virtual PaletteDragFeedback GetDragDropFeedback()
        {
            // Do we need to calculate the feedback value again?
            if (_dragFeedback == PaletteDragFeedback.Inherit)
            {
                // We default to using rounded feedback on Vista upwards and square on earlier versions
                _dragFeedback = (Environment.OSVersion.Version.Major >= 6 ? PaletteDragFeedback.Rounded : PaletteDragFeedback.Square);

                // If trying to use rounded feedback...
                if (_dragFeedback == PaletteDragFeedback.Rounded)
                {
                    // Rounded feedback uses a per-pixel alpha blending and so we need to be on a machine that supports
                    // more than 256 colors and also allows the layered windows feature. If not then revert to sqaures
                    if ((OSFeature.Feature.GetVersionPresent(OSFeature.LayeredWindows) == null) || (CommonHelper.ColorDepth() <= 8))
                        _dragFeedback = PaletteDragFeedback.Square;
                }
            }

            return _dragFeedback;
        }
Пример #14
0
 /// <summary>
 /// Handle a change in the user preferences.
 /// </summary>
 /// <param name="sender">Source of event.</param>
 /// <param name="e">Event data.</param>
 protected virtual void OnUserPreferenceChanged(object sender, UserPreferenceChangedEventArgs e)
 {
     _inputControlPadding = null;
     _dragFeedback = PaletteDragFeedback.Inherit;
 }