Exemple #1
0
        private void ColorEditor_ColorEvent(Component.ColorEditor.ColorEventArgs e)
        {
            //this._model.HexThin1 = this.ToHex(e, -30);
            //this._model.HexThin2 = this.ToHex(e, -60);
            //this._model.HexDark1 = this.ToHex(e, 30);
            //this._model.HexDark2 = this.ToHex(e, 60);

            // データモデルがうまいこと機能しないのでとりあえず直接設定。。
            this.cThins1.Hex = this.ToHex(e, -30);
            this.cThins2.Hex = this.ToHex(e, -60);
            this.cDark1.Hex  = this.ToHex(e, 30);
            this.cDark2.Hex  = this.ToHex(e, 60);
        }
Exemple #2
0
        /// <summary>
        /// convert int to hex with offset
        /// </summary>
        /// <param name="e">event arguement</param>
        /// <param name="offSet">color offset</param>
        /// <returns>hex color</returns>
        private string ToHex(Component.ColorEditor.ColorEventArgs e, int offSet)
        {
            string toHexSub(int value)
            {
                var val = value + offSet;

                if (val < 0)
                {
                    val = 0;
                }
                else if (255 < val)
                {
                    val = 255;
                }
                var result = Convert.ToString(val, 16);

                if (1 == result.Length)
                {
                    result = "0" + result;
                }
                return(result);
            };
            return(toHexSub(e.R) + toHexSub(e.G) + toHexSub(e.B));
        }