FromContext() public static method

public static FromContext ( RenderingContext renderingContext ) : GridStack
renderingContext RenderingContext
return GridStack
        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))
            {
                if (!double.TryParse(ratioValue, out ratio))
                {
                    ratio = 1.0;
                }
            }

            var gridStack = GridStack.FromContext(context);

            return((int)(GetWidth(gridStack) * ratio));
        }
        public void Leave(object model, RenderingContext context, string name, IDictionary <string, string> parameters)
        {
            var gridStack = GridStack.FromContext(context);

            gridStack.Pop();
        }
Beispiel #4
0
 public static GridContext GetFromRenderingContext(RenderingContext renderingContext)
 {
     return(GridStack.FromContext(renderingContext).Current);
 }