/// <summary> /// Initialize a new instance of the DropDockingIndicatorsSquare class. /// </summary> /// <param name="paletteDragDrop">Drawing palette.</param> /// <param name="renderer">Drawing renderer.</param> /// <param name="showLeft">Show left hot area.</param> /// <param name="showRight">Show right hot area.</param> /// <param name="showTop">Show top hot area.</param> /// <param name="showBottom">Show bottom hot area.</param> /// <param name="showMiddle">Show middle hot area.</param> public DropDockingIndicatorsSquare(IPaletteDragDrop paletteDragDrop, IRenderer renderer, bool showLeft, bool showRight, bool showTop, bool showBottom, bool showMiddle) { _paletteDragDrop = paletteDragDrop; _renderer = renderer; // Initialize the drag data that indicators which docking indicators are needed _dragData = new RenderDragDockingData(showLeft, showRight, showTop, showBottom, showMiddle); // Ask the renderer to measure the sizing of the indicators that are displayed _renderer.RenderGlyph.MeasureDragDropDockingGlyph(_dragData, _paletteDragDrop, PaletteDragFeedback.Square); // Setup window so that it is transparent to the Silver color and does not have any borders etc... BackColor = Color.Silver; ClientSize = _dragData.DockWindowSize; ControlBox = false; FormBorderStyle = FormBorderStyle.None; Location = new Point(100, 200); MaximizeBox = false; MinimizeBox = false; MinimumSize = Size.Empty; Name = "DropIndicators"; ShowInTaskbar = false; SizeGripStyle = SizeGripStyle.Hide; StartPosition = FormStartPosition.Manual; Text = "DropIndicators"; TransparencyKey = Color.Silver; Paint += DropIndicators_Paint; }
/// <summary> /// Initialize a new instance of the DropDockingIndicatorsSquare class. /// </summary> /// <param name="paletteDragDrop">Drawing palette.</param> /// <param name="renderer">Drawing renderer.</param> /// <param name="showLeft">Show left hot area.</param> /// <param name="showRight">Show right hot area.</param> /// <param name="showTop">Show top hot area.</param> /// <param name="showBottom">Show bottom hot area.</param> /// <param name="showMiddle">Show middle hot area.</param> public DropDockingIndicatorsSquare(IPaletteDragDrop paletteDragDrop, IRenderer renderer, bool showLeft, bool showRight, bool showTop, bool showBottom, bool showMiddle) { _paletteDragDrop = paletteDragDrop; _renderer = renderer; // Initialize the drag data that indicators which docking indicators are needed _dragData = new RenderDragDockingData(showLeft, showRight, showTop, showBottom, showMiddle); // Ask the renderer to measure the sizing of the indicators that are displayed _renderer.RenderGlyph.MeasureDragDropDockingGlyph(_dragData, _paletteDragDrop, PaletteDragFeedback.Square); // Setup window so that it is transparent to the Silver color and does not have any borders etc... BackColor = Color.Silver; ClientSize = _dragData.DockWindowSize; ControlBox = false; FormBorderStyle = FormBorderStyle.None; Location = new Point(100, 200); MaximizeBox = false; MinimizeBox = false; MinimumSize = Size.Empty; Name = "DropIndicators"; ShowInTaskbar = false; SizeGripStyle = SizeGripStyle.Hide; StartPosition = FormStartPosition.Manual; Text = "DropIndicators"; TransparencyKey = System.Drawing.Color.Silver; Paint += new PaintEventHandler(DropIndicators_Paint); }
/// <summary> /// Initialize a new instance of the DockCluster class. /// </summary> /// <param name="paletteDragDrop">Drawing palette.</param> /// <param name="renderer">Drawing renderer.</param> /// <param name="target">Initial target for the cluster.</param> public DockCluster(IPaletteDragDrop paletteDragDrop, IRenderer renderer, DragTarget target) { _paletteDragDrop = paletteDragDrop; _renderer = renderer; _screenRect = target.ScreenRect; _drawRect = target.DrawRect; _hintToTarget = new HintToTarget(); _hintToTarget.Add(target.Hint & DragTargetHint.ExcludeFlags, target); _excludeCluster = (target.Hint & DragTargetHint.ExcludeCluster) == DragTargetHint.ExcludeCluster; }
/// <summary> /// Called to initialize the implementation when dragging starts. /// </summary> /// <param name="paletteDragDrop">Drawing palette.</param> /// <param name="renderer">Drawing renderer.</param> /// <param name="pageDragEndData">Drag data associated with drag operation.</param> /// <param name="dragTargets">List of all drag targets.</param> public virtual void Start(IPaletteDragDrop paletteDragDrop, IRenderer renderer, PageDragEndData pageDragEndData, DragTargetList dragTargets) { Debug.Assert(paletteDragDrop != null); Debug.Assert(renderer != null); Debug.Assert(pageDragEndData != null); Debug.Assert(dragTargets != null); _paletteDragDrop = paletteDragDrop; _renderer = renderer; _pageDragEndData = pageDragEndData; _dragTargets = dragTargets; }
/// <summary> /// Initialize a new instance of the DropSolidWindow class. /// </summary> /// <param name="paletteDragDrop">Drawing palette.</param> /// <param name="renderer">Drawing renderer.</param> public DropSolidWindow(IPaletteDragDrop paletteDragDrop, IRenderer renderer) { _paletteDragDrop = paletteDragDrop; _renderer = renderer; FormBorderStyle = FormBorderStyle.None; SizeGripStyle = SizeGripStyle.Hide; StartPosition = FormStartPosition.Manual; MaximizeBox = false; MinimizeBox = false; ShowInTaskbar = false; BackColor = Color.Magenta; TransparencyKey = Color.Magenta; Opacity = _paletteDragDrop.GetDragDropSolidOpacity(); }
/// <summary> /// Called to initialize the implementation when dragging starts. /// </summary> /// <param name="paletteDragDrop">Drawing palette.</param> /// <param name="renderer">Drawing renderer.</param> /// <param name="pageDragEndData">Drag data associated with drag operation.</param> /// <param name="dragTargets">List of all drag targets.</param> public override void Start(IPaletteDragDrop paletteDragDrop, IRenderer renderer, PageDragEndData pageDragEndData, DragTargetList dragTargets) { base.Start(paletteDragDrop, renderer, pageDragEndData, dragTargets); if (_solid == null) { // Create and show a window without it taking focus _solid = new DropSolidWindow(PaletteDragDrop, Renderer); _solid.SetBounds(0, 0, 1, 1, BoundsSpecified.All); _solid.ShowWithoutActivate(); _solid.Refresh(); } }
/// <summary> /// Initialize a new instance of the DropDockingIndicatorsRounded class. /// </summary> /// <param name="paletteDragDrop">Drawing palette.</param> /// <param name="renderer">Drawing renderer.</param> /// <param name="showLeft">Show left hot area.</param> /// <param name="showRight">Show right hot area.</param> /// <param name="showTop">Show top hot area.</param> /// <param name="showBottom">Show bottom hot area.</param> /// <param name="showMiddle">Show middle hot area.</param> public DropDockingIndicatorsRounded(IPaletteDragDrop paletteDragDrop, IRenderer renderer, bool showLeft, bool showRight, bool showTop, bool showBottom, bool showMiddle) { _paletteDragDrop = paletteDragDrop; _renderer = renderer; // Initialize the drag data that indicators which docking indicators are needed _dragData = new RenderDragDockingData(showLeft, showRight, showTop, showBottom, showMiddle); // Ask the renderer to measure the sizing of the indicators that are displayed _renderer.RenderGlyph.MeasureDragDropDockingGlyph(_dragData, _paletteDragDrop, PaletteDragFeedback.Rounded); _showRect = new Rectangle(Point.Empty, _dragData.DockWindowSize); // Any old title will do as it will not be shown CreateParams cp = new CreateParams { Caption = "DropDockingIndicatorsRounded", // Define the screen position/size X = _showRect.X, Y = _showRect.Y, Height = _showRect.Width, Width = _showRect.Height, // As a top-level window it has no parent Parent = IntPtr.Zero, // Appear as a top-level window Style = unchecked ((int)PI.WS_.POPUP), // Set styles so that it does not have a caption bar and is above all other // windows in the ZOrder, i.e. TOPMOST ExStyle = PI.WS_EX_.TOPMOST | PI.WS_EX_.TOOLWINDOW }; // We are going to use per-pixel alpha blending and so need a layered window cp.ExStyle |= PI.WS_EX_.LAYERED; // Create the actual window CreateHandle(cp); }
/// <summary> /// Initialize a new instance of the DropDockingIndicatorsRounded class. /// </summary> /// <param name="paletteDragDrop">Drawing palette.</param> /// <param name="renderer">Drawing renderer.</param> /// <param name="showLeft">Show left hot area.</param> /// <param name="showRight">Show right hot area.</param> /// <param name="showTop">Show top hot area.</param> /// <param name="showBottom">Show bottom hot area.</param> /// <param name="showMiddle">Show middle hot area.</param> public DropDockingIndicatorsRounded(IPaletteDragDrop paletteDragDrop, IRenderer renderer, bool showLeft, bool showRight, bool showTop, bool showBottom, bool showMiddle) { _paletteDragDrop = paletteDragDrop; _renderer = renderer; // Initialize the drag data that indicators which docking indicators are needed _dragData = new RenderDragDockingData(showLeft, showRight, showTop, showBottom, showMiddle); // Ask the renderer to measure the sizing of the indicators that are displayed _renderer.RenderGlyph.MeasureDragDropDockingGlyph(_dragData, _paletteDragDrop, PaletteDragFeedback.Rounded); _showRect = new Rectangle(Point.Empty, _dragData.DockWindowSize); // Any old title will do as it will not be shown CreateParams cp = new CreateParams(); cp.Caption = "DropDockingIndicatorsRounded"; // Define the screen position/size cp.X = _showRect.X; cp.Y = _showRect.Y; cp.Height = _showRect.Width; cp.Width = _showRect.Height; // As a top-level window it has no parent cp.Parent = IntPtr.Zero; // Appear as a top-level window cp.Style = unchecked((int)(uint)PI.WS_POPUP); // Set styles so that it does not have a caption bar and is above all other // windows in the ZOrder, i.e. TOPMOST cp.ExStyle = (int)PI.WS_EX_TOPMOST + (int)PI.WS_EX_TOOLWINDOW; // We are going to use per-pixrl alpha blending and so need a layered window cp.ExStyle += (int)PI.WS_EX_LAYERED; // Create the actual window this.CreateHandle(cp); }
/// <summary> /// Called to initialize the implementation when dragging starts. /// </summary> /// <param name="paletteDragDrop">Drawing palette.</param> /// <param name="renderer">Drawing renderer.</param> /// <param name="pageDragEndData">Drag data associated with drag operation.</param> /// <param name="dragTargets">List of all drag targets.</param> public override void Start(IPaletteDragDrop paletteDragDrop, IRenderer renderer, PageDragEndData pageDragEndData, DragTargetList dragTargets) { base.Start(paletteDragDrop, renderer, pageDragEndData, dragTargets); if (_solid == null) { // Create and show a solid feedback window without it taking focus _solid = new DropSolidWindow(PaletteDragDrop, Renderer); _solid.SetBounds(0, 0, 1, 1, BoundsSpecified.All); _solid.ShowWithoutActivate(); _solid.Refresh(); } ClearClusters(); // Create clusters of related drag targets foreach (DragTarget target in dragTargets) { // Check if the target is actually able to drop inside itself if (target.IsMatch(target.HotRect.Location, pageDragEndData)) { // Find the existing cluster for the targets screen rectangle DockCluster cluster = FindTargetCluster(target); // Is the target allowed to be added to the found cluster (if there is one found) if ((cluster == null) || cluster.ExcludeCluster || ((target.Hint & DragTargetHint.ExcludeCluster) == DragTargetHint.ExcludeCluster)) { _clusters.Add(new DockCluster(PaletteDragDrop, Renderer, target)); } else { cluster.Add(target); } } } }
private void MeasureDragDockingSquares(RenderDragDockingData dragData, IPaletteDragDrop dragDropPalette) { dragData.DockWindowSize = new Size(88, 88); if (dragData.ShowMiddle) { dragData.RectLeft = new Rectangle(0, 29, 29, 29); dragData.RectRight = new Rectangle(59, 29, 29, 29); dragData.RectTop = new Rectangle(29, 0, 29, 29); dragData.RectBottom = new Rectangle(29, 59, 29, 29); dragData.RectMiddle = new Rectangle(23, 23, 40, 40); } else { dragData.RectLeft = new Rectangle(0, 29, 32, 29); dragData.RectRight = new Rectangle(56, 29, 32, 29); dragData.RectTop = new Rectangle(29, 0, 29, 32); dragData.RectBottom = new Rectangle(29, 56, 29, 31); } }
/// <summary> /// Draw a solid area glyph suitable for a drag drop area. /// </summary> /// <param name="context">Render context.</param> /// <param name="drawRect">Drawing rectangle space.</param> /// <param name="dragDropPalette">Palette source of drawing values.</param> public override void DrawDragDropSolidGlyph(RenderContext context, Rectangle drawRect, IPaletteDragDrop dragDropPalette) { Debug.Assert(context != null); Debug.Assert(dragDropPalette != null); using(SolidBrush backBrush = new SolidBrush(dragDropPalette.GetDragDropSolidBack())) context.Graphics.FillRectangle(backBrush, drawRect); using (Pen borderPen = new Pen(dragDropPalette.GetDragDropSolidBorder())) context.Graphics.DrawRectangle(borderPen, drawRect); }
/// <summary> /// Draw a solid area glyph suitable for a drag drop area. /// </summary> /// <param name="context">Render context.</param> /// <param name="drawRect">Drawing rectangle space.</param> /// <param name="dragDropPalette">Palette source of drawing values.</param> public abstract void DrawDragDropSolidGlyph(RenderContext context, Rectangle drawRect, IPaletteDragDrop dragDropPalette);
private void MeasureDragDockingRounded(RenderDragDockingData dragData, IPaletteDragDrop dragDropPalette) { dragData.DockWindowSize = new Size(103, 103); dragData.RectLeft = new Rectangle(0, 36, 32, 31); dragData.RectRight = new Rectangle(71, 36, 32, 31); dragData.RectTop = new Rectangle(36, 0, 31, 32); dragData.RectBottom = new Rectangle(36, 71, 31, 32); dragData.RectMiddle = new Rectangle(36, 36, 31, 31); }
private void DrawDragDockingSquares(RenderContext context, RenderDragDockingData dragData, IPaletteDragDrop dragDropPalette) { Color back = dragDropPalette.GetDragDropDockBack(); Color border = dragDropPalette.GetDragDropDockBorder(); Color active = dragDropPalette.GetDragDropDockActive(); Color inactive = dragDropPalette.GetDragDropDockInactive(); DrawDragDockingSquaresBackground(context.Graphics, back, border, dragData); if (dragData.ShowLeft) DrawDragDockingSquaresLeft(context.Graphics, active, inactive, dragData); if (dragData.ShowRight) DrawDragDockingSquaresRight(context.Graphics, active, inactive, dragData); if (dragData.ShowTop) DrawDragDockingSquaresTop(context.Graphics, active, inactive, dragData); if (dragData.ShowBottom) DrawDragDockingSquaresBottom(context.Graphics, active, inactive, dragData); if (dragData.ShowMiddle) DrawDragDockingSquaresMiddle(context.Graphics, active, inactive, dragData); }
/// <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);
/// <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); }
/// <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);
/// <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); }