Пример #1
0
        private void SetDefaultPosition(WindowPositionData positionData, double defaultScreenProportion)
        {
            var screenWidth   = SystemParameters.PrimaryScreenWidth;
            var screenHeight  = SystemParameters.PrimaryScreenHeight;
            var desiredHeight = screenHeight * defaultScreenProportion;
            var desiredWidth  = screenWidth * defaultScreenProportion;

            positionData.Height = desiredHeight;
            positionData.Width  = desiredWidth;
            positionData.Top    = (screenHeight - desiredHeight) / 2;
            positionData.Left   = (screenWidth - desiredWidth) / 2;
        }
Пример #2
0
        // ReSharper disable CompareOfFloatsByEqualityOperator
        public WindowPositionSettings(WindowPositionData positionData, double defaultScreenProportion)
        {
            if (positionData == null)
            {
                CreateCentredPosition(defaultScreenProportion);
            }
            else
            {
                PositionData = positionData;
            }

            if (PositionData.Width == 0 || PositionData.Height == 0)
            {
                SetDefaultPosition(PositionData, defaultScreenProportion);
            }
        }
Пример #3
0
 private void CreateCentredPosition(double defaultScreenProportion)
 {
     PositionData = new WindowPositionData();
     SetDefaultPosition(PositionData, defaultScreenProportion);
 }