Esempio n. 1
0
        public ConnectionManager(IStatusBar statusBar, IRSessionProvider sessionProvider, IRSettings settings, IRInteractiveWorkflow interactiveWorkflow)
        {
            _statusBar       = statusBar;
            _sessionProvider = sessionProvider;
            _brokerConnector = interactiveWorkflow.BrokerConnector;
            _settings        = settings;
            _shell           = interactiveWorkflow.Shell;

            _statusBarViewModel = new ConnectionStatusBarViewModel(this, interactiveWorkflow.Shell);

            _disposableBag = DisposableBag.Create <ConnectionManager>()
                             .Add(_statusBarViewModel)
                             .Add(() => _brokerConnector.BrokerChanged            -= BrokerChanged)
                             .Add(() => interactiveWorkflow.RSession.Connected    -= RSessionOnConnected)
                             .Add(() => interactiveWorkflow.RSession.Disconnected -= RSessionOnDisconnected);

            _brokerConnector.BrokerChanged += BrokerChanged;
            // TODO: Temporary solution - need to separate RHost errors and network connection issues
            interactiveWorkflow.RSession.Connected    += RSessionOnConnected;
            interactiveWorkflow.RSession.Disconnected += RSessionOnDisconnected;

            _shell.DispatchOnUIThread(() => _disposableBag.Add(_statusBar.AddItem(new ConnectionStatusBar {
                DataContext = _statusBarViewModel
            })));

            // Get initial values
            var connections = GetConnectionsFromSettings();

            _connections = new ConcurrentDictionary <Uri, IConnection>(connections);

            UpdateRecentConnections();
            SwitchBrokerToLastConnection();
        }
Esempio n. 2
0
 private void AddToStatusBar(FrameworkElement element, object dataContext)
 {
     if (_disposableBag.TryAdd(_statusBar.AddItem(element)))
     {
         element.DataContext = dataContext;
     }
 }
Esempio n. 3
0
        private async Task CompleteInitializationAsync()
        {
            await _shell.SwitchToMainThreadAsync();

            _disposableBag.Add(_statusBar.AddItem(new ConnectionStatusBar {
                DataContext = _statusBarViewModel
            }));
            await SwitchBrokerToLastConnection();
        }
Esempio n. 4
0
        public override void Initialize()
        {
            base.Initialize();

            Shell.ToolBars.Visible = true;

            mStatusBar.AddItem("Ready", new GridLength(1, GridUnitType.Star));
            AppStateStatusBarItem = mStatusBar.Items[0];
            //mStatusBar.AddItem("", new GridLength(100));
            //mStatusBar.AddItem("", new GridLength(100));

            RestoreWindowLocation();
        }
Esempio n. 5
0
 private void AddToStatusBar(FrameworkElement element, object dataContext)
 {
     lock (_syncObj) {
         // This only happens in tests when fixture is disposed
         // from background thread and main thread completion comes late.
         // TODO: Figure out of this can be improved in the test framework.
         if (!_disposed)
         {
             element.DataContext = dataContext;
             _disposableBag.Add(_statusBar.AddItem(element));
         }
     }
 }
Esempio n. 6
0
        private void OnGraphicsControlMouseMove(object sender, MouseEventArgs e)
        {
            var position      = e.GetPosition(this);
            var worldPosition = cameraHandler.Camera.TranslateScreenToWorld(position.ToMonogameVector2());

            coordinates.Set((int)position.X, (int)position.Y);
            statusBar.Items.Clear();
            statusBar.AddItem($"X: {(int)worldPosition.X}  /  Y: {(int)worldPosition.Y}", new GridLength(1, GridUnitType.Star));

            var newSelectedFrame =
                frames.FirstOrDefault(frame => (frame.Item2).Contains(worldPosition))
                ?.Item1 ?? -1;

            if (newSelectedFrame != selectedFrame)
            {
                selectedFrame = newSelectedFrame;
                output.AppendLine($"Frame: {selectedFrame}");
            }
            ReDraw();
        }
Esempio n. 7
0
 private void AddToStatusBar(IStatusBar statusBar, FrameworkElement item, object dataContext)
 {
     item.DataContext = dataContext;
     Disposables.TryAdd(statusBar.AddItem(item));
 }
Esempio n. 8
0
 private void AddToStatusBar(Func <FrameworkElement> itemFactory, object dataContext)
 {
     _disposableBag.TryAdd(_statusBar.AddItem(itemFactory, dataContext));
 }