Exemple #1
0
        private void dSkinButton_BackGround_Click(object sender, EventArgs e)
        {
            bool           bbb            = dSkinCheckBox_ImageFuzzy.Checked;
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter      = "Image Files(*.All Types)|*.jpg;*.jpeg;*.png;*.bmp;*.gif";
            openFileDialog.FilterIndex = 1;
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                System.IO.FileInfo fl = new System.IO.FileInfo(openFileDialog.FileName);
                if (fl.Length > 1024 * 1024)
                {
                    //System.Windows.Forms.MessageBox.Show("请选择1M以内的横向图片");
                    AuroraMessageBox msg = null;
                    msg               = new AuroraMessageBox();
                    msg.strCaption    = "Aurora智能提示";
                    msg.strMessage    = "请选择1M以内的横向图片";
                    msg.strButtonText = "确定";
                    msg.StartPosition = FormStartPosition.Manual;
                    msg.Location      = new Point(this.Location.X + this.Width / 2 - msg.Width / 2, this.Location.Y + this.Height / 2 - msg.Height / 2);
                    msg.ShowDialog();
                    return;
                }
                mainFrm.str_BackGroundImage = dSkinTextBox_BackGround.Text = openFileDialog.FileName;
                mainFrm.SetPlayerBackground();
                mainFrm.ItemHoverColor = SkinTools.GetImageAverageColor(Image.FromFile(openFileDialog.FileName));
                HSL hsl = ColorConverterEx.ColorToHSL(mainFrm.ItemHoverColor);
                //hsl.Luminance += 0.2;
                //if (hsl.Luminance >= 1)
                //    hsl.Luminance = 0.99;
                hsl.Saturation += 0.2;
                if (hsl.Saturation >= 1)
                {
                    hsl.Saturation = 0.99;
                }
                mainFrm.ItemHoverColor           = ColorConverterEx.HSLToColor(hsl);
                dSkinCheckBox_ImageFuzzy.Checked = !bbb;
                dSkinCheckBox_ImageFuzzy.Checked = bbb;
                this.Invalidate();
            }
        }
Exemple #2
0
        /// <summary>
        /// 判断颜色偏向于暗色或亮色(true为偏向于暗色,false位偏向于亮色。)
        /// </summary>
        /// <param name="c">要判断的颜色</param>
        /// <returns>true为偏向于暗色,false位偏向于亮色。</returns>
        public static bool ColorSlantsDarkOrBright(Color c)
        {
            HSL hsl = ColorConverterEx.ColorToHSL(c);

            if (hsl.Luminance < 0.15d)
            {
                return(true);
            }
            else if (hsl.Luminance < 0.35d)
            {
                return(true);
            }
            else if (hsl.Luminance < 0.85d)
            {
                return(false);
            }
            else
            {
                return(false);
            }
        }