Exemplo n.º 1
0
        private static void ApplySceneItemToControl(SceneItem item, Control ctrl)
        {
            Type type = ctrl.GetType();

            SceneRenderBase render;

            //检测是否是特殊控件,并已经注册
            if (Scene.regRenderList.TryGetValue(type, out render) == false)
            {
                render = new SceneRenderBase(ctrl.GetType());
            }

            render.RenderEnabled(ctrl, item.Enabled);
            render.RenderReadOnly(ctrl, item.ReadOnly);
            render.RenderVisible(ctrl, item.Visible);
            render.RenderHtmlAttributes(ctrl, item.Attributes);
            render.RenderHtmlStyles(ctrl, item.Styles);
            render.RenderSubItems(ctrl, item.SubItems);

            if (item.Recursive)
            {
                foreach (Control child in ctrl.Controls)
                {
                    ApplySceneItemToControl(item, child);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 注册特殊控件重绘方案
        /// </summary>
        /// <param name="type">特殊控件类型</param>
        /// <param name="render">重写SceneRenderBase后的重绘方案</param>
        public static void RegisterRender(System.Type type, SceneRenderBase render)
        {
            ExceptionHelper.FalseThrow <ArgumentNullException>(type != null, "type");
            ExceptionHelper.FalseThrow <ArgumentNullException>(render != null, "render");

            lock (Scene.regRenderList)
            {
                if (Scene.regRenderList.ContainsKey(type) == false)
                {
                    Scene.regRenderList.Add(type, render);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 得到已经注册的重绘方案。如果没有注册,则创建一个新的。
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static SceneRenderBase GetRegisteredRender(System.Type type)
        {
            ExceptionHelper.FalseThrow <ArgumentNullException>(type != null, "type");

            SceneRenderBase render;

            //检测是否是特殊控件,并已经注册
            if (Scene.regRenderList.TryGetValue(type, out render) == false)
            {
                render = new SceneRenderBase(type);

                RegisterRender(type, render);
            }

            return(render);
        }
Exemplo n.º 4
0
        private static void ApplySceneItemToControl(SceneItem item, Control ctrl)
        {
            SceneRenderBase render = GetRegisteredRender(ctrl.GetType());

            render.RenderEnabled(ctrl, item.Enabled);
            render.RenderReadOnly(ctrl, item.ReadOnly);
            render.RenderVisible(ctrl, item.Visible);
            render.RenderHtmlAttributes(ctrl, item.Attributes);
            render.RenderHtmlStyles(ctrl, item.Styles);
            render.RenderSubItems(ctrl, item.SubItems);

            if (item.Recursive)
            {
                foreach (Control child in ctrl.Controls)
                {
                    ApplySceneItemToControl(item, child);
                }
            }
        }