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