示例#1
0
        protected override void onDraw(Cairo.Context gr)
        {
            gr.Save();

            Rectangle rBack = new Rectangle(Slot.Size);

            Background.SetAsSource(gr, rBack);
            CairoHelpers.CairoRectangle(gr, rBack, CornerRadius);
            gr.Fill();

            if (ClipToClientRect)
            {
                //clip to client zone
                CairoHelpers.CairoRectangle(gr, ClientRectangle, CornerRadius);
                gr.Clip();
            }

            childrenRWLock.EnterReadLock();

            foreach (GraphicObject g in Children)
            {
                g.Paint(ref gr);
            }

            childrenRWLock.ExitReadLock();


            if (!IsDropTarget)
            {
                gr.Restore();
                return;
            }

            DockWindow dw = IFace.DragAndDropOperation.DragSource as DockWindow;

            if (dw == null)
            {
                return;
            }
            if (!dw.IsDocked)
            {
                Rectangle cb     = ClientRectangle;
                double    minDim = Math.Min(cb.Width, cb.Height);

                Rectangle r = rIn;
                if (Children.Count <= 1 || dw.DockingPosition.GetOrientation() == Orientation)
                {
                    r = cb;
                }

                switch (dw.DockingPosition)
                {
                case Alignment.Top:
                    gr.Rectangle(r.Left, r.Top, r.Width, r.Height * dockThresh);
                    break;

                case Alignment.Bottom:
                    gr.Rectangle(r.Left, r.Bottom - r.Height * dockThresh, r.Width, r.Height * dockThresh);
                    break;

                case Alignment.Left:
                    gr.Rectangle(r.Left, r.Top, r.Width * dockThresh, r.Height);
                    break;

                case Alignment.Right:
                    gr.Rectangle(r.Right - r.Width * dockThresh, r.Top, r.Width * dockThresh, r.Height);
                    break;

                case Alignment.Center:
                    r.Inflate((int)Math.Ceiling(Math.Min(r.Width, r.Height) * -0.05));
                    gr.Rectangle(r);
                    break;
                }
                gr.LineWidth = 1;
                gr.SetSourceRGBA(0.4, 0.4, 0.9, 0.4);
                gr.FillPreserve();
                gr.SetSourceRGBA(0.9, 0.9, 1.0, 0.8);
                gr.Stroke();
            }
            gr.Restore();
        }
示例#2
0
        public override void onMouseMove(object sender, MouseMoveEventArgs e)
        {
            if (IsDropTarget)
            {
                DockWindow dw = IFace.DragAndDropOperation.DragSource as DockWindow;
                if (dw.IsDocked)
                {
                    base.onMouseMove(sender, e);
                    return;
                }

                Alignment curDockPos = dw.DockingPosition;
                dw.DockingPosition = Alignment.Undefined;

                Rectangle cb = ClientRectangle;
                Point     lm = ScreenPointToLocal(e.Position);

                if (Children.Count == 0)
                {
                    Rectangle r = cb;
                    r.Inflate(r.Width / -5, r.Height / -5);
                    if (r.ContainsOrIsEqual(lm))
                    {
                        dw.DockingPosition = Alignment.Center;
                    }
                }
                else
                {
                    rIn = cb;

                    if (Orientation == Orientation.Horizontal || Children.Count == 1)
                    {
                        if (lm.Y > cb.Top + cb.Height / 3 && lm.Y < cb.Bottom - cb.Height / 3)
                        {
                            if (lm.X < cb.Left + cb.Width / 3)
                            {
                                dw.DockingPosition = Alignment.Left;
                            }
                            else if (lm.X > cb.Right - cb.Width / 3)
                            {
                                dw.DockingPosition = Alignment.Right;
                            }
                        }
                        else
                        {
                            getFocusedChild(lm);
                            if (focusedChild != null)
                            {
                                if (lm.Y < rIn.Top + rIn.Height / 3)
                                {
                                    dw.DockingPosition = Alignment.Top;
                                }
                                else if (lm.Y > rIn.Bottom - rIn.Height / 3)
                                {
                                    dw.DockingPosition = Alignment.Bottom;
                                }
                            }
                        }
                    }
                    if (Orientation == Orientation.Vertical || Children.Count == 1)
                    {
                        if (lm.X > cb.Left + cb.Width / 3 && lm.X < cb.Right - cb.Width / 3)
                        {
                            if (lm.Y < cb.Top + cb.Height / 3)
                            {
                                dw.DockingPosition = Alignment.Top;
                            }
                            else if (lm.Y > cb.Bottom - cb.Height / 3)
                            {
                                dw.DockingPosition = Alignment.Bottom;
                            }
                        }
                        else
                        {
                            getFocusedChild(lm);
                            if (focusedChild != null)
                            {
                                if (lm.X < rIn.Left + rIn.Width / 3)
                                {
                                    dw.DockingPosition = Alignment.Left;
                                }
                                else if (lm.X > rIn.Right - rIn.Width / 3)
                                {
                                    dw.DockingPosition = Alignment.Right;
                                }
                            }
                        }
                    }
                }

                if (curDockPos != dw.DockingPosition)
                {
                    RegisterForGraphicUpdate();
                }
            }
            base.onMouseMove(sender, e);
        }