public AirportUserControl(MainWindow core) { InitializeComponent(); SimServiceProxy SimProxy = new SimServiceProxy(); ViewModelLocator locator = new ViewModelLocator(this, SimProxy); DataContext = locator.AirportViewModel; }
/// <summary> /// The constructor of the view model. called from the user control by a locator. /// </summary> /// <param name="control">the user control that calls the view model</param> /// <param name="proxy">the UI service proxy</param> public AirportViewModel(AirportUserControl control, SimServiceProxy proxy) : base() { airportUserControl = control; //the view model listens to the loaded event of the user control to start the flight object generator after load. airportUserControl.Loaded += airportUserControl_Loaded; simProxy = proxy; //the method that runs after the control loaded event simProxy.OnLoadEvent += SimProxy_OnLoadEvent; //the method that runs each flight object checkpoint promotion event simProxy.OnPromotionEvaluationEvent += SimProxy_OnPromotionEvaluationEvent; //the method that runs when a flight object leaves the airport simProxy.OnDisposeEvent += SimProxy_OnDisposeEvent; txtblckCheckpoints = InitializeTxtblckCheckpoints(txtblckCheckpoints); lstvwsCheckpoints = InitializeLstvwsCheckpoints(lstvwsCheckpoints); imgPlanes = InitializeImgPlanes(imgPlanes); }
/// <summary> /// Initializes the locator with it's view model object that recieves the UI's user control & it's proxy /// </summary> /// <param name="control">the UI's user control</param> /// <param name="proxy">the UI's proxy</param> public ViewModelLocator(AirportUserControl control, SimServiceProxy proxy) : this() { airportViewModel = new AirportViewModel(control, proxy); }