Exemple #1
0
        public ContainerPickerViewModel(bool supportSSHConnections)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            SupportSSHConnections = supportSSHConnections;
            InitializeConnections();
            ContainerInstances = new ObservableCollection <IContainerViewModel>();

            // SSH is only available if we have Linux containers.
            _sshAvailable           = new Lazy <bool>(() => SupportSSHConnections && IsLibLinuxAvailable());
            AddSSHConnectionCommand = new ContainerUICommand(
                AddSSHConnection,
                (parameter /*unused parameter*/) =>
            {
                return(_sshAvailable.Value);
            },
                UIResources.AddNewSSHConnectionLabel,
                UIResources.AddNewSSHConnectionToolTip);

            OKCommand = new ContainerUICommand(
                (dialogObject) =>
            {
                ContainerPickerDialogWindow dialog = dialogObject as ContainerPickerDialogWindow;
                dialog.DialogResult = ComputeContainerConnectionString();
                dialog.Close();
            },
                (parameter /*unused*/) =>
            {
                return(SelectedContainerInstance != null);
            },
                UIResources.OKLabel,
                UIResources.OKLabel
                );

            CancelCommand = new ContainerUICommand(
                (dialogObject) =>
            {
                ContainerPickerDialogWindow dialog = dialogObject as ContainerPickerDialogWindow;
                dialog.Close();
            },
                UIResources.CancelLabel,
                UIResources.CancelLabel
                );

            RefreshCommand = new ContainerUICommand(
                (parameter /*unused*/) =>
            {
                RefreshContainersList();
            },
                (parameter /*unused*/) =>
            {
                return(IsRefreshEnabled);
            },
                UIResources.RefreshHyperlink,
                UIResources.RefreshToolTip);

            PropertyChanged   += ContainerPickerViewModel_PropertyChanged;
            SelectedConnection = SupportedConnections.First(item => item is LocalConnectionViewModel) ?? SupportedConnections.First();
        }
        public ContainerPickerViewModel()
        {
            InitializeConnections();
            ContainerInstances = new ObservableCollection <IContainerViewModel>();

            _sshAvailable           = new Lazy <bool>(() => IsLibLinuxAvailable());
            AddSSHConnectionCommand = new ContainerUICommand(
                AddSSHConnection,
                (parameter /*unused parameter*/) =>
            {
                return(_sshAvailable.Value);
            },
                UIResources.AddNewSSHConnectionLabel,
                UIResources.AddNewSSHConnectionToolTip);

            PropertyChanged   += ContainerPickerViewModel_PropertyChanged;
            SelectedConnection = SupportedConnections.First(item => item is LocalConnectionViewModel) ?? SupportedConnections.First();
        }