diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-06-19 14:26:15 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-06-19 14:26:15 +0300 |
| commit | 6f9da1e19024c7c65d7dbd6038cd34776453f9dc (patch) | |
| tree | 5bac3f9154c45ea89310b934c64b0788e0598c54 /Software/Visual_Studio | |
| parent | 62dfa96e0bf7cba8b32a0866a0f8101b1e7ec562 (diff) | |
| download | Tango-6f9da1e19024c7c65d7dbd6038cd34776453f9dc.tar.gz Tango-6f9da1e19024c7c65d7dbd6038cd34776453f9dc.zip | |
Implemented Touch Panel.
Implemented KeyboardView BringToView routine.
Diffstat (limited to 'Software/Visual_Studio')
18 files changed, 508 insertions, 100 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Converters/JobCollectionToCategoryCountConverter.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Converters/JobCollectionToCategoryCountConverter.cs new file mode 100644 index 000000000..3e0cc7898 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Converters/JobCollectionToCategoryCountConverter.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using Tango.BL.Entities; +using Tango.BL.Enumerations; + +namespace Tango.PPC.Jobs.Converters +{ + public class JobCollectionToCategoryCountConverter : IMultiValueConverter + { + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + IList<Job> jobs = values[0] as IList<Job>; + + JobCategories category = (JobCategories)values[1]; + + if (jobs != null) + { + return jobs.Where(x => x.JobCategories.Contains(category)).Count().ToString(); + } + + return "0"; + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} 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 b79d309a8..99e768a24 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 @@ -85,6 +85,7 @@ <Compile Include="..\..\..\Versioning\PPCVersionInfo.cs"> <Link>PPCVersionInfo.cs</Link> </Compile> + <Compile Include="Converters\JobCollectionToCategoryCountConverter.cs" /> <Compile Include="Converters\JobToPieImageConverter.cs" /> <Compile Include="JobsModule.cs" /> <Compile Include="Messages\JobSelectedMessage.cs" /> 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 03ab40cb7..4cb225c2d 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 @@ -25,6 +25,7 @@ <sharedConverters:DateTimeUTCToShortDateConverter x:Key="DateTimeUTCToShortDateConverter" /> <sharedConverters:EnumToDescriptionConverter x:Key="EnumToDescriptionConverter" /> <sharedConverters:EnumToItemsSourceConverter x:Key="EnumToItemsSourceConverter" /> + <converters:JobCollectionToCategoryCountConverter x:Key="JobCollectionToCategoryCountConverter" /> </UserControl.Resources> @@ -102,9 +103,25 @@ <touch:TouchIconButton Padding="20" Icon="Refresh" Style="{StaticResource TangoRoundTouchIconButton}"></touch:TouchIconButton> </StackPanel> - <touch:TouchNavigationLinks SelectedValue="{Binding FilterCategory}" SelectedValuePath="Value" ItemsSource="{Binding Source={x:Type enumerations:JobCategories},Converter={StaticResource EnumToItemsSourceConverter},Mode=OneTime}" DisplayMemberPath="DisplayName" IsEnabled="{Binding IsMultiSelecting,Converter={StaticResource BooleanInverseConverter}}" VerticalAlignment="Bottom" Margin="20" FontSize="{StaticResource TangoNavigationLinksFontSize}"></touch:TouchNavigationLinks> + <touch:TouchNavigationLinks SelectedValue="{Binding FilterCategory}" SelectedValuePath="Value" ItemsSource="{Binding Source={x:Type enumerations:JobCategories},Converter={StaticResource EnumToItemsSourceConverter},Mode=OneTime}" IsEnabled="{Binding IsMultiSelecting,Converter={StaticResource BooleanInverseConverter}}" VerticalAlignment="Bottom" Margin="20" FontSize="{StaticResource TangoNavigationLinksFontSize}"> + <touch:TouchNavigationLinks.ItemTemplate> + <DataTemplate> + <TextBlock> + <Run Text="{Binding DisplayName,Mode=OneWay}"></Run> + <Run>(</Run><Run> + <Run.Text> + <MultiBinding Converter="{StaticResource JobCollectionToCategoryCountConverter}"> + <Binding RelativeSource="{RelativeSource AncestorType=UserControl}" Path="DataContext.Jobs" /> + <Binding Path="Value" Mode="OneWay"></Binding> + </MultiBinding> + </Run.Text> + </Run><Run>)</Run> + </TextBlock> + </DataTemplate> + </touch:TouchNavigationLinks.ItemTemplate> + </touch:TouchNavigationLinks> - <Grid Grid.Row="1"> + <Grid Grid.Row="1" x:Name="moveGrid"> <touch:TouchLoadingPanel IsLoading="{Binding IsLoadingJobs}"> <touch:LightTouchDataGrid x:Name="dataGridJobs" SelectedItems="{Binding SelectedJobs}" IsMultiSelecting="{Binding IsMultiSelecting,Mode=TwoWay}" OnDragAndDropCommand="{Binding JobDragedDroppedCommand}" ItemsSource="{Binding JobsCollectionView}" ItemSelectedCommand="{Binding JobSelectedCommand}" Margin="10"> <touch:LightTouchDataGrid.Columns> @@ -153,10 +170,10 @@ </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 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 CornerRadius="0 5 5 0"> <Border.Style> <Style TargetType="Border"> <Setter Property="Background" Value="{StaticResource TangoMidAccentBrush}"></Setter> @@ -181,7 +198,7 @@ <Style TargetType="dragAndDrop:DragThumb"> <Setter Property="Visibility" Value="Collapsed"></Setter> <Style.Triggers> - <DataTrigger Binding="{Binding Source={x:Reference userSortColumn},Path=SortDirection}" Value="Ascending"> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=touch:LightTouchDataGridCell},Path=Column.SortDirection}" Value="Ascending"> <Setter Property="Visibility" Value="Visible"></Setter> </DataTrigger> </Style.Triggers> @@ -198,7 +215,7 @@ </touch:LightTouchDataGrid.Columns> </touch:LightTouchDataGrid> </touch:TouchLoadingPanel> - <TextBox VerticalAlignment="Bottom" HorizontalAlignment="Center" Margin="100" Width="200" keyboard:KeyboardView.Mode="Alpha"></TextBox> + <TextBox VerticalAlignment="Bottom" HorizontalAlignment="Center" Margin="100" Width="200" keyboard:KeyboardView.Mode="Alpha" keyboard:KeyboardView.Container="{Binding ElementName=moveGrid}"></TextBox> </Grid> </Grid> </Grid> diff --git a/Software/Visual_Studio/Tango.PMR/Hardware/HardwarePidControlType.cs b/Software/Visual_Studio/Tango.PMR/Hardware/HardwarePidControlType.cs index 482ed763a..7dfb82634 100644 --- a/Software/Visual_Studio/Tango.PMR/Hardware/HardwarePidControlType.cs +++ b/Software/Visual_Studio/Tango.PMR/Hardware/HardwarePidControlType.cs @@ -23,16 +23,17 @@ namespace Tango.PMR.Hardware { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "ChxIYXJkd2FyZVBpZENvbnRyb2xUeXBlLnByb3RvEhJUYW5nby5QTVIuSGFy", - "ZHdhcmUqiAMKFkhhcmR3YXJlUGlkQ29udHJvbFR5cGUSFAoQRHJ5ZXJIZWF0", + "ZHdhcmUqmgMKFkhhcmR3YXJlUGlkQ29udHJvbFR5cGUSFAoQRHJ5ZXJIZWF0", "ZXIxMDAwdxAAEhQKEERyeWVySGVhdGVyMjAwdzEQARIUChBEcnllckhlYXRl", "cjIwMHcyEAISEAoMSGVhZEhlYXRlcloxEAMSEAoMSGVhZEhlYXRlcloyEAQS", - "EAoMSGVhZEhlYXRlclozEAUSEAoMSGVhZEhlYXRlclo0EAYSDwoLTWl4ZXJI", - "ZWF0ZXIQBxIQCgxXYXN0ZUNvbnRyb2wQCBIOCgpNb3RvckRyeWVyEAkSDwoL", - "TW90b3JGZWVkZXIQChIPCgtNb3RvclBvb2xlchALEg8KC01vdG9yV2luZGVy", - "EAwSDgoKRGlzcGVuc2VyMRANEg4KCkRpc3BlbnNlcjIQDhIOCgpEaXNwZW5z", - "ZXIzEA8SDgoKRGlzcGVuc2VyNBAQEg4KCkRpc3BlbnNlcjUQERIOCgpEaXNw", - "ZW5zZXI2EBISDgoKRGlzcGVuc2VyNxATEg4KCkRpc3BlbnNlcjgQFEIeChxj", - "b20udHdpbmUudGFuZ28ucG1yLmhhcmR3YXJlYgZwcm90bzM=")); + "EAoMSGVhZEhlYXRlclozEAUSEAoMSGVhZEhlYXRlclo0EAYSEAoMSGVhZEhl", + "YXRlclo1EAcSDwoLTWl4ZXJIZWF0ZXIQCBIQCgxXYXN0ZUNvbnRyb2wQCRIO", + "CgpNb3RvckRyeWVyEAoSDwoLTW90b3JGZWVkZXIQCxIPCgtNb3RvclBvb2xl", + "chAMEg8KC01vdG9yV2luZGVyEA0SDgoKRGlzcGVuc2VyMRAOEg4KCkRpc3Bl", + "bnNlcjIQDxIOCgpEaXNwZW5zZXIzEBASDgoKRGlzcGVuc2VyNBAREg4KCkRp", + "c3BlbnNlcjUQEhIOCgpEaXNwZW5zZXI2EBMSDgoKRGlzcGVuc2VyNxAUEg4K", + "CkRpc3BlbnNlcjgQFUIeChxjb20udHdpbmUudGFuZ28ucG1yLmhhcmR3YXJl", + "YgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Tango.PMR.Hardware.HardwarePidControlType), }, null)); @@ -71,61 +72,65 @@ namespace Tango.PMR.Hardware { /// </summary> [pbr::OriginalName("HeadHeaterZ4")] HeadHeaterZ4 = 6, /// <summary> + ///Head Heater Zone 5 + /// </summary> + [pbr::OriginalName("HeadHeaterZ5")] HeadHeaterZ5 = 7, + /// <summary> ///Mixer Heater /// </summary> - [pbr::OriginalName("MixerHeater")] MixerHeater = 7, + [pbr::OriginalName("MixerHeater")] MixerHeater = 8, /// <summary> ///Waste Control /// </summary> - [pbr::OriginalName("WasteControl")] WasteControl = 8, + [pbr::OriginalName("WasteControl")] WasteControl = 9, /// <summary> ///Dryer Motor /// </summary> - [pbr::OriginalName("MotorDryer")] MotorDryer = 9, + [pbr::OriginalName("MotorDryer")] MotorDryer = 10, /// <summary> ///Feeder Motor /// </summary> - [pbr::OriginalName("MotorFeeder")] MotorFeeder = 10, + [pbr::OriginalName("MotorFeeder")] MotorFeeder = 11, /// <summary> ///Pooler Motor /// </summary> - [pbr::OriginalName("MotorPooler")] MotorPooler = 11, + [pbr::OriginalName("MotorPooler")] MotorPooler = 12, /// <summary> ///Winder Motor /// </summary> - [pbr::OriginalName("MotorWinder")] MotorWinder = 12, + [pbr::OriginalName("MotorWinder")] MotorWinder = 13, /// <summary> ///Dispenser 1 /// </summary> - [pbr::OriginalName("Dispenser1")] Dispenser1 = 13, + [pbr::OriginalName("Dispenser1")] Dispenser1 = 14, /// <summary> ///Dispenser 2 /// </summary> - [pbr::OriginalName("Dispenser2")] Dispenser2 = 14, + [pbr::OriginalName("Dispenser2")] Dispenser2 = 15, /// <summary> ///Dispenser 3 /// </summary> - [pbr::OriginalName("Dispenser3")] Dispenser3 = 15, + [pbr::OriginalName("Dispenser3")] Dispenser3 = 16, /// <summary> ///Dispenser 4 /// </summary> - [pbr::OriginalName("Dispenser4")] Dispenser4 = 16, + [pbr::OriginalName("Dispenser4")] Dispenser4 = 17, /// <summary> ///Dispenser 5 /// </summary> - [pbr::OriginalName("Dispenser5")] Dispenser5 = 17, + [pbr::OriginalName("Dispenser5")] Dispenser5 = 18, /// <summary> ///Dispenser 6 /// </summary> - [pbr::OriginalName("Dispenser6")] Dispenser6 = 18, + [pbr::OriginalName("Dispenser6")] Dispenser6 = 19, /// <summary> ///Dispenser 7 /// </summary> - [pbr::OriginalName("Dispenser7")] Dispenser7 = 19, + [pbr::OriginalName("Dispenser7")] Dispenser7 = 20, /// <summary> ///Dispenser 8 /// </summary> - [pbr::OriginalName("Dispenser8")] Dispenser8 = 20, + [pbr::OriginalName("Dispenser8")] Dispenser8 = 21, } #endregion diff --git a/Software/Visual_Studio/Tango.SharedUI/DialogViewVM.cs b/Software/Visual_Studio/Tango.SharedUI/DialogViewVM.cs new file mode 100644 index 000000000..84452408f --- /dev/null +++ b/Software/Visual_Studio/Tango.SharedUI/DialogViewVM.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.SharedUI; + +namespace Tango.SharedUI +{ + /// <summary> + /// Represents a dialog view model base class. + /// </summary> + /// <seealso cref="Tango.SharedUI.ViewModel" /> + public abstract class DialogViewVM : ViewModel + { + public event Action Accepted; + public event Action Canceled; + + /// <summary> + /// Initializes a new instance of the <see cref="DialogViewVM"/> class. + /// </summary> + public DialogViewVM() + { + CanClose = true; + CloseCommand = new RelayCommand(Cancel, (x) => CanClose); + OKCommand = new RelayCommand(Accept, (x) => CanClose); + } + + private bool _canClose; + /// <summary> + /// Gets or sets a value indicating whether this dialog can be closed. + /// </summary> + public bool CanClose + { + get { return _canClose; } + set { _canClose = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + } + + /// <summary> + /// Gets or sets the close command. + /// </summary> + public RelayCommand CloseCommand { get; set; } + + /// <summary> + /// Gets or sets the OK command. + /// </summary> + public RelayCommand OKCommand { get; set; } + + /// <summary> + /// Called when the dialog has been shown. + /// </summary> + public virtual void OnShow() + { + + } + + /// <summary> + /// Invokes the <see cref="Accepted"/> event. + /// </summary> + protected virtual void Accept() + { + Accepted?.Invoke(); + } + + /// <summary> + /// Invokes the <see cref="Canceled"/> event. + /// </summary> + protected virtual void Cancel() + { + Canceled?.Invoke(); + } + } +} diff --git a/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj b/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj index b3634e969..02698a3b0 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj +++ b/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj @@ -105,6 +105,7 @@ <Compile Include="Converters\StringFormatConverter.cs" /> <Compile Include="Converters\StringNullOrEmptyToBooleanConverter.cs" /> <Compile Include="Converters\StringToWordsConverter.cs" /> + <Compile Include="DialogViewVM.cs" /> <Compile Include="Editors\IParameterItemEditor.cs" /> <Compile Include="Editors\ParameterItemEditor.cs" /> <Compile Include="Editors\ParameterItemNumericUpDownEditor.xaml.cs"> diff --git a/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGrid.xaml b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGrid.xaml index ca6d5fd2d..3de4ba8f0 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGrid.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGrid.xaml @@ -278,6 +278,7 @@ <Style TargetType="local:LightTouchDataGridCell" BasedOn="{StaticResource {x:Type local:LightTouchDataGridCell}}"> <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment}"></Setter> <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment}"></Setter> + <Setter Property="Column" Value="{Binding}"></Setter> </Style> </local:LightTouchDataGridCell.Style> <ContentControl Content="{Binding RelativeSource={RelativeSource AncestorType=ItemsPresenter},Path=DataContext}" ContentTemplate="{Binding CellTemplate}" VerticalContentAlignment="{Binding VerticalContentAlignment}" HorizontalContentAlignment="{Binding HorizontalContentAlignment}" /> diff --git a/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGridCell.cs b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGridCell.cs index c35bf768f..64055b772 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGridCell.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGridCell.cs @@ -14,5 +14,13 @@ namespace Tango.Touch.Controls { DefaultStyleKeyProperty.OverrideMetadata(typeof(LightTouchDataGridCell), new FrameworkPropertyMetadata(typeof(LightTouchDataGridCell))); } + + public LightTouchDataGridColumn Column + { + get { return (LightTouchDataGridColumn)GetValue(ColumnProperty); } + set { SetValue(ColumnProperty, value); } + } + public static readonly DependencyProperty ColumnProperty = + DependencyProperty.Register("Column", typeof(LightTouchDataGridColumn), typeof(LightTouchDataGridCell), new PropertyMetadata(null)); } } diff --git a/Software/Visual_Studio/Tango.Touch/Controls/MessageBoxVM.cs b/Software/Visual_Studio/Tango.Touch/Controls/MessageBoxVM.cs new file mode 100644 index 000000000..15e2d0c5c --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Controls/MessageBoxVM.cs @@ -0,0 +1,25 @@ +using FontAwesome.WPF; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using Tango.SharedUI; + +namespace Tango.Touch.Controls +{ + public class MessageBoxVM : DialogViewVM + { + public String Title { get; set; } + + public BitmapSource Icon { get; set; } + + public Brush Brush { get; set; } + + public String Message { get; set; } + + public bool HasCancel { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.cs new file mode 100644 index 000000000..fa01c207b --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; + +namespace Tango.Touch.Controls +{ + public class TouchPanel : ContentControl + { + static TouchPanel() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(TouchPanel), new FrameworkPropertyMetadata(typeof(TouchPanel))); + } + + public bool HasMessageBox + { + get { return (bool)GetValue(HasMessageBoxProperty); } + set { SetValue(HasMessageBoxProperty, value); } + } + public static readonly DependencyProperty HasMessageBoxProperty = + DependencyProperty.Register("HasMessageBox", typeof(bool), typeof(TouchPanel), new PropertyMetadata(false)); + + public MessageBoxVM CurrentMessageBox + { + get { return (MessageBoxVM)GetValue(CurrentMessageBoxProperty); } + set { SetValue(CurrentMessageBoxProperty, value); } + } + public static readonly DependencyProperty CurrentMessageBoxProperty = + DependencyProperty.Register("CurrentMessageBox", typeof(MessageBoxVM), typeof(TouchPanel), new PropertyMetadata(null)); + + public double MinNotificationHeight + { + get { return (double)GetValue(MinNotificationHeightProperty); } + set { SetValue(MinNotificationHeightProperty, value); } + } + public static readonly DependencyProperty MinNotificationHeightProperty = + DependencyProperty.Register("MinNotificationHeight", typeof(double), typeof(TouchPanel), new PropertyMetadata(60.0)); + + public bool HasNotifications + { + get { return (bool)GetValue(HasNotificationsProperty); } + set { SetValue(HasNotificationsProperty, value); } + } + public static readonly DependencyProperty HasNotificationsProperty = + DependencyProperty.Register("HasNotifications", typeof(bool), typeof(TouchPanel), new PropertyMetadata(false)); + + public IList Notifications + { + get { return (IList)GetValue(NotificationsProperty); } + set { SetValue(NotificationsProperty, value); } + } + public static readonly DependencyProperty NotificationsProperty = + DependencyProperty.Register("Notifications", typeof(IList), typeof(TouchPanel), new PropertyMetadata(null)); + + public DataTemplate NotificationTemplate + { + get { return (DataTemplate)GetValue(NotificationTemplateProperty); } + set { SetValue(NotificationTemplateProperty, value); } + } + public static readonly DependencyProperty NotificationTemplateProperty = + DependencyProperty.Register("NotificationTemplate", typeof(DataTemplate), typeof(TouchPanel), new PropertyMetadata(null)); + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.xaml new file mode 100644 index 000000000..946c5c0f0 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.xaml @@ -0,0 +1,110 @@ +<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + xmlns:keyboard="clr-namespace:Tango.Touch.Keyboard" + xmlns:local="clr-namespace:Tango.Touch.Controls"> + + <ResourceDictionary.MergedDictionaries> + <ResourceDictionary Source="../Resources/Colors.xaml" /> + <ResourceDictionary Source="../Resources/Fonts.xaml" /> + <ResourceDictionary Source="../Styles/TouchButton.xaml" /> + + <ResourceDictionary> + <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" /> + </ResourceDictionary> + </ResourceDictionary.MergedDictionaries> + + <Style x:Key="TangoMessageBoxButton" TargetType="{x:Type local: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> + + <Style TargetType="local:TouchPanel"> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="local:TouchPanel"> + <Border Background="{TemplateBinding Background}"> + <Grid> + <keyboard:KeyboardView Background="Silver"> + <Grid> + <local:TouchNotificationBar NotificationTemplate="{TemplateBinding NotificationTemplate}" MinNotificationHeight="{TemplateBinding MinNotificationHeight}" HasNotifications="{TemplateBinding HasNotifications}" Notifications="{TemplateBinding Notifications}"> + <Grid> + <!--Content--> + <ContentPresenter Content="{TemplateBinding Content}" /> + + <!--Messages--> + <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 RelativeSource={RelativeSource TemplatedParent},Path=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> + + <Grid DataContext="{Binding RelativeSource={RelativeSource TemplatedParent},Path=CurrentMessageBox}" Height="400" Margin="20"> + <Border Background="{StaticResource TangoPrimaryBackgroundBrush}" CornerRadius="10" Margin="10"> + <Border.Effect> + <DropShadowEffect BlurRadius="10" /> + </Border.Effect> + + <Grid ClipToBounds="True"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="100"/> + <ColumnDefinition Width="75*"/> + </Grid.ColumnDefinitions> + <Grid.RowDefinitions> + <RowDefinition Height="100" /> + <RowDefinition Height="1*" /> + <RowDefinition Height="70"/> + </Grid.RowDefinitions> + + <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> + + <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"> + <local:TouchButton x:Name="btnCancel" Width="180" Margin="2 0" Style="{StaticResource TangoMessageBoxButton}" Command="{Binding CloseCommand}" Visibility="{Binding HasCancel,Converter={StaticResource BooleanToVisibilityConverter}}">CANCEL</local:TouchButton> + <local:TouchButton x:Name="btnOK" Width="180" Margin="2 0" Style="{StaticResource TangoMessageBoxButton}" Command="{Binding OKCommand}">OK</local:TouchButton> + </StackPanel> + </Grid> + </Border> + </Grid> + </Grid> + </Grid> + </local:TouchNotificationBar> + </Grid> + </keyboard:KeyboardView> + </Grid> + </Border> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + + +</ResourceDictionary>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardView.cs b/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardView.cs index 36bdaced1..af18357c3 100644 --- a/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardView.cs +++ b/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardView.cs @@ -10,6 +10,7 @@ using System.Windows.Documents; using System.Windows.Input; using System.Windows.Markup; using System.Windows.Media; +using System.Windows.Media.Animation; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; @@ -25,6 +26,7 @@ namespace Tango.Touch.Keyboard private static KeyboardView _instance; private TouchKeyboard keyboard; + private Grid gridContent; #region Properties @@ -87,24 +89,86 @@ namespace Tango.Touch.Keyboard private static void RegisterElement(FrameworkElement element) { - element.PreviewMouseUp += (_, __) => OnElementFocused(element); - element.PreviewTouchUp += (_, __) => OnElementFocused(element); - element.GotFocus += (_, __) => OnElementFocused(element); - element.LostFocus += (_, __) => OnElementLostFocus(element); + element.GotFocus -= Element_GotFocus; + element.LostFocus -= Element_LostFocus; + element.GotFocus += Element_GotFocus; + element.LostFocus += Element_LostFocus; } - private async static void OnElementFocused(FrameworkElement element) + private static void Element_LostFocus(object sender, RoutedEventArgs e) { + FrameworkElement element = sender as FrameworkElement; + + _instance.IsOpened = false; + + if (GetContainer(element) != null) + { + ThicknessAnimation ani = new ThicknessAnimation(); + ani.To = new Thickness(0); + ani.Duration = TimeSpan.FromSeconds(0.2); + GetContainer(element).BeginAnimation(FrameworkElement.MarginProperty, ani); + } + } + + private async static void Element_GotFocus(object sender, RoutedEventArgs e) + { + var element = sender as FrameworkElement; + _instance.keyboard.ActionKeyMode = GetAction(element); _instance.keyboard.Mode = GetMode(element).Value; - _instance.IsOpened = true; - await Task.Delay(200); - element.BringIntoView(); + + if (!_instance.IsOpened) + { + _instance.IsOpened = true; + await Task.Delay(200); + } + + if (GetContainer(element) != null) + { + double viewPort = _instance.ActualHeight - _instance.keyboard.ActualHeight; + double centerViewPort = viewPort / 2; + + Point relativeLocation = element.TranslatePoint(new Point(0, 0), _instance.gridContent); + + if (relativeLocation.Y + element.ActualHeight + 10 > viewPort || relativeLocation.Y < 0) + { + double requiredMargin = (relativeLocation.Y + (element.ActualHeight / 2)) - centerViewPort; + + ThicknessAnimation ani = new ThicknessAnimation(); + ani.To = new Thickness(0, -requiredMargin, 0, requiredMargin); + ani.Duration = TimeSpan.FromSeconds(0.2); + GetContainer(element).BeginAnimation(FrameworkElement.MarginProperty, ani); + } + } + } + + #endregion + + #region Container + + public static readonly DependencyProperty ContainerProperty = + DependencyProperty.RegisterAttached("Container", + typeof(FrameworkElement), typeof(KeyboardView), + new FrameworkPropertyMetadata(null)); + + /// <summary> + /// Sets the Container attached property. + /// </summary> + /// <param name="element">The element.</param> + /// <param name="value">if set to <c>true</c> [value].</param> + public static void SetContainer(FrameworkElement element, FrameworkElement value) + { + element.SetValue(ContainerProperty, value); } - private static void OnElementLostFocus(FrameworkElement element) + /// <summary> + /// Gets the Container attached property. + /// </summary> + /// <param name="element">The element.</param> + /// <returns></returns> + public static FrameworkElement GetContainer(FrameworkElement element) { - _instance.IsOpened = false; + return (FrameworkElement)element.GetValue(ContainerProperty); } #endregion @@ -114,17 +178,7 @@ namespace Tango.Touch.Keyboard public static readonly DependencyProperty ActionProperty = DependencyProperty.RegisterAttached("Action", typeof(KeyboardActionKeyMode), typeof(KeyboardView), - new FrameworkPropertyMetadata(KeyboardActionKeyMode.Tab, ActionChanged)); - - /// <summary> - /// Action changed. - /// </summary> - /// <param name="d">The d.</param> - /// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> instance containing the event data.</param> - private static void ActionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - RegisterElement(d as FrameworkElement); - } + new FrameworkPropertyMetadata(KeyboardActionKeyMode.Tab)); /// <summary> /// Sets the Action attached property. @@ -167,6 +221,7 @@ namespace Tango.Touch.Keyboard base.OnApplyTemplate(); keyboard = GetTemplateChild("PART_Keyboard") as TouchKeyboard; + gridContent = GetTemplateChild("PART_GridContent") as Grid; keyboard.ActionKeyPressed += OnActionKeyPressed; } diff --git a/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardView.xaml b/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardView.xaml index db5ba6f3d..245c0061d 100644 --- a/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardView.xaml +++ b/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardView.xaml @@ -3,51 +3,46 @@ xmlns:local="clr-namespace:Tango.Touch.Keyboard"> - <Style TargetType="{x:Type local:KeyboardView}"> - <Setter Property="Template"> - <Setter.Value> - <ControlTemplate TargetType="{x:Type local:KeyboardView}"> - <Grid DataContext="{Binding RelativeSource={RelativeSource AncestorType=local:KeyboardView}}"> - <Grid.RowDefinitions> - <RowDefinition Height="1*"/> - <RowDefinition Height="Auto"> - <RowDefinition.Style> - <Style TargetType="RowDefinition"> - <Setter Property="MaxHeight" Value="0"></Setter> - <Style.Triggers> - <DataTrigger Binding="{Binding IsOpened}" Value="True"> - <DataTrigger.EnterActions> - <BeginStoryboard> - <Storyboard> - <DoubleAnimation Storyboard.TargetProperty="MaxHeight" To="1000" Duration="00:00:0.2"></DoubleAnimation> - </Storyboard> - </BeginStoryboard> - </DataTrigger.EnterActions> - <DataTrigger.ExitActions> - <BeginStoryboard> - <Storyboard> - <DoubleAnimation Storyboard.TargetProperty="MaxHeight" To="0" Duration="00:00:0.1"></DoubleAnimation> - </Storyboard> - </BeginStoryboard> - </DataTrigger.ExitActions> - </DataTrigger> - </Style.Triggers> - </Style> - </RowDefinition.Style> - </RowDefinition> - </Grid.RowDefinitions> - - <Grid> - <ContentPresenter Content="{Binding View}"></ContentPresenter> - </Grid> - - <Grid Grid.Row="1"> - <local:TouchKeyboard x:Name="PART_Keyboard" /> - </Grid> - </Grid> - </ControlTemplate> - </Setter.Value> - </Setter> - </Style> + <Style TargetType="{x:Type local:KeyboardView}"> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="{x:Type local:KeyboardView}"> + <Grid> + <Grid> + <Grid x:Name="PART_GridContent"> + <ContentPresenter Content="{TemplateBinding View}"></ContentPresenter> + </Grid> + <Grid VerticalAlignment="Bottom" Background="{TemplateBinding Background}"> + <Grid.Style> + <Style TargetType="Grid"> + <Setter Property="MaxHeight" Value="0"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=local:KeyboardView},Path=IsOpened}" Value="True"> + <DataTrigger.EnterActions> + <BeginStoryboard> + <Storyboard> + <DoubleAnimation Storyboard.TargetProperty="MaxHeight" To="600" Duration="00:00:0.2"></DoubleAnimation> + </Storyboard> + </BeginStoryboard> + </DataTrigger.EnterActions> + <DataTrigger.ExitActions> + <BeginStoryboard> + <Storyboard> + <DoubleAnimation Storyboard.TargetProperty="MaxHeight" To="0" Duration="00:00:0.2"></DoubleAnimation> + </Storyboard> + </BeginStoryboard> + </DataTrigger.ExitActions> + </DataTrigger> + </Style.Triggers> + </Style> + </Grid.Style> + <local:TouchKeyboard x:Name="PART_Keyboard"></local:TouchKeyboard> + </Grid> + </Grid> + </Grid> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> </ResourceDictionary>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Touch/Resources/Fonts.xaml b/Software/Visual_Studio/Tango.Touch/Resources/Fonts.xaml index 8a27319b2..cd2e0ea58 100644 --- a/Software/Visual_Studio/Tango.Touch/Resources/Fonts.xaml +++ b/Software/Visual_Studio/Tango.Touch/Resources/Fonts.xaml @@ -3,4 +3,7 @@ xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:local="clr-namespace:Tango.Touch.Resources"> + <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/Tango.Touch/Styles/TouchButton.xaml b/Software/Visual_Studio/Tango.Touch/Styles/TouchButton.xaml index a6fa06deb..7d757740a 100644 --- a/Software/Visual_Studio/Tango.Touch/Styles/TouchButton.xaml +++ b/Software/Visual_Studio/Tango.Touch/Styles/TouchButton.xaml @@ -3,6 +3,10 @@ xmlns:controls="clr-namespace:Tango.Touch.Controls" xmlns:local="clr-namespace:Tango.Touch.Styles"> + <ResourceDictionary.MergedDictionaries> + <ResourceDictionary Source="../Resources/Colors.xaml" /> + </ResourceDictionary.MergedDictionaries> + <Style x:Key="TangoRoundTouchButton" TargetType="{x:Type controls:TouchButton}"> <Setter Property="Background" Value="{StaticResource TangoMidAccentBrush}"></Setter> <Setter Property="CornerRadius" Value="50"></Setter> diff --git a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj index 43e1e9b37..339da6e59 100644 --- a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj +++ b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj @@ -56,9 +56,11 @@ <Reference Include="PresentationFramework" /> </ItemGroup> <ItemGroup> + <Compile Include="Controls\MessageBoxVM.cs" /> <Compile Include="Controls\TouchListBox.cs" /> <Compile Include="Controls\TouchListBoxItem.cs" /> <Compile Include="Controls\TouchTextBox.cs" /> + <Compile Include="Controls\TouchPanel.cs" /> <Compile Include="Converters\StringToPasswordConverter.cs" /> <Compile Include="Helpers\TouchHelper.cs" /> <Page Include="Components\Ripple.xaml"> @@ -129,6 +131,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Controls\TouchPanel.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="Keyboard\KeyboardView.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> diff --git a/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml b/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml index e0e5a5904..7a19d2184 100644 --- a/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml +++ b/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml @@ -29,6 +29,8 @@ <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchToggleButton.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchButton.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchIconButton.xaml" /> + + <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchPanel.xaml" /> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> diff --git a/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml b/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml index c4855c614..0c7e9d1d9 100644 --- a/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml +++ b/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml @@ -14,14 +14,14 @@ Title="MainWindow" Height="1000" Width="800" DataContext="{Binding RelativeSource={RelativeSource Self}}" Background="{StaticResource TangoMidBackgroundBrush}"> <Grid> - <keyboard:KeyboardView> + <touch:TouchPanel> <Grid DataContext="{Binding RelativeSource={RelativeSource AncestorType=Window},Path=DataContext}"> - <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Width="300"> + <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Width="300" Margin="0 500 0 0"> <touch:TouchTextBox FontSize="20" Watermark="Email" Text="{Binding Email,NotifyOnValidationError=True,ValidatesOnDataErrors=True}" /> <touch:TouchTextBox IsPassword="True" Margin="0 30 0 0" FontSize="20" Watermark="Password" keyboard:KeyboardView.Action="Enter" Text="{Binding Password}" /> <touch:TouchButton Height="50" Margin="0 60 0 0" IsDefault="True" Command="{Binding LoginCommand}">LOGIN</touch:TouchButton> - <touch:TouchListBox Background="White" SelectionMode="Multiple" Height="300" Margin="0 40 0 0" BorderThickness="1" BorderBrush="Black" ItemsSource="{Binding Names}"> + <touch:TouchListBox Background="White" SelectionMode="Multiple" Height="50" Margin="0 40 0 0" BorderThickness="1" BorderBrush="Black" ItemsSource="{Binding Names}"> <touch:TouchListBox.ItemTemplate> <DataTemplate> <Border BorderBrush="Gray" BorderThickness="0 0 0 1" Padding="5"> @@ -32,7 +32,6 @@ </touch:TouchListBox> </StackPanel> </Grid> - </keyboard:KeyboardView> - + </touch:TouchPanel> </Grid> </Window> |
