protected override Tuple <double, double> CalculateSizesOnUserResize(int pageX, int pageY) { var availSpace = Container.GetAvailableHeightForFormElement(); var basePosY = Container.OffsetTop; var handlePos = Splitter.GetBoundingClientRect(); double upperHght = pageY - basePosY; var lowerHght = availSpace + basePosY - pageY - handlePos.Height; Logger.Debug(GetType(), "CalculateSizesOnEvent availSpace={0} splitterHeight={1} outcome=({2},{3})", availSpace, handlePos.Height, upperHght, lowerHght); return(Tuple.Create(upperHght, lowerHght)); }
protected override Tuple <double, double> CalculateSizesOnUserResize(int pageX, int pageY) { var basePosX = Container.OffsetLeft; var availSpace = Container.GetBoundingClientRect(); var handlePos = Splitter.GetBoundingClientRect(); double leftWdth = pageX - basePosX; var rightWdth = availSpace.Width + basePosX - pageX - handlePos.Width; Logger.Debug(GetType(), "CalculateSizesOnEvent availSpace={0} splitterWidth={1} outcome=({2},{3})", availSpace, handlePos.Height, leftWdth, rightWdth); return(Tuple.Create(leftWdth, rightWdth)); }
protected override Tuple <double, double> CalculateSizesOnAttachOrResize( VisibilityAction?change, Tuple <double, double> lastSizeOrNull = null) { var theoretAvailSpace = Window.InnerWidth; //TODO change to equivalent of Container.GetAvailableHeightForFormElement(); var factAvailSpace = theoretAvailSpace - Splitter.GetBoundingClientRect().Width; var leftWdth = FirstPanel.GetBoundingClientRect().Width; var rightWdth = SecondPanel.GetBoundingClientRect().Width; Logger.Debug(GetType(), "lastSize change={0} hidden?={1} lastSize={2} avail={3}", change, Hidden, lastSizeOrNull?.Item1 + lastSizeOrNull?.Item2, factAvailSpace); if (lastSizeOrNull != null && change == VisibilityAction.Showing && DoubleExtensions.AreApproximatellyTheSame( lastSizeOrNull.Item1 + lastSizeOrNull.Item2, factAvailSpace, 1.1)) { Logger.Debug(GetType(), "reusing lastSize"); leftWdth = lastSizeOrNull.Item1; rightWdth = lastSizeOrNull.Item2; } else if (Hidden) { Logger.Debug(GetType(), "hiding reusing all available space"); if (Hideable == Hideability.First) { leftWdth = 0; rightWdth = factAvailSpace; } else if (Hideable == Hideability.Second) { leftWdth = factAvailSpace; rightWdth = 0; } } else { //showing or resize or attach Logger.Debug(GetType(), "not reusing lastSize"); var res = ComputeSpace(leftWdth, rightWdth, factAvailSpace); leftWdth = res.Item1; rightWdth = res.Item2; } if (!Hidden) { leftWdth = Math.Max(leftWdth, MinPanelSizePx); rightWdth = Math.Max(rightWdth, MinPanelSizePx); //make sure that panels are visible on show var ratio = leftWdth / (leftWdth + rightWdth); leftWdth = factAvailSpace * ratio; rightWdth = factAvailSpace - leftWdth; } Logger.Debug(GetType(), "CalculateSizesInitial(id={0}) availSpace={1} splitterHeight={2} outcome=({3},{4})", Container.Id, theoretAvailSpace, Splitter.GetBoundingClientRect().Width, leftWdth, rightWdth); return(Tuple.Create(leftWdth, rightWdth)); }
protected override Tuple <double, double> CalculateSizesOnAttachOrResize( VisibilityAction?change, Tuple <double, double> lastSizeOrNull = null) { var theoretAvailSpace = Container.GetAvailableHeightForFormElement(); var factAvailSpace = theoretAvailSpace - Splitter.GetBoundingClientRect().Height; var upperHght = FirstPanel.GetBoundingClientRect().Height; var lowerHght = SecondPanel.GetBoundingClientRect().Height; Logger.Debug(GetType(), "lastSize change={0} hidden?={1} lastSize={2} avail={3}", change, Hidden, lastSizeOrNull?.Item1 + lastSizeOrNull?.Item2, factAvailSpace); if (lastSizeOrNull != null && change == VisibilityAction.Showing && DoubleExtensions.AreApproximatellyTheSame( lastSizeOrNull.Item1 + lastSizeOrNull.Item2, factAvailSpace, 1.1)) { Logger.Debug(GetType(), "reusing lastSize"); upperHght = lastSizeOrNull.Item1; lowerHght = lastSizeOrNull.Item2; } else if (Hidden) { Logger.Debug(GetType(), "hiding reusing all available space"); if (Hideable == Hideability.First) { upperHght = 0; lowerHght = factAvailSpace; } else if (Hideable == Hideability.Second) { upperHght = factAvailSpace; lowerHght = 0; } } else { //showing or resize or attach Logger.Debug(GetType(), "not reusing lastSize"); var res = ComputeSpace(upperHght, lowerHght, factAvailSpace); upperHght = res.Item1; lowerHght = res.Item2; } if (!Hidden) { upperHght = Math.Max(upperHght, MinPanelSizePx); lowerHght = Math.Max(lowerHght, MinPanelSizePx); //make sure that panels are visible on show var ratio = upperHght / (upperHght + lowerHght); upperHght = factAvailSpace * ratio; lowerHght = factAvailSpace - upperHght; } Logger.Debug(GetType(), "CalculateSizesInitial(id={0}) availSpace={1} splitterHeight={2} outcome=({3},{4})", Container.Id, theoretAvailSpace, Splitter.GetBoundingClientRect().Height, upperHght, lowerHght); return(Tuple.Create(upperHght, lowerHght)); }