コード例 #1
0
        //获取图片主色调,设置前景色
        public static void SetForeColor(DSkinForm form, Image image)
        {
            Color cl = SkinTools.GetImageAverageColor(image);

            if ((cl.B + cl.G + cl.R) / 2 > 200)
            {
                form.ForeColor = Color.Black;
            }
            else
            {
                form.ForeColor = Color.WhiteSmoke;
            }
        }
コード例 #2
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();
            }
        }