protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); SetLabelsText(); if (e.NavigationMode == NavigationMode.New) { bool isNew = e.Parameter == null; idx = isNew ? -1 : (int)e.Parameter; profile = !isNew ? AppManager.ProfilesManager.Items[idx].Clone() : new Profile(); DataContext = profile; //btnDelete.Visibility = isNew ? Visibility.Collapsed : Visibility.Visible; } }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); AppShell.Current.SetNavigationInfo("EditProfile", "menuProfiles"); if (AppManager.EcosApp.License.IsTrial) tbPort.IsEnabled = false; if (e.NavigationMode == NavigationMode.New) { bool isNew = e.Parameter == null; idx = isNew ? -1 : (int)e.Parameter; profile = !isNew ? AppManager.EcosApp.Profiles[idx].Clone() : new EcosProfile(); DataContext = profile; btnDelete.Visibility = isNew ? Visibility.Collapsed : Visibility.Visible; } }
private void RegisterProfileNotifications(EcosProfile profile) { if (profile != null) { profile.PropertyChanged += (s, e) => { NotifyProfilesChanged(); }; profile.CommandError += (s, e) => { Error?.Invoke(s, new StringEventArgs(e.Message.ResultString)); }; } }
public async Task<bool> ConnectAsync(EcosProfile profile) { bool result = false; await DisconnectAsync(); if (profile != null && !IsConnecting && !IsConnected) { IsConnecting = true; var host = profile.UseRemoteConnection ? profile.RemoteHost : profile.IPAddress; var port = profile.UseRemoteConnection ? profile.Port : profile.RemotePort; if (IsConnected = await connection.ConnectAsync(host, port)) { result = true; await profile.ConnectAsync(); ActiveProfile = profile; } IsConnecting = false; } return result; }