Exemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();

            this.Closing += OnWindowClosing;

            XBatchApp app = null;

            try
            {
                app = (XBatchApp)Application.Current;

                m_BatchManager = app.Host.Services.GetService <BatchManagerVM>();

                this.DataContext = m_BatchManager;

                m_BatchManager.ParentWindowHandle = new WindowInteropHelper(this).EnsureHandle();
            }
            catch (Exception ex)
            {
                IMessageService msgSvc;

                try
                {
                    msgSvc = app.Host.Services.GetService <IMessageService>();
                }
                catch
                {
                    msgSvc = new GenericMessageService("Batch+");
                }

                msgSvc.ShowError(ex.ParseUserError(out _));
            }
        }
Exemplo n.º 2
0
        private static void OnWindowCreated(MainWindow window, BatchArguments args)
        {
            try
            {
                m_Window = window;

                m_BatchManager     = m_AppLauncher.Container.Resolve <BatchManagerVM>();
                window.Closing    += OnWindowClosing;
                window.DataContext = m_BatchManager;

                m_BatchManager.ParentWindow = window;

                if (m_StartupOptions != null)
                {
                    if (!string.IsNullOrEmpty(m_StartupOptions.FilePath))
                    {
                        m_BatchManager.OpenDocument(m_StartupOptions.FilePath);
                    }

                    if (m_StartupOptions.CreateNew)
                    {
                        m_BatchManager.CreateDocument(m_StartupOptions.ApplicationId);
                    }
                }
            }
            catch (Exception ex)
            {
                IMessageService msgSvc;

                try
                {
                    msgSvc = m_AppLauncher.Container.Resolve <IMessageService>();
                }
                catch
                {
                    msgSvc = new GenericMessageService("Batch+");
                }

                msgSvc.ShowError(ex.ParseUserError());
                Environment.Exit(1);
            }
        }