Exemplo n.º 1
0
        // Returns the Foreground brush depending on the style
        private Brush GetForegroundDpadBrush(DirectInputDpadStyle style, int position, Rectangle boundingBox)
        {
            if (style != null)
            {
                string imageFileName = style.BackgroundNeutralImageFileName;

                if (position == 0)
                {
                    imageFileName = style.BackgroundTopImageFileName ?? style.BackgroundNeutralImageFileName;
                }
                else if (position == 4500)
                {
                    imageFileName = style.BackgroundTopRightImageFileName ?? style.BackgroundNeutralImageFileName;
                }
                else if (position == 9000)
                {
                    imageFileName = style.BackgroundRightImageFileName ?? style.BackgroundNeutralImageFileName;
                }
                else if (position == 13500)
                {
                    imageFileName = style.BackgroundBottomRightImageFileName ?? style.BackgroundNeutralImageFileName;
                }
                else if (position == 18000)
                {
                    imageFileName = style.BackgroundBottomImageFileName ?? style.BackgroundNeutralImageFileName;
                }
                else if (position == 22500)
                {
                    imageFileName = style.BackgroundBottomLeftImageFileName ?? style.BackgroundNeutralImageFileName;
                }
                else if (position == 27000)
                {
                    imageFileName = style.BackgroundLeftImageFileName ?? style.BackgroundNeutralImageFileName;
                }
                else if (position == 31500)
                {
                    imageFileName = style.BackgroundTopLeftImageFileName ?? style.BackgroundNeutralImageFileName;
                }

                return(imageFileName == null || !FileHelper.StyleImageExists(imageFileName)
                    ? string.IsNullOrEmpty(style.BackgroundNeutralImageFileName) || !FileHelper.StyleImageExists(style.BackgroundNeutralImageFileName)
                    ? new SolidBrush(style.ForegroundColor) : this.BrushFromImage(boundingBox, style.BackgroundNeutralImageFileName)
                    : this.BrushFromImage(boundingBox, imageFileName));
            }
            else
            {
                return(new SolidBrush(GlobalSettings.CurrentStyle.DefaultDirectInputDpadStyle.ForegroundColor));
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="KeyStyleForm" /> class.
        /// </summary>
        /// <param name="initialStyle">The initial style.</param>
        /// <param name="defaultStyle">The default style to revert to when the override checkbox is unchecked.</param>
        public DirectInputDpadStyleForm(DirectInputDpadStyle initialStyle, DirectInputDpadStyle defaultStyle)
        {
            if (defaultStyle == null)
            {
                throw new ArgumentNullException(nameof(defaultStyle));
            }
            if (defaultStyle.SubStyle == null)
            {
                throw new ArgumentNullException(nameof(defaultStyle));
            }

            this.initialStyle = ((DirectInputDpadStyle)initialStyle?.Clone()) ?? new DirectInputDpadStyle {
                SubStyle = null
            };
            this.defaultStyle = (DirectInputDpadStyle)defaultStyle?.Clone();
            this.currentStyle = (DirectInputDpadStyle)this.initialStyle.Clone();

            this.InitializeComponent();
        }