diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-06-06 18:39:17 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-06-06 18:39:17 +0300 |
| commit | cff4a8079c4d352cfd47793c701650e62337ed6e (patch) | |
| tree | af145431e541f08ed99b1d3ae377d8a59faedc4f /Software/Visual_Studio/PPC/Tango.PPC.UI | |
| parent | 776d934a1adc8c58301e56f6639afdeeccb0dda6 (diff) | |
| download | Tango-cff4a8079c4d352cfd47793c701650e62337ed6e.tar.gz Tango-cff4a8079c4d352cfd47793c701650e62337ed6e.zip | |
Working on PPC..
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI')
12 files changed, 183 insertions, 45 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml index 5616ff68f..863a424a0 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml @@ -1,7 +1,8 @@ <Application x:Class="Tango.PPC.UI.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:dragAndDrop="clr-namespace:Tango.DragAndDrop;assembly=Tango.DragAndDrop" + xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + xmlns:dragAndDrop="clr-namespace:Tango.DragAndDrop;assembly=Tango.DragAndDrop" xmlns:local="clr-namespace:Tango.PPC.UI" StartupUri="MainWindow.xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" d1p1:Ignorable="d" xmlns:d1p1="http://schemas.openxmlformats.org/markup-compatibility/2006"> <Application.Resources> @@ -20,6 +21,11 @@ <ResourceDictionary Source="Resources/Colors.xaml"></ResourceDictionary> <ResourceDictionary Source="Resources/Fonts.xaml"></ResourceDictionary> <ResourceDictionary Source="Resources/Styles.xaml"></ResourceDictionary> + + <!--Converters--> + <ResourceDictionary> + <converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" /> + </ResourceDictionary> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/MessageBox Icons/information.png b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/MessageBox Icons/information.png Binary files differindex c56906674..c1c638c6b 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/MessageBox Icons/information.png +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/MessageBox Icons/information.png diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml index c80a1473c..289d0cdf2 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml @@ -12,9 +12,9 @@ Foreground="{StaticResource TangoDarkForegroundBrush}"> <Grid> <Viewbox Stretch="Fill"> - <Grid Height="1280" Width="800"> - <views:MainView/> - </Grid> - </Viewbox> + <Grid Height="1280" Width="800"> + <views:MainView/> + </Grid> + </Viewbox> </Grid> </Window> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs index dbaafa6bb..02e41e087 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs @@ -8,16 +8,37 @@ using System.Windows; using System.Windows.Media; using Tango.PPC.Common.Notifications; using Tango.Core; +using System.Collections.Concurrent; +using System.Windows.Media.Imaging; +using Tango.SharedUI.Helpers; namespace Tango.PPC.UI.Notifications { public class DefaultNotificationProvider : ExtendedObject, INotificationProvider { + private class PendingMessageBox + { + public MessageBoxVM VM { get; set; } + public TaskCompletionSource<bool> CompletionSource { get; set; } + } + + private ConcurrentQueue<PendingMessageBox> _pendingMessageBoxes; + + public DefaultNotificationProvider() + { + _pendingMessageBoxes = new ConcurrentQueue<PendingMessageBox>(); + } + private MessageBoxVM _currentMessageBox; public MessageBoxVM CurrentMessageBox { get { return _currentMessageBox; } - private set { _currentMessageBox = value; RaisePropertyChangedAuto(); } + private set + { + _currentMessageBox = value; + RaisePropertyChangedAuto(); + RaisePropertyChanged(nameof(HasMessageBox)); + } } public bool HasMessageBox @@ -30,22 +51,84 @@ namespace Tango.PPC.UI.Notifications public Task ShowError(string message) { - throw new NotImplementedException(); + return ShowMessageBox(new MessageBoxVM() + { + Message = message, + Icon = ResourceHelper.GetImageFromResources("Images/MessageBox Icons/information.png"), + Title = "Error", + Brush = Application.Current.Resources["TangoMessageBoxErrorBrush"] as Brush, + }); } public Task ShowInfo(string message) { - throw new NotImplementedException(); + return ShowMessageBox(new MessageBoxVM() + { + Message = message, + Icon = ResourceHelper.GetImageFromResources("Images/MessageBox Icons/information.png"), + Title = "Information", + Brush = Application.Current.Resources["TangoMessageBoxInfoBrush"] as Brush, + }); } public Task ShowWarning(string message) { - throw new NotImplementedException(); + return ShowMessageBox(new MessageBoxVM() + { + Message = message, + Icon = ResourceHelper.GetImageFromResources("Images/MessageBox Icons/information.png"), + Title = "Warning", + Brush = Application.Current.Resources["TangoMessageBoxWarningBrush"] as Brush, + }); } public Task<bool> ShowQuestion(string message) { - throw new NotImplementedException(); + return ShowMessageBox(new MessageBoxVM() + { + Message = message, + Icon = ResourceHelper.GetImageFromResources("Images/MessageBox Icons/information.png"), + Title = "Confirm", + HasCancel = true, + Brush = Application.Current.Resources["TangoMessageBoxQuestionBrush"] as Brush, + }); + } + + private Task<bool> ShowMessageBox(MessageBoxVM vm) + { + TaskCompletionSource<bool> source = new TaskCompletionSource<bool>(); + + vm.Accepted += () => { OnMessageBoxClosed(); source.SetResult(true); }; + vm.Canceled += () => { OnMessageBoxClosed(); source.SetResult(false); }; + + if (CurrentMessageBox == null) + { + CurrentMessageBox = vm; + } + else + { + _pendingMessageBoxes.Enqueue(new PendingMessageBox() + { + VM = vm, + CompletionSource = source, + }); + } + + return source.Task; + } + + private void OnMessageBoxClosed() + { + CurrentMessageBox = null; + + if (_pendingMessageBoxes.Count > 0) + { + PendingMessageBox p = null; + if (_pendingMessageBoxes.TryDequeue(out p)) + { + CurrentMessageBox = p.VM; + } + } } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/MessageBox.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/MessageBox.xaml index a699902b8..07d3b11ac 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/MessageBox.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/MessageBox.xaml @@ -8,30 +8,37 @@ xmlns:vm="clr-namespace:Tango.PPC.Common.Notifications;assembly=Tango.PPC.Common" xmlns:local="clr-namespace:Tango.PanelPC.UI.Notifications" mc:Ignorable="d" - d:DesignHeight="200" d:DesignWidth="500" d:DataContext="{d:DesignInstance vm:MessageBoxVM,IsDesignTimeCreatable=False}"> + d:DesignHeight="400" d:DesignWidth="800" d:DataContext="{d:DesignInstance vm:MessageBoxVM,IsDesignTimeCreatable=False}"> <Grid> - <Border Background="{StaticResource TangoPrimaryBackgroundBrush}" CornerRadius="10" Margin="10" Padding="10"> + <Border Background="{StaticResource TangoPrimaryBackgroundBrush}" CornerRadius="10" Margin="10"> <Border.Effect> <DropShadowEffect BlurRadius="10" /> </Border.Effect> <Grid> <Grid.ColumnDefinitions> - <ColumnDefinition Width="17*"/> + <ColumnDefinition Width="100"/> <ColumnDefinition Width="75*"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> + <RowDefinition Height="100" /> <RowDefinition Height="1*" /> - <RowDefinition Height="Auto"/> + <RowDefinition Height="70"/> </Grid.RowDefinitions> - <Image Source="{Binding Icon,FallbackValue='/Images/MessageBox Icons/information.png'}" Margin="10" /> - <TextBlock x:Name="lbMessage" Grid.Column="1" TextWrapping="Wrap" VerticalAlignment="Center" Margin="10,50,10,55" Height="16"></TextBlock> + <Image Grid.Row="0" Source="{Binding Icon}" Margin="20" /> + <TextBlock Grid.Column="1" Text="{Binding Title,TargetNullValue=Confirm}" Foreground="{Binding Brush,TargetNullValue={StaticResource TangoPrimaryAccentBrush}}" VerticalAlignment="Center" Margin="10" Style="{StaticResource TangoMessageBoxTitle}"></TextBlock> - <UniformGrid Grid.Column="1" Grid.Row="1" HorizontalAlignment="Right" Rows="1" Width="220"> - <touch:TouchButton x:Name="btnCancel" Margin="2" Style="{StaticResource TangoFlatButtonTextOnly}">CANCEL</touch:TouchButton> - <touch:TouchButton x:Name="btnOK" Margin="2" Style="{StaticResource TangoFlatButtonTextOnly}">OK</touch:TouchButton> - </UniformGrid> + <Rectangle Stroke="{Binding Brush}" VerticalAlignment="Bottom" Grid.ColumnSpan="2" StrokeThickness="3" /> + + <TextBlock Grid.Row="1" FontSize="{StaticResource TangoMessageBoxMessageFontSize}" Text="{Binding Message}" VerticalAlignment="Top" Grid.Column="1" TextWrapping="Wrap" Margin="10 20 10 10"></TextBlock> + + <Rectangle Stroke="{StaticResource TangoDividerBrush}" VerticalAlignment="Bottom" Grid.Row="1" Grid.ColumnSpan="2" StrokeThickness="1"/> + + <StackPanel Grid.Column="1" Grid.Row="2" HorizontalAlignment="Right" Orientation="Horizontal"> + <touch:TouchButton x:Name="btnCancel" Width="180" Margin="2 0" Style="{StaticResource TangoMessageBoxButton}" Command="{Binding CloseCommand}" Visibility="{Binding HasCancel,Converter={StaticResource BooleanToVisibilityConverter}}">CANCEL</touch:TouchButton> + <touch:TouchButton x:Name="btnOK" Width="180" Margin="2 0" Style="{StaticResource TangoMessageBoxButton}" Command="{Binding OKCommand}">OK</touch:TouchButton> + </StackPanel> </Grid> </Border> </Grid> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Resources/Colors.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Resources/Colors.xaml index 1c24d118b..3b9ccf2fa 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Resources/Colors.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Resources/Colors.xaml @@ -4,4 +4,9 @@ <SolidColorBrush x:Key="TangoKeyboardBackground" Color="Silver" /> + <SolidColorBrush x:Key="TangoMessageBoxInfoBrush" Color="{StaticResource TangoPrimaryAccentColor}" /> + <SolidColorBrush x:Key="TangoMessageBoxWarningBrush" Color="#FF9629" /> + <SolidColorBrush x:Key="TangoMessageBoxErrorBrush" Color="#FF6262" /> + <SolidColorBrush x:Key="TangoMessageBoxQuestionBrush" Color="{StaticResource TangoPrimaryAccentColor}" /> + </ResourceDictionary>
\ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Resources/Fonts.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Resources/Fonts.xaml index 46deceb85..659970db2 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Resources/Fonts.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Resources/Fonts.xaml @@ -11,5 +11,7 @@ <sys:Double x:Key="TangoNavigationLinksFontSize">18</sys:Double> <sys:Double x:Key="TangoHeaderFontSize">30</sys:Double> <sys:Double x:Key="TangoButtonFontSize">20</sys:Double> + <sys:Double x:Key="TangoMessageBoxTitleFontSize">30</sys:Double> + <sys:Double x:Key="TangoMessageBoxMessageFontSize">20</sys:Double> </ResourceDictionary>
\ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Resources/Styles.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Resources/Styles.xaml index a82e1acb4..f83d71e92 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Resources/Styles.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Resources/Styles.xaml @@ -22,4 +22,17 @@ <Setter Property="FontSize" Value="{StaticResource TangoButtonFontSize}"></Setter> </Style> + <Style x:Key="TangoMessageBoxButton" TargetType="{x:Type touch:TouchButton}" BasedOn="{StaticResource TangoFlatButton}"> + <Setter Property="HorizontalContentAlignment" Value="Center"></Setter> + <Setter Property="Foreground" Value="{StaticResource TangoDarkForegroundBrush}"></Setter> + <Setter Property="FontSize" Value="{StaticResource TangoButtonFontSize}"></Setter> + <Setter Property="BorderBrush" Value="{StaticResource TangoDividerBrush}"></Setter> + <Setter Property="BorderThickness" Value="1 0 0 0"></Setter> + </Style> + + <Style x:Key="TangoMessageBoxTitle" TargetType="TextBlock"> + <Setter Property="FontSize" Value="{StaticResource TangoMessageBoxTitleFontSize}"></Setter> + <Setter Property="Foreground" Value="{StaticResource TangoPrimaryAccentBrush}"></Setter> + </Style> + </ResourceDictionary>
\ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/JobsViewVM.cs index b5e3e18fc..2af15b1ad 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/JobsViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/JobsViewVM.cs @@ -51,20 +51,6 @@ namespace Tango.PPC.UI.ViewModels public RelayCommand<DropEventArgs> OnDragAndDropCommand { get; set; } - public JobsViewVM(IPPCApplicationManager application, IAuthenticationProvider authentication, INavigationManager navigation, INotificationProvider notification) : base(application, authentication, navigation, notification) - { - Jobs = new ObservableCollection<Job>(); - - JobSelectedCommand = new RelayCommand((x) => JobSelected(x as Job)); - OnDragAndDropCommand = new RelayCommand<DropEventArgs>((e) => - { - Job draggedJob = e.Draggable.DataContext as Job; - Job droppedJob = e.Droppable.DataContext as Job; - - OnDragAndDropJobs(draggedJob, droppedJob); - }); - } - private void OnDragAndDropJobs(Job draggedJob, Job droppedJob) { Debug.WriteLine(draggedJob.Name + " Dragged on to " + droppedJob.Name); @@ -88,9 +74,24 @@ namespace Tango.PPC.UI.ViewModels JobsCollectionView.Refresh(); } - private void JobSelected(Job job) + private async void JobSelected(Job job) { Debug.WriteLine(job.Name); + await NotificationProvider.ShowInfo("Job details not yet implemented..."); + } + + public JobsViewVM() + { + Jobs = new ObservableCollection<Job>(); + + JobSelectedCommand = new RelayCommand((x) => JobSelected(x as Job)); + OnDragAndDropCommand = new RelayCommand<DropEventArgs>((e) => + { + Job draggedJob = e.Draggable.DataContext as Job; + Job droppedJob = e.Droppable.DataContext as Job; + + OnDragAndDropJobs(draggedJob, droppedJob); + }); } public override void OnApplicationStarted() diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs index 37940b2f8..a33dc25d7 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs @@ -17,11 +17,6 @@ namespace Tango.PPC.UI.ViewModels { public class LoadingViewVM : PPCViewModel { - public LoadingViewVM(IPPCApplicationManager application, IAuthenticationProvider authentication, INavigationManager navigation, INotificationProvider notification) : base(application, authentication, navigation, notification) - { - - } - public async override void OnApplicationStarted() { await Task.Delay(500); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs index c75e031f1..d1fc4c015 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs @@ -3,18 +3,20 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.PPC.Common; using Tango.PPC.Common.Application; +using Tango.PPC.Common.Authentication; +using Tango.PPC.Common.Navigation; +using Tango.PPC.Common.Notifications; using Tango.SharedUI; namespace Tango.PPC.UI.ViewModels { - public class MainViewVM : ViewModel + public class MainViewVM : PPCViewModel { - public String Test { get; set; } - - public MainViewVM(IPPCApplicationManager application) + public override void OnApplicationStarted() { - Test = "This is a binding test"; + } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml index 9d264afae..8da05f0dd 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml @@ -7,6 +7,7 @@ xmlns:vm="clr-namespace:Tango.PPC.UI.ViewModels" xmlns:global="clr-namespace:Tango.PPC.UI" xmlns:local="clr-namespace:Tango.PPC.UI.Views" + xmlns:notifications="clr-namespace:Tango.PanelPC.UI.Notifications" mc:Ignorable="d" d:DesignHeight="1280" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> <Grid> @@ -14,5 +15,28 @@ <local:LoadingView controls:NavigationControl.NavigationName="LoadingView"></local:LoadingView> <local:LayoutView controls:NavigationControl.NavigationName="LayoutView"></local:LayoutView> </controls:NavigationControl> + + <Grid Background="#9E000000"> + <Grid.Style> + <Style TargetType="Grid"> + <Setter Property="Opacity" Value="0"></Setter> + <Setter Property="Visibility" Value="Hidden"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding NotificationProvider.HasMessageBox}" Value="True"> + <Setter Property="Visibility" Value="Visible"></Setter> + <DataTrigger.EnterActions> + <BeginStoryboard> + <Storyboard> + <DoubleAnimation To="1" Storyboard.TargetProperty="Opacity" Duration="00:00:0.2" /> + </Storyboard> + </BeginStoryboard> + </DataTrigger.EnterActions> + </DataTrigger> + </Style.Triggers> + </Style> + </Grid.Style> + + <notifications:MessageBox Height="400" Margin="20" DataContext="{Binding NotificationProvider.CurrentMessageBox}" /> + </Grid> </Grid> </UserControl> |
