Exemple #1
0
        public MainModel(Config config, Ec2Connection connection)
        {
            this.Config = config;
            this.Connection = connection;

            this.Config.MainConfig.Bind(s => s.AwsAccessKey, (o, e) => this.ReconnectConnection());
            this.Config.MainConfig.Bind(s => s.AwsSecretKey, (o, e) => this.ReconnectConnection());

            this.ReconnectConnection();
        }
        public VolumeViewModel(
            Logger logger,
            IWindowManager windowManager,
            Ec2Connection connection,
            ICreateSnapshotDetailsViewModelFactory createSnapshotDetailsViewModelFactory,
            IScriptDetailsViewModelFactory scriptDetailsViewModelFactory)
        {
            this.Logger = logger;
            this.windowManager = windowManager;
            this.connection = connection;
            this.createSnapshotDetailsViewModelFactory = createSnapshotDetailsViewModelFactory;
            this.scriptDetailsViewModelFactory = scriptDetailsViewModelFactory;

            this.SelectedScript = this.Scripts[0];
        }
        public ConnectViewModel(MainModel model, IEventAggregator events)
        {
            this.config = model.Config;
            this.connection = model.Connection;
            this.events = events;

            this.config.Bind(s => s.MainConfig, (o, e) => 
                {
                    this.LoadFromConfig();
                });

            this.connection.Bind(s => s.IsConnected, (o, e) =>
                {
                    this.RefreshRunningInstances();
                    this.NotifyOfPropertyChange(() => CanRefreshRunningInstances);
                    this.NotifyOfPropertyChange(() => CanCreate);
                    this.NotifyOfPropertyChange(() => CanReconnectInstance);
                    this.NotifyOfPropertyChange(() => CanTerminateInstance);
                    var spotPriceTask = this.RefreshCurrentSpotPriceAsync();
                });

            this.Bind(s => s.ActiveInstanceType, (o, e) => Task.Run(() => this.RefreshCurrentSpotPriceAsync()));

            this.DisplayName = "Create New Instance";
            this.LoadFromConfig();

            this.ActiveInstanceType = this.InstanceTypes.FirstOrDefault(x => x.Key == "t1.micro");
            this.ActiveRunningInstance = this.RunningInstances[0];

            this.RefreshRunningInstances();
            var spotPriceTaskMain = this.RefreshCurrentSpotPriceAsync();
        }