diff options
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer')
9 files changed, 538 insertions, 39 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/camera.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/camera.png Binary files differnew file mode 100644 index 000000000..526573632 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/camera.png diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/graphs.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/graphs.png Binary files differnew file mode 100644 index 000000000..6a211693d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/graphs.png diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/line_graph.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/line_graph.png Binary files differnew file mode 100644 index 000000000..7e21f4e97 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/line_graph.png diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/no-signal.jpg b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/no-signal.jpg Binary files differnew file mode 100644 index 000000000..e8b1313c9 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/no-signal.jpg diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Resources/GraphEx.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Resources/GraphEx.xaml new file mode 100644 index 000000000..a44a8191c --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Resources/GraphEx.xaml @@ -0,0 +1,126 @@ +<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:sys="clr-namespace:System;assembly=mscorlib" + xmlns:local="clr-namespace:Tango.MachineStudio.Developer.Resources"> + + <FontFamily x:Key="FontName">Segoe UI</FontFamily> + <FontFamily x:Key="NotesFont">Lucida Console</FontFamily> + + <sys:Double x:Key="ExtraExtraLargeFontSize">28</sys:Double> + <sys:Double x:Key="ExtraLargeFontSize">26</sys:Double> + <sys:Double x:Key="LargeFontSize">20</sys:Double> + <sys:Double x:Key="MediumFontSize">16</sys:Double> + <sys:Double x:Key="SmallFontSize">14</sys:Double> + <sys:Double x:Key="MiniFontSize">12</sys:Double> + <sys:Double x:Key="TinyFontSize">9</sys:Double> + + <!--Colors--> + <Color x:Key="borderColor">Silver</Color> + <Color x:Key="graphGridLinesColor">#FFE9E9E9</Color> + <Color x:Key="graphsMarkerColor">Gray</Color> + <Color x:Key="materialColor">#03A9F4</Color> + + + <!--Brushes--> + <SolidColorBrush x:Key="borderBrush" Color="{StaticResource borderColor}"></SolidColorBrush> + <SolidColorBrush x:Key="graphGridLinesBrush" Color="{StaticResource graphGridLinesColor}"></SolidColorBrush> + <SolidColorBrush x:Key="BlackBrush" Color="#545454"></SolidColorBrush> + + <SolidColorBrush x:Key="graphGridLinesLightBrush" Color="{StaticResource graphGridLinesColor}"></SolidColorBrush> + <SolidColorBrush x:Key="graphGridLinesDarkBrush" Color="#FF2E2E2E"></SolidColorBrush> + + <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" x:Key="graphBackgroundLight"> + <GradientStop Color="White"/> + <GradientStop Color="#FFE9E9E9" Offset="1"/> + </LinearGradientBrush> + + <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" x:Key="graphBackgroundDark"> + <GradientStop Color="Black"/> + <GradientStop Color="#FF333333" Offset="1"/> + </LinearGradientBrush> + + <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" x:Key="graphBackground"> + <GradientStop Color="White"/> + <GradientStop Color="#FFE9E9E9" Offset="1"/> + </LinearGradientBrush> + + <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" x:Key="graphLabelBackground" Opacity="0.7"> + <GradientStop Color="White"/> + <GradientStop Color="#FFD9D9D9" Offset="1"/> + </LinearGradientBrush> + + <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" x:Key="graphLegendBackground" Opacity="0.7"> + <GradientStop Color="#FFE9E9E9"/> + <GradientStop Color="#FFBDBDBD" Offset="1"/> + </LinearGradientBrush> + + <SolidColorBrush Color="#FFF1F1F1" x:Key="topBarBackgroundBrush"></SolidColorBrush> + + <!--Navigation Link Button--> + <Style x:Key="LinkButton" TargetType="Button"> + <Setter Property="Stylus.IsPressAndHoldEnabled" Value="False"/> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="Button"> + <TextBlock FontSize="{TemplateBinding FontSize}" FontFamily="{TemplateBinding FontFamily}"> + <ContentPresenter /></TextBlock> + </ControlTemplate> + </Setter.Value> + </Setter> + <Setter Property="Foreground" Value="{StaticResource BlackBrush}" /> + <Style.Triggers> + <Trigger Property="IsEnabled" Value="False"> + <Setter Property="Opacity" Value="0.5"></Setter> + </Trigger> + <Trigger Property="IsMouseOver" Value="true"> + <Setter Property="Foreground" Value="{StaticResource AccentColorBrush}" /> + </Trigger> + <EventTrigger RoutedEvent="TouchUp"> + <BeginStoryboard> + <Storyboard> + <ColorAnimation Storyboard.TargetProperty="Foreground.Color" Duration="0" To="{StaticResource BlackColor}"></ColorAnimation> + </Storyboard> + </BeginStoryboard> + </EventTrigger> + </Style.Triggers> + </Style> + <!--Navigation Link Button--> + + + <!--Graph Label--> + <Style x:Key="graphLabel" TargetType="Label"> + <Style.Setters> + <Setter Property="IsHitTestVisible" Value="False"></Setter> + <Setter Property="Margin" Value="-1 -1 0 0"></Setter> + <Setter Property="HorizontalAlignment" Value="Left"></Setter> + <Setter Property="VerticalAlignment" Value="Top"></Setter> + <Setter Property="Padding" Value="0"></Setter> + <Setter Property="ContentTemplate"> + <Setter.Value> + <DataTemplate> + <Border Width="Auto" Padding="0 0 20 0" Height="25" BorderBrush="{StaticResource AccentColorBrush}" BorderThickness="1" CornerRadius="0 0 30 0" Background="{StaticResource graphLabelBackground}" > + <TextBlock Margin="5 0 0 0" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="{StaticResource TinyFontSize}" Text="{Binding}"></TextBlock> + </Border> + </DataTemplate> + </Setter.Value> + </Setter> + </Style.Setters> + </Style> + <!--Graph Label--> + + + <!--Graph Ticks Template--> + <DataTemplate x:Key="graphTicksTemplate"> + <Ellipse Width="3" Height="3" Margin="0 0 0 0" Fill="{StaticResource AccentColorBrush}"></Ellipse> + </DataTemplate> + <!--Graph Ticks Template--> + + <DataTemplate x:Key="graphTooltipTemplate"> + <Border CornerRadius="5" BorderThickness="1" BorderBrush="White" Padding="8" MinWidth="50" Margin="20 0 20 0"> + <Border.Background> + <SolidColorBrush Color="Black" Opacity="0.5"></SolidColorBrush> + </Border.Background> + <TextBlock Foreground="White" FontSize="10" HorizontalAlignment="Center" TextAlignment="Center" Text="{Binding StringFormat='0.000'}"></TextBlock> + </Border> + </DataTemplate> +</ResourceDictionary>
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj index f5da6fca4..276dd6c54 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj @@ -82,6 +82,10 @@ <Compile Include="..\..\..\Versioning\GlobalVersionInfo.cs"> <Link>GlobalVersionInfo.cs</Link> </Compile> + <Page Include="Resources\GraphEx.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> <Page Include="Views\MainView.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -113,6 +117,10 @@ </None> </ItemGroup> <ItemGroup> + <ProjectReference Include="..\..\..\SideChains\RealTimeGraphEx\RealTimeGraphEx.csproj"> + <Project>{b9ae25d6-be35-492f-9079-21a7f3e6f7cc}</Project> + <Name>RealTimeGraphEx</Name> + </ProjectReference> <ProjectReference Include="..\..\..\Tango.Core\Tango.Core.csproj"> <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> <Name>Tango.Core</Name> @@ -125,6 +133,10 @@ <Project>{38197109-8610-4d3f-92b9-16d48df94d7c}</Project> <Name>Tango.DAL.Remote</Name> </ProjectReference> + <ProjectReference Include="..\..\..\Tango.DragAndDrop\Tango.DragAndDrop.csproj"> + <Project>{b112d89a-a106-41ae-a0c1-4abc84c477f5}</Project> + <Name>Tango.DragAndDrop</Name> + </ProjectReference> <ProjectReference Include="..\..\..\Tango.SharedUI\Tango.SharedUI.csproj"> <Project>{8491d07b-c1f6-4b62-a412-41b9fd2d6538}</Project> <Name>Tango.SharedUI</Name> @@ -161,5 +173,17 @@ <ItemGroup> <Resource Include="Images\machine-trans.png" /> </ItemGroup> + <ItemGroup> + <Resource Include="Images\graphs.png" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\line_graph.png" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\no-signal.jpg" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\camera.png" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs index 2013de3c8..590474f9d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs @@ -7,22 +7,37 @@ using System.Text; using System.Threading.Tasks; using Tango.Core.Commands; using Tango.DAL.Observables; +using Tango.MachineStudio.Common.Controls; using Tango.MachineStudio.Common.Notifications; using Tango.MachineStudio.Common.StudioApplication; using Tango.SharedUI; namespace Tango.MachineStudio.Developer.ViewModels { + /// <summary> + /// Represents the developer module main view, view model. + /// </summary> + /// <seealso cref="Tango.SharedUI.ViewModel" /> public class MainViewVM : ViewModel { private INotificationProvider _notification; + #region Properties + + /// <summary> + /// Gets or sets the application manager. + /// </summary> public IStudioApplicationManager ApplicationManager { get; set; } + /// <summary> + /// Gets or sets observable entites database the adapter. + /// </summary> public ObservablesEntitiesAdapter Adapter { get; set; } private Machine _selectedMachine; - + /// <summary> + /// Gets or sets the selected machine. + /// </summary> public Machine SelectedMachine { get { return _selectedMachine; } @@ -30,7 +45,9 @@ namespace Tango.MachineStudio.Developer.ViewModels } private List<LiquidTypesRml> _liquidTypesRmls; - + /// <summary> + /// Gets or sets the liquid types RMLS. + /// </summary> public List<LiquidTypesRml> LiquidTypesRmls { get { return _liquidTypesRmls; } @@ -38,48 +55,49 @@ namespace Tango.MachineStudio.Developer.ViewModels } private ProcessParametersTablesGroup _rmlProcessParametersTablesGroup; - + /// <summary> + /// Gets or sets the RML process parameters table group (cloned). + /// </summary> public ProcessParametersTablesGroup RmlProcessParametersTableGroup { get { return _rmlProcessParametersTablesGroup; } set { _rmlProcessParametersTablesGroup = value; RaisePropertyChangedAuto(); } } - private ProcessParametersTablesGroup _selectedGroupHistory; - - public ProcessParametersTablesGroup SelectedGroupHistory - { - get { return _selectedGroupHistory; } - set { _selectedGroupHistory = value; RaisePropertyChangedAuto(); OnSelectedGroupHistoryChanged(); } - } - - private void OnSelectedGroupHistoryChanged() - { - if (SelectedGroupHistory != null) - { - RmlProcessParametersTableGroup = SelectedGroupHistory.CloneGroup(); - } - } - private ObservableCollection<ProcessParametersTablesGroup> _groupsHistory; - + /// <summary> + /// Gets or sets the RML process parameters groups history. + /// </summary> public ObservableCollection<ProcessParametersTablesGroup> GroupsHistory { get { return _groupsHistory; } set { _groupsHistory = value; RaisePropertyChangedAuto(); } } - private Job _selectedJob; + private ProcessParametersTablesGroup _selectedGroupHistory; + /// <summary> + /// Gets or sets the selected process parameters tables group history. + /// </summary> + public ProcessParametersTablesGroup SelectedGroupHistory + { + get { return _selectedGroupHistory; } + set { _selectedGroupHistory = value; RaisePropertyChangedAuto(); OnSelectedGroupHistoryChanged(); } + } + private Job _selectedJob; + /// <summary> + /// Gets or sets the selected machine job. + /// </summary> public Job SelectedJob { get { return _selectedJob; } set { _selectedJob = value; RaisePropertyChangedAuto(); } } - private Rml _selectedRML; - + /// <summary> + /// Gets or sets the selected RML. + /// </summary> public Rml SelectedRML { get { return _selectedRML; } @@ -87,43 +105,131 @@ namespace Tango.MachineStudio.Developer.ViewModels } private bool _isSideBarOpened; - + /// <summary> + /// Gets or sets a value indicating whether the configuration panels are opened. + /// </summary> public bool IsSideBarOpened { get { return _isSideBarOpened; } set { _isSideBarOpened = value; RaisePropertyChangedAuto(); } } + private ObservableCollection<Sensor> _availableSensors; + /// <summary> + /// Gets or sets the available sensors. + /// </summary> + public ObservableCollection<Sensor> AvailableSensors + { + get { return _availableSensors; } + set { _availableSensors = value; RaisePropertyChangedAuto(); } + } + private ObservableCollection<RealTimeGraphControl> _graphs; + /// <summary> + /// Gets or sets the collection of displayed graph controls. + /// </summary> + public ObservableCollection<RealTimeGraphControl> Graphs + { + get { return _graphs; } + set { _graphs = value; RaisePropertyChangedAuto(); } + } + + #endregion + + #region Commands + + /// <summary> + /// Gets or sets the edit machine command. + /// </summary> public RelayCommand EditMachineCommand { get; set; } + /// <summary> + /// Gets or sets the edit RML command. + /// </summary> public RelayCommand EditRMLCommand { get; set; } + /// <summary> + /// Gets or sets the toggle side bar command. + /// </summary> public RelayCommand ToggleSideBarCommand { get; set; } + /// <summary> + /// Gets or sets the save process parameters command. + /// </summary> public RelayCommand SaveProcessParametersCommand { get; set; } + /// <summary> + /// Gets or sets the save liquid factors command. + /// </summary> public RelayCommand SaveLiquidFactorsCommand { get; set; } + #endregion + + #region Constructors + + /// <summary> + /// Initializes a new instance of the <see cref="MainViewVM"/> class. + /// </summary> public MainViewVM() { IsSideBarOpened = true; + + if (!this.DesignMode) + { + Adapter = ObservablesEntitiesAdapter.Instance; + AvailableSensors = Adapter.Sensors.ToObservableCollection(); + } + + Graphs = new ObservableCollection<RealTimeGraphControl>(); } + /// <summary> + /// Initializes a new instance of the <see cref="MainViewVM"/> class. + /// </summary> + /// <param name="applicationManager">The application manager.</param> + /// <param name="notificationProvider">The notification provider.</param> [PreferredConstructor] - public MainViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider) + public MainViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider) : this() { _notification = notificationProvider; - Adapter = ObservablesEntitiesAdapter.Instance; EditMachineCommand = new RelayCommand(EditMachine, (x) => SelectedMachine != null); ApplicationManager = applicationManager; EditRMLCommand = new RelayCommand(EditRML, (x) => SelectedRML != null); ToggleSideBarCommand = new RelayCommand(() => IsSideBarOpened = !IsSideBarOpened); SaveProcessParametersCommand = new RelayCommand(SaveProcessParameters); SaveLiquidFactorsCommand = new RelayCommand(SaveLiquidFactors); - IsSideBarOpened = true; } + #endregion + + #region Virtual Methods + + /// <summary> + /// Called when the selected group history has been changed + /// </summary> + protected virtual void OnSelectedGroupHistoryChanged() + { + if (SelectedGroupHistory != null) + { + RmlProcessParametersTableGroup = SelectedGroupHistory.CloneGroup(); + } + } + + /// <summary> + /// Called when the machine has been changed + /// </summary> + protected virtual void OnMachineChanged() + { + InvalidateLiquidFactorsAndProcessTables(); + } + + #endregion + + #region Private Methods + + /// <summary> + /// Saves the liquid factors. + /// </summary> private async void SaveLiquidFactors() { if (SelectedRML != null) @@ -141,21 +247,25 @@ namespace Tango.MachineStudio.Developer.ViewModels } } + /// <summary> + /// Navigates to the DB Module in order to edit the selected RML. + /// </summary> private void EditRML() { ApplicationManager.RequestModule("Data Base", SelectedRML); } + /// <summary> + /// Navigates to the Machine Designer Module in order to edit the selected machine. + /// </summary> private void EditMachine() { ApplicationManager.RequestModule("Machine Designer", SelectedMachine); } - private void OnMachineChanged() - { - InvalidateLiquidFactorsAndProcessTables(); - } - + /// <summary> + /// Saves the process parameters group. + /// </summary> private async void SaveProcessParameters() { var response = _notification.ShowTextInput("Enter Group Name", "Group Name"); @@ -196,6 +306,9 @@ namespace Tango.MachineStudio.Developer.ViewModels } } + /// <summary> + /// Invalidates the liquid factors and process parameters tables. + /// </summary> private void InvalidateLiquidFactorsAndProcessTables() { if (SelectedRML != null && SelectedMachine != null) @@ -212,5 +325,49 @@ namespace Tango.MachineStudio.Developer.ViewModels GroupsHistory = SelectedRML.ProcessParametersTablesGroups.OrderByDescending(x => x.SaveDate).OrderBy(x => !x.Active).ToObservableCollection(); } } + + #endregion + + #region Public Events + + /// <summary> + /// Add sensor graph from available sensors to displayed graphs. + /// </summary> + /// <param name="sensor">The sensor.</param> + public void OnDropAvailableSensor(Sensor sensor) + { + if (Graphs.Count < 8) + { + RealTimeGraphControl graphControl = new RealTimeGraphControl(); + graphControl.Tag = sensor; + graphControl.SensorName = sensor.Description; + graphControl.SensorUnits = sensor.Units; + graphControl.Graph.Minimum = sensor.Min; + graphControl.Graph.Maximum = sensor.Max; + graphControl.Graph.MaxPoints = Common.Helpers.GraphsHelper.GetMaxPoints(sensor.PointsPerFrame); + graphControl.GraphRemoveButtonPressed += (sender, __) => + { + RemoveGraph(sender as RealTimeGraphControl); + }; + Graphs.Add(graphControl); + AvailableSensors.Remove(sensor); + } + else + { + _notification.ShowInfo("The maximum number of real-time graphs is eight. Please remove a graph to add another."); + } + } + + /// <summary> + /// Removes the graph. + /// </summary> + /// <param name="graph">The graph.</param> + public void RemoveGraph(RealTimeGraphControl graph) + { + Graphs.Remove(graph); + AvailableSensors.Insert(0, graph.Tag as Sensor); + } + + #endregion } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml index 7d98fe2d7..40babfc74 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml @@ -5,6 +5,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:global="clr-namespace:Tango.MachineStudio.Developer" + xmlns:dragAndDrop="clr-namespace:Tango.DragAndDrop;assembly=Tango.DragAndDrop" xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" xmlns:db="clr-namespace:Tango.MachineStudio.DB.Views.DBViews;assembly=Tango.MachineStudio.DB" xmlns:commonControls="clr-namespace:Tango.MachineStudio.Common.Controls;assembly=Tango.MachineStudio.Common" @@ -31,6 +32,51 @@ <SolidColorBrush x:Key="SideBarBackground" Color="#F9F9F9"> </SolidColorBrush> + + <Style x:Key="droppableGrid" TargetType="Grid"> + <Setter Property="RenderTransform"> + <Setter.Value> + <ScaleTransform ScaleX="1" ScaleY="1"></ScaleTransform> + </Setter.Value> + </Setter> + <Setter Property="RenderTransformOrigin" Value="0.5,0.5"></Setter> + <Setter Property="Background" Value="Transparent"></Setter> + <Setter Property="dragAndDrop:DragAndDropService.Droppable" Value="True"></Setter> + <Setter Property="dragAndDrop:DragAndDropService.DraggingSurface" Value="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DraggingSurface}"></Setter> + <Style.Triggers> + <Trigger Property="dragAndDrop:DragAndDropService.IsDraggableOver" Value="True"> + <Setter Property="Opacity" Value="0.5"></Setter> + <Trigger.EnterActions> + <BeginStoryboard> + <Storyboard> + <DoubleAnimation To="0.95" Duration="00:00:0.2" Storyboard.TargetProperty="RenderTransform.ScaleX"></DoubleAnimation> + <DoubleAnimation To="0.95" Duration="00:00:0.2" Storyboard.TargetProperty="RenderTransform.ScaleY"></DoubleAnimation> + </Storyboard> + </BeginStoryboard> + </Trigger.EnterActions> + <Trigger.ExitActions> + <BeginStoryboard> + <Storyboard> + <DoubleAnimation To="1" Duration="00:00:0.2" Storyboard.TargetProperty="RenderTransform.ScaleX"></DoubleAnimation> + <DoubleAnimation To="1" Duration="00:00:0.2" Storyboard.TargetProperty="RenderTransform.ScaleY"></DoubleAnimation> + </Storyboard> + </BeginStoryboard> + </Trigger.ExitActions> + </Trigger> + </Style.Triggers> + </Style> + + <Style x:Key="draggableGrid" TargetType="Grid"> + <Setter Property="RenderTransform"> + <Setter.Value> + <ScaleTransform ScaleX="1" ScaleY="1"></ScaleTransform> + </Setter.Value> + </Setter> + <Setter Property="RenderTransformOrigin" Value="0.5,0.5"></Setter> + <Setter Property="Background" Value="Transparent"></Setter> + <Setter Property="dragAndDrop:DragAndDropService.Draggable" Value="True"></Setter> + <Setter Property="dragAndDrop:DragAndDropService.DraggingSurface" Value="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DraggingSurface}"></Setter> + </Style> </UserControl.Resources> <Grid> @@ -291,7 +337,7 @@ <Grid> <Grid.RowDefinitions> <RowDefinition Height="234*"/> - <RowDefinition Height="131*"/> + <RowDefinition Height="161*"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="173*"/> @@ -331,9 +377,9 @@ </DockPanel> </Grid> - <Grid Grid.Column="1" Margin="10"> + <Grid Grid.Column="1" Margin="10 10 10 0"> <Grid.ColumnDefinitions> - <ColumnDefinition Width="1*"/> + <ColumnDefinition/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <Grid> @@ -402,7 +448,7 @@ </StackPanel> </Grid> - <Grid Grid.Column="1" Background="{StaticResource SideBarBackground}" Margin="10 0 0 0" Width="400"> + <Grid Grid.Column="1" Margin="10 0 0 0" Width="340"> <Grid.Style> <Style TargetType="Grid"> <Setter Property="LayoutTransform"> @@ -431,14 +477,133 @@ </Style> </Grid.Style> - <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center">CAMERAS</TextBlock> + <Grid Margin="5 0 0 0"> + <DockPanel> + <StackPanel Orientation="Horizontal" DockPanel.Dock="Top"> + <Image Source="../Images/camera.png" Width="42"></Image> + <TextBlock VerticalAlignment="Center" Margin="10 0 0 0" Foreground="DimGray" FontSize="16" FontWeight="SemiBold">USB CAMERAS</TextBlock> + </StackPanel> + <UniformGrid Rows="3"> + <Border BorderBrush="Gray" BorderThickness="1" Margin="0 0 0 5" CornerRadius="5"> + <Border.Background> + <ImageBrush ImageSource="../Images/no-signal.jpg" Stretch="Fill"></ImageBrush> + </Border.Background> + + <Grid> + <Label Style="{StaticResource graphLabel}"> + <TextBlock VerticalAlignment="Center" FontSize="10" Margin="0 0 30 0">CAMERA 1</TextBlock> + </Label> + </Grid> + </Border> + <Border BorderBrush="Gray" BorderThickness="1" Margin="0 0 0 5" CornerRadius="5"> + <Border.Background> + <ImageBrush ImageSource="../Images/no-signal.jpg" Stretch="Fill"></ImageBrush> + </Border.Background> + + <Grid> + <Label Style="{StaticResource graphLabel}"> + <TextBlock VerticalAlignment="Center" FontSize="10" Margin="0 0 30 0">CAMERA 2</TextBlock> + </Label> + </Grid> + </Border> + <Border BorderBrush="Gray" BorderThickness="1" Margin="0 0 0 5" CornerRadius="5"> + <Border.Background> + <ImageBrush ImageSource="../Images/no-signal.jpg" Stretch="Fill"></ImageBrush> + </Border.Background> + + <Grid> + <Label Style="{StaticResource graphLabel}"> + <TextBlock VerticalAlignment="Center" FontSize="10" Margin="0 0 30 0">CAMERA 3</TextBlock> + </Label> + </Grid> + </Border> + </UniformGrid> + </DockPanel> + </Grid> + </Grid> </Grid> - + <Grid Grid.Row="1" Grid.ColumnSpan="2" Background="{StaticResource SideBarBackground}"> + <Grid Margin="10 70 10 10"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="1*"/> + <ColumnDefinition Width="350"/> + </Grid.ColumnDefinitions> + + <Grid Grid.Column="1"> + <DockPanel> + <StackPanel Orientation="Horizontal" DockPanel.Dock="Top"> + <Image Source="../Images/graphs.png" Width="42"></Image> + <TextBlock VerticalAlignment="Center" Margin="10 0 0 0" Foreground="DimGray" FontSize="16" FontWeight="SemiBold">AVAILABLE GRAPHS</TextBlock> + </StackPanel> + <ScrollViewer Margin="0 5 0 0" VerticalScrollBarVisibility="Auto"> + <ItemsControl Margin="0 0 5 0" ItemsSource="{Binding AvailableSensors}"> + <ItemsControl.ItemsPanel> + <ItemsPanelTemplate> + <UniformGrid Columns="2" IsItemsHost="True"></UniformGrid> + </ItemsPanelTemplate> + </ItemsControl.ItemsPanel> + <ItemsControl.ItemTemplate> + <DataTemplate DataType="{x:Type observables:Sensor}"> + <Border dragAndDrop:DragAndDropService.Draggable="True" dragAndDrop:DragAndDropService.DraggingSurface="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DraggingSurface}" Margin="5" CornerRadius="3" Height="120" BorderThickness="1" BorderBrush="Silver" ClipToBounds="True"> + <Border.Background> + <ImageBrush ImageSource="../Images/line_graph.png" Stretch="Fill"></ImageBrush> + </Border.Background> + <Grid> + <Label HorizontalAlignment="Left" VerticalAlignment="Top" Style="{StaticResource graphLabel}"> + <TextBlock Foreground="DimGray" VerticalAlignment="Center" Text="{Binding Description}"></TextBlock> + </Label> + </Grid> + </Border> + </DataTemplate> + </ItemsControl.ItemTemplate> + </ItemsControl> + </ScrollViewer> + </DockPanel> + </Grid> + + <Grid> + <Grid Margin="0 0 10 0" Style="{StaticResource droppableGrid}" dragAndDrop:DragAndDropService.Drop="OnDropAvailableSensor"> + <Border> + <ItemsControl ItemsSource="{Binding Graphs}"> + <ItemsControl.ItemsPanel> + <ItemsPanelTemplate> + <UniformGrid Columns="4" Rows="2" IsItemsHost="True"></UniformGrid> + </ItemsPanelTemplate> + </ItemsControl.ItemsPanel> + </ItemsControl> + </Border> + <Grid> + <Grid.Style> + <Style TargetType="Grid"> + <Setter Property="Visibility" Value="Collapsed"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding Graphs.Count}" Value="0"> + <Setter Property="Visibility" Value="Visible"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </Grid.Style> + <TextBlock Foreground="Silver" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="30">DRAG & DROP GRAPHS</TextBlock> + </Grid> + </Grid> + </Grid> + </Grid> - <Grid Grid.Row="1" Grid.ColumnSpan="2"> + <Border VerticalAlignment="Top" Height="50" CornerRadius="0 0 50 50"> + <Border.Effect> + <DropShadowEffect BlurRadius="30" ShadowDepth="20" Opacity="0.2" /> + </Border.Effect> + <Border.Background> + <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> + <GradientStop Color="White" Offset="0" /> + <GradientStop Color="#FFE6E6E6" Offset="1"/> + </LinearGradientBrush> + </Border.Background> + </Border> + <dragAndDrop:DraggingSurface x:Name="draggingSurface" /> </Grid> </Grid> </Grid> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs index 6ebfd9832..9eeff4975 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs @@ -12,6 +12,9 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using Tango.DAL.Observables; +using Tango.DragAndDrop; +using Tango.MachineStudio.Developer.ViewModels; namespace Tango.MachineStudio.Developer.Views { @@ -20,9 +23,33 @@ namespace Tango.MachineStudio.Developer.Views /// </summary> public partial class MainView : UserControl { + private MainViewVM _vm; + + public DraggingSurface DraggingSurface + { + get { return (DraggingSurface)GetValue(DraggingSurfaceProperty); } + set { SetValue(DraggingSurfaceProperty, value); } + } + public static readonly DependencyProperty DraggingSurfaceProperty = + DependencyProperty.Register("DraggingSurface", typeof(DraggingSurface), typeof(MainView), new PropertyMetadata(null)); + public MainView() { InitializeComponent(); + + DraggingSurface = draggingSurface; + this.Loaded += (x, y) => + { + _vm = DataContext as MainViewVM; + }; + } + + private void OnDropAvailableSensor(object sender, DropEventArgs e) + { + if (e.Draggable.DataContext is Sensor) + { + _vm.OnDropAvailableSensor(e.Draggable.DataContext as Sensor); + } } } } |
