private void GotCanDesktops(IEnumerable <desktop> desktops) { if (desktops.Count() == 1) { try { var desktop = desktops.First(); ConnectDesktop(desktop); } catch (Exception ex) { MessageBox.Show(ex.Message); } } if (desktops.Count() > 1) { var viewModel = new RemoteDesktopSelectViewModel(desktops); var window = new RemoteDesktopSelectWindow(viewModel); _resources.Add(Disposable.Create( () => _dispatcher.Dispatch(window.Close))); window.ShowDialog(); //TODO: implement dialogresult if (viewModel.SelectedDesktop != null) { ConnectDesktop(viewModel.SelectedDesktop); } } }
public RemoteDesktopSelectWindow(RemoteDesktopSelectViewModel viewModel) { InitializeComponent(); _viewModel = viewModel; listBox1.DataSource = viewModel.Desktops; listBox1.DisplayMember = "Name"; listBox1.SelectedValueChanged += (s, e) => _viewModel.SelectedDesktop = (desktop)listBox1.SelectedValue; }
private void GotCanDesktops(IEnumerable <desktop> desktops) { if (desktops.Count() == 1) { var desktop = desktops.First(); DoConnect(desktop); } else if (desktops.Count() > 1) { var viewModel = new RemoteDesktopSelectViewModel(desktops); var window = new RemoteDesktopSelectWindow(viewModel); //_resources.Add(Disposable.Create(() => _dispatcher.Dispatch(window.Close))); window.ShowDialog(); if (window.DialogResult.HasValue && window.DialogResult.Value && viewModel.SelectedDesktop != null) { DoConnect(viewModel.SelectedDesktop); } } }
public RemoteDesktopSelectWindow(RemoteDesktopSelectViewModel viewModel) { InitializeComponent(); DataContext = viewModel; }