public HorizontalSplitBase(Arguments args) { this.Split = args.Split; this.SplitArea = args.SplitArea; var hs = args.Split; var hsArea = args.SplitArea; var hsa = args.SplitImage; this.SplitImageContainer = new IHTMLDiv(); SplitImageContainer.AttachTo(hs.Splitter); SplitImageContainer.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute; SplitImageContainer.style.left = "1px"; SplitImageContainer.style.top = "50%"; SplitImageContainer.style.marginTop = (-args.SplitImageHeight / 2) + "px"; hsa.AttachTo(SplitImageContainer); hsArea.Abort.style.Opacity = 0.05; var dragmode = false; Action ReleaseCapture = delegate { }; hsArea.Target.onmousedown += ee => { ReleaseCapture = hsArea.Target.CaptureMouse(); hsArea.Target.style.backgroundColor = SelectionColor; dragmode = true; ee.PreventDefault(); hsArea.Abort.style.Opacity = SelectionBackgroundOpacity; }; hsArea.PageContainer.onmousemove += ee => { var OffsetX = ee.GetOffsetX(hsArea.PageContainer); if (!dragmode) { return; } var p = System.Convert.ToInt32(OffsetX * 100 / hsArea.PageContainer.offsetWidth); if (p < Convert.ToInt32(Minimum * 100)) { p = Convert.ToInt32(Minimum * 100); } if (p > Convert.ToInt32(Maximum * 100)) { p = Convert.ToInt32(Maximum * 100); } hsArea.Target.style.left = p + "%"; }; InternalSetValue = p => { if (p < Convert.ToInt32(Minimum * 100)) { p = Convert.ToInt32(Minimum * 100); } if (p > Convert.ToInt32(Maximum * 100)) { p = Convert.ToInt32(Maximum * 100); } hsArea.Target.style.left = p + "%"; hs.Right.style.left = p + "%"; hs.Right.style.width = (100 - p) + "%"; hs.Left.style.width = p + "%"; }; hsArea.PageContainer.onmouseup += ee => { if (!dragmode) { return; } ReleaseCapture(); var OffsetX = ee.GetOffsetX(hsArea.PageContainer); dragmode = false; var p = System.Convert.ToInt32(OffsetX * 100 / hsArea.PageContainer.offsetWidth); Value = p * 0.01; hsArea.Abort.style.Opacity = 0; hsArea.Target.style.backgroundColor = ScriptCoreLib.JavaScript.Runtime.JSColor.None; }; hsArea.Abort.onmousemove += ee => { if (dragmode) { return; } hsArea.Target.style.backgroundColor = ScriptCoreLib.JavaScript.Runtime.JSColor.None; hsArea.PageContainer.Orphanize(); }; hs.Splitter.onmouseover += delegate { hsArea.Abort.style.Opacity = 0.05; hsArea.PageContainer.AttachTo(hs.ContentContainer); }; }
public HorizontalSplitBase(Arguments args) { this.Split = args.Split; this.SplitArea = args.SplitArea; var hs = args.Split; var hsArea = args.SplitArea; var hsa = args.SplitImage; this.SplitImageContainer = new IHTMLDiv(); SplitImageContainer.AttachTo(hs.Splitter); SplitImageContainer.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute; SplitImageContainer.style.left = "1px"; SplitImageContainer.style.top = "50%"; SplitImageContainer.style.marginTop = (-args.SplitImageHeight / 2) + "px"; hsa.AttachTo(SplitImageContainer); hsArea.Abort.style.Opacity = 0.05; var dragmode = false; Action ReleaseCapture = delegate { }; hsArea.Target.onmousedown += ee => { ReleaseCapture = hsArea.Target.CaptureMouse(); hsArea.Target.style.backgroundColor = SelectionColor; dragmode = true; // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2015/201511/20151103 ee.preventDefault(); hsArea.Abort.style.Opacity = SelectionBackgroundOpacity; }; hsArea.PageContainer.onmousemove += ee => { var OffsetX = ee.GetOffsetX(hsArea.PageContainer); if (!dragmode) return; var p = System.Convert.ToInt32(OffsetX * 100 / hsArea.PageContainer.offsetWidth); if (p < Convert.ToInt32(Minimum * 100)) p = Convert.ToInt32(Minimum * 100); if (p > Convert.ToInt32(Maximum * 100)) p = Convert.ToInt32(Maximum * 100); hsArea.Target.style.left = p + "%"; }; InternalSetValue = p => { if (p < Convert.ToInt32(Minimum * 100)) p = Convert.ToInt32(Minimum * 100); if (p > Convert.ToInt32(Maximum * 100)) p = Convert.ToInt32(Maximum * 100); hsArea.Target.style.left = p + "%"; hs.Right.style.left = p + "%"; hs.Right.style.width = (100 - p) + "%"; hs.Left.style.width = p + "%"; }; hsArea.PageContainer.onmouseup += ee => { if (!dragmode) return; ReleaseCapture(); var OffsetX = ee.GetOffsetX(hsArea.PageContainer); dragmode = false; var p = System.Convert.ToInt32(OffsetX * 100 / hsArea.PageContainer.offsetWidth); Value = p * 0.01; hsArea.Abort.style.Opacity = 0; hsArea.Target.style.backgroundColor = ScriptCoreLib.JavaScript.Runtime.JSColor.None; }; hsArea.Abort.onmousemove += ee => { if (dragmode) { return; } hsArea.Target.style.backgroundColor = ScriptCoreLib.JavaScript.Runtime.JSColor.None; hsArea.PageContainer.Orphanize(); }; hs.Splitter.onmouseover += delegate { hsArea.Abort.style.Opacity = 0.05; hsArea.PageContainer.AttachTo(hs.ContentContainer); }; }