示例#1
0
        public DeviceEditingViewModel(Func <IDeviceDefinitionViewModel> deviceDefinitionCreator,
                                      IDevicesContainerService devicesContainerService, ITypesContainer container,
                                      IDialogCoordinator dialogCoordinator, ILocalizerService localizerService, IFlyoutService flyoutService)
        {
            DeviceDefinitions = new ObservableCollection <IDeviceDefinitionViewModel>();
            DeviceConnections = new ObservableCollection <IViewModel>();
            //подгрузка всех файлов с определениями (вынести в асинхронный метод)

            _deviceDefinitionCreator = deviceDefinitionCreator;
            _devicesContainerService = devicesContainerService;
            _container         = container;
            _dialogCoordinator = dialogCoordinator;
            _localizerService  = localizerService;
            _flyoutService     = flyoutService;

            SubmitCommand             = new RelayCommand(OnSubmitCommand, () => _canSubmitCommandExecute);
            OpenDeviceFromFileCommand = new RelayCommand(OnOpenDeviceFromFileExecute);

            //подгрузка всех зарегистрированных фабрик разных видов подключений
            IEnumerable <IDeviceConnectionFactory> deviceConnectionFactories =
                _container.ResolveAll <IDeviceConnectionFactory>();

            foreach (IDeviceConnectionFactory deviceConnectionFactory in deviceConnectionFactories)
            {
                DeviceConnections.Add(deviceConnectionFactory.CreateDeviceConnectionViewModel());
            }
        }
 private void OnResetExecute()
 {
     UshortsFormatterViewModels.Clear();
     UshortsFormatterViewModels.AddCollection(_container.ResolveAll <IUshortsFormatterViewModel>());
     SelectedUshortsFormatterViewModel = null;
     IsFormatterFromResource           = false;
     CurrentResourceString             = null;
 }
示例#3
0
        public AddFragmentViewModel(IResultingDeviceViewModel resultingDeviceViewModel)
        {
            _resultingDeviceViewModel = resultingDeviceViewModel;
            AvailableFragments        = new ObservableCollection <IFragmentEditorViewModel>();
            IEnumerable <IFragmentEditorViewModel> fragments = _container.ResolveAll <IFragmentEditorViewModel>();

            foreach (IFragmentEditorViewModel fragment in fragments)
            {
                AvailableFragments.Add(fragment);
            }
            AddSelectedFragmentCommand = new RelayCommand <object>(OnAddSelectedFragment, CanAddSelectedFragment);
        }
示例#4
0
 public FragmentSettingsViewModel(ITypesContainer container)
 {
     _container                = container;
     CancelCommand             = new RelayCommand <object>(OnExecuteCancel);
     SubmitCommand             = new RelayCommand <object>(OnExecuteSubmit);
     AddSelectedSettingCommand = new RelayCommand(OnAddSelectedSettingExecute);
     _configurationSettings    =
         _container.Resolve <IFragmentSettings>();
     ConfigurationSettingViewModelCollection.Clear();
     _availableConfigurationSettings = new List <IFragmentSetting>(_container.ResolveAll <IFragmentSetting>());
     foreach (IFragmentSetting configurationSetting in _availableConfigurationSettings)
     {
         IFragmentSettingViewModel configurationSettingViewModel =
             _container.Resolve <IFragmentSettingViewModel>(configurationSetting.StrongName +
                                                            ApplicationGlobalNames.CommonInjectionStrings.VIEW_MODEL);
         ConfigurationSettingViewModelCollection.Add(configurationSettingViewModel);
     }
 }
示例#5
0
        public List <IMatrixVariableOptionTemplateEditorViewModel> CreateAvailableMatrixVariableOptionTemplateEditorViewModel()
        {
            List <IMatrixVariableOptionTemplateEditorViewModel> matrixVariableOptionTemplateEditorViewModels =
                new List <IMatrixVariableOptionTemplateEditorViewModel>();

            IEnumerable <IMatrixVariableOptionTemplate> matrixVariableOptionTemplates = _container.ResolveAll <IMatrixVariableOptionTemplate>();

            matrixVariableOptionTemplates.ForEach(model =>
            {
                IMatrixVariableOptionTemplateEditorViewModel matrixVariableOptionTemplateEditorViewModel = _container.Resolve <IViewModel>(
                    model.StrongName + ApplicationGlobalNames.CommonInjectionStrings.EDITOR_VIEWMODEL) as IMatrixVariableOptionTemplateEditorViewModel;
                matrixVariableOptionTemplateEditorViewModel.Model = model;
                matrixVariableOptionTemplateEditorViewModels.Add(matrixVariableOptionTemplateEditorViewModel);
            });

            return(matrixVariableOptionTemplateEditorViewModels);
        }
        public FormatterSelectionViewModel(ITypesContainer container,
                                           List <IUshortFormattableEditorViewModel> ushortFormattableViewModels,
                                           List <IConfigurationItemViewModel> rootConfigurationItemViewModels)
        {
            CurrentResourceString       = null;
            _container                  = container;
            _ushortFormattableViewModel = ushortFormattableViewModels;

            _sharedResourcesGlobalViewModel = _container.Resolve <ISharedResourcesGlobalViewModel>();

            _ushortsFormatterViewModels = new ObservableCollection <IUshortsFormatterViewModel>();
            UshortsFormatterViewModels.AddCollection(_container.ResolveAll <IUshortsFormatterViewModel>());
            BitNumbersInWord = new ObservableCollection <IBitViewModel>();

            // for (int i = 15; i >= 0; i--)
            // {
            //    IBitViewModel bitViewModel = new BitViewModel(i, true);
            //   BitNumbersInWord.Add(bitViewModel);
            //}

            IsBitsEditingEnabled = false;


            if (ushortFormattableViewModels.Count == 1)
            {
                var ushortFormattableViewModel = ushortFormattableViewModels.First();

                if (ushortFormattableViewModel is IBitsConfigViewModel bitsConfigViewModel)
                {
                    BitNumbersInWord.AddCollection(
                        BitOwnershipHelper.CreateBitViewModelsWithOwnership(bitsConfigViewModel,
                                                                            rootConfigurationItemViewModels));
                    bitsConfigViewModel.CopyBitsTo(this);
                    IsBitsEditingEnabled = true;
                }

                if (ushortFormattableViewModel.FormatterParametersViewModel != null)
                {
                    if (_sharedResourcesGlobalViewModel.GetResourceViewModelByName(
                            ushortFormattableViewModel.FormatterParametersViewModel.Name).IsSuccess)
                    {
                        CurrentResourceString    = ushortFormattableViewModel.FormatterParametersViewModel.Name;
                        _isFormatterFromResource = true;
                        ushortFormattableViewModel.FormatterParametersViewModel.RelatedUshortsFormatterViewModel =
                            container.Resolve <IFormatterViewModelFactory>().CreateFormatterViewModel(
                                _sharedResourcesGlobalViewModel.GetResourceByName(_currentResourceString) as
                                IUshortsFormatter).RelatedUshortsFormatterViewModel;
                    }

                    var formatter =
                        _ushortsFormatterViewModels.FirstOrDefault(f =>
                                                                   f.StrongName == ushortFormattableViewModel.FormatterParametersViewModel
                                                                   .RelatedUshortsFormatterViewModel.StrongName);
                    var existingIndex =
                        _ushortsFormatterViewModels.IndexOf(formatter);
                    _ushortsFormatterViewModels.RemoveAt(existingIndex);
                    _ushortsFormatterViewModels.Insert(existingIndex,
                                                       ushortFormattableViewModel.FormatterParametersViewModel.RelatedUshortsFormatterViewModel);
                    SelectedUshortsFormatterViewModel = ushortFormattableViewModel.FormatterParametersViewModel
                                                        .RelatedUshortsFormatterViewModel;
                }
            }

            CancelCommand              = new RelayCommand <object>(OnCancelExecute);
            OkCommand                  = new RelayCommand <object>(OnOkExecute);
            ResetCommand               = new RelayCommand(OnResetExecute);
            AddAsResourceCommand       = new RelayCommand(OnAddAsResourceExecute);
            SelectFromResourcesCommand = new RelayCommand(OnSelectFromResourcesExecute);
        }