Imagara 2 年 前
コミット
7ad2c83bde

+ 1 - 1
RaspisKusach/EDM.Designer.cs

@@ -1,4 +1,4 @@
-// Создание кода T4 для модели "C:\Users\pc\source\repos\RaspisKusach\RaspisKusach\EDM.edmx" включено. 
+// Создание кода T4 для модели "C:\Users\milic\source\repos\RaspisKusach\RaspisKusach\EDM.edmx" включено. 
 // Чтобы включить формирование кода прежних версий, измените значение свойства "Стратегия создания кода" конструктора
 // на "Legacy ObjectContext". Это свойство доступно в окне "Свойства", если модель
 // открыта в конструкторе.

+ 1 - 1
RaspisKusach/EDM.edmx.diagram

@@ -9,7 +9,7 @@
         <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Routes" Width="1.5" PointX="3.875" PointY="4.25" />
         <EntityTypeShape EntityType="RouteScheduleDataBaseModel.RoutesStations" Width="1.5" PointX="3.875" PointY="7.875" />
         <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Station" Width="1.5" PointX="7.125" PointY="7.875" />
-        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.sysdiagrams" Width="1.5" PointX="10" PointY="4.625" />
+        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.sysdiagrams" Width="1.5" PointX="7" PointY="4.375" />
         <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Tickets" Width="1.5" PointX="1.25" PointY="4.5" />
         <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Trains" Width="1.5" PointX="3.75" PointY="1.875" />
         <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Users" Width="1.5" PointX="1.25" PointY="8.125" />

+ 23 - 151
RaspisKusach/Pages/MainPage.xaml

@@ -33,14 +33,14 @@
                                 Grid.Row="0"
                                 HorizontalAlignment="Center"
                                 Height="50">
-                        <ComboBox Name="StationArrivalComboBox"
+                        <ComboBox Name="StationDepartureComboBox"
                                   Margin="5,0,5,0"
                                   IsEditable="True"
                                   Width="80"
                                   Text="Откуда">
                         </ComboBox>
 
-                        <ComboBox Name="StationDepartureComboBox"
+                        <ComboBox Name="StationArrivalComboBox"
                                   Margin="5,0,5,0"
                                   IsEditable="True"
                                   Width="80"
@@ -76,132 +76,14 @@
             </Grid>
         </Border>
 
-        <!--TEMP-->
-        <Grid Name="TempGrid"
-              Background="{x:Null}"
-              Grid.Column="1"
-              Visibility="Collapsed">
-            
-            <Border Height="120"
-                    CornerRadius="10"
-                    Background="{StaticResource Color2}"
-                    BorderThickness="1.5"
-                    BorderBrush="{StaticResource Selection}"
-                    Margin="10,2,10,2"
-                    MouseDown="Border_MouseDown">
-                
-                <Grid Background="{x:Null}">
-                    <Grid.ColumnDefinitions>
-                        <ColumnDefinition/>
-                        <ColumnDefinition/>
-                    </Grid.ColumnDefinitions>
-                    <Grid.RowDefinitions>
-                        <RowDefinition Height="40"/>
-                        <RowDefinition/>
-                    </Grid.RowDefinitions>
-
-                    <!--UPLEFT-->
-                    <StackPanel Orientation="Horizontal"
-                            Grid.Column="0">
-                        <Image Width="35"
-                               Height="35"
-                               Margin="5"
-                               HorizontalAlignment="Left"
-                               Source="/Resources/Train.png">
-                        </Image>
-                        <StackPanel>
-                            <Label Content="{Binding IdRoute}"/>
-                            <Label Content="{Binding str}"
-                                   Margin="0,-7,0,0"/>
-                        </StackPanel>
-                    </StackPanel>
-                    <!--UPRIGHT-->
-                    <StackPanel Orientation="Horizontal"
-                                Grid.Column="1"
-                                HorizontalAlignment="Right">
-                        <Image Source="/Resources/Train.png"
-                                       Margin="3">
-                        </Image>
-                        <Image Source="/Resources/Train.png"
-                                       Margin="3">
-                        </Image>
-                        <Image Source="/Resources/Train.png"
-                                       Margin="3">
-                        </Image>
-
-                    </StackPanel>
-
-                    <!--DOWNLEFT-->
-                    <Grid Grid.Row="1" Grid.Column="0"
-                          Background="{x:Null}">
-                        <Grid Background="{x:Null}">
-                            <Grid.ColumnDefinitions>
-                                <ColumnDefinition/>
-                                <ColumnDefinition/>
-                                <ColumnDefinition/>
-                            </Grid.ColumnDefinitions>
-                            
-                            <StackPanel>
-                                <Label Content="City">
-
-                                </Label>
-                                <Label Content="Time">
-
-                                </Label>
-                            </StackPanel>
-
-                            <Label Content="TimeBetween" Grid.Column="1">
-
-                            </Label>
-
-                            <StackPanel Grid.Column="2">
-                                <Label Content="City">
-
-                                </Label>
-                                <Label Content="Time">
-
-                                </Label>
-                            </StackPanel>
-                            
-                            <!--<Label Name="FROML"
-                                   Content="{Binding Station.Name}">
-                                
-                            </Label>
-                            <Label Content="To">
-                                
-                            </Label>
-                            <Label Name="ToL"
-                                   Content="{Binding Station.Name}">
-                                
-                            </Label>-->
-                        </Grid>
-                    </Grid>
-
-                    <ListBox Grid.Row="1" Grid.Column="1"
-                          Background="{x:Null}">
-                        <Grid Width="260" Height="20" Background="Black">
-                            
-                        </Grid>
-                        <Grid Width="260" Height="20" Background="Black">
-                            
-                        </Grid>
-                        <Grid Width="260" Height="20" Background="Black">
-                            
-                        </Grid>
-                    </ListBox>
-                    
-                </Grid>
-
-
-            </Border>
-        </Grid>
-
         <ListBox Name="ListBox"
                  Grid.Column="1"
-                 Visibility="Visible">
+                 BorderBrush="{x:Null}">
+            <ScrollViewer VerticalScrollBarVisibility="Visible"/>
             <ListBox.ItemTemplate>
                 <DataTemplate>
                     <Border Height="120"
+                            Width="555"
                     CornerRadius="10"
                     Background="{StaticResource Color2}"
                     BorderThickness="1.5"
@@ -252,7 +134,7 @@
 
                             <!--DOWNLEFT-->
                             <Grid Grid.Row="1" Grid.Column="0"
-                          Background="{x:Null}">
+                                  Background="{x:Null}">
                                 <Grid Background="{x:Null}">
                                     <Grid.ColumnDefinitions>
                                         <ColumnDefinition/>
@@ -261,43 +143,37 @@
                                     </Grid.ColumnDefinitions>
 
                                     <StackPanel>
-                                        <Label Content="City">
-
+                                        <Label Content="{Binding stationDeparture}"
+                                               Style="{StaticResource TextCenter}">
                                         </Label>
-                                        <Label Content="Time">
-
+                                        <Label Content="{Binding timeDeparture}"
+                                               Style="{StaticResource TextCenter}">
                                         </Label>
                                     </StackPanel>
 
-                                    <Label Content="TimeBetween" Grid.Column="1">
-
+                                    <Label Content="{Binding timeBetween}" 
+                                           Grid.Column="1"
+                                           Style="{StaticResource TextCenter}">
                                     </Label>
 
                                     <StackPanel Grid.Column="2">
-                                        <Label Content="City">
+                                        <Label Content="{Binding stationArrival}"
+                                               Style="{StaticResource TextCenter}">
 
                                         </Label>
-                                        <Label Content="Time">
+                                        <Label Content="{Binding timeArrival}"
+                                               Style="{StaticResource TextCenter}">
 
                                         </Label>
                                     </StackPanel>
-
-                                    <!--<Label Name="FROML"
-                                   Content="{Binding Station.Name}">
-                                
-                            </Label>
-                            <Label Content="To">
-                                
-                            </Label>
-                            <Label Name="ToL"
-                                   Content="{Binding Station.Name}">
-                                
-                            </Label>-->
                                 </Grid>
                             </Grid>
-
+                            
+                            
+                            <!--DOWNRIGHT-->
                             <ListBox Grid.Row="1" Grid.Column="1"
-                          Background="{x:Null}">
+                                     Background="{x:Null}"
+                                     BorderBrush="{x:Null}">
                                 <Grid Width="260" Height="20" Background="Black">
 
                                 </Grid>
@@ -305,17 +181,13 @@
 
                                 </Grid>
                                 <Grid Width="260" Height="20" Background="Black">
-
                                 </Grid>
                             </ListBox>
-
                         </Grid>
-
-
                     </Border>
                 </DataTemplate>
             </ListBox.ItemTemplate>
         </ListBox>
-
+        
     </Grid>
 </Page>

+ 29 - 20
RaspisKusach/Pages/MainPage.xaml.cs

@@ -20,13 +20,13 @@ namespace RaspisKusach.Pages
         public MainPage()
         {
             InitializeComponent();
-
+            ListBox.Items.Clear();
             foreach (var station in cnt.db.Station.GroupBy(item => item.Location))
             {
                 StationArrivalComboBox.Items.Add(station.Key);
                 StationDepartureComboBox.Items.Add(station.Key);
             }
-            //UpdateRoutesList();
+            UpdateRoutesList();
         }
         private void UpdateRoutesList()
         {
@@ -39,23 +39,32 @@ namespace RaspisKusach.Pages
             //        list.Remove(route);
             //}
 
-            List<RouteClass> playerApps = new List<RouteClass>();
+            List<RouteClass> routeList = new List<RouteClass>();
 
             foreach (Routes route in cnt.db.Routes)
             {
-                RouteClass playerApp = new RouteClass();
-                playerApp.route = route;
-                playerApp.str = cnt.db.RoutesStations.Where(item => item.IdStation == cnt.db.Station.Where(it => it.Location == StationArrivalComboBox.Text).Select(it => it.IdStation).FirstOrDefault()).Select(item => item.DateTime).FirstOrDefault().ToString();
-                playerApp.stationArrival = StationArrivalComboBox.Text;
-                playerApp.stationDeparture = StationDepartureComboBox.Text;
-                //playerApp.timeArrival = Data
-                //playerApp.timeDe
-
-
-                playerApps.Add(playerApp);
+                RouteClass rt = new RouteClass();
+                rt.route = route;
+                //rt.str = cnt.db.RoutesStations.
+                //    Where(item => item.IdStation == cnt.db.Station.
+                //        Where(it => it.Location == StationArrivalComboBox.Text).
+                //        Select(it => it.IdStation).FirstOrDefault()).
+                //    Select(item => item.DateTime).FirstOrDefault().
+                //    ToString();
+                rt.stationArrival = StationArrivalComboBox.Text;
+                rt.stationDeparture = StationDepartureComboBox.Text;
+                rt.timeArrival = cnt.db.RoutesStations.
+                    Where(item => item.IdRoute == route.IdRoute && item.Station.Location == StationArrivalComboBox.Text).
+                    Select(item => item.DateTime).FirstOrDefault();
+                rt.timeDeparture = cnt.db.RoutesStations.
+                    Where(item => item.IdRoute == route.IdRoute && item.Station.Location == StationDepartureComboBox.Text).
+                    Select(item => item.DateTime).FirstOrDefault();
+                rt.timeBetween = rt.timeDeparture - rt.timeArrival;
+
+                routeList.Add(rt);
             }
 
-            ListBox.ItemsSource = playerApps;
+            ListBox.ItemsSource = routeList;
         }
         private void Button_Click(object sender, RoutedEventArgs e)
         {
@@ -73,21 +82,21 @@ namespace RaspisKusach.Pages
 
         }
 
-        public class RouteClass
+        private void FindRoutesButton_Click(object sender, RoutedEventArgs e)
         {
+            UpdateRoutesList();
+        }
 
+        public class RouteClass
+        {
             public Routes route { get; set; }
             public string str { get; set; }
             public string stationDeparture { get; set; }
             public string stationArrival { get; set; }
             public DateTime timeDeparture { get; set; }
             public DateTime timeArrival { get; set; }
+            public TimeSpan timeBetween { get; set; }
 
         }
-
-        private void FindRoutesButton_Click(object sender, RoutedEventArgs e)
-        {
-            UpdateRoutesList();
-        }
     }
 }

+ 5 - 0
RaspisKusach/Styles/Style.xaml

@@ -35,6 +35,11 @@
         <Setter Property="Background" Value="White"/>
     </Style>
 
+    <Style x:Key="TextCenter" TargetType="Label">
+        <Setter Property="HorizontalContentAlignment" Value="Center"/>
+        <Setter Property="VerticalContentAlignment" Value="Center"/>
+    </Style>
+
     <Style TargetType="Button">
         <Setter Property="Template">
             <Setter.Value>