Beispiel #1
0
 public PageListContextMenuStrip(TabControl tabControl, LabelButton lablBtn)
 {
     contextMenuStrip1        = new ClassicContextMenuStrip();
     tabControl1              = tabControl;
     labelButton1             = lablBtn;
     labelButton1.MouseClick += new System.Windows.Forms.MouseEventHandler(labelButton1_MouseClick);
 }
 public PageListContextMenuStrip(TabControl tabControl, LabelButton lablBtn)
 {
     contextMenuStrip1 = new ClassicContextMenuStrip();
     tabControl1 = tabControl;
     labelButton1 = lablBtn;
     labelButton1.MouseClick += new System.Windows.Forms.MouseEventHandler(labelButton1_MouseClick);
 }
        private void btns_Click(object sender, EventArgs e)
        {
            //OnButtonsClick(sender, e);

            LabelButton btn = ((LabelButton)sender);
            string      s   = btn.Tag.ToString();

            BtnsClick(s);
        }
        public string CreateButtons(string s)
        {
            path = s;
            //buttons
            //ICON1.Visible = true;
            string[] arr = s.Split(new string[] { "\\", }, StringSplitOptions.None);
            string   s1  = "";

            btns = new LabelButton[arr.Length];
            //  释放按钮
            //DisposeButtons();


            int LEFT = 24;
            int TOP  = 1;

            for (int i = 0; i < arr.Length; i++)
            {
                string name  = string.Format("{0}", arr[i]);
                string path1 = string.Format("\\{0}", arr[i]);
                s1 += path1;

                btn           = new LabelButton();
                btn.Font      = new Drawing.Font("微软雅黑", 9F);
                btn.Text      = name;
                btn.Tag       = s1.Remove(0, 1) + "\\";
                btn.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
                btn.BackColor = Color.Transparent;

                btn.Parent = pictureBox1;
                btn.Height = pictureBox1.ClientRectangle.Height;

                btn.MouseDownColor  = Color.FromArgb(209, 232, 255);
                btn.MouseEnterColor = Color.FromArgb(229, 243, 251);

                Size size = TextRenderer.MeasureText(name, btn.Font);

                btn.Width   = size.Width;
                btn.Height -= 2;

                btn.Location = new Point(LEFT, TOP);
                LEFT        += size.Width;

                btn.BringToFront();
                btn.Click      += new System.EventHandler(btns_Click);
                btn.MouseLeave += new System.EventHandler(btn_MouseLeave);
                btn.MouseEnter += new System.EventHandler(btn_MouseEnter);

                btns[i] = btn;
                btn.Refresh();
            }

            LEFT = 24;
            return(s);
        }
        private void btn_MouseLeave(object sender, EventArgs e)
        {
            LabelButton btn = ((LabelButton)sender);

            btn.BorderColor = Color.Transparent;
        }
        private void btn_MouseEnter(object sender, EventArgs e)
        {
            LabelButton btn = ((LabelButton)sender);

            btn.BorderColor = Color.FromArgb(102, 167, 232);
        }
        public string CreateButtons(string s)
        {
            path = s;
            //buttons
            //ICON1.Visible = true;
            string[] arr = s.Split(new string[] { "\\", }, StringSplitOptions.None);
            string s1 = "";

            btns = new LabelButton[arr.Length];
            //  释放按钮
            //DisposeButtons();

            int LEFT = 24;
            int TOP = 1;

            for (int i = 0; i < arr.Length; i++)
            {
                string name = string.Format("{0}", arr[i]);
                string path1 = string.Format("\\{0}", arr[i]);
                s1 += path1;

                btn = new LabelButton();
                btn.Font = new Drawing.Font("微软雅黑", 9F);
                btn.Text = name;
                btn.Tag = s1.Remove(0, 1) + "\\";
                btn.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
                btn.BackColor = Color.Transparent;

                btn.Parent = pictureBox1;
                btn.Height = pictureBox1.ClientRectangle.Height;

                btn.MouseDownColor = Color.FromArgb(209, 232, 255);
                btn.MouseEnterColor = Color.FromArgb(229, 243, 251);

                Size size = TextRenderer.MeasureText(name, btn.Font);

                btn.Width = size.Width;
                btn.Height -= 2;

                btn.Location = new Point(LEFT, TOP);
                LEFT += size.Width;

                btn.BringToFront();
                btn.Click += new System.EventHandler(btns_Click);
                btn.MouseLeave += new System.EventHandler(btn_MouseLeave);
                btn.MouseEnter += new System.EventHandler(btn_MouseEnter);

                btns[i] = btn;
                btn.Refresh();
            }

            LEFT = 24;
            return s;
        }