ChartWindow: Enhance ComboCheckBox
This commit is contained in:
@ -8,40 +8,31 @@ namespace Elwig.Helpers.Billing {
|
||||
|
||||
public WineVar? Variety { get; }
|
||||
public WineAttr? Attribute { get; }
|
||||
public string Listing => Variety != null || Attribute != null ? $"{Variety?.SortId}{Attribute?.AttrId}" : "";
|
||||
public string Listing => $"{Variety?.SortId}{Attribute?.AttrId}";
|
||||
|
||||
public ContractSelection(WineVar? var, WineAttr? attr) {
|
||||
Variety = var;
|
||||
Attribute = attr;
|
||||
}
|
||||
|
||||
public ContractSelection(WineVar var) {
|
||||
Variety = var;
|
||||
}
|
||||
|
||||
public ContractSelection(WineAttr attr) {
|
||||
Attribute = attr;
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return (Variety != null ? $"{Variety.Name}" : "") + (Attribute != null ? $" {Attribute.Name}" : "");
|
||||
}
|
||||
|
||||
public static List<ContractSelection> GetContractsForYear(AppDbContext context, int year) {
|
||||
return context.DeliveryParts
|
||||
.Where(d => d.Year == year)
|
||||
.Where(p => p.Year == year)
|
||||
.Select(d => new ContractSelection(d.Variant, d.Attribute))
|
||||
.Distinct()
|
||||
.ToList()
|
||||
.Union(context.WineVarieties.Select(v => new ContractSelection(v)))
|
||||
.Union(context.WineVarieties.Select(v => new ContractSelection(v, null)))
|
||||
.DistinctBy(c => c.Listing)
|
||||
.Order()
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return Listing;
|
||||
}
|
||||
|
||||
public int CompareTo(ContractSelection? other) {
|
||||
//MessageBox.Show($"{Listing} -- {other.Listing} : {Listing.CompareTo(other.Listing)}");
|
||||
return other != null ?
|
||||
Listing.CompareTo(other.Listing) :
|
||||
throw new ArgumentException();
|
||||
return Listing.CompareTo(other?.Listing);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -63,16 +63,17 @@
|
||||
<TextBlock x:Name="GraphNum" Margin="55,0,0,0" FontSize="14" Width="50" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left"/>
|
||||
|
||||
<Label Content="Für:" Margin="10,0,0,0" FontSize="14" Grid.Column="1" VerticalAlignment="Center"/>
|
||||
<xctk:CheckComboBox x:Name="ContractInput" Margin="0,10,-42,5" Grid.Column="1" DisplayMemberPath="{Binding Listing}"
|
||||
Delimiter=", " AllItemsSelectedContent="Alle" IsEnabled="False" ItemSelectionChanged="ContractInput_Changed"
|
||||
Width="500" Height="25" HorizontalAlignment="Right">
|
||||
<!--<xctk:CheckComboBox.ItemTemplate>
|
||||
<xctk:CheckComboBox x:Name="ContractInput" Margin="0,10,-42,5" Grid.Column="1"
|
||||
Delimiter=", " AllItemsSelectedContent="Alle" IsEnabled="False" ItemSelectionChanged="ContractInput_Changed"
|
||||
Width="500" Height="25" HorizontalAlignment="Right">
|
||||
<xctk:CheckComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{}" Width="40"/>
|
||||
<TextBlock Text="{Binding Variety.Name}" Width="150"/>
|
||||
<TextBlock Text="{Binding Attribute.Name}"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</xctk:CheckComboBox.ItemTemplate>-->
|
||||
</xctk:CheckComboBox.ItemTemplate>
|
||||
</xctk:CheckComboBox>
|
||||
</Grid>
|
||||
|
||||
|
@ -73,7 +73,7 @@ namespace Elwig.Windows {
|
||||
var data = EditBillingData.FromJson(PaymentVar.Data, attrVariants);
|
||||
GraphEntries = [ ..data.GetPaymentGraphEntries(Context), ..data.GetQualityGraphEntries(Context)];
|
||||
|
||||
var contracts = ContractSelection.GetContractsForYear(Context, Year).DistinctBy(c => c.Listing).Order().ToList();
|
||||
var contracts = ContractSelection.GetContractsForYear(Context, Year);
|
||||
ControlUtils.RenewItemsSource(ContractInput, contracts, g => (g as ContractSelection)?.ToString());
|
||||
ControlUtils.RenewItemsSource(GraphList, GraphEntries, g => (g as GraphEntry)?.Id, null, ControlUtils.RenewSourceDefault.First);
|
||||
|
||||
|
Reference in New Issue
Block a user