예제 #1
0
        private string SetValue(CssResourceList list, ComboBox combox)
        {
            string value = combox.Text;

            if (list.HasValue(value))
            {
                value = list.GetValue(value);
            }
            return(value);
        }
예제 #2
0
        /// <summary>
        /// 返回合理的属性值,如位置中的"内"返回inside
        /// </summary>
        /// <param name="property"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        private string ReturnValue(string property, string value)
        {
            CssResourceList list = CssResources.Resources[property];
            string          text = value;

            if (list.HasValue(text))
            {
                return(list.GetValue(text));
            }
            return(text);
        }
예제 #3
0
        private void GetValue()
        {
            string field = cbbField.Text;
            string unit  = cbbUnit.Text;

            if (string.IsNullOrEmpty(_value))
            {
                _value = "";
            }
            if (string.IsNullOrEmpty(field))
            {
                _value = "";
                return;
            }

            CssResourceList list = new CssResourceList();

            switch (_fieldUnitType)
            {
            case CssFieldUnitType.LineHeight:
                #region
            {
                list = CssResources.Resources["normal"];
                if (list.HasValue(field))
                {
                    field = list.GetValue(field);
                }
                list = CssResources.Resources["lineHeightUnit"];
                if (list.HasValue(unit) && cbbUnit.Enabled)
                {
                    unit = list.GetValue(unit);
                }
                else
                {
                    unit = "";
                }
                _value = field + unit;
            }
            break;

                #endregion
            case CssFieldUnitType.FontSize:
                #region
            {
                list = CssResources.Resources["font-size"];
                if (list.HasValue(field))
                {
                    field = list.GetValue(field);
                }
                list = CssResources.Resources["unit"];
                if (list.HasValue(unit) && cbbUnit.Enabled)
                {
                    unit = list.GetValue(unit);
                }
                else
                {
                    unit = "";
                }
                _value = field + unit;
            }
            break;

                #endregion
            case CssFieldUnitType.LevelPosition:
                #region
            {
                list = CssResources.Resources["levelPostion"];
                if (list.HasValue(field))
                {
                    field = list.GetValue(field);
                }
                list = CssResources.Resources["unit"];
                if (list.HasValue(unit) && cbbUnit.Enabled)
                {
                    unit = list.GetValue(unit);
                }
                else
                {
                    unit = "";
                }
                _value = field + unit;
            }
            break;

                #endregion
            case CssFieldUnitType.VerticalPosition:
                #region
            {
                list = CssResources.Resources["verticalPostion"];
                if (list.HasValue(field))
                {
                    field = list.GetValue(field);
                }
                list = CssResources.Resources["unit"];
                if (list.HasValue(unit) && cbbUnit.Enabled)
                {
                    unit = list.GetValue(unit);
                }
                else
                {
                    unit = "";
                }
                _value = field + unit;
            }
            break;

                #endregion
            case CssFieldUnitType.TextIndent:
                #region
            {
                list = CssResources.Resources["unit"];
                if (list.HasValue(unit) && cbbUnit.Enabled)
                {
                    unit = list.GetValue(unit);
                }
                else
                {
                    unit = "";
                }
                _value = field + unit;
            }
            break;

                #endregion
            case CssFieldUnitType.WordSpacing:
                #region
            {
                list = CssResources.Resources["normal"];
                if (list.HasValue(field))
                {
                    field = list.GetValue(field);
                }
                list = CssResources.Resources["wordSpaceUnit"];
                if (list.HasValue(unit) && cbbUnit.Enabled)
                {
                    unit = list.GetValue(unit);
                }
                else
                {
                    unit = "";
                }
                _value = field + unit;
            }
            break;

                #endregion
            case CssFieldUnitType.LetterSpacing:
                #region
            {
                list = CssResources.Resources["normal"];
                if (list.HasValue(field))
                {
                    field = list.GetValue(field);
                }
                list = CssResources.Resources["letterSpaceUnit"];
                if (list.HasValue(unit) && cbbUnit.Enabled)
                {
                    unit = list.GetValue(unit);
                }
                else
                {
                    unit = "";
                }
                _value = field + unit;
            }
            break;

                #endregion
            case CssFieldUnitType.VerticalAlign:
                #region
            {
                list = CssResources.Resources["vertical-align"];
                if (list.HasValue(field))
                {
                    field = list.GetValue(field);
                }
                list = CssResources.Resources["verticalUnit"];
                if (list.HasValue(unit) && cbbUnit.Enabled)
                {
                    unit = list.GetValue(unit);
                }
                else
                {
                    unit = "";
                }
                _value = field + unit;
            }
            break;

                #endregion
            case CssFieldUnitType.Padding:
                #region
            {
                list = CssResources.Resources["value"];
                if (list.HasValue(field))
                {
                    field = list.GetValue(field);
                }
                list = CssResources.Resources["unit"];
                if (list.HasValue(unit) && cbbUnit.Enabled)
                {
                    unit = list.GetValue(unit);
                }
                else
                {
                    unit = "";
                }
                _value = field + unit;
            }
            break;

                #endregion
            case CssFieldUnitType.MarginWidthHeightPosition:
                #region
            {
                list = CssResources.Resources["auto"];
                if (list.HasValue(field))
                {
                    field = list.GetValue(field);
                }
                list = CssResources.Resources["unit"];
                if (list.HasValue(unit) && cbbUnit.Enabled)
                {
                    unit = list.GetValue(unit);
                }
                else
                {
                    unit = "";
                }
                _value = field + unit;
            }
            break;

                #endregion
            case CssFieldUnitType.BorderWidth:
                #region
            {
                list = CssResources.Resources["borderWidth"];
                if (list.HasValue(field))
                {
                    field = list.GetValue(field);
                }
                list = CssResources.Resources["unit"];
                if (list.HasValue(unit) && cbbUnit.Enabled)
                {
                    unit = list.GetValue(unit);
                }
                else
                {
                    unit = "";
                }
                _value = field + unit;
            }
            break;

                #endregion
            case CssFieldUnitType.Clip:
                #region
            {
                list = CssResources.Resources["auto"];
                if (list.HasValue(field))
                {
                    field = list.GetValue(field);
                }
                list = CssResources.Resources["letterSpaceUnit"];
                if (list.HasValue(unit) && cbbUnit.Enabled)
                {
                    unit = list.GetValue(unit);
                }
                else
                {
                    unit = "";
                }
                _value = field + unit;
            }
            break;

                #endregion
            case CssFieldUnitType.Part:
                #region
            {
                list = CssResources.Resources["partUnit"];
                if (list.HasValue(unit) && cbbUnit.Enabled)
                {
                    unit = list.GetValue(unit);
                }
                else
                {
                    unit = "";
                }
                _value = field + unit;
            }
            break;

                #endregion
            case CssFieldUnitType.None:
                #region
            {
            }
            break;

                #endregion
            default:
                break;
            }
        }
예제 #4
0
        public override bool LeaveValidate()
        {
            #region 写入当前值
            //类型
            CssResourceList list = CssResources.Resources["position"];
            string          str  = cmbPosition.Text;
            if (list.HasValue(str))
            {
                str = list.GetValue(str);
            }
            Value.Properties["position"] = str;
            //浮动
            list = CssResources.Resources["float"];
            str  = cmbFloat.Text;
            if (list.HasValue(str))
            {
                str = list.GetValue(str);
            }
            Value.Properties["float"] = str;
            //显示
            list = CssResources.Resources["visibility"];
            str  = cmbVisibility.Text;
            if (list.HasValue(str))
            {
                str = list.GetValue(str);
            }
            Value.Properties["visibility"] = str;
            //Z轴
            list = CssResources.Resources["z-index"];
            str  = cmbZindex.Text;
            if (list.HasValue(str))
            {
                str = list.GetValue(str);
            }
            Value.Properties["z-index"] = str;
            //溢出
            list = CssResources.Resources["overflow"];
            str  = cmbOverflow.Text;
            if (list.HasValue(str))
            {
                str = list.GetValue(str);
            }
            Value.Properties["overflow"] = str;
            //清除
            list = CssResources.Resources["clear"];
            str  = cmbClear.Text;
            if (list.HasValue(str))
            {
                str = list.GetValue(str);
            }
            Value.Properties["clear"] = str;

            //宽度
            if (!WidthAuto)
            {
                Value.Properties["width"] = cssWidth.Value;
            }
            //高度
            if (!HeightAuto)
            {
                Value.Properties["height"] = cssHeight.Value;
            }
            //上
            Value.Properties["top"] = cssTop.Value;
            //右
            Value.Properties["right"] = cssRight.Value;
            //下
            Value.Properties["bottom"] = cssBottom.Value;
            //左
            Value.Properties["left"] = cssLeft.Value;
            //剪辑rect(auto,123px,123px,123px)
            string clip1 = "auto";
            string clip2 = "auto";
            string clip3 = "auto";
            string clip4 = "auto";
            if (string.IsNullOrEmpty(cssClipTop.Value) && string.IsNullOrEmpty(cssClipRight.Value) && string.IsNullOrEmpty(cssClipBottom.Value) && string.IsNullOrEmpty(cssClipLeft.Value))
            {
                Value.Properties["clip"] = "";
            }
            else
            {
                if (!string.IsNullOrEmpty(cssClipTop.Value))
                {
                    clip1 = cssClipTop.Value;
                }
                if (!string.IsNullOrEmpty(cssClipRight.Value))
                {
                    clip2 = cssClipRight.Value;
                }
                if (!string.IsNullOrEmpty(cssClipBottom.Value))
                {
                    clip3 = cssClipBottom.Value;
                }
                if (!string.IsNullOrEmpty(cssClipLeft.Value))
                {
                    clip4 = cssClipLeft.Value;
                }
                Value.Properties["clip"] = "rect(" + clip1 + "," + clip2 + "," + clip3 + "," + clip4 + ")";
            }

            #endregion

            foreach (Control control in Controls)
            {
                string curText = "";
                string cssName = "";
                Type   type    = control.GetType();
                if (type == typeof(ComboBox))
                {
                    #region  拉框
                    ComboBox cmb = (ComboBox)control;
                    curText = cmb.Text;
                    bool _isError = false;
                    switch (cmb.Name)
                    {
                    case "cmbPosition":
                        cssName  = "position";
                        _isError = CssResources.CheckValue(cssName, curText, false);
                        break;

                    case "cmbFloat":
                        cssName  = "float";
                        _isError = CssResources.CheckValue(cssName, curText, false);
                        break;

                    case "cmbVisibility":
                        cssName  = "visibility";
                        _isError = CssResources.CheckValue(cssName, curText, false);
                        break;

                    case "cmbZindex":
                        cssName = "z-index";
                        double d = 0;
                        if (curText == "(值)")
                        {
                            CssUtility.ShowReplaceMsg(curText);
                            cmb.Focus();
                            return(false);
                        }
                        if (curText != "自动" && curText != "auto" && !string.IsNullOrEmpty(curText) && !Double.TryParse(curText, out d))
                        {
                            _isError = true;
                        }
                        else
                        {
                            _isError = false;
                        }
                        break;

                    case "cmbOverflow":
                        cssName  = "overflow";
                        _isError = CssResources.CheckValue(cssName, curText, false);
                        break;

                    case "cmbClear":
                        cssName  = "clear";
                        _isError = CssResources.CheckValue(cssName, curText, false);
                        break;

                    default:
                        break;
                    }
                    if (_isError)
                    {
                        if (!CssUtility.ShowNotStandard(curText))
                        {
                            cmb.Focus();
                            return(false);
                        }
                    }
                    #endregion
                }
                if (type == typeof(GroupBox))
                {
                    foreach (Control item in control.Controls)
                    {
                        if (item.GetType() == typeof(CssFieldUnit))
                        {
                            #region 数值单位型
                            CssFieldUnit cfu = (CssFieldUnit)item;
                            curText = cfu.Value;
                            cssName = cfu.Name;
                            if (!cfu.CheckValue())
                            {
                                cfu.SelectFirst();
                                return(false);
                            }
                            #endregion
                        }
                    }
                }
            }

            return(base.LeaveValidate());
        }
예제 #5
0
        /// <summary>
        /// 保存CSS的值
        /// </summary>
        private void  SaveCssValue()
        {
            //单词间距
            CssResourceList list = CssResources.Resources["wordSpaceUnit"];
            string          str  = css_WordSpace.Value;

            if (list.HasValue(str))
            {
                str = list.GetValue(str);
            }
            Value.Properties[WORD_SPACING] = str;

            //字母间距
            list = CssResources.Resources["letterSpaceUnit"];
            str  = css_CharSpace.Value;
            if (list.HasValue(str))
            {
                str = list.GetValue(str);
            }
            Value.Properties[LETTER_SPACING] = str;

            //垂直对齐
            list = CssResources.Resources[VERTICL_ALIGN];
            str  = css_VertiSimilar.Value;
            if (list.HasValue(str))
            {
                str = list.GetValue(str);
            }
            Value.Properties[VERTICL_ALIGN] = str;

            //文本对齐
            list = CssResources.Resources[TEXT_ALIGN];
            str  = cb_TextSimilar.Text;
            if (list.HasValue(str))
            {
                str = list.GetValue(str);
            }
            Value.Properties[TEXT_ALIGN] = str;

            //文本缩进
            // list = CssResources.Resources[TEXT_INDEN];
            str = css_TextIndet.Value;
            //if (list.HasValue(str))
            //{
            //    str = list.GetValue(str);
            //}
            Value.Properties[TEXT_INDEN] = str;

            //空格
            list = CssResources.Resources[WHITE_SPACE];
            str  = cb_Space.Text;
            if (list.HasValue(str))
            {
                str = list.GetValue(str);
            }
            Value.Properties[WHITE_SPACE] = str;

            //显示
            list = CssResources.Resources[DISPLAY];
            str  = cb_Show.Text;
            if (list.HasValue(str))
            {
                str = list.GetValue(str);
            }
            Value.Properties[DISPLAY] = str;
        }
예제 #6
0
        /// <summary>
        /// 保存CSS的值
        /// </summary>
        private void SaveCssValue()
        {
            //字体

            Regex r = new Regex("[^\x00-\xff]"); //匹配汉字
            char  c = '"';

            string strsign = c.ToString(); //双引号
            string str     = cb_Font.Text;

            string [] strFont = str.Split(new char[] { ',' });

            //对字体做一些处理
            str = "";
            foreach (string s in strFont)
            {
                string strtemp = s.Trim();
                if (strtemp.IndexOf(" ") >= 0 && !strtemp.StartsWith(strsign) && !strtemp.EndsWith(strsign))  //字体中有空格
                {
                    str += '"' + strtemp + '"' + ", ";
                }
                else if (r.Matches(s).Count > 0 && !strtemp.StartsWith(strsign) && !strtemp.EndsWith(strsign)) //字体中有汉字
                {
                    str += '"' + strtemp + '"' + ", ";
                }
                else
                {
                    str += strtemp + ", ";
                }
            }
            //str = str.TrimEnd(new char[] { ' ' });//去掉最后一个空格
            str = str.Remove(str.Length - 2);//去掉最后的 逗号和空格
            Value.Properties[FONT_FAMILY] = str;

            //大小
            CssResourceList list = CssResources.Resources[FONT_SIZE];

            str = css_FontSize.Value;
            if (list.HasValue(str))
            {
                str = list.GetValue(str);
            }
            Value.Properties[FONT_SIZE] = str;

            //粗细
            list = CssResources.Resources[FONT_WEIGHT];
            str  = cb_FontThick.Text;
            if (list.HasValue(str))
            {
                str = list.GetValue(str);
            }
            Value.Properties[FONT_WEIGHT] = str;

            //样式
            list = CssResources.Resources[FONT_STYLE];
            str  = cb_FontMode.Text;
            if (list.HasValue(str))
            {
                str = list.GetValue(str);
            }
            Value.Properties[FONT_STYLE] = str;
            //变体
            list = CssResources.Resources[FONT_VARIANT];
            str  = cb_Anamorphosis.Text;
            if (list.HasValue(str))
            {
                str = list.GetValue(str);
            }
            Value.Properties[FONT_VARIANT] = str;

            //行高
            list = CssResources.Resources["normal"];
            str  = css_FontRowHeight.Value;
            if (list.HasValue(str))
            {
                str = list.GetValue(str);
            }
            Value.Properties[FONT_HEIGHT] = str;

            //大小写
            list = CssResources.Resources[TEXT_TRANSFORM];
            str  = cb_CapsLock.Text;
            if (list.HasValue(str))
            {
                str = list.GetValue(str);
            }
            Value.Properties[TEXT_TRANSFORM] = str;

            //修饰
            if (chk_None.Checked)
            {
                str = "none";
            }
            else
            {
                str = "";
                if (chk_Underline.Checked)
                {
                    str += "underline ";
                }
                if (chk_Upline.Checked)
                {
                    str += "overline ";
                }
                if (chk_Delline.Checked)
                {
                    str += "line-through ";
                }
                if (chk_Ray.Checked)
                {
                    str += "blink ";
                }
                if (str.Length > 0)
                {
                    str = str.Remove(str.Length - 1);//去掉最后一个空格
                }
            }
            Value.Properties[TEXT_DECORATION] = str;

            //颜色
            str = colorText_FontClolor.ColorText;
            Value.Properties[COLOR] = str;
        }