Skip to content
This repository was archived by the owner on Sep 1, 2022. It is now read-only.

Commit dad4787

Browse files
authored
Merge pull request #4 from kungfux/feature_1.3
Milestone 1.3. UI changes
2 parents 350a985 + 7b7ee93 commit dad4787

32 files changed

+1110
-1044
lines changed

BusinessAccounting/BusinessAccounting/App.config

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,11 @@
66
<connectionStrings>
77
<!--<add name="SQLiteConnection" connectionString="Data Source=ba.sqlite;Version=3;UTF8Encoding=True;foreign keys=true;FailIfMissing=true;" providerName="System.Data.Sqlite" />-->
88
</connectionStrings>
9+
<appSettings>
10+
<!-- Offset in days for default date on cash page (0 - today, -1 - yesterday etc.) -->
11+
<add key="DefaultInputDateOffset" value=""/>
12+
<!-- Offset in days for default date on charts page (0 - today, -1 - yesterday etc.) -->
13+
<add key="DefaultStartDateOffset" value=""/>
14+
<add key="DefaultEndDateOffset" value=""/>
15+
</appSettings>
916
</configuration>

BusinessAccounting/BusinessAccounting/App.xaml.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66

77
namespace BusinessAccounting
88
{
9-
/// <summary>
10-
/// Interaction logic for App.xaml
11-
/// </summary>
129
public partial class App
1310
{
1411
public static readonly XQuerySqlite Sqlite = new XQuerySqlite();
@@ -32,7 +29,8 @@ private void App_OnStartup(object sender, StartupEventArgs e)
3229
}
3330
else
3431
{
35-
MessageBox.Show($"Не удалось установить соединение с базой данных.{Environment.NewLine}Детали: {Sqlite.LastErrorMessage}", "Проблемка");
32+
MessageBox.Show($"Не удалось установить соединение с базой данных.{Environment.NewLine}Детали: {Sqlite.LastErrorMessage}",
33+
"Business Accounting", MessageBoxButton.OK, MessageBoxImage.Stop);
3634
Current.Shutdown();
3735
}
3836
}

BusinessAccounting/BusinessAccounting/BusinessAccounting.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
<Generator>MSBuild:Compile</Generator>
8585
<SubType>Designer</SubType>
8686
</ApplicationDefinition>
87-
<Compile Include="Settings.cs" />
87+
<Compile Include="UserControls\BooleanToVisibilityConverter.cs" />
8888
<Compile Include="UserControls\CashPage.xaml.cs">
8989
<DependentUpon>CashPage.xaml</DependentUpon>
9090
</Compile>
@@ -98,6 +98,7 @@
9898
<Compile Include="UserControls\CashTransaction.cs" />
9999
<Compile Include="UserControls\IndexToBooleanConverter.cs" />
100100
<Compile Include="UserControls\InverseBooleanConverter.cs" />
101+
<Compile Include="UserControls\WaitCursor.cs" />
101102
<Page Include="MainWindow.xaml">
102103
<Generator>MSBuild:Compile</Generator>
103104
<SubType>Designer</SubType>
@@ -135,15 +136,11 @@
135136
<SubType>Designer</SubType>
136137
</None>
137138
</ItemGroup>
138-
<ItemGroup>
139-
<Resource Include="Resources\favicon.ico" />
140-
</ItemGroup>
141139
<ItemGroup>
142140
<Resource Include="Resources\image_menu.png" />
143141
</ItemGroup>
144142
<ItemGroup>
145143
<Resource Include="Resources\image_cash.png" />
146-
<Resource Include="Resources\image_clock.png" />
147144
<Resource Include="Resources\image_graph.png" />
148145
</ItemGroup>
149146
<ItemGroup>
@@ -152,6 +149,9 @@
152149
<ItemGroup>
153150
<Resource Include="Resources\image_noimage.png" />
154151
</ItemGroup>
152+
<ItemGroup>
153+
<Resource Include="Resources\favicon.ico" />
154+
</ItemGroup>
155155
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
156156
<Import Project="..\packages\System.Data.SQLite.Core.1.0.104.0\build\net46\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.104.0\build\net46\System.Data.SQLite.Core.targets')" />
157157
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

BusinessAccounting/BusinessAccounting/MainWindow.xaml

Lines changed: 20 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -15,116 +15,53 @@
1515
SaveWindowPosition="True">
1616

1717
<controls:MetroWindow.Resources>
18-
<Image x:Key="ImageMenu" Source="pack://application:,,,/Resources/image_menu.png" />
19-
<Image x:Key="ImageCash" Source="pack://application:,,,/Resources/image_cash.png" />
20-
<Image x:Key="ImageMan" Source="pack://application:,,,/Resources/image_man.png" />
21-
<Image x:Key="ImageGraph" Source="pack://application:,,,/Resources/image_graph.png" />
18+
<Image x:Key="ImageMenu" Source="pack://application:,,,/Resources/image_menu.png"/>
19+
<Image x:Key="ImageCash" Source="pack://application:,,,/Resources/image_cash.png"/>
20+
<Image x:Key="ImageMan" Source="pack://application:,,,/Resources/image_man.png"/>
21+
<Image x:Key="ImageGraph" Source="pack://application:,,,/Resources/image_graph.png"/>
2222
</controls:MetroWindow.Resources>
2323

2424
<controls:MetroWindow.RightWindowCommands>
2525
<controls:WindowCommands>
26-
<Button Name="OpenDbFolder" Content="Открыть папку с БД" Click="OpenDbFolder_OnClick"/>
26+
<Button Content="Открыть папку с БД" Click="OpenDbFolder_Click"/>
2727
</controls:WindowCommands>
2828
</controls:MetroWindow.RightWindowCommands>
2929

30-
<!-- this grid contain menu button -->
3130
<Grid>
3231
<Grid.Triggers>
33-
<!-- Animates the rectangle's opacity. -->
3432
<EventTrigger RoutedEvent="Grid.Loaded">
3533
<BeginStoryboard>
3634
<Storyboard>
37-
<DoubleAnimation
38-
Storyboard.TargetProperty="Opacity"
39-
From="0.0" To="1.0" Duration="0:0:0.5" />
35+
<DoubleAnimation Storyboard.TargetProperty="Opacity" From="0.0" To="1.0" Duration="0:0:0.5"/>
4036
</Storyboard>
4137
</BeginStoryboard>
4238
</EventTrigger>
4339
</Grid.Triggers>
44-
<!-- this grid contain all user controls (pages of app) -->
40+
4541
<Grid Name="UserControlGrid">
46-
<!-- active pages content -->
4742
</Grid>
48-
<!-- main menu button -->
49-
<Grid
50-
Width="150"
51-
VerticalAlignment="Top"
52-
HorizontalAlignment="Right"
53-
Margin="0,74,10,0"
54-
Opacity="1.0"
55-
x:Name="GridMenu">
43+
44+
<Grid Width="150" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="0,74,10,0" Opacity="1.0" Name="MainMenuGrid">
5645
<Border BorderBrush="{DynamicResource AccentColorBrush}" BorderThickness="2" CornerRadius="4">
5746
<Grid Background="White">
5847
<Grid.ColumnDefinitions>
59-
<ColumnDefinition />
48+
<ColumnDefinition/>
6049
<ColumnDefinition Width="64"/>
6150
</Grid.ColumnDefinitions>
6251
<Grid.RowDefinitions>
63-
<RowDefinition Height="64" />
64-
<RowDefinition Height="64" />
65-
<RowDefinition Height="64" />
52+
<RowDefinition Height="64"/>
53+
<RowDefinition Height="64"/>
54+
<RowDefinition Height="64"/>
6655
</Grid.RowDefinitions>
67-
<Button
68-
Height="64"
69-
Width="64"
70-
Focusable="False"
71-
Content="{StaticResource ImageCash}"
72-
HorizontalAlignment="Left"
73-
Grid.Row="0"
74-
Grid.Column="1"
75-
x:Name="MenuButtonCash"
76-
Click="MenuButtonCash_Click"/>
77-
<Button
78-
Height="64"
79-
Width="64"
80-
Focusable="False"
81-
Content="{StaticResource ImageMan}"
82-
HorizontalAlignment="Left"
83-
Grid.Row="1"
84-
Grid.Column="1"
85-
x:Name="MenuButtonEmployee"
86-
Click="MenuButtonEmployee_Click"/>
87-
<Button
88-
Height="64"
89-
Width="64"
90-
Focusable="False"
91-
Content="{StaticResource ImageGraph}"
92-
HorizontalAlignment="Left"
93-
Grid.Row="2"
94-
Grid.Column="1"
95-
x:Name="MenuButtonGraphics"
96-
Click="MenuButtonGraphics_Click"/>
97-
<Label
98-
Grid.Row="0"
99-
Grid.Column="0"
100-
Content="Касса"
101-
HorizontalAlignment="Right"
102-
VerticalContentAlignment="Center"/>
103-
<Label
104-
Grid.Row="1"
105-
Grid.Column="0"
106-
Content="Сотрудники"
107-
HorizontalAlignment="Right"
108-
VerticalContentAlignment="Center"/>
109-
<Label
110-
Grid.Row="2"
111-
Grid.Column="0"
112-
Content="Графики"
113-
HorizontalAlignment="Right"
114-
VerticalContentAlignment="Center"/>
56+
<Label Grid.Row="0" Grid.Column="0" Content="Касса" HorizontalAlignment="Right" VerticalContentAlignment="Center"/>
57+
<Button Grid.Row="0" Grid.Column="1" Height="64" Width="64" Focusable="False" Content="{StaticResource ImageCash}" HorizontalAlignment="Left" Click="MenuButtonCash_Click"/>
58+
<Label Grid.Row="1" Grid.Column="0" Content="Сотрудники" HorizontalAlignment="Right" VerticalContentAlignment="Center"/>
59+
<Button Grid.Row="1" Grid.Column="1" Height="64" Width="64" Focusable="False" Content="{StaticResource ImageMan}" HorizontalAlignment="Left" Click="MenuButtonEmployee_Click"/>
60+
<Label Grid.Row="2" Grid.Column="0" Content="Графики" HorizontalAlignment="Right" VerticalContentAlignment="Center"/>
61+
<Button Grid.Row="2" Grid.Column="1" Height="64" Width="64" Focusable="False" Content="{StaticResource ImageGraph}" HorizontalAlignment="Left" Click="MenuButtonGraphics_Click"/>
11562
</Grid>
11663
</Border>
11764
</Grid>
118-
<Button
119-
Height="64"
120-
Width="64"
121-
Focusable="False"
122-
Content="{StaticResource ImageMenu}"
123-
HorizontalAlignment="Right"
124-
VerticalAlignment="Top"
125-
Margin="0,10,10,0"
126-
ToolTip="Главное меню"
127-
x:Name="ButtonMenu"
128-
Click="ButtonMenu_Click"/>
65+
<Button Height="64" Width="64" Focusable="False" Content="{StaticResource ImageMenu}" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,10,10,0" ToolTip="Главное меню" Click="ButtonMenu_Click"/>
12966
</Grid>
13067
</controls:MetroWindow>

BusinessAccounting/BusinessAccounting/MainWindow.xaml.cs

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,21 @@
33
using System.IO;
44
using System.Reflection;
55
using System.Windows;
6-
using System.Windows.Controls;
76
using System.Windows.Media;
87
using MahApps.Metro.Controls;
98
using System.Windows.Media.Animation;
109
using MahApps.Metro.Controls.Dialogs;
1110

1211
namespace BusinessAccounting
1312
{
14-
/// <summary>
15-
/// Interaction logic for MainWindow.xaml
16-
/// </summary>
1713
public partial class MainWindow
1814
{
1915
public MainWindow()
2016
{
2117
InitializeComponent();
22-
// set opacity and visibility to hidden to display objects in design mode
23-
GridMenu.Opacity = 0;
24-
GridMenu.Visibility = Visibility.Hidden;
18+
19+
MainMenuGrid.Opacity = 0;
20+
MainMenuGrid.Visibility = Visibility.Hidden;
2521
}
2622

2723
private void ButtonMenu_Click(object sender, RoutedEventArgs e)
@@ -49,31 +45,29 @@ private void MenuButtonEmployee_Click(object sender, RoutedEventArgs e)
4945

5046
private void OpenCloseMenu()
5147
{
52-
if (GridMenu.Opacity == 0)
48+
if (MainMenuGrid.Opacity == 0)
5349
{
54-
GridMenu.Visibility = Visibility.Visible;
50+
MainMenuGrid.Visibility = Visibility.Visible;
5551
}
56-
DoubleAnimation animation = new DoubleAnimation
52+
var animation = new DoubleAnimation
5753
{
58-
From = GridMenu.Opacity > 0 ? 1 : 0,
59-
To = GridMenu.Opacity > 0 ? 0 : 1,
54+
From = MainMenuGrid.Opacity > 0 ? 1 : 0,
55+
To = MainMenuGrid.Opacity > 0 ? 0 : 1,
6056
Duration = new Duration(TimeSpan.FromSeconds(0.5))
6157
};
6258
animation.Completed += animation_Completed;
63-
GridMenu.BeginAnimation(OpacityProperty, animation);
59+
MainMenuGrid.BeginAnimation(OpacityProperty, animation);
6460
}
6561

6662
private void animation_Completed(object sender, EventArgs e)
6763
{
68-
// hide objects if they are not visible already
69-
// to avoid clicks
70-
if (GridMenu.Opacity == 0)
64+
if (MainMenuGrid.Opacity == 0)
7165
{
72-
GridMenu.Visibility = Visibility.Hidden;
66+
MainMenuGrid.Visibility = Visibility.Hidden;
7367
}
7468
}
7569

76-
private void LoadPage(UserControl pPage)
70+
private void LoadPage(UIElement pPage)
7771
{
7872
UserControlGrid.Children.Clear();
7973
UserControlGrid.Children.Add(pPage);
@@ -90,20 +84,19 @@ protected override void OnContentRendered(EventArgs e)
9084

9185
_windowDisplayed = true;
9286

93-
// open default page
9487
LoadPage(new UserControls.CashPage());
9588
}
9689

9790
private void ShowMessage(string text)
9891
{
9992
for (var visual = this as Visual; visual != null; visual = VisualTreeHelper.GetParent(visual) as Visual)
100-
if (visual is MetroWindow)
101-
{
102-
((MetroWindow)visual).ShowMessageAsync("Проблемка", text + Environment.NewLine + App.Sqlite.LastErrorMessage);
103-
}
93+
{
94+
var window = visual as MetroWindow;
95+
window?.ShowMessageAsync("Проблемка", text + Environment.NewLine + App.Sqlite.LastErrorMessage);
96+
}
10497
}
10598

106-
private void OpenDbFolder_OnClick(object sender, RoutedEventArgs e)
99+
private void OpenDbFolder_Click(object sender, RoutedEventArgs e)
107100
{
108101
string dbPath = $@"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}\{Assembly.GetExecutingAssembly().GetName().Name}";
109102

BusinessAccounting/BusinessAccounting/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@
5151
// You can specify all the values or you can default the Build and Revision Numbers
5252
// by using the '*' as shown below:
5353
// [assembly: AssemblyVersion("1.0.*")]
54-
[assembly: AssemblyVersion("1.2.0.0")]
55-
[assembly: AssemblyFileVersion("1.2.0.0")]
54+
[assembly: AssemblyVersion("1.3.0.0")]
55+
[assembly: AssemblyFileVersion("1.3.0.0")]
255 KB
Binary file not shown.
-2.83 KB
Binary file not shown.

BusinessAccounting/BusinessAccounting/Settings.cs

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System;
2+
using System.Globalization;
3+
using System.Windows;
4+
using System.Windows.Data;
5+
6+
namespace BusinessAccounting.UserControls
7+
{
8+
[ValueConversion(typeof(bool), typeof(Visibility))]
9+
public class BooleanToVisibilityConverter : IValueConverter
10+
{
11+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
12+
{
13+
var visibility = Visibility.Visible;
14+
try
15+
{
16+
if (value != null)
17+
{
18+
visibility = (bool)value ? Visibility.Visible : Visibility.Collapsed;
19+
}
20+
}
21+
catch (Exception)
22+
{
23+
// ignored
24+
}
25+
return visibility;
26+
27+
}
28+
29+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
30+
{
31+
32+
return (value != null) && (value == (object) Visibility.Visible);
33+
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)