private void reportMoveToolStripMenuItem_Click() { // This is an event handler triggered by a menu item (or button). _reporterWin.BackColor = Color.Black; _reporterWin.Height = 20; _reporterWin.FormBorderStyle = FormBorderStyle.None; _reporterWin.TopMost = true; PositionReporterEdge(); // Position the window. _reporterWin.Show(); } /// <summary> /// Position the "Reporter" form next to the current form. /////////// private void PositionReporterEdge() { int screenHeight = Screen.PrimaryScreen.WorkingArea.Height; int screenWidth = Screen.PrimaryScreen.WorkingArea.Width; Point parentPoint = this.Location; int parentHeight = this.Height; int parentWidth = this.Width; int childHeight = _reporterWin.Height; int childWidth = _reporterWin.Width; int resultX; int resultY; if ((parentPoint.Y + parentHeight + childHeight) > screenHeight) { // If we would move off the screen, position near the top. resultY = parentPoint.Y + 50; // move down 50 resultX = parentPoint.X; } else { // Position on the edge. resultY = parentPoint.Y + parentHeight; resultX = parentPoint.X; } // set our child form to the new position _reporterWin.Location = new Point(resultX, resultY); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)