aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-02-20 15:13:30 +0200
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-02-20 15:13:30 +0200
commite213a2f2e87d7853e1385f6fb0d0ae4dae8b90e6 (patch)
treefd54b2a2a898ad3ef7219ccf76e99fe94343bebd /Software/Visual_Studio
parentd6e2772dd98e6880de14ea12be0ef53bae24f763 (diff)
downloadTango-e213a2f2e87d7853e1385f6fb0d0ae4dae8b90e6.tar.gz
Tango-e213a2f2e87d7853e1385f6fb0d0ae4dae8b90e6.zip
Fixed issues with ExtendedObject stackoverflow.
Working on FSE...
Diffstat (limited to 'Software/Visual_Studio')
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.Common/FSEDialogViewVM.cs50
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.Common/FSEViewModel.cs6
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj1
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.UI/Connection/DefaultMachineProvider.cs8
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.UI/Dialogs/MachineConnectionSerialView.xaml12
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.UI/Dialogs/MachineConnectionSerialView.xaml.cs28
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.UI/Dialogs/MachineConnectionSerialViewVM.cs19
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj9
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModels/DashboardViewVM.cs1
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.UI/Views/MainView.xaml72
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.UI/Views/MainView.xaml.cs18
-rw-r--r--Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs2
-rw-r--r--Software/Visual_Studio/Tango.Core/ExtendedObject.cs2
13 files changed, 217 insertions, 11 deletions
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/FSEDialogViewVM.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/FSEDialogViewVM.cs
new file mode 100644
index 000000000..a5137b9b5
--- /dev/null
+++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/FSEDialogViewVM.cs
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.SharedUI;
+
+namespace Tango.FSE.Common
+{
+ public class FSEDialogViewVM : DialogViewVM
+ {
+ private bool _autoMode;
+ /// <summary>
+ /// Will apply the default cancel and OK buttons.
+ /// </summary>
+ public bool AutoMode
+ {
+ get { return _autoMode; }
+ set { _autoMode = value; RaisePropertyChangedAuto(); }
+ }
+
+ private String _okText;
+ /// <summary>
+ /// Gets or sets the OK button text.
+ /// </summary>
+ public String OKText
+ {
+ get { return _okText; }
+ set { _okText = value; }
+ }
+
+ private String _cancelText;
+ /// <summary>
+ /// Gets or sets the cancel button text.
+ /// </summary>
+ public String CancelText
+ {
+ get { return _cancelText; }
+ set { _cancelText = value; RaisePropertyChangedAuto(); }
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="FSEDialogViewVM"/> class.
+ /// </summary>
+ public FSEDialogViewVM() : base()
+ {
+ AutoMode = true;
+ }
+ }
+}
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/FSEViewModel.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/FSEViewModel.cs
index 2d27e9013..e2cae4ded 100644
--- a/Software/Visual_Studio/FSE/Tango.FSE.Common/FSEViewModel.cs
+++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/FSEViewModel.cs
@@ -208,11 +208,11 @@ namespace Tango.FSE.Common
}
- protected override void RaisePropertyChanged(string propName)
+ protected override void RaisePropertyChangedAuto([CallerMemberName] string caller = null)
{
- base.RaisePropertyChanged(propName);
+ base.RaisePropertyChangedAuto(caller);
- if (propName == nameof(IsFree))
+ if (caller == nameof(IsFree))
{
if (IsFree)
{
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj b/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj
index 64241a1d6..7eaac67c8 100644
--- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj
+++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj
@@ -81,6 +81,7 @@
<Compile Include="Connection\IMachineProvider.cs" />
<Compile Include="Controls\IconButton.cs" />
<Compile Include="FSEApplication\IFSEApplicationManager.cs" />
+ <Compile Include="FSEDialogViewVM.cs" />
<Compile Include="FSEModuleAttribute.cs" />
<Compile Include="Gateway\GatewayClient.cs" />
<Compile Include="Gateway\IGatewayService.cs" />
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Connection/DefaultMachineProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/Connection/DefaultMachineProvider.cs
index 2e0f06f53..66482e476 100644
--- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Connection/DefaultMachineProvider.cs
+++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Connection/DefaultMachineProvider.cs
@@ -6,7 +6,10 @@ using System.Text;
using System.Threading.Tasks;
using Tango.BL.Entities;
using Tango.Core;
+using Tango.Core.DI;
using Tango.FSE.Common.Connection;
+using Tango.FSE.Common.Notifications;
+using Tango.FSE.UI.Dialogs;
using Tango.Integration.ExternalBridge;
using Tango.Integration.Operation;
@@ -14,6 +17,9 @@ namespace Tango.FSE.UI.Connection
{
public class DefaultMachineProvider : ExtendedObject, IMachineProvider
{
+ [TangoInject]
+ private INotificationProvider NotificationProvider { get; set; }
+
private Machine _machine;
/// <summary>
/// Gets the database machine entity associated with the current machine.
@@ -64,6 +70,8 @@ namespace Tango.FSE.UI.Connection
await DisconnectMachine();
}
+ await NotificationProvider.ShowDialog<MachineConnectionSerialViewVM>();
+
ReassignEventHandlers(MachineOperator, machine);
MachineOperator = machine;
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Dialogs/MachineConnectionSerialView.xaml b/Software/Visual_Studio/FSE/Tango.FSE.UI/Dialogs/MachineConnectionSerialView.xaml
new file mode 100644
index 000000000..c8ff5e887
--- /dev/null
+++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Dialogs/MachineConnectionSerialView.xaml
@@ -0,0 +1,12 @@
+<UserControl x:Class="Tango.FSE.UI.Dialogs.MachineConnectionSerialView"
+ 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.FSE.UI.Dialogs"
+ mc:Ignorable="d"
+ Height="300" Width="700" Background="{StaticResource FSE_PrimaryBackgroundLightBrush}" Foreground="{StaticResource FSE_PrimaryForegroundBrush}">
+ <Grid>
+ <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="40">Machine Serial Dialog</TextBlock>
+ </Grid>
+</UserControl>
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Dialogs/MachineConnectionSerialView.xaml.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/Dialogs/MachineConnectionSerialView.xaml.cs
new file mode 100644
index 000000000..b29a83d72
--- /dev/null
+++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Dialogs/MachineConnectionSerialView.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.FSE.UI.Dialogs
+{
+ /// <summary>
+ /// Interaction logic for MachineConnectionSerialView.xaml
+ /// </summary>
+ public partial class MachineConnectionSerialView : UserControl
+ {
+ public MachineConnectionSerialView()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Dialogs/MachineConnectionSerialViewVM.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/Dialogs/MachineConnectionSerialViewVM.cs
new file mode 100644
index 000000000..79c68dd11
--- /dev/null
+++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Dialogs/MachineConnectionSerialViewVM.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.FSE.Common;
+
+namespace Tango.FSE.UI.Dialogs
+{
+ public class MachineConnectionSerialViewVM : FSEDialogViewVM
+ {
+ public MachineConnectionSerialViewVM() : base()
+ {
+ AutoMode = true;
+ CancelText = "CANCEL";
+ OKText = "CONNECT";
+ }
+ }
+}
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj b/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj
index c2e7ebda0..3fed0c00e 100644
--- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj
+++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj
@@ -86,6 +86,10 @@
<Compile Include="Authentication\DefaultAuthenticationProvider.cs" />
<Compile Include="Connection\DefaultMachineProvider.cs" />
<Compile Include="Contracts\ILayoutView.cs" />
+ <Compile Include="Dialogs\MachineConnectionSerialView.xaml.cs">
+ <DependentUpon>MachineConnectionSerialView.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="Dialogs\MachineConnectionSerialViewVM.cs" />
<Compile Include="Gateway\DefaultGatewayService.cs" />
<Compile Include="InternalModule.cs" />
<Compile Include="Modules\DefaultFSEModuleLoader.cs" />
@@ -124,6 +128,10 @@
<Compile Include="Views\MainView.xaml.cs">
<DependentUpon>MainView.xaml</DependentUpon>
</Compile>
+ <Page Include="Dialogs\MachineConnectionSerialView.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@@ -257,6 +265,7 @@
<Resource Include="Images\Connections\usb.png" />
<Resource Include="Images\Connections\wifi.png" />
</ItemGroup>
+ <ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\..\packages\MaterialDesignThemes.3.0.1\build\MaterialDesignThemes.targets" Condition="Exists('..\..\packages\MaterialDesignThemes.3.0.1\build\MaterialDesignThemes.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModels/DashboardViewVM.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModels/DashboardViewVM.cs
index 068ac6b42..7e8776af4 100644
--- a/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModels/DashboardViewVM.cs
+++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModels/DashboardViewVM.cs
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
using Tango.Core.Commands;
using Tango.FSE.Common;
using Tango.FSE.Diagnostics;
+using Tango.FSE.UI.Dialogs;
namespace Tango.FSE.UI.ViewModels
{
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Views/MainView.xaml b/Software/Visual_Studio/FSE/Tango.FSE.UI/Views/MainView.xaml
index 3533e3148..b4a4d620a 100644
--- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Views/MainView.xaml
+++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Views/MainView.xaml
@@ -24,7 +24,70 @@
</controls:NavigationControl>
<!--DIALOGS-->
- <Grid x:Name="gridDialogs" IsVisibleChanged="GridDialogs_IsVisibleChanged" Background="{StaticResource FSE_SemiTransparentBrush}" Visibility="{Binding NotificationProvider.HasMessageBox,Converter={StaticResource BooleanToVisibilityConverter}}">
+ <Grid x:Name="gridDialog" IsVisibleChanged="GridDialog_IsVisibleChanged" Background="{StaticResource FSE_SemiTransparentBrush}" Visibility="{Binding NotificationProvider.HasDialog,Converter={StaticResource BooleanToVisibilityConverter}}">
+ <Grid RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Center" VerticalAlignment="Center">
+ <Grid.Style>
+ <Style TargetType="Grid">
+ <Setter Property="RenderTransform">
+ <Setter.Value>
+ <ScaleTransform ScaleX="0" ScaleY="0" />
+ </Setter.Value>
+ </Setter>
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding NotificationProvider.HasDialog}" Value="True">
+ <DataTrigger.EnterActions>
+ <BeginStoryboard>
+ <Storyboard>
+ <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleX" From="0" To="1" Duration="00:00:0.1" />
+ <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleY" From="0" To="1" Duration="00:00:0.1" />
+ </Storyboard>
+ </BeginStoryboard>
+ </DataTrigger.EnterActions>
+ <DataTrigger.ExitActions>
+ <BeginStoryboard>
+ <Storyboard>
+ <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleX" From="1" To="0" Duration="00:00:0.1" />
+ <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleY" From="1" To="0" Duration="00:00:0.1" />
+ </Storyboard>
+ </BeginStoryboard>
+ </DataTrigger.ExitActions>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </Grid.Style>
+
+ <Border Background="{StaticResource FSE_PrimaryBackgroundLightBrush}" CornerRadius="5">
+ <Border.Effect>
+ <DropShadowEffect BlurRadius="10" />
+ </Border.Effect>
+ <Grid ClipToBounds="True">
+ <Grid DataContext="{Binding NotificationProvider.CurrentDialog}">
+ <DockPanel>
+ <Grid DockPanel.Dock="Bottom" Visibility="{Binding DataContext.AutoMode,Converter={StaticResource BooleanToVisibilityConverter}}">
+ <Border Background="{StaticResource FSE_PrimaryBackgroundBrush}" CornerRadius="0 0 5 5" Padding="10">
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
+ <Button Height="40" MinWidth="150" Margin="0 0 5 0" Style="{StaticResource FSE_RaisedButton_Dark_Hover}" Command="{Binding DataContext.CloseCommand}" Visibility="{Binding DataContext.CanClose,Converter={StaticResource BooleanToVisibilityConverter}}" Content="{Binding DataContext.CancelText,TargetNullValue='CANCEL'}"></Button>
+ <Button x:Name="btnDialogOK" Height="40" MinWidth="150" IsDefault="True" Style="{StaticResource FSE_RaisedButton_Dark_Hover}" Command="{Binding DataContext.OKCommand}" Content="{Binding DataContext.OKText,TargetNullValue='OK'}"></Button>
+ </StackPanel>
+ </Border>
+ <Rectangle VerticalAlignment="Top" DockPanel.Dock="Bottom" Stroke="{StaticResource FSE_BorderBrush}" StrokeThickness="1" StrokeDashArray="5" />
+ </Grid>
+
+ <ContentPresenter Margin="5" Content="{Binding}" />
+ </DockPanel>
+
+ <Grid HorizontalAlignment="Right" VerticalAlignment="Top" Visibility="{Binding DataContext.AutoMode,Converter={StaticResource BooleanToVisibilityConverter}}">
+ <commonControls:IconButton Icon="Close" Padding="8" Margin="0 0 5 0" Command="{Binding DataContext.CloseCommand}" Visibility="{Binding DataContext.CanClose,Converter={StaticResource BooleanToVisibilityConverter}}" Width="{Binding RelativeSource={RelativeSource Self},Path=ActualHeight}"/>
+ </Grid>
+ </Grid>
+ </Grid>
+ </Border>
+ </Grid>
+ </Grid>
+ <!--DIALOGS-->
+
+ <!--MESSAGE BOXES-->
+ <Grid x:Name="gridMessageBox" IsVisibleChanged="GridMessageBox_IsVisibleChanged" Background="{StaticResource FSE_SemiTransparentBrush}" Visibility="{Binding NotificationProvider.HasMessageBox,Converter={StaticResource BooleanToVisibilityConverter}}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="100*"/>
@@ -118,8 +181,8 @@
<ColumnDefinition Width="50*" />
<ColumnDefinition Width="50*" />
</Grid.ColumnDefinitions>
- <Button Grid.Column="1" x:Name="btnCancel" Height="Auto" Style="{StaticResource MaterialDesignRaisedLightButton}" FontWeight="Normal" Margin="0 0 10 0" Command="{Binding CloseCommand}" Visibility="{Binding HasCancel,Converter={StaticResource BooleanToVisibilityConverter}}" Content="{Binding CancelText}"></Button>
- <Button Grid.Column="2" x:Name="btnOK" IsDefault="True" Style="{StaticResource MaterialDesignRaisedLightButton}" Height="Auto" FontWeight="Normal" Margin="0 0 0 0" Command="{Binding OKCommand}" Content="{Binding OKText}"></Button>
+ <Button Grid.Column="1" x:Name="btnCancel" Height="Auto" Style="{StaticResource FSE_RaisedButton_Dark_Hover}" Margin="0 0 10 0" Command="{Binding CloseCommand}" Visibility="{Binding HasCancel,Converter={StaticResource BooleanToVisibilityConverter}}" Content="{Binding CancelText}"></Button>
+ <Button Grid.Column="2" x:Name="btnOK" IsDefault="True" Style="{StaticResource FSE_RaisedButton_Dark_Hover}" Height="Auto" Command="{Binding OKCommand}" Content="{Binding OKText}"></Button>
</Grid>
</Grid>
</Grid>
@@ -127,6 +190,7 @@
</Grid>
</Grid>
</Grid>
- <!--DIALOGS-->
+ <!--MESSAGE BOXES-->
+
</Grid>
</UserControl>
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Views/MainView.xaml.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/Views/MainView.xaml.cs
index 38ab523c4..12add824b 100644
--- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Views/MainView.xaml.cs
+++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Views/MainView.xaml.cs
@@ -30,9 +30,9 @@ namespace Tango.FSE.UI.Views
InitializeComponent();
}
- private async void GridDialogs_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
+ private async void GridMessageBox_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
{
- if (gridDialogs.IsVisible)
+ if (gridMessageBox.IsVisible)
{
_previousFocusedElement = Keyboard.FocusedElement as UIElement;
await Task.Delay(100);
@@ -43,5 +43,19 @@ namespace Tango.FSE.UI.Views
_previousFocusedElement?.Focus();
}
}
+
+ private async void GridDialog_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
+ {
+ if (gridDialog.IsVisible)
+ {
+ _previousFocusedElement = Keyboard.FocusedElement as UIElement;
+ await Task.Delay(100);
+ btnDialogOK.Focus();
+ }
+ else
+ {
+ _previousFocusedElement?.Focus();
+ }
+ }
}
}
diff --git a/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs b/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs
index 0ab4f1969..dd3a9f0de 100644
--- a/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs
+++ b/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs
@@ -358,7 +358,7 @@ namespace Tango.Core.DI
{
var type = target.GetType();
- foreach (var prop in type.GetPropertiesWithAttribute<TangoInjectAttribute>(BindingFlags.Public | BindingFlags.Instance))
+ foreach (var prop in type.GetPropertiesWithAttribute<TangoInjectAttribute>(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic))
{
var att = prop.GetCustomAttribute<TangoInjectAttribute>();
diff --git a/Software/Visual_Studio/Tango.Core/ExtendedObject.cs b/Software/Visual_Studio/Tango.Core/ExtendedObject.cs
index 1875dcd2d..acead4157 100644
--- a/Software/Visual_Studio/Tango.Core/ExtendedObject.cs
+++ b/Software/Visual_Studio/Tango.Core/ExtendedObject.cs
@@ -69,7 +69,7 @@ namespace Tango.Core
/// <param name="propName">Name of the property.</param>
protected virtual void RaisePropertyChangedAuto([CallerMemberName] string caller = null)
{
- RaisePropertyChanged(caller);
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(caller));
}
/// <summary>