Пример #1
0
        private object OnCustomEditorEditValueEvent(CustomProperty sender, CustomEditorEventArgs e)
        {
            CustomProperty prop = sender;

            string svalue;
            if (e.value is DBCustomClass)
                svalue = ((DBCustomClass)e.value).Value.ToString();
            else
                svalue = e.value.ToString();
            
            try
            {
                if (m_lua != null)
                {
                    DoScript(prop);
                    
                    //如果是树结点,需要额外的增加事件,以支持新建从表记录
                    if (prop.Value is DBCustomClass)
                    {
                        LuaFunction fun = m_lua.GetFunction(GetRealFunctionName(prop.Key, "neednewrecord"));//"__fname__" + prop.Key + ".oneditvalue");
                        if (fun != null)
                        {
                            object[] retobjs = fun.Call(prop, e);
                            if (retobjs != null && retobjs.GetLength(0) > 0)
                            {
                                if (retobjs[0] is bool && (bool)retobjs[0])
                                {
                                    NewRecord(prop);
                                }
                            }
                        }
                    }
                    //else
                    {
                        LuaFunction fun = m_lua.GetFunction(GetRealFunctionName(prop.Key, "oneditvalue"));//"__fname__" + prop.Key + ".oneditvalue");
                        if (fun != null)
                        {
                            object[] retobjs = fun.Call(prop, e);
                            if (retobjs != null && retobjs.GetLength(0) > 0)
                            {
                                if (retobjs[0] is bool)
                                {
                                    if ((bool)retobjs[0] == true)
                                    {
                                        if (retobjs.GetLength(0) == 2)
                                        {
                                            //prop.DisplayValue = null;
                                            return retobjs[1];
                                        }
                                        else if (retobjs.GetLength(0) > 2)
                                        {
                                            //prop.DisplayValue = retobjs[2];
                                            //prop.IsClearDisplayValue = false;
                                            return retobjs[1];
                                        }
                                    }
                                }
                            }
                            return e.value;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //ScriptDebugForm frm = Program.MainForm.DebugForm;
                //frm.OutputBox.Text += ex.Message + "\r\n";
                //frm.Show();
                //frm.BringToFront();
                Helper.AddLog(ex.Message);
            }
            return e.value;//取消修改值,或者未更改值
        }
Пример #2
0
        private object OnCustomEditorEditValue(CustomProperty sender, CustomEditorEventArgs e)
        {
            CustomProperty prop = sender;

            string svalue = e.value.ToString();
            try
            {
                if (m_lua != null)
                {
                    DoScript(prop.ID);
                    LuaFunction fun = m_lua.GetFunction("__fname__" + prop.ID + ".oneditvalue");
                    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 e.value;//取消修改值,或者未更改值
        }