private void ToolBarMouseUp(object sender, MouseEventArgs e) { if(_dragged != null) { _dragged = null; _ptOffset.X = 8; _ptOffset.Y = 8; } }
public ToolBarDockHolder AddControl(Control c, DockStyle site, Control refControl, DockStyle refSite) { if(site == DockStyle.Fill) site = DockStyle.Top; ToolBarDockHolder holder = new ToolBarDockHolder(this, c, site); if(refControl != null) { ToolBarDockHolder refHolder = GetHolder(refControl); if(refHolder != null) { Point p = refHolder.PreferredDockedLocation; if(refSite == DockStyle.Left) { p.X -= 1; } else if(refSite == DockStyle.Right) { p.X += refHolder.Width+1; } else if(refSite == DockStyle.Bottom) { p.Y += refHolder.Height+1; } else { p.Y -= 1; } holder.PreferredDockedLocation = p; } } _holders.Add(holder); if(site != DockStyle.None) { holder.DockStyle = site; holder.Parent = holder.PreferredDockedArea; } else { holder.Parent = holder.FloatForm; holder.Location = new Point(0,0); holder.DockStyle = DockStyle.None; holder.FloatForm.Size = holder.Size; holder.FloatForm.Visible = true; } holder.MouseUp += new MouseEventHandler(this.ToolBarMouseUp); holder.DoubleClick += new EventHandler(this.ToolBarDoubleClick); holder.MouseMove += new MouseEventHandler(this.ToolBarMouseMove); holder.MouseDown += new MouseEventHandler(this.ToolBarMouseDown); return holder; }
private bool IsDocked(ToolBarDockHolder holder) { return holder.Parent == Top || holder.Parent == Left || holder.Parent == Right || holder.Parent == Bottom; }
private void ToolBarMouseDown(object sender, MouseEventArgs e) { ToolBarDockHolder holder = (ToolBarDockHolder)sender; if(_dragged==null && e.Button.Equals(MouseButtons.Left) && e.Clicks == 1 && holder.CanDrag(new Point(e.X, e.Y)) ) { _ptStart = Control.MousePosition; _dragged = (ToolBarDockHolder)sender; _ptOffset = new Point(e.X, e.Y); } }
private ToolBarDockArea GetDockedArea(ToolBarDockHolder holder) { if(holder.Parent == Top) return Top; if(holder.Parent == Left) return Left; if(holder.Parent == Right) return Right; if(holder.Parent == Bottom) return Bottom; return null; }
public ColumnHolder(int pos, ToolBarDockHolder holder, int size) { Position = pos; Holder = holder; Size = size; }
protected int GetPreferredPosition(ToolBarDockHolder holder) { if(Horizontal) return holder.PreferredDockedLocation.X; else return holder.PreferredDockedLocation.Y; }
protected int GetPreferredLine(int lineSz, ToolBarDockHolder holder) { int pos, sz; if(Horizontal) { pos = holder.PreferredDockedLocation.Y; sz = holder.Size.Height; if(pos < 0) return Int32.MinValue; if(pos > this.Height) return Int32.MaxValue; } else { pos = holder.PreferredDockedLocation.X; sz = holder.Size.Width; if(pos < 0) return Int32.MinValue; if(pos > this.Width) return Int32.MaxValue; } int line = pos / lineSz; int posLine = line * lineSz; if(posLine + 3 > pos) return line*2; if(posLine + lineSz - 3 < pos) return line*2+2; return line*2 + 1; }
protected int GetHolderWidth(ToolBarDockHolder holder) { if(Horizontal) return holder.Width; else return holder.Height; }