コード例 #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="zones"></param>
        /// <param name="sources"></param>
        public ZoneContext(List <ZoneGraphic> zones, List <SourceGraphic> sources)
        {
            _synchronizationContext = SynchronizationContext.Current;

            this._zones      = zones;
            this._activeZone = zones[0];
            this._zoneState  = new ZoneState();
            this._sources    = sources.ToArray().ToList();
            _viewSources     = (ListCollectionView)CollectionViewSource.GetDefaultView(this._sources);

            CommandBinding binding = new CommandBinding(CustomCommands.VolumeUp, VolumeUpCommand_Executed, VolumeUpCommand_CanExecute);

            _bindings.Add(binding);
            binding = new CommandBinding(CustomCommands.VolumeDown, VolumeDownCommand_Executed, VolumeDownCommand_CanExecute);
            _bindings.Add(binding);
            binding = new CommandBinding(CustomCommands.Power, PowerCommand_Executed, PowerCommand_CanExecute);
            _bindings.Add(binding);
        }
コード例 #2
0
        /// <summary>
        /// Updates the context with the specified new zone context.
        /// </summary>
        /// <param name="context">The new zone context.</param>
        public void UpdateContext(IHierarchyContext context)
        {
            if ((context is ZoneContext) == false)
            {
                return;
            }

            _ignoreViewSelectionChange = true;

            ZoneContext newContext = context as ZoneContext;

            _zones      = newContext._zones;
            _activeZone = _zones[0];
            _sources    = newContext._sources;

            NotifyPropertyChanged(new PropertyChangedEventArgs(""));

            _ignoreViewSelectionChange = false;
        }
コード例 #3
0
        /// <summary>
        /// Creates the specified zone of a floor view.
        /// </summary>
        /// <param name="zone">The zone to create.</param>
        /// <param name="sources">All available sources</param>
        private void CreateFloorZone(ZoneGraphic zone, List <SourceGraphic> sources)
        {
            int xOffset;
            int yOffset;

            CalculateOffset(zone.FloorPlanCoordinates, out xOffset, out yOffset);
            List <Point>       relativeCoordinates = ShiftCoordinates(zone.FloorPlanCoordinates, xOffset, yOffset);
            ZoneGraphic        zoneMod             = new ZoneGraphic(zone.Id, zone.Name, zone.PicturePath, zone.PictureType, relativeCoordinates, zone.ZoneControlCoordinate);
            ZoneControl        zoneControl         = new ZoneControl();
            ZoneState          state = new ZoneState();
            List <ZoneGraphic> zones = new List <ZoneGraphic>();

            zones.Add(zoneMod);
            ZoneContext zoneContext = new ZoneContext(zones, sources);

            zoneControl.DataContext = zoneContext;
            Canvas.SetLeft(zoneControl, xOffset);
            Canvas.SetTop(zoneControl, yOffset);
            _canvasFloor.Children.Add(zoneControl);
            zoneContext.ZoneLoaded();
        }
コード例 #4
0
        /// <summary>
        /// Navigate to a specified object of this context.
        /// </summary>
        /// <param name="id">The id of the object to navigate to. Here, this is the id of a zone.</param>
        /// <param name="unsubscribePreviousZone">Set to true, if previous zone must be unsubscribed first.</param>
        private void Navigate(Address id, bool unsubscribePreviousZone)
        {
            _ignoreViewSelectionChange = true;

            ZoneGraphic tempZone = FindZone(id);

            if (tempZone == null)
            {
                tempZone = _zones[0];
            }

            if (unsubscribePreviousZone)
            {
                Unsubscribe(_activeZone.Id);
            }
            _activeZone = tempZone;
            Subscribe(_activeZone.Id);
            NotifyPropertyChanged(new PropertyChangedEventArgs(""));

            _ignoreViewSelectionChange = false;
        }