/// <summary> /// FireTabChangedEvent publishes a TabChangedEvent /// based on the current state of the TabHost. /// </summary> /// <param name="sendBlank">Determines if the Active Window should be checked for validity prior to sending the Message</param> private void FireTabChangedEvent(Boolean sendBlank) { //Get a reference to the TabHostView TabHostView thv = this._unity.Resolve <TabHostView>(Strings.TabHostViewName); //Create an ActiveTabInfo and fill it ActiveTabInfo info = new ActiveTabInfo(); //If the flag says to check the active window, do it if (sendBlank == false) { //If there is a current Tab available, fill the //ActiveDocumentInfo object. TabView dw = thv._tabContainer.ActiveWindow as TabView; if (dw != null) { //Cast the DataContext to the TabViewModel TabViewModel tvm = dw.DataContext as TabViewModel; //Fill the info info.DocumentName = tvm.DocumentName; info.TabsOpen = thv._tabContainer.Children.Count; } } //Finally, fire the TabChangedEvent this._eventAggregator.GetEvent <TabChangedEvent>().Publish(info); }
/// <summary> /// OnOpenSpectrum is called when the user would like /// to Open a Spectrum. /// </summary> /// <param name="fileName">The file to open</param> private void OnOpenSpectrum(String fileName) { //Get the objects required to open a Spectrum TabViewModel tvm = this._unity.Resolve <TabViewModel>(); TabView tv = this._unity.Resolve <TabView>(); //Set up the View tvm.FileName = fileName; tvm.HookEvents(tv); tv.DataContext = tvm; //Open the new Spectrum this.AddSpectrumTab(tv); }
/// <summary> /// OnNewSpectrum is called when the user would like /// to create a new Spectrum. /// </summary> /// <param name="info"></param> private void OnNewSpectrum(NewSpectrumInfo info) { //Get the objects required to open a Spectrum TabViewModel tvm = this._unity.Resolve <TabViewModel>(); TabView tv = this._unity.Resolve <TabView>(); //Set up the View tvm.HookEvents(tv); tv.DataContext = tvm; //Open the new Spectrum this.AddSpectrumTab(tv); //Start up the acquisition by setting the NewSpectrumInfo //object on the ViewModel tvm.NewSpectrumInfo = info; }