/// <summary>
        /// construct a BeanContextChildSupport where the JavaBean component
        /// itself implements BeanContextChild, and encapsulates this, delegating
        /// that interface to this implementation </summary>
        /// <param name="bcc"> the underlying bean context child </param>

        public BeanContextChildSupport(BeanContextChild bcc) : base()
        {
            BeanContextChildPeer_Renamed = (bcc != null) ? bcc : this;

            PcSupport = new PropertyChangeSupport(BeanContextChildPeer_Renamed);
            VcSupport = new VetoableChangeSupport(BeanContextChildPeer_Renamed);
        }
Exemple #2
0
        public ClientViewModel(LinkedList <INavigableViewModel> navigation, ClientEntity clientEntity, LinkedListNode <INavigableViewModel> prevNode = null)
        {
            _pcs          = new PropertyChangeSupport(this);
            _navigation   = navigation;
            _clientEntity = clientEntity;
            _clientEntity.PropertyChanged += _clientChanged;
            _clientMode  = prevNode == null;
            _bookingMode = !_clientMode;

            if (_bookingMode)
            {
                _currentBookingVM = prevNode.Value as BookingViewModel;
            }

            _sumUpCommand      = new DelegateCommand <ClientViewModel>(_sumUp);
            _bookingCommand    = new DelegateCommand <ClientViewModel>(_booking);
            _saveClientCommand = new DelegateCommandAsync <ClientViewModel>(_saveClient);

            _unlockSaveAndSumUpIfNeeded();

            if (!_bookingMode)
            {
                _navigation.AddLast(this);
            }
            else
            {
                _navigation.AddAfter(prevNode, this);
            }
        }
Exemple #3
0
 public PromptViewModel(string title, string message, bool hasInput = true)
 {
     _pcs      = new PropertyChangeSupport(this);
     _title    = title;
     _message  = message;
     _hasInput = hasInput;
 }
        /// <summary>
        /// construct a BeanContextChildSupport where this class has been
        /// subclassed in order to implement the JavaBean component itself.
        /// </summary>

        public BeanContextChildSupport() : base()
        {
            BeanContextChildPeer_Renamed = this;

            PcSupport = new PropertyChangeSupport(BeanContextChildPeer_Renamed);
            VcSupport = new VetoableChangeSupport(BeanContextChildPeer_Renamed);
        }
Exemple #5
0
 public PaymentEntity(Booking booking)
 {
     _pcs = new PropertyChangeSupport(this);
     _booking = booking;
     _requiredAmmount = booking.Total;
     _booking.Payment = booking.Payment;
 }
Exemple #6
0
 public State(System.String name)
 {
     InitBlock();
     this.name  = name;
     this.state = State.NOTRUN;
     changes    = new PropertyChangeSupport(this);
 }
Exemple #7
0
        public BookingViewModel(LinkedList <INavigableViewModel> navigation, Booking booking, LinkedListNode <INavigableViewModel> prevNode = null)
        {
            _pcs                         = new PropertyChangeSupport(this);
            _navigation                  = navigation;
            _parameters                  = new BookingParametersViewModel(booking);
            _parameters.Defined         += _parameters_defined;
            _parameters.PropertyChanged += _parametersChanged;
            _parametersValidated         = false;
            _booking                     = booking;
            _clientEntity                = new ClientEntity(_booking.Client);
            _bookingEntity               = new BookingEntity(_booking);
            _clientEntity.Bookings.Add(_bookingEntity);
            _computeTitle(_clientEntity);
            _clientEntity.PropertyChanged += _clientChanged;

            _searchClientCommand    = new DelegateCommandAsync <BookingViewModel>(_searchClient, false);
            _newClientCommand       = new DelegateCommandAsync <BookingViewModel>(_newClient, false);
            _validateBookingCommand = new DelegateCommandAsync <BookingViewModel>(_validateBooking, false);

            if (prevNode == null)
            {
                _navigation.AddLast(this);
            }
            else
            {
                _navigation.AddAfter(prevNode, this);
            }
        }
        public SearchClientsViewModel(List <ClientEntity> clientEntities, bool reservationMode = false)
        {
            _pcs   = new PropertyChangeSupport(this);
            _title = "Resotel - Recherche de client";

            if (reservationMode)
            {
                _title = "Resotel - Recherche de réservation";
            }

            _searchClientVMs                     = new ObservableCollection <SearchClientViewModel>();
            _searchClientVMsSource               = CollectionViewProvider.Provider(_searchClientVMs);
            _searchClientVMsView                 = _searchClientVMsSource.View;
            _searchClientVMsView.Filter          = _filterClientNameOrFirstName;
            _searchClientVMsView.CurrentChanged += _client_selected;

            HashSet <string> clientKeys = new HashSet <string>();

            foreach (ClientEntity clientEntity in clientEntities)
            {
                if (clientKeys.Add($"{clientEntity.FirstName}{clientEntity.LastName}"))
                {
                    SearchClientViewModel clientSearchVM = new SearchClientViewModel(clientEntity, clientEntities);
                    _searchClientVMs.Add(clientSearchVM);
                    clientSearchVM.ClientSelected += _subClient_selected;
                }
            }
        }
Exemple #9
0
 private OptionChoiceEntity(string description, string imageFullName, OptionChoice option, bool taken = false)
 {
     _pcs           = new PropertyChangeSupport(this);
     _optionChoice  = option;
     _imageFullPath = imageFullName;
     _taken         = taken;
 }
Exemple #10
0
 public RoomChoiceEntity(RoomKind kind, int maxAvailable, int count = 0)
 {
     _pcs          = new PropertyChangeSupport(this);
     _bedKind      = kind.ToBedKind();
     _roomKind     = kind;
     _maxAvailable = maxAvailable;
     _count        = count;
 }
Exemple #11
0
 private RoomsChoiceViewModel()
 {
     _pcs = new PropertyChangeSupport(this);
     _availableRoomChoiceEntities       = new ObservableCollection <RoomChoiceEntity>();
     _availableRoomChoiceEntitiesSource = CollectionViewProvider.Provider(_availableRoomChoiceEntities);
     _availableRoomChoiceEntitiesView   = _availableRoomChoiceEntitiesSource.View;
     _filteredRooms       = new List <Room>();
     _availableRoomCounts = new Dictionary <RoomKind, int>();
 }
Exemple #12
0
 public DiscountEntity(Discount discount)
 {
     _pcs      = new PropertyChangeSupport(this);
     _discount = discount;
     if (discount != null)
     {
         _validityEntity = new DateRangeEntity(discount.Validity);
     }
 }
Exemple #13
0
 public ClientEntity(Client client)
 {
     _pcs    = new PropertyChangeSupport(this);
     _client = client;
     if (client.BirthDate.Year == 1)
     {
         // completely randomly choosen birthdate initialization (but that's better than 01/01/0001)
         _client.BirthDate = DateTime.Now.AddYears(-20);
     }
 }
Exemple #14
0
 public BookingEntity(Booking booking)
 {
     _pcs           = new PropertyChangeSupport(this);
     _booking       = booking;
     _clientEntity  = new ClientEntity(_booking.Client);
     _paymentEntity = new PaymentEntity(booking);
     _datesEntity   = new DateRangeEntity(_booking.Dates);
     _discountedOptionChoiceEntity = new OptionChoiceEntity(_booking, _booking.DiscountedOptionChoice);
     _optionDiscountEntity         = new DiscountEntity(_booking.OptionDiscount);
 }
Exemple #15
0
        public LoginViewModel()
        {
            _pcs         = new PropertyChangeSupport(this);
            _loginResult = "";
            _resultReady = false;
            _title       = "Resotel - Login";

            _loadCommand  = new DelegateCommand <IUITimer>(_load);
            _loginCommand = new DelegateCommandAsync <object>(_loginCmd);
        }
Exemple #16
0
 private OptionsViewModel()
 {
     _pcs = new PropertyChangeSupport(this);
     _availableOptionChoiceEntities           = new ObservableCollection <OptionChoiceEntity>();
     _availableOptionsChoiceEntitiesSource    = CollectionViewProvider.Provider(_availableOptionChoiceEntities);
     _availableOptionChoiceEntitiesView       = _availableOptionsChoiceEntitiesSource.View;
     _choosenOptionsChoiceEntitiesSource      = CollectionViewProvider.Provider(_availableOptionChoiceEntities);
     _choosenOptionsChoiceEntitiesView        = _choosenOptionsChoiceEntitiesSource.View;
     _choosenOptionsChoiceEntitiesView.Filter = _isChoosen;
 }
Exemple #17
0
        public OptionChoiceEntity(OptionChoice optionChoice)
        {
            _pcs          = new PropertyChangeSupport(this);
            _optionChoice = optionChoice;

            string cleanedLabel;

            cleanedLabel   = _cleanLabel(optionChoice.Option.Label);
            _imageFullPath = string.Format("/Resources/{0}.png", cleanedLabel);
            _taken         = false;
        }
Exemple #18
0
        public void FirePropertyChange(INotifyPropertyChangedSource obj, PropertyChangeSupport propertyChangeSupport, IPropertyInfo property, Object oldValue, Object currentValue)
        {
            ICacheModification cacheModification = this.CacheModification;
            PropertyEntry      entry             = GetPropertyEntry(obj.GetType(), property);

            if (currentValue == null)
            {
                currentValue = entry.getDelegate(obj);
            }
            try
            {
                if (entry.isAddedRemovedCheckNecessary)
                {
                    if (oldValue != null)
                    {
                        HandleRemovedItem(obj, oldValue, entry.isParentChildSetter);
                    }
                    if (currentValue != null)
                    {
                        HandleAddedItem(obj, currentValue, entry.isParentChildSetter);
                    }
                }
                String[] propertyNames = entry.propertyNames;
                Object[] oldValues;
                Object[] currentValues;

                if (FireOldPropertyValueActive)
                {
                    oldValues     = CreateArrayOfValues(oldValue, propertyNames.Length);
                    currentValues = Object.ReferenceEquals(currentValue, oldValue) ? oldValues : CreateArrayOfValues(currentValue, propertyNames.Length);
                }
                else
                {
                    oldValues     = entry.unknownValues;
                    currentValues = oldValues;
                }
                FirePropertyChange(obj, entry.pceArgs, propertyNames, oldValues, currentValues);
                if (entry.firesToBeCreatedPCE)
                {
                    IDataObject dObj = (IDataObject)obj;
                    if (dObj.ToBeCreated && dObj.ToBeUpdated)
                    {
                        dObj.ToBeUpdated = false;
                    }
                }
            }
            finally
            {
                if (entry.doesModifyToBeUpdated && !cacheModification.ActiveOrFlushingOrInternalUpdate)
                {
                    SetToBeUpdated(obj, true);
                }
            }
        }
Exemple #19
0
        protected PropertyChangeSupport getChangeSupport()
        {
            Object pcs = this.getValue(PROPERTY_CHANGE_SUPPORT);

            if (pcs == null || !(pcs is PropertyChangeSupport))
            {
                pcs = new PropertyChangeSupport(this);
                this.setValue(PROPERTY_CHANGE_SUPPORT, pcs);
            }

            return((PropertyChangeSupport)pcs);
        }
Exemple #20
0
 protected void ExecuteFirePropertyChange(PropertyChangeSupport propertyChangeSupport, IList <IPropertyChangeExtension> extensions, Object obj, PropertyChangedEventArgs[] evnts, String[] propertyNames, Object[] oldValues, Object[] currentValues)
 {
     if (AsyncPropertyChangeActive)
     {
         GuiThreadHelper.InvokeInGui(delegate()
         {
             ExecuteFirePropertyChangeIntern(propertyChangeSupport, extensions, obj, evnts, propertyNames, oldValues, currentValues);
         });
     }
     else
     {
         ExecuteFirePropertyChangeIntern(propertyChangeSupport, extensions, obj, evnts, propertyNames, oldValues, currentValues);
     }
 }
Exemple #21
0
        public SumUpViewModel(LinkedList <INavigableViewModel> navigation, Booking booking, LinkedListNode <INavigableViewModel> prevNode = null)
        {
            _pcs           = new PropertyChangeSupport(this);
            _navigation    = navigation;
            _booking       = booking;
            _dates         = booking.Dates;
            _clientEntity  = new ClientEntity(booking.Client);
            _paymentEntity = new PaymentEntity(booking);
            _paymentEntity.PropertyChanged += _payment_changed;
            _hasPayment     = _booking.Payment != null && _booking.Payment.Ammount > 0d;
            _hadPayment     = _hasPayment;
            _wasInTempState = _booking.State == BookingState.Validated;

            _appliedPackEntities  = new List <AppliedPackEntity>();
            _optionChoiceEntities = new List <OptionChoiceEntity>(booking.OptionChoices.Count);

            _updateOptionChoiceEntities(booking);

            _title = $"Réservation de {_clientEntity.FirstName} {_clientEntity.LastName} du {booking.Dates.Start:dd/MM/yyyy}";

            _fillAppliedPacksEntities(booking);


            bool canSave = _booking.State == BookingState.Validated;

            _defineCommands(canSave);
            _definePaymentModes();

            _unlockSaveIfNeeded();
            _unlockEditIfNeeded();



            if ((_booking.State != BookingState.Validated && canSave) ||
                (_booking.State == BookingState.Validated && !canSave)
                )
            {
                _saveBookingCommand.ChangeCanExecute();
            }


            if (prevNode != null)
            {
                _navigation.AddAfter(prevNode, this);
            }
            else
            {
                _navigation.AddLast(this);
            }
        }
        public ClientBookingsViewModel(ClientEntity clientEntity)
        {
            _pcs                  = new PropertyChangeSupport(this);
            _clientEntity         = clientEntity;
            _clientBookingsSource = CollectionViewProvider.Provider(clientEntity.Bookings);
            _clientBookingsView   = _clientBookingsSource.View;
            Booking booking = default(Booking);

            _clientBookingsView.SortDescriptions.Add(new SortDescription($"{nameof(booking.Dates)}.{nameof(booking.Dates.Start)}", ListSortDirection.Ascending));
            _clientBookingsView.CurrentChanged += _clientBookingsView_currentChanged;

            _selectBookingCommand = new DelegateCommand <object>(_selectBooking);
            _cancelBookingCommand = new DelegateCommandAsync <object>(_cancelBooking);

            _clientBookingsView.Filter = _mustShowBooking;
        }
Exemple #23
0
        public BookingParametersViewModel(Booking booking)
        {
            _pcs = new PropertyChangeSupport(this);

            _booking             = booking;
            _booking.Dates.Start = booking.Dates.Start.Date;
            _booking.Dates.End   = booking.Dates.End.Date;
            _dateRange           = new DateRangeEntity(booking.Dates);
            _adultsCount         = booking.AdultsCount;
            _babiesCount         = booking.BabiesCount;
            _validateCommand     = new DelegateCommand <object>(_validate);

            if (_adultsCount == 0 && booking.Id == 0)
            {
                AdultsCount = 1;
            }
        }
Exemple #24
0
        public MainWindowViewModel(UserEntity user)
        {
            Logger.Log("=Initialisation Fenêtre principale (post login)=");
            _pcs             = new PropertyChangeSupport(this);
            _user            = user;
            _currentEntities = new ObservableCollection <INavigableViewModel>();
            _title           = "Resotel - Facturation";
            _navigation      = new LinkedList <INavigableViewModel>();

            _addBookingCommand    = new DelegateCommand <object>(_addBooking);
            _closeBookingCommand  = new DelegateCommand <IEntity>(_closeBooking);
            _addClientCommand     = new DelegateCommand <object>(_addClient);
            _searchBookingCommand = new DelegateCommandAsync <object>(_searchBooking);
            _searchClientCommand  = new DelegateCommandAsync <object>(_searchClient);
            _logoutCommand        = new DelegateCommand <object>(_logOut);
            _nextCommand          = new DelegateCommand <BookingViewModel>(_next);
            _prevCommand          = new DelegateCommand <BookingViewModel>(_prev);
            Logger.Log("=fenêtre principale initialisée (post login)=");
        }
Exemple #25
0
        public void FirePropertyChange(INotifyPropertyChangedSource obj, PropertyChangedEventArgs[] evnts, String[] propertyNames, Object[] oldValues, Object[] currentValues)
        {
            PropertyChangeSupport            propertyChangeSupport = obj.PropertyChangeSupport;
            IList <IPropertyChangeExtension> extensions            = propertyChangeExtensions.GetExtensions(obj.GetType());

            if (propertyChangeSupport == null && extensions == null && !(obj is IPropertyChangedEventHandler))
            {
                return;
            }
            ICacheModification cacheModification = this.CacheModification;

            if (cacheModification.Active)
            {
                cacheModification.QueuePropertyChangeEvent(delegate()
                {
                    ExecuteFirePropertyChange(propertyChangeSupport, extensions, obj, evnts, propertyNames, oldValues, currentValues);
                });
                return;
            }
            ExecuteFirePropertyChange(propertyChangeSupport, extensions, obj, evnts, propertyNames, oldValues, currentValues);
        }
        public SearchClientViewModel(ClientEntity clientEntity, IEnumerable <ClientEntity> clientEntities)
        {
            _pcs = new PropertyChangeSupport(this);
            _displayMoreToggled      = false;
            _clientEntity            = clientEntity;
            _subClientEntities       = new ObservableCollection <ClientEntity>();
            _subClientEntitiesSource = CollectionViewProvider.Provider(_subClientEntities);
            _subClientEntitiesView   = _subClientEntitiesSource.View;
            _subClientEntitiesView.CurrentChanged += _subClientEntitiesView_CurrentChanged;

            foreach (ClientEntity clientE in clientEntities)
            {
                if (clientE.FirstName == _clientEntity.FirstName && clientE.LastName == _clientEntity.LastName)
                {
                    _subClientEntities.Add(clientE);
                }
            }

            _needsCount        = _subClientEntities.Count > 1;
            _foundClientsCount = _subClientEntities.Count;
        }
Exemple #27
0
        public OptionChoiceEntity(Booking booking, OptionChoice optionChoice)
        {
            _pcs          = new PropertyChangeSupport(this);
            _optionChoice = optionChoice;
            _booking      = booking;


            string cleanedLabel;

            if (optionChoice != null)
            {
                cleanedLabel   = _cleanLabel(optionChoice.Option.Label);
                _imageFullPath = string.Format("/Resources/{0}.png", cleanedLabel);

                // restauration
                if (optionChoice.PeopleCount == 0 && optionChoice.Option.Id == 8)
                {
                    PeopleCount = 1;
                }
            }
            _taken = false;
        }
Exemple #28
0
        protected void ExecuteFirePropertyChangeIntern(PropertyChangeSupport propertyChangeSupport, IList <IPropertyChangeExtension> extensions, Object obj, PropertyChangedEventArgs[] evnts, String[] propertyNames, Object[] oldValues, Object[] currentValues)
        {
            bool debugEnabled = Log.DebugEnabled;
            IPropertyChangedEventHandler pcl = (IPropertyChangedEventHandler)(obj is IPropertyChangedEventHandler ? obj : null);

            for (int a = 0, size = propertyNames.Length; a < size; a++)
            {
                String propertyName = propertyNames[a];
                if (debugEnabled)
                {
                    Log.Debug("Process PCE '" + propertyName + "' on " + obj);
                }
                Object oldValue     = oldValues[a];
                Object currentValue = currentValues[a];
                if (oldValue == UNKNOWN_VALUE)
                {
                    oldValue = null;
                }
                if (currentValue == UNKNOWN_VALUE)
                {
                    currentValue = null;
                }
                if (pcl != null && (oldValue != null || currentValue != null))
                {
                    // called only in "non-technical" PCEs
                    pcl.PropertyChanged(obj, evnts[a]);
                }
                if (propertyChangeSupport != null)
                {
                    propertyChangeSupport.FirePropertyChange(obj, evnts[a], propertyName, oldValue, currentValue);
                }
                for (int b = 0, sizeB = extensions.Count; b < sizeB; b++)
                {
                    extensions[b].PropertyChanged(obj, propertyName, oldValue, currentValue);
                }
            }
        }
Exemple #29
0
 public DateRangeEntity(DateRange dateRange)
 {
     _pcs       = new PropertyChangeSupport(this);
     _dateRange = dateRange;
 }
Exemple #30
0
 public void RemovePropertyChangeListener(PropertyChangeSupport propertyChangeSupport, PropertyChangedEventHandler listener)
 {
     propertyChangeSupport.RemovePropertyChangeListener(listener);
 }