Пример #1
0
 protected virtual void RemoveHandlers(ViewModel.Implementations.BaseViewModel bvm)
 {
     if (bvm is ViewModel.Interfaces.INavigate)
     {
         ((ViewModel.Interfaces.INavigate)bvm).NavigationEvent -= Vm_RequestNavigation;
     }
     if (bvm is ViewModel.Interfaces.IUpdatePlot)
     {
         ((ViewModel.Interfaces.IUpdatePlot)bvm).UpdatePlotEvent -= Vm_UpdatePlot;
     }
     //if (bvm is ViewModel.Interfaces.IClose)
     //{
     //    ((ViewModel.Interfaces.IClose)bvm).CloseEvent += wb_Close;
     //}
 }
Пример #2
0
 protected void Vm_RequestNavigation(object sender, ViewModel.Events.NavigationEventArgs e)
 {
     ViewModel.Implementations.BaseViewModel vm = e.ViewModel as ViewModel.Implementations.BaseViewModel;
     if (vm != null)
     {
         if ((e.NavigationProperties & ViewModel.Enumerations.NavigationOptionsEnum.AsNewWindow) > 0)
         {
             BasicWindow vw = new BasicWindow(vm);
             if (e.WindowTitle != "")
             {
                 vw.Title = e.WindowTitle;
             }
             vw.Owner = this;
             if ((e.NavigationProperties & ViewModel.Enumerations.NavigationOptionsEnum.AsDialog) > 0)
             {
                 vw.ShowDialog();
             }
             else
             {
                 vw.Show();
             }
         }
         else
         {
             ViewModel.Implementations.BaseViewModel bvm = DataContext as ViewModel.Implementations.BaseViewModel;
             RemoveHandlers(bvm);
             if (e.WindowTitle != "")
             {
                 this.Title = e.WindowTitle;
             }
             this.DataContext = vm;
             AddHandlers(vm);
         }
     }
     else
     {
         //throw an error.
     }
 }
Пример #3
0
 protected virtual void AddHandlers(ViewModel.Implementations.BaseViewModel bvm)
 {
     if (bvm is ViewModel.Interfaces.INavigate)
     {
         ((ViewModel.Interfaces.INavigate)bvm).NavigationEvent += Vm_RequestNavigation;
     }
     if (bvm is ViewModel.Interfaces.IUpdatePlot)
     {
         ((ViewModel.Interfaces.IUpdatePlot)bvm).UpdatePlotEvent += Vm_UpdatePlot;
     }
     if (bvm is Base.Interfaces.IReportMessage)
     {
         Base.Implementations.MessageHub.Register(bvm as Base.Interfaces.IReportMessage);
     }
     if (bvm is Base.Interfaces.IRecieveMessages)
     {
         Base.Implementations.MessageHub.Subscribe(bvm as Base.Interfaces.IRecieveMessages);
     }
     if (bvm is ViewModel.Interfaces.IClose)
     {
         ((ViewModel.Interfaces.IClose)bvm).CloseEvent += CloseProgram;
     }
 }
Пример #4
0
 public Window(ViewModel.Implementations.BaseViewModel bvm)
 {
     DataContext = bvm;
     AddHandlers(bvm);
 }
Пример #5
0
 public BasicWindow(ViewModel.Implementations.BaseViewModel bvm) : base(bvm)
 {
     DataContext = bvm;
     InitializeComponent();
 }