/// <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> /// HookEvents sets up some of the events that can't /// be handled with a Command. /// </summary> /// <param name="view">The View whose events must be hooked</param> public void HookEvents(TabView view) { //Save the View in the member variable this._view = view; //Hook the events this._view.SizeChanged += new System.Windows.SizeChangedEventHandler(view_SizeChanged); }
/// <summary> /// AddSpectrumTab resolves the TabHostView and /// adds the current Spectrum to the Tabbed List. /// </summary> /// <param name="tv">The TabView to add to the list</param> private void AddSpectrumTab(TabView tv) { //Get a reference to the TabHostView TabHostView thv = this._unity.Resolve <TabHostView>(Strings.TabHostViewName); //Add it to the TabbedMdiContainer and Activate it thv._tabContainer.Children.Add(tv); thv._tabContainer.SelectItem(tv); //Fire the TabChangedEvent this.FireTabChangedEvent(false); }
/// <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; }