lordcoco's Profile
Reputation: 0
Apprentice
- Group:
- New Members
- Active Posts:
- 11 (0.06 per day)
- Joined:
- 23-November 12
- Profile Views:
- 1,346
- Last Active:
Dec 20 2012 01:48 PM- Currently:
- Offline
Previous Fields
- Dream Kudos:
- 0
Posts I've Made
-
In Topic: WPF Cinema Booking
Posted 18 Dec 2012
So.. I`ve listened to you.. and I used to StackPanels to represent the seats...
using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace WpfControlLibrary1 { public partial class SeatingArea : UserControl { private ObservableCollection<Seat> seats; private int i = 0; private ObservableCollection<int> rows; private ObservableCollection<int> columns; public ObservableCollection<Seat> Seats { get { return seats; } set { seats = value; } } public ObservableCollection<int> Rows { get { return rows; } set { rows = value; } } public SeatingArea() { Seats = new ObservableCollection<Seat>(); for (int i = 1; i <= 15; i++) for (int j =1; j<=5;j++) { Seat seat = new Seat(j,i); seat.IsOccupied = false; Seats.Add(seat); } rows = new ObservableCollection<int>(); columns = new ObservableCollection<int>(); foreach (Seat seat in Seats) { if (!rows.Contains(seat.Row)) { rows.Add(seat.Row); } if (!columns.Contains(seat.Nr)) { columns.Add(seat.Nr); Debug.WriteLine(seat.Nr); } } InitializeComponent(); } private void CheckBox_Checked_1(object sender, RoutedEventArgs e) { i++; MessageBox.Show(i.ToString()); } } public class Seat { bool isOccupied; int nr; int row; public int Row { get { return row; } set { row = value; } } public int Nr { get { return nr; } set { nr = value; } } public Seat(int nr, int row) { Nr = nr; Row = row; } public bool IsOccupied { get { return isOccupied; } set { isOccupied = value; } } } }
<UserControl x:Class="WpfControlLibrary1.SeatingArea" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:c="clr-namespace:WpfControlLibrary1" Background="Beige" DataContext="{Binding RelativeSource={RelativeSource Self}}" > <StackPanel> <TextBlock HorizontalAlignment="Center" Text="SEATING CHART" FontSize="24" Margin="0,10"/> <ItemsControl ItemsSource="{Binding Rows}"> <ItemsControl.ItemTemplate> <DataTemplate> <StackPanel Background="blue" HorizontalAlignment="Center" > <ItemsControl ItemsSource="{Binding Columns}"> <ItemsControl.ItemTemplate> <DataTemplate> <CheckBox HorizontalAlignment="Center" VerticalAlignment="Top" Width="30" Height="30" Background="Red" /> </DataTemplate> </ItemsControl.ItemTemplate> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <WrapPanel HorizontalAlignment="Center" /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </ItemsControl> </StackPanel> </DataTemplate> </ItemsControl.ItemTemplate> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Vertical" /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </ItemsControl> </StackPanel> </UserControl>
The problem is that I successfully bind the first itemssource to Rows ... but I don't think that the second itemssource is bound correctly to Columns... because when I start the application it shows me only 7 checkboxes per each row.. what do you think it's the problem? and what did you mean by a Grid of Controls.. because I can't find anything about it -
In Topic: WPF Cinema Booking
Posted 12 Dec 2012
sorry for making it look like I don't try... but I really tried for lots of hours....but I still didn't figure it out..
So this is the xaml.cs code I have until now... I made a list of seats which are numbered by rows and nr in the row.
using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace WpfControlLibrary1 { public partial class SeatingArea : UserControl { private ObservableCollection<Seat> seats; public ObservableCollection<Seat> Seats { get { return seats; } set { seats = value; } } public SeatingArea() { Seats = new ObservableCollection<Seat>(); for (int i = 1; i <= 10; i++) for (int j =1; j<=10;j++) { Seat seat = new Seat(j,i); seat.IsOccupied = false; Seats.Add(seat); } InitializeComponent(); } } public class Seat { bool isOccupied; int nr; int row; public int Row { get { return row*100; } set { row = value; } } public int Nr { get { return nr*100; } set { nr = value; } } public Seat(int nr, int row) { Nr = nr; Row = row; } public bool IsOccupied { get { return isOccupied; } set { isOccupied = value; } } } }
When it comes to the .xaml code this is what I have until now..
<UserControl x:Class="WpfControlLibrary1.SeatingArea" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Background="Beige" DataContext="{Binding RelativeSource={RelativeSource Self}}"> <StackPanel> <TextBlock HorizontalAlignment="Center" Text="SEATING CHART" FontSize="24" Margin="0,10"/> <ItemsControl ItemsSource="{Binding Seats}"> <ItemsControl.ItemTemplate> <DataTemplate> <Grid > <CheckBox Content="{Binding Nr}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="30" Height="30" Margin="5,5" Click="Button_Click_1" Tag="{Binding}" Canvas.Left="{Binding Nr}" Canvas.Top="{Binding Row}" /> </Grid> </DataTemplate> </ItemsControl.ItemTemplate> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <Canvas Height="300" Width="550"/> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </ItemsControl> </StackPanel> </UserControl>
I though that using the canvas was best for me because I wanted to show the seats on row... and by using Canvas.Left and Canvas.Top it should have worked... but it doesn't... I am using the WrapPanel it will make really odd... so that's why asked which panel would you advice me... -
In Topic: WPF Cinema Booking
Posted 12 Dec 2012
There are 2 situations: 1)the best seats are preselected...
2) if the user doesn't like those, he should be able to choose other seats...
So I think that CheckBoxes would be the best.. because he can check those boxes...
So, in what Panel should I put the boxes and how to limit the number of checkboxes that can be checked? -
In Topic: WPF Cinema Booking
Posted 12 Dec 2012
After all I changed it a little bit... but I still have some questions.. instead of buttons I`ll use check boxes.. but can I select the maximum number of check boxes I can check at a time? -
In Topic: WPF Cinema Booking
Posted 12 Dec 2012
I will need the program to autoselect the best suitable seats (by receiving the seats from a webservice) or also to select more than 1 seat and then to book those seats. Should I use something else than buttons? Thanks for helping me:D
My Information
- Member Title:
- New D.I.C Head
- Age:
- Age Unknown
- Birthday:
- Birthday Unknown
- Gender:
Contact Information
- E-mail:
- Private
Friends
lordcoco hasn't added any friends yet.
|
|


Find Topics
Find Posts
View Reputation Given
|
Comments
lordcoco has no profile comments yet. Why not say hello?