// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
namespace Tango.Scripting.Editors.CodeCompletion
{
///
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.BL.Entities;
using Tango.Core;
using Tango.SharedUI;
namespace Tango.MachineStudio.RML.ViewModels
{
public class CalibrationDataVM : ExtendedObject
{
private LiquidType _liquidType;
public LiquidType LiquidType
{
get { return _liquidType; }
set { _liquidType = value; RaisePropertyChangedAuto(); }
}
private IdsPack _idsPack;
public IdsPack IdsPack
{
get { return _idsPack; }
set { _idsPack = value; RaisePropertyChangedAuto(); }
}
private ObservableCollection<CalibrationDataPointVM> _calibrationPoints;
public ObservableCollection<CalibrationDataPointVM> CalibrationPoints
{
get { return _calibrationPoints; }
set { _calibrationPoints = value; RaisePropertyChangedAuto(); OnCalibrationPointsChanged(); }
}
private void OnCalibrationPointsChanged()
{
if (CalibrationPoints != null)
{
CalibrationPoints.CollectionChanged -= CalibrationPoints_CollectionChanged;
CalibrationPoints.CollectionChanged += CalibrationPoints_CollectionChanged;
SetIndices();
}
}
private void CalibrationPoints_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
SetIndices();
}
private void SetIndices()
{
if (CalibrationPoints != null)
{
int index = 1;
foreach (var p in CalibrationPoints)
{
p.Index = index++;
}
}
}
private CalibrationDataVM()
{
CalibrationPoints = new ObservableCollection<CalibrationDataPointVM>();
}
public CalibrationDataVM(IdsPack pack) : this()
{
IdsPack = pack;
LiquidType = pack.LiquidType;
}
public CalibrationDataVM(LiquidType liquidType) : this()
{
LiquidType = liquidType;
}
}
}