public DescriptorValueEditor(DescriptorMultistateBase assignedAccessDescriptor, bool enableStateManagement)
        {
            _assignedAccessDescriptor = assignedAccessDescriptor;

            _usedVariables = _assignedAccessDescriptor.GetAllUsedVariables().ToList();
            _connectorList = _assignedAccessDescriptor.GetConnectors(null, true).ToList().OrderBy(i => i.Order).ToList();
            foreach (var s in _connectorList)
            {
                foreach (var v in _usedVariables)
                {
                    var formula = _assignedAccessDescriptor.GetFormula(v, s.Id);
                    _localFormulaKeeper.StoreVariableFormula(formula, _assignedAccessDescriptor.GetId(), v, s.Id);
                }
            }
            InitializeComponent();
            Localize();
            AddState.Visibility    = enableStateManagement ? Visibility.Visible : Visibility.Hidden;
            RemoveState.Visibility = enableStateManagement ? Visibility.Visible : Visibility.Hidden;
            RenameState.Visibility = enableStateManagement ? Visibility.Visible : Visibility.Hidden;
            if (_assignedAccessDescriptor is IDefautValueAbility)
            {
                _defaultState = ((IDefautValueAbility)assignedAccessDescriptor).GetDefaultStateId();
                SelectDefaultState.Visibility = enableStateManagement ? Visibility.Visible : Visibility.Hidden;
            }
            else
            {
                SelectDefaultState.Visibility = Visibility.Hidden;
            }
            ShowData();
        }
        public bool IsDataChanged()
        {
            var origUsedVariables = _assignedAccessDescriptor.GetAllUsedVariables();
            var origStateList     = _assignedAccessDescriptor.GetConnectors(null, true).ToList().OrderBy(i => i.Order);

            // Сравниваем размер и состав массива переменных
            if (origUsedVariables.Length != _usedVariables.Count())
            {
                return(true);
            }
            if (origUsedVariables.Where((t, i) => t != _usedVariables[i]).Any())
            {
                return(true);
            }
            // Сравниваем размер и состав массива состояний
            if (origStateList.Count() != _connectorList.Count())
            {
                return(true);
            }
            for (var i = 0; i < origStateList.Count(); i++)
            {
                if (_connectorList.ElementAt(i).Id != origStateList.ElementAt(i).Id)
                {
                    return(true);
                }
            }
            // Проверяем совпадение формул
            for (var stateIndex = 0; stateIndex < _dataTable.Rows.Count; stateIndex++)
            {
                var arr = _dataTable.Rows[stateIndex].ItemArray.ToList();
                // Удаляем колонку State и DefaultState
                arr.RemoveRange(0, _additionalColumnsCount);
                for (var varIndex = 0; varIndex < arr.Count; varIndex++)
                {
                    var origFormula     = _localFormulaKeeper.GetVariableFormulaText(_assignedAccessDescriptor.GetId(), origUsedVariables[varIndex], origStateList.ElementAt(stateIndex).Id);
                    var dataGridFormula = (string)arr[varIndex];
                    if (!Utils.AreStringsEqual(origFormula, dataGridFormula))
                    {
                        return(true);
                    }
                }
            }
            if (_assignedAccessDescriptor is IDefautValueAbility)
            {
                if (((IDefautValueAbility)_assignedAccessDescriptor).GetDefaultStateId() != _defaultState)
                {
                    return(true);
                }
            }
            return(false);
        }