aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB
diff options
context:
space:
mode:
authorRoy <roy.mail.net@gmail.com>2017-12-15 03:34:09 +0200
committerRoy <roy.mail.net@gmail.com>2017-12-15 03:34:09 +0200
commit27fe2f3f63191ecefbb00f16acf2b8b089a30d83 (patch)
treed861255d3c0596b321c213b1ed64225bfed434dd /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB
parentad35c9c2df0001157ea13312382f3cdfdad67f06 (diff)
downloadTango-27fe2f3f63191ecefbb00f16acf2b8b089a30d83.tar.gz
Tango-27fe2f3f63191ecefbb00f16acf2b8b089a30d83.zip
Added Login.
Implemented message boxes through notification provider. Implemented VM auto validation using data annotation.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ExtensionMethods/INotificationProviderExtensions.cs13
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj8
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Windows/DBDialogWindow.xaml32
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Windows/DBDialogWindow.xaml.cs68
4 files changed, 116 insertions, 5 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ExtensionMethods/INotificationProviderExtensions.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ExtensionMethods/INotificationProviderExtensions.cs
index 2da59724c..8d95bb38e 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ExtensionMethods/INotificationProviderExtensions.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ExtensionMethods/INotificationProviderExtensions.cs
@@ -9,6 +9,7 @@ using Tango.DAL.Observables;
using Tango.MachineStudio.Common.Notifications;
using Tango.MachineStudio.DB.ViewModels;
using Tango.MachineStudio.DB.Views.DBViews;
+using Tango.MachineStudio.DB.Windows;
namespace Tango.MachineStudio.DB.ExtensionMethods
{
@@ -17,11 +18,13 @@ namespace Tango.MachineStudio.DB.ExtensionMethods
public static bool ShowDialog<T>(this INotificationProvider provider, DialogOpenMode mode, DbTableViewModel<T> context) where T : class, IObservableEntity
{
Type viewType = typeof(INotificationProviderExtensions).Assembly.GetType(typeof(OrganizationView).Namespace + "." + typeof(T).Name + "View");
- return provider.ShowDialog(
- (mode == DialogOpenMode.Editing ? PackIconKind.TableEdit : PackIconKind.Plus),
- (mode == DialogOpenMode.Editing ? "Edit " : "Add New ") + typeof(T).Name,
- Activator.CreateInstance(viewType) as FrameworkElement,
- context);
+
+ DBDialogWindow window = new DBDialogWindow(Activator.CreateInstance(viewType) as FrameworkElement);
+ window.IconKind = (mode == DialogOpenMode.Editing ? PackIconKind.TableEdit : PackIconKind.Plus);
+ window.InnerTitle = (mode == DialogOpenMode.Editing ? "Edit " : "Add New ") + typeof(T).Name;
+ window.DataContext = context;
+
+ return provider.ShowModalWindow(window).Value;
}
}
}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj
index 712a99953..95bf8aa53 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj
@@ -135,6 +135,9 @@
<Compile Include="Views\MainDBView.xaml.cs">
<DependentUpon>MainDBView.xaml</DependentUpon>
</Compile>
+ <Compile Include="Windows\DBDialogWindow.xaml.cs">
+ <DependentUpon>DBDialogWindow.xaml</DependentUpon>
+ </Compile>
<Page Include="Controls\DbTableView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@@ -202,6 +205,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
+ <Page Include="Windows\DBDialogWindow.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
@@ -259,5 +266,6 @@
<ItemGroup>
<Resource Include="Images\seamless-grid.jpg" />
</ItemGroup>
+ <ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Windows/DBDialogWindow.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Windows/DBDialogWindow.xaml
new file mode 100644
index 000000000..83cd48926
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Windows/DBDialogWindow.xaml
@@ -0,0 +1,32 @@
+<mahapps:MetroWindow x:Class="Tango.MachineStudio.DB.Windows.DBDialogWindow"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls"
+ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
+ xmlns:local="clr-namespace:Tango.MachineStudio.DB.Windows"
+ mc:Ignorable="d"
+ Title="Machine Studio" Height="450" Width="650" EnableDWMDropShadow="True" ShowCloseButton="False" WindowTransitionsEnabled="False" ShowMaxRestoreButton="False" ShowMinButton="False" TitleCaps="False" BorderThickness="1" WindowStartupLocation="CenterOwner">
+ <Grid>
+ <Border Margin="16">
+ <DockPanel LastChildFill="True">
+ <StackPanel Orientation="Horizontal" DockPanel.Dock="Top" VerticalAlignment="Top">
+ <materialDesign:PackIcon Kind="{Binding RelativeSource={RelativeSource AncestorType=Window},Path=IconKind}" VerticalAlignment="Center" Width="32" Height="32" Foreground="{StaticResource AccentColorBrush}" />
+ <TextBlock Margin="10 0 0 0" Foreground="{StaticResource AccentColorBrush}" FontSize="16" Text="{Binding RelativeSource={RelativeSource AncestorType=Window},Path=InnerTitle}"></TextBlock>
+ </StackPanel>
+ <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Right" DockPanel.Dock="Bottom">
+ <Button Style="{StaticResource MaterialDesignFlatButton}" IsDefault="True" Margin="0 8 8 0" Command="{Binding DialogOKCommand}" Click="OnOKClicked">
+ ACCEPT
+ </Button>
+ <Button Style="{StaticResource MaterialDesignFlatButton}" IsCancel="True" Margin="0 8 8 0" Command="{Binding DialogCancelCommand}" Click="OnCancelClicked">
+ CANCEL
+ </Button>
+ </StackPanel>
+ <ScrollViewer Margin="0 10 0 10" VerticalScrollBarVisibility="Auto" Padding="5">
+ <ContentPresenter x:Name="presenter"></ContentPresenter>
+ </ScrollViewer>
+ </DockPanel>
+ </Border>
+ </Grid>
+</mahapps:MetroWindow>
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Windows/DBDialogWindow.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Windows/DBDialogWindow.xaml.cs
new file mode 100644
index 000000000..d9629c642
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Windows/DBDialogWindow.xaml.cs
@@ -0,0 +1,68 @@
+using MahApps.Metro.Controls;
+using MaterialDesignThemes.Wpf;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+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.Shapes;
+namespace Tango.MachineStudio.DB.Windows
+{
+ /// <summary>
+ /// Interaction logic for DBDialogWindow.xaml
+ /// </summary>
+ public partial class DBDialogWindow : MetroWindow
+ {
+ public DBDialogWindow()
+ {
+ InitializeComponent();
+ }
+
+ public String InnerTitle
+ {
+ get { return (String)GetValue(InnerTitleProperty); }
+ set { SetValue(InnerTitleProperty, value); }
+ }
+ public static readonly DependencyProperty InnerTitleProperty =
+ DependencyProperty.Register("InnerTitle", typeof(String), typeof(DBDialogWindow), new PropertyMetadata(null));
+
+
+
+ public PackIconKind IconKind
+ {
+ get { return (PackIconKind)GetValue(IconKindProperty); }
+ set { SetValue(IconKindProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for IconKind. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty IconKindProperty =
+ DependencyProperty.Register("IconKind", typeof(PackIconKind), typeof(DBDialogWindow), new PropertyMetadata(PackIconKind.TableEdit));
+
+
+
+
+ public DBDialogWindow(FrameworkElement content) : this()
+ {
+ presenter.Content = content;
+ }
+
+ private void OnOKClicked(object sender, RoutedEventArgs e)
+ {
+ DialogResult = true;
+ Close();
+ }
+
+ private void OnCancelClicked(object sender, RoutedEventArgs e)
+ {
+ DialogResult = false;
+ Close();
+ }
+ }
+}