Esempio n. 1
0
        public ConsoleViewModel(ConsoleView view)
        {
            if (view == null) throw new ArgumentNullException("view");
            _currentLineCount = 1; // first character typed will give a single line
            _view = view;

            Left = _configProvider.ReplLeft;
            Top = _configProvider.ReplTop;
            Width = _configProvider.ReplWidth;
            Height = _configProvider.ReplHeight;
            
            _view.Closing += ViewClosing;
            _view.InputTb.TextChanged += InputTbTextChanged;
            _closeCommand = new RelayCommand(async param => await CloseAsync(), param => CanCloseExecuted());
            _reportProvider.Initialise(_view.OutputTb);

            _cancellationSource = new CancellationTokenSource();
            StartMonitoring(_cancellationSource.Token);

            _cmdFactory.IsInSession = true;
        }
Esempio n. 2
0
        private OpohoConsoleManager()
        {
            if (!_provider.IsValid)
            {
                _log.Error("Invalid CompositionProvider. Unable to initialise OpohoConsoleManager");
                return;
            }
            var config = _provider.ConfigurationProvider as IConsoleConfigurationProvider;
            if (config == null)
            {
                _log.Error("Invalid ConfigurationProvider. Unable to initialise OpohoConsoleManager");
                return;
            }
            if (!config.IsValid)
            {
                _log.Error("Invalid configuration. Unable to initialise OpohoConsoleManager");
                return;
            }

            _isRunning = false;
            _ui = () =>
            {
                _view = new ConsoleView(ComponentManager.ApplicationWindow) { ShowInTaskbar = false };
                _viewModel = new ConsoleViewModel(_view);
                _view.DataContext = _viewModel;
                _isRunning = true;
                if (config.IsValid)
                {
                    if (config.StartOpohoOnShow) _viewModel.StartOpoho();
                }
                _viewModel.ClearReporting();
                _view.ShowDialog();

                _isRunning = false;
                _t = null;
                _view = null;
                _viewModel = null;
            };
        }