/// <summary>
        /// Creates a new <see cref="TemplateSection"/> VieModel
        /// </summary>
        /// <param name="section"> The <see cref="TemplateSection"/> associated with this ViewModel</param>
        /// <param name="template">The <see cref="TemplateVM"/> associated with this <see cref="TemplateSection"/> </param>
        public SectionVM(TemplateSection section, TemplateVM template)
        {
            TemplateViewModel = template;
            m_section         = section;

            AddAnalyticCommand   = new RelayCommand(AddAnalytic, () => true);
            DeleteSectionCommand = new RelayCommand(RemoveSection, () => true);
            m_analytics          = new ObservableCollection <AnalyticVM>();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new <see cref="SelectSignalVM"/> VieModel.
        /// </summary>
        /// <param name="templateViewModel"> The <see cref="TemplateVM"/> used to get available Signals. </param>
        /// <param name="onComplete">The <see cref="Action"/> to be called when a Signal is selected. </param>
        /// <param name="maxOrder">The maximum Order of the Sections. -1 for all Sections in the <paramref name="templateViewModel"/>. </param>
        public SelectSignalVM(TemplateVM templateViewModel, Action <AnalyticInput> onComplete, int maxOrder = -1)
        {
            CancelCommand = new RelayCommand(Cancel, (obj) => true);
            SelectCommand = new RelayCommand(Select, (obj) => true);
            m_onComplete  = onComplete;

            // Create Full List of Signals including outputs from Analytics
            Devices = new ObservableCollection <DeviceVM>(templateViewModel.Devices.Where(d => !d.Removed).Select(d => new DeviceVM(d)));
            IEnumerable <AnalyticOutputVM> outputs = templateViewModel.Sections
                                                     .Where(s => s.Order < maxOrder || maxOrder == -1)
                                                     .SelectMany(s => s.Analytics).SelectMany(a => a.Outputs);

            foreach (DeviceVM dev in Devices)
            {
                dev.AddSignals(outputs.Where(s => s.DeviceID == dev.ID));
            }

            m_selectedSignalID    = Devices.FirstOrDefault().Signals.FirstOrDefault()?.ID ?? -1;
            m_selectedInputSignal = Devices.FirstOrDefault().Signals.FirstOrDefault()?.IsInput ?? false;
        }