示例#1
0
        public void RebuildMap(ObservableCollection <IHotasBaseMap> map)
        {
            RemoveAllButtonMapHandlers();

            ButtonMap.Clear();

            foreach (var baseMap in map)
            {
                switch (baseMap.Type)
                {
                case HOTASButton.ButtonType.AxisLinear:
                    var linearMap = baseMap as HOTASAxis;
                    var lmVm      = new AxisMapViewModel(_appDispatcher, _mediaPlayerFactory, _fileSystem, linearMap);
                    AddAxisMapHandlers(lmVm);
                    ButtonMap.Add(lmVm);
                    break;

                case HOTASButton.ButtonType.AxisRadial:
                    var radialMap = baseMap as HOTASAxis;
                    var rmVm      = new AxisMapViewModel(_appDispatcher, _mediaPlayerFactory, _fileSystem, radialMap);
                    AddAxisMapHandlers(rmVm);
                    ButtonMap.Add(rmVm);
                    break;

                default:
                    var buttonMap = baseMap as HOTASButton;
                    var bmVm      = new ButtonMapViewModel(buttonMap);
                    AddButtonMapHandlers(bmVm);
                    ButtonMap.Add(bmVm);
                    break;
                }
            }
        }
        public void Add(ButtonMapViewModel buttonMap)
        {
            var item = buttonMap.ActionItem;

            if (Catalog.Contains(item))
            {
                return;
            }

            if (string.IsNullOrWhiteSpace(item.ActionName) || item.ActionName == NO_ACTION_TEXT)
            {
                item.ActionName = $"Action for {buttonMap.ButtonName}";
            }

            Catalog.Add(item);
            Logging.Log.Debug($"{item.ActionName} - {buttonMap.ButtonName} added to actions catalog");
        }
示例#3
0
 private void AddButtonMapHandlers(ButtonMapViewModel mapViewModel)
 {
     mapViewModel.RecordingStarted   += MapViewModel_RecordingStarted;
     mapViewModel.RecordingStopped   += MapViewModel_RecordingStopped;
     mapViewModel.RecordingCancelled += MapViewModel_RecordingCancelled;
 }