Exemplo n.º 1
0
        private void setOpacity()
        {
            double opacity = 0.85d;

            Opacity = opacity;
            ContextMenuStripHelper.SetOpacity(cms_text, opacity);
            MenuHelper.SetOpacity(ms_left.Items, opacity);
            MenuHelper.SetOpacity(ms_right.Items, opacity);
        }
Exemplo n.º 2
0
        private void setToolStrip()
        {
            double opacity = 0.85d;

            ContextMenuStrip[] cmss = new ContextMenuStrip[] { this.itemCms, this.dgvCms, this.naviCms };
            foreach (ContextMenuStrip cms in cmss)
            {
                ContextMenuStripHelper.SetOpacity(cms, opacity);
            }
        }
Exemplo n.º 3
0
        private void init()
        {
            //
            //cms
            //
            ToolStripMenuItem tsmi_max = new ToolStripMenuItem();

            tsmi_max.Text   = "最大化";
            tsmi_max.Click += new EventHandler((object sender, EventArgs e) => {
                if (_f.WindowState == FormWindowState.Normal)
                {
                    _f.WindowState = FormWindowState.Maximized;
                }
                else
                {
                    _f.WindowState = FormWindowState.Normal;
                }
            });
            ToolStripMenuItem tsmi_min = new ToolStripMenuItem();

            tsmi_min.Text   = "最小化";
            tsmi_min.Click += new EventHandler((object sender, EventArgs e) => { _f.WindowState = FormWindowState.Minimized; });
            ToolStripMenuItem tsmi_end = new ToolStripMenuItem();

            tsmi_end.Text   = "关闭";
            tsmi_end.Click += new EventHandler((object sender, EventArgs e) =>
            {
                if (DiyCloseWindowEvent == null)
                {
                    closeWindow();
                }
                else
                {
                    DiyCloseWindowEvent(null, null);
                }
            });
            this._defCms.Items.AddRange(new ToolStripItem[] { tsmi_max, tsmi_min, tsmi_end });
            this._defCms.Opening += new System.ComponentModel.CancelEventHandler((object sender, System.ComponentModel.CancelEventArgs e) => {
                tsmi_min.Enabled = _f.WindowState != FormWindowState.Minimized &&
                                   (Style == TitleBarStyles.MinOnly ||
                                    Style == TitleBarStyles.MinEnd ||
                                    Style == TitleBarStyles.MinMax ||
                                    Style == TitleBarStyles.MinMaxEnd);
                tsmi_max.Enabled = Style == TitleBarStyles.MaxEnd ||
                                   Style == TitleBarStyles.MaxOnly ||
                                   Style == TitleBarStyles.MinMax ||
                                   Style == TitleBarStyles.MinMaxEnd;
                tsmi_end.Enabled = Style == TitleBarStyles.EndOnly ||
                                   Style == TitleBarStyles.MaxEnd ||
                                   Style == TitleBarStyles.MinEnd ||
                                   Style == TitleBarStyles.MinMaxEnd;
                tsmi_max.Text = _f.WindowState == FormWindowState.Maximized ? "还原" : "最大化";
                ContextMenuStripHelper.SetOpacity(this._defCms, _f.Opacity);
                this._defCms.Font = _f.Font;
            });
            this._tPanel.SuspendLayout();
            //
            // maxLabel
            //
            this._maxLabel.AutoSize  = false;
            this._maxLabel.BackColor = System.Drawing.Color.Transparent;
            this._maxLabel.ImeMode   = System.Windows.Forms.ImeMode.NoControl;
            this._maxLabel.Cursor    = Cursors.Default;
            this._maxLabel.Top       = 1;
            this._maxLabel.Name      = "maxLabel";
            this._maxLabel.Text      = "=";
            this._maxLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            //
            // minLabel
            //
            this._minLabel.AutoSize  = false;
            this._minLabel.BackColor = System.Drawing.Color.Transparent;
            this._minLabel.ImeMode   = System.Windows.Forms.ImeMode.NoControl;
            this._minLabel.Top       = 1;
            this._minLabel.Cursor    = Cursors.Default;
            this._minLabel.Name      = "minLabel";
            this._minLabel.Text      = "—";
            this._minLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;

            //
            // endLabel
            //
            this._endLabel.AutoSize  = false;
            this._endLabel.BackColor = System.Drawing.Color.Transparent;
            this._endLabel.ImeMode   = System.Windows.Forms.ImeMode.NoControl;
            this._endLabel.Top       = 1;
            this._endLabel.Name      = "endLabel";
            this._endLabel.Cursor    = Cursors.Default;
            this._endLabel.Text      = "X";
            this._endLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            //
            //iconPictureBox
            //
            this._iconPictureBox.BackColor             = System.Drawing.Color.Transparent;
            this._iconPictureBox.Cursor                = Cursors.Arrow;
            this._iconPictureBox.Top                   = 1;
            this._iconPictureBox.Name                  = "iconPictureBox";
            this._iconPictureBox.BackgroundImageLayout = ImageLayout.Zoom;
            this._iconPictureBox.ContextMenuStrip      = null;
            this._iconPictureBox.ParentChanged        += new EventHandler((object sender, EventArgs e) => { resetControlLocation(); });
            //
            // tPanel
            //
            this._tPanel.Controls.Add(this._minLabel);
            this._tPanel.Controls.Add(this._maxLabel);
            this._tPanel.Controls.Add(this._endLabel);
            this._tPanel.Controls.Add(this._tLabel);
            this._tPanel.Controls.Add(this._iconPictureBox);
            this._tPanel.Cursor           = System.Windows.Forms.Cursors.SizeAll;
            this._tPanel.Dock             = System.Windows.Forms.DockStyle.Top;
            this._tPanel.ImeMode          = System.Windows.Forms.ImeMode.NoControl;
            this._tPanel.Name             = "tPanel";
            this._tPanel.ContextMenuStrip = _defCms;
            this._tPanel.TabIndex         = 0;
            this._tPanel.SizeChanged     += (o, e) => {
                Height = _tPanel.Height;
            };
            this._tPanel.Disposed  += new EventHandler((object sender, EventArgs e) => { Disposed?.Invoke(this, e); });
            this._tPanel.MouseDown += (object sender, MouseEventArgs e) =>
            {
                if (e.Button == MouseButtons.Left)
                {
                    if (Moveable)
                    {
                        FormHelper.Move(_f.Handle);
                    }
                }
            };
            this._tPanel.SizeChanged += new EventHandler((object sender, EventArgs e) =>
            {
                this.resetControlLocation();
            });
            //
            //tLabel
            //
            this._tLabel.Left         = _iconPictureBox.Right;
            this._tLabel.Top          = 0;
            this._tLabel.AutoEllipsis = true;
            this._tLabel.AutoSize     = false;
            this._tLabel.BackColor    = Color.Transparent;
            this._tLabel.Height       = _tPanel.Height;
            this._tLabel.Name         = "tLabel";
            this._tLabel.TextAlign    = ContentAlignment.MiddleLeft;
            this._tLabel.MouseDown   += (object sender, MouseEventArgs e) =>
            {
                if (e.Button == MouseButtons.Left)
                {
                    if (Moveable)
                    {
                        FormHelper.Move(_f.Handle);
                    }
                }
            };

            _f.SizeChanged += new EventHandler((object sender, EventArgs e) =>
            {
                if (_f.WindowState == FormWindowState.Maximized)
                {
                    //_maxLabel.Font = new Font(_maxLabel.Font.Name, 10.5f, _maxLabel.Font.Style);
                    _maxLabel.Text = "=";
                    _maxLabel.Size = _minLabel.Size;
                }
                else
                {
                    //_maxLabel.Font = new Font(_maxLabel.Font.Name, 9.5f, _maxLabel.Font.Style);
                    _maxLabel.Text = "=";
                    _maxLabel.Size = _minLabel.Size;
                }
            });
            Icon           = _f.Icon;
            BackColor      = _f.BackColor;
            Title          = _f.Text;
            TitleAlignment = ContentAlignment.MiddleLeft;
            Cms            = _defCms;
            IconVisible    = true;
            Style          = Style;
            Font           = new Font("SIMSUN", 9f, FontStyle.Regular);
            Height         = 26;
            if (_f is IThemeBase)
            {
                BackColor = (_f as IThemeBase).BorderColor;
            }
            else
            {
                BackColor = Drawing.ColorHelper.GetSimilarColor(_f.BackColor, true, Level.Level10);
            }


            this.setControlButtons();
            this._tPanel.ResumeLayout(false);
        }