Imagara 2 年之前
父節點
當前提交
0103525edc

+ 18 - 22
RaspisKusach/Functions.cs

@@ -10,21 +10,9 @@ namespace RaspisKusach
     public class Functions
     {
         // Получение направления по маршруту или поездке
-        public static string GetRouteDirection(Routes route)
-        {
-            string direction = "";
-            direction += cnt.db.RoutesStations.Where(item => item.IdRoute == route.IdRoute).Select(item => item.Stations.Location).FirstOrDefault()
-                + " - "
-                + cnt.db.RoutesStations.Where(item => item.IdRoute == route.IdRoute).OrderByDescending(item => item.IdRouteStation).Select(item => item.Stations.Location).FirstOrDefault();
-            return direction;
-        }
         public static string GetRouteDirection(Trips trip)
         {
-            string direction = "";
-            direction += cnt.db.RoutesStations.Where(item => item.IdRoute == trip.Routes.IdRoute).Select(item => item.Stations.Location).FirstOrDefault()
-                + " - "
-                + cnt.db.RoutesStations.Where(item => item.IdRoute == trip.Routes.IdRoute).OrderByDescending(item => item.IdRouteStation).Select(item => item.Stations.Location).FirstOrDefault();
-            return direction;
+            return GetDepartureStationLocation(trip) + " - " + GetArrivalStationLocation(trip);
         }
         // Получение времени прибытия поезда на станцию
         public static DateTime GetArrivalTime(Stations station, Trips trip)
@@ -51,17 +39,25 @@ namespace RaspisKusach
             }
             return date;
         }
-        // Получение времени поездки от станции отправления до станции прибытия
-        public static TimeSpan GetTimeBetweenDepartureNArrival(Stations departureStation, Stations arrivalStation, Trips trip)
+        // Получение станции отправления (первой)
+        public static string GetDepartureStationLocation(Trips trip)
         {
-            //TimeSpan dateBetween = ;
-            foreach (RoutesStations item in cnt.db.RoutesStations.Where(item => item.IdRoute == trip.IdRoute))
-            {
-                
-            }
-            //return dateBetween;
-            return new TimeSpan(0,0,0); //temp
+            return cnt.db.RoutesStations.Where(item => item.IdRoute == trip.Routes.IdRoute).OrderByDescending(item => item.IdRouteStation).Select(item => item.Stations.Location).FirstOrDefault();
+        }
+        public static string GetDepartureStationLocation(Routes route)
+        {
+            return cnt.db.RoutesStations.Where(item => item.IdRoute == route.IdRoute).OrderByDescending(item => item.IdRouteStation).Select(item => item.Stations.Location).FirstOrDefault();
+        }
+        // Получение станции прибытия (последней)
+        public static string GetArrivalStationLocation(Trips trip)
+        {
+            return cnt.db.RoutesStations.Where(item => item.IdRoute == trip.Routes.IdRoute).Select(item => item.Stations.Location).FirstOrDefault();
         }
+        public static string GetArrivalStationLocation(Routes route)
+        {
+            return cnt.db.RoutesStations.Where(item => item.IdRoute == route.IdRoute).Select(item => item.Stations.Location).FirstOrDefault();
+        }
+
         // Валидация номера телефона
         public static bool IsPhoneNumberCorrect(string phoneNumber)
         {

+ 3 - 1
RaspisKusach/MainWindow.xaml.cs

@@ -9,10 +9,12 @@ namespace RaspisKusach
         public MainWindow()
         {
             InitializeComponent();
-            //MessageBox.Show($" {cnt.db.RoutesStations.Where(item => item.IdRouteStation == 1).Select(item => item.StopTime).FirstOrDefault() + cnt.db.RoutesStations.Where(item => item.IdRouteStation == 1).Select(item => item.TravelTime).FirstOrDefault()}");
         }
         private void Border_MouseDown(object sender, MouseButtonEventArgs e)
         {
+            if(Application.Current.MainWindow.WindowState == WindowState.Maximized)
+                Application.Current.MainWindow.WindowState = WindowState.Normal;
+            
             if (e.LeftButton == MouseButtonState.Pressed)
                 DragMove();
         }

+ 1 - 1
RaspisKusach/Pages/AdministrationPage.xaml

@@ -8,7 +8,7 @@
       d:DesignHeight="450" d:DesignWidth="800"
       Title="AdministrationPage">
 
-    <Grid>
+    <Grid Background="White">
         <Grid.RowDefinitions>
             <RowDefinition Height="35"/>
             <RowDefinition/>

+ 1 - 1
RaspisKusach/Pages/ProfilePage.xaml

@@ -8,7 +8,7 @@
       d:DesignHeight="450" d:DesignWidth="800"
       Title="ProfilePage">
 
-    <Grid>
+    <Grid Background="White">
         <StackPanel>
             <Label>
 

+ 6 - 4
RaspisKusach/Pages/SchedulePage.xaml

@@ -4,11 +4,14 @@
       xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
       xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
       xmlns:local="clr-namespace:RaspisKusach.Pages"
+      xmlns:math="http://hexinnovation.com/math"
       mc:Ignorable="d" 
       d:DesignHeight="450" d:DesignWidth="800"
       Title="SchedulePage">
-
-    <Grid>
+    <Page.Resources>
+        <math:MathConverter x:Key="math"/>
+    </Page.Resources>
+    <Grid Background="White">
         <Grid.RowDefinitions>
             <RowDefinition Height="40"/>
             <RowDefinition Height="40"/>
@@ -42,7 +45,6 @@
 
         <ListBox Name="TripsListBox"
                  Grid.Row="2"
-                 Margin="10,0,10,0"
                  Background="White"
                  BorderBrush="{x:Null}"
                  ScrollViewer.HorizontalScrollBarVisibility="Disabled"
@@ -50,7 +52,7 @@
             <ScrollBar></ScrollBar>
             <ListBox.ItemTemplate>
                 <DataTemplate>
-                    <Border Width="{Binding Path=ActualWidth, ElementName=TripsListBox}"
+                    <Border Width="{Binding Path=ActualWidth, Mode=OneWay, ElementName=TripsListBox, Converter={StaticResource math}, ConverterParameter=x-15}"
                             Height="70"
                             CornerRadius="15"
                             Background="{StaticResource Color2}">

+ 25 - 21
RaspisKusach/Pages/SearchForTicketsPage.xaml

@@ -4,15 +4,18 @@
       xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
       xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
       xmlns:local="clr-namespace:RaspisKusach.Pages"
+      xmlns:math="http://hexinnovation.com/math"
       mc:Ignorable="d" 
       d:DesignHeight="450" 
       d:DesignWidth="800"
       Title="MainPage">
-
-    <Grid>
+    <Page.Resources>
+        <math:MathConverter x:Key="math"/>
+    </Page.Resources>
+    <Grid Background="White">
         <Grid.ColumnDefinitions>
-            <ColumnDefinition Width="210"/>
-            <ColumnDefinition/>
+            <ColumnDefinition Width="*"/>
+            <ColumnDefinition Width="3*"/>
         </Grid.ColumnDefinitions>
 
         <!--LEFTBAR-->
@@ -70,24 +73,25 @@
         <ListBox Name="ListBox"
                  Grid.Column="1"
                  BorderBrush="{x:Null}"
-                 ScrollViewer.HorizontalScrollBarVisibility="Disabled">
-           temp
+                 ScrollViewer.HorizontalScrollBarVisibility="Disabled"
+                 SelectionChanged="ListBox_SelectionChanged">
+            temp
             <ListBox.ItemTemplate>
                 <DataTemplate>
                     <Border Height="120"
-                            Width="555"
-                    CornerRadius="10"
-                    Background="{StaticResource Color2}"
-                    BorderThickness="1.5"
-                    BorderBrush="{StaticResource Selection}"
-                    Margin="10,2,10,2">
-                        
+                            Width="{Binding Path=ActualWidth, Mode=OneWay, ElementName=ListBox, Converter={StaticResource math}, ConverterParameter=x-15}"
+                            CornerRadius="10"
+                            Background="{StaticResource Color2}"
+                            BorderThickness="1.5"
+                            BorderBrush="{StaticResource Selection}"
+                            Margin="0,2,0,2">
+
                         <Grid>
                             <Grid.RowDefinitions>
                                 <RowDefinition Height="40"/>
                                 <RowDefinition/>
                             </Grid.RowDefinitions>
-                            
+
                             <!--UP-->
                             <Grid>
                                 <Grid.ColumnDefinitions>
@@ -96,17 +100,17 @@
                                 </Grid.ColumnDefinitions>
                                 <!--UPLEFT-->
                                 <StackPanel Orientation="Horizontal"
-                            Grid.Column="0">
+                                            Grid.Column="0">
                                     <Image Width="35"
-                               Height="35"
-                               Margin="5"
-                               HorizontalAlignment="Left"
-                               Source="/Resources/Train.png">
+                                           Height="35"
+                                           Margin="5"
+                                           HorizontalAlignment="Left"
+                                           Source="/Resources/Train.png">
                                     </Image>
                                     <StackPanel>
                                         <Label Content="{Binding route.IdRoute}"/>
                                         <Label Content="{Binding str}"
-                                   Margin="0,-7,0,0"/>
+                                               Margin="0,-7,0,0"/>
                                     </StackPanel>
                                 </StackPanel>
                                 <!--UPRIGHT-->
@@ -125,7 +129,7 @@
 
                                 </StackPanel>
                             </Grid>
-                            
+
                             <!--DOWNLEFT-->
                             <Grid Grid.Row="1" Grid.Column="0"
                                   Background="{x:Null}">

+ 13 - 0
RaspisKusach/Pages/SearchForTicketsPage.xaml.cs

@@ -69,6 +69,19 @@ namespace RaspisKusach.Pages
             UpdateRoutesList();
         }
 
+        private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            try
+            {
+                if (((TripClass)ListBox.SelectedItem) != null)
+                    NavigationService.Navigate(new TripInfoPage(((TripClass)ListBox.SelectedItem).trip));
+            }
+            catch
+            {
+                new ErrorWindow("Ошибка открытия окна.").ShowDialog();
+            }
+        }
+
         public class TripClass
         {
             public Trips trip { get; set; }

+ 38 - 2
RaspisKusach/Pages/TripInfoPage.xaml

@@ -8,7 +8,43 @@
       d:DesignHeight="450" d:DesignWidth="800"
       Title="TripInfoPage">
 
-    <Grid>
-        
+    <Grid Background="White">
+        <Grid.RowDefinitions>
+            <RowDefinition/>
+            <RowDefinition Height="2*"/>
+        </Grid.RowDefinitions>
+        <!--UP-->
+        <Grid>
+            <Grid.RowDefinitions>
+                <RowDefinition Height="33*"/>
+                <RowDefinition Height="38*"/>
+                <RowDefinition Height="79*"/>
+            </Grid.RowDefinitions>
+            <StackPanel Orientation="Horizontal">
+                <Image Source="/RaspisKusach;component/Resources/Train.png" >
+
+                </Image>
+                <Label>
+                    ПОЕЗД  #123
+                </Label>
+            </StackPanel>
+
+            <Label Grid.Row="1"
+                   Name="Direction"
+                   HorizontalContentAlignment="Left"/>
+
+            <Grid Grid.Row="2">
+
+            </Grid>
+
+        </Grid>
+
+        <!--DOWN-->
+        <Grid Grid.Row="1">
+
+        </Grid>
+
     </Grid>
+
+
 </Page>

+ 7 - 4
RaspisKusach/Pages/TripInfoPage.xaml.cs

@@ -15,14 +15,17 @@ using System.Windows.Shapes;
 
 namespace RaspisKusach.Pages
 {
-    /// <summary>
-    /// Логика взаимодействия для TripInfoPage.xaml
-    /// </summary>
     public partial class TripInfoPage : Page
     {
-        public TripInfoPage()
+        public TripInfoPage(Trips trip)
         {
             InitializeComponent();
+            string stationsList = "";
+            foreach (RoutesStations rs in cnt.db.RoutesStations.Where(item => item.IdRoute == trip.IdRoute))
+                stationsList += rs.Stations.Location == Functions.GetDepartureStationLocation(trip) ? rs.Stations.Name : $"{rs.Stations.Name} → ";
+            Direction.Content = stationsList;
+
         }
+
     }
 }

+ 3 - 0
RaspisKusach/RaspisKusach.csproj

@@ -41,6 +41,9 @@
     <Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
       <HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
     </Reference>
+    <Reference Include="MathConverter, Version=1.2.1.6, Culture=neutral, processorArchitecture=MSIL">
+      <HintPath>..\packages\MathConverter.1.2.1.6\lib\net40-client\MathConverter.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.ComponentModel.DataAnnotations" />
     <Reference Include="System.Data" />

+ 1 - 1
RaspisKusach/Styles/Style.cs

@@ -10,7 +10,7 @@ namespace RaspisKusach
         private void MouseEnter(object sender, MouseEventArgs e)
         {
             ((Border)sender).BorderBrush = new SolidColorBrush(Color.FromRgb(0x8B, 0x00, 0xFF));
-        }//#8B00FF
+        }
 
         private void MouseLeave(object sender, MouseEventArgs e)
         {

+ 1 - 0
RaspisKusach/packages.config

@@ -2,4 +2,5 @@
 <packages>
   <package id="EntityFramework" version="6.2.0" targetFramework="net472" />
   <package id="EntityFramework.ru" version="6.2.0" targetFramework="net472" />
+  <package id="MathConverter" version="1.2.1.6" targetFramework="net472" />
 </packages>