Beispiel #1
0
        public void Evaluate(object model, RenderingContext context, IDictionary <string, string> parameters)
        {
            var    gridStack        = GridStack.FromContext(context);
            double ratio            = GetValue(parameters, "ratio", 1);
            double margin           = GetValue(parameters, "margin", 0);
            double padding          = GetValue(parameters, "padding", 0);
            double?componentPadding = GetValueNullable(parameters, "component-padding");
            double width            = GetValue(parameters, "width", gridStack.Current.Width);

            gridStack.Push((int)(((width - margin) * ratio) - padding), componentPadding);
        }
        private int CalculateWidth(RenderingContext context, IDictionary <string, string> parameters)
        {
            double ratio = 1.0;
            string ratioValue;

            if (parameters.TryGetValue("ratio", out ratioValue) && !double.TryParse(ratioValue, out ratio))
            {
                ratio = 1.0;
            }

            var gridStack = GridStack.FromContext(context);

            return((int)(GetWidth(gridStack) * ratio));
        }
Beispiel #3
0
        public static GridStack FromContext(RenderingContext renderingContext)
        {
            object    stack;
            GridStack gridStack;

            if (!renderingContext.Data.TryGetValue(Gridstackkey, out stack))
            {
                gridStack = new GridStack();
                renderingContext.Data.Add(Gridstackkey, gridStack);
            }
            else
            {
                gridStack = stack as GridStack;
                if (gridStack == null)
                {
                    gridStack = new GridStack();
                    renderingContext.Data[Gridstackkey] = gridStack;
                }
            }
            return(gridStack);
        }
Beispiel #4
0
 public static GridContext GetFromRenderingContext(RenderingContext renderingContext)
 {
     return(GridStack.FromContext(renderingContext).Current);
 }
 internal override double GetWidth(GridStack gridStack)
 {
     return(gridStack.Current.Width - gridStack.Current.ComponentPadding * 2);
 }
 internal override double GetWidth(GridStack gridStack)
 {
     return(gridStack.Current.Width);
 }
 internal abstract double GetWidth(GridStack gridStack);
Beispiel #8
0
        public void Leave(object model, RenderingContext context, string name, IDictionary <string, string> parameters)
        {
            var gridStack = GridStack.FromContext(context);

            gridStack.Pop();
        }