public ConnectionDataViewModel(IConnectionViewModel connectionViewModel) : base("Connection To Cornerstone") { ConnectionViewModel = connectionViewModel; ConnectionViewModel.PropertyChanged += ConnectionViewModelPropertyChanged; }
public void SelectConnection(IConnectionViewModel connection) { _shell.AssertIsOnMainThread(); if (connection == _selectedConnection) { return; } if (SelectedConnection != null && SelectedConnection.HasChanges) { var dialogResult = _shell.ShowMessage(Resources.ConnectionManager_ChangedSelection_HasChanges, MessageButtons.YesNoCancel); switch (dialogResult) { case MessageButtons.Yes: SaveSelected(); break; case MessageButtons.No: CancelSelected(); break; default: return; } } SelectedConnection = connection; }
public async Task ConnectAsync(IConnectionViewModel connection) { _shell.AssertIsOnMainThread(); await _connectionManager.ConnectAsync(SelectedConnection.Name, SelectedConnection.Path, SelectedConnection.RCommandLineArguments); UpdateConnections(); }
public bool TryDelete(IConnectionViewModel connection) { Shell.AssertIsOnMainThread(); CancelTestConnection(); if (connection == null) { return(false); } var confirmMessage = connection.IsActive ? Resources.ConnectionManager_RemoveActiveConnectionConfirmation.FormatCurrent(connection.Name) : Resources.ConnectionManager_RemoveConnectionConfirmation.FormatCurrent(connection.Name); var confirm = Shell.ShowMessage(confirmMessage, MessageButtons.YesNo); if (confirm == MessageButtons.No) { return(false); } if (connection.IsActive) { try { Shell.ProgressDialog.Show(ct => ConnectionManager.DisconnectAsync(ct), Resources.ConnectionManager_DeleteConnectionProgressBarMessage.FormatInvariant(connection.Name)); } catch (OperationCanceledException) { return(false); } } var result = ConnectionManager.TryRemove(connection.Name); UpdateConnections(); return(result); }
public void BrowseLocalPath(IConnectionViewModel connection) { _shell.AssertIsOnMainThread(); string latestLocalPath; Uri latestLocalPathUri; if (connection.Path != null && Uri.TryCreate(connection.Path, UriKind.Absolute, out latestLocalPathUri) && latestLocalPathUri.IsFile && !latestLocalPathUri.IsUnc) { latestLocalPath = latestLocalPathUri.LocalPath; } else { latestLocalPath = Environment.SystemDirectory; try { latestLocalPath = new RInstallation().GetCompatibleEnginePathFromRegistry(); if (string.IsNullOrEmpty(latestLocalPath) || !Directory.Exists(latestLocalPath)) { // Force 64-bit PF latestLocalPath = Environment.GetEnvironmentVariable("ProgramFiles"); } } catch (ArgumentException) { } catch (IOException) { } } var path = _shell.ShowBrowseDirectoryDialog(latestLocalPath); if (path != null) { connection.Path = path; } }
private bool TryStartEditing(IConnectionViewModel connection) { _shell.AssertIsOnMainThread(); if (connection == EditedConnection) { return(false); } if (EditedConnection != null && EditedConnection.HasChanges) { var dialogResult = _shell.ShowMessage(Resources.ConnectionManager_EditedConnectionHasChanges, MessageButtons.YesNoCancel); switch (dialogResult) { case MessageButtons.Yes: Save(EditedConnection); break; case MessageButtons.No: CancelEdit(); break; default: return(false); } } else { CancelEdit(); } EditedConnection = connection; connection.IsEditing = true; return(true); }
private bool TryStartEditing(IConnectionViewModel connection) { _shell.AssertIsOnMainThread(); // When 'Edit' button is clicked second time, we close the panel. // If panel has changes, offer save the changes. if (EditedConnection != null && EditedConnection.HasChanges) { var dialogResult = _shell.ShowMessage(Resources.ConnectionManager_EditedConnectionHasChanges, MessageButtons.YesNoCancel); switch (dialogResult) { case MessageButtons.Yes: Save(EditedConnection); break; case MessageButtons.Cancel: return false; } } var wasEditingConnection = EditedConnection; CancelEdit(); // If it is the same connection that was edited then we came here as a result // of a second click on the edit button. Don't start editing it again. if (connection != wasEditingConnection) { EditedConnection = connection; connection.IsEditing = true; } return true; }
private bool TryStartEditing(IConnectionViewModel connection) { _shell.AssertIsOnMainThread(); // When 'Edit' button is clicked second time, we close the panel. // If panel has changes, offer save the changes. if (EditedConnection != null && EditedConnection.HasChanges) { var dialogResult = _shell.ShowMessage(Resources.ConnectionManager_EditedConnectionHasChanges, MessageButtons.YesNoCancel); switch (dialogResult) { case MessageButtons.Yes: Save(EditedConnection); break; case MessageButtons.Cancel: return(false); } } var wasEditingConnection = EditedConnection; CancelEdit(); // If it is the same connection that was edited then we came here as a result // of a second click on the edit button. Don't start editing it again. if (connection != wasEditingConnection) { EditedConnection = connection; connection.IsEditing = true; } return(true); }
public void CancelTestConnection(IConnectionViewModel connection) { _shell.AssertIsOnMainThread(); connection.TestingConnectionCts?.Cancel(); connection.TestingConnectionCts = null; connection.IsTestConnectionSucceeded = false; connection.TestConnectionFailedText = null; }
public bool TryDelete(IConnectionViewModel connection) { _shell.AssertIsOnMainThread(); var result = _connectionManager.TryRemove(connection.Id); UpdateConnections(); return(result); }
public void Edit(IConnectionViewModel connection) { Shell.AssertIsOnMainThread(); if (connection == null) { return; } TryStartEditing(connection); }
public bool TryEdit(IConnectionViewModel connection) { Shell.AssertIsOnMainThread(); if (connection == null) { return(false); } return(TryStartEditing(connection)); }
protected CommandDataViewModel(IConnectionViewModel connectionViewModel, String label) : base(label) { Commands = new ObservableList <RemoteCommandViewModel>(Application.Current.Dispatcher); Traffic = new ObservableList <TrafficData>(Application.Current.Dispatcher); ExecuteCommand = new RelayCommand(OnExecute); ConnectionViewModel = connectionViewModel; ConnectionViewModel.PropertyChanged += ConnectionViewModelPropertyChanged; }
/// <summary> /// Initializes a new instance of the <see cref="RemoveConnectionViewModel" /> class. /// </summary> /// <param name="platformProvider">The platform provider.</param> /// <param name="eventAggregator">The event aggregator.</param> /// <param name="settingsRepository">The settings repository.</param> /// <param name="connectionViewModel">The connection view model.</param> public RemoveConnectionViewModel(IPlatformProvider platformProvider, IEventAggregator eventAggregator, IConnectionSettingsRepository settingsRepository, IConnectionViewModel connectionViewModel) : base(platformProvider) { Ensure.That(eventAggregator).IsNotNull(); Ensure.That(settingsRepository).IsNotNull(); Ensure.That(connectionViewModel).IsNotNull(); _eventAggregator = eventAggregator; _settingsRepository = settingsRepository; _connectionViewModel = connectionViewModel; DisplayName = Properties.Resources.RemoveConnection_View; }
public void Save(IConnectionViewModel connectionViewModel) { _shell.AssertIsOnMainThread(); var connection = _connectionManager.AddOrUpdateConnection( connectionViewModel.Name, connectionViewModel.Path, connectionViewModel.RCommandLineArguments); if (connection.Id != connectionViewModel.Id && connectionViewModel.Id != null) { _connectionManager.TryRemove(connectionViewModel.Id); } EditedConnection = null; IsEditingNew = false; UpdateConnections(); }
public void Connect(IConnectionViewModel connection) { _shell.AssertIsOnMainThread(); if (connection.IsActive && !IsConnected) { _shell.ProgressDialog.Show(_connectionManager.ReconnectAsync, Resources.ConnectionManager_ReconnectionToProgressBarMessage.FormatInvariant(connection.Name)); } else { var progressBarMessage = _connectionManager.ActiveConnection != null ? Resources.ConnectionManager_SwitchConnectionProgressBarMessage.FormatInvariant(_connectionManager.ActiveConnection.Name, connection.Name) : Resources.ConnectionManager_ConnectionToProgressBarMessage.FormatInvariant(connection.Name); _shell.ProgressDialog.Show(ct => _connectionManager.ConnectAsync(connection, ct), progressBarMessage); } UpdateConnections(); }
public async Task TestConnectionAsync(IConnectionViewModel connection) { Shell.AssertIsOnMainThread(); if (connection == null) { return; } CancelTestConnection(); connection.TestingConnectionCts = new CancellationTokenSource(); _testingConnection = connection; try { await ConnectionManager.TestConnectionAsync(connection, connection.TestingConnectionCts.Token); connection.IsTestConnectionSucceeded = true; } catch (ArgumentException) { if (connection.TestingConnectionCts != null) { connection.TestConnectionFailedText = Resources.ConnectionManager_TestConnectionFailed_PathIsInvalid; } } catch (RHostDisconnectedException exception) { if (connection.TestingConnectionCts != null) { connection.TestConnectionFailedText = Resources.ConnectionManager_TestConnectionFailed_Format.FormatInvariant(exception.Message); } } catch (ComponentBinaryMissingException) { if (connection.TestingConnectionCts != null) { connection.TestConnectionFailedText = Resources.ConnectionManager_TestConnectionFailed_RHostIsMissing; } } catch (OperationCanceledException) { if (connection.TestingConnectionCts != null) { connection.TestConnectionFailedText = Resources.ConnectionManager_TestConnectionCanceled; } } finally { connection.TestingConnectionCts?.Dispose(); connection.TestingConnectionCts = null; _testingConnection = null; } }
public void BrowseLocalPath(IConnectionViewModel connection) { Shell.AssertIsOnMainThread(); if (connection == null) { return; } string latestLocalPath; Uri latestLocalPathUri; if (connection.Path != null && Uri.TryCreate(connection.Path, UriKind.Absolute, out latestLocalPathUri) && latestLocalPathUri.IsFile && !latestLocalPathUri.IsUnc) { latestLocalPath = latestLocalPathUri.LocalPath; } else { latestLocalPath = Environment.SystemDirectory; try { latestLocalPath = new RInstallation().GetCompatibleEngines().FirstOrDefault()?.InstallPath; if (string.IsNullOrEmpty(latestLocalPath) || !Directory.Exists(latestLocalPath)) { // Force 64-bit PF latestLocalPath = Environment.GetEnvironmentVariable("ProgramW6432"); } } catch (ArgumentException) { } catch (IOException) { } } var path = Shell.FileDialog.ShowBrowseDirectoryDialog(latestLocalPath); if (path != null) { // Verify path var ri = new RInterpreterInfo(string.Empty, path); if (ri.VerifyInstallation(null, null, Shell)) { connection.Path = path; } } }
public void Save(IConnectionViewModel connectionViewModel) { Shell.AssertIsOnMainThread(); if (connectionViewModel == null || !connectionViewModel.HasChanges) { return; } if ((connectionViewModel.IsRenamed || IsEditingNew) && ConnectionManager.GetConnection(connectionViewModel.Name) != null) { Shell.ShowMessage(Resources.ConnectionManager_CantSaveWithTheSameName.FormatCurrent(connectionViewModel.Name), MessageButtons.OK); return; } if (connectionViewModel.IsConnected) { var confirm = Shell.ShowMessage(Resources.ConnectionManager_RenameActiveConnectionConfirmation.FormatCurrent(connectionViewModel.OriginalName), MessageButtons.YesNo); if (confirm == MessageButtons.Yes) { var message = Resources.ConnectionManager_RenameConnectionProgressBarMessage.FormatInvariant(connectionViewModel.OriginalName, connectionViewModel.Name); try { Shell.ProgressDialog.Show(ct => ConnectionManager.DisconnectAsync(ct), message); } catch (OperationCanceledException) { return; } } } ConnectionManager.AddOrUpdateConnection(connectionViewModel); if (connectionViewModel.IsRenamed) { ConnectionManager.TryRemove(connectionViewModel.OriginalName); } EditedConnection = null; IsEditingNew = false; UpdateConnections(); }
public void Save(IConnectionViewModel connectionViewModel) { }
public void Edit(IConnectionViewModel connection) { }
public Task TestConnectionAsync(IConnectionViewModel connection) => Task.CompletedTask;
public void Connect(IConnectionViewModel connection, bool connectToEdited) { _shell.AssertIsOnMainThread(); if (connection == null) { return; } if (connection != EditedConnection) { CancelEdit(); } else if (connectToEdited) { Save(connection); } else { return; } CancelTestConnection(); if (connection.IsActive && !IsConnected) { _shell.ProgressDialog.Show(_connectionManager.ReconnectAsync, Resources.ConnectionManager_ReconnectionToProgressBarMessage.FormatInvariant(connection.Name)); } else { var progressBarMessage = _connectionManager.ActiveConnection != null ? Resources.ConnectionManager_SwitchConnectionProgressBarMessage.FormatInvariant(_connectionManager.ActiveConnection.Name, connection.Name) : Resources.ConnectionManager_ConnectionToProgressBarMessage.FormatInvariant(connection.Name); _shell.ProgressDialog.Show(ct => _connectionManager.ConnectAsync(connection, ct), progressBarMessage); } UpdateConnections(); }
public FreeFormDataViewModel(IConnectionViewModel connectionViewModel) : base(connectionViewModel, "User Data Entry") { }
public void BrowseLocalPath(IConnectionViewModel connection) { _shell.AssertIsOnMainThread(); if (connection == null) { return; } string latestLocalPath; Uri latestLocalPathUri; if (connection.Path != null && Uri.TryCreate(connection.Path, UriKind.Absolute, out latestLocalPathUri) && latestLocalPathUri.IsFile && !latestLocalPathUri.IsUnc) { latestLocalPath = latestLocalPathUri.LocalPath; } else { latestLocalPath = Environment.SystemDirectory; try { latestLocalPath = new RInstallation().GetCompatibleEngines().FirstOrDefault()?.InstallPath; if (string.IsNullOrEmpty(latestLocalPath) || !Directory.Exists(latestLocalPath)) { // Force 64-bit PF latestLocalPath = Environment.GetEnvironmentVariable("ProgramW6432"); } } catch (ArgumentException) { } catch (IOException) { } } var path = _shell.FileDialog.ShowBrowseDirectoryDialog(latestLocalPath); if (path != null) { // Verify path var ri = new RInterpreterInfo(string.Empty, path); if (ri.VerifyInstallation(null, null, _shell)) { connection.Path = path; } } }
public void Save(IConnectionViewModel connectionViewModel) { _shell.AssertIsOnMainThread(); if (connectionViewModel == null || !connectionViewModel.HasChanges) { return; } _connectionManager.AddOrUpdateConnection( connectionViewModel.Name, connectionViewModel.Path, connectionViewModel.RCommandLineArguments, connectionViewModel.IsUserCreated); if (connectionViewModel.IsRenamed) { _connectionManager.TryRemove(connectionViewModel.OriginalName); } EditedConnection = null; IsEditingNew = false; UpdateConnections(); }
public RemoteSampleLoginDataViewModel(IConnectionViewModel connectionViewModel) : base(connectionViewModel, "Remote Sample Login Commands") { InitializeCommands(); SetupAvailability(); }
public void BrowseLocalPath(IConnectionViewModel connection) { }
public void Connect(IConnectionViewModel connection, bool connectToEdited) { }
public bool TryDelete(IConnectionViewModel connection) => false;
public async Task TestConnectionAsync(IConnectionViewModel connection) { _shell.AssertIsOnMainThread(); if (connection == null) { return; } CancelTestConnection(); connection.TestingConnectionCts = new CancellationTokenSource(); _testingConnection = connection; try { await _connectionManager.TestConnectionAsync(connection, connection.TestingConnectionCts.Token); connection.IsTestConnectionSucceeded = true; } catch (ArgumentException) { if (connection.TestingConnectionCts != null) { connection.TestConnectionFailedText = Resources.ConnectionManager_TestConnectionFailed_PathIsInvalid; } } catch (RHostDisconnectedException exception) { if (connection.TestingConnectionCts != null) { connection.TestConnectionFailedText = Resources.ConnectionManager_TestConnectionFailed_Format.FormatInvariant(exception.Message); } } catch (RHostBrokerBinaryMissingException) { if (connection.TestingConnectionCts != null) { connection.TestConnectionFailedText = Resources.ConnectionManager_TestConnectionFailed_RHostIsMissing; } } catch (OperationCanceledException) { if (connection.TestingConnectionCts != null) { connection.TestConnectionFailedText = Resources.ConnectionManager_TestConnectionCanceled; } } finally { connection.TestingConnectionCts?.Dispose(); connection.TestingConnectionCts = null; _testingConnection = null; } }
public void Edit(IConnectionViewModel connection) { _shell.AssertIsOnMainThread(); if (connection == null) { return; } TryStartEditing(connection); }
public void Connect(IConnectionViewModel connection, bool connectToEdited) { Shell.AssertIsOnMainThread(); if (connection == null || !connection.IsValid) { return; } if (connection != EditedConnection) { CancelEdit(); } else if (connectToEdited) { connection.UpdatePath(); Save(connection); } else { return; } CancelTestConnection(); if (connection.IsActive && !IsConnected) { Shell.ProgressDialog.Show(ConnectionManager.ReconnectAsync, Resources.ConnectionManager_ReconnectionToProgressBarMessage.FormatInvariant(connection.Name)); } else { var activeConnection = ConnectionManager.ActiveConnection; var connectionToSwitch = ConnectionManager.GetConnection(connection.Name); if (activeConnection != null && connectionToSwitch.BrokerConnectionInfo == activeConnection.BrokerConnectionInfo) { var text = Resources.ConnectionManager_ConnectionsAreIdentical.FormatCurrent(activeConnection.Name, connection.Name); Shell.ShowMessage(text, MessageButtons.OK); } else { var connect = true; if (activeConnection != null && _settings.ShowWorkspaceSwitchConfirmationDialog == YesNo.Yes) { var message = Resources.ConnectionManager_SwitchConfirmation.FormatCurrent(activeConnection.Name, connection.Name); if (Shell.ShowMessage(message, MessageButtons.YesNo) == MessageButtons.No) { connect = false; } } if (connect) { var progressBarMessage = activeConnection != null ? Resources.ConnectionManager_SwitchConnectionProgressBarMessage.FormatCurrent(activeConnection.Name, connection.Name) : Resources.ConnectionManager_ConnectionToProgressBarMessage.FormatCurrent(connection.Name); Shell.ProgressDialog.Show(ct => ConnectionManager.ConnectAsync(connection, ct), progressBarMessage); } } } UpdateConnections(); }
public void Edit(IConnectionViewModel connection) { _shell.AssertIsOnMainThread(); TryStartEditing(connection); }
public RemoteQueryDataViewModel(IConnectionViewModel connectionViewModel) : base(connectionViewModel, "Remote Query Commands") { InitializeCommands(); SetupAvailability(); }
public bool TryDelete(IConnectionViewModel connection) { _shell.AssertIsOnMainThread(); CancelTestConnection(); if (connection != null) { var confirm = _shell.ShowMessage(string.Format(CultureInfo.CurrentUICulture, Resources.ConnectionManager_RemoveConnectionConfirmation, connection.Name), MessageButtons.YesNo); if (confirm == MessageButtons.Yes) { var result = _connectionManager.TryRemove(connection.Name); UpdateConnections(); return result; } } return false; }
public bool TryEdit(IConnectionViewModel connection) => false;