aboutsummaryrefslogtreecommitdiffstats
path: root/Software
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-06-27 16:42:04 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-06-27 16:42:04 +0300
commitf99f56c619bed96ab7b75be8477dec6e504bad7e (patch)
tree9fafdfb4e9fd62e4b7c1c1df2f1297b51a6f1688 /Software
parent90e05a52a1a6a3b7f5bce8a619dd4e50ea10575d (diff)
downloadTango-f99f56c619bed96ab7b75be8477dec6e504bad7e.tar.gz
Tango-f99f56c619bed96ab7b75be8477dec6e504bad7e.zip
Implemented segment & brush stop remove.
Diffstat (limited to 'Software')
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/JobSummeryViewer.xaml12
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs41
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml5
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml1
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs7
-rw-r--r--Software/Visual_Studio/Tango.BL/EntitiesExtensions/Segment.cs9
-rw-r--r--Software/Visual_Studio/Tango.Settings/SettingsManager.cs8
7 files changed, 79 insertions, 4 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/JobSummeryViewer.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/JobSummeryViewer.xaml
index c674b57fe..48116c581 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/JobSummeryViewer.xaml
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/JobSummeryViewer.xaml
@@ -34,7 +34,17 @@
</Grid.Width>
<TextBlock HorizontalAlignment="Center" FontSize="{StaticResource TangoSmallFontSize}">
- <Run Text="{Binding Length,Mode=OneWay,StringFormat=N0}"></Run><Run Text="m"></Run>
+ <TextBlock.Style>
+ <Style TargetType="TextBlock">
+ <Setter Property="Visibility" Value="Visible"></Setter>
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=Grid},Path=ActualWidth,Converter={StaticResource SmallerThanToBooleanConverter},ConverterParameter=20}" Value="True">
+ <Setter Property="Visibility" Value="Collapsed"></Setter>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </TextBlock.Style>
+ <Run Text="{Binding Length,Mode=OneWay,StringFormat=N0}"></Run><Run Text="m"></Run>
</TextBlock>
</Grid>
</DataTemplate>
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 90e404307..5edab6255 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
@@ -131,6 +131,16 @@ namespace Tango.PPC.Jobs.ViewModels
/// </summary>
public RelayCommand<DropEventArgs> SegmentDroppedCommand { get; set; }
+ /// <summary>
+ /// Gets or sets the remove segment command.
+ /// </summary>
+ public RelayCommand<Segment> RemoveSegmentCommand { get; set; }
+
+ /// <summary>
+ /// Gets or sets the remove brush stop command.
+ /// </summary>
+ public RelayCommand<BrushStop> RemoveBrushStopCommand { get; set; }
+
#endregion
#region Constructors
@@ -157,6 +167,9 @@ namespace Tango.PPC.Jobs.ViewModels
(e.Draggable as FrameworkElement).DataContext as Segment,
(e.Droppable as FrameworkElement).DataContext as Segment);
});
+
+ RemoveSegmentCommand = new RelayCommand<Segment>(RemoveSegment);
+ RemoveBrushStopCommand = new RelayCommand<BrushStop>(RemoveBrushStop);
}
#endregion
@@ -205,6 +218,18 @@ namespace Tango.PPC.Jobs.ViewModels
SegmentsCollectionView.Refresh();
}
+ /// <summary>
+ /// Removes the segment.
+ /// </summary>
+ /// <param name="segment">The segment.</param>
+ private async void RemoveSegment(Segment segment)
+ {
+ if (await NotificationProvider.ShowQuestion("Are you sure you want to remove the selected segment?"))
+ {
+ Job.Segments.Remove(segment);
+ }
+ }
+
#endregion
#region Brush Stops Management
@@ -218,6 +243,22 @@ namespace Tango.PPC.Jobs.ViewModels
segment.AddBrushStop();
}
+ /// <summary>
+ /// Removes the brush stop.
+ /// </summary>
+ /// <param name="brushStop">The brush stop.</param>
+ private void RemoveBrushStop(BrushStop brushStop)
+ {
+ if (brushStop.Segment.BrushStops.Count > 2)
+ {
+ brushStop.Segment.BrushStops.Remove(brushStop);
+ }
+ else
+ {
+ NotificationProvider.ShowInfo("Gradient segments must contain at least two colors.");
+ }
+ }
+
#endregion
#region Job Selection Message
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 26a0db10f..e9fb4cde4 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
@@ -163,7 +163,7 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
- <Grid Background="Transparent" dragAndDrop:DragAndDropService.Draggable="True" dragAndDrop:DragAndDropService.Droppable="True" dragAndDrop:DragAndDropService.DraggingSurface="{Binding ElementName=DraggingSurface}">
+ <Grid Background="Transparent" dragAndDrop:DragAndDropService.DropCommand="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.SegmentDroppedCommand}" dragAndDrop:DragAndDropService.Draggable="True" dragAndDrop:DragAndDropService.Droppable="True" dragAndDrop:DragAndDropService.DraggingSurface="{Binding ElementName=DraggingSurface}">
<Grid.Style>
<Style TargetType="Grid">
<Setter Property="Opacity" Value="1"></Setter>
@@ -269,7 +269,7 @@
</TextBlock.Style>
</TextBlock>
<StackPanel Visibility="{Binding ElementName=toggleEdit,Path=IsChecked,Converter={StaticResource BooleanToVisibilityConverter}}" Orientation="Horizontal">
- <touch:TouchIconButton EnableDropShadow="False" Icon="TrashOutline" Padding="12" Foreground="{StaticResource TangoPrimaryAccentBrush}" Width="50" Height="50" RippleBrush="{StaticResource TangoRippleDarkBrush}" CornerRadius="30" />
+ <touch:TouchIconButton Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.RemoveSegmentCommand}" CommandParameter="{Binding}" EnableDropShadow="False" Icon="TrashOutline" Padding="12" Foreground="{StaticResource TangoPrimaryAccentBrush}" Width="50" Height="50" RippleBrush="{StaticResource TangoRippleDarkBrush}" CornerRadius="30" />
<dragAndDrop:DragThumb Background="Transparent" IsHitTestVisible="True">
<touch:TouchIconButton IsHitTestVisible="False" EnableDropShadow="False" Icon="Bars" Padding="15" Foreground="{StaticResource TangoPrimaryAccentBrush}" Width="50" Height="50" RippleBrush="{StaticResource TangoRippleDarkBrush}" CornerRadius="30" />
@@ -350,6 +350,7 @@
</Grid>
</DockPanel>
</StackPanel>
+ <touch:TouchIconButton Visibility="{Binding ElementName=toggleEdit,Path=IsChecked,Converter={StaticResource BooleanToVisibilityConverter}}" Margin="0 0 -80 0" HorizontalAlignment="Right" VerticalAlignment="Top" Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.RemoveBrushStopCommand}" CommandParameter="{Binding}" EnableDropShadow="False" Icon="TrashOutline" Padding="12" Foreground="{StaticResource TangoPrimaryAccentBrush}" Width="50" Height="50" RippleBrush="{StaticResource TangoRippleDarkBrush}" CornerRadius="30" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml
index 5c03af129..c8041863b 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml
@@ -32,6 +32,7 @@
<converters:SegmentLengthToWidthConverter x:Key="SegmentLengthToWidthConverter" />
<converters:WidthHeightToRectConverter x:Key="WidthHeightToRectConverter" />
<converters:OneToPercentConverter x:Key="OneToPercentConverter" />
+ <converters:SmallerThanToBooleanConverter x:Key="SmallerThanToBooleanConverter" />
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs
index c8dc68291..f823e88aa 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs
@@ -126,7 +126,12 @@ namespace Tango.PPC.UI.PPCApplication
File.Copy(Path.Combine(PathHelper.GetStartupPath(), "DB", "Tango.mdf"), CoreSettings.DefaultDataBaseSource);
}
- var settings = SettingsManager.Default.GetOrCreate<PPCSettings>(); ;
+ var settings = SettingsManager.Default.GetOrCreate<PPCSettings>();
+
+ if (!SettingsManager.Default.IsFileExists())
+ {
+ settings.Save();
+ }
ObservablesEntitiesAdapter.Instance.Initialize();
Machine = ObservablesEntitiesAdapter.Instance.Machines.FirstOrDefault();
diff --git a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Segment.cs b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Segment.cs
index a667b4a42..61fd35558 100644
--- a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Segment.cs
+++ b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Segment.cs
@@ -57,6 +57,15 @@ namespace Tango.BL.Entities
stop.RaiseOffsetChanged();
}
+ if (BrushStops.Count > 0)
+ {
+ BrushStops.First().OffsetPercent = 0;
+ }
+ if (BrushStops.Count > 1)
+ {
+ BrushStops.Last().OffsetPercent = 100;
+ }
+
RaiseSegmentBrushChanged();
}
diff --git a/Software/Visual_Studio/Tango.Settings/SettingsManager.cs b/Software/Visual_Studio/Tango.Settings/SettingsManager.cs
index a9c5429de..34ac2ddfe 100644
--- a/Software/Visual_Studio/Tango.Settings/SettingsManager.cs
+++ b/Software/Visual_Studio/Tango.Settings/SettingsManager.cs
@@ -116,6 +116,14 @@ namespace Tango.Settings
}
/// <summary>
+ /// Determines whether a settings file exists.
+ /// </summary>
+ public virtual bool IsFileExists()
+ {
+ return File.Exists(FilePath);
+ }
+
+ /// <summary>
/// Saves settings.
/// </summary>
public virtual void Save()