public static BuiltPanels <T> BuiltHideable(T panel, IFormRenderer <HTMLElement> first, IFormRenderer <HTMLElement> second, ElementWrapperFormCanvas firstCanvas, ElementWrapperFormCanvas secondCanvas, Action hideAction, Action showAction) { return(new BuiltPanels <T>(panel, first, second, firstCanvas, secondCanvas, hideAction, showAction)); }
private static BuiltPanels <T> BuildNonhideable <T>(T panels, IFormRenderer <HTMLElement> renderer) where T : TwoPanelsWithResizer { var leftCanvas = new ElementWrapperFormCanvas( Toolkit.BaseFormCanvasTitleStrategy, panels.FirstPanel, Toolkit.DefaultExitButtonBuilder, Toolkit.DefaultLayoutMode); var leftRenderer = renderer.CreateRendererWithBase(leftCanvas); var rightCanvas = new ElementWrapperFormCanvas( Toolkit.BaseFormCanvasTitleStrategy, panels.SecondPanel, Toolkit.DefaultExitButtonBuilder, Toolkit.DefaultLayoutMode); var rightRenderer = renderer.CreateRendererWithBase(rightCanvas); return(BuiltPanels <T> .BuiltNonHideable(panels, leftRenderer, rightRenderer, leftCanvas, rightCanvas)); }
private BuiltPanels(T panel, IFormRenderer <HTMLElement> first, IFormRenderer <HTMLElement> second, ElementWrapperFormCanvas firstCanvas, ElementWrapperFormCanvas secondCanvas, Action hideAction, Action showAction) { Panel = panel; First = first; Second = second; FirstCanvas = firstCanvas; SecondCanvas = secondCanvas; HideAction = hideAction; ShowAction = showAction; }
public static BuiltPanels <T> BuiltNonHideable(T panel, IFormRenderer <HTMLElement> first, IFormRenderer <HTMLElement> second, ElementWrapperFormCanvas firstCanvas, ElementWrapperFormCanvas secondCanvas) { return(new BuiltPanels <T>(panel, first, second, firstCanvas, secondCanvas, null, null)); }
/// <param name="whichOne">true = first, false=second</param> private static BuiltPanels <T> BuildHideable <T>( T panels, bool whichOne, bool showable, IFormRenderer <HTMLElement> renderer) where T : TwoPanelsWithResizer { var fstIsHideable = whichOne; var toBeHidden = fstIsHideable ? panels.FirstPanel : panels.SecondPanel; var hideAct = new HTMLDivElement { TextContent = FontAwesomeSolid.IconTimes } .With(x => x.AddClasses( Magics.CssClassHideAction, Magics.CssClassEnabled, IconFontType.FontAwesomeSolid.ToCssClassName())); var showAct = showable ? new HTMLDivElement { TextContent = FontAwesomeSolid.IconBars } .With(x => x.AddClasses( Magics.CssClassShowAction, IconFontType.FontAwesomeSolid.ToCssClassName())) : null; panels.FirstPanel.AddClasses(Magics.CssClassPositionRelative); var leftCanvas = new ElementWrapperFormCanvas( Toolkit.BaseFormCanvasTitleStrategy, panels.FirstPanel, Toolkit.DefaultExitButtonBuilder, Toolkit.DefaultLayoutMode, fstIsHideable ? hideAct : showAct); var leftRenderer = renderer.CreateRendererWithBase(leftCanvas); panels.SecondPanel.AddClasses(Magics.CssClassPositionRelative); var rightCanvas = new ElementWrapperFormCanvas( Toolkit.BaseFormCanvasTitleStrategy, panels.SecondPanel, Toolkit.DefaultExitButtonBuilder, Toolkit.DefaultLayoutMode, fstIsHideable ? showAct : hideAct); var rightRenderer = renderer.CreateRendererWithBase(rightCanvas); var lastSize = new MutableHolder <Tuple <double, double> >(); var shown = new MutableHolder <bool>(true); void HideAction() { if (!shown.Value) { Logger.Debug(typeof(TwoPanelsWithResizerBuilder), "already hidden"); return; } hideAct.RemoveClasses(Magics.CssClassEnabled); if (showable) { showAct.AddClasses(Magics.CssClassEnabled); } lastSize.Value = panels.Sizes; toBeHidden.AddClasses(Magics.CssClassNotRendered); panels.Splitter.AddClasses(Magics.CssClassNotRendered); shown.Value = false; panels.ForceSizeCalculation(VisibilityAction.Hiding); } void ShowAction() { if (shown.Value) { Logger.Debug(typeof(TwoPanelsWithResizerBuilder), "already shown"); return; } if (showable) { showAct.RemoveClasses(Magics.CssClassEnabled); } hideAct.AddClasses(Magics.CssClassEnabled); toBeHidden.RemoveClasses(Magics.CssClassNotRendered); panels.Splitter.RemoveClasses(Magics.CssClassNotRendered); shown.Value = true; panels.ForceSizeCalculation(VisibilityAction.Showing, lastSize.Value); } hideAct.OnClick += ev => HideAction(); if (showable) { showAct.OnClick += ev => ShowAction(); } return(BuiltPanels <T> .BuiltHideable(panels, leftRenderer, rightRenderer, leftCanvas, rightCanvas, HideAction, ShowAction)); }