From a794a5d088b425d7b41f87d7c3a43b904249e11e Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 19 Feb 2018 17:52:10 +0200 Subject: Working on developer module... --- .../Tango.MachineStudio.Developer.csproj | 7 - .../ViewModelLocator.cs | 2 +- .../ViewModels/MainViewVM.cs | 251 +-- .../Views/JobView.xaml | 2 +- .../Views/JobView.xaml.cs | 8 - .../Views/MachineJobSelectionView.xaml | 4 +- .../Views/MainView.xaml | 2246 -------------------- .../Views/MainView.xaml.cs | 162 -- 8 files changed, 46 insertions(+), 2636 deletions(-) delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer') 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 eae234a8b..f986219e2 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 @@ -136,9 +136,6 @@ MachineJobSelectionView.xaml - - MainView.xaml - GlobalVersionInfo.cs @@ -165,10 +162,6 @@ Designer MSBuild:Compile - - Designer - MSBuild:Compile - Designer MSBuild:Compile diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModelLocator.cs index 415643e3f..b397f1912 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModelLocator.cs @@ -20,7 +20,7 @@ namespace Tango.MachineStudio.Developer { ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); - SimpleIoc.Default.Register(() => MainView.Self); + //SimpleIoc.Default.Register(() => MainView.Self); SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); } 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 c8a6aa89f..199183c12 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 @@ -45,14 +45,12 @@ namespace Tango.MachineStudio.Developer.ViewModels /// Represents the developer module main view, view model. /// /// - public class MainViewVM : ViewModel, IShutdownRequestBlocker + public class MainViewVM : ViewModel, IShutdownRequestBlocker { private static object _syncLock = new object(); private INotificationProvider _notification; private TimeSpan _runningJobEstimatedDuration; - private Dictionary _controllers; - private int _fullScreenGraphIndex; private JobHandler _jobHandler; private DeveloperNavigationManager _navigation; private ObservablesContext _dbJobContext; @@ -62,6 +60,16 @@ namespace Tango.MachineStudio.Developer.ViewModels #region Properties + private ObservableCollection _machines; + /// + /// Gets or sets the machines. + /// + public ObservableCollection Machines + { + get { return _machines; } + set { _machines = value; RaisePropertyChangedAuto(); } + } + private ObservableCollection _colorSpaces; /// /// Gets or sets the color spaces. @@ -82,6 +90,15 @@ namespace Tango.MachineStudio.Developer.ViewModels set { _rmls = value; RaisePropertyChangedAuto(); } } + private ObservableCollection _windingMethods; + + public ObservableCollection WindingMethods + { + get { return _windingMethods; } + set { _windingMethods = value; RaisePropertyChangedAuto(); } + } + + /// /// Gets or sets the application manager. /// @@ -92,11 +109,6 @@ namespace Tango.MachineStudio.Developer.ViewModels /// public IVideoCaptureProvider VideoCaptureProvider { get; set; } - /// - /// Gets or sets observable entites database the adapter. - /// - public ObservablesEntitiesAdapter Adapter { get; set; } - protected Machine _selectedMachine; /// /// Gets or sets the selected machine. @@ -286,26 +298,6 @@ namespace Tango.MachineStudio.Developer.ViewModels set { _isSideBarOpened = value; RaisePropertyChangedAuto(); } } - private ObservableCollection _availableGraphs; - /// - /// Gets or sets the available sensors. - /// - public ObservableCollection AvailableGraphs - { - get { return _availableGraphs; } - set { _availableGraphs = value; RaisePropertyChangedAuto(); } - } - - private ObservableCollection _graphs; - /// - /// Gets or sets the collection of displayed graph controls. - /// - public ObservableCollection Graphs - { - get { return _graphs; } - set { _graphs = value; RaisePropertyChangedAuto(); } - } - private TimeSpan _estimatedDuration; /// /// Gets or sets the estimated duration for the selected job. @@ -556,16 +548,6 @@ namespace Tango.MachineStudio.Developer.ViewModels /// public RelayCommand CloseJobCompletionStatusCommand { get; set; } - /// - /// Gets or sets the toggle camera command. - /// - public RelayCommand ToggleCameraCommand { get; set; } - - /// - /// Gets or sets the exit full screen command. - /// - public RelayCommand ExitFullScreenCommand { get; set; } - /// /// Gets or sets the load job command. /// @@ -593,16 +575,9 @@ namespace Tango.MachineStudio.Developer.ViewModels /// /// Initializes a new instance of the class. /// - public MainViewVM(IMainView view) : base(view, true) + public MainViewVM() : base() { - if (!this.DesignMode) - { - Adapter = ObservablesEntitiesAdapter.Instance; - AvailableGraphs = Adapter.TechMonitors.ToObservableCollection(); - } - Graphs = new ObservableCollection(); - _controllers = new Dictionary(); } /// @@ -611,8 +586,13 @@ namespace Tango.MachineStudio.Developer.ViewModels /// The application manager. /// The notification provider. [PreferredConstructor] - public MainViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IMainView view, IDiagnosticsFrameProvider diagnosticsFrameProvider, IVideoCaptureProvider videoCaptureProvider, DeveloperNavigationManager navigation, IAuthenticationProvider authentication) : this(view) + public MainViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IDiagnosticsFrameProvider diagnosticsFrameProvider, IVideoCaptureProvider videoCaptureProvider, DeveloperNavigationManager navigation, IAuthenticationProvider authentication) : this() { + using (var db = ObservablesContext.CreateDefault()) + { + Machines = db.Machines.ToObservableCollection(); + } + _machineDBContext = ObservablesContext.CreateDefault(); SelectedJobs = new ObservableCollection(); @@ -623,7 +603,6 @@ namespace Tango.MachineStudio.Developer.ViewModels _navigation = navigation; ApplicationManager = applicationManager; VideoCaptureProvider = videoCaptureProvider; - diagnosticsFrameProvider.FrameReceived += DiagnosticsFrameProvider_FrameReceived; //Initialize Commands... EditMachineCommand = new RelayCommand(EditMachine, () => SelectedMachine != null); @@ -642,14 +621,11 @@ namespace Tango.MachineStudio.Developer.ViewModels StartJobCommand = new RelayCommand(StartJob, () => ActiveJob != null && !IsJobRunning); StopJobCommand = new RelayCommand(StopJob, () => IsJobRunning); CloseJobCompletionStatusCommand = new RelayCommand(CloseJobCompletionStatusBar); - ExitFullScreenCommand = new RelayCommand(ExitFullScreen); LoadJobCommand = new RelayCommand(LoadJob, () => SelectedMachineJob != null); DuplicateJobCommand = new RelayCommand(DuplicateSelectedJobs, () => SelectedMachineJob != null); DuplicateSegmentCommand = new RelayCommand(DuplicateSelectedSegments, () => SelectedSegment != null); DuplicateBrushStopCommand = new RelayCommand(DuplicateSelectedBrushStops, () => SelectedBrushStop != null); - ToggleCameraCommand = new RelayCommand(ToggleCamera); - ApplicationManager.ConnectedMachineChanged += ApplicationManager_ConnectedMachineChanged; } @@ -657,16 +633,6 @@ namespace Tango.MachineStudio.Developer.ViewModels #region Event Handlers - /// - /// Handles the diagnostics provider frame received event. - /// - /// The sender. - /// The response. - private void DiagnosticsFrameProvider_FrameReceived(object sender, PushDiagnosticsResponse response) - { - PopulateDiagnosticsData(response); - } - /// /// Handles the application manager connected machine changes event. /// @@ -835,6 +801,7 @@ namespace Tango.MachineStudio.Developer.ViewModels ColorSpaces = _dbJobContext.ColorSpaces.ToObservableCollection(); Rmls = _dbJobContext.Rmls.ToObservableCollection(); + WindingMethods = _dbJobContext.WindingMethods.ToObservableCollection(); _activeJob = _dbJobContext.Jobs.SingleOrDefault(x => x.Guid == SelectedMachineJob.Guid); @@ -896,59 +863,6 @@ namespace Tango.MachineStudio.Developer.ViewModels } } - private void ClearGraphs() - { - _controllers.ToList().ForEach(x => x.Value.Clear()); - } - - private void PopulateDiagnosticsData(PushDiagnosticsResponse data) - { - foreach (var prop in data.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)) - { - GraphControllerBase controller = null; - - if (_controllers.TryGetValue(prop.Name, out controller)) - { - if (controller is GraphController) - { - double[] arr = Enumerable.ToArray(prop.GetValue(data) as IEnumerable); - (controller as GraphController).PushData(arr); - } - else - { - DoubleArray[] arrayOfDoubles = Enumerable.ToArray(prop.GetValue(data) as IEnumerable); - (controller as GraphMultiController).PushData(arrayOfDoubles.Select(x => x.Data.ToList()).ToList()); - } - } - } - } - - private void ExitFullScreen() - { - if (FullScreenGraph != null) - { - FullScreenGraph.EnableToolBar = true; - Graphs.Insert(_fullScreenGraphIndex, FullScreenGraph); - FullScreenGraph = null; - } - } - - private void StartFullScreenGraph(IRealTimeGraph graph) - { - graph.EnableToolBar = false; - _fullScreenGraphIndex = Graphs.IndexOf(graph); - Graphs.Remove(graph); - FullScreenGraph = graph; - } - - private void ToggleCamera(CaptureDevice captureDevice) - { - if (captureDevice.Device != null) - { - captureDevice.IsStarted = !captureDevice.IsStarted; - } - } - private void CloseJobCompletionStatusBar() { _navigation.NavigateTo(DeveloperNavigationView.JobView); @@ -1138,15 +1052,9 @@ namespace Tango.MachineStudio.Developer.ViewModels g.Active = false; } - //String machineGuid = SelectedMachine.Guid; - //String rmlGuid = SelectedRML.Guid; - SelectedRML.ProcessParametersTablesGroups.Add(group); await SelectedRML.SaveAsync(); - //SelectedMachine = Adapter.Machines.SingleOrDefault(x => x.Guid == machineGuid); - //SelectedRML = Adapter.Rmls.SingleOrDefault(x => x.Guid == rmlGuid); - InvalidateLiquidFactorsAndProcessTables(); } } @@ -1329,8 +1237,8 @@ namespace Tango.MachineStudio.Developer.ViewModels newJob.Name = jobName; newJob.CreationDate = DateTime.UtcNow; newJob.User = _authentication.CurrentUser; - newJob.Rml = Adapter.Rmls.FirstOrDefault(); - newJob.WindingMethod = Adapter.WindingMethods.FirstOrDefault(); + newJob.Rml = _machineDBContext.Rmls.FirstOrDefault(); + newJob.WindingMethod = _machineDBContext.WindingMethods.FirstOrDefault(); newJob.Machine = SelectedMachine; SelectedMachine.Jobs.Add(newJob); @@ -1462,68 +1370,6 @@ namespace Tango.MachineStudio.Developer.ViewModels #region Public Methods - /// - /// Add sensor graph from available sensors to displayed graphs. - /// - /// The sensor. - public void OnDropAvailableGraph(TechMonitor sensor) - { - if (Graphs.Count < 8) - { - IRealTimeGraph graphControl = null; - GraphControllerBase controller = null; - - if (!sensor.MultiChannel) - { - graphControl = new RealTimeGraphControl(); - controller = new GraphController(); - graphControl.Controller = controller; - } - else - { - graphControl = new RealTimeGraphMultiControl(); - controller = new GraphMultiController(); - - for (int i = 0; i < sensor.ChannelCount; i++) - { - var randomColor = new SolidColorBrush(Core.Helpers.ColorHelper.GetRandomColor()); - - (controller as GraphMultiController).AddSeries(new DataYSeries() - { - Name = sensor.Description.First().ToString() + (i + 1), - UseFillAndStroke = true, - Stroke = randomColor - }); - } - - graphControl.Controller = controller; - } - - graphControl.Tag = sensor; - graphControl.SensorName = sensor.Description; - graphControl.SensorUnits = sensor.Units; - graphControl.InnerGraph.Minimum = sensor.Min; - graphControl.InnerGraph.Maximum = sensor.Max; - graphControl.InnerGraph.MaxPoints = Common.Helpers.GraphsHelper.GetMaxPoints(sensor.PointsPerFrame); - graphControl.GraphRemoveButtonPressed += (sender, _) => - { - RemoveGraph(sender as IRealTimeGraph); - }; - graphControl.GraphFullScreenButtonPressed += (sender, _) => - { - StartFullScreenGraph(sender as IRealTimeGraph); - }; - Graphs.Add(graphControl); - AvailableGraphs.Remove(sensor); - - _controllers.Add(sensor.Name, controller); - } - else - { - _notification.ShowInfo("The maximum number of real-time graphs is eight. Please remove a graph to add another."); - } - } - /// /// Switch the brush stop position in the segment. /// @@ -1536,19 +1382,6 @@ namespace Tango.MachineStudio.Developer.ViewModels ArrangeBrushStopsIndices(); } - /// - /// Removes the graph. - /// - /// The graph. - public void RemoveGraph(IRealTimeGraph graph) - { - var sensor = graph.Tag as TechMonitor; - _controllers.Remove(sensor.Name); - graph.InnerGraph.Dispose(); - Graphs.Remove(graph); - AvailableGraphs.Insert(0, sensor); - } - #endregion #region IShutdownRequestBlocker @@ -1575,20 +1408,20 @@ namespace Tango.MachineStudio.Developer.ViewModels #region IMainView - protected override void OnViewAttached() - { - base.OnViewAttached(); + //protected override void OnViewAttached() + //{ + // base.OnViewAttached(); - if (SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedMachineGuid != null) - { - SelectedMachine = Adapter.Machines.SingleOrDefault(x => x.Guid == SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedMachineGuid); - } + // //if (SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedMachineGuid != null) + // //{ + // // SelectedMachine = Adapter.Machines.SingleOrDefault(x => x.Guid == SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedMachineGuid); + // //} - if (SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedJobGuid != null && SelectedMachine != null) - { - ActiveJob = SelectedMachine.Jobs.SingleOrDefault(x => x.Guid == SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedJobGuid); - } - } + // //if (SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedJobGuid != null && SelectedMachine != null) + // //{ + // // ActiveJob = SelectedMachine.Jobs.SingleOrDefault(x => x.Guid == SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedJobGuid); + // //} + //} #endregion } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml index cf7af21d9..69f0fed5c 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml @@ -357,7 +357,7 @@ Winding Method - + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml.cs index 41886357b..27ea3cae8 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml.cs @@ -82,14 +82,6 @@ namespace Tango.MachineStudio.Developer.Views } } - private void OnDropAvailableGraph(object sender, DropEventArgs e) - { - if (e.Draggable.DataContext is TechMonitor) - { - _vm.OnDropAvailableGraph(e.Draggable.DataContext as TechMonitor); - } - } - private void Offset_Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) { UpdateGradientBrushDisplay(); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml index 8881e4f57..c07ddb95b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml @@ -31,7 +31,7 @@ TARGET MACHINE - + @@ -84,7 +84,7 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Job Completed Successfully - - - - - - - - - - - - - - - - - - - - - - - Job Failed To Complete - - - - - - - - - - - - - - - - - - - - - - - - - Job Aborted By User - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - HISTORY - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SELECT MACHINE & MEDIA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MACHINE JOBS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name - - - - - - - - - - Winding Method - - - - - - - - - - Inter Segment - - - - - - - - - - - - - Lubrication - - - - - - - - - - - - Description - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SEGMENTS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name - - - - - - - - - Length - - - - - - - - - - - - - - - - - - - - - - - - - - - SEGMENT BRUSH - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Color Space - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ESTIMATED DURATION: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - USB CAMERAS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AVAILABLE GRAPHS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DRAG & DROP GRAPHS - - - - - - - - - - - - - - - - - - - - Display Graphs - - - - - - - - - - - - - - - - - Job Status - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LIQUID FACTORS ( Max Nanolitter/CM ) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SELECT MACHINE & MEDIA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Press - 'Escape' - to exit full screen mode - - - - - - - - - - - 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 deleted file mode 100644 index 2bd36e449..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs +++ /dev/null @@ -1,162 +0,0 @@ -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.Integration.Observables; -using Tango.DragAndDrop; -using Tango.MachineStudio.Developer.Converters; -using Tango.MachineStudio.Developer.ViewModels; -using System.Windows.Threading; -using Tango.SharedUI; - -namespace Tango.MachineStudio.Developer.Views -{ - /// - /// Interaction logic for MainView.xaml - /// - public partial class MainView : UserControl, IMainView - { - public static MainView Self { get; set; } - - private MainViewVM _vm; - private DispatcherTimer _jobBrushTimer; - - 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 event EventHandler ViewAttached; - - public MainView() - { - Self = this; - - InitializeComponent(); - - DraggingSurface = draggingSurface; - this.Loaded += (x, y) => - { - _vm = DataContext as MainViewVM; - ViewAttached?.Invoke(this, this); - }; - - chkGraphs.Checked += (x, y) => - { - graphRowDefinition.Height = new GridLength(440, GridUnitType.Pixel); - //listCameras.Width = 240; - //dockCameras.Width = 270; - //dockCameras.Height = 600; - }; - chkGraphs.Unchecked += (x, y) => - { - graphRowDefinition.Height = new GridLength(80, GridUnitType.Pixel); - //listCameras.Width = double.NaN; - //dockCameras.Width = 330; - //dockCameras.Height = 850; - }; - - _jobBrushTimer = new DispatcherTimer(); - _jobBrushTimer.Interval = TimeSpan.FromSeconds(1); - _jobBrushTimer.Tick += _jobBrushTimer_Tick; - _jobBrushTimer.Start(); - } - - private void _jobBrushTimer_Tick(object sender, EventArgs e) - { - if (_vm != null && _vm.ActiveJob != null) - { - List segments = new List(); - foreach (var s in _vm.ActiveJob.Segments) - { - segments.Add(s); - - if (_vm.ActiveJob.EnableInterSegment && _vm.ActiveJob.Segments.IndexOf(s) != _vm.ActiveJob.Segments.Count - 1) - { - segments.Add(new Segment() - { - Length = _vm.ActiveJob.InterSegmentLength, - BrushStops = new System.Collections.ObjectModel.ObservableCollection() - { - new BrushStop() - { - Color = Colors.White, - } - }, - }); - } - } - - jobBrushList.ItemsSource = segments; - } - } - - private void OnDropAvailableGraph(object sender, DropEventArgs e) - { - if (e.Draggable.DataContext is TechMonitor) - { - _vm.OnDropAvailableGraph(e.Draggable.DataContext as TechMonitor); - } - } - - private void Offset_Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) - { - UpdateGradientBrushDisplay(); - } - - private void UpdateGradientBrushDisplay() - { - if (_vm.SelectedSegment != null) - { - SegmentToGradientStopsConverter converter = new SegmentToGradientStopsConverter(); - GradientStopCollection stops = converter.Convert(_vm.SelectedSegment, null, null, null) as GradientStopCollection; - gradientBrush.GradientStops = stops; - } - else - { - gradientBrush.GradientStops = new GradientStopCollection(); - } - } - - private void OnBrushStopBorderDrop(object sender, DropEventArgs e) - { - if (e.Draggable.DataContext is BrushStop) - { - _vm.OnDropBrushStop(e.Draggable.DataContext as BrushStop, e.Droppable.DataContext as BrushStop); - } - } - - private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) - { - UpdateGradientBrushDisplay(); - } - - private void OnJobStartClick(object sender, RoutedEventArgs e) - { - - } - - private void HiveColorPickerControl_SelectedColorChanged(object sender, Color e) - { - UpdateGradientBrushDisplay(); - } - - private void Popup_MouseDown(object sender, MouseButtonEventArgs e) - { - e.Handled = true; - } - } -} -- cgit v1.3.1