Commit b5ba9b47 authored by Ian Slater's avatar Ian Slater
Browse files

added to order bindings

parent bfc145cd
......@@ -18,16 +18,17 @@ namespace CowboyCafe.Data
private List<IOrderItem> items = new List<IOrderItem>();
public IEnumerable<IOrderItem> Items {get => items;}
public IEnumerable<IOrderItem> Items {get => items.ToArray();}
public void Add(IOrderItem i)
{
items.Add(i);
this.Subtotal += i.Price;
PropertyChanged.Invoke(this, new PropertyChangedEventArgs("Subtotal"));
PropertyChanged.Invoke(this, new PropertyChangedEventArgs("Items"));
}
public void Remove(IOrderItem i)
{
......
......@@ -30,7 +30,6 @@ namespace PointOfSale
{
InitializeComponent();
Order currentOrder = new Order();
currentOrder.PropertyChanged += ordersummarycontrol.OnItemChanged;
DataContext = currentOrder;
}
......
......@@ -43,79 +43,67 @@ namespace PointOfSale
private void CowpokeChiliButton_Click(object sender, RoutedEventArgs e)
{
CowpokeChili cp = new CowpokeChili();
ticket.Items.Add(cp.ToString());
}
private void DakotaDoubleButton_Click(object sender, RoutedEventArgs e)
{
DakotaDoubleBurger ddb = new DakotaDoubleBurger();
ticket.Items.Add(ddb.ToString());
}
private void PecosPulledPorkButton_Click(object sender, RoutedEventArgs e)
{
PecosPulledPork ppp = new PecosPulledPork();
ticket.Items.Add(ppp.ToString());
}
private void RustlersRibsButton_Click(object sender, RoutedEventArgs e)
{
RustlersRibs rr = new RustlersRibs();
ticket.Items.Add(rr.ToString());
}
private void TexasTripleButton_Click(object sender, RoutedEventArgs e)
{
TexasTripleBurger ttb = new TexasTripleBurger();
ticket.Items.Add(ttb.ToString());
}
private void TrailBurgerButton_Click(object sender, RoutedEventArgs e)
{
TrailBurger tb = new TrailBurger();
ticket.Items.Add(tb.ToString());
}
private void ChiliCheeseFriesButton_Click(object sender, RoutedEventArgs e)
{
ChiliCheeseFries ccf = new ChiliCheeseFries();
ticket.Items.Add(ccf.ToString());
}
private void CornDodgerButton_Click(object sender, RoutedEventArgs e)
{
CornDodgers cd = new CornDodgers();
ticket.Items.Add(cd.ToString());
}
private void PandeCampoButton_Click(object sender, RoutedEventArgs e)
{
PanDeCampo pdc = new PanDeCampo();
ticket.Items.Add(pdc.ToString());
}
private void JerkedSodeButton_Click(object sender, RoutedEventArgs e)
{
JerkedSoda js = new JerkedSoda();
ticket.Items.Add(js.ToString());
}
private void CowboyCoffeButton_Click(object sender, RoutedEventArgs e)
{
CowboyCoffee cc = new CowboyCoffee();
ticket.Items.Add(cc.ToString());
}
private void TexasTeaButton_Click(object sender, RoutedEventArgs e)
{
TexasTea tt = new TexasTea();
ticket.Items.Add(tt.ToString());
}
private void WaterButton_Click(object sender, RoutedEventArgs e)
{
Water w = new Water();
ticket.Items.Add(w.ToString());
}
}
}
......@@ -9,7 +9,20 @@
<Grid>
<Border BorderThickness="1" BorderBrush="Black" Margin="10,38,10,60">
<ListBox Name="ticket"/>
<ListBox HorizontalContentAlignment="Stretch" ItemsSource="{Binding Path=Items}" SelectionChanged="ListBox_SelectionChanged" Margin="19,26,23,25">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding}"></TextBlock>
<TextBlock HorizontalAlignment="Right" Text="{Binding Path=Price}"
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Border>
<TextBlock Name="SubtotalTextBox" HorizontalAlignment="Right" Margin="0,515,10,0" FontSize="20" Text="{Binding Path=Subtotal, StringFormat=c}" TextWrapping="Wrap" VerticalAlignment="Top" Height="45" Width="84"/>
......
......@@ -27,16 +27,12 @@ namespace PointOfSale
}
public void OnItemChanged(object sender, PropertyChangedEventArgs e)
private void ScrollBar_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (sender is Order order)
{
ticket.Items.Add("Angry Chicken");
}
}
private void ScrollBar_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment