예제 #1
0
        private string GetValue(CssResourceList list, string saveValue)
        {
            string value = saveValue;

            if (list.HasValue(value))
            {
                value = list.ValueToText(value);
            }
            return(value);
        }
예제 #2
0
        private void InitControls(string before, string after,
                                  bool isGeneralString, KeyValuePair <string, string> fieldUnit)
        {
            CssResourceList list = new CssResourceList();

            if (isGeneralString)
            {
                if (string.IsNullOrEmpty(fieldUnit.Value))
                {
                    cbbField.Text   = Value;
                    cbbUnit.Text    = "";
                    cbbUnit.Enabled = true;
                }
                else
                {
                    cbbField.Text   = fieldUnit.Key;
                    list            = CssResources.Resources[after];
                    cbbUnit.Text    = list.ValueToText(fieldUnit.Value);
                    cbbUnit.Enabled = true;
                }
            }
            else
            {
                list = CssResources.Resources[before];
                if (list.HasValue(Value))
                {
                    cbbField.Text = list.ValueToText(Value);
                }
                else
                {
                    cbbField.Text = Value;
                }
                cbbUnit.Text    = "";
                cbbUnit.Enabled = false;
            }
        }
예제 #3
0
        /// <summary>
        /// 根据源设置各个控件的值
        /// </summary>
        private void InitControl()
        {
            if (_value == null)
            {
                _value = "";
            }
            CssResourceList list = new CssResourceList();
            KeyValuePair <string, string> fieldUnit = new KeyValuePair <string, string>();
            bool isGeneralString = CssUtility.ParseFieldUnit(Value, out fieldUnit);

            switch (_fieldUnitType)
            {
            case CssFieldUnitType.LineHeight:
                #region
            {
                if (isGeneralString)
                {
                    if (string.IsNullOrEmpty(fieldUnit.Value))
                    {
                        cbbField.Text   = Value;
                        cbbUnit.Text    = "倍行高";
                        cbbUnit.Enabled = true;
                    }
                    else
                    {
                        cbbField.Text   = fieldUnit.Key;
                        list            = CssResources.Resources["lineHeightUnit"];
                        cbbUnit.Text    = list.ValueToText(fieldUnit.Value);
                        cbbUnit.Enabled = true;
                    }
                }
                else
                {
                    list = CssResources.Resources["normal"];
                    if (list.HasValue(Value))
                    {
                        cbbField.Text = list.ValueToText(Value);
                    }
                    else
                    {
                        cbbField.Text = Value;
                    }
                    cbbUnit.Text    = "";
                    cbbUnit.Enabled = false;
                }
            }
            break;

                #endregion
            case CssFieldUnitType.FontSize:
                #region
            {
                InitControls("font-size", "unit", isGeneralString, fieldUnit);
            }
            break;

                #endregion
            case CssFieldUnitType.LevelPosition:
                #region
            {
                InitControls("levelPostion", "unit", isGeneralString, fieldUnit);
            }
            break;

                #endregion
            case CssFieldUnitType.VerticalPosition:
                #region
            {
                InitControls("verticalPostion", "unit", isGeneralString, fieldUnit);
            }
            break;

                #endregion
            case CssFieldUnitType.TextIndent:
                #region
            {
                if (isGeneralString)
                {
                    if (string.IsNullOrEmpty(fieldUnit.Value))
                    {
                        cbbField.Text   = Value;
                        cbbUnit.Text    = "";
                        cbbUnit.Enabled = true;
                    }
                    else
                    {
                        cbbField.Text   = fieldUnit.Key;
                        list            = CssResources.Resources["unit"];
                        cbbUnit.Text    = list.ValueToText(fieldUnit.Value);
                        cbbUnit.Enabled = true;
                    }
                }
                else
                {
                    cbbField.Text   = Value;
                    cbbUnit.Text    = "";
                    cbbUnit.Enabled = false;
                }
            }
            break;

                #endregion
            case CssFieldUnitType.WordSpacing:
                #region
            {
                InitControls("normal", "wordSpaceUnit", isGeneralString, fieldUnit);
            }
            break;

                #endregion
            case CssFieldUnitType.LetterSpacing:
                #region
            {
                InitControls("normal", "letterSpaceUnit", isGeneralString, fieldUnit);
            }
            break;

                #endregion
            case CssFieldUnitType.VerticalAlign:
                #region
            {
                InitControls("vertical-align", "verticalUnit", isGeneralString, fieldUnit);
            }
            break;

                #endregion
            case CssFieldUnitType.Padding:
                #region
            {
                InitControls("value", "unit", isGeneralString, fieldUnit);
            }
            break;

                #endregion
            case CssFieldUnitType.MarginWidthHeightPosition:
                #region
            {
                InitControls("auto", "unit", isGeneralString, fieldUnit);
            }
            break;

                #endregion
            case CssFieldUnitType.BorderWidth:
                #region
            {
                InitControls("borderWidth", "unit", isGeneralString, fieldUnit);
            }
            break;

                #endregion
            case CssFieldUnitType.Clip:
                #region
            {
                InitControls("auto", "letterSpaceUnit", isGeneralString, fieldUnit);
            }
            break;

                #endregion
            case CssFieldUnitType.Part:
                #region
            {
                if (isGeneralString)
                {
                    if (string.IsNullOrEmpty(fieldUnit.Value))
                    {
                        cbbField.Text   = Value;
                        cbbUnit.Text    = "";
                        cbbUnit.Enabled = true;
                    }
                    else
                    {
                        cbbField.Text   = fieldUnit.Key;
                        list            = CssResources.Resources["partUnit"];
                        cbbUnit.Text    = list.ValueToText(fieldUnit.Value);
                        cbbUnit.Enabled = true;
                    }
                }
                else
                {
                    cbbField.Text   = Value;
                    cbbUnit.Text    = "";
                    cbbUnit.Enabled = false;
                }
            }
            break;

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

                #endregion
            default:
                break;
            }
        }