Ejemplo n.º 1
0
        public WindowContext(IRootElement nodeBase) : base($"Window_{nodeBase.NodeBase.Id}_")
        {
            WindowingService = nodeBase.ServiceData.OperationManager.GetOperation <WindowingService>();
            StyleOperator    = nodeBase.ServiceData.OperationManager.GetOperation <StyleOperator>();

            Add("node", ElementNode = new LinkMember(this));

            InitTitlebar(nodeBase);
            InitTabSection(nodeBase);
            InitContentPane(nodeBase);

            cssClass = "window-context";

            WithAttribute("style", out StyleContext styleContext);
            styleContext.WithStyle(StyleOperator, this,
                                   ("position", "absolute"),
                                   ("left", $"{Transform.Position.X}px"),
                                   ("top", $"{Transform.Position.Y}px"),
                                   ("width", $"{Transform.Size.Width}px"),
                                   ("height", $"{Transform.Size.Height}px"),
                                   ("border", "2px solid black"));

            Transform.OnMove = (transform, position) =>
            {
                styleContext.WithStyle(StyleOperator, this,
                                       ("left", $"{Transform.Position.X}px"),
                                       ("top", $"{Transform.Position.Y}px"));
            };

            Transform.OnResize = (transform, size) =>
            {
                styleContext.WithStyle(StyleOperator, this,
                                       ("width", $"{Transform.Size.Width}px"),
                                       ("height", $"{Transform.Size.Height}px"));
            };

            PreventDefaults.Add("onfocus");
            PreventDefaults.Add("ondragover");
            PreventDefaults.Add("ondrop");
            StopPropagations.Add("ondragover");
            StopPropagations.Add("ondrop");

            AddEvent("onmousedown", OnMouseDown);
            AddEvent("onmouseup", WindowingService.WindowResizeUp);
            AddEvent("onmousemove", OnMouseMove);
            AddEvent("onmouseleave", OnMouseLeave);
            AddEvent("ondrop", OnTabWindowDropped);
            AddEvent("ondragover", a => {});
        }
Ejemplo n.º 2
0
        public ContainerContext(IRootElement nodeBase) : base($"Container_{nodeBase.NodeBase.Id}_")
        {
            cssClass = "window-container";

            NodeBase = nodeBase;
            Add("node", ElementNode = new LinkMember(this));

            WithAttribute("draggable", out AttributeString drag);
            drag.Value = "false";

            WindowingService = nodeBase.ServiceData.OperationManager.GetOperation <WindowingService>();
            WindowingService.ContainerContext = this;
            StyleOperator = nodeBase.ServiceData.OperationManager.GetOperation <StyleOperator>();

            WithAttribute("style", out StyleContext styleContext);
            styleContext.WithStyle(StyleOperator, this,
                                   ("background-color", "red"),
                                   ("position", "relative"),
                                   ("touch-action", "none"));

            Slider = new ElementContext("Slider");
            Slider.WithAttribute("style", out StyleContext sliderStyle);
            sliderStyle.WithStyle(StyleOperator, Slider,
                                  ("top", "0px"),
                                  ("left", "0px"),
                                  ("position", "absolute"));

            SlideMember = new LinkMember(Slider);
            ElementNode.Add(SlideMember);

            SliderTransform        = new Transform();
            SliderTransform.OnMove = (transform1, position) =>
            {
                sliderStyle.WithStyle(StyleOperator, Slider,
                                      ("margin-top", $"{position.Y}px"));
            };

            string[] events =
            {
            };

            StopPropagations.AddRange(events);
            StopPropagations.Add("onwheel");

            PreventDefaults.Add("ondragover");
            PreventDefaults.Add("ondrop");

            AddEvent("onmousedown", WindowingService.ContainerMouseDown);
            AddEvent("onmousemove", WindowingService.ContainerMouseMove);
            AddEvent("onmouseup", WindowingService.ContainerMouseUp);
            AddEvent("onmouseleave", WindowingService.ContainerMouseLeave);
            AddEvent("ondragend", WindowingService.ContainerMouseUp);
            AddEvent("onwheel", WindowingService.ContainerWheel);
            AddEvent("ondrop", WindowingService.OnContainerTabDropped);
            AddEvent("ondragover", a => {  });

            var hold = WindowingService.CreateWindow;

            for (int i = 0; i < 4; i++)
            {
                var tab = WindowingService.CreateTab();
                tab.TabContext = new TabContext(nodeBase, tab)
                {
                };
                tab.TabContext.SetHtml($"TAB {i}");
                WindowingService.AddTabToWindow(hold, tab);
            }
        }