Эх сурвалжийг харах

Работа над стилями

Almir Myxametszanov 8 сар өмнө
parent
commit
2b769d88e3

+ 1 - 0
src/DontHarmDesktop/App.xaml

@@ -8,6 +8,7 @@
             <ResourceDictionary.MergedDictionaries>
                 <ResourceDictionary Source="Dictionaries/BrushesStyle.xaml"/>
                 <ResourceDictionary Source="Dictionaries/MainStyle.xaml"/>
+                <ResourceDictionary Source="Dictionaries/Buttons.xaml"/>
             </ResourceDictionary.MergedDictionaries>
         </ResourceDictionary>
     </Application.Resources>

+ 7 - 3
src/DontHarmDesktop/Dictionaries/BrushesStyle.xaml

@@ -1,6 +1,10 @@
 <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
-    <SolidColorBrush x:Key="MainColor" Color="White"/>
-    <SolidColorBrush x:Key="SecondaryColor" Color="#76e383"/>
-    <SolidColorBrush x:Key="AccentColor" Color="#498c51"/>
+    
+    <SolidColorBrush x:Key="MainColor" Color="#EEEEEC"/>
+    <SolidColorBrush x:Key="SecondaryColor" Color="#26854c"/>
+    <SolidColorBrush x:Key="AccentColor" Color="#006554"/>
+
+    <SolidColorBrush x:Key="DestructiveAction" Color="#ec273f"/>
+    <SolidColorBrush x:Key="SuggestedAction" Color="#5ab552"/>
 </ResourceDictionary>

+ 11 - 0
src/DontHarmDesktop/Dictionaries/Buttons.xaml

@@ -0,0 +1,11 @@
+<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
+    <Style x:Key="Suggested" TargetType="Button">
+        <Setter Property="Background" Value="{StaticResource SuggestedAction}"/>
+        <Setter Property="Foreground" Value="White"/>
+    </Style>
+    <Style x:Key="Destructive" TargetType="Button">
+        <Setter Property="Background" Value="{StaticResource DestructiveAction}"/>
+        <Setter Property="Foreground" Value="White"/>
+    </Style>
+</ResourceDictionary>

+ 4 - 0
src/DontHarmDesktop/DontHarmDesktop.csproj

@@ -101,6 +101,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Dictionaries\Buttons.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Dictionaries\MainStyle.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>

+ 3 - 4
src/DontHarmDesktop/MainWindow.xaml

@@ -12,7 +12,7 @@
 
     <Grid>
         <Grid.RowDefinitions>
-            <RowDefinition Height="64"/>
+            <RowDefinition Height="48"/>
             <RowDefinition Height="*"/>
             <RowDefinition Height="32"/>
         </Grid.RowDefinitions>
@@ -27,13 +27,12 @@
             
             <Image Source="/Pages/Logo.png" Grid.Column="0"/>
             <TextBlock 
+                Foreground="White"
                 Grid.Column="1"
                 HorizontalAlignment="Center"
                 VerticalAlignment="Center"
                 FontSize="18">Не навреди</TextBlock>
             <Button
-                Foreground="White"
-                Background="{StaticResource AccentColor}"
                 Command="{Binding LogoutCmd}"
                 Grid.Column="2"
                 Height="32"
@@ -50,7 +49,7 @@
         <!-- Body end -->
         
         <!-- Footer start -->
-        <Grid Background="{StaticResource AccentColor}" Grid.Row="2">
+        <Grid Background="{StaticResource SecondaryColor}" Grid.Row="2">
             <TextBlock 
                 Grid.Row="2"
                 x:Name="TimerTextBlock" 

+ 6 - 1
src/DontHarmDesktop/Pages/ServiceAdd.xaml

@@ -29,6 +29,11 @@
         <TextBox Grid.Row="1" Grid.Column="1" Margin="4" Text="{Binding Price}"/>
         <TextBox Grid.Row="2" Grid.Column="1" Margin="4" Text="{Binding Code}"/>
 
-        <Button Grid.Row="3" Grid.Column="1" Margin="4" Background="{StaticResource SecondaryColor}" Command="{Binding Submit}">Сохранить</Button>
+        <Button 
+            Grid.Row="3"
+            Grid.Column="1"
+            Margin="4"
+            Style="{StaticResource Suggested}"
+            Command="{Binding Submit}">Сохранить</Button>
     </Grid>
 </Page>

+ 24 - 19
src/DontHarmDesktop/Pages/Services.xaml

@@ -10,34 +10,39 @@
 
     <Grid>
         <Grid.RowDefinitions>
-            <RowDefinition Height="*"/>
             <RowDefinition Height="32"/>
+            <RowDefinition Height="*"/>
         </Grid.RowDefinitions>
 
-        <DataGrid Grid.Row="0" ItemsSource="{Binding Services}" AutoGenerateColumns="False" IsReadOnly="True">
+        <Grid Grid.Row="0">
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition Width="128"/>
+                <ColumnDefinition Width="128"/>
+                <ColumnDefinition Width="128"/>
+            </Grid.ColumnDefinitions>
+
+            <Button 
+                Grid.Column="0" 
+                Style="{StaticResource Suggested}"
+                Command="{Binding AddServiceCmd}"
+                Margin="4">Добавить</Button>
+            <Button 
+                Grid.Column="1"
+                Margin="4">Редактировать</Button>
+            <Button 
+                Grid.Column="2"
+                Style="{StaticResource Destructive}"
+                Margin="4">Удалить</Button>
+        </Grid>
+
+        <DataGrid Grid.Row="1" ItemsSource="{Binding Services}" AutoGenerateColumns="False" IsReadOnly="True">
             <DataGrid.Columns>
                 <DataGridTextColumn Header="Наименование" Binding="{Binding name}"/>
                 <DataGridTextColumn Header="Цена" Binding="{Binding price}"/>
                 <DataGridTextColumn Header="Код услуги" Binding="{Binding code}"/>
-                <DataGridTemplateColumn>
-                    <DataGridTemplateColumn.CellTemplate>
-                        <DataTemplate>
-                            <Button Background="{StaticResource SecondaryColor}" Content="Редактировать"/>
-                        </DataTemplate>
-                    </DataGridTemplateColumn.CellTemplate>
-                </DataGridTemplateColumn>
             </DataGrid.Columns>
         </DataGrid>
 
-        <Grid Grid.Row="1">
-            <Grid.ColumnDefinitions>
-                <ColumnDefinition Width="256"/>
-                <ColumnDefinition Width="*"/>
-                <ColumnDefinition Width="256"/>
-            </Grid.ColumnDefinitions>
-
-            <Button Grid.Column="0" Background="{StaticResource SecondaryColor}" Command="{Binding AddServiceCmd}">Добавить</Button>
-            <Button Grid.Column="2" Background="{StaticResource SecondaryColor}">Удалить</Button>
-        </Grid>
+        
     </Grid>
 </Page>

+ 6 - 0
src/DontHarmDesktop/ViewModels/AuthViewModel.cs

@@ -79,6 +79,12 @@ namespace DontHarmDesktop.ViewModels
         /// </summary>
         private void AddLoginRecord(bool successful, string login)
         {
+            // Если логина нет то не стоит даже добавлять попытку
+            if (String.IsNullOrEmpty(login))
+            {
+                return;
+            }
+
             var record = new login_attempts();
             record.successfull = Convert.ToByte(successful);
             record.login = login;