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