Esempio n. 1
0
        private void SetButtonText(TabBarButton btn, int index, ConnectionTag tag)
        {
            btn.HeadText = (index + 1).ToString();
            string t = tag.FormatTabText();

            btn.Text = (t == null || t.Length == 0)? " " : t;         //テキストなしだとHeadTextもなくなってしまうのでやむなく回避
        }
Esempio n. 2
0
        void InitializeTaskBar()
        {
            TaskBar             = taskBar1;
            TaskBar.Font        = SystemFonts.MenuFont;
            TaskBar.Height      = Math.Max(32, TaskBar.Height);
            TaskBar.MaxItemSize = 300;
            //TaskBar.Padding = new Padding(2, 0, 2, 0);

            BtnStart = new StartMenuButton
            {
                Text       = "Menu",
                CustomSize = 50
            };
            BtnStart.Click += BtnStart_Click;

            //BtnNew = new TabBarButton();
            //BtnNew.Icon = Properties.Resources._new;
            //BtnNew.ToolTipText = "Create New Document";
            //BtnNew.Click += MenuNew_Click;

            BtnOpen = new TabBarButton
            {
                Icon        = Properties.Resources.open,
                ToolTipText = "Open Document..."
            };
            BtnOpen.Click += MenuOpen_Click;

            BtnHelp = new TabBarButton
            {
                Icon = Properties.Resources.help,
                Text = "Help"
            };
            BtnHelp.Click += BtnHelp_Click;

            TaskBar.LeftButtons.Add(BtnStart);
            //TaskBar.LeftButtons.Add(BtnNew);
            TaskBar.LeftButtons.Add(BtnOpen);
            TaskBar.RightButtons.Add(BtnHelp);
            TaskBar.Items.ItemAdded   += TaskBar_Items_ItemAdded;
            TaskBar.Items.ItemRemoved += TaskBar_Items_ItemRemoved;

            MenuHelps.DropDown    = HelpMenu;
            MenuQuickHelp.Enabled = Helper.HasQuickHelp();

            //
            TabNew        = new SpecialTabItem(Properties.Resources._new);
            TabNew.Click += new EventHandler(MenuNew_Click);
            TaskBar.RightSpecialTabs.Add(TabNew);
        }
Esempio n. 3
0
        private void OnMouseMove(object sender, MouseEventArgs args)
        {
            if (args.Button != MouseButtons.Left)
            {
                return;
            }

            if (Math.Abs(_dragStartPosX - args.X) + Math.Abs(_dragStartPosY - args.Y) >= 3)
            {
                object tag = ((TabBarButton)sender).Tag;
                this.DoDragDrop(tag, DragDropEffects.Move);
                TabBarButton btn = sender as TabBarButton;
                if (btn != null)
                {
                    btn.Reset();
                }
            }
        }
Esempio n. 4
0
        private void OnMouseUp(object sender, MouseEventArgs args)
        {
            if (args.Button != MouseButtons.Right)
            {
                return;
            }

            TabBarButton  b  = (TabBarButton)sender;
            int           tx = this.Left + b.Left;
            int           ty = this.Top + b.Top;
            ConnectionTag t  = (ConnectionTag)b.Tag;

            Debug.Assert(t != null);
            GApp.Frame.CommandTargetConnection = t.Connection;
            //メニューのUI調整
            GApp.Frame.AdjustContextMenu(true, t.Connection);
            GApp.Frame.ContextMenu.Show(GApp.Frame, new Point(tx + args.X, ty + args.Y));         //ボタンやタブバーをコンテナにするとキーボードで選択できなくなる
        }
Esempio n. 5
0
        private Control CreateNewButton(ConnectionTag ct)
        {
            TabBarButton b = new TabBarButton();

            ct.Button = b;
            SetButtonText(b, Controls.Count - 1, ct);
            _tabToolTip.SetToolTip(b, ct.FormatFrameText());
            //b.Image = _imageList.Images[(int)e.item.Type];

            b.Tag        = ct;
            b.Font       = _basicFont;
            b.Width      = GetNecessaryButtonWidth(b);
            b.Visible    = true;
            b.TabStop    = false;
            b.Click     += new EventHandler(this.OnButtonClick);
            b.MouseDown += new MouseEventHandler(OnMouseDown);
            b.MouseUp   += new MouseEventHandler(OnMouseUp);
            b.MouseMove += new MouseEventHandler(OnMouseMove);
            return(b);
        }
Esempio n. 6
0
        private void ArrangeButtonsForMultiRowStyle()
        {
            if (_leftScrollButton != null)
            {
                this.Controls.Remove(_leftScrollButton);
                this.Controls.Remove(_rightScrollButton);
                _leftScrollButton = _rightScrollButton = null;
            }

            int x = 2;
            int y = 3;
            int i = 0;

            foreach (Control c in Controls)
            {
                TabBarButton button = c as TabBarButton;
                if (button == null)
                {
                    continue;
                }

                SetButtonText(button, i, (ConnectionTag)button.Tag);
                if (x + button.Width >= this.Width)
                {
                    x  = 2;
                    y += UNITHEIGHT;
                }
                button.Left    = x;
                button.Width   = GetNecessaryButtonWidth((ConnectionTag)button.Tag);
                x             += button.Width + BUTTON_MARGIN;
                button.Top     = y;
                button.Visible = true;
                button.Height  = UNITHEIGHT - 4;
                button.Invalidate();
                i++;
            }
            this.Height = y + UNITHEIGHT;
        }
Esempio n. 7
0
        public void SetActiveTab(ConnectionTag active)
        {
            foreach (ConnectionTag ct in GEnv.Connections)
            {
                TabBarButton b = ct.Button as TabBarButton;

                if (b == null)
                {
                    continue;
                }

                if (active == ct)
                {
                    b.BackColor = _activeTabColor;
                    b.Font      = _activeTabFont;
                    b.Selected  = true;
                    if (GApp.Options.TabBarStyle == TabBarStyle.ScrollButton)
                    {
                        if (!b.Visible)
                        {
                            int index = GEnv.Connections.IndexOf(ct);
                            if (index != -1)
                            {
                                EnsureButtonVisible(index);
                            }
                        }
                    }
                }
                else
                {
                    b.BackColor = SystemColors.Control;
                    b.Font      = _basicFont;
                    b.Selected  = false;
                }
                b.Invalidate();
            }
        }
Esempio n. 8
0
        private void ArrangeButtonsForScrollStyle(bool animation, int animation_offset)
        {
            if (_leftScrollButton == null)
            {
                InitScrollButtons();
            }

            for (int i = 0; i < _scrollButtonOffset; i++)
            {
                GEnv.Connections.TagAt(i).Button.Visible = false;
            }
            int x     = 2;
            int y     = 3;
            int limit = x + GetTabAreaWidth();

            x += animation_offset;
            int offset = _scrollButtonOffset;
            int index  = offset;

            while (offset < GEnv.Connections.Count)
            {
                ConnectionTag ct = GEnv.Connections.TagAt(offset);
                if (!ct.IsTerminated)
                {
                    TabBarButton button = (TabBarButton)ct.Button;
                    button.Left  = x;
                    button.Width = GetNecessaryButtonWidth(ct);
                    SetButtonText(button, index, ct);
                    if (x > limit && offset > _scrollButtonOffset)
                    {
                        break;                                                             //少なくとも一つはボタンを表示する
                    }
                    button.Top     = y;
                    button.Visible = true;
                    button.Height  = UNITHEIGHT - 4;
                    x += button.Width + BUTTON_MARGIN;
                    index++;
                }
                offset++;
            }

            for (int i = offset; i < GEnv.Connections.Count; i++)
            {
                GEnv.Connections.TagAt(i).Button.Visible = false;
            }

            _leftScrollButton.Left = this.Width - SCROLLBUTTON_SIZE * 2;
            _leftScrollButton.Top  = y + 2;
            _leftScrollButton.BringToFront();
            _leftScrollButton.Enabled = !animation && _scrollButtonOffset > 0;
            _rightScrollButton.Left   = this.Width - SCROLLBUTTON_SIZE;
            _rightScrollButton.Top    = y + 2;
            _rightScrollButton.BringToFront();
            _rightScrollButton.Enabled = !animation && offset < GEnv.Connections.Count;

            //幅をふやしていったときなど、スペースに余裕があるなら表示を拡大
            if (!animation && _scrollButtonOffset > 0 && GEnv.Connections.TagAt(_scrollButtonOffset - 1).Button.Width + BUTTON_MARGIN < limit - x)
            {
                _scrollButtonOffset--;
                ArrangeButtonsForScrollStyle(false, 0);
            }
            this.Height = y + UNITHEIGHT;
        }
Esempio n. 9
0
        private void OnButtonClick(object sender, EventArgs args)
        {
            TabBarButton b = (TabBarButton)sender;

            GApp.GlobalCommandTarget.ActivateConnection(((ConnectionTag)b.Tag).Connection);
        }
Esempio n. 10
0
 void OnTabBarClick(TabBarButton button)
 {
     ShowSection(button.Id);
 }