using System; using System.Collections.Generic; using System.Linq; using System.Windows; using Comal.Classes; using InABox.Core; using InABox.DynamicGrid; using InABox.Integration.V6; using PRSDesktop.Integrations.V6; using PRSDesktop.Integrations.Common; using PRSDesktop.Integrations.Logikal; namespace PRSDesktop.Integrations.V6; public partial class V6ElevationSelection : Window { private V6Client _client; private V6Project? _project; private Func _callback; private Func? _filter; public V6ElevationSelection(V6Client client, V6Project? project, Func? filter, bool multiselect, Func callback) { _client = client; _callback = callback; _project = project; _filter = filter; InitializeComponent(); Projects.Refresh(true,false); Elevations.Options.MultiSelect = multiselect; Elevations.Refresh(true, false); } private void V6ElevationSelection_OnLoaded(object sender, RoutedEventArgs e) { if (_client.IsConnected) { if (_project != null) { ProjectsColumn.Width = new GridLength(0); SplitterColumn.Width = new GridLength(0); Elevations.Items = _client.GetElevations(_project).Where(x=> _filter == null || _filter(x)).ToList(); Elevations.Refresh(false,true); } else { ProjectsColumn.Width = new GridLength(500); SplitterColumn.Width = new GridLength(1, GridUnitType.Auto); Projects.Items = _client.GetProjects().ToList(); Projects.Refresh(false,true); } } } private void OK_Click(object sender, RoutedEventArgs e) { if (_project == null) return; var selected = Elevations.SelectedRows.Select(x => x.Index).ToArray(); var result = _callback.Invoke(_project,selected.Select(x=>Elevations.Items[x]).ToArray()); DialogResult = result; } private void Cancel_Click(object sender, RoutedEventArgs e) { DialogResult = false; } private void Elevations_OnOnSelectItem(object sender, DynamicGridSelectionEventArgs e) { OK.IsEnabled = Elevations.SelectedRows.Any(); } private void Projects_OnOnSelectItem(object sender, DynamicGridSelectionEventArgs e) { var row = e.Rows?.FirstOrDefault(); if (row == null) return; _project = Projects.Items[row.Index]; Elevations.Items = _client.GetElevations(_project); Elevations.Refresh(false,true); } }