예제 #1
0
 public void RemoveStartupScript(ControlBase control)
 {
     for (int i = 0; i < _startupScriptBlockList.Count; i++)
     {
         if (_startupScriptBlockList[i].Control == control)
         {
             _startupScriptBlockList.RemoveAt(i);
             break;
         }
     }
 }
예제 #2
0
파일: FState.cs 프로젝트: proson/Fine-UI
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="control">控件</param>
 public FState(ControlBase control)
 {
     _control = control;
 }
예제 #3
0
        /// <summary>
        /// 控件control的注册脚本是否存在
        /// </summary>
        /// <param name="control"></param>
        /// <returns></returns>
        public bool IsStartupScriptExist(ControlBase control)
        {
            foreach (ScriptBlock cs in _startupScriptBlockList)
            {
                if (cs.Control == control)
                {
                    return true;
                }
            }

            return false;
        }
예제 #4
0
        public ScriptBlock GetStartupScript(ControlBase control)
        {
            foreach (ScriptBlock cs in _startupScriptBlockList)
            {
                if (cs.Control == control)
                {
                    return cs;
                }
            }

            return null;
        }
예제 #5
0
        /// <summary>
        /// 添加脚本
        /// 相同控件的脚本合并在一起([email protected] 2008-7-4)
        /// </summary>
        /// <param name="control"></param>
        /// <param name="script"></param>
        /// <param name="extraScript"></param>
        public void AddStartupScript(ControlBase control, string script, string extraScript)
        {
            ScriptBlock cs = new ScriptBlock(control, script);

            ScriptBlock existBlock = GetStartupScript(control);
            if (existBlock == null)
            {
                _startupScriptBlockList.Add(cs);
            }
            else
            {
                existBlock.Script += script;
                //existBlock.ExtraScript += extraScript;
            }
        }
예제 #6
0
 public void AddStartupScript(ControlBase control, string script)
 {
     AddStartupScript(control, script, String.Empty);
 }
예제 #7
0
        ///// <summary>
        ///// 取得要插入位置的 换行前缀
        ///// </summary>
        ///// <param name="insertIndex"></param>
        ///// <param name="list"></param>
        ///// <returns></returns>
        //private string GetLineBreakString(int insertIndex, List<ScriptBlock> list)
        //{
        //    if (insertIndex == list.Count)
        //    {
        //        return DEBUG_LINE_BREAK;
        //    }
        //    else
        //    {
        //        return "\r\n" + '\t' + GetStringPrefix(list[insertIndex].Script);
        //    }
        //}

        ///// <summary>
        ///// 取得字符串的换行前缀
        ///// </summary>
        ///// <param name="script"></param>
        ///// <returns></returns>
        //private string GetStringPrefix(string script)
        //{
        //    StringBuilder sb = new StringBuilder();
        //    for (int i = 2, count = script.Length; i < count; i++)
        //    {
        //        if (script[i] == '\t')
        //        {
        //            sb.Append("\t");
        //        }
        //        else
        //        {
        //            break;
        //        }
        //    }

        //    return sb.ToString();
        //}

        #endregion

        #region GetInsertIndex

        /// <summary>
        /// 取得应该将Script插入的位置
        /// 要能够向上回溯,因为控件的父控件可能不存在列表中,而父控件的父控件存在列表中
        /// </summary>
        /// <param name="testControl"></param>
        /// <param name="checkList"></param>
        /// <returns></returns>
        private int GetInsertIndex(ControlBase testControl, List<ScriptBlock> checkList)
        {
            int returnIndex = checkList.Count;

            // 这个地方不能是ControlBase,比如用户控件中控件,要能向上回溯到UserControlConnector
            Control parentControl = testControl.Parent;
            while (parentControl != null)
            {
                for (int i = 0, count = checkList.Count; i < count; i++)
                {
                    Control checkControl = checkList[i].Control;

                    if (checkControl != null && parentControl == checkControl)
                    {
                        return i;
                    }
                }

                parentControl = parentControl.Parent;
            }

            if (testControl is Menu)
            {
                // 如果菜单控件没有上级,则默认将脚本放在最前面
                return 0;
            }
            else
            {
                return returnIndex;
            }
        }
예제 #8
0
 public ScriptBlock(ControlBase control, string script)
 {
     _control = control;
     _script = script;
     
 }
예제 #9
0
        /// <summary>
        /// 取得应该将Script插入的位置
        /// 要能够向上回溯,因为控件的父控件可能不存在列表中,而父控件的父控件存在列表中
        /// </summary>
        /// <param name="testControl"></param>
        /// <param name="checkList"></param>
        /// <returns></returns>
        private int GetInsertIndex(ControlBase testControl, List<ScriptBlock> checkList)
        {
            int returnIndex = checkList.Count;

            ControlBase parentControl = testControl.Parent as ControlBase;

            while (parentControl != null)
            {
                for (int i = 0, count = checkList.Count; i < count; i++)
                {
                    ControlBase checkControl = checkList[i].Control as ControlBase;

                    if (checkControl != null && parentControl == checkControl)
                    {
                        return i;
                    }
                }

                parentControl = parentControl.Parent as ControlBase;
            }

            if (testControl is Menu)
            {
                // 如果菜单控件没有上级,则默认将脚本放在最前面
                return 0;
            }
            else
            {
                return returnIndex;
            }
        }