diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-02-08 14:26:17 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-02-08 14:26:17 +0200 |
| commit | a1432b11d087a4b2f4530504e18434225b36bf48 (patch) | |
| tree | f3cd718c99872544f3c7a69eadcd27d5aa77911c /Software/Visual_Studio/MachineStudio | |
| parent | 4cf9cd72047bbb5a1c83255721870d29bbdb03f7 (diff) | |
| download | Tango-a1432b11d087a4b2f4530504e18434225b36bf48.tar.gz Tango-a1432b11d087a4b2f4530504e18434225b36bf48.zip | |
Moved all tech work to Technician module.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio')
14 files changed, 466 insertions, 61 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml new file mode 100644 index 000000000..d3ce4fc10 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml @@ -0,0 +1,87 @@ +<local:ElementEditor x:Class="Tango.MachineStudio.Technician.Editors.MonitorElementEditor" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:converters="clr-namespace:Tango.Editors.Converters;assembly=Tango.Editors" + xmlns:local="clr-namespace:Tango.Editors;assembly=Tango.Editors" + mc:Ignorable="d" + d:DesignHeight="300" d:DesignWidth="300" Background="Transparent" ClipToBounds="False" BorderThickness="0" MinWidth="1" MinHeight="1" RenderTransformOrigin="0.5,0.5"> + + <UserControl.Resources> + <converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"></converters:BoolToVisibilityConverter> + + <!--Theme--> + <SolidColorBrush x:Key="BorderBrush" Color="Transparent"></SolidColorBrush> + <SolidColorBrush x:Key="CornersBrush" Color="Red"></SolidColorBrush> + </UserControl.Resources> + + <UserControl.RenderTransform> + <RotateTransform Angle="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=Angle}"></RotateTransform> + </UserControl.RenderTransform> + + <Grid> + + + <!--Content--> + <Grid> + <Viewbox Stretch="Fill"> + <StackPanel> + <Grid Grid.Column="1" Grid.Row="1" Width="200" Height="120"> + <Border BorderThickness="1" BorderBrush="#878787" CornerRadius="5"> + <Border.Background> + <ImageBrush ImageSource="../Images/black-screen.jpg" /> + </Border.Background> + + <TextBlock FontFamily="../Fonts/#digital-7" TextAlignment="Center" VerticalAlignment="Center" Foreground="Gainsboro" FontSize="90" Text="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=Value,FallbackValue='0000'}"></TextBlock> + </Border> + </Grid> + </StackPanel> + </Viewbox> + + <Border Margin="0 0 0 -23" VerticalAlignment="Bottom"> + <TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=MonitorItem.TechMonitor.Description}" FontSize="14" Foreground="DimGray" HorizontalAlignment="Center"></TextBlock> + </Border> + </Grid> + <!--Content--> + + + <Border BorderThickness="1" BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=BorderBrush,TargetNullValue={StaticResource BorderBrush},FallbackValue={StaticResource BorderBrush}}" Visibility="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=(local:ElementsEditor.IsSelected),Converter={StaticResource BoolToVisibilityConverter}}"> + <Grid> + <ContentPresenter Content="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=InnerContent}"></ContentPresenter> + + <Thumb Opacity="0" DragDelta="MoveDrag" DragStarted="DragStarted" DragCompleted="OnDragEnded"></Thumb> + <Thumb HorizontalAlignment="Left" Cursor="SizeWE" Opacity="0" DragDelta="DragLeft" DragStarted="DragStarted" DragCompleted="OnDragEnded"></Thumb> + <Thumb HorizontalAlignment="Right" Cursor="SizeWE" Opacity="0" DragDelta="DragRight" DragStarted="DragStarted" DragCompleted="OnDragEnded"></Thumb> + <Thumb VerticalAlignment="Top" Cursor="SizeNS" Opacity="0" DragDelta="DragTop" DragStarted="DragStarted" DragCompleted="OnDragEnded"></Thumb> + <Thumb VerticalAlignment="Bottom" Cursor="SizeNS" Opacity="0" DragDelta="DragBottom" DragStarted="DragStarted" DragCompleted="OnDragEnded"></Thumb> + + <Grid ClipToBounds="False" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0 -20 0 0" Width="10" Height="10"> + <Ellipse Stroke="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=CornersBrush,TargetNullValue={StaticResource CornersBrush},FallbackValue={StaticResource CornersBrush}}" StrokeThickness="2"></Ellipse> + <Rectangle HorizontalAlignment="Center" VerticalAlignment="Stretch" Margin="0 10 0 -8" StrokeThickness="1" Stroke="Red"></Rectangle> + <Thumb Opacity="0" DragDelta="DragAngle" DragStarted="DragStarted" Cursor="Arrow" DragCompleted="OnDragEnded"></Thumb> + </Grid> + + <Grid Width="10" Height="10" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="-8 -8 0 0"> + <Border BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=CornersBrush,TargetNullValue={StaticResource CornersBrush},FallbackValue={StaticResource CornersBrush}}" BorderThickness="2 2 0 0"></Border> + <Thumb Opacity="0" DragDelta="DragTopLeft" DragStarted="DragStarted" Cursor="SizeNWSE" DragCompleted="OnDragEnded"></Thumb> + </Grid> + + <Grid Width="10" Height="10" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0 -8 -8 0"> + <Border BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=CornersBrush,TargetNullValue={StaticResource CornersBrush},FallbackValue={StaticResource CornersBrush}}" BorderThickness="0 2 2 0"></Border> + <Thumb Opacity="0" DragDelta="DragTopRight" DragStarted="DragStarted" Cursor="SizeNESW" DragCompleted="OnDragEnded"></Thumb> + </Grid> + + <Grid Width="10" Height="10" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0 0 -8 -8"> + <Border BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=CornersBrush,TargetNullValue={StaticResource CornersBrush},FallbackValue={StaticResource CornersBrush}}" BorderThickness="0 0 2 2"></Border> + <Thumb Opacity="0" DragDelta="DragBottomRight" DragStarted="DragStarted" Cursor="SizeNWSE" DragCompleted="OnDragEnded"></Thumb> + </Grid> + + <Grid Width="10" Height="10" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="-8 0 0 -8"> + <Border BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:ElementEditor},Path=CornersBrush,TargetNullValue={StaticResource CornersBrush},FallbackValue={StaticResource CornersBrush}}" BorderThickness="2 0 0 2"></Border> + <Thumb Opacity="0" DragDelta="DragBottomLeft" DragStarted="DragStarted" Cursor="SizeNESW" DragCompleted="OnDragEnded"></Thumb> + </Grid> + </Grid> + </Border> + </Grid> +</local:ElementEditor> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml.cs new file mode 100644 index 000000000..f50fc9039 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml.cs @@ -0,0 +1,127 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Markup; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.Editors; +using Tango.Integration.Observables; +using Tango.MachineStudio.Technician.Items; + +namespace Tango.MachineStudio.Technician.Editors +{ + /// <summary> + /// <para><img class="classImage" src="../Media/MonitorElementEditor.png" /></para> + /// Represents a <see cref="FrameworkElement"/> editor with position, size and angle control. + /// </summary> + /// <example> + /// <para class="example-title"> + /// <img class="exampleIcon" src="../Icons/CodeExample.png" /> + /// <i> + /// The following example demonstrates a basic scenario of using <see cref="N:WpfVideoTools.Tiles"/> and <see cref="N:Tango.Editors"/> by creating a simple video projection application with the following features: + /// </i> + /// <list type="bullet"> + /// <item>Use the mouse to draw any type of tile of the editor surface.</item> + /// <item>Apply any input shape on any tile.</item> + /// <item>Load any video and display it on any of the selected tile.</item> + /// <item>Built in support for undo, redo, cut, copy and paste, delete and select operations.</item> + /// <item>Built in support for saving/loading the editor state to memory or file.</item> + /// <item>Built in support for tile and editor properties adjustment using the <see cref="ParameterizedEditor"/>.</item> + /// </list> + /// </para> + /// <para><markup><video class="exampleVideo" autoplay="autoplay" loop="loop" controls="controls" src="../Media/EditorsExample.mp4"></video></markup></para> + /// <code lang="XAML" source="../FullAPIExamples/Examples/Editors/EditorsExample.xaml" title="Elements editor example." /> + /// <i>Code-Behind.</i> + /// <code lang="C#" source="../FullAPIExamples/Examples/Editors/EditorsExample.xaml.cs" title="Elements editor example." /> + /// </example> + /// <seealso cref="Tango.Editors.ElementEditor" /> + [ContentProperty("InnerContent")] + public partial class MonitorElementEditor : ElementEditor + { + /// <summary> + /// Initializes a new instance of the <see cref="MonitorElementEditor"/> class. + /// </summary> + public MonitorElementEditor() + : base() + { + InitializeComponent(); + } + + /// <summary> + /// Initializes a new instance of the <see cref="MonitorElementEditor"/> class. + /// </summary> + /// <param name="frameworkElement">The framework element.</param> + public MonitorElementEditor(MonitorItem monitorItem) + : this() + { + MonitorItem = monitorItem; + } + + /// <summary> + /// Initializes a new instance of the <see cref="MonitorElementEditor"/> class. + /// </summary> + /// <param name="frameworkElement">The framework element.</param> + /// <param name="bounds">The bounds.</param> + public MonitorElementEditor(MonitorItem monitorItem, Rect bounds) + : this(monitorItem) + { + Left = bounds.Left; + Top = bounds.Top; + Width = bounds.Width; + Height = bounds.Height; + } + + private MonitorItem _monitorItem; + + public MonitorItem MonitorItem + { + get { return _monitorItem; } + set { _monitorItem = value; RaisePropertyChanged(nameof(MonitorItem)); } + } + + + /// <summary> + /// Clones this instance. + /// </summary> + /// <returns></returns> + public override IElementEditor Clone() + { + try + { + MonitorElementEditor cloned = new MonitorElementEditor(); + + cloned.MonitorItem = MonitorItem.Clone() as MonitorItem; + cloned.Top = Top; + cloned.Left = Left; + cloned.Width = Width; + cloned.Height = Height; + cloned.Angle = Angle; + return cloned; + } + catch (Exception ex) + { + throw new InvalidOperationException("Could not clone this editor. You may have to create a custom editor and implement a custom Clone method.", ex); + } + } + + /// <summary> + /// Gets the hosted element. + /// </summary> + [ParameterIgnore] + public override Object HostedElement + { + get { return MonitorItem; } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Fonts/digital-7.ttf b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Fonts/digital-7.ttf Binary files differnew file mode 100644 index 000000000..5dbe6f908 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Fonts/digital-7.ttf diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/black-screen.jpg b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/black-screen.jpg Binary files differnew file mode 100644 index 000000000..7ed5c3eb2 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/black-screen.jpg diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Items/MonitorItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Items/MonitorItem.cs new file mode 100644 index 000000000..4150e3784 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Items/MonitorItem.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Integration.Observables; + +namespace Tango.MachineStudio.Technician.Items +{ + public class MonitorItem : TechItem + { + private TechMonitor _techMonitor; + public TechMonitor TechMonitor + { + get { return _techMonitor; } + set { _techMonitor = value; RaisePropertyChangedAuto(); } + } + + private double _value; + public double Value + { + get { return _value; } + set { _value = value; RaisePropertyChanged(nameof(Value)); } + } + + public MonitorItem() : base() + { + + } + + public MonitorItem(TechMonitor techMonitor) : this() + { + TechMonitor = techMonitor; + } + + public override TechItem Clone() + { + MonitorItem cloned = base.Clone() as MonitorItem; + cloned.TechMonitor = TechMonitor; + return cloned; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Items/TechItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Items/TechItem.cs new file mode 100644 index 000000000..bfeeef011 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Items/TechItem.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; + +namespace Tango.MachineStudio.Technician.Items +{ + public abstract class TechItem : ExtendedObject + { + public TechItem() + { + ID = Guid.NewGuid().ToString(); + Name = "Untitled"; + } + + private String _id; + /// <summary> + /// Unique Item ID. + /// </summary> + public String ID + { + get { return _id; } + set { _id = value; RaisePropertyChanged(nameof(ID)); } + } + + private String _name; + /// <summary> + /// item Name. + /// </summary> + public String Name + { + get { return _name; } + set { _name = value; RaisePropertyChanged(nameof(Name)); } + } + + private double _left; + /// <summary> + /// Item Left. + /// </summary> + public double Left + { + get { return _left; } + set { _left = value; RaisePropertyChanged(nameof(Left)); } + } + + private double _top; + /// <summary> + /// Item Top. + /// </summary> + public double Top + { + get { return _top; } + set { _top = value; RaisePropertyChanged(nameof(Top)); } + } + + private double _width; + /// <summary> + /// Item Width. + /// </summary> + public double Width + { + get { return _width; } + set { _width = value; RaisePropertyChanged(nameof(Width)); } + } + + private double _height; + /// <summary> + /// Item Height. + /// </summary> + public double Height + { + get { return _height; } + set { _height = value; RaisePropertyChanged(nameof(Height)); } + } + + private double _angle; + /// <summary> + /// Item Angle. + /// </summary> + public double Angle + { + get { return _angle; } + set { _angle = value; RaisePropertyChanged(nameof(Angle)); } + } + + public virtual TechItem Clone() + { + TechItem cloned = Activator.CreateInstance(this.GetType()) as TechItem; + cloned.Left = Left; + cloned.Top = Top; + cloned.Width = Width; + cloned.Height = Height; + cloned.Angle = Angle; + return cloned; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj index 196589e99..6d3ae9c1a 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj @@ -79,13 +79,22 @@ <ItemGroup> <Compile Include="Converters\SecondsToGraphPointsConverter.cs" /> <Compile Include="Converters\TransitionLinkConverter.cs" /> + <Compile Include="Editors\MonitorElementEditor.xaml.cs"> + <DependentUpon>MonitorElementEditor.xaml</DependentUpon> + </Compile> <Compile Include="Helpers\GraphsHelper.cs" /> + <Compile Include="Items\MonitorItem.cs" /> + <Compile Include="Items\TechItem.cs" /> <Compile Include="Navigation\TechNavigationView.cs" /> <Compile Include="Navigation\TechNavigationManager.cs" /> <Compile Include="TechnicianModule.cs" /> <Compile Include="ViewModelLocator.cs" /> + <Compile Include="ViewModels\MachineTechViewVM.cs" /> <Compile Include="ViewModels\MainViewVM.cs" /> <Compile Include="ViewModels\SensorsViewVM.cs" /> + <Compile Include="Views\MachineTechView.xaml.cs"> + <DependentUpon>MachineTechView.xaml</DependentUpon> + </Compile> <Compile Include="Views\MotorsView.xaml.cs"> <DependentUpon>MotorsView.xaml</DependentUpon> </Compile> @@ -101,10 +110,18 @@ <Compile Include="..\..\..\Versioning\GlobalVersionInfo.cs"> <Link>GlobalVersionInfo.cs</Link> </Compile> + <Page Include="Editors\MonitorElementEditor.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> <Page Include="Resources\GraphEx.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Views\MachineTechView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> <Page Include="Views\MotorsView.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -141,6 +158,7 @@ <LastGenOutput>Resources.Designer.cs</LastGenOutput> </EmbeddedResource> <None Include="app.config" /> + <Resource Include="Fonts\digital-7.ttf" /> <None Include="packages.config" /> <None Include="Properties\Settings.settings"> <Generator>SettingsSingleFileGenerator</Generator> @@ -156,6 +174,10 @@ <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> <Name>Tango.Core</Name> </ProjectReference> + <ProjectReference Include="..\..\..\Tango.Editors\Tango.Editors.csproj"> + <Project>{de2f2b86-025b-4f26-83a4-38bd48224ed5}</Project> + <Name>Tango.Editors</Name> + </ProjectReference> <ProjectReference Include="..\..\..\Tango.Integration\Tango.Integration.csproj"> <Project>{4206ac58-3b57-4699-8835-90bf6db01a61}</Project> <Name>Tango.Integration</Name> @@ -188,5 +210,8 @@ <ItemGroup> <Resource Include="Images\technician.jpg" /> </ItemGroup> + <ItemGroup> + <Resource Include="Images\black-screen.jpg" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModelLocator.cs index e7fea686d..077b30663 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModelLocator.cs @@ -21,6 +21,7 @@ namespace Tango.MachineStudio.Technician SimpleIoc.Default.Register<MainViewVM>(); SimpleIoc.Default.Register<SensorsViewVM>(); + SimpleIoc.Default.Register<MachineTechViewVM>(); SimpleIoc.Default.Unregister<TechNavigationManager>(); @@ -42,5 +43,13 @@ namespace Tango.MachineStudio.Technician return ServiceLocator.Current.GetInstance<SensorsViewVM>(); } } + + public static MachineTechViewVM MachineTechViewVM + { + get + { + return ServiceLocator.Current.GetInstance<MachineTechViewVM>(); + } + } } }
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs new file mode 100644 index 000000000..51c2b840d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using Tango.Editors; +using Tango.Integration.Observables; +using Tango.MachineStudio.Technician.Editors; +using Tango.MachineStudio.Technician.Items; +using Tango.SharedUI; + +namespace Tango.MachineStudio.Technician.ViewModels +{ + public class MachineTechViewVM : ViewModel + { + private ObservableCollection<IElementEditor> _elements; + + public ObservableCollection<IElementEditor> Elements + { + get { return _elements; } + set { _elements = value; RaisePropertyChangedAuto(); } + } + + public ObservablesEntitiesAdapter Adapter { get; set; } + + public MachineTechViewVM() + { + Adapter = ObservablesEntitiesAdapter.Instance; + Adapter.Initialize(); //TODO: Remove on Machine Studio. + Elements = new ObservableCollection<IElementEditor>(); + } + + public void AddElement(Rect bounds) + { + MonitorItem item = new MonitorItem(Adapter.TechMonitors.FirstOrDefault()); + MonitorElementEditor editor = new MonitorElementEditor(item, bounds); + Elements.Add(editor); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineTech/MachineTechView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml index 192122a30..256a4a385 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineTech/MachineTechView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml @@ -1,15 +1,15 @@ -<UserControl x:Class="Tango.MachineStudio.Common.MachineTech.MachineTechView" +<UserControl x:Class="Tango.MachineStudio.Technician.Views.MachineTechView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:vm="clr-namespace:Tango.MachineStudio.Common.ViewModels" - xmlns:global="clr-namespace:Tango.MachineStudio.Common" + xmlns:vm="clr-namespace:Tango.MachineStudio.Technician.ViewModels" + xmlns:global="clr-namespace:Tango.MachineStudio.Technician" xmlns:editors="clr-namespace:Tango.Editors;assembly=Tango.Editors" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:local="clr-namespace:Tango.MachineStudio.Common.MachineTech" + xmlns:local="clr-namespace:Tango.MachineStudio.Technician.Views" mc:Ignorable="d" d:DesignHeight="720" d:DesignWidth="1280" Background="White" d:DataContext="{d:DesignInstance Type=vm:MachineTechViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MachineTechViewVM}"> @@ -48,7 +48,20 @@ </Grid.ColumnDefinitions> <Grid> - <editors:ElementsEditor Margin="0 0 5 0" RulerHeight="32" FontSize="10" Background="White" EditorBackground="White" RulerBackground="White" Foreground="{StaticResource AccentColorBrush}" SelectionFillBrush="#338D8D8D" SelectionStrokeBrush="{StaticResource AccentColorBrush}" BorderBrush="{StaticResource AccentColorBrush}" BorderThickness="1" /> + <editors:ElementsEditor + Elements="{Binding Elements}" + ElementCreation="ElementsEditor_ElementCreation" + Margin="0 0 5 0" + RulerHeight="32" + FontSize="10" + Background="White" + EditorBackground="White" + RulerBackground="White" + Foreground="{StaticResource AccentColorBrush}" + SelectionFillBrush="#338D8D8D" + SelectionStrokeBrush="{StaticResource AccentColorBrush}" + BorderBrush="{StaticResource AccentColorBrush}" + BorderThickness="1" /> </Grid> <Grid Grid.Column="1"> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineTech/MachineTechView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml.cs index 6546fd09e..5944af1e2 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineTech/MachineTechView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml.cs @@ -12,17 +12,32 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using Tango.Editors; +using Tango.MachineStudio.Technician.ViewModels; -namespace Tango.MachineStudio.Common.MachineTech +namespace Tango.MachineStudio.Technician.Views { /// <summary> /// Interaction logic for MachineTechView.xaml /// </summary> public partial class MachineTechView : UserControl { + private MachineTechViewVM _vm; + public MachineTechView() { InitializeComponent(); + + this.Loaded += (x, y) => + { + _vm = DataContext as MachineTechViewVM; + }; + } + + private void ElementsEditor_ElementCreation(object sender, ElementCreationEventArgs e) + { + _vm.AddElement(e.Bounds); + e.AppendUndoState = true; } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj index d0ddd7267..7def48cb5 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj @@ -92,11 +92,6 @@ <Compile Include="Messages\IStudioMessage.cs" /> <Compile Include="Notifications\TaskItem.cs" /> <Compile Include="ValidationRules\Required.cs" /> - <Compile Include="ViewModelLocator.cs" /> - <Compile Include="ViewModels\MachineTechViewVM.cs" /> - <Compile Include="MachineTech\MachineTechView.xaml.cs"> - <DependentUpon>MachineTechView.xaml</DependentUpon> - </Compile> <Page Include="Controls\HiveColorPickerControl.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -131,10 +126,6 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> - <Page Include="MachineTech\MachineTechView.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.Common/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/ViewModelLocator.cs deleted file mode 100644 index 6dcf23289..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/ViewModelLocator.cs +++ /dev/null @@ -1,33 +0,0 @@ -using GalaSoft.MvvmLight; -using GalaSoft.MvvmLight.Ioc; -using Microsoft.Practices.ServiceLocation; -using Tango.MachineStudio.Common.ViewModels; -using Tango.MachineStudio.Common.MachineTech; - -namespace Tango.MachineStudio.Common -{ - /// <summary> - /// This class contains static references to all the view models in the - /// application and provides an entry point for the bindings. - /// </summary> - public static class ViewModelLocator - { - /// <summary> - /// Initializes a new instance of the ViewModelLocator class. - /// </summary> - static ViewModelLocator() - { - ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); - - SimpleIoc.Default.Register<MachineTechViewVM>(); - } - - public static MachineTechViewVM MachineTechViewVM - { - get - { - return ServiceLocator.Current.GetInstance<MachineTechViewVM>(); - } - } - } -}
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/ViewModels/MachineTechViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/ViewModels/MachineTechViewVM.cs deleted file mode 100644 index eeb490d99..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/ViewModels/MachineTechViewVM.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.SharedUI; - -namespace Tango.MachineStudio.Common.ViewModels -{ - public class MachineTechViewVM : ViewModel - { - } -} |
