aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Utilities
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2017-12-10 19:01:05 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2017-12-10 19:01:05 +0200
commit3fdcdac577d552bbdf6d7320c6ffb0753e810a08 (patch)
tree55e392cea80a3539164abb1fd16c15986c92b287 /Software/Visual_Studio/Utilities
parent3eabdee9604ad67cdbab7ee35bdfa249402f8831 (diff)
downloadTango-3fdcdac577d552bbdf6d7320c6ffb0753e810a08.tar.gz
Tango-3fdcdac577d552bbdf6d7320c6ffb0753e810a08.zip
Started working on machine designer view models.
Added NAME field to MACHINE table.
Diffstat (limited to 'Software/Visual_Studio/Utilities')
-rw-r--r--Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/App.config18
-rw-r--r--Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/App.xaml.cs6
-rw-r--r--Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/DBAdapter.cs20
-rw-r--r--Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/EntityViewModel.cs30
-rw-r--r--Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/SupervisingController/IMachinesView.cs14
-rw-r--r--Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/Tango.MachineDesigner.UI.csproj18
-rw-r--r--Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/ViewModelLocator.cs13
-rw-r--r--Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/ViewModels/MachinesViewVM.cs41
-rw-r--r--Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/Views/MachinesView.xaml36
-rw-r--r--Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/Views/MachinesView.xaml.cs2
-rw-r--r--Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/Views/MainView.xaml2
-rw-r--r--Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/packages.config1
12 files changed, 169 insertions, 32 deletions
diff --git a/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/App.config b/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/App.config
index 8324aa6ff..92aa00bf9 100644
--- a/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/App.config
+++ b/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/App.config
@@ -1,6 +1,16 @@
-<?xml version="1.0" encoding="utf-8" ?>
+<?xml version="1.0" encoding="utf-8"?>
<configuration>
- <startup>
- <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
- </startup>
+ <configSections>
+ <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
+ <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
+ </configSections>
+ <startup>
+ <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
+ </startup>
+ <entityFramework>
+ <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
+ <providers>
+ <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
+ </providers>
+ </entityFramework>
</configuration> \ No newline at end of file
diff --git a/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/App.xaml.cs b/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/App.xaml.cs
index 04e61e96b..7b4aa8b01 100644
--- a/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/App.xaml.cs
+++ b/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/App.xaml.cs
@@ -13,5 +13,11 @@ namespace Tango.MachineDesigner.UI
/// </summary>
public partial class App : Application
{
+ protected override void OnStartup(StartupEventArgs e)
+ {
+ base.OnStartup(e);
+
+ DBAdapter.Initialize();
+ }
}
}
diff --git a/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/DBAdapter.cs b/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/DBAdapter.cs
new file mode 100644
index 000000000..e628db850
--- /dev/null
+++ b/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/DBAdapter.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.DAL.Remote.DB;
+using Tango.Settings;
+
+namespace Tango.MachineDesigner.UI
+{
+ public class DBAdapter
+ {
+ public static RemoteDB DbContext { get; set; }
+
+ public static void Initialize()
+ {
+ DbContext = new RemoteDB(SettingsManager.Default.DataBase.SQLServerAddress, false);
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/EntityViewModel.cs b/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/EntityViewModel.cs
new file mode 100644
index 000000000..a580098eb
--- /dev/null
+++ b/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/EntityViewModel.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.SharedUI;
+
+namespace Tango.MachineDesigner.UI
+{
+ public class EntityViewModel<T> : ViewModel
+ {
+ private T _entity;
+
+ public T Entity
+ {
+ get { return _entity; }
+ set { _entity = value; RaisePropertyChanged(nameof(Entity)); }
+ }
+
+ public EntityViewModel() : base()
+ {
+
+ }
+
+ public EntityViewModel(T entity) : this()
+ {
+ Entity = entity;
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/SupervisingController/IMachinesView.cs b/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/SupervisingController/IMachinesView.cs
deleted file mode 100644
index ba676c925..000000000
--- a/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/SupervisingController/IMachinesView.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Tango.SharedUI;
-
-namespace Tango.MachineDesigner.UI.SupervisingController
-{
- public interface IMachinesView : IView
- {
-
- }
-}
diff --git a/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/Tango.MachineDesigner.UI.csproj b/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/Tango.MachineDesigner.UI.csproj
index 7f291de85..b0cce92a0 100644
--- a/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/Tango.MachineDesigner.UI.csproj
+++ b/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/Tango.MachineDesigner.UI.csproj
@@ -40,6 +40,12 @@
<Reference Include="Dragablz, Version=0.0.3.197, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Dragablz.0.0.3.197\lib\net45\Dragablz.dll</HintPath>
</Reference>
+ <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
+ <HintPath>..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
+ </Reference>
+ <Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
+ <HintPath>..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
+ </Reference>
<Reference Include="FontAwesome.WPF, Version=4.7.0.37774, Culture=neutral, PublicKeyToken=0758b07a11a4f466, processorArchitecture=MSIL">
<HintPath>..\..\packages\FontAwesome.WPF.4.7.0.9\lib\net40\FontAwesome.WPF.dll</HintPath>
</Reference>
@@ -65,6 +71,7 @@
<HintPath>..\..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath>
</Reference>
<Reference Include="System" />
+ <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>
@@ -87,7 +94,8 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
- <Compile Include="SupervisingController\IMachinesView.cs" />
+ <Compile Include="DBAdapter.cs" />
+ <Compile Include="EntityViewModel.cs" />
<Compile Include="SupervisingController\IMainView.cs" />
<Compile Include="ViewModels\MachinesViewVM.cs" />
<Compile Include="ViewModels\MainViewVM.cs" />
@@ -158,6 +166,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.DAL.Remote\Tango.DAL.Remote.csproj">
<Project>{38197109-8610-4d3f-92b9-16d48df94d7c}</Project>
<Name>Tango.DAL.Remote</Name>
@@ -166,6 +178,10 @@
<Project>{bc932dbd-7cdb-488c-99e4-f02cf441f55e}</Project>
<Name>Tango.Logging</Name>
</ProjectReference>
+ <ProjectReference Include="..\..\Tango.Settings\Tango.Settings.csproj">
+ <Project>{d8f1ad85-526a-4f50-b6dc-d437af63d8d8}</Project>
+ <Name>Tango.Settings</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/Utilities/Tango.MachineDesigner.UI/ViewModelLocator.cs b/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/ViewModelLocator.cs
index 6b8bc5aea..5d26a3e21 100644
--- a/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/ViewModelLocator.cs
+++ b/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/ViewModelLocator.cs
@@ -33,17 +33,14 @@ namespace Tango.MachineDesigner.UI
//// SimpleIoc.Default.Register<IDataService, DataService>();
////}
- LogManager.Log("Registering MainView View Model...");
SimpleIoc.Default.Register<MainViewVM>();
+ SimpleIoc.Default.Register<MachinesViewVM>();
//Register View (Supervising Controller Pattern).
if (!ViewModelBase.IsInDesignModeStatic)
{
LogManager.Log(String.Format("Registering Supervising Controller {0}...", nameof(IMainView)));
SimpleIoc.Default.Register(() => (IMainView)MainView.Self);
-
- LogManager.Log(String.Format("Registering Supervising Controller {0}...", nameof(IMachinesView)));
- SimpleIoc.Default.Register(() => (IMachinesView)MainView.Self);
}
}
@@ -54,5 +51,13 @@ namespace Tango.MachineDesigner.UI
return ServiceLocator.Current.GetInstance<MainViewVM>();
}
}
+
+ public MachinesViewVM MachinesViewVM
+ {
+ get
+ {
+ return ServiceLocator.Current.GetInstance<MachinesViewVM>();
+ }
+ }
}
} \ No newline at end of file
diff --git a/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/ViewModels/MachinesViewVM.cs b/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/ViewModels/MachinesViewVM.cs
index 6d2cddda6..88a62dff8 100644
--- a/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/ViewModels/MachinesViewVM.cs
+++ b/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/ViewModels/MachinesViewVM.cs
@@ -1,18 +1,53 @@
using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
-using Tango.MachineDesigner.UI.SupervisingController;
+using Tango.DAL.Observables;
using Tango.SharedUI;
namespace Tango.MachineDesigner.UI.ViewModels
{
- public class MachinesViewVM : ViewModel<IMachinesView>
+ public class MachinesViewVM : ViewModel
{
- public MachinesViewVM(IMachinesView view) : base(view)
+ private ObservableCollection<Machine> _machines;
+ /// <summary>
+ /// Gets or sets the machines.
+ /// </summary>
+ public ObservableCollection<Machine> Machines
{
+ get { return _machines; }
+ set { _machines = value; RaisePropertyChangedAuto(); }
+ }
+
+ private ObservableCollection<Organization> _organizations;
+ /// <summary>
+ /// Gets or sets the organizations.
+ /// </summary>
+ public ObservableCollection<Organization> Organizations
+ {
+ get { return _organizations; }
+ set { _organizations = value; RaisePropertyChangedAuto(); }
+ }
+ private Machine _selectedMachine;
+ /// <summary>
+ /// Gets or sets the selected machine.
+ /// </summary>
+ public Machine SelectedMachine
+ {
+ get { return _selectedMachine; }
+ set { _selectedMachine = value; RaisePropertyChangedAuto(); }
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MachinesViewVM"/> class.
+ /// </summary>
+ public MachinesViewVM() : base()
+ {
+ Organizations = DBAdapter.DbContext.ORGANIZATIONS.Where(x => !x.DELETED).ToList().Select(x => new Organization(x)).ToObservableCollection();
+ Machines = DBAdapter.DbContext.MACHINES.Where(x => !x.DELETED).ToList().Select(x => new Machine(x)).ToObservableCollection();
}
}
}
diff --git a/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/Views/MachinesView.xaml b/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/Views/MachinesView.xaml
index c85f03682..0bbf3a285 100644
--- a/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/Views/MachinesView.xaml
+++ b/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/Views/MachinesView.xaml
@@ -1,4 +1,4 @@
-<controls:View x:Class="Tango.MachineDesigner.UI.Views.MachinesView"
+<UserControl x:Class="Tango.MachineDesigner.UI.Views.MachinesView"
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"
@@ -6,10 +6,38 @@
xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI"
xmlns:local="clr-namespace:Tango.MachineDesigner.UI.Views"
mc:Ignorable="d"
- d:DesignHeight="720" d:DesignWidth="1280" Background="White">
+ d:DesignHeight="720" d:DesignWidth="1280" Background="White" DataContext="{Binding MachinesViewVM, Source={StaticResource Locator}}">
<Grid>
<Grid>
-
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="300"/>
+ <ColumnDefinition Width="1*"/>
+ </Grid.ColumnDefinitions>
+
+ <Grid Margin="10">
+ <ListBox ItemsSource="{Binding Machines}" SelectedItem="{Binding SelectedMachine}">
+ <ListBox.ItemTemplate>
+ <DataTemplate>
+ <TextBlock>
+ <Run Text="{Binding Organization.Name}"></Run>
+ <LineBreak/>
+ <Run Text="{Binding Name}"></Run>
+ <LineBreak/>
+ <Run Text="{Binding Guid}"></Run>
+ </TextBlock>
+ </DataTemplate>
+ </ListBox.ItemTemplate>
+ </ListBox>
+ </Grid>
+
+ <Grid Grid.Column="1" Margin="10">
+ <StackPanel Width="400" HorizontalAlignment="Left">
+ <TextBlock>Name</TextBlock>
+ <TextBox Text="{Binding SelectedMachine.Name}"></TextBox>
+ <TextBlock>Organization</TextBlock>
+ <ComboBox ItemsSource="{Binding Organizations}" SelectedItem="{Binding SelectedMachine.Organization}" DisplayMemberPath="Name"></ComboBox>
+ </StackPanel>
+ </Grid>
</Grid>
</Grid>
-</controls:View>
+</UserControl>
diff --git a/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/Views/MachinesView.xaml.cs b/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/Views/MachinesView.xaml.cs
index ebab90278..3b0013051 100644
--- a/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/Views/MachinesView.xaml.cs
+++ b/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/Views/MachinesView.xaml.cs
@@ -19,7 +19,7 @@ namespace Tango.MachineDesigner.UI.Views
/// <summary>
/// Interaction logic for MachinesView.xaml
/// </summary>
- public partial class MachinesView : View
+ public partial class MachinesView : UserControl
{
public MachinesView() : base()
{
diff --git a/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/Views/MainView.xaml b/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/Views/MainView.xaml
index 510ffd0c3..76048199b 100644
--- a/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/Views/MainView.xaml
+++ b/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/Views/MainView.xaml
@@ -63,7 +63,7 @@
<dragablz:InterTabController />
</dragablz:TabablzControl.InterTabController>
<TabItem Header="MACHINES">
- <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center">Hello World</TextBlock>
+ <local:MachinesView></local:MachinesView>
</TabItem>
<TabItem Header="LIQUIDS">
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center">Material Design</TextBlock>
diff --git a/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/packages.config b/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/packages.config
index 08bc64f62..05f5d8725 100644
--- a/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/packages.config
+++ b/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/packages.config
@@ -2,6 +2,7 @@
<packages>
<package id="CommonServiceLocator" version="1.3" targetFramework="net46" />
<package id="Dragablz" version="0.0.3.197" targetFramework="net46" />
+ <package id="EntityFramework" version="6.2.0" targetFramework="net46" />
<package id="FontAwesome.WPF" version="4.7.0.9" targetFramework="net46" />
<package id="MahApps.Metro" version="1.5.0" targetFramework="net46" />
<package id="MaterialDesignColors" version="1.1.2" targetFramework="net46" />