Example #1
0
 //½öΪ objpool ·þÎñ
 public void Init(CustomClass Parent, object value)
 {
     //m_nLastServerVersion = -1;
     m_parent = Parent;
     this.Value = value;
     DefaultValue = null;
 }
Example #2
0
 public TreeValueEventArgs(CustomClass Parent, CustomProperty Child)//, object id, object value)
 {
     m_parentclass = Parent;
     m_childclass = Child;
     //m_id = id;
     //m_class = Parent;
 }
Example #3
0
 public CustomProperty(CustomClass parent, string strID, string sName, object value, bool bReadOnly, bool bVisible, enumValueType vtType)
 {
     m_combofieldhelper = new CombxHelper(this);
     
     m_parent = parent;
     this.m_strid = strID;
     this.sName = sName;
     this.m_objValue = value;
     this.bReadOnly = bReadOnly;
     this.bVisible = bVisible;
     this.m_vt = vtType;
 }
Example #4
0
 public static DBCustomProperty GetProperty(int nFieldID, CustomClass parent, string strID, string sName, object value, bool bReadOnly, bool bVisible, enumValueType vtType)
 {
     if (!m_bEnabled)
         return new DBCustomProperty(parent, strID, sName, value, bReadOnly, bVisible, vtType);
     string strkey = GetPropKey(nFieldID, strID, sName, value, bReadOnly, bVisible, vtType);
     DBCustomProperty prop = null;
     if (m_poolprop.ContainsKey(strkey))
     {
         prop = m_poolprop[strkey];
         m_poolprop.Remove(strkey);
         prop.Init(parent, value);
     }
     else
         prop = new DBCustomProperty(parent, strID, sName, value, bReadOnly, bVisible, vtType);
     prop.FieldID = nFieldID;
     return prop;
 }
Example #5
0
        public static DBCustomProperty GetProperty(int nFieldID, CustomClass parent, string strID, string sName, object value, bool bReadOnly, bool bVisible, enumValueType vtType)
        {
            if (!m_bEnabled)
            {
                return(new DBCustomProperty(parent, strID, sName, value, bReadOnly, bVisible, vtType));
            }
            string           strkey = GetPropKey(nFieldID, strID, sName, value, bReadOnly, bVisible, vtType);
            DBCustomProperty prop   = null;

            if (m_poolprop.ContainsKey(strkey))
            {
                prop = m_poolprop[strkey];
                m_poolprop.Remove(strkey);
                prop.Init(parent, value);
            }
            else
            {
                prop = new DBCustomProperty(parent, strID, sName, value, bReadOnly, bVisible, vtType);
            }
            prop.FieldID = nFieldID;
            return(prop);
        }
Example #6
0
 public DBCustomProperty(CustomClass parent, string strID, string sName, object value, bool bReadOnly, bool bVisible, enumValueType vtType)
     :base(parent, strID, sName, value, bReadOnly, bVisible, vtType)
 {
     //DBCustomClass cls = parent as DBCustomClass;
     //m_lock = new RecordLock(cls.Conn, cls.MainTable, cls.DBPrimaryKey, cls.ModId);
 }
Example #7
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);
                }
            }
        }
Example #8
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);
                }
            }
        }
Example #9
0
        private void GetClassContent(CustomClass clsParent, DataRow CurrRow, object[] keyvalues)
        {
            if (CurrRow == null) // 如果没有找到相关记录,则清除下属所有的属性。
            {
                ClearProperties();
                return;
            }           

            m_findkeys = keyvalues;
            ClearProperties();            

            for (int i = 0; i < m_listSortedCol.Count; i ++ )
            {
                this.Add(GetProperty(CurrRow, m_listSortedCol[i]));                
            }
        }
Example #10
0
 private object OnGetTreeValueEvent(CustomClass sender, TreeValueEventArgs e)
 {
     CustomClass parent = sender;
     CustomProperty prop = e.tree;
     object svalue = null;
     try
     {
         if (m_lua != null && prop.ID != null)
         {
             this.DoScript(prop);
             LuaFunction fun = m_lua.GetFunction(GetRealFunctionName(prop.Key, "ongettreevalue"));//"__fname__" + prop.Key + ".ongetreevalue");
             if (fun != null)
             {
                 CustomClass child = (CustomClass)e.tree.Value;
                 svalue = child.Value;//e.tree.Description;
                 object[] retobjs = fun.Call(prop, e);
                 if (retobjs != null && retobjs.GetLength(0) > 0)
                 {
                     if (retobjs[0] is bool)
                     {
                         if ((bool)retobjs[0] == true && retobjs.GetLength(0) > 1)
                             return retobjs[1];
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         //ScriptDebugForm frm = Program.MainForm.DebugForm;
         //frm.OutputBox.Text += ex.Message + "\r\n";
         //frm.Show();
         //frm.BringToFront();
         Helper.AddLog(ex.Message);
     }
     return svalue;//取消修改值,或者未更改值
 }
Example #11
0
 public DBCustomProperty(CustomClass parent, string strID, string sName, object value, bool bReadOnly, bool bVisible, enumValueType vtType)
     : base(parent, strID, sName, value, bReadOnly, bVisible, vtType)
 {
     //DBCustomClass cls = parent as DBCustomClass;
     //m_lock = new RecordLock(cls.Conn, cls.MainTable, cls.DBPrimaryKey, cls.ModId);
 }
Example #12
0
 public object DoEditValue(CustomClass instance, CustomPropertyDescriptor descriptor, object value)
 {
     object newvalue = instance.OnCustomEditValue(descriptor.Property, value);
     if (value is CustomClass)
     {
         object newrealvalue = newvalue is CustomClass ? (newvalue as CustomClass).Value : newvalue;
         if (!(value as CustomClass).Value.Equals(newrealvalue))
             descriptor.Property.SetValue(newrealvalue);
     }
     return newvalue == null ? value : newvalue;
 }
Example #13
0
        private object OnGetTreeValue(CustomClass sender, TreeValueEventArgs e)
        {
            CustomClass prop = sender;

            string svalue = e.tree.Description;
            try
            {
                if (m_lua != null && prop.ID != null)
                {
                    DoScript(prop.ID);
                    LuaFunction fun = m_lua.GetFunction("__fname__" + prop.ID + ".ongetreevalue");
                    if (fun != null)
                    {
                        object[] retobjs = fun.Call(prop, e);
                        if (retobjs.GetLength(0) > 0)
                        {
                            if (retobjs[0] is bool)
                            {
                                if ((bool)retobjs[0] == true && retobjs.GetLength(0) > 1)
                                    return retobjs[1];
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ScriptDebugForm frm = ((MainForm)ParentForm).DebugForm;
                frm.OutputBox.Text += ex.Message + "\r\n";
                frm.Show();
                frm.BringToFront();
            }
            return svalue;//取消修改值,或者未更改值
        }