コード例 #1
0
 /// <summary>
 /// Initializes a new <see cref="MasterDetailViewModel"/> instance.
 /// </summary>
 /// <param name="model">The model providing the information about the controller.</param>
 /// <param name="moduleName">The name of the module the controller belongs to.</param>
 /// <param name="controllerCommander">The controller commander to interact with the controller.</param>
 /// <param name="states">The states of this view providing loading-content-error states.</param>
 public MasterDetailViewModel(
     Controller model,
     string moduleName,
     ICommandControllers controllerCommander,
     IProvideStatesForScreenActivation states)
 {
     _controller          = model;
     _moduleName          = moduleName;
     _controllerCommander = controllerCommander;
     _states         = states;
     _changes        = new BindableCollection <KeyValueChange>();
     _actualValues   = new BindableCollection <KeyValueUnitViewModel>();
     _childs         = new BindableCollection <MasterDetailViewModel>();
     _command        = new ActionCommand(ExecuteCommandOnController);
     _configurations = new BindableCollection <KeyValueUnitViewModel>();
     _inputs         = new BindableCollection <ForcingKeyValueUnitViewModel>();
     //TODO: Rolf, please check this
     _inputs.CollectionChanged += InputsChanged;
     _outputs = new BindableCollection <ForcingKeyValueUnitViewModel>();
     //TODO: Rolf, please check this
     _outputs.CollectionChanged += OutputsChanged;
     _parameters = new BindableCollection <KeyValueUnitViewModel>();
     _logger     = new Log4NetLogger();
     _logger.Init(typeof(MasterDetailViewModel));
 }
 public TestableGenericPlcViewModel(
     IProvidePlcInformation informationProvider,
     ICommandControllers controllerCommander,
     IProvideStatesForScreenActivation states,
     IProvideStatesForScreenActivation detailStates,
     ISaveToFileSystem saver,
     ILoadFromFileSystem loader,
     IAskUser askUser,
     IModuleScreen parent,
     string moduleName)
     : base(informationProvider, controllerCommander, states, detailStates, saver, loader, askUser, parent, moduleName, new NonDispatchingDispatcher())
 {
 }
コード例 #3
0
 /// <summary>
 /// Initializes a new <see cref="GenericPlcViewModel"/> instance.
 /// </summary>
 /// <param name="informationProvider">
 /// The information provider is mainly used to get information about the platform
 /// modules plc controllers, but it also provides some interaction possibilities with those controllers.
 /// </param>
 /// <param name="controllerCommander">
 /// The controller commander provides functions to interact with a certain controller.
 /// This view model is responsible for creating <see cref="MasterDetailViewModel"/> instances which make
 /// use of the controller commander.
 /// </param>
 /// <param name="states">
 /// The states represent the three main view states of the generic page (Loading - Content - Error) and
 /// provide functions to switch between those.
 /// </param>
 /// <param name="detailStates">
 /// The detail states represent the three detail view states of the generic page (Loading - Content - Error) and
 /// provide functions to switch between those.
 /// </param>
 /// <param name="saver">
 /// The saver provides the possibility to save a string to the filesystem, used by the export
 /// functionality of the generic page.
 /// </param>
 /// <param name="loader">
 /// The loader provides the possibility to load a file from the filesystem, used by the import
 /// functionality of the generic page.
 /// </param>
 /// <param name="askUser">
 /// The ask user instance can get used to interact with the user.
 /// </param>
 /// <param name="parent">
 /// The view model of the parent screen is used to navigate back to it.
 /// </param>
 /// <param name="moduleName">
 /// The module name identifies the module this view model is responsible for.
 /// </param>
 /// <param name="dispatcher">
 /// The dispatcher is used to delegate all const-intensive operation to background threads and vice versa.
 /// </param>
 public GenericPlcViewModel(
     IProvidePlcInformation informationProvider,
     ICommandControllers controllerCommander,
     IProvideStatesForScreenActivation states,
     IProvideStatesForScreenActivation detailStates,
     ISaveToFileSystem saver,
     ILoadFromFileSystem loader,
     IAskUser askUser,
     IModuleScreen parent,
     string moduleName,
     IDispatcher dispatcher)
     : this()
 {
     _informationProvider = informationProvider;
     _controllerCommander = controllerCommander;
     _states            = states;
     _detailStates      = detailStates;
     _saver             = saver;
     _loader            = loader;
     _askUser           = askUser;
     _moduleName        = moduleName;
     _parenModuleScreen = parent;
     DisplayName        = "Detail View";
 }
コード例 #4
0
        private MasterDetailViewModel CreateMasterDetailViewModel(Controller controller, ICommandControllers commander, string moduleName)
        {
            if (controller == null)
            {
                return(new MasterDetailViewModel(new Controller {
                    Id = -1
                }, moduleName, commander, _detailStates));
            }
            IEnumerable <Controller> children = controller.Children ?? new Controller[0];
            var master = new MasterDetailViewModel(controller, moduleName, commander, _detailStates)
            {
                SuppressChangeEvent = true,
                Childs = children.Where(x => x != null)
                         .Select(x => CreateMasterDetailViewModel(x, commander, moduleName))
                         .MakeBindable(),
            };

            master.SuppressChangeEvent = false;
            return(master);
        }