From a1432b11d087a4b2f4530504e18434225b36bf48 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 8 Feb 2018 14:26:17 +0200 Subject: Moved all tech work to Technician module. --- .../Editors/MonitorElementEditor.xaml | 87 ++++++++++++++ .../Editors/MonitorElementEditor.xaml.cs | 127 +++++++++++++++++++++ .../Fonts/digital-7.ttf | Bin 0 -> 34360 bytes .../Images/black-screen.jpg | Bin 0 -> 15003 bytes .../Items/MonitorItem.cs | 43 +++++++ .../Items/TechItem.cs | 99 ++++++++++++++++ .../Tango.MachineStudio.Technician.csproj | 25 ++++ .../ViewModelLocator.cs | 9 ++ .../ViewModels/MachineTechViewVM.cs | 42 +++++++ .../Views/MachineTechView.xaml | 75 ++++++++++++ .../Views/MachineTechView.xaml.cs | 43 +++++++ 11 files changed, 550 insertions(+) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Fonts/digital-7.ttf create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/black-screen.jpg create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Items/MonitorItem.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Items/TechItem.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules') 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 +{ + /// + /// + /// Represents a editor with position, size and angle control. + /// + /// + /// + /// + /// + /// The following example demonstrates a basic scenario of using and by creating a simple video projection application with the following features: + /// + /// + /// Use the mouse to draw any type of tile of the editor surface. + /// Apply any input shape on any tile. + /// Load any video and display it on any of the selected tile. + /// Built in support for undo, redo, cut, copy and paste, delete and select operations. + /// Built in support for saving/loading the editor state to memory or file. + /// Built in support for tile and editor properties adjustment using the . + /// + /// + /// + /// + /// Code-Behind. + /// + /// + /// + [ContentProperty("InnerContent")] + public partial class MonitorElementEditor : ElementEditor + { + /// + /// Initializes a new instance of the class. + /// + public MonitorElementEditor() + : base() + { + InitializeComponent(); + } + + /// + /// Initializes a new instance of the class. + /// + /// The framework element. + public MonitorElementEditor(MonitorItem monitorItem) + : this() + { + MonitorItem = monitorItem; + } + + /// + /// Initializes a new instance of the class. + /// + /// The framework element. + /// The bounds. + 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)); } + } + + + /// + /// Clones this instance. + /// + /// + 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); + } + } + + /// + /// Gets the hosted element. + /// + [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 new file mode 100644 index 000000000..5dbe6f908 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Fonts/digital-7.ttf differ 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 new file mode 100644 index 000000000..7ed5c3eb2 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Images/black-screen.jpg differ 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; + /// + /// Unique Item ID. + /// + public String ID + { + get { return _id; } + set { _id = value; RaisePropertyChanged(nameof(ID)); } + } + + private String _name; + /// + /// item Name. + /// + public String Name + { + get { return _name; } + set { _name = value; RaisePropertyChanged(nameof(Name)); } + } + + private double _left; + /// + /// Item Left. + /// + public double Left + { + get { return _left; } + set { _left = value; RaisePropertyChanged(nameof(Left)); } + } + + private double _top; + /// + /// Item Top. + /// + public double Top + { + get { return _top; } + set { _top = value; RaisePropertyChanged(nameof(Top)); } + } + + private double _width; + /// + /// Item Width. + /// + public double Width + { + get { return _width; } + set { _width = value; RaisePropertyChanged(nameof(Width)); } + } + + private double _height; + /// + /// Item Height. + /// + public double Height + { + get { return _height; } + set { _height = value; RaisePropertyChanged(nameof(Height)); } + } + + private double _angle; + /// + /// Item Angle. + /// + 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 @@ + + MonitorElementEditor.xaml + + + + + + MachineTechView.xaml + MotorsView.xaml @@ -101,10 +110,18 @@ GlobalVersionInfo.cs + + MSBuild:Compile + Designer + Designer MSBuild:Compile + + MSBuild:Compile + Designer + Designer MSBuild:Compile @@ -141,6 +158,7 @@ Resources.Designer.cs + SettingsSingleFileGenerator @@ -156,6 +174,10 @@ {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} Tango.Core + + {de2f2b86-025b-4f26-83a4-38bd48224ed5} + Tango.Editors + {4206ac58-3b57-4699-8835-90bf6db01a61} Tango.Integration @@ -188,5 +210,8 @@ + + + \ 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(); SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); SimpleIoc.Default.Unregister(); @@ -42,5 +43,13 @@ namespace Tango.MachineStudio.Technician return ServiceLocator.Current.GetInstance(); } } + + public static MachineTechViewVM MachineTechViewVM + { + get + { + return ServiceLocator.Current.GetInstance(); + } + } } } \ 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 _elements; + + public ObservableCollection 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(); + } + + 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/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml new file mode 100644 index 000000000..256a4a385 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml.cs new file mode 100644 index 000000000..5944af1e2 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.Editors; +using Tango.MachineStudio.Technician.ViewModels; + +namespace Tango.MachineStudio.Technician.Views +{ + /// + /// Interaction logic for MachineTechView.xaml + /// + 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; + } + } +} -- cgit v1.3.1