Exemplo n.º 1
0
 public ControlsTree()
 {
     _controls        = new LinkedList <TvControlMetadata>();
     _focused         = null;
     _componentTree   = null;
     _indexedControls = new Dictionary <Guid, TvControlMetadata>();
 }
Exemplo n.º 2
0
        public void InsertAfter(TvControlMetadata cdata, int position)
        {
            if (position < 0)
            {
                throw new ArgumentException("position must be >=0", nameof(position));
            }

            var current = _controls.NodeAt(position);

            _controls.AddAfter(current, cdata);
            _indexedControls.Add(cdata.ControlId, cdata);
        }
Exemplo n.º 3
0
        public TvControl(ISkin skin, IViewport viewport, TState initialState, string name = null)
        {
            _component = new TvComponent <TState>(initialState, name ?? $"TvControl_<$>");
            Metadata   = new TvControlMetadata(this, _component.ComponentId);
            var typename   = GetType().Name.ToLowerInvariant();
            var genericIdx = typename.IndexOf('`');

            ControlType  = genericIdx != -1 ? typename.Substring(0, genericIdx) : typename;
            CurrentStyle = skin.GetControlStyle(this);
            State        = initialState;
            _component.AddViewport(viewport);
            AddElements();
        }
Exemplo n.º 4
0
        public bool Focus(TvControlMetadata controlToFocus)
        {
            if (_focused != controlToFocus)
            {
                if (_focused != null)
                {
                    _focused.Unfocus();
                }
                controlToFocus.Focus();
                _focused = controlToFocus;
                return(true);
            }

            return(false);
        }
Exemplo n.º 5
0
 public TvControlMetadata PreviousControl(TvControlMetadata current)
 {
     return(_controls.Find(current)?.Previous?.Value);
 }
Exemplo n.º 6
0
        public TvControlMetadata NextControl(TvControlMetadata current)
        {
            var next = _controls.Find(current)?.Next;

            return(next != null ? next.Value : _controls.First.Value);
        }
Exemplo n.º 7
0
 public void Remove(TvControlMetadata cdata)
 {
     _controls.Remove(cdata);
     _indexedControls.Remove(cdata.ControlId);
 }
Exemplo n.º 8
0
 public void Add(TvControlMetadata cdata)
 {
     _controls.AddLast(cdata);
     _indexedControls.Add(cdata.ControlId, cdata);
 }