Exemplo n.º 1
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();
            }
        }
Exemplo n.º 2
0
 private bool IsDocked(ToolBarDockHolder holder)
 {
     return(holder.Parent == Top ||
            holder.Parent == Left ||
            holder.Parent == Right ||
            holder.Parent == Bottom);
 }
Exemplo n.º 3
0
            public int Compare(object x, object y)
            {
                ToolBarDockHolder h1 = x as ToolBarDockHolder;
                ToolBarDockHolder h2 = y as ToolBarDockHolder;

                return(h1.ToolbarTitle.CompareTo(h2.ToolbarTitle));
            }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
 private void ToolBarMouseUp(object sender, MouseEventArgs e)
 {
     if (_dragged != null)
     {
         _dragged    = null;
         _ptOffset.X = 8;
         _ptOffset.Y = 8;
     }
 }
Exemplo n.º 6
0
 protected int GetHolderWidth(ToolBarDockHolder holder)
 {
     if (Horizontal)
     {
         return(holder.Width);
     }
     else
     {
         return(holder.Height);
     }
 }
Exemplo n.º 7
0
 protected int GetPreferredPosition(ToolBarDockHolder holder)
 {
     if (Horizontal)
     {
         return(holder.PreferredDockedLocation.X);
     }
     else
     {
         return(holder.PreferredDockedLocation.Y);
     }
 }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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();
            }
        }
Exemplo n.º 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;
                    }
                }
            }
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 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);
 }
Exemplo n.º 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));
        }
Exemplo n.º 14
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;
 }
Exemplo n.º 15
0
 public ColumnHolder(int pos, ToolBarDockHolder holder, int size)
 {
     Position = pos;
     Holder = holder;
     Size = size;
 }
Exemplo n.º 16
0
 protected int GetPreferredPosition(ToolBarDockHolder holder)
 {
     if(Horizontal)
         return holder.PreferredDockedLocation.X;
     else
         return holder.PreferredDockedLocation.Y;
 }
Exemplo n.º 17
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;
 }
Exemplo n.º 18
0
 protected int GetHolderWidth(ToolBarDockHolder holder)
 {
     if(Horizontal)
         return holder.Width;
     else
         return holder.Height;
 }
Exemplo n.º 19
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;
        }
Exemplo n.º 20
0
 private void ToolBarMouseUp(object sender, MouseEventArgs e)
 {
     if(_dragged != null)
     {
         _dragged = null;
         _ptOffset.X = 8;
         _ptOffset.Y = 8;
     }
 }
Exemplo n.º 21
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);
            }
        }
Exemplo n.º 22
0
 public ColumnHolder(int pos, ToolBarDockHolder holder, int size)
 {
     Position = pos;
     Holder   = holder;
     Size     = size;
 }
Exemplo n.º 23
0
 private bool IsDocked(ToolBarDockHolder holder)
 {
     return holder.Parent == Top
         || holder.Parent == Left
         || holder.Parent == Right
         || holder.Parent == Bottom;
 }