private void LinkFn(FloatingWindowScope scope, jQueryObject element, dynamic attr) { myElement = element; myScope = scope; items.Add(element, scope); element.Click((elem, @event) => Focus()); scope.Parent.SwingAway = (a, b, c) => { SwingAway(a, b, element, c); }; scope.Parent.SwingBack = (c) => { SwingBack(scope, element, c); }; scope.Parent.Minimize = () => { scope.Parent.Minimized = true; scope.Minimize(); }; scope.Parent.DestroyWindow = () => { scope.Destroy(); element.Remove(); }; scope.PositionStyles = new FloatingWindowPosition() { Left = scope.Left, Top = scope.Top, Display = "block" }; scope.PositionStyles.ZIndex = 10000; if (scope.Left.IndexOf("%") != -1) { scope.PositionStyles.MarginLeft = (-(int.Parse(scope.Width.Replace("px", "")) / 2)) + "px"; } if (scope.Top.IndexOf("%") != -1) { scope.PositionStyles.MarginTop = (-(int.Parse(scope.Height.Replace("px", "")) / 2)) + "px"; } scope.SizeStyle = new Size() { Width = scope.Width, Height = scope.Height, }; scope.Maximize = () => { if (!scope.IsMaximized) { scope.LastPositionStyles = scope.PositionStyles; scope.LastSizeStyle = scope.SizeStyle; scope.PositionStyles = new FloatingWindowPosition() { Left = "0", Top = "0", Display = "block" }; scope.SizeStyle = new Size() { Width = "100%", Height = "100%", }; } else { scope.PositionStyles = scope.LastPositionStyles; scope.SizeStyle = scope.LastSizeStyle; scope.LastPositionStyles = null; scope.LastSizeStyle = null; } scope.IsMaximized = !scope.IsMaximized; }; scope.Close = () => { if (scope.OnClose != null) { scope.OnClose(); } if (scope.Parent.OnClose != null) { scope.Parent.OnClose(); } //todo destroy scope.PositionStyles.Display = "none"; }; scope.Minimize = () => { // myUIManagerService.OnMinimize(scope); scope.Parent.SwingAway(SwingDirection.Bottom, false, () => { scope.PositionStyles.Display = "none"; }); }; scope.Restore = () => { scope.Parent.SwingBack(null); scope.PositionStyles.Display = "block"; }; Focus(); if (scope.Parent.OnReady != null) scope.Parent.OnReady(); }
public void SwingBack(FloatingWindowScope scope, jQueryObject element, Action callback) { Window.SetTimeout(() => { var js = new JsDictionary<string, object>(); js["left"] = scope.Left; js["top"] = scope.Top; element.CSS("display", "block"); element.Animate(js, EffectDuration.Fast, EffectEasing.Swing, callback); }, 1); }