public void Delete(object sender) { ConnectionViewModel source = (ConnectionViewModel)sender; Global.Parameters.Connections.Remove(source.Connection); ConnectionViewModels.Remove(source); }
public async void Edit(object sender) { ConnectionViewModel source = (ConnectionViewModel)sender; NewConnectionPage nc = new NewConnectionPage(source, false); Update(); await Navigation.PushAsync(nc); }
private async void Create() { Connection connection = new Connection(); Global.Parameters.Connections.Add(connection); ConnectionViewModel cvm = new ConnectionViewModel(Navigation, connection); ConnectionViewModels.Add(cvm); NewConnectionPage nc = new NewConnectionPage(cvm, true); await Navigation.PushAsync(nc); }
public void Select(ConnectionViewModel selected) { Global.Connect(selected.Name); selected.Connected = true; selected.Connection.Connected = true; foreach (ConnectionViewModel cvm in ConnectionViewModels) { if (cvm != selected) { cvm.Connected = false; cvm.Connection.Connected = false; } } }
public void Copy(object sender) { ConnectionViewModel source = (ConnectionViewModel)sender; Connection connection = new Connection(); source.Connection.CopyTo(connection); connection.Connected = false; connection.Name += " Copy"; Global.Parameters.Connections.Add(connection); ConnectionViewModel cvm = new ConnectionViewModel(Navigation, connection); ConnectionViewModels.Add(cvm); SelectedConnection = cvm; }
public ConnectionsViewModel(INavigation navigation) : base(navigation) { ConnectionViewModels = new ObservableCollection <ConnectionViewModel>(); if (Global.Parameters.Connections is List <Connection> ) { foreach (Connection connection in Global.Parameters.Connections) { if (connection.Name == Settings.CurrentConnection) { connection.Connected = true; } ConnectionViewModel cvm = new ConnectionViewModel(Navigation, connection); ConnectionViewModels.Add(cvm); } } Update(); NewConnectionCommand = new Command(Create); DeleteConnectionCommand = new Command <object>(Delete); EditConnectionCommand = new Command <object>(Edit); CopyConnectionCommand = new Command <object>(Copy); State = ModelState.Undefined; }