Esempio n. 1
0
        void OnEnable()
        {
            var styleSheet = AssetDatabase.LoadAssetAtPath <StyleSheet>(_styleSheetPath);
            var uxml       = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(_uxmlPath);

            uxml.CloneTree(rootVisualElement);
            rootVisualElement.styleSheets.Add(styleSheet);

            _back = rootVisualElement.Query <Button>("back");
            _back.clickable.clicked += HistoryList.MoveBack;
            _back.SetEnabled(HistoryList.CanMoveBack());

            _forward = rootVisualElement.Query <Button>("forward");
            _forward.clickable.clicked += HistoryList.MoveForward;
            _forward.SetEnabled(HistoryList.CanMoveForward());

            _listView = rootVisualElement.Query <ListView>().First();
            _listView.selectionType       = SelectionType.Single;
            _listView.itemsSource         = HistoryList.History;
            _listView.makeItem            = MakeItem;
            _listView.bindItem            = BindItem;
            _listView.onItemChosen       += item => Select();
            _listView.onSelectionChanged += selection => Highlight();

            Selection.selectionChanged += Refresh;
        }
Esempio n. 2
0
 private void Refresh()
 {
     _back.SetEnabled(HistoryList.CanMoveBack());
     _forward.SetEnabled(HistoryList.CanMoveForward());
     _listView.Refresh();
 }