Beispiel #1
0
 private bool IsDocked(ToolBarDockHolder holder)
 {
     return(holder.Parent == Top ||
            holder.Parent == Left ||
            holder.Parent == Right ||
            holder.Parent == Bottom);
 }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        private void ToolBarDoubleClick(object sender, System.EventArgs e)
        {
            ToolBarDockHolder holder = (ToolBarDockHolder)sender;

            if (IsDocked(holder))
            {
                ToolBarDockArea docked = GetDockedArea(holder);
                docked.SuspendLayout();
                holder.Parent            = holder.FloatForm;
                holder.Location          = new Point(0, 0);
                holder.DockStyle         = DockStyle.None;
                holder.FloatForm.Visible = true;
                holder.FloatForm.Size    = holder.Size;
                docked.ResumeLayout();
                docked.PerformLayout();
            }
            else
            {
                ToolBarDockArea area = holder.PreferredDockedArea;
                area.SuspendLayout();
                Point newLoc = holder.PreferredDockedLocation;
                holder.DockStyle = area.Dock;
                holder.Parent    = area;
                holder.PreferredDockedLocation = newLoc;
                holder.FloatForm.Visible       = false;
                holder.PreferredDockedArea     = area;
                area.ResumeLayout();
                area.PerformLayout();
            }
        }
Beispiel #4
0
            public int Compare(object x, object y)
            {
                ToolBarDockHolder h1 = x as ToolBarDockHolder;
                ToolBarDockHolder h2 = y as ToolBarDockHolder;

                return(h1.ToolbarTitle.CompareTo(h2.ToolbarTitle));
            }
Beispiel #5
0
 private void ToolBarMouseUp(object sender, MouseEventArgs e)
 {
     if (_dragged != null)
     {
         _dragged    = null;
         _ptOffset.X = 8;
         _ptOffset.Y = 8;
     }
 }
 protected int GetHolderWidth(ToolBarDockHolder holder)
 {
     if (Horizontal)
     {
         return(holder.Width);
     }
     else
     {
         return(holder.Height);
     }
 }
 protected int GetPreferredPosition(ToolBarDockHolder holder)
 {
     if (Horizontal)
     {
         return(holder.PreferredDockedLocation.X);
     }
     else
     {
         return(holder.PreferredDockedLocation.Y);
     }
 }
Beispiel #8
0
        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);
            }
        }
Beispiel #9
0
        public void RemoveControl(Control c)
        {
            ToolBarDockHolder holder = GetHolder(c);

            if (holder != null)
            {
                holder.MouseUp     -= new MouseEventHandler(this.ToolBarMouseUp);
                holder.DoubleClick -= new EventHandler(this.ToolBarDoubleClick);
                holder.MouseMove   -= new MouseEventHandler(this.ToolBarMouseMove);
                holder.MouseDown   -= new MouseEventHandler(this.ToolBarMouseDown);

                _holders.Remove(holder);
                holder.Parent = null;
                holder.FloatForm.Close();
            }
        }
Beispiel #10
0
        public void ShowControl(Control c, bool show)
        {
            ToolBarDockHolder holder = GetHolder(c);

            if (holder != null)
            {
                if (holder.Visible != show)
                {
                    if (IsDocked(holder))
                    {
                        holder.Visible = show;
                    }
                    else
                    {
                        holder.FloatForm.Visible = show;
                    }
                }
            }
        }
        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);
        }
Beispiel #12
0
 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);
 }
Beispiel #13
0
        // Added by mav
        public virtual void ShowContextMenu(Point ptScreen)
        {
            System.Windows.Forms.ContextMenu cm = new System.Windows.Forms.ContextMenu();
            ArrayList al = new ArrayList();

            al.AddRange(_holders);
            al.Sort(new HolderSorter());

            MyMenuItem [] items = new MyMenuItem[al.Count];
            for (int i = 0; i < al.Count; i++)
            {
                ToolBarDockHolder holder = al[i] as ToolBarDockHolder;
                Control           c      = holder.Control;
                items[i]         = new MyMenuItem();
                items[i].Checked = c.Visible;
                items[i].Text    = holder.ToolbarTitle;
                items[i].Click  += new EventHandler(MenuClickEventHandler);
                items[i].Control = c;
                cm.MenuItems.Add(items[i]);
            }
            cm.Show(DockStation, DockStation.PointToClient(ptScreen));
        }
        public ToolBarDockHolder AddControl(Control c, DockStyle site, Point location)
        {
            ToolBarDockHolder holder = new ToolBarDockHolder(this, c, site);

            _holders.Add(holder);
            if (site != DockStyle.None)
            {
                holder.DockStyle = site;
                holder.Parent    = holder.PreferredDockedArea;
                holder.PreferredDockedLocation = location;
            }
            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.FloatForm.Location = location;
            }

            //holder.Parent = holder.FloatForm;
            //holder.Location = new Point(0, 0);
            //holder.DockStyle = DockStyle.None;
            //holder.FloatForm.Size = holder.Size;

            //Point newLoc = holder.FloatForm.PointToScreen(new Point(400, 400));
            //holder.FloatForm.Location = newLoc;
            //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);
        }
Beispiel #15
0
 private bool IsDocked(ToolBarDockHolder holder)
 {
     return holder.Parent == Top
         || holder.Parent == Left
         || holder.Parent == Right
         || holder.Parent == Bottom;
 }
Beispiel #16
0
        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);
            }
        }
Beispiel #17
0
 private void ToolBarMouseUp(object sender, MouseEventArgs e)
 {
     if(_dragged != null)
     {
         _dragged = null;
         _ptOffset.X = 8;
         _ptOffset.Y = 8;
     }
 }
Beispiel #18
0
 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;
 }
 public ColumnHolder(int pos, ToolBarDockHolder holder, int size)
 {
     Position = pos;
     Holder   = holder;
     Size     = size;
 }
Beispiel #20
0
 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;
 }
Beispiel #21
0
 public ColumnHolder(int pos, ToolBarDockHolder holder, int size)
 {
     Position = pos;
     Holder = holder;
     Size = size;
 }
Beispiel #22
0
 protected int GetPreferredPosition(ToolBarDockHolder holder)
 {
     if(Horizontal)
         return holder.PreferredDockedLocation.X;
     else
         return holder.PreferredDockedLocation.Y;
 }
Beispiel #23
0
        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;
        }
Beispiel #24
0
 protected int GetHolderWidth(ToolBarDockHolder holder)
 {
     if(Horizontal)
         return holder.Width;
     else
         return holder.Height;
 }