protected override void Initialize(bool initData)
        {
            base.Initialize(initData);

            if (initData)
            {
                // ------- Set the environment name --------------
                EnvironmentName = _doc.Name;

                // ------- Set available quantities --------------
                _quantities.Clear();
                if (string.IsNullOrEmpty(_doc.Quantity)) // if doc has not quantitie still, then all quantities will be shown
                {
                    foreach (var quantity in UnitsExtensions.GetAllDefinedQuantities())
                    {
                        var node = new SelectableListNode(quantity, quantity, quantity == _doc.Quantity);
                        _quantities.Add(node);
                        if (node.IsSelected)
                        {
                            _selectedQuantity = node;
                        }
                    }
                }
                else // else if doc already has a quantity, then we do not allow to change this quantity
                {
                    var node = new SelectableListNode(_doc.Quantity, _doc.Quantity, true);
                    _quantities.Add(node);
                    _selectedQuantity = node;
                }

                // -------- Set up the unit environment controller -------
                _unitController = new UnitEnvironmentController(quantity: _doc.Quantity);
                _unitController.InitializeDocument(_doc.Environment ?? new QuantityWithUnitGuiEnvironment());
                Current.Gui.FindAndAttachControlTo(_unitController);
            }
        }
 public override IEnumerable <ControllerAndSetNullMethod> GetSubControllers()
 {
     yield return(new ControllerAndSetNullMethod(_unitController, () => _unitController = null));
 }