Ejemplo n.º 1
0
        private void SetupEvents()
        {
            SearchBox.KeyDown += HandleSearchKeyDown;

            SearchBox.GotFocus    += SelectTextOnFocus;
            Entities.DoubleTapped += (s, e) => LoadSelectedEntity();
            Entities.AddHandler(KeyDownEvent, (s, e) =>
            {
                if (e.Key == Key.Enter)
                {
                    LoadSelectedEntity();
                    e.Handled = true;
                }
            }, RoutingStrategies.Tunnel);
            Entities.Sorting += (sender, e) =>
            {
                if (e.Column is DataGridTextColumn column)
                {
                    var path = ((Avalonia.Data.Binding)column.Binding).Path;
                    SetSortProperty(path);
                    UpdateEntityList();
                    BringSelectedItemIntoView();
                    e.Handled = true;
                }
            };
            Entities.SelectionChanged += (s, e) => { BringSelectedItemIntoView(); };
            SearchBox.PropertyChanged += (s, e) =>
            {
                if (SearchBox.Text == null)
                {
                    return;
                }
                if (SearchBox.Text != _searchText)
                {
                    _searchText = SearchBox.Text;
                    QueueHandler.Trigger(_searchText);
                }
            };
            SaveButton.Click   += (s, e) => SaveOrUpdate();
            CancelButton.Click += (s, e) => ClearInputFields();
            DeleteButton.Click += async(s, e) => await Delete();

            PrintButton.Click += (s, e) => PrintEntities(_filteredEntities);
            SetupAdditionalEvents();
        }
Ejemplo n.º 2
0
        private void FindTagsGridChanged(object sender, AvaloniaPropertyChangedEventArgs e)
        {
            if (e.Property != ToggleButton.IsCheckedProperty)
            {
                return;
            }
            if (!(sender is CheckBox cb))
            {
                return;
            }
            var tag = (Tag)cb.Tag;

            if (_findTagsGridValues.ContainsKey(tag))
            {
                _findTagsGridValues[tag] = cb.IsChecked;
            }
            else
            {
                _findTagsGridValues.Add(tag, cb.IsChecked);
            }
            QueueHandler.Trigger(string.Empty);
        }