diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-02-20 15:08:22 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-02-20 15:08:22 +0200 |
| commit | 2fe707abce023813d234b57b097a731174fd4a26 (patch) | |
| tree | 010fd3d915f24c266e9dff119c3b5c3657ae80f8 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI | |
| parent | 98507ffd2075fcd7ae69d97d4f4795ca8c85c646 (diff) | |
| download | Tango-2fe707abce023813d234b57b097a731174fd4a26.tar.gz Tango-2fe707abce023813d234b57b097a731174fd4a26.zip | |
Implemented module popping!
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI')
7 files changed, 222 insertions, 5 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj index f48561e40..d82de0e9a 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj @@ -120,12 +120,12 @@ <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </ApplicationDefinition> + <Compile Include="Modules\DefaultStudioModuleLoader.cs" /> <Compile Include="Notifications\TextInputBoxWindow.xaml.cs"> <DependentUpon>TextInputBoxWindow.xaml</DependentUpon> </Compile> <Compile Include="StudioApplication\DefaultStudioApplicationManager.cs" /> <Compile Include="Authentication\DefaultAuthenticationProvider.cs" /> - <Compile Include="Modules\DefaultStudioModuleLoader.cs" /> <Compile Include="Navigation\DefaultNavigationManager.cs" /> <Compile Include="Notifications\DefaultNotificationProvider.cs" /> <Compile Include="Notifications\MessageBoxWindow.xaml.cs"> @@ -138,6 +138,7 @@ <Compile Include="ViewModels\MachineLoginViewVM.cs" /> <Compile Include="ViewModels\MainViewVM.cs" /> <Compile Include="ViewModelLocator.cs" /> + <Compile Include="ViewModels\ModuleWindowVM.cs" /> <Compile Include="ViewModels\ShutdownViewVM.cs" /> <Compile Include="Views\LoadingView.xaml.cs"> <DependentUpon>LoadingView.xaml</DependentUpon> @@ -164,6 +165,9 @@ <Compile Include="Windows\ExceptionWindow.xaml.cs"> <DependentUpon>ExceptionWindow.xaml</DependentUpon> </Compile> + <Compile Include="Windows\ModuleWindow.xaml.cs"> + <DependentUpon>ModuleWindow.xaml</DependentUpon> + </Compile> <Page Include="MainWindow.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> @@ -223,6 +227,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Windows\ModuleWindow.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> </ItemGroup> <ItemGroup> <Compile Include="Properties\AssemblyInfo.cs"> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs index 679ba5ff3..503532223 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -7,6 +7,9 @@ using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media; using Tango.Core.Commands; using Tango.Integration.Services; using Tango.Logging; @@ -18,8 +21,10 @@ using Tango.MachineStudio.Common.Notifications; using Tango.MachineStudio.Common.StudioApplication; using Tango.MachineStudio.UI.SupervisingController; using Tango.MachineStudio.UI.Views; +using Tango.MachineStudio.UI.Windows; using Tango.PMR.Stubs; using Tango.SharedUI; +using Tango.SharedUI.Helpers; using Tango.Transport.Adapters; namespace Tango.MachineStudio.UI.ViewModels @@ -69,6 +74,11 @@ namespace Tango.MachineStudio.UI.ViewModels public RelayCommand<IStudioModule> StartModuleCommand { get; set; } /// <summary> + /// Gets or sets the open module in window command. + /// </summary> + public RelayCommand<IStudioModule> OpenModuleInWindowCommand { get; set; } + + /// <summary> /// Gets or sets the home command. /// </summary> public RelayCommand HomeCommand { get; set; } @@ -157,6 +167,7 @@ namespace Tango.MachineStudio.UI.ViewModels ConnectCommand = new RelayCommand(ConnectToMachine); SignoutCommand = new RelayCommand(SignOut); DisconnectCommand = new RelayCommand(DisconnectFromMachine, (x) => ApplicationManager.IsMachineConnected && !_isDisconnecting); + OpenModuleInWindowCommand = new RelayCommand<IStudioModule>(OpenModuleInWindow); } /// <summary> @@ -302,5 +313,28 @@ namespace Tango.MachineStudio.UI.ViewModels { base.OnViewAttached(); } + + private void OpenModuleInWindow(IStudioModule module) + { + module.InNewWindow = true; + + var parent = (MainView.Self as MainView).TransitionControl.Controls.SingleOrDefault(x => x.Tag.ToString() == module.Name).Content as Grid; + + var view = parent.Children[0] as FrameworkElement; + parent.Children.Remove(view); + + ModuleWindowVM vm = new ModuleWindowVM(module, parent); + ModuleWindow window = new ModuleWindow(this, vm, view); + + window.Closing += (x, y) => + { + window.grid.Children.Remove(view); + parent.Children.Add(view); + module.InNewWindow = false; + }; + + window.Owner = MainWindow.Instance; + window.Show(); + } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ModuleWindowVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ModuleWindowVM.cs new file mode 100644 index 000000000..a5b737b59 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ModuleWindowVM.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Controls; +using Tango.MachineStudio.Common; +using Tango.SharedUI; + +namespace Tango.MachineStudio.UI.ViewModels +{ + public class ModuleWindowVM : ViewModel + { + private IStudioModule _module; + + public IStudioModule Module + { + get { return _module; } + set { _module = value; RaisePropertyChangedAuto(); } + } + + public Grid Parent { get; set; } + + public ModuleWindowVM(IStudioModule module, Grid parent) + { + Parent = parent; + Module = module; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml index 479052cc5..19a5283c2 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml @@ -17,6 +17,7 @@ <UserControl.Resources> <converters:StringEllipsisConverter x:Key="StringEllipsisConverter" /> + <converters:BooleanToVisibilityInverseConverter x:Key="BooleanToVisibilityInverseConverter" /> </UserControl.Resources> <Grid> @@ -216,7 +217,7 @@ <ItemsControl.ItemTemplate> <DataTemplate> - <materialDesign:Card Width="300" Margin="10" Height="400"> + <materialDesign:Card Width="300" Margin="10" Height="400" Visibility="{Binding InNewWindow,Converter={StaticResource BooleanToVisibilityInverseConverter}}"> <Grid > <Grid.RowDefinitions> <RowDefinition Height="180" /> @@ -234,8 +235,8 @@ <StackPanel Grid.Row="2" Margin="8" HorizontalAlignment="Right" Orientation="Horizontal"> <materialDesign:PopupBox Padding="2,0,2,0" Style="{StaticResource MaterialDesignToolPopupBox}"> <StackPanel> - <Button Content="More" /> - <Button Content="Options" /> + <Button Content="Open in new window" Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.OpenModuleInWindowCommand}" CommandParameter="{Binding}" /> + <Button Content="Settings" /> </StackPanel> </materialDesign:PopupBox> </StackPanel> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml.cs index e6e1557f3..c40904173 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml.cs @@ -69,10 +69,13 @@ namespace Tango.MachineStudio.UI.Views { ThreadsHelper.InvokeUI(() => { + Grid grid = new Grid(); + grid.Children.Add(module.MainView); + TransitionControl.Controls.Add(new ContentControl() { Tag = module.Name, - Content = module.MainView + Content = grid, }); _loader.UserModules.Add(module); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ModuleWindow.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ModuleWindow.xaml new file mode 100644 index 000000000..8721cfd6a --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ModuleWindow.xaml @@ -0,0 +1,97 @@ +<mahapps:MetroWindow x:Class="Tango.MachineStudio.UI.Windows.ModuleWindow" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:local="clr-namespace:Tango.MachineStudio.UI.Windows" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:views="clr-namespace:Tango.MachineStudio.UI.Views" + xmlns:sharedControls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" + mc:Ignorable="d" + Title="{Binding RelativeSource={RelativeSource Self},Path=ModuleContext.Module.Name}" Height="800" Width="1280" WindowStartupLocation="CenterOwner" WindowState="Maximized" Foreground="#494949" BorderThickness="1" BorderBrush="{StaticResource AccentColorBrush}"> + + <Window.Resources> + <converters:StringEllipsisConverter x:Key="StringEllipsisConverter" /> + </Window.Resources> + + <Grid> + <Grid.Background> + <ImageBrush ImageSource="/Images/White-Abstract.png" Stretch="Fill"></ImageBrush> + </Grid.Background> + <Viewbox Stretch="Fill" UseLayoutRounding="True" SnapsToDevicePixels="True"> + <Grid Width="1920" Height="1145"> + <Grid> + <DockPanel> + <materialDesign:ColorZone Padding="16" materialDesign:ShadowAssist.ShadowDepth="Depth2" + Mode="PrimaryMid" DockPanel.Dock="Top"> + <DockPanel> + <Grid> + <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Height="60" HorizontalAlignment="Center"> + <Image Source="/Images/machine-trans.png" RenderOptions.BitmapScalingMode="Fant"></Image> + <TextBlock Text="Machine Studio" VerticalAlignment="Center" Margin="20 0 0 0" FontSize="36"/> + </StackPanel> + </Grid> + </DockPanel> + </materialDesign:ColorZone> + + <Grid> + <Grid> + <Grid.RowDefinitions> + <RowDefinition Height="Auto"/> + <RowDefinition Height="1*"/> + </Grid.RowDefinitions> + + <Grid Grid.Row="1" x:Name="grid"> + + </Grid> + </Grid> + + <Border HorizontalAlignment="Right" Margin="0 -1 10 0" VerticalAlignment="Top" Width="300" Height="40" Padding="5" CornerRadius="0 0 30 30" BorderThickness="1 0 1 1" BorderBrush="DimGray"> + <Border.Style> + <Style TargetType="Border"> + <Setter Property="RenderTransform"> + <Setter.Value> + <ScaleTransform ScaleX="1" ScaleY="0"></ScaleTransform> + </Setter.Value> + </Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding NotificationProvider.HasTaskItems}" Value="True"> + <DataTrigger.EnterActions> + <BeginStoryboard HandoffBehavior="Compose"> + <Storyboard> + <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleY" FillBehavior="HoldEnd" To="1" Duration="00:00:0.2"></DoubleAnimation> + </Storyboard> + </BeginStoryboard> + </DataTrigger.EnterActions> + <DataTrigger.ExitActions> + <BeginStoryboard HandoffBehavior="Compose"> + <Storyboard> + <DoubleAnimation BeginTime="00:00:02" FillBehavior="HoldEnd" Storyboard.TargetProperty="RenderTransform.ScaleY" To="0" From="1" Duration="00:00:0.5"></DoubleAnimation> + </Storyboard> + </BeginStoryboard> + </DataTrigger.ExitActions> + </DataTrigger> + </Style.Triggers> + </Style> + </Border.Style> + <Border.Background> + <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> + <GradientStop Color="#03A9F4"/> + <GradientStop Color="#0081BB" Offset="1"/> + </LinearGradientBrush> + </Border.Background> + + <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="20 0 0 0"> + <mahapps:ProgressRing Width="24" Height="24" Foreground="White"></mahapps:ProgressRing> + <TextBlock Text="{Binding NotificationProvider.CurrentTaskItem.Message,Converter={StaticResource StringEllipsisConverter},ConverterParameter=35}" Foreground="White" VerticalAlignment="Center" Margin="10 0 0 0" TextWrapping="Wrap"></TextBlock> + </StackPanel> + </Border> + </Grid> + </DockPanel> + </Grid> + </Grid> + </Viewbox> + </Grid> +</mahapps:MetroWindow> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ModuleWindow.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ModuleWindow.xaml.cs new file mode 100644 index 000000000..7ca062645 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ModuleWindow.xaml.cs @@ -0,0 +1,44 @@ +using MahApps.Metro.Controls; +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.Shapes; +using Tango.MachineStudio.UI.ViewModels; + +namespace Tango.MachineStudio.UI.Windows +{ + /// <summary> + /// Interaction logic for ModuleWindow.xaml + /// </summary> + public partial class ModuleWindow : MetroWindow + { + public ModuleWindowVM ModuleContext + { + get { return (ModuleWindowVM)GetValue(ModuleContextProperty); } + set { SetValue(ModuleContextProperty, value); } + } + public static readonly DependencyProperty ModuleContextProperty = + DependencyProperty.Register("ModuleContext", typeof(ModuleWindowVM), typeof(ModuleWindow), new PropertyMetadata(null)); + + public ModuleWindow() + { + InitializeComponent(); + } + + public ModuleWindow(MainViewVM mainViewVM, ModuleWindowVM moduleVM, FrameworkElement view) : this() + { + DataContext = mainViewVM; + ModuleContext = moduleVM; + grid.Children.Add(view); + } + } +} |
