//-- Event Handlers
        #endregion
        //---------------------------------------------------------------------
        #region Methods

        private void HandleNewFhemObject(FhemObject a_fhemObject, IFhemService a_fhemService, IRegionManager a_regionManager)
        {
            //-- First of all create a view model for the Fhem object
            var fhemObjectViewModel = new FhemObjectViewModel(a_fhemObject, a_fhemService, a_regionManager, m_applicationService);

            //-- Add the view model to the public collection
            m_fhemObjectsCollection.Add(fhemObjectViewModel);

            //-- Add a link between the Fhem object and its view model to the private index
            m_fhemObjectViewModelsByFhemObjects.Add(a_fhemObject, fhemObjectViewModel);
        }
        private void HandleRemovedFhemObject(FhemObject a_fhemObject)
        {
            if (m_fhemObjectViewModelsByFhemObjects.ContainsKey(a_fhemObject))
            {
                //-- Determine the corresponding view model
                var fhemObjectViewModel = m_fhemObjectViewModelsByFhemObjects[a_fhemObject];

                //-- Remove the view model from the collection
                m_fhemObjectsCollection.Remove(fhemObjectViewModel);
                m_fhemObjectViewModelsByFhemObjects.Remove(a_fhemObject);
            }
        }
Exemple #3
0
        //-- Properties
        #endregion
        //---------------------------------------------------------------------
        #region Constructors

        /// <summary>
        /// Initializes a new instance of the FhemObjectsViewModel class.
        /// </summary>
        /// <param name="a_fhemObject">
        /// The <see cref="FhemObject"/> that is represented by this view model.
        /// </param>
        /// <param name="a_fhemService"></param>
        /// <param name="a_regionManager"></param>
        /// <param name="a_applicationService"></param>
        public FhemObjectViewModel(FhemObject a_fhemObject, IFhemService a_fhemService, IRegionManager a_regionManager, IApplicationService a_applicationService)
            : base(a_fhemService)
        {
            //-- Initialize fields
            m_applicationService = a_applicationService;
            m_regionManager      = a_regionManager;

            //-- Initialize properties
            this.FhemObject = a_fhemObject;
            this.Name       = this.FhemObject.Name;

            //-- Initialize commands
            this.AbortFhemObjectRenamingCommand = new DelegateCommand(this.AbortFhemObjectRenamingCommandAction);
            this.EditFhemObjectNameCommand      = new DelegateCommand(this.EditFhemObjectNameCommandAction);
            this.OpenFhemObjectDetailsCommand   = new DelegateCommand(this.OpenFhemObjectDetailsCommandAction);
            this.RenameFhemObjectNameCommand    = new DelegateCommand(this.RenameFhemObjectNameCommandAction);
        }