當前位置: 首頁>>代碼示例>>C#>>正文


C# ToolStrip.MakeShadow方法代碼示例

本文整理匯總了C#中System.Windows.Forms.ToolStrip.MakeShadow方法的典型用法代碼示例。如果您正苦於以下問題:C# ToolStrip.MakeShadow方法的具體用法?C# ToolStrip.MakeShadow怎麽用?C# ToolStrip.MakeShadow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Forms.ToolStrip的用法示例。


在下文中一共展示了ToolStrip.MakeShadow方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: OnMouseUp

        protected override void OnMouseUp(MouseEventArgs e)
        {
            if (!Enabled) return;

            RaiseClick();
            if (DropDownItems.Count == 0)
            {
                ResetSelected();
                if (Parent.Parent == null)
                    Parent.Dispose();
                return;
            }

            if (_dropDownToolStrip != null)
            {
                _dropDownToolStrip = null;
                return;
            }

            if (!_pressed)
            {
                _dropDownToolStrip = new ToolStrip();
                _dropDownToolStrip.Context = true;
                _dropDownToolStrip.OwnerItem = this;

                if (Parent.ShadowHandler != null)
                    _dropDownToolStrip.MakeShadow();

                int index = Parent.Items.IndexOf(this);
                int x = 0, y = 0;
                for (int i = 0; i < index; i++)
                {
                    if (Parent.Orientation == Forms.Orientation.Horizontal)
                        x += Parent.Items[i].Width;
                    if (Parent.Orientation == Forms.Orientation.Vertical)
                        y += Parent.Items[i].Height;
                }
                //_dropDownToolStrip.BackColor = Parent.BackColor;
                _dropDownToolStrip.Items.AddRange(DropDownItems);
                for (int i = 0; i < _dropDownToolStrip.Items.Count; i++)
                {
                    _dropDownToolStrip.Items[i].OwnerItem = this;
                    _dropDownToolStrip.Items[i].Selected = false;
                }
                _dropDownToolStrip.ShadowBox = true;
                _dropDownToolStrip.Orientation = Orientation.Vertical;
                int height = 0;
                for (int i = 0; i < DropDownItems.Count; i++)
                    height += DropDownItems[i].Height;
                _dropDownToolStrip.Size = new Size(DropDownItems[0].Width, height);

                var parentLocationClient = Parent.PointToScreen(Point.Zero);
                if (Parent.Orientation == Orientation.Horizontal)
                {
                    _dropDownToolStrip.Location = new Point(parentLocationClient.X + x + Parent.Padding.Left, parentLocationClient.Y + Parent.Height - HoverPadding.Y - 1);
                    _dropDownToolStrip.BorderColor = Color.Transparent;
                }
                else
                {
                    _dropDownToolStrip.Location = new Point(parentLocationClient.X + x + Parent.Width, parentLocationClient.Y + y);
                    _dropDownToolStrip.BorderColor = Parent.BorderColor;

                    if (_dropDownToolStrip.Location.X + _dropDownToolStrip.Width > Screen.PrimaryScreen.WorkingArea.Width)
                    {
                        _dropDownToolStrip.Location = new Point(parentLocationClient.X - _dropDownToolStrip.Width, _dropDownToolStrip.Location.Y);
                    }
                }

                _dropDownToolStrip.OnDisposing += (object sender, EventArgs args) =>
                {
                    var clientRect = new System.Drawing.Rectangle(x, y, Width, Height);
                    var contains = clientRect.Contains(Parent.PointToClient(Control.MousePosition));
                    if (!contains)
                        _pressed = false;
                    else
                        _pressed = !_pressed;
                    _dropDownToolStrip = null;
                };
            }
            else
            {
                _pressed = false;
            }
        }
開發者ID:Meragon,項目名稱:Unity-WinForms,代碼行數:84,代碼來源:ToolStripItem.cs


注:本文中的System.Windows.Forms.ToolStrip.MakeShadow方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。