Esempio n. 1
0
        public override void SetValue(object component, object value)
        {
            try
            {
                SetValueCommand cmd = new SetValueCommand();
                cmd.Execute();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                throw;
            }

            if (component is CustomClass)
            {
                CustomClass o = (CustomClass)component;
                if (m_Property.ValueType == enumValueType.vtCombo)
                {
                    o.OnDataValidate(m_Property, m_Property.ComboValues[value], value);
                }
                else
                {
                    o.OnDataValidate(m_Property, value, value);
                }
            }

            if (m_Property.ValueType == enumValueType.vtFileNameScript)
            {
                string strFullPath = (string)value;

                // to 相对路径
                string strBase = null;
                if (System.IO.File.Exists(Application.StartupPath + "\\GameDesingerTools.ini"))
                {
                    StringBuilder sb = new StringBuilder(255);
                    FileFolderHelper.ReadIniFile("Browsing Base Folder", "Script", "", sb, 255, Application.StartupPath + "\\GameDesingerTools.ini");
                    strBase = sb.ToString();
                }
                string strConverted = strFullPath.Replace(strBase + "\\", "");

                // '\' -> '/'
                strConverted     = strConverted.Replace("\\", "/");
                m_Property.Value = strConverted;
            }
            else if (m_Property.ValueType == enumValueType.vtExpandNode && m_Property.Value is DBCustomClass)
            {
                //((DBCustomClass)m_Property.Value).Value = value;
                //((DBCustomClass)m_Property.Value).ReinitData();
                //((DBCustomClass)m_Property.Value).GetDynamicClass(new object[]{value});
                //m_Property.Value = (DBCustomClass)m_Property.Value;
                //m_Property.ValueType = enumValueType.vtExpandNode;
            }
            else
            {
                //if (m_Property.IsClearDisplayValue) //仅在 oneditvalue 时会被置 false, 用于设置显示值,不影响保存的值
                //    m_Property.DisplayValue = null;
                //m_Property.IsClearDisplayValue = true;
                m_Property.Value = value;
            }

            if (component is CustomClass)
            {
                CustomClass o = (CustomClass)component;
                if (m_Property.ValueType == enumValueType.vtCombo)
                {
                    o.OnAfterDataValidate(m_Property, m_Property.ComboValues[value], value);
                }
                else
                {
                    o.OnAfterDataValidate(m_Property, value, value);
                }
            }
        }
Esempio n. 2
0
        //只有在树结点中输入新值,才会调用这里
        public void SetValue(object value)
        {
            if (value == Value)
            {
                return;
            }

            if (Parent != null && Parent is CustomClass)
            {
                CustomClass o = (CustomClass)Parent;
                if (ValueType == enumValueType.vtCombo)
                {
                    o.OnDataValidate(this, ComboValues[value], value);
                }
                else
                {
                    o.OnDataValidate(this, value, value);
                }
            }

            if (Parent != null && Parent is DBCustomClass)
            {
                ((DBCustomClass)Parent).MarkValueChanged();
            }

            bool bRealField = false;

            if (m_objValue is DBCustomClass) //如果是树,则需要影响下面的结点,而不是简单替换值
            {
                DBCustomClass cls = (DBCustomClass)m_objValue;
                bRealField = cls.ParentFieldType != 1;
                //cls.Value = value;
                //cls.GetDynamicClass(new object[] { value }); //不能直接使用value,因可能是修改的非主键字段,要获取这个真正的主键
                if (bRealField)
                {
                    cls.ReplaceSubFindKey(this, value);
                }
                cls.OnAsynNotifyEvent(1, null);//todo:多个页存在同一表同一字段时,会导致重复刷新多次
            }
            else
            {
                m_objValue = value;
                bRealField = true;
            }
            //如果改了主键值,则需要特殊处理
            if (Parent != null && Parent is DBCustomClass && bRealField)
            {
                DBCustomClass parentClass = (DBCustomClass)Parent;
                //parentClass.DBPrimaryKey
                parentClass.ModifyFindKeys(this, value);
            }
            if (Parent != null && Parent is CustomClass)
            {
                CustomClass o = (CustomClass)Parent;
                if (ValueType == enumValueType.vtCombo)
                {
                    o.OnAfterDataValidate(this, ComboValues[value], value);
                }
                else
                {
                    o.OnAfterDataValidate(this, value, value);
                }
            }
        }