diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-03-14 17:48:33 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-03-14 17:48:33 +0200 |
| commit | 748d18fe3bfa60a586de151c3bb0d1fd608b1e13 (patch) | |
| tree | 27748a339a8e4e5572a6503cc08324f49aa120b7 /Software/Visual_Studio/MachineStudio/Modules | |
| parent | 1ebb6a67c93969f3d3822893d4e191d14f8fd3e3 (diff) | |
| download | Tango-748d18fe3bfa60a586de151c3bb0d1fd608b1e13.tar.gz Tango-748d18fe3bfa60a586de151c3bb0d1fd608b1e13.zip | |
Working on machine events !!!
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules')
10 files changed, 188 insertions, 2 deletions
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 cefaac6f3..8eabcc605 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 @@ -106,6 +106,7 @@ <Compile Include="ViewModels\CctsViewVM.cs" /> <Compile Include="ViewModels\ConfigurationsViewVM.cs" /> <Compile Include="ViewModels\ContactsViewVM.cs" /> + <Compile Include="ViewModels\EventTypesGroupsViewVM.cs" /> <Compile Include="ViewModels\HardwareDancerTypesViewVM.cs" /> <Compile Include="ViewModels\DbTableViewModel.cs" /> <Compile Include="ViewModels\DialogOpenMode.cs" /> @@ -147,6 +148,12 @@ <Compile Include="Views\DBViews\ActionTypeView.xaml.cs"> <DependentUpon>ActionTypeView.xaml</DependentUpon> </Compile> + <Compile Include="Views\DBViews\EventTypesGroupsView.xaml.cs"> + <DependentUpon>EventTypesGroupsView.xaml</DependentUpon> + </Compile> + <Compile Include="Views\DBViews\EventTypesGroupView.xaml.cs"> + <DependentUpon>EventTypesGroupView.xaml</DependentUpon> + </Compile> <Compile Include="Views\DBViews\HardwarePidControlTypesView.xaml.cs"> <DependentUpon>HardwarePidControlTypesView.xaml</DependentUpon> </Compile> @@ -407,6 +414,14 @@ <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </Page> + <Page Include="Views\DBViews\EventTypesGroupsView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> + <Page Include="Views\DBViews\EventTypesGroupView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> <Page Include="Views\DBViews\HardwarePidControlTypesView.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs index feb9b7de5..da2bdf631 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs @@ -66,6 +66,8 @@ namespace Tango.MachineStudio.DB SimpleIoc.Default.Register<HardwareMotorTypesViewVM>(); SimpleIoc.Default.Register<HardwareDancerTypesViewVM>(); SimpleIoc.Default.Register<HardwarePidControlTypesViewVM>(); + + SimpleIoc.Default.Register<EventTypesGroupsViewVM>(); } public static MainViewVM MainViewVM @@ -395,5 +397,13 @@ namespace Tango.MachineStudio.DB return ServiceLocator.Current.GetInstance<HardwarePidControlTypesViewVM>(); } } + + public static EventTypesGroupsViewVM EventTypesGroupsViewVM + { + get + { + return ServiceLocator.Current.GetInstance<EventTypesGroupsViewVM>(); + } + } } }
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs index 71e9fad18..de6772bf8 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs @@ -180,7 +180,6 @@ namespace Tango.MachineStudio.DB.ViewModels ValidationErrors.Clear(); DialogOpenMode = DialogOpenMode.Editing; EditEntity = GetEditableEntity(DialogOpenMode); - //_notification.ShowDialog(DialogOpenMode, this); Messenger.Default.Send(new OpenEntityEditViewMessage(DialogOpenMode, this, typeof(T))); IsDialogOpen = true; } @@ -193,7 +192,18 @@ namespace Tango.MachineStudio.DB.ViewModels ValidationErrors.Clear(); DialogOpenMode = DialogOpenMode.Adding; EditEntity = GetEditableEntity(DialogOpenMode); - //_notification.ShowDialog(DialogOpenMode, this); + + var codeProp = EditEntity.GetType().GetProperty("Code"); + + if (codeProp != null) + { + if (EditEntity.GetDbSet<T>(Adapter.Context).Count() > 0) + { + int lastCode = EditEntity.GetDbSet<T>(Adapter.Context).ToList().Max(x => (int)codeProp.GetValue(x)); + codeProp.SetValue(EditEntity, lastCode + 1); + } + } + Messenger.Default.Send(new OpenEntityEditViewMessage(DialogOpenMode, this, typeof(T))); IsDialogOpen = true; } @@ -208,6 +218,19 @@ namespace Tango.MachineStudio.DB.ViewModels if (ValidationErrors.Count > 0) return; + var codeProp = entity.GetType().GetProperty("Code"); + + if (codeProp != null) + { + int code = (int)codeProp.GetValue(entity); + + if (entity.GetDbSet<T>(Adapter.Context).ToList().Where(x => x.Guid != entity.Guid).Select(x => (int)codeProp.GetValue(x)).Contains(code)) + { + _notification.ShowError("The entity code specified already exists."); + return; + } + } + Messenger.Default.Send(new CloseEntityEditViewMessage()); if (mode == DialogOpenMode.Editing) diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/EventTypesGroupsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/EventTypesGroupsViewVM.cs new file mode 100644 index 000000000..abdb00e32 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/EventTypesGroupsViewVM.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.MachineStudio.Common.Notifications; + +namespace Tango.MachineStudio.DB.ViewModels +{ + public class EventTypesGroupsViewVM : DbTableViewModel<EventTypesGroup> + { + public EventTypesGroupsViewVM(INotificationProvider notification) : base(notification) + { + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypeView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypeView.xaml index 4bbc741f0..6e804ef3c 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypeView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypeView.xaml @@ -29,6 +29,10 @@ <TextBox Text="{Binding EditEntity.Name,Mode=TwoWay}"></TextBox> <TextBlock Text="Description:" FontWeight="Bold"></TextBlock> <TextBox Text="{Binding EditEntity.Description,Mode=TwoWay}"></TextBox> + <TextBlock Text="Category:" FontWeight="Bold"></TextBlock> + <ComboBox ItemsSource="{Binding Adapter.EventTypesCategories}" SelectedItem="{Binding EditEntity.EventTypesCategory,Mode=TwoWay}" DisplayMemberPath="Name"></ComboBox> + <TextBlock Text="Group:" FontWeight="Bold"></TextBlock> + <ComboBox ItemsSource="{Binding Adapter.EventTypesGroups}" SelectedItem="{Binding EditEntity.EventTypesGroup,Mode=TwoWay}" DisplayMemberPath="Name"></ComboBox> <TextBlock Text="Actions:" FontWeight="Bold"></TextBlock> <ComboBox x:Name="comboActions" SelectionChanged="comboRoles_SelectionChanged" ItemsSource="{Binding SelectedActions}" materialDesign:HintAssist.Hint="{Binding SelectedActions,Converter={StaticResource EventTypeActionsToStringConverter},UpdateSourceTrigger=PropertyChanged}"> <ComboBox.ItemTemplate> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypesGroupView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypesGroupView.xaml new file mode 100644 index 000000000..8f8ec1eae --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypesGroupView.xaml @@ -0,0 +1,31 @@ +<UserControl x:Class="Tango.MachineStudio.DB.Views.DBViews.EventTypesGroupView" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:controls="clr-namespace:Tango.MachineStudio.DB.Controls" + xmlns:converters="clr-namespace:Tango.MachineStudio.DB.Converters" + xmlns:local="clr-namespace:Tango.MachineStudio.DB.Views.DBViews" + mc:Ignorable="d" + d:DesignHeight="300" d:DesignWidth="300"> + + + <Grid> + <controls:TableGrid> + <TextBlock Text="ID:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.ID}" IsReadOnly="True" IsEnabled="False"></TextBox> + <TextBlock Text="GUID:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.Guid}" IsReadOnly="True" IsEnabled="False"></TextBox> + <TextBlock Text="Last Updated:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.LastUpdated}" IsReadOnly="True" IsEnabled="False"></TextBox> + <TextBlock Text="Code:" FontWeight="Bold"></TextBlock> + <mahapps:NumericUpDown Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Left" Value="{Binding EditEntity.Code,Mode=TwoWay}"></mahapps:NumericUpDown> + <TextBlock Text="Name:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.Name,Mode=TwoWay}"></TextBox> + <TextBlock Text="Description:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.Description,Mode=TwoWay}"></TextBox> + </controls:TableGrid> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypesGroupView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypesGroupView.xaml.cs new file mode 100644 index 000000000..e164fa171 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypesGroupView.xaml.cs @@ -0,0 +1,28 @@ +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.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// <summary> + /// Interaction logic for UserView.xaml + /// </summary> + public partial class EventTypesGroupView : UserControl + { + public EventTypesGroupView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypesGroupsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypesGroupsView.xaml new file mode 100644 index 000000000..e6dff7f8a --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypesGroupsView.xaml @@ -0,0 +1,26 @@ +<UserControl x:Class="Tango.MachineStudio.DB.Views.DBViews.EventTypesGroupsView" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:controls="clr-namespace:Tango.MachineStudio.DB.Controls" + xmlns:global="clr-namespace:Tango.MachineStudio.DB" + xmlns:converters="clr-namespace:Tango.MachineStudio.DB.Converters" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:local="clr-namespace:Tango.MachineStudio.DB.Views.DBViews" + mc:Ignorable="d" + d:DesignHeight="720" d:DesignWidth="1280" Background="White" DataContext="{x:Static global:ViewModelLocator.EventTypesGroupsViewVM}"> + + <Grid> + <controls:DbTableView> + <DataGrid Background="Transparent" ItemsSource="{Binding Adapter.EventTypesGroupsViewSource}" SelectedItem="{Binding SelectedEntity}" AutoGenerateColumns="False" IsReadOnly="True"> + <DataGrid.Columns> + <DataGridTextColumn Header="ID" Binding="{Binding ID}"></DataGridTextColumn> + <DataGridTextColumn Header="GUID" Binding="{Binding Guid}"></DataGridTextColumn> + <DataGridTextColumn Header="Code" Binding="{Binding Code}"></DataGridTextColumn> + <DataGridTextColumn Header="Name" Binding="{Binding Name}"></DataGridTextColumn> + <DataGridTextColumn Header="Description" Binding="{Binding Description}"></DataGridTextColumn> + </DataGrid.Columns> + </DataGrid> + </controls:DbTableView> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypesGroupsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypesGroupsView.xaml.cs new file mode 100644 index 000000000..c11aeccc4 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypesGroupsView.xaml.cs @@ -0,0 +1,30 @@ +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.Navigation; +using System.Windows.Shapes; +using Tango.MachineStudio.DB.CustomAttributes; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// <summary> + /// Interaction logic for UsersView.xaml + /// </summary> + [DBView] + public partial class EventTypesGroupsView : UserControl + { + public EventTypesGroupsView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypesView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypesView.xaml index bb8f6e514..701fa3f77 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypesView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypesView.xaml @@ -23,6 +23,8 @@ <DataGridTextColumn Header="Code" Binding="{Binding Code}"></DataGridTextColumn> <DataGridTextColumn Header="Name" Binding="{Binding Name}"></DataGridTextColumn> <DataGridTextColumn Header="Description" Binding="{Binding Description}"></DataGridTextColumn> + <DataGridTextColumn Header="Category" Binding="{Binding EventTypesCategory.Name}"></DataGridTextColumn> + <DataGridTextColumn Header="Group" Binding="{Binding EventTypesGroup.Name}"></DataGridTextColumn> <DataGridTextColumn Header="Actions" Binding="{Binding EventTypesActions,Converter={StaticResource EventTypeActionsToStringConverter}}"></DataGridTextColumn> </DataGrid.Columns> </DataGrid> |
