diff options
| author | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2023-09-10 15:00:28 +0300 |
|---|---|---|
| committer | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2023-09-10 15:01:40 +0300 |
| commit | 3c0b20184527064f1c5d9374894f3d9ec44672e3 (patch) | |
| tree | 9d1c94b30a1455ca3b84cf760839ff4ddaebbd90 /Software/Visual_Studio/PPC/Modules | |
| parent | e0edf9de24600db0242952064475fbbde157ccaf (diff) | |
| download | Tango-3c0b20184527064f1c5d9374894f3d9ec44672e3.tar.gz Tango-3c0b20184527064f1c5d9374894f3d9ec44672e3.zip | |
Add My Color - add command to save on OK, added name and selection to ListBox. libraries
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules')
3 files changed, 96 insertions, 19 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml index e737a8f7a..3ec03eff7 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml @@ -51,7 +51,7 @@ <Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}"> <touch:TouchScrollViewer CanContentScroll="True" Padding="{TemplateBinding Padding}" Focusable="False" Style="{StaticResource TouchVerticalScrollViewer}"> - <ItemsPresenter /> + <ItemsPresenter HorizontalAlignment="Stretch"/> </touch:TouchScrollViewer> </Border> </ControlTemplate> @@ -170,7 +170,7 @@ </Grid> <Canvas Grid.Column="1" Width="28" Height="28" VerticalAlignment="Top" HorizontalAlignment="Left"> - <touch:TouchToggleButton Canvas.Left="0" Canvas.Top="0" x:Name="addColorToGroup" EnableDropShadow="False" Foreground="{StaticResource TangoKeyboardKeyDarkTextBrush}" Background="Transparent" BorderThickness="0" Command="{Binding SaveMyColorsCommand}" > + <touch:TouchToggleButton Canvas.Left="0" Canvas.Top="0" x:Name="addColorToGroup" EnableDropShadow="False" Foreground="{StaticResource TangoKeyboardKeyDarkTextBrush}" Background="Transparent" BorderThickness="0" Command="{Binding OpenCloseAddMyColorDialogCommand}" > <touch:TouchToggleButton.Style> <Style TargetType="touch:TouchToggleButton" BasedOn="{StaticResource TangoTouchToggleButtonNoDisable}"> <Setter Property="IsEnabled" Value="True"/> @@ -376,18 +376,31 @@ <touch:TouchTextBox Width="220" Height="40" FontSize="{StaticResource TangoButtonFontSize}" Margin=" 20 0 10 0" Text="{Binding MyColorName}" FocusSelectionMode="SelectAll"></touch:TouchTextBox> </StackPanel> <Grid Margin="14 10 14 10" > - <ListBox HorizontalAlignment="Stretch" MaxHeight="220" ItemsSource="{Binding Libraries}" Style="{StaticResource ListBoxVerticalScroll}" - ScrollViewer.VerticalScrollBarVisibility="Visible" > + <ListBox HorizontalAlignment="Stretch" MaxHeight="220" ItemsSource="{Binding Libraries}" Style="{StaticResource ListBoxVerticalScroll}" SelectedItem="{Binding SelectedColorLibraryMyColor}" + ScrollViewer.VerticalScrollBarVisibility="Visible" HorizontalContentAlignment="Stretch" ScrollViewer.HorizontalScrollBarVisibility="Disabled"> <ListBox.ItemsPanel> <ItemsPanelTemplate> - <WrapPanel Orientation="Vertical" /> + <UniformGrid Columns="1" VerticalAlignment="Top" /> </ItemsPanelTemplate> </ListBox.ItemsPanel> <ListBox.ItemTemplate> <DataTemplate DataType="{x:Type models:ColorLibrary}"> - <touch:TouchButton Command="{Binding DataContext.AddColorToLibraryCommand, ElementName=colorSelectionView}" Style="{StaticResource TangoFlatButton}" CommandParameter="{Binding }" Background="Transparent"> - <TextBlock Text="{Binding Name}" FontSize="{StaticResource TangoButtonFontSize}"></TextBlock> - </touch:TouchButton> + <Grid HorizontalAlignment="Stretch" > + <Grid.Style > + <Style TargetType="Grid"> + <Setter Property="Background" Value="Transparent"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding IsSelected}" Value="True"> + <Setter Property="Background" Value="{StaticResource TangoLightSelectedBrush}"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </Grid.Style> + + <touch:TouchButton Command="{Binding DataContext.SelectLibraryCommand, ElementName=colorSelectionView}" Style="{StaticResource TangoFlatButton}" CommandParameter="{Binding }" Background="Transparent"> + <TextBlock Text="{Binding Name}" FontSize="{StaticResource TangoButtonFontSize}"></TextBlock> + </touch:TouchButton> + </Grid> </DataTemplate> </ListBox.ItemTemplate> </ListBox> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionViewVM.cs index 3146da179..37f5c3f7b 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionViewVM.cs @@ -323,6 +323,24 @@ namespace Tango.PPC.Jobs.Dialogs private ColorLibrary SelectedColorLibrary { get; set; } + private ColorLibrary _selectedColorLibraryMyColor; + + public ColorLibrary SelectedColorLibraryMyColor + { + get { return _selectedColorLibraryMyColor; } + set { + if(_selectedColorLibraryMyColor != null) + _selectedColorLibraryMyColor.IsSelected = false; + + _selectedColorLibraryMyColor = value; + + if (_selectedColorLibraryMyColor != null) + _selectedColorLibraryMyColor.IsSelected = true; + RaisePropertyChangedAuto(); + } + } + + private FavoriteColor _selectedColor; public FavoriteColor SelectedColor @@ -446,10 +464,11 @@ namespace Tango.PPC.Jobs.Dialogs /// <summary> /// Gets or sets the save my colors command. /// </summary> + public RelayCommand OpenCloseAddMyColorDialogCommand { get; set; } public RelayCommand SaveMyColorsCommand { get; set; } public RelayCommand<string> AddNewGroupCommand { get; set; } public RelayCommand<string> AddNewGroupAndColorCommand { get; set; } - public RelayCommand<ColorLibrary> AddColorToLibraryCommand { get; set; } + public RelayCommand<ColorLibrary> SelectLibraryCommand { get; set; } /// <summary> /// Gets or sets the open my colors command. @@ -501,6 +520,7 @@ namespace Tango.PPC.Jobs.Dialogs } }); + OpenCloseAddMyColorDialogCommand = new RelayCommand(OpenCloseAddMyColorDialog); SaveMyColorsCommand = new RelayCommand(SaveMyColors); OpenMyColorsCommand = new RelayCommand(() => { MyColorsMode = true; }); CloseMyColorsCommand = new RelayCommand(() => { MyColorsMode = false; SearchColorText = "";}); @@ -508,7 +528,8 @@ namespace Tango.PPC.Jobs.Dialogs AddGroupCommand = new RelayCommand(AddGroup); AddNewGroupCommand = new RelayCommand<string>(AddNewGroup); AddNewGroupAndColorCommand = new RelayCommand<string>(AddNewGroupAndColor); - AddColorToLibraryCommand = new RelayCommand<ColorLibrary>(AddColorToLibrary); + + SelectLibraryCommand = new RelayCommand<ColorLibrary>(SelectLibrary); DeleteGroupCommand = new RelayCommand<ColorLibrary>(DeleteGroup); EditColorsLibraryCommand = new RelayCommand<ColorLibrary>(EditColorsLibrary); EditColorsLibrariesCommand = new RelayCommand(EditColorsLibraries); @@ -824,7 +845,7 @@ namespace Tango.PPC.Jobs.Dialogs #region MyColors - private void SaveMyColors() + private void OpenCloseAddMyColorDialog() { if(IsBusy) return; @@ -866,17 +887,37 @@ namespace Tango.PPC.Jobs.Dialogs else { SaveMyColorMode = !SaveMyColorMode; + //Init MyColorName on open the dialog String colorName = "MyColor"; - if (SelectedBrushStop != null && SelectedBrushStop.SegmentModel != null - && SelectedBrushStop.SegmentModel.Job != null) + if ( SelectedBrushStop != null && SelectedBrushStop.SegmentModel != null && SelectedBrushStop.SegmentModel.Job != null ) { colorName = SelectedBrushStop.SegmentModel.Job.Name; if(colorName.Length > 40) colorName = colorName.Substring(0, 40); } MyColorName = colorName; + SelectedColorLibraryMyColor = null; + AddGroupMode = false; } - + IsBusy = false; + + } + + /// <summary> + /// Saves my colors on OK button of dialog "Add my Color" + /// </summary> + private void SaveMyColors() + { + if (IsBusy) + return; + IsBusy = true; + if (SelectedColorLibraryMyColor != null) + { + AddColorToLibrary(SelectedColorLibraryMyColor); + } + SelectedColorLibraryMyColor = null; + AddGroupMode = false; + SaveMyColorMode = false; IsBusy = false; } @@ -932,14 +973,15 @@ namespace Tango.PPC.Jobs.Dialogs { NotificationProvider.ShowInfo("A group with this name already exists. Try adding a different name."); } + SelectedColorLibrary = library; - AddColorToLibrary(library); + // AddColorToLibrary(library); } NewGroupName = "Library" + (Libraries.Count() + 1); - SaveMyColorMode = false; - AddGroupMode = false; + //SaveMyColorMode = false; + //AddGroupMode = false; } - + /// <summary> /// Adds the selected color to library in Save my Colors. /// </summary> @@ -985,6 +1027,11 @@ namespace Tango.PPC.Jobs.Dialogs SaveMyColorMode = false; } + private void SelectLibrary(ColorLibrary library) + { + SelectedColorLibraryMyColor = library; + } + private void SelectColor(FavoriteColor favoriteColor) { SelectedColor = favoriteColor; diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/ColorLibrary.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/ColorLibrary.cs index 62dc7ec1b..284b2c787 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/ColorLibrary.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/ColorLibrary.cs @@ -16,6 +16,7 @@ namespace Tango.PPC.Jobs.Models { public class ColorLibrary: ExtendedObject { + #region Properties private ObservableCollection<FavoriteColor> _colorList; public ObservableCollection<FavoriteColor> ColorList { @@ -51,7 +52,23 @@ namespace Tango.PPC.Jobs.Models OnEditGroupModeChanged(); RaisePropertyChangedAuto(); } } - + + private bool _isSelected; + [BsonIgnore] + public bool IsSelected + { + get { + return _isSelected; + } + set { + _isSelected = value; + RaisePropertyChangedAuto(); + } + } + + + #endregion + public ColorLibrary() { _colorList = new ObservableCollection<FavoriteColor>(); |
