/// <summary>
        /// Initializes a new instance of the OptionsViewPresenter class.
        /// </summary>
        /// <param name="optionsView">Options view.</param>
        /// <param name="mainView">Main view.</param>
        /// <param name="fileWatcherController">FileWatcherController.</param>
        /// <param name="applicationOptionsController">ApplicationOptionsController.</param>
        /// <exception cref="ArgumentNullException">fileWatcherController is null.</exception>
        public OptionsViewPresenter(IOptionsView optionsView,
            IMainView mainView,
            FileWatcherController fileWatcherController,
            ApplicationOptionsController applicationOptionsController)
        {
            if (mainView == null)
            {
                throw new ArgumentNullException("mainView",
                                                Resources.ArgumentNullException);
            }
            if (optionsView == null)
            {
                throw new ArgumentNullException("optionsView",
                                                Resources.ArgumentNullException);
            }
            if (fileWatcherController == null)
            {
                throw new ArgumentNullException("fileWatcherController",
                                                Resources.ArgumentNullException);
            }
            if (applicationOptionsController == null)
            {
                throw new ArgumentNullException("applicationOptionsController",
                                                Resources.ArgumentNullException);
            }

            _optionsView = optionsView;
            _mainView = mainView;
            _fileWatcherController = fileWatcherController;
            _applicationOptionsController = applicationOptionsController;

            SubscribeToMainViewEvents();
            SubscribeToOptionsViewEvents();
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the LogViewPresenterBase class. 
        /// </summary>
        /// <param name="logView">Log view.</param>
        /// <param name="mainView">Main view.</param>
        /// <param name="applicationOptionsController">ApplicationOptionsController.</param>
        /// <param name="fileWatcherController">FileWatcherController.</param>
        /// <param name="formatter">Log formatter.</param>
        /// <param name="viewUpdateInterval">View update interval.</param>
        /// <param name="logMessageSize">Log message size.</param>
        /// <exception cref="ArgumentNullException">Log view is null.</exception>
        /// <exception cref="ArgumentNullException">fileWatcherController is null.</exception>
        /// <exception cref="ArgumentNullException">formatter is null.</exception>
        public LogViewPresenter(ILogView logView,
            IMainView mainView,
            ApplicationOptionsController applicationOptionsController,
            FileWatcherController fileWatcherController,
            IFormatter formatter,
            double viewUpdateInterval,
            int logMessageSize)
            : base(fileWatcherController, formatter, logMessageSize)
        {
            if (logView == null)
            {
                throw new ArgumentNullException("logView",
                                                Resources.ArgumentNullException);
            }
            if (mainView == null)
            {
                throw new ArgumentNullException("mainView",
                                                Resources.ArgumentNullException);
            }
            if (applicationOptionsController == null)
            {
                throw new ArgumentNullException("applicationOptionsController",
                                                Resources.ArgumentNullException);
            }
            if (fileWatcherController == null)
            {
                throw new ArgumentNullException("fileWatcherController",
                                                Resources.ArgumentNullException);
            }
            if (formatter == null)
            {
                throw new ArgumentNullException("formatter",
                                                Resources.ArgumentNullException);
            }

            _logView = logView;
            _mainView = mainView;
            _applicationOptionsController = applicationOptionsController;

            // Check if view interval is less than default value.
            if (viewUpdateInterval < 100)
            {
                _updateTimer.Interval = 100;
            }
            else
            {
                _updateTimer.Interval = viewUpdateInterval;
            }

            SubscribeToLogViewEvents();
            SubscribeToMainViewEvents();
            SubscribeToApplicationOptionsControllerEvents();

            // Subscribe to timer event. (updates view).
            _updateTimer.Elapsed += new ElapsedEventHandler(OnElapsed);

            // Set synchronization context for running events in main thread.
            SetSynchronizationContext();
        }