Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainWindowViewModel"/> class.
        /// </summary>
        /// <param name="applicationContext">The application context.</param>
        /// <param name="dataprovider">The BackupData data provider.</param>
        /// <param name="logger">The logging facility.</param>
        public MainWindowViewModel(ApplicationContext applicationContext,
                                   IBackupDataService dataprovider, ILogger logger)
        {
            Guard.NotNull(() => applicationContext, applicationContext);
            Guard.NotNull(() => dataprovider, dataprovider);
            Guard.NotNull(() => logger, logger);
            //MessageBox.Show("MainWindowViewModel create0");
            this.applicationContext = applicationContext;
            //MessageBox.Show("MainWindowViewModel create1");
            this.mainWindow   = applicationContext.MainWindow;
            this.dataprovider = dataprovider;
            this.logger       = logger;
            //MessageBox.Show("MainWindowViewModel create2");
            if (ViewModelBase.IsInDesignModeStatic)
            {
                //MessageBox.Show("MainWindowViewModel create3");
                mainWindow_Initialized(null, null);
                //MessageBox.Show("MainWindowViewModel create4");
                //MessageBox.Show("MainWindowViewModel mainWindow_Initialized");
            }
            else
            {
                // SimpleIoc.Default.Register<IDataService, Design.DesignDataService>();
                applicationContext.MainWindow.Initialized += this.mainWindow_Initialized;
                this.generalCommands = new GeneralCommandsModel(/*applicationViewModel,*/
                    this,
                    applicationContext.MainWindow);
            }

            /*if (this.mainWindow.Designer == null)
             * {
             *  throw new ArgumentNullException("mainWindow", "No Designer!");
             * }*/

            //ListBox lb;
            //this.MessengerInstance.Register<BuildMessageEventArgs>(this, logger.LogMessageEvent);
            //this.MessengerInstance.Register<TaskCommandLineEventArgs>(this, LogMessageEvent);
            //this.MessengerInstance.Register<string>(this, MainWindowMessageReceived);
            this.MessengerInstance.Register <string>(this, logger.LogMessageEvent);
            this.MessengerInstance.Register <MVVM.Messaging.DialogMessage>(this, MainWindowMessageReceived);
            this.MessengerInstance.Register <Exception>(this, true, MainWindowExceptionReceived);
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainWindowViewModel"/> class.
        /// </summary>
        /// <param name="applicationContext">The application context.</param>
        /// <param name="dataprovider">The BackupData data provider.</param>
        /// <param name="logger">The logging facility.</param>
        public MainWindowViewModel(ApplicationContext applicationContext,
            IBackupDataService dataprovider, ILogger logger)
        {
            Guard.NotNull(() => applicationContext, applicationContext);
            Guard.NotNull(() => dataprovider, dataprovider);
            Guard.NotNull(() => logger, logger);
            //MessageBox.Show("MainWindowViewModel create0");
            this.applicationContext = applicationContext;
            //MessageBox.Show("MainWindowViewModel create1");
            this.mainWindow = applicationContext.MainWindow;
            this.dataprovider = dataprovider;
            this.logger = logger;
            //MessageBox.Show("MainWindowViewModel create2");
            if (ViewModelBase.IsInDesignModeStatic)
            {
                //MessageBox.Show("MainWindowViewModel create3");
                mainWindow_Initialized(null, null);
                //MessageBox.Show("MainWindowViewModel create4");
                //MessageBox.Show("MainWindowViewModel mainWindow_Initialized");
            }
            else
            {
                // SimpleIoc.Default.Register<IDataService, Design.DesignDataService>();
                applicationContext.MainWindow.Initialized += this.mainWindow_Initialized;
                this.generalCommands = new GeneralCommandsModel(/*applicationViewModel,*/
                    this,
                    applicationContext.MainWindow);
            }
            /*if (this.mainWindow.Designer == null)
            {
                throw new ArgumentNullException("mainWindow", "No Designer!");
            }*/

            //ListBox lb;
            //this.MessengerInstance.Register<BuildMessageEventArgs>(this, logger.LogMessageEvent);
            //this.MessengerInstance.Register<TaskCommandLineEventArgs>(this, LogMessageEvent);
            //this.MessengerInstance.Register<string>(this, MainWindowMessageReceived);
            this.MessengerInstance.Register<string>(this, logger.LogMessageEvent);
            this.MessengerInstance.Register<MVVM.Messaging.DialogMessage>(this, MainWindowMessageReceived);
            this.MessengerInstance.Register<Exception>(this, true, MainWindowExceptionReceived);
        }