diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-07-02 19:03:59 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-07-02 19:03:59 +0300 |
| commit | 2d340ef8bbbb5a1c7f3415da704a0b83c28c07b4 (patch) | |
| tree | e051087540ca37ab98c253075adf90b16fe6c665 /Software/Visual_Studio/PPC | |
| parent | 327fe90a471c74a5723258ccbda7d9ade064b50c (diff) | |
| download | Tango-2d340ef8bbbb5a1c7f3415da704a0b83c28c07b4.tar.gz Tango-2d340ef8bbbb5a1c7f3415da704a0b83c28c07b4.zip | |
WOrking on PPC.
Diffstat (limited to 'Software/Visual_Studio/PPC')
10 files changed, 221 insertions, 74 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj index 100b7dcbd..935fdb77d 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj @@ -104,6 +104,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Views\TwineCatalogView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> <Page Include="Views\TwineCatalogColorCorrectionView.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -154,6 +158,7 @@ <Compile Include="ViewModels\JobViewVM.cs" /> <Compile Include="ViewModels\MainViewVM.cs" /> <Compile Include="ViewModels\TwineCatalogColorCorrectionViewVM.cs" /> + <Compile Include="ViewModels\TwineCatalogViewVM.cs" /> <Compile Include="Views\JobsView.xaml.cs"> <DependentUpon>JobsView.xaml</DependentUpon> </Compile> @@ -166,6 +171,9 @@ <Compile Include="Views\MainView.xaml.cs"> <DependentUpon>MainView.xaml</DependentUpon> </Compile> + <Compile Include="Views\TwineCatalogView.xaml.cs"> + <DependentUpon>TwineCatalogView.xaml</DependentUpon> + </Compile> <Compile Include="Views\TwineCatalogColorCorrectionView.xaml.cs"> <DependentUpon>TwineCatalogColorCorrectionView.xaml</DependentUpon> </Compile> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModelLocator.cs index 17a14192e..2a0692350 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModelLocator.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModelLocator.cs @@ -19,6 +19,7 @@ namespace Tango.PPC.Jobs TangoIOC.Default.Register<JobsViewVM>(); TangoIOC.Default.Register<JobSummeryViewVM>(); TangoIOC.Default.Register<JobViewVM>(); + TangoIOC.Default.Register<TwineCatalogViewVM>(); TangoIOC.Default.Register<TwineCatalogColorCorrectionViewVM>(); } @@ -66,6 +67,14 @@ namespace Tango.PPC.Jobs } } + public static TwineCatalogViewVM TwineCatalogViewVM + { + get + { + return TangoIOC.Default.GetInstance<TwineCatalogViewVM>(); + } + } + public static TwineCatalogColorCorrectionViewVM TwineCatalogColorCorrectionViewVM { get diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs index 8663686c6..1c4fec382 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs @@ -160,6 +160,11 @@ namespace Tango.PPC.Jobs.ViewModels /// </summary> public RelayCommand<BrushStop> ReplaceBrushStopCommand { get; set; } + /// <summary> + /// Gets or sets the twine catalog field tap command. + /// </summary> + public RelayCommand<BrushStop> TwineCatalogFieldTapCommand { get; set; } + #endregion #region Constructors @@ -192,6 +197,7 @@ namespace Tango.PPC.Jobs.ViewModels RemoveJobCommand = new RelayCommand(RemoveJob); SaveJobCommand = new RelayCommand(SaveJob); ReplaceBrushStopCommand = new RelayCommand<BrushStop>(InvokeColorAdjustmentForBrushStop); + TwineCatalogFieldTapCommand = new RelayCommand<BrushStop>(InvokeTwineCatalogForBrushStop); } #endregion @@ -349,6 +355,19 @@ namespace Tango.PPC.Jobs.ViewModels } } + private async void InvokeTwineCatalogForBrushStop(BrushStop brushStop) + { + _can_navigate_back = true; + var catalogItem = await NavigationManager.NavigateForResult<JobsModule, TwineCatalogView, CatalogItem, BrushStop>(brushStop); + _can_navigate_back = false; + + if (catalogItem != null) + { + brushStop.ColorCatalog = _db.ColorCatalogs.Single(x => x.Guid == catalogItem.Entity.Guid); + brushStop.Color = catalogItem.Color; + } + } + #endregion #region Job Selection Message diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/TwineCatalogColorCorrectionViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/TwineCatalogColorCorrectionViewVM.cs index 9cae25dd2..7217bd174 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/TwineCatalogColorCorrectionViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/TwineCatalogColorCorrectionViewVM.cs @@ -13,35 +13,8 @@ using Tango.Settings; namespace Tango.PPC.Jobs.ViewModels { - public class TwineCatalogColorCorrectionViewVM : PPCViewModel, INavigationResultProvider<CatalogItem, BrushStop> + public class TwineCatalogColorCorrectionViewVM : TwineCatalogViewVM { - private bool _confirmed; - - private Catalog _catalog; - public Catalog Catalog - { - get { return _catalog; } - set { _catalog = value; RaisePropertyChangedAuto(); } - } - - private Catalog _recent; - public Catalog Recent - { - get { return _recent; } - set { _recent = value; RaisePropertyChangedAuto(); } - } - - - private CatalogItem _selectedItem; - public CatalogItem SelectedItem - { - get { return _selectedItem; } - set - { - _selectedItem = value; RaisePropertyChangedAuto(); - } - } - private BrushStop _invalidBrushStop; public BrushStop InvalidBrushStop { @@ -49,49 +22,7 @@ namespace Tango.PPC.Jobs.ViewModels set { _invalidBrushStop = value; RaisePropertyChangedAuto(); } } - public RelayCommand OKCommand { get; set; } - - public TwineCatalogColorCorrectionViewVM() - { - OKCommand = new RelayCommand(Confirm); - } - - public override void OnApplicationStarted() - { - Catalog = CatalogLoader.LoadCatalog(BL.Enumerations.ColorSpaces.Twine, ObservablesEntitiesAdapter.Instance.Context); - Recent = CatalogLoader.GetRecent(Catalog, SettingsManager.Default.GetOrCreate<JobsModuleSettings>().RecentTwineCatalogColors); - } - - public override void OnNavigatedTo() - { - SelectedItem = null; - base.OnNavigatedTo(); - _confirmed = false; - } - - private void Confirm() - { - SettingsManager.Default.GetOrCreate<JobsModuleSettings>().RecentTwineCatalogColors.Add(SelectedItem.Entity.Guid); - SettingsManager.Default.Save(); - Recent = CatalogLoader.GetRecent(Catalog, SettingsManager.Default.GetOrCreate<JobsModuleSettings>().RecentTwineCatalogColors); - - _confirmed = true; - NavigationManager.NavigateBack(); - } - - public CatalogItem GetNavigationResult() - { - if (_confirmed) - { - return SelectedItem; - } - else - { - return null; - } - } - - public void OnNavigationObjectReceived(BrushStop brushStop) + public override void OnNavigationObjectReceived(BrushStop brushStop) { InvalidBrushStop = brushStop; } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/TwineCatalogViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/TwineCatalogViewVM.cs new file mode 100644 index 000000000..2b7a24ab8 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/TwineCatalogViewVM.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Catalogs; +using Tango.BL.Entities; +using Tango.Core.Commands; +using Tango.PPC.Common; +using Tango.PPC.Common.Navigation; +using Tango.Settings; + +namespace Tango.PPC.Jobs.ViewModels +{ + public class TwineCatalogViewVM : PPCViewModel, INavigationResultProvider<CatalogItem, BrushStop> + { + private bool _confirmed; + + private Catalog _catalog; + public Catalog Catalog + { + get { return _catalog; } + set { _catalog = value; RaisePropertyChangedAuto(); } + } + + private Catalog _recent; + public Catalog Recent + { + get { return _recent; } + set { _recent = value; RaisePropertyChangedAuto(); } + } + + private CatalogItem _selectedItem; + public CatalogItem SelectedItem + { + get { return _selectedItem; } + set + { + _selectedItem = value; RaisePropertyChangedAuto(); + } + } + + public RelayCommand OKCommand { get; set; } + + public TwineCatalogViewVM() + { + OKCommand = new RelayCommand(Confirm); + } + + public override void OnApplicationStarted() + { + Catalog = CatalogLoader.LoadCatalog(BL.Enumerations.ColorSpaces.Twine, ObservablesEntitiesAdapter.Instance.Context); + Recent = CatalogLoader.GetRecent(Catalog, SettingsManager.Default.GetOrCreate<JobsModuleSettings>().RecentTwineCatalogColors); + } + + public override void OnNavigatedTo() + { + base.OnNavigatedTo(); + _confirmed = false; + } + + private void Confirm() + { + SettingsManager.Default.GetOrCreate<JobsModuleSettings>().RecentTwineCatalogColors.Add(SelectedItem.Entity.Guid); + SettingsManager.Default.Save(); + Recent = CatalogLoader.GetRecent(Catalog, SettingsManager.Default.GetOrCreate<JobsModuleSettings>().RecentTwineCatalogColors); + + _confirmed = true; + NavigationManager.NavigateBack(); + } + + public CatalogItem GetNavigationResult() + { + if (_confirmed) + { + return SelectedItem; + } + else + { + return null; + } + } + + public virtual void OnNavigationObjectReceived(BrushStop brushStop) + { + if (brushStop.ColorCatalog != null) + { + SelectedItem = Catalog.Groups.SelectMany(x => x.Items).SingleOrDefault(x => x.Entity.Guid == brushStop.ColorCatalog.Guid); + } + else + { + SelectedItem = null; + } + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml index 610d3f61f..a55e5a7d3 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml @@ -52,6 +52,10 @@ <touch:TouchNumericTextBox Margin="2 0" HorizontalContentAlignment="Center" Value="{Binding B}" keyboard:KeyboardView.Container="{Binding ElementName=Container}" HasDecimalPoint="True" Minimum="-128" Maximum="128" StringFormat="0.00" /> </UniformGrid> </DataTemplate> + + <DataTemplate x:Key="TWINE_Template" DataType="{x:Type entities:BrushStop}"> + <touch:TouchTextBox TapCommand="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.TwineCatalogFieldTapCommand}" TapCommandParameter="{Binding}" IsReadOnly="True" keyboard:KeyboardView.Mode="{x:Null}" Margin="2 0" Text="{Binding ColorCatalog.Name}" keyboard:KeyboardView.Container="{Binding ElementName=Container}" /> + </DataTemplate> </UserControl.Resources> <Grid Background="{StaticResource TangoMidBackgroundBrush}"> @@ -248,6 +252,9 @@ <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.Job.ColorSpace.Name}" Value="LAB"> <Setter Property="ContentTemplate" Value="{StaticResource LAB_Template}" /> </DataTrigger> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.Job.ColorSpace.Name}" Value="Twine"> + <Setter Property="ContentTemplate" Value="{StaticResource TWINE_Template}" /> + </DataTrigger> </Style.Triggers> </Style> </ContentControl.Style> @@ -375,6 +382,9 @@ <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.Job.ColorSpace.Name}" Value="LAB"> <Setter Property="ContentTemplate" Value="{StaticResource LAB_Template}" /> </DataTrigger> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.Job.ColorSpace.Name}" Value="Twine"> + <Setter Property="ContentTemplate" Value="{StaticResource TWINE_Template}" /> + </DataTrigger> </Style.Triggers> </Style> </ContentControl.Style> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/MainView.xaml index e2ab2c26f..6de05b01b 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/MainView.xaml @@ -15,6 +15,7 @@ <views:JobsView /> <views:JobSummeryView /> <views:JobView /> + <views:TwineCatalogView /> <views:TwineCatalogColorCorrectionView /> </controls:NavigationControl> </Grid> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/TwineCatalogView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/TwineCatalogView.xaml new file mode 100644 index 000000000..3a29c3dd2 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/TwineCatalogView.xaml @@ -0,0 +1,37 @@ +<UserControl x:Class="Tango.PPC.Jobs.Views.TwineCatalogView" + 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:vm="clr-namespace:Tango.PPC.Jobs.ViewModels" + xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" + xmlns:controls="clr-namespace:Tango.PPC.Jobs.Controls" + xmlns:global="clr-namespace:Tango.PPC.Jobs" + xmlns:local="clr-namespace:Tango.PPC.Jobs.Views" + mc:Ignorable="d" + d:DesignHeight="1280" d:DesignWidth="800" Background="{StaticResource TangoPrimaryBackgroundBrush}" d:DataContext="{d:DesignInstance Type=vm:TwineCatalogViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.TwineCatalogViewVM}"> + <Grid> + <Grid Background="{StaticResource TangoMidBackgroundBrush}"> + <Grid.RowDefinitions> + <RowDefinition Height="Auto"/> + <RowDefinition Height="1*"/> + </Grid.RowDefinitions> + + <Border Padding="20" Background="{StaticResource TangoPrimaryBackgroundBrush}" BorderThickness="0 0 0 1" BorderBrush="{StaticResource TangoDividerBrush}"> + <TextBlock VerticalAlignment="Center" FontSize="{StaticResource TangoHeaderFontSize}" FontWeight="SemiBold">Twine Catalog</TextBlock> + </Border> + + <Grid Grid.Row="1"> + <DockPanel Margin="10"> + <Border DockPanel.Dock="Bottom" Height="100"> + <touch:TouchButton Command="{Binding OKCommand}" HorizontalAlignment="Right" VerticalAlignment="Center" Content="OK" Height="50" Width="150" Style="{StaticResource TangoHollowButton}" Margin="0 0 20 0" /> + </Border> + + <Border Style="{StaticResource TangoTouchBorder}" Padding="20 20 20 100" Margin="0 10 0 0"> + <controls:TwineCatalogViewer Catalog="{Binding Catalog}" Recent="{Binding Recent}" SelectedItem="{Binding SelectedItem,Mode=TwoWay}" /> + </Border> + </DockPanel> + </Grid> + </Grid> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/TwineCatalogView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/TwineCatalogView.xaml.cs new file mode 100644 index 000000000..57600322f --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/TwineCatalogView.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.PPC.Jobs.Views +{ + /// <summary> + /// Interaction logic for TwineCatalogColorCorrectionView.xaml + /// </summary> + public partial class TwineCatalogView : UserControl + { + public TwineCatalogView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs index d26f4d396..448fc0edc 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs @@ -171,11 +171,18 @@ namespace Tango.PPC.UI.Navigation await Task.Delay(100); var v = moduleNavigation.NavigateTo(view); - _currentVM = v.DataContext; + if (v != null) + { + _currentVM = v.DataContext; - if (view != path.Last()) + if (view != path.Last()) + { + moduleNavigation = v.FindChildOffline<NavigationControl>(); + } + } + else { - moduleNavigation = v.FindChildOffline<NavigationControl>(); + throw new ArgumentNullException("Could not navigate to " + fullPath); } } |
