public void ToDetailScreen(IModuleScreen moduleScreen, GenericPlcViewModel detailScreen) { var items = AddBreadcrumbBarItems(moduleScreen); items.Add(new BreadcrumbBarItem(detailScreen)); BreadcrumbBarItems = items; }
private async Task InitializeModule(IModuleScreen moduleScreen) { _logger.InfoFormat("Initializing shell moduleScreen {0}", moduleScreen.DisplayName); for (int i = 0; i < MaxReconnectFailCount; i++) { try { await moduleScreen.Initialize(); moduleScreen.IsEnabled = true; return; } catch (EndpointNotFoundException) { // try initialize current moduleScreen later again _logger.WarnFormat("WCF Communication endpoint problem. Try reconnect in {0} ms ...", WcfReconnectDelay); } catch (Exception e) { _logger.ErrorFormat("Cannot initialize screen {0}", moduleScreen.DisplayName, e); DisableModule(moduleScreen); return; } await Task.Delay(WcfReconnectDelay); } _logger.ErrorFormat("Can't connect to Server because timeout. Failed {0} times.", MaxReconnectFailCount); DisableModule(moduleScreen); }
public void DisableModule(IModuleScreen moduleScreen) { moduleScreen.IsEnabled = false; _logger.WarnFormat("Module {0} has been disabled", moduleScreen.DisplayName); var moduleControlScreen = moduleScreen as ModuleControlScreen; if (moduleControlScreen != null) { moduleControlScreen.State = "Disabled (Init failed)"; } }
public IModuleScreen GetModule(string moduleKey) { IModuleScreen foundModule = _modules.FirstOrDefault(m => Equals(m.ModuleKey, moduleKey)); if (foundModule == null) { throw new InvalidOperationException(new StringBuilder().AppendLine() .AppendFormat("Tried to get the module with name '{0}'.", moduleKey).AppendLine() .AppendLine("Unfortunately that module does not exist.").ToString()); } return(foundModule); }
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()) { }
private List <BreadcrumbBarItem> AddBreadcrumbBarItems(IModuleScreen moduleScreen) { var items = new List <BreadcrumbBarItem>(); if (HomeScreen != null) { items.Add(new BreadcrumbBarItem(HomeScreen)); } if (moduleScreen != null && !items.Any(x => x.DisplayName.Contains(moduleScreen.DisplayName))) { items.Add(new BreadcrumbBarItem(moduleScreen)); } return(items); }
public BreadcrumbBarItem(IModuleScreen screen) { if (screen != null) { _displayName = screen.DisplayName; _relatedScreen = screen; var baseViewModel = screen as BaseViewModel; if (baseViewModel != null) { _iconKey = baseViewModel.IconKey; } else { IconKey = string.Empty; } } }
/// <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"; }
/// <summary> /// Initializes a new <see cref="GenericPlcViewModel"/> instance. /// </summary> /// <param name="parent">The parent screen.</param> public GenericPlcViewModel(IModuleScreen parent) : this() { _parenModuleScreen = parent; DisplayName = "Detail View"; }
public void ToModuleScreen(IModuleScreen moduleScreen) { BreadcrumbBarItems = AddBreadcrumbBarItems(moduleScreen); }
public BreadcrumbBarViewModel(IModuleScreen homeScreen) { HomeScreen = homeScreen; ToHomeScreen(); }
/// <summary> /// Should only be called by module factories during application startup. /// </summary> public void AddNewModule(IModuleScreen module) { _modules.Add(module); }
public void NavigateToScreen(IModuleScreen screen) { CurrentScreen = screen; }