diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2018-06-15 23:18:51 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2018-06-15 23:18:51 +0300 |
| commit | f0bcdcdbfa78ba705b8fa44591fa594a425352a9 (patch) | |
| tree | d5476a7259fc5d6061d819ae5f1df5b78c904856 /Software/Visual_Studio | |
| parent | 84700eb44cffe4b503a9ad22b1dfa8c703f356d2 (diff) | |
| download | Tango-f0bcdcdbfa78ba705b8fa44591fa594a425352a9.tar.gz Tango-f0bcdcdbfa78ba705b8fa44591fa594a425352a9.zip | |
Implemented TouchLoadingPanel
Diffstat (limited to 'Software/Visual_Studio')
8 files changed, 218 insertions, 102 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs index fabb57d10..3cbb44bbe 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs @@ -53,6 +53,17 @@ namespace Tango.PPC.Jobs.ViewModels } } + private bool _isLoadingJobs; + /// <summary> + /// Gets or sets a value indicating whether this instance is loading jobs. + /// </summary> + public bool IsLoadingJobs + { + get { return _isLoadingJobs; } + set { _isLoadingJobs = value; RaisePropertyChangedAuto(); } + } + + #endregion #region Commands @@ -139,6 +150,8 @@ namespace Tango.PPC.Jobs.ViewModels { Task.Factory.StartNew(() => { + IsLoadingJobs = true; + Thread.Sleep(500); if (_jobsContext != null) @@ -151,6 +164,8 @@ namespace Tango.PPC.Jobs.ViewModels Jobs = _jobsContext.Jobs.Where(x => x.Machine.SerialNumber == Settings.MachineSerialNumber).ToObservableCollection(); JobsCollectionView = CollectionViewSource.GetDefaultView(Jobs); JobsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Job.LastUpdated), ListSortDirection.Descending)); + + IsLoadingJobs = false; }); } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml index 1686aef84..63e65f777 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml @@ -23,7 +23,7 @@ <converters:JobToPieImageConverter x:Key="JobToPieImageConverter" /> <sharedConverters:DateTimeUTCToShortDateConverter x:Key="DateTimeUTCToShortDateConverter" /> <sharedConverters:EnumToDescriptionConverter x:Key="EnumToDescriptionConverter" /> - + </UserControl.Resources> <Grid Background="{StaticResource TangoMidBackgroundBrush}"> @@ -58,98 +58,100 @@ </touch:TouchNavigationLinks> <Grid Grid.Row="1"> - <touch:LightTouchDataGrid x:Name="dataGridJobs" OnDragAndDropCommand="{Binding JobDragedDroppedCommand}" ItemsSource="{Binding JobsCollectionView}" ItemSelectedCommand="{Binding JobSelectedCommand}" Margin="10"> - <touch:LightTouchDataGrid.Columns> - <touch:LightTouchDataGridColumn Width="50"> - <touch:LightTouchDataGridColumn.Header> - <Image Source="../Images/warning.png" Width="24" /> - </touch:LightTouchDataGridColumn.Header> - <touch:LightTouchDataGridColumn.CellTemplate> - <DataTemplate> - <Image Source="../Images/Job Issues/cyan.png" Width="38" /> - </DataTemplate> - </touch:LightTouchDataGridColumn.CellTemplate> - </touch:LightTouchDataGridColumn> - <touch:LightTouchDataGridColumn Width="100" Header="Status" SortMember="JobStatus"> - <touch:LightTouchDataGridColumn.CellTemplate> - <DataTemplate> - <TextBlock IsHitTestVisible="False" Text="{Binding JobStatus,Converter={StaticResource EnumToDescriptionConverter}}"></TextBlock> - </DataTemplate> - </touch:LightTouchDataGridColumn.CellTemplate> - </touch:LightTouchDataGridColumn> - <touch:LightTouchDataGridColumn Width="1*" Header="Name" SortMember="Name" HorizontalContentAlignment="Left"> - <touch:LightTouchDataGridColumn.CellTemplate> - <DataTemplate> - <TextBlock IsHitTestVisible="False" Text="{Binding Name}"></TextBlock> - </DataTemplate> - </touch:LightTouchDataGridColumn.CellTemplate> - </touch:LightTouchDataGridColumn> - <touch:LightTouchDataGridColumn Width="117" Header="Length (m)" SortMember="Length"> - <touch:LightTouchDataGridColumn.CellTemplate> - <DataTemplate> - <TextBlock IsHitTestVisible="False" Text="{Binding Length,StringFormat=0.0}"></TextBlock> - </DataTemplate> - </touch:LightTouchDataGridColumn.CellTemplate> - </touch:LightTouchDataGridColumn> - <touch:LightTouchDataGridColumn Header="Colors" SortMember="Segments.Count" Width="85"> - <touch:LightTouchDataGridColumn.CellTemplate> - <DataTemplate> - <Image Stretch="Fill" IsHitTestVisible="False" Source="{Binding Converter={StaticResource JobToPieImageConverter},ConverterParameter='25,25'}" Width="25" Height="25" HorizontalAlignment="Left"></Image> - </DataTemplate> - </touch:LightTouchDataGridColumn.CellTemplate> - </touch:LightTouchDataGridColumn> - <touch:LightTouchDataGridColumn Width="100" Header="Updated" SortMember="LastUpdated"> - <touch:LightTouchDataGridColumn.CellTemplate> - <DataTemplate> - <TextBlock IsHitTestVisible="False" Text="{Binding LastUpdated,Converter={StaticResource DateTimeUTCToShortDateConverter}}"></TextBlock> - </DataTemplate> - </touch:LightTouchDataGridColumn.CellTemplate> - </touch:LightTouchDataGridColumn> - <touch:LightTouchDataGridColumn x:Name="userSortColumn" SortMember="JobIndex" SortDirection="{x:Null}" Width="78" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" DisplayChevron="False" ForcedSortDirection="Ascending"> - <touch:LightTouchDataGridColumn.HeaderTemplate> - <DataTemplate> - <Border CornerRadius="0 5 5 0" x:Name="userSortColumnBorder"> - <Border.Style> - <Style TargetType="Border"> - <Setter Property="Background" Value="{StaticResource TangoMidAccentBrush}"></Setter> - <Style.Triggers> - <DataTrigger Binding="{Binding SortDirection}" Value="Ascending"> - <Setter Property="Background" Value="{StaticResource TangoLowAccentBrush}"></Setter> - </DataTrigger> - </Style.Triggers> - </Style> - </Border.Style> - <Grid> - <Rectangle HorizontalAlignment="Left" StrokeThickness="2" Stroke="{StaticResource TangoColumnDividerBrush}" /> - <Image Source="/Images/arrows.png" Width="28" /> - </Grid> - </Border> - </DataTemplate> - </touch:LightTouchDataGridColumn.HeaderTemplate> - <touch:LightTouchDataGridColumn.CellTemplate> - <DataTemplate> - <dragAndDrop:DragThumb Background="Transparent" touchComponents:Ripple.PreventRipple="True" touchComponents:TransformationHelper.PreventTransform="True"> - <dragAndDrop:DragThumb.Style> - <Style TargetType="dragAndDrop:DragThumb"> - <Setter Property="Visibility" Value="Collapsed"></Setter> - <Style.Triggers> - <DataTrigger Binding="{Binding Source={x:Reference userSortColumn},Path=SortDirection}" Value="Ascending"> - <Setter Property="Visibility" Value="Visible"></Setter> - </DataTrigger> - </Style.Triggers> - </Style> - </dragAndDrop:DragThumb.Style> - <StackPanel Width="30" IsHitTestVisible="False" VerticalAlignment="Center"> - <Rectangle StrokeThickness="2" Stroke="{StaticResource TangoDarkForegroundBrush}" /> - <Rectangle StrokeThickness="2" Stroke="{StaticResource TangoDarkForegroundBrush}" Margin="0 5 0 0" /> - </StackPanel> - </dragAndDrop:DragThumb> - </DataTemplate> - </touch:LightTouchDataGridColumn.CellTemplate> - </touch:LightTouchDataGridColumn> - </touch:LightTouchDataGrid.Columns> - </touch:LightTouchDataGrid> + <touch:TouchLoadingPanel IsLoading="{Binding IsLoadingJobs}"> + <touch:LightTouchDataGrid x:Name="dataGridJobs" OnDragAndDropCommand="{Binding JobDragedDroppedCommand}" ItemsSource="{Binding JobsCollectionView}" ItemSelectedCommand="{Binding JobSelectedCommand}" Margin="10"> + <touch:LightTouchDataGrid.Columns> + <touch:LightTouchDataGridColumn Width="50"> + <touch:LightTouchDataGridColumn.Header> + <Image Source="../Images/warning.png" Width="24" /> + </touch:LightTouchDataGridColumn.Header> + <touch:LightTouchDataGridColumn.CellTemplate> + <DataTemplate> + <Image Source="../Images/Job Issues/cyan.png" Width="38" /> + </DataTemplate> + </touch:LightTouchDataGridColumn.CellTemplate> + </touch:LightTouchDataGridColumn> + <touch:LightTouchDataGridColumn Width="100" Header="Status" SortMember="JobStatus"> + <touch:LightTouchDataGridColumn.CellTemplate> + <DataTemplate> + <TextBlock IsHitTestVisible="False" Text="{Binding JobStatus,Converter={StaticResource EnumToDescriptionConverter}}"></TextBlock> + </DataTemplate> + </touch:LightTouchDataGridColumn.CellTemplate> + </touch:LightTouchDataGridColumn> + <touch:LightTouchDataGridColumn Width="1*" Header="Name" SortMember="Name" HorizontalContentAlignment="Left"> + <touch:LightTouchDataGridColumn.CellTemplate> + <DataTemplate> + <TextBlock IsHitTestVisible="False" Text="{Binding Name}"></TextBlock> + </DataTemplate> + </touch:LightTouchDataGridColumn.CellTemplate> + </touch:LightTouchDataGridColumn> + <touch:LightTouchDataGridColumn Width="117" Header="Length (m)" SortMember="Length"> + <touch:LightTouchDataGridColumn.CellTemplate> + <DataTemplate> + <TextBlock IsHitTestVisible="False" Text="{Binding Length,StringFormat=0.0}"></TextBlock> + </DataTemplate> + </touch:LightTouchDataGridColumn.CellTemplate> + </touch:LightTouchDataGridColumn> + <touch:LightTouchDataGridColumn Header="Colors" SortMember="Segments.Count" Width="85"> + <touch:LightTouchDataGridColumn.CellTemplate> + <DataTemplate> + <Image Stretch="Fill" IsHitTestVisible="False" Source="{Binding Converter={StaticResource JobToPieImageConverter},ConverterParameter='25,25'}" Width="25" Height="25" HorizontalAlignment="Left"></Image> + </DataTemplate> + </touch:LightTouchDataGridColumn.CellTemplate> + </touch:LightTouchDataGridColumn> + <touch:LightTouchDataGridColumn Width="100" Header="Updated" SortMember="LastUpdated"> + <touch:LightTouchDataGridColumn.CellTemplate> + <DataTemplate> + <TextBlock IsHitTestVisible="False" Text="{Binding LastUpdated,Converter={StaticResource DateTimeUTCToShortDateConverter}}"></TextBlock> + </DataTemplate> + </touch:LightTouchDataGridColumn.CellTemplate> + </touch:LightTouchDataGridColumn> + <touch:LightTouchDataGridColumn x:Name="userSortColumn" SortMember="JobIndex" SortDirection="{x:Null}" Width="78" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" DisplayChevron="False" ForcedSortDirection="Ascending"> + <touch:LightTouchDataGridColumn.HeaderTemplate> + <DataTemplate> + <Border CornerRadius="0 5 5 0" x:Name="userSortColumnBorder"> + <Border.Style> + <Style TargetType="Border"> + <Setter Property="Background" Value="{StaticResource TangoMidAccentBrush}"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding SortDirection}" Value="Ascending"> + <Setter Property="Background" Value="{StaticResource TangoLowAccentBrush}"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </Border.Style> + <Grid> + <Rectangle HorizontalAlignment="Left" StrokeThickness="2" Stroke="{StaticResource TangoColumnDividerBrush}" /> + <Image Source="/Images/arrows.png" Width="28" /> + </Grid> + </Border> + </DataTemplate> + </touch:LightTouchDataGridColumn.HeaderTemplate> + <touch:LightTouchDataGridColumn.CellTemplate> + <DataTemplate> + <dragAndDrop:DragThumb Background="Transparent" touchComponents:Ripple.PreventRipple="True" touchComponents:TransformationHelper.PreventTransform="True"> + <dragAndDrop:DragThumb.Style> + <Style TargetType="dragAndDrop:DragThumb"> + <Setter Property="Visibility" Value="Collapsed"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding Source={x:Reference userSortColumn},Path=SortDirection}" Value="Ascending"> + <Setter Property="Visibility" Value="Visible"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </dragAndDrop:DragThumb.Style> + <StackPanel Width="30" IsHitTestVisible="False" VerticalAlignment="Center"> + <Rectangle StrokeThickness="2" Stroke="{StaticResource TangoDarkForegroundBrush}" /> + <Rectangle StrokeThickness="2" Stroke="{StaticResource TangoDarkForegroundBrush}" Margin="0 5 0 0" /> + </StackPanel> + </dragAndDrop:DragThumb> + </DataTemplate> + </touch:LightTouchDataGridColumn.CellTemplate> + </touch:LightTouchDataGridColumn> + </touch:LightTouchDataGrid.Columns> + </touch:LightTouchDataGrid> + </touch:TouchLoadingPanel> <TextBox VerticalAlignment="Bottom" HorizontalAlignment="Center" Margin="100" Width="200" keyboard:KeyboardView.Mode="Alpha"></TextBox> </Grid> </Grid> 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 233751ddb..554bd704c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs @@ -128,10 +128,8 @@ namespace Tango.PPC.UI.PPCApplication var settings = SettingsManager.Default.GetOrCreate<PPCSettings>(); ; - using (ObservablesContext db = ObservablesContext.CreateDefault()) - { - Machine = db.Machines.SingleOrDefault(x => x.SerialNumber == settings.MachineSerialNumber); - } + ObservablesEntitiesAdapter.Instance.Initialize(); + Machine = ObservablesEntitiesAdapter.Instance.Machines.FirstOrDefault(); }); ApplicationStarted?.Invoke(this, new EventArgs()); 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 f6b06ca61..5bc02f829 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs @@ -36,11 +36,6 @@ namespace Tango.PPC.UI.ViewModels /// </summary> public async override void OnApplicationStarted() { - await Task.Factory.StartNew(() => - { - ObservablesEntitiesAdapter.Instance.Initialize(); - }); - ApplicationManager.ModulesInitialized += (_, __) => { NavigationManager.NavigateTo(NavigationView.HomeModule); diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchLoadingPanel.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchLoadingPanel.cs new file mode 100644 index 000000000..bb9745e68 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchLoadingPanel.cs @@ -0,0 +1,41 @@ +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.Touch.Controls +{ + public class TouchLoadingPanel : ContentControl + { + static TouchLoadingPanel() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(TouchLoadingPanel), new FrameworkPropertyMetadata(typeof(TouchLoadingPanel))); + } + + public bool IsLoading + { + get { return (bool)GetValue(IsLoadingProperty); } + set { SetValue(IsLoadingProperty, value); } + } + public static readonly DependencyProperty IsLoadingProperty = + DependencyProperty.Register("IsLoading", typeof(bool), typeof(TouchLoadingPanel), new PropertyMetadata(false)); + + public String LoadingMessage + { + get { return (String)GetValue(LoadingMessageProperty); } + set { SetValue(LoadingMessageProperty, value); } + } + public static readonly DependencyProperty LoadingMessageProperty = + DependencyProperty.Register("LoadingMessage", typeof(String), typeof(TouchLoadingPanel), new PropertyMetadata("Loading...")); + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchLoadingPanel.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchLoadingPanel.xaml new file mode 100644 index 000000000..d4c0c3d80 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchLoadingPanel.xaml @@ -0,0 +1,59 @@ +<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:local="clr-namespace:Tango.Touch.Controls"> + + <ResourceDictionary.MergedDictionaries> + <ResourceDictionary Source="../Resources/Colors.xaml" /> + </ResourceDictionary.MergedDictionaries> + + <Style TargetType="{x:Type local:TouchLoadingPanel}"> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="{x:Type local:TouchLoadingPanel}"> + <Border Background="{TemplateBinding Background}" + BorderBrush="{TemplateBinding BorderBrush}" + BorderThickness="{TemplateBinding BorderThickness}"> + + <Grid> + <ContentPresenter Content="{TemplateBinding Content}" /> + + <Grid Background="#66FFFFFF"> + <Grid.Style> + <Style TargetType="Grid"> + <Setter Property="IsHitTestVisible" Value="False"></Setter> + <Setter Property="Opacity" Value="0"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=local:TouchLoadingPanel},Path=IsLoading}" Value="True"> + <Setter Property="IsHitTestVisible" Value="False"></Setter> + <DataTrigger.EnterActions> + <BeginStoryboard> + <Storyboard> + <DoubleAnimation Storyboard.TargetProperty="Opacity" To="1" Duration="00:00:0.2"></DoubleAnimation> + </Storyboard> + </BeginStoryboard> + </DataTrigger.EnterActions> + <DataTrigger.ExitActions> + <BeginStoryboard> + <Storyboard> + <DoubleAnimation Storyboard.TargetProperty="Opacity" To="0" Duration="00:00:0.1"></DoubleAnimation> + </Storyboard> + </BeginStoryboard> + </DataTrigger.ExitActions> + </DataTrigger> + </Style.Triggers> + </Style> + </Grid.Style> + + <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> + <local:TouchBusyIndicator Foreground="{TemplateBinding Foreground}" IsIndeterminate="True" Width="100" Height="100" HorizontalAlignment="Center" /> + <TextBlock Margin="20" Text="{TemplateBinding LoadingMessage}" HorizontalAlignment="Center" /> + </StackPanel> + </Grid> + </Grid> + </Border> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + +</ResourceDictionary>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj index 9dd79de83..be6c5add3 100644 --- a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj +++ b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj @@ -80,6 +80,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Controls\TouchLoadingPanel.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="Controls\TouchNavigationLinks.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -159,6 +163,7 @@ <Compile Include="Controls\TouchDataGridRow.cs" /> <Compile Include="Controls\TouchHamburgerButton.cs" /> <Compile Include="Controls\TouchIconButton.cs" /> + <Compile Include="Controls\TouchLoadingPanel.cs" /> <Compile Include="Controls\TouchNavigationLinks.cs" /> <Compile Include="Controls\TouchButton.cs" /> <Compile Include="Controls\TouchDataGrid.cs" /> diff --git a/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml b/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml index eed986d3a..26faaa754 100644 --- a/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml +++ b/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml @@ -1,4 +1,4 @@ -<ResourceDictionary +<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:Tango.Touch"> @@ -21,6 +21,7 @@ <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/LightTouchDataGrid.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/LightTouchScrollViewer.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchHamburgerButton.xaml" /> + <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchLoadingPanel.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchToggleButton.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchButton.xaml" /> |
