private void TrayContextMenu_Opened(object sender, EventArgs e)
        {
            var contextMenuStrip           = (ContextMenuStrip)sender;
            var dropDownLocationCalculator = new DropDownLocationCalculator(contextMenuStrip.Size);

            contextMenuStrip.Location = dropDownLocationCalculator.CalculateLocationForDropDown(Cursor.Position);
        }
示例#2
0
        public void CalculatedLocationForDropDown_Should_ReturnTheCorrectLocation(Size controlSize, Point mousePosition,
                                                                                  Rectangle screenRect, Point expectedPoint)
        {
            var dropDownLocationCalculator = new DropDownLocationCalculator(controlSize);
            var sut = dropDownLocationCalculator.CalculateLocationForDropDown(mousePosition, screenRect);

            Assert.AreEqual(expectedPoint, sut);
        }