示例#1
0
        public TvDialog CreateDialog(IViewport viewport, Action <TvDialog> dialogSetup, string name = null)
        {
            var dialogViewport = viewport.Layer(ViewportLayer.Top, -1);
            var dialogName     = name ?? $"TvDialog_{Guid.NewGuid()}";
            var dialog         = new TvDialog(_skinManager.CurrentSkin, dialogViewport, _ui, dialogName);

            dialogSetup.Invoke(dialog);
            foreach (var cmp in dialog.State.UI.Components)
            {
                cmp.UpdateViewport(cmp.Viewport.Layer(ViewportLayer.Top));
            }
            return(dialog);
        }
示例#2
0
        public void ShowDialog(TvDialog dialog)
        {
            var controlsTree   = dialog.State.UI.RootControls();
            var insideControls = dialog.State.UI.OwnedControls().Union(dialog.State.Buttons.Select(b => b.Metadata));

            foreach (var controlMetadata in controlsTree.ControlsMetadata)
            {
                if (!insideControls.Contains(controlMetadata))
                {
                    controlMetadata.DisableFocusability();
                    _outsideDialogControls.Add(controlMetadata);
                }
            }
            _ui.Add(dialog);
            DialogShown = dialog;
        }
示例#3
0
        internal void Init(TvDialog dialog, IComponentTree owner)
        {
            _myDialog = dialog;
            _buttons.AddOkButton();
            _buttons.AddCancelButton();
            var viewport = _myDialog.AsComponent().Viewport.Layer(ViewportLayer.Top);

            _mainPanel = new TvStackPanel(owner, $"{_prefixNames}_MainPanel");
            _mainPanel.Layout.Add("1", "*");
            _mainPanel.AsComponent().AddViewport(new Viewport(viewport.Position + new TvPoint(1, 1), viewport.Columns - 2, viewport.Rows - 2, viewport.ZIndex));
            _bottomGrid = new TvGrid(owner, new GridState(1, 2), $"{_prefixNames}_BottomGrid");
            _bottomGrid.Use(0, 0).Add(_buttons.OkButton);
            _bottomGrid.Use(0, 1).Add(_buttons.CancelButton);
            _mainCanvas = new TvCanvas(owner, $"{_prefixNames}_BodyCanvas");
            _mainCanvas.AsComponent().AddViewport(Viewport.NullViewport);

            _mainPanel.At(0).Add(_mainCanvas);
            _mainPanel.At(1).Add(_bottomGrid);

            IsDirty = true;
        }