diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2017-12-14 19:48:41 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2017-12-14 19:48:41 +0200 |
| commit | ad35c9c2df0001157ea13312382f3cdfdad67f06 (patch) | |
| tree | 78c4708893f6207ff692f729ac43408823f963e1 /Software/Visual_Studio | |
| parent | 7887ca0ad2433c4adbb65d96bf926561405ab290 (diff) | |
| download | Tango-ad35c9c2df0001157ea13312382f3cdfdad67f06.tar.gz Tango-ad35c9c2df0001157ea13312382f3cdfdad67f06.zip | |
Implemented IAuthenticationProvider, INavigationProvider, IModuleLoader.
LoadingView,
LoginView,
Diffstat (limited to 'Software/Visual_Studio')
38 files changed, 760 insertions, 39 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/DBModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/DBModule.cs index dbc560b8e..b1a268a9b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/DBModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/DBModule.cs @@ -5,6 +5,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Media.Imaging; +using Tango.DAL.Observables; using Tango.MachineStudio.Common; using Tango.MachineStudio.DB.Views; @@ -24,6 +25,8 @@ namespace Tango.MachineStudio.DB public bool IsInitialized => _isInitialized; + public PermissionsEnum Permission => PermissionsEnum.RunDataBaseModule; + public void Dispose() { throw new NotImplementedException(); 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 4831e838f..712a99953 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 @@ -49,6 +49,9 @@ <Reference Include="GalaSoft.MvvmLight.Platform, Version=5.3.0.19032, Culture=neutral, PublicKeyToken=5f873c45e98af8a1, processorArchitecture=MSIL"> <HintPath>..\..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Platform.dll</HintPath> </Reference> + <Reference Include="MahApps.Metro, Version=1.5.0.23, Culture=neutral, PublicKeyToken=f4fb5a3c4d1e5b4f, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\MahApps.Metro.1.5.0\lib\net45\MahApps.Metro.dll</HintPath> + </Reference> <Reference Include="MaterialDesignColors, Version=1.1.2.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\..\..\packages\MaterialDesignColors.1.1.2\lib\net45\MaterialDesignColors.dll</HintPath> </Reference> @@ -62,7 +65,7 @@ <Reference Include="System.ComponentModel.DataAnnotations" /> <Reference Include="System.Data" /> <Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> - <HintPath>..\..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\System.Windows.Interactivity.dll</HintPath> + <HintPath>..\..\..\packages\MahApps.Metro.1.5.0\lib\net45\System.Windows.Interactivity.dll</HintPath> </Reference> <Reference Include="System.Xml" /> <Reference Include="Microsoft.CSharp" /> @@ -87,11 +90,18 @@ <Compile Include="ViewModels\MachinesViewVM.cs" /> <Compile Include="ViewModels\MultiComboVM.cs" /> <Compile Include="ViewModels\OrganizationsViewVM.cs" /> + <Compile Include="ViewModels\PermissionsViewVM.cs" /> <Compile Include="ViewModels\RolesViewVM.cs" /> <Compile Include="ViewModels\UsersViewVM.cs" /> <Compile Include="ViewModels\EntityViewModel.cs" /> <Compile Include="ViewModels\MainViewVM.cs" /> <Compile Include="ViewModelLocator.cs" /> + <Compile Include="Views\DBViews\PermissionView.xaml.cs"> + <DependentUpon>PermissionView.xaml</DependentUpon> + </Compile> + <Compile Include="Views\DBViews\PermissionsView.xaml.cs"> + <DependentUpon>PermissionsView.xaml</DependentUpon> + </Compile> <Compile Include="Views\DBViews\RoleView.xaml.cs"> <DependentUpon>RoleView.xaml</DependentUpon> </Compile> @@ -140,6 +150,14 @@ <Compile Include="CustomAttributes\DBViewAttribute.cs" /> <Compile Include="Managers\RegisteredView.cs" /> <Compile Include="Managers\ViewsManager.cs" /> + <Page Include="Views\DBViews\PermissionView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> + <Page Include="Views\DBViews\PermissionsView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> <Page Include="Views\DBViews\RoleView.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 70e9d672f..c5f3f452e 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs @@ -23,6 +23,7 @@ namespace Tango.MachineStudio.DB SimpleIoc.Default.Register<AddressesViewVM>(); SimpleIoc.Default.Register<UsersViewVM>(); SimpleIoc.Default.Register<RolesViewVM>(); + SimpleIoc.Default.Register<PermissionsViewVM>(); } public static MainViewVM MainViewVM @@ -72,5 +73,13 @@ namespace Tango.MachineStudio.DB return ServiceLocator.Current.GetInstance<RolesViewVM>(); } } + + public static PermissionsViewVM PermissionsViewVM + { + get + { + return ServiceLocator.Current.GetInstance<PermissionsViewVM>(); + } + } } }
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/PermissionsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/PermissionsViewVM.cs new file mode 100644 index 000000000..9a2d1c24d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/PermissionsViewVM.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DAL.Observables; +using Tango.MachineStudio.Common.Notifications; + +namespace Tango.MachineStudio.DB.ViewModels +{ + public class PermissionsViewVM : DbTableViewModel<Permission> + { + public PermissionsViewVM(INotificationProvider notification) : base(notification) + { + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PermissionView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PermissionView.xaml new file mode 100644 index 000000000..98e1e086d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PermissionView.xaml @@ -0,0 +1,27 @@ +<UserControl x:Class="Tango.MachineStudio.DB.Views.DBViews.PermissionView" + 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:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:controls="clr-namespace:Tango.MachineStudio.DB.Controls" + 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"></TextBox> + <TextBlock Text="GUID:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.Guid}" IsReadOnly="True"></TextBox> + <TextBlock Text="Last Updated:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.LastUpdated}" IsReadOnly="True"></TextBox> + <TextBlock Text="Code:" FontWeight="Bold"></TextBlock> + <mahapps:NumericUpDown Minimum="0" Maximum="1000" 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/PermissionView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PermissionView.xaml.cs new file mode 100644 index 000000000..4d5eaf3a7 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PermissionView.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 AddressView.xaml + /// </summary> + public partial class PermissionView : UserControl + { + public PermissionView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PermissionsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PermissionsView.xaml new file mode 100644 index 000000000..d773dc58a --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PermissionsView.xaml @@ -0,0 +1,24 @@ +<UserControl x:Class="Tango.MachineStudio.DB.Views.DBViews.PermissionsView" + 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:global="clr-namespace:Tango.MachineStudio.DB" + xmlns:controls="clr-namespace:Tango.MachineStudio.DB.Controls" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + mc:Ignorable="d" + d:DesignHeight="720" d:DesignWidth="1280" Background="White" DataContext="{x:Static global:ViewModelLocator.PermissionsViewVM}"> + <Grid> + <controls:DbTableView> + <DataGrid Background="Transparent" ItemsSource="{Binding Adapter.Permissions}" 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/PermissionsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PermissionsView.xaml.cs new file mode 100644 index 000000000..dc19c1d58 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/PermissionsView.xaml.cs @@ -0,0 +1,31 @@ +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; +using Tango.SharedUI.Controls; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// <summary> + /// Interaction logic for MachinesView.xaml + /// </summary> + [DBView] + public partial class PermissionsView : UserControl + { + public PermissionsView() : base() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RoleView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RoleView.xaml index d23e9c7b2..e88277e11 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RoleView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RoleView.xaml @@ -4,6 +4,7 @@ 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" @@ -23,7 +24,7 @@ <TextBlock Text="Last Updated:" FontWeight="Bold"></TextBlock> <TextBox Text="{Binding EditEntity.LastUpdated}" IsReadOnly="True"></TextBox> <TextBlock Text="Code:" FontWeight="Bold"></TextBlock> - <TextBox Text="{Binding EditEntity.Code,Mode=TwoWay}"></TextBox> + <mahapps:NumericUpDown Minimum="0" Maximum="1000" 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> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/packages.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/packages.config index ccf9158d8..ab8c25d56 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/packages.config +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/packages.config @@ -3,6 +3,7 @@ <package id="CommonServiceLocator" version="1.3" targetFramework="net46" /> <package id="Dragablz" version="0.0.3.197" targetFramework="net46" /> <package id="EntityFramework" version="6.0.0" targetFramework="net46" /> + <package id="MahApps.Metro" version="1.5.0" targetFramework="net46" /> <package id="MaterialDesignColors" version="1.1.2" targetFramework="net46" /> <package id="MaterialDesignThemes" version="2.3.1.953" targetFramework="net46" /> <package id="MvvmLight" version="5.3.0.0" targetFramework="net46" /> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModule.cs index aefe9b62d..3d55849f8 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModule.cs @@ -5,6 +5,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Media.Imaging; +using Tango.DAL.Observables; using Tango.MachineStudio.Common; using Tango.MachineStudio.Developer.Views; using Tango.SharedUI.Helpers; @@ -25,6 +26,8 @@ namespace Tango.MachineStudio.Developer public bool IsInitialized => _isInitialized; + public PermissionsEnum Permission => PermissionsEnum.RunDeveloperModule; + public void Dispose() { throw new NotImplementedException(); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj index 1ae7b2baa..269720012 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj @@ -95,6 +95,10 @@ <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> <Name>Tango.Core</Name> </ProjectReference> + <ProjectReference Include="..\..\..\Tango.DAL.Observables\Tango.DAL.Observables.csproj"> + <Project>{0ecd6da8-7aa6-48d9-8b65-279d176ad9af}</Project> + <Name>Tango.DAL.Observables</Name> + </ProjectReference> <ProjectReference Include="..\..\..\Tango.SharedUI\Tango.SharedUI.csproj"> <Project>{8491d07b-c1f6-4b62-a412-41b9fd2d6538}</Project> <Name>Tango.SharedUI</Name> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/IAuthenticationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/IAuthenticationProvider.cs new file mode 100644 index 000000000..488a2f6dc --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/IAuthenticationProvider.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DAL.Observables; + +namespace Tango.MachineStudio.Common.Authentication +{ + public interface IAuthenticationProvider + { + event EventHandler<User> CurrentUserChanged; + + User CurrentUser { get; } + + User Login(String email, String password); + + void Logout(); + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/ExtensionMethods/UserExtensions.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/ExtensionMethods/UserExtensions.cs new file mode 100644 index 000000000..a11ee7e8a --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/ExtensionMethods/UserExtensions.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DAL.Observables; + +public static class UserExtensions +{ + public static bool HasPermission(this User user, PermissionsEnum permission) + { + return user.UsersRoles.Select(x => x.Role).ToList().SelectMany(x => x.RolesPermissions).ToList().Exists(x => x.Permission.Code == permission.ToInt32()); + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/IStudioModule.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/IStudioModule.cs index f75a60002..36c885340 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/IStudioModule.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/IStudioModule.cs @@ -5,6 +5,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Media.Imaging; +using Tango.DAL.Observables; namespace Tango.MachineStudio.Common { @@ -18,6 +19,8 @@ namespace Tango.MachineStudio.Common FrameworkElement MainView { get; } + PermissionsEnum Permission { get; } + bool IsInitialized { get; } void Initialize(); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Modules/IStudioModuleLoader.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Modules/IStudioModuleLoader.cs new file mode 100644 index 000000000..d67accbc1 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Modules/IStudioModuleLoader.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.Common.Modules +{ + public interface IStudioModuleLoader + { + ObservableCollection<IStudioModule> AllModules { get; } + + ObservableCollection<IStudioModule> UserModules { get; } + + void LoadModules(); + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationManager.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationManager.cs new file mode 100644 index 000000000..631f9e2eb --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationManager.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.Common.Navigation +{ + public interface INavigationManager + { + void NavigateTo(NavigationView view); + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/NavigationView.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/NavigationView.cs new file mode 100644 index 000000000..77dbaf5b4 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/NavigationView.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.Common.Navigation +{ + public enum NavigationView + { + LoadingView, + MainView, + LoginView, + ShutdownView, + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj index 28c2ba817..c94e6fbdc 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj @@ -60,12 +60,17 @@ <Compile Include="..\..\Versioning\GlobalVersionInfo.cs"> <Link>GlobalVersionInfo.cs</Link> </Compile> + <Compile Include="Authentication\IAuthenticationProvider.cs" /> <Compile Include="Controls\MdiChild.cs" /> <Compile Include="Controls\MdiContainerControl.xaml.cs"> <DependentUpon>MdiContainerControl.xaml</DependentUpon> </Compile> <Compile Include="Converters\PointToMarginConverter.cs" /> + <Compile Include="ExtensionMethods\UserExtensions.cs" /> <Compile Include="IStudioModule.cs" /> + <Compile Include="Modules\IStudioModuleLoader.cs" /> + <Compile Include="Navigation\INavigationManager.cs" /> + <Compile Include="Navigation\NavigationView.cs" /> <Compile Include="Notifications\INotificationProvider.cs" /> </ItemGroup> <ItemGroup> @@ -97,6 +102,14 @@ <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> <Name>Tango.Core</Name> </ProjectReference> + <ProjectReference Include="..\..\Tango.DAL.Observables\Tango.DAL.Observables.csproj"> + <Project>{0ecd6da8-7aa6-48d9-8b65-279d176ad9af}</Project> + <Name>Tango.DAL.Observables</Name> + </ProjectReference> + <ProjectReference Include="..\..\Tango.DAL.Remote\Tango.DAL.Remote.csproj"> + <Project>{38197109-8610-4d3f-92b9-16d48df94d7c}</Project> + <Name>Tango.DAL.Remote</Name> + </ProjectReference> <ProjectReference Include="..\..\Tango.SharedUI\Tango.SharedUI.csproj"> <Project>{8491d07b-c1f6-4b62-a412-41b9fd2d6538}</Project> <Name>Tango.SharedUI</Name> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs new file mode 100644 index 000000000..a30cf0f92 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Authentication; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; +using Tango.DAL.Observables; +using Tango.MachineStudio.Common.Authentication; + +namespace Tango.MachineStudio.UI.Authentication +{ + public class DefaultAuthenticationProvider : ExtendedObject, IAuthenticationProvider + { + private User _currentUser; + + public User CurrentUser + { + get { return _currentUser; } + set + { + _currentUser = value; + CurrentUserChanged?.Invoke(this, _currentUser); + RaisePropertyChangedAuto(); + } + } + + public event EventHandler<User> CurrentUserChanged; + + public User Login(string email, string password) + { + User user = ObservablesEntitiesAdapter.Instance.Users.SingleOrDefault(x => x.Email.ToLower() == email.ToLower() && x.Password == password); + + if (user == null) + { + throw new AuthenticationException("Login failed for user " + email); + } + + CurrentUser = user; + return user; + } + + public void Logout() + { + CurrentUser = null; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/MainWindow.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/MainWindow.xaml index a425345dc..963b9eb8b 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/MainWindow.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/MainWindow.xaml @@ -6,13 +6,29 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:Tango.MachineStudio.UI" xmlns:views="clr-namespace:Tango.MachineStudio.UI.Views" + xmlns:sharedControls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" mc:Ignorable="d" Title="Tango" Height="720" Width="1280" WindowStartupLocation="CenterOwner" WindowState="Maximized"> <Grid> - <views:MainView></views:MainView> + <sharedControls:MultiTransitionControl AlwaysFade="True" TransitionType="Zoom" x:Name="TransitionControl" x:FieldModifier="public"> + <sharedControls:MultiTransitionControl.Controls> + <ContentControl Tag="LoadingView"> + <views:LoadingView></views:LoadingView> + </ContentControl> + <ContentControl Tag="LoginView"> + <views:LoginView></views:LoginView> + </ContentControl> + <ContentControl Tag="MainView"> + <views:MainView></views:MainView> + </ContentControl> + <ContentControl Tag="ShutdownView"> + <views:ShutdownView></views:ShutdownView> + </ContentControl> + </sharedControls:MultiTransitionControl.Controls> + </sharedControls:MultiTransitionControl> <Grid Background="Black" Opacity="0.7" x:Name="shadowGrid" Visibility="Hidden"> - + </Grid> </Grid> </mahapps:MetroWindow> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs new file mode 100644 index 000000000..689ac7b38 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; +using Tango.MachineStudio.Common; +using Tango.MachineStudio.Common.Authentication; +using Tango.MachineStudio.Common.Modules; + +namespace Tango.MachineStudio.UI.Modules +{ + public class DefaultStudioModuleLoader : ExtendedObject, IStudioModuleLoader + { + private IAuthenticationProvider _authenticationProvider; + private bool _loaded; + + public DefaultStudioModuleLoader(IAuthenticationProvider authenticationProvider) + { + _authenticationProvider = authenticationProvider; + AllModules = new ObservableCollection<IStudioModule>(); + UserModules = new ObservableCollection<IStudioModule>(); + _authenticationProvider.CurrentUserChanged += _authenticationProvider_CurrentUserChanged; + } + + private void _authenticationProvider_CurrentUserChanged(object sender, DAL.Observables.User e) + { + LoadModules(); + } + + private ObservableCollection<IStudioModule> _allModules; + public ObservableCollection<IStudioModule> AllModules + { + get { return _allModules; } + private set { _allModules = value; RaisePropertyChangedAuto(); } + } + + private ObservableCollection<IStudioModule> _userModules; + public ObservableCollection<IStudioModule> UserModules + { + get { return _userModules; } + private set { _userModules = value; RaisePropertyChangedAuto(); } + } + + public void LoadModules() + { + if (!_loaded) + { + AllModules.Clear(); + string assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + + foreach (var file in Directory.GetFiles(assemblyFolder, "*.dll").Where(x => x.Contains("MachineStudio"))) + { + try + { + Assembly moduleAssembly = null; + moduleAssembly = Assembly.LoadFrom(file); + + if (moduleAssembly != null) + { + foreach (var moduleType in moduleAssembly.GetTypes().Where(x => !x.IsInterface && typeof(IStudioModule).IsAssignableFrom(x))) + { + var module = Activator.CreateInstance(moduleType) as IStudioModule; + AllModules.Add(module); + } + } + } + catch { } + } + + _loaded = true; + } + + UserModules.Clear(); + + if (_authenticationProvider.CurrentUser != null) + { + UserModules = AllModules.Where(x => _authenticationProvider.CurrentUser.HasPermission(x.Permission)).ToObservableCollection(); + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Navigation/DefaultNavigationManager.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Navigation/DefaultNavigationManager.cs new file mode 100644 index 000000000..10314ae62 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Navigation/DefaultNavigationManager.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.MachineStudio.Common.Navigation; + +namespace Tango.MachineStudio.UI.Navigation +{ + public class DefaultNavigationManager : INavigationManager + { + public void NavigateTo(NavigationView view) + { + MainWindow.Instance.TransitionControl.AutoNavigate(view.ToString()); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj index 6c008797f..9d2860241 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj @@ -96,16 +96,31 @@ <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </ApplicationDefinition> + <Compile Include="Authentication\DefaultAuthenticationProvider.cs" /> + <Compile Include="Modules\DefaultStudioModuleLoader.cs" /> + <Compile Include="Navigation\DefaultNavigationManager.cs" /> <Compile Include="Notifications\DefaultNotificationProvider.cs" /> <Compile Include="SupervisingController\IMainView.cs" /> + <Compile Include="ViewModels\LoadingViewVM.cs" /> + <Compile Include="ViewModels\LoginViewVM.cs" /> <Compile Include="ViewModels\MainViewVM.cs" /> <Compile Include="ViewModelLocator.cs" /> + <Compile Include="ViewModels\ShutdownViewVM.cs" /> + <Compile Include="Views\LoadingView.xaml.cs"> + <DependentUpon>LoadingView.xaml</DependentUpon> + </Compile> + <Compile Include="Views\LoginView.xaml.cs"> + <DependentUpon>LoginView.xaml</DependentUpon> + </Compile> <Compile Include="Views\MainView.xaml.cs"> <DependentUpon>MainView.xaml</DependentUpon> </Compile> <Compile Include="Notifications\DialogWindow.xaml.cs"> <DependentUpon>DialogWindow.xaml</DependentUpon> </Compile> + <Compile Include="Views\ShutdownView.xaml.cs"> + <DependentUpon>ShutdownView.xaml</DependentUpon> + </Compile> <Page Include="MainWindow.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> @@ -125,6 +140,14 @@ <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </Page> + <Page Include="Views\LoadingView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> + <Page Include="Views\LoginView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="Views\MainView.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -133,6 +156,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Views\ShutdownView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> </ItemGroup> <ItemGroup> <Compile Include="Properties\AssemblyInfo.cs"> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs index 1f08e31ca..5095dfc93 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs @@ -3,7 +3,13 @@ using GalaSoft.MvvmLight.Ioc; using Microsoft.Practices.ServiceLocation; using System; using Tango.Logging; +using Tango.MachineStudio.Common.Authentication; +using Tango.MachineStudio.Common.Modules; +using Tango.MachineStudio.Common.Navigation; using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.UI.Authentication; +using Tango.MachineStudio.UI.Modules; +using Tango.MachineStudio.UI.Navigation; using Tango.MachineStudio.UI.Notifications; using Tango.MachineStudio.UI.SupervisingController; using Tango.MachineStudio.UI.ViewModels; @@ -35,9 +41,20 @@ namespace Tango.MachineStudio.UI //// SimpleIoc.Default.Register<IDataService, DataService>(); ////} - SimpleIoc.Default.Register<INotificationProvider>(() => new DefaultNotificationProvider()); + SimpleIoc.Default.Unregister<INotificationProvider>(); + SimpleIoc.Default.Unregister<IAuthenticationProvider>(); + SimpleIoc.Default.Unregister<INavigationManager>(); + SimpleIoc.Default.Unregister<IStudioModuleLoader>(); + + SimpleIoc.Default.Register<INotificationProvider, DefaultNotificationProvider>(); + SimpleIoc.Default.Register<IAuthenticationProvider, DefaultAuthenticationProvider>(); + SimpleIoc.Default.Register<INavigationManager, DefaultNavigationManager>(); + SimpleIoc.Default.Register<IStudioModuleLoader, DefaultStudioModuleLoader>(); SimpleIoc.Default.Register<MainViewVM>(); + SimpleIoc.Default.Register<LoadingViewVM>(); + SimpleIoc.Default.Register<ShutdownViewVM>(); + SimpleIoc.Default.Register<LoginViewVM>(); //Register View (Supervising Controller Pattern). if (!ViewModelBase.IsInDesignModeStatic) @@ -54,5 +71,29 @@ namespace Tango.MachineStudio.UI return ServiceLocator.Current.GetInstance<MainViewVM>(); } } + + public LoadingViewVM LoadingViewVM + { + get + { + return ServiceLocator.Current.GetInstance<LoadingViewVM>(); + } + } + + public ShutdownViewVM ShutdownViewVM + { + get + { + return ServiceLocator.Current.GetInstance<ShutdownViewVM>(); + } + } + + public LoginViewVM LoginViewVM + { + get + { + return ServiceLocator.Current.GetInstance<LoginViewVM>(); + } + } } }
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs new file mode 100644 index 000000000..72ab5aca9 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Tango.MachineStudio.Common.Modules; +using Tango.MachineStudio.Common.Navigation; +using Tango.SharedUI; + +namespace Tango.MachineStudio.UI.ViewModels +{ + public class LoadingViewVM : ViewModel + { + public LoadingViewVM(INavigationManager navigationManager, IStudioModuleLoader studioModuleLoader) + { + Task.Factory.StartNew(() => + { + Thread.Sleep(3000); + }).ContinueWith((x) => + { + + studioModuleLoader.LoadModules(); + navigationManager.NavigateTo(NavigationView.LoginView); + + }, TaskScheduler.FromCurrentSynchronizationContext()); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs new file mode 100644 index 000000000..67c116790 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using Tango.Core.Commands; +using Tango.MachineStudio.Common.Authentication; +using Tango.MachineStudio.Common.Navigation; +using Tango.SharedUI; + +namespace Tango.MachineStudio.UI.ViewModels +{ + public class LoginViewVM : ViewModel + { + private IAuthenticationProvider _authenticationProvider; + private INavigationManager _navigationManager; + + private String _email; + public String Email + { + get { return _email; } + set { _email = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand<PasswordBox> LoginCommand { get; set; } + + public LoginViewVM(IAuthenticationProvider authenticationProvider, INavigationManager navigationManager) + { + _navigationManager = navigationManager; + _authenticationProvider = authenticationProvider; + LoginCommand = new RelayCommand<PasswordBox>(Login); + } + + private void Login(PasswordBox passwordBox) + { + String password = passwordBox.Password; + try + { + _authenticationProvider.Login(Email, password); + _navigationManager.NavigateTo(NavigationView.MainView); + } + catch (Exception ex) + { + MessageBox.Show("Failed"); + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs index e0aff5be3..213d1a83d 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -8,6 +8,8 @@ using System.Text; using System.Threading.Tasks; using Tango.Core.Commands; using Tango.MachineStudio.Common; +using Tango.MachineStudio.Common.Authentication; +using Tango.MachineStudio.Common.Modules; using Tango.MachineStudio.UI.SupervisingController; using Tango.SharedUI; @@ -15,8 +17,6 @@ namespace Tango.MachineStudio.UI.ViewModels { public class MainViewVM : ViewModel<IMainView> { - public ObservableCollection<IStudioModule> Modules { get; set; } - private IStudioModule _currentModule; public IStudioModule CurrentModule @@ -37,43 +37,29 @@ namespace Tango.MachineStudio.UI.ViewModels public RelayCommand HomeCommand { get; set; } - public String Text { get; set; } - - public MainViewVM(IMainView view) : base(view) + private IAuthenticationProvider _authenticationProvider; + public IAuthenticationProvider AuthenticationProvider { - Modules = new ObservableCollection<IStudioModule>(); - - LoadModules(); - - Text = "Hi ROy"; + get { return _authenticationProvider; } + set { _authenticationProvider = value; RaisePropertyChangedAuto(); } + } - StartModuleCommand = new RelayCommand<IStudioModule>(StartModule); + private IStudioModuleLoader _studioModuleLoader; - HomeCommand = new RelayCommand(Home); + public IStudioModuleLoader StudioModuleLoader + { + get { return _studioModuleLoader; } + set { _studioModuleLoader = value; RaisePropertyChangedAuto(); } } - private void LoadModules() + public MainViewVM(IMainView view, IAuthenticationProvider authenticationProvider, IStudioModuleLoader studioModuleLoader) : base(view) { - string assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + AuthenticationProvider = authenticationProvider; + StudioModuleLoader = studioModuleLoader; - foreach (var file in Directory.GetFiles(assemblyFolder, "*.dll").Where(x => x.Contains("MachineStudio"))) - { - try - { - Assembly moduleAssembly = null; - moduleAssembly = Assembly.LoadFrom(file); + StartModuleCommand = new RelayCommand<IStudioModule>(StartModule); - if (moduleAssembly != null) - { - foreach (var moduleType in moduleAssembly.GetTypes().Where(x => !x.IsInterface && typeof(IStudioModule).IsAssignableFrom(x))) - { - var module = Activator.CreateInstance(moduleType) as IStudioModule; - Modules.Add(module); - } - } - } - catch { } - } + HomeCommand = new RelayCommand(Home); } private void Home() diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ShutdownViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ShutdownViewVM.cs new file mode 100644 index 000000000..c7a919a82 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ShutdownViewVM.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.UI.ViewModels +{ + public class ShutdownViewVM + { + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoadingView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoadingView.xaml new file mode 100644 index 000000000..ab0875023 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoadingView.xaml @@ -0,0 +1,23 @@ +<UserControl x:Class="Tango.MachineStudio.UI.Views.LoadingView" + 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:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:local="clr-namespace:Tango.MachineStudio.UI.Views" + mc:Ignorable="d" + d:DesignHeight="720" d:DesignWidth="1280" DataContext="{Binding LoadingViewVM, Source={StaticResource Locator}}" Background="White"> + <Grid> + <Grid HorizontalAlignment="Center" VerticalAlignment="Center"> + <StackPanel> + <Image Source="/Images/machine-trans.png" RenderOptions.BitmapScalingMode="Fant" Width="100"></Image> + <StackPanel Orientation="Horizontal"> + <TextBlock FontSize="70" Foreground="{StaticResource AccentColorBrush}">Machine Studio</TextBlock> + </StackPanel> + <TextBlock HorizontalAlignment="Right" FontSize="18" Margin="0 0 -50 0" Foreground="{StaticResource AccentColorBrush}">Twine Solutions</TextBlock> + <mahapps:ProgressRing Margin="20 60 20 20" Width="80" Height="80"></mahapps:ProgressRing> + <TextBlock HorizontalAlignment="Center" FontSize="18" FontStyle="Italic">Loading, please wait...</TextBlock> + </StackPanel> + </Grid> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoadingView.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoadingView.xaml.cs new file mode 100644 index 000000000..15eba3cf8 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoadingView.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.UI.Views +{ + /// <summary> + /// Interaction logic for LoadingView.xaml + /// </summary> + public partial class LoadingView : UserControl + { + public LoadingView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoginView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoginView.xaml new file mode 100644 index 000000000..60590a16b --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoginView.xaml @@ -0,0 +1,18 @@ +<UserControl x:Class="Tango.MachineStudio.UI.Views.LoginView" + 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:local="clr-namespace:Tango.MachineStudio.UI.Views" + mc:Ignorable="d" + d:DesignHeight="720" d:DesignWidth="1280" DataContext="{Binding LoginViewVM, Source={StaticResource Locator}}" Background="White"> + <Grid> + <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Width="300"> + <Image Source="/Images/machine-trans.png" RenderOptions.BitmapScalingMode="Fant" Width="100"></Image> + <TextBox Margin="0 40 0 0" materialDesign:HintAssist.FloatingScale="0.50" materialDesign:HintAssist.Hint="Email" materialDesign:TextFieldAssist.TextBoxViewMargin="1 0 1 0" FontSize="24" Style="{StaticResource MaterialDesignFloatingHintTextBox}" Text="{Binding Email,UpdateSourceTrigger=PropertyChanged}" /> + <PasswordBox x:Name="txtPass" Margin="0 20 0 0" materialDesign:HintAssist.FloatingScale="0.50" materialDesign:HintAssist.Hint="Password" materialDesign:TextFieldAssist.TextBoxViewMargin="1 0 1 0" FontSize="24" Style="{StaticResource MaterialDesignFloatingHintPasswordBox}" /> + <Button Margin="0 40 0 0" Height="50" Command="{Binding LoginCommand}" CommandParameter="{Binding ElementName=txtPass}">LOGIN</Button> + </StackPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoginView.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoginView.xaml.cs new file mode 100644 index 000000000..0b3a9ae4f --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoginView.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.UI.Views +{ + /// <summary> + /// Interaction logic for LoginView.xaml + /// </summary> + public partial class LoginView : UserControl + { + public LoginView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml index ad366ce9a..98b6ecb73 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml @@ -74,7 +74,7 @@ <TextBlock HorizontalAlignment="Right" Margin="0 5 -130 0" FontStyle="Italic" Style="{StaticResource MaterialDesignSubheadingTextBlock}" Foreground="{StaticResource AccentColorBrush}">Select Your Studio Module...</TextBlock> </StackPanel> </Grid> - <ItemsControl ItemsSource="{Binding Modules}" Grid.Row="2" Margin="10"> + <ItemsControl ItemsSource="{Binding StudioModuleLoader.UserModules}" Grid.Row="2" Margin="10"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <WrapPanel IsItemsHost="True"></WrapPanel> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ShutdownView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ShutdownView.xaml new file mode 100644 index 000000000..20329ef25 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ShutdownView.xaml @@ -0,0 +1,12 @@ +<UserControl x:Class="Tango.MachineStudio.UI.Views.ShutdownView" + 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:local="clr-namespace:Tango.MachineStudio.UI.Views" + mc:Ignorable="d" + d:DesignHeight="300" d:DesignWidth="300" DataContext="{Binding ShutdownViewVM, Source={StaticResource Locator}}"> + <Grid> + + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ShutdownView.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ShutdownView.xaml.cs new file mode 100644 index 000000000..e1d49aec0 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ShutdownView.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.UI.Views +{ + /// <summary> + /// Interaction logic for ShutdownView.xaml + /// </summary> + public partial class ShutdownView : UserControl + { + public ShutdownView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/Tango.DAL.Observables/ObservablesEntitiesAdapter.cs b/Software/Visual_Studio/Tango.DAL.Observables/ObservablesEntitiesAdapter.cs index 3434fe368..09a380de1 100644 --- a/Software/Visual_Studio/Tango.DAL.Observables/ObservablesEntitiesAdapter.cs +++ b/Software/Visual_Studio/Tango.DAL.Observables/ObservablesEntitiesAdapter.cs @@ -67,11 +67,21 @@ namespace Tango.DAL.Observables Addresses = Context.ADDRESSES.Where(x => !x.DELETED).ToList().OrderBy(x => x.ADDRESS_STRING).Select(x => ObservableEntity.CreateObservableFromEntity<Address>(x)).ToObservableCollection(); Contacts = Context.CONTACTS.Where(x => !x.DELETED).ToList().OrderBy(x => x.FULL_NAME).Select(x => ObservableEntity.CreateObservableFromEntity<Contact>(x)).ToObservableCollection(); - Users = Context.USERS.Where(x => !x.DELETED).ToList().OrderBy(x => x.CONTACT.FULL_NAME).Select(x => ObservableEntity.CreateObservableFromEntity<User>(x)).ToObservableCollection(); - Roles = Context.ROLES.Where(x => !x.DELETED).ToList().OrderBy(x => x.NAME).Select(x => ObservableEntity.CreateObservableFromEntity<Role>(x)).ToObservableCollection(); Permissions = Context.PERMISSIONS.Where(x => !x.DELETED).ToList().OrderBy(x => x.NAME).Select(x => ObservableEntity.CreateObservableFromEntity<Permission>(x)).ToObservableCollection(); + + Users = Context.USERS.Where(x => !x.DELETED).ToList().OrderBy(x => x.CONTACT.FULL_NAME).Select(x => ObservableEntity.CreateObservableFromEntity<User>(x)).ToObservableCollection(); + + foreach (var user in Users) + { + user.UsersRoles = user.UsersRoles.Where(x => !x.Deleted).ToObservableCollection(); + } + + foreach (var role in Roles) + { + role.RolesPermissions = role.RolesPermissions.Where(x => !x.Deleted).ToObservableCollection(); + } } private ObservableCollection<Organization> _organizations; diff --git a/Software/Visual_Studio/Web/Tango.MachineService/App_Data/Tango.db b/Software/Visual_Studio/Web/Tango.MachineService/App_Data/Tango.db Binary files differindex ca132ea1d..d036138bc 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/App_Data/Tango.db +++ b/Software/Visual_Studio/Web/Tango.MachineService/App_Data/Tango.db |
