Esempio n. 1
0
        /// <summary>
        /// Draw the images on the current tab
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="index"></param>
        private void PaintTabImage(System.Drawing.Graphics graphics, int index)
        {
            Image tabImage = null;

            if (this.TabPages[index].ImageIndex > -1 && this.ImageList != null)
            {
                tabImage = this.ImageList.Images[this.TabPages[index].ImageIndex];
            }
            else if (this.TabPages[index].ImageKey.Trim().Length > 0 && this.ImageList != null)
            {
                tabImage = this.ImageList.Images[this.TabPages[index].ImageKey];
            }
            Rectangle rect = this.GetTabRect(index);

            if (tabImage != null)
            {
                Rectangle tabimageArea = new Rectangle(rect.Left + rect.Height / 2, rect.Top + 4, 15, 15);
                graphics.DrawRectangle(new Pen(Color.Blue), tabimageArea);
                this.PaintImage(tabimageArea, graphics, tabImage);
            }
            Rectangle closeImageArea = new Rectangle(rect.Right - 16, rect.Top + 2, 13, 13);
            f0t0page  page           = this.TabPages[index] as f0t0page;

            if (page != null && page.CanClose)
            {
                using (Bitmap bmp = (index == this.SelectedIndex) ?
                                    new Bitmap(Properties.Resources.closebtn) : new Bitmap(Properties.Resources.disabled_close_btn))
                {
                    this.PaintImage(closeImageArea, graphics, bmp);
                    page.CloseBounds = closeImageArea;
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a new tab
        /// </summary>
        internal void CreateNewTab()
        {
            f0t0page newtab = new f0t0page();

            newtab.Name = string.Format("{0}{1}", newtab.Name, this.TabCount);
            newtab.SetFotoBox(fotoBox);
            this.TabPages.Add(newtab);
            this.SelectTab(newtab.Name);
            newtab.Focus();
        }
Esempio n. 3
0
        private void CloseClone(object sender, CloningEventArgs e)
        {
            f0t0page page = sender as f0t0page;

            if (page != null)
            {
                page.ReAssemble();
                page.IsCloned = false;
                page.UpdateText(e.MainPictureName);
                page.fotobox.UpdateAll();
            }
        }
Esempio n. 4
0
        private void InitClone(object sender, CloningEventArgs e)
        {
            f0t0page page = sender as f0t0page;

            if (page != null)
            {
                //Thread.Sleep(200); //wait a few millsecs for stuff.
                this.splitContainer.SplitterDistance = this.splitContainer.Parent.Width;
                page.IsCloned = true;
                page.fotobox.UpdateAll();
                page.UpdateText(e.MainPictureName);
                page.Retract();
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Event: occurs when the mouse moves over the surface of a control
        /// </summary>
        /// <param name="e">mouse event arguments</param>
        protected override void OnMouseMove(MouseEventArgs e)
        {
            this.SuspendLayout();
            base.OnMouseMove(e);
            Point    pt   = new Point(e.X, e.Y);
            f0t0page page = GetTabPageByLocation(pt) as f0t0page;

            if (e.Button == MouseButtons.Left)
            {
                if (page != null)
                {
                    this.DoDragDrop(page, DragDropEffects.All);
                }
            }
            this.ResumeLayout(true);
        }
Esempio n. 6
0
        /// <summary>
        /// Event: Occurs when the mouse button goes up
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);
            f0t0page page = this.GetTabPageByLocation(e.Location) as f0t0page;

            if (e.Button == MouseButtons.Left)
            {
                if (page != null && page.CanClose && page.CloseHot)
                {
                    Rectangle closeBtnBounds = page.CloseBounds;
                    if (closeBtnBounds.Contains(e.Location))
                    {
                        this.Close(page);
                    }
                }
            }
        }
Esempio n. 7
0
 /// <summary>
 /// Event: occurs when mouse button is down
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseDown(MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         this.SelectedTab = this.GetTabPageByLocation(e.Location);
     }
     else if (e.Button == MouseButtons.Left)
     {
         f0t0page page = this.SelectedTab as f0t0page;
         if (page != null && page.CanClose)
         {
             Rectangle closeBtnBounds = page.CloseBounds;
             if (closeBtnBounds.Contains(e.Location))
             {
                 page.CloseHot = true;
                 //this.Close(page);
             }
         }
     }
     base.OnMouseDown(e);
 }
Esempio n. 8
0
        /// <summary>
        /// Event: Occurs when the mouse is dragged over the tabcontrol.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="drgevent"></param>
        protected override void OnDragOver(DragEventArgs drgevent)
        {
            base.OnDragOver(drgevent);
            Point p = new Point(drgevent.X, drgevent.Y);

            p = this.PointToClient(p);

            f0t0page hovered_page = this.GetTabPageByLocation(p) as f0t0page;

            if (hovered_page != null)
            {
                this.SelectedTab = hovered_page;
                if (drgevent.Data.GetDataPresent(typeof(f0t0page)))
                {
                    drgevent.Effect = DragDropEffects.Move;
                    f0t0page movingTab      = drgevent.Data.GetData(typeof(f0t0page)) as f0t0page;
                    int      currentIndex   = FindTabIndex(hovered_page);
                    int      movingTabIndex = FindTabIndex(movingTab);
                    if (currentIndex.CompareTo(movingTabIndex) != 0)
                    {
                        this.SuspendLayout();
                        if (currentIndex >= 0 || movingTabIndex >= 0)
                        {
                            this.TabPages[currentIndex]   = movingTab;
                            this.TabPages[movingTabIndex] = hovered_page;
                            bool canclose = movingTab.CanClose;
                            movingTab.CanClose    = hovered_page.CanClose;
                            hovered_page.CanClose = canclose;
                        }
                        this.ResumeLayout(true);
                        this.SelectedTab = movingTab;
                    }
                }
                else
                {
                    drgevent.Effect = DragDropEffects.Link;
                    hovered_page.Focus();
                }
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Close a given tabpage
        /// </summary>
        /// <param name="tabpage">the tabpage to close</param>
        public void Close(TabPage tabpage)
        {
            if (this.Contains(tabpage))
            {
                f0t0page f = (tabpage as f0t0page);
                if (f.CanClose)
                {
                    int tabIndex = this.FindTabIndex(f);
                    while (this.closeTabList.ContainsKey(tabIndex))
                    {
                        tabIndex++;
                    }
                    this.closeTabList.Add(tabIndex, tabpage);

                    //TODO: Design a DS to hold tabpages so that an upper limit can be set.

                    this.TabPages.Remove(tabpage);
                }
                else
                {
                    this.CurrentPage.UnloadPicture(this);
                }
            }
        }