Beispiel #1
0
        private static HintForm createHintForm(BoardInfo board, int x, int y, bool vertical)
        {
            var hint = new HintForm();

            CoordinateActors xActors = new CoordinateActors
            {
                dimensionSelector = sz => sz.Width,
                formExtentAssigner = coord => hint.Width = coord,
                formStartAssigner = coord => hint.Left = coord
            };

            CoordinateActors yActors = new CoordinateActors
            {
                dimensionSelector = sz => sz.Height,
                formExtentAssigner = coord => hint.Height = coord,
                formStartAssigner = coord => hint.Top = coord
            };

            CoordinateActors len = vertical ? yActors : xActors;
            CoordinateActors wid = vertical ? xActors : yActors;

            var corner = board.getCellCorner(x, y);
            var cellSize = board.getCellSize(x, y);

            int hintWidth = 1;
            int hintLength = len.dimensionSelector(cellSize);
            var center = board.getCellCenter(x, y);

            len.formStartAssigner(len.dimensionSelector(new Size(center)) + hintLength / 3);
            wid.formStartAssigner(wid.dimensionSelector(new Size(center)) - hintWidth / 2);

            hint.StartPosition = FormStartPosition.Manual;

            hint.Width = 1;
            hint.Height = 1;

            hint.Show();

            len.formExtentAssigner(hintLength / 3);
            wid.formExtentAssigner(hintWidth);

            hint.Hide();

            return hint;
        }