Newer
Older
Correlator / Correlator / App.xaml.cs
using System.Windows;
using Correlator.DataService;
using Correlator.Dialog;
using Correlator.ViewModels;
using Correlator.Views;
using Prism.DryIoc;
using Prism.Ioc;

namespace Correlator
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : PrismApplication
    {
        protected override Window CreateShell()
        {
            return Container.Resolve<MainWindow>();
        }

        protected override void InitializeShell(Window shell)
        {
            //可以实现登录
            var startupWindow = Container.Resolve<StartupWindow>();
            var result = startupWindow.ShowDialog();
            if (result == null)
            {
                Current.Shutdown();
                return;
            }

            if (result.Value)
            {
                base.OnInitialized();
            }
            else
            {
                Current.Shutdown();
            }
        }

        protected override void RegisterTypes(IContainerRegistry containerRegistry)
        {
            //Data
            containerRegistry.RegisterSingleton<IApplicationDataService, ApplicationDataServiceImpl>();
            containerRegistry.RegisterSingleton<ISerialPortService, SerialPortServiceImpl>();
            containerRegistry.RegisterSingleton<IAudioService, AudioServiceImpl>();
            
            //Dialog or Window
            containerRegistry.RegisterDialog<PictureFileView, PictureFileViewModel>();
            containerRegistry.RegisterDialog<BigPictureView, BigPictureViewModel>();
            containerRegistry.RegisterDialog<AudioFileView, AudioFileViewModel>();
            containerRegistry.RegisterDialog<SoundSpeedDialog, SoundSpeedDialogViewModel>();
            containerRegistry.RegisterDialog<AddSoundSpeedDialog, AddSoundSpeedDialogViewModel>();
            containerRegistry.RegisterDialog<EditSoundSpeedDialog, EditSoundSpeedDialogViewModel>();
            containerRegistry.RegisterDialog<ImportResponseDialog, ImportResponseDialogViewModel>();
            containerRegistry.RegisterDialog<CheckResponseDialog, CheckResponseDialogViewModel>();
            containerRegistry.RegisterDialog<SimplyAuditionDialog, SimplyAuditionDialogViewModel>();
            containerRegistry.RegisterDialog<NumericKeypadDialog, NumericKeypadDialogViewModel>();
            containerRegistry.RegisterDialog<AlertMessageDialog, AlertMessageDialogViewModel>();
            containerRegistry.RegisterDialog<AlertControlDialog, AlertControlDialogViewModel>();
        }
    }
}