本文整理汇总了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;
}
}