public void SetUp()
        {
            hkcu.DeleteSubKeyTree(TestKeyPath, false);
            this.settingsRepository = new ApplicationSettingsRepository(hkcu.CreateSubKey(TestKeyPath));
            this.projectRepository  = new ProjectRepository(
                hkcu.CreateSubKey(TestKeyPath));

            this.resourceManagerAdapterMock = new Mock <IResourceManagerAdapter>();
            this.resourceManagerAdapterMock.Setup(a => a.GetProjectAsync(
                                                      It.IsAny <string>(),
                                                      It.IsAny <CancellationToken>()))
            .ReturnsAsync(new Apis.CloudResourceManager.v1.Data.Project()
            {
                ProjectId = SampleProjectId,
                Name      = $"[{SampleProjectId}]"
            });

            this.computeEngineAdapterMock = new Mock <IComputeEngineAdapter>();
            this.computeEngineAdapterMock.Setup(a => a.ListInstancesAsync(
                                                    It.IsAny <string>(),
                                                    It.IsAny <CancellationToken>()))
            .ReturnsAsync(new[]
            {
                SampleWindowsInstanceInZone1,
                SampleLinuxInstanceInZone1
            });

            this.cloudConsoleServiceMock = new Mock <ICloudConsoleService>();
            this.eventServiceMock        = new Mock <IEventService>();
            this.sessionBrokerMock       = new Mock <IGlobalSessionBroker>();
        }
        public ScreenOptionsViewModel(
            ApplicationSettingsRepository settingsRepository)
        {
            this.settingsRepository = settingsRepository;

            //
            // Read current settings.
            //
            // NB. Do not hold on to the settings object because other tabs
            // might apply changes to other application settings.
            //

            var fullScreenDevices = (this.settingsRepository.GetSettings()
                                     .FullScreenDevices
                                     .StringValue ?? string.Empty)
                                    .Split(ApplicationSettings.FullScreenDevicesSeparator)
                                    .ToHashSet();

            this.Devices = new ObservableCollection <ScreenDevice>(
                Screen.AllScreens.Select(s => new ScreenDevice(this, s)
            {
                IsSelected = fullScreenDevices.Contains(s.DeviceName)
            }));

            this.isDirty = false;
        }
Exemple #3
0
        public NetworkOptionsViewModel(
            ApplicationSettingsRepository settingsRepository,
            IHttpProxyAdapter proxyAdapter)
        {
            this.settingsRepository = settingsRepository;
            this.proxyAdapter       = proxyAdapter;

            //
            // Read current settings.
            //
            // NB. Do not hold on to the settings object because other tabs
            // might apply changes to other application settings.
            //

            var settings = this.settingsRepository.GetSettings();

            if (!string.IsNullOrEmpty(settings.ProxyUrl.StringValue) &&
                Uri.TryCreate(settings.ProxyUrl.StringValue, UriKind.Absolute, out Uri proxyUrl))
            {
                this.proxyServer = proxyUrl.Host;
                this.proxyPort   = proxyUrl.Port.ToString();
            }

            if (!string.IsNullOrEmpty(settings.ProxyPacUrl.StringValue) &&
                IsValidProxyAutoConfigurationAddress(settings.ProxyPacUrl.StringValue))
            {
                this.proxyPacAddress = settings.ProxyPacUrl.StringValue;
            }

            if (this.proxyServer != null || this.proxyPacAddress != null)
            {
                this.proxyUsername = settings.ProxyUsername.StringValue;
                this.proxyPassword = settings.ProxyPassword.ClearTextValue;
            }
        }
Exemple #4
0
        public void SetUp()
        {
            hkcu.DeleteSubKeyTree(TestKeyPath, false);
            var baseKey = hkcu.CreateSubKey(TestKeyPath);

            this.settingsRepository = new ApplicationSettingsRepository(baseKey);
        }
Exemple #5
0
        public ProjectExplorerViewModel(
            IWin32Window view,
            ApplicationSettingsRepository settingsRepository,
            IJobService jobService,
            IEventService eventService,
            IGlobalSessionBroker sessionBroker,
            IProjectModelService projectModelService,
            ICloudConsoleService cloudConsoleService)
        {
            this.View = view;
            this.settingsRepository  = settingsRepository;
            this.jobService          = jobService;
            this.sessionBroker       = sessionBroker;
            this.projectModelService = projectModelService;
            this.cloudConsoleService = cloudConsoleService;

            this.RootNode = new CloudViewModelNode(this);

            //
            // Read current settings.
            //
            // NB. Do not hold on to the settings object because it might change.
            //

            this.operatingSystemsFilter = settingsRepository
                                          .GetSettings()
                                          .IncludeOperatingSystems
                                          .EnumValue;

            eventService.BindAsyncHandler <SessionStartedEvent>(
                e => UpdateInstanceAsync(e.Instance, i => i.IsConnected = true));
            eventService.BindAsyncHandler <SessionEndedEvent>(
                e => UpdateInstanceAsync(e.Instance, i => i.IsConnected = false));
        }
        public void TestInitialize()
        {
            _sqlConnectionWrapperMock      = new Mock <ISqlConnectionWrapper>(MockBehavior.Strict);
            _applicationSettingsRepository = new ApplicationSettingsRepository(_sqlConnectionWrapperMock.Object);

            SetUpGetTenantInfo(_sqlConnectionWrapperMock, "Blueprint_D29B49C10EC54646A9F03B77B9C51C26_20170722");
        }
        public GeneralOptionsViewModel(
            ApplicationSettingsRepository settingsRepository,
            IAppProtocolRegistry protocolRegistry,
            HelpService helpService)
        {
            this.settingsRepository = settingsRepository;
            this.protocolRegistry   = protocolRegistry;
            this.helpService        = helpService;

            //
            // Read current settings.
            //
            // NB. Do not hold on to the settings object because other tabs
            // might apply changes to other application settings.
            //

            var settings = this.settingsRepository.GetSettings();

            this.isUpdateCheckEnabled = settings.IsUpdateCheckEnabled.BoolValue;
            this.isDcaEnabled         = settings.IsDeviceCertificateAuthenticationEnabled.BoolValue;
            this.lastUpdateCheck      = settings.LastUpdateCheck.IsDefault
                ? "never"
                : DateTime.FromBinary(settings.LastUpdateCheck.LongValue).ToString();

            this.isBrowserIntegrationEnabled = this.protocolRegistry.IsRegistered(
                IapRdpUrl.Scheme,
                ExecutableLocation);
        }
Exemple #8
0
 internal async void OnCurrentApplicationSettingsIDChanged(object sender, NotificationEventArgs <string> e)
 {
     using (ApplicationSettingsRepository ctx = new ApplicationSettingsRepository())
     {
         CurrentApplicationSettings = await ctx.GetApplicationSettings(e.Data).ConfigureAwait(continueOnCapturedContext: false);
     }
     NotifyPropertyChanged(m => CurrentApplicationSettings);
 }
Exemple #9
0
        public DocumentWindow(
            IServiceProvider serviceProvider)
            : base(serviceProvider, DockState.Document)
        {
            this.settingsRepository = serviceProvider.GetService <ApplicationSettingsRepository>();

            this.DockAreas = DockAreas.Document;
        }
Exemple #10
0
        public void SetUp()
        {
            hkcu.DeleteSubKeyTree(TestKeyPath, false);
            var baseKey = hkcu.CreateSubKey(TestKeyPath);

            this.settingsRepository   = new ApplicationSettingsRepository(baseKey);
            this.protocolRegistryMock = new Mock <IAppProtocolRegistry>();
        }
        public void SetUp()
        {
            hkcu.DeleteSubKeyTree(TestKeyPath, false);
            this.settingsKey = hkcu.CreateSubKey(TestKeyPath);

            this.settingsRepository = new ApplicationSettingsRepository(this.settingsKey);
            this.proxyAdapterMock   = new Mock <IHttpProxyAdapter>();
        }
 public MainFormViewModel(
     Control view,
     ApplicationSettingsRepository applicationSettings,
     AuthSettingsRepository authSettings)
 {
     this.View = view;
     this.applicationSettings = applicationSettings;
     this.authSettings        = authSettings;
 }
Exemple #13
0
        public void SetUp()
        {
            var hkcu = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default);

            hkcu.DeleteSubKeyTree(TestKeyPath, false);
            var settingsKey = hkcu.CreateSubKey(TestKeyPath);

            this.settingsRepository = new ApplicationSettingsRepository(settingsKey);
        }
        public async Task SelectAll()
        {
            IEnumerable <ApplicationSettings> lst = null;

            using (var ctx = new ApplicationSettingsRepository())
            {
                lst = await ctx.GetApplicationSettingsByExpressionNav(vloader.FilterExpression, vloader.NavigationExpression).ConfigureAwait(continueOnCapturedContext: false);
            }
            SelectedApplicationSettings = new ObservableCollection <ApplicationSettings>(lst);
        }
 public MainFormViewModel(
     Control view,
     ApplicationSettingsRepository applicationSettings,
     AuthSettingsRepository authSettings,
     AppProtocolRegistry protocolRegistry)
 {
     this.View = view;
     this.applicationSettings = applicationSettings;
     this.authSettings        = authSettings;
     this.protocolRegistry    = protocolRegistry;
 }
        /// <summary>
        /// Initializes a new instance of the ApplicationSettingsService class.
        /// </summary>
        /// <param name="unitOfWork">UnitOfWork information</param>
        /// <param name="applicationSettings">Application settings</param>
        public ApplicationSettingsService(UnitOfWork unitOfWork, ApplicationSettings applicationSettings)
        {
            if (unitOfWork == null)
            {
                throw new ArgumentNullException(UnitOfWorkConst);
            }

            this.unitOfWork = unitOfWork;
            this.applicationSettingsRepository = new ApplicationSettingsRepository(this.unitOfWork);
            this.applicationSettings = applicationSettings;
        }
Exemple #17
0
        public void SetUp()
        {
            hkcu.DeleteSubKeyTree(TestKeyPath, false);
            var baseKey = hkcu.CreateSubKey(TestKeyPath);

            this.settingsRepository   = new ApplicationSettingsRepository(baseKey);
            this.protocolRegistryMock = new Mock <IAppProtocolRegistry>();
            this.viewModel            = new GeneralOptionsViewModel(
                this.settingsRepository,
                this.protocolRegistryMock.Object,
                new HelpService());
        }
Exemple #18
0
        public void WhenProxyPacUrlInvalid_ThenSetValueThrowsArgumentOutOfRangeException()
        {
            var baseKey    = hkcu.CreateSubKey(TestKeyPath);
            var repository = new ApplicationSettingsRepository(baseKey);

            var settings = repository.GetSettings();

            settings.ProxyPacUrl.Value = null;

            Assert.Throws <ArgumentOutOfRangeException>(
                () => settings.ProxyPacUrl.Value = "thisisnotanurl");
        }
        public MainFormViewModel(
            Control view,
            DockPanelColorPalette colorPalette,
            ApplicationSettingsRepository applicationSettings,
            AuthSettingsRepository authSettings)
        {
            this.View         = view;
            this.colorPalette = colorPalette;

            this.applicationSettings = applicationSettings;
            this.authSettings        = authSettings;
        }
        private SecureConnectEnrollment(
            ICertificateStoreAdapter certificateStore,
            ApplicationSettingsRepository applicationSettingsRepository)
        {
            this.applicationSettingsRepository = applicationSettingsRepository;
            this.certificateStore = certificateStore;

            // Initialize to a default state. The real initialization
            // happens in RefreshAsync().

            this.State       = DeviceEnrollmentState.Disabled;
            this.Certificate = null;
        }
        //---------------------------------------------------------------------
        // Publics.
        //---------------------------------------------------------------------

        public static async Task <SecureConnectEnrollment> GetEnrollmentAsync(
            ICertificateStoreAdapter certificateStore,
            ApplicationSettingsRepository applicationSettingsRepository,
            string userId)
        {
            var enrollment = new SecureConnectEnrollment(
                certificateStore,
                applicationSettingsRepository);
            await enrollment.RefreshAsync(userId)
            .ConfigureAwait(false);

            return(enrollment);
        }
        public void WhenKeyEmpty_ThenDefaultsAreProvided()
        {
            var baseKey    = hkcu.CreateSubKey(TestKeyPath);
            var repository = new ApplicationSettingsRepository(baseKey);

            var settings = repository.GetSettings();

            Assert.AreEqual(false, settings.IsMainWindowMaximized.Value);
            Assert.AreEqual(0, settings.MainWindowHeight.Value);
            Assert.AreEqual(0, settings.MainWindowWidth.Value);
            Assert.AreEqual(true, settings.IsUpdateCheckEnabled.Value);
            Assert.AreEqual(0, settings.LastUpdateCheck.Value);
        }
Exemple #23
0
        private static async Task AddApplicationSettings(FileDatabaseContext context)
        {
            var repository = new ApplicationSettingsRepository(context);

            try
            {
                await repository.LoadAsync();
            }
            catch (AggregateRootNotFoundException)
            {
                await repository.SaveAsync(new ApplicationSettingsFactory().Create());
            }
        }
Exemple #24
0
 public MainViewModel()
 {
     try
     {
         using (ApplicationSettingsRepository ctx = new ApplicationSettingsRepository())
         {
             BaseViewModel.Instance.CurrentApplicationSettings = ctx.ApplicationSettings().Result.FirstOrDefault(x => x.Description == "WaterNut");
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Exemple #25
0
        private BaseViewModel()
        {
            if (CurrentApplicationSettings == null && LicenseManager.UsageMode != LicenseUsageMode.Designtime)
            {
                using (var ctx = new ApplicationSettingsRepository())
                {
                    CurrentApplicationSettings = ctx.ApplicationSettings().Result.FirstOrDefault();
                }

                if (CurrentApplicationSettings == null)
                {
                    MessageBox.Show("No Default Application Settings Defined");
                }
            }
        }
        public ProjectExplorerViewModel(
            ApplicationSettingsRepository settingsRepository)
        {
            this.settingsRepository = settingsRepository;

            //
            // Read current settings.
            //
            // NB. Do not hold on to the settings object because it might change.
            //

            this.includedOperatingSystems = settingsRepository
                                            .GetSettings()
                                            .IncludeOperatingSystems
                                            .EnumValue;
        }
        public void WhenSettingsSaved_ThenSettingsCanBeRead()
        {
            var baseKey    = hkcu.CreateSubKey(TestKeyPath);
            var repository = new ApplicationSettingsRepository(baseKey);

            var settings = repository.GetSettings();

            settings.IsMainWindowMaximized.BoolValue = true;
            settings.MainWindowHeight.IntValue       = 480;
            settings.MainWindowWidth.IntValue        = 640;
            settings.IsUpdateCheckEnabled.BoolValue  = false;
            settings.LastUpdateCheck.LongValue       = 123L;
            repository.SetSettings(settings);

            settings = repository.GetSettings();

            Assert.AreEqual(true, settings.IsMainWindowMaximized.BoolValue);
            Assert.AreEqual(480, settings.MainWindowHeight.IntValue);
            Assert.AreEqual(640, settings.MainWindowWidth.IntValue);
            Assert.AreEqual(false, settings.IsUpdateCheckEnabled.BoolValue);
            Assert.AreEqual(123, settings.LastUpdateCheck.LongValue);
        }
Exemple #28
0
        public MainForm(IServiceProvider bootstrappingServiceProvider, IServiceProvider serviceProvider)
        {
            this.serviceProvider     = serviceProvider;
            this.applicationSettings = bootstrappingServiceProvider.GetService <ApplicationSettingsRepository>();
            this.authSettings        = bootstrappingServiceProvider.GetService <AuthSettingsRepository>();
            this.protocolRegistry    = bootstrappingServiceProvider.GetService <AppProtocolRegistry>();

            //
            // Restore window settings.
            //
            var windowSettings = this.applicationSettings.GetSettings();

            if (windowSettings.IsMainWindowMaximized)
            {
                this.WindowState = FormWindowState.Maximized;
                InitializeComponent();
            }
            else if (windowSettings.MainWindowHeight != 0 &&
                     windowSettings.MainWindowWidth != 0)
            {
                InitializeComponent();
                this.Size = new Size(
                    windowSettings.MainWindowWidth,
                    windowSettings.MainWindowHeight);
            }
            else
            {
                InitializeComponent();
            }

            // Set fixed size for the left/right panels.
            this.dockPanel.DockLeftPortion      =
                this.dockPanel.DockRightPortion = (300.0f / this.Width);

            this.checkForUpdatesOnExitToolStripMenuItem.Checked =
                this.applicationSettings.GetSettings().IsUpdateCheckEnabled;
            this.enableAppProtocolToolStripMenuItem.Checked =
                this.protocolRegistry.IsRegistered(IapRdpUrl.Scheme, GetType().Assembly.Location);
        }
Exemple #29
0
        public void WhenSettingsSaved_ThenSettingsCanBeRead()
        {
            var baseKey    = hkcu.CreateSubKey(TestKeyPath);
            var repository = new ApplicationSettingsRepository(baseKey);

            repository.SetSettings(new ApplicationSettings()
            {
                IsMainWindowMaximized = true,
                MainWindowHeight      = 480,
                MainWindowWidth       = 640,
                IsUpdateCheckEnabled  = false,
                LastUpdateCheck       = 123
            });

            var settings = repository.GetSettings();

            Assert.IsTrue(settings.IsMainWindowMaximized);
            Assert.AreEqual(480, settings.MainWindowHeight);
            Assert.AreEqual(640, settings.MainWindowWidth);
            Assert.AreEqual(false, settings.IsUpdateCheckEnabled);
            Assert.AreEqual(123, settings.LastUpdateCheck);
        }
Exemple #30
0
        public NetworkOptionsViewModel(
            ApplicationSettingsRepository settingsRepository,
            IHttpProxyAdapter proxyAdapter)
        {
            this.settingsRepository = settingsRepository;
            this.proxyAdapter       = proxyAdapter;

            //
            // Read current settings.
            //
            // NB. Do not hold on to the settings object because other tabs
            // might apply changes to other application settings.
            //

            var settings = this.settingsRepository.GetSettings();

            if (!string.IsNullOrEmpty(settings.ProxyUrl.StringValue) &&
                Uri.TryCreate(settings.ProxyUrl.StringValue, UriKind.Absolute, out Uri proxyUrl))
            {
                this.proxyServer = proxyUrl.Host;
                this.proxyPort   = proxyUrl.Port.ToString();
            }
        }
        public IList <ApplicationSettings> LoadRange(int startIndex, int count, SortDescriptionCollection sortDescriptions, out int overallCount)
        {
            try
            {
                if (FilterExpression == null)
                {
                    FilterExpression = "All";
                }
                using (var ctx = new ApplicationSettingsRepository())
                {
                    var r = ctx.LoadRange(startIndex, count, FilterExpression, navExp, IncludesLst);
                    overallCount = r.Result.Item2;

                    return(r.Result.Item1.ToList());
                }
            }
            catch (Exception ex)
            {
                StatusModel.Message(ex.Message);
                overallCount = 0;
                return(new List <ApplicationSettings>());
            }
        }