Beispiel #1
0
        /// <summary>
        /// Invokes the action as a result of a ribbon control being clicked, selected, etc.
        /// </summary>
        /// <param name="ribbonControlId">
        /// The Id property of the associated RibbonControl
        /// </param>
        /// <param name="ribbonControlTag">
        /// The Tag property of the associated RibbonControl
        /// </param>
        public override async Task OnAction(string ribbonControlId, string ribbonControlTag = "")
        {
            IDialogNavigationService dialogService;

            switch (ribbonControlId)
            {
            case "CDP4_Open":
                dialogService = ServiceLocator.Current.GetInstance <IDialogNavigationService>();
                var dataSelection       = new DataSourceSelectionViewModel();
                var dataSelectionResult = dialogService.NavigateModal(dataSelection) as DataSourceSelectionResult;
                break;

            case "CDP4_Close":
                await this.session.Close();

                break;

            case "CDP4_ProxySettings":
                dialogService = ServiceLocator.Current.GetInstance <IDialogNavigationService>();
                var proxyServerViewModel       = new ProxyServerViewModel();
                var proxyServerViewModelResult = dialogService.NavigateModal(proxyServerViewModel) as DataSourceSelectionResult;
                break;

            default:
                logger.Debug("The ribbon control with Id {0} and Tag {1} is not handled by the current RibbonPart", ribbonControlId, ribbonControlTag);
                break;
            }
        }
Beispiel #2
0
        public MainWindow()
        {
            proxyServerViewModel = new ProxyServerViewModel();
            DataContext          = proxyServerViewModel;

            InitializeComponent();
        }
Beispiel #3
0
        public void Verify_that_when_invalid_port_ok_not_enabled()
        {
            var vm = new ProxyServerViewModel();

            vm.Port = "rtyuio";

            Assert.IsFalse(vm.OkCommand.CanExecute(null));

            vm.Port = "8080";

            Assert.IsTrue(vm.OkCommand.CanExecute(null));
        }
Beispiel #4
0
        public void Verify_that_when_invalid_address_ok_not_enabled()
        {
            var vm = new ProxyServerViewModel();

            vm.Address = "%$#@";

            Assert.IsFalse(vm.OkCommand.CanExecute(null));

            vm.Address = "proxy.cdp4.org";

            Assert.IsTrue(vm.OkCommand.CanExecute(null));
        }
Beispiel #5
0
        public void Verify_that_the_ProxyServerViewModel_can_be_constructed()
        {
            var vm = new ProxyServerViewModel();

            Assert.AreEqual("proxy.cdp4.org", vm.Address);
            Assert.AreEqual("8888", vm.Port);
            Assert.IsNull(vm.UserName);
            Assert.IsNull(vm.Password);

            Assert.IsTrue(vm.OkCommand.CanExecute(null));

            Assert.IsTrue(vm.CancelCommand.CanExecute(null));
        }
Beispiel #6
0
        /// <summary>
        /// Invokes the action as a result of a ribbon control being clicked, selected, etc.
        /// </summary>
        /// <param name="ribbonControlId">
        /// The Id property of the associated RibbonControl
        /// </param>
        /// <param name="ribbonControlTag">
        /// The Tag property of the associated RibbonControl
        /// </param>
        public override async Task OnAction(string ribbonControlId, string ribbonControlTag = "")
        {
            switch (ribbonControlId)
            {
            case "CDP4_Open":
                var dataSelection       = new DataSourceSelectionViewModel(this.DialogNavigationService);
                var dataSelectionResult = this.DialogNavigationService.NavigateModal(dataSelection) as DataSourceSelectionResult;

                if (dataSelectionResult?.OpenModel ?? false)
                {
                    this.OpenModelDialog();
                }

                break;

            case "CDP4_Close":
                await this.session.Close();

                break;

            case "CDP4_ProxySettings":
                var proxyServerViewModel       = new ProxyServerViewModel();
                var proxyServerViewModelResult = this.DialogNavigationService.NavigateModal(proxyServerViewModel) as DataSourceSelectionResult;
                break;

            case "CDP4_SelectModelToOpen":
                this.OpenModelDialog();
                break;

            case "CDP4_SelectModelToClose":
                var sessionsClosing = new List <ISession> {
                    this.session
                };
                var modelClosingDialogViewModel       = new ModelClosingDialogViewModel(sessionsClosing);
                var modelClosingDialogViewModelResult = this.DialogNavigationService.NavigateModal(modelClosingDialogViewModel) as DataSourceSelectionResult;
                break;

            case "CDP4_Plugins":
                var modelPluginDialogViewModel = new PluginManagerViewModel <AddinAppSettings>(this.appSettingService);
                var modelPluginDialogResult    = this.DialogNavigationService.NavigateModal(modelPluginDialogViewModel) as DataSourceSelectionResult;
                break;

            default:
                logger.Debug("The ribbon control with Id {0} and Tag {1} is not handled by the current RibbonPart", ribbonControlId, ribbonControlTag);
                break;
            }
        }
Beispiel #7
0
        public void Verify_that_when_ok_executed_registry_is_written_and_result_is_true()
        {
            var vm = new ProxyServerViewModel();

            vm.Address  = "192.168.0.100";
            vm.Port     = "1234";
            vm.UserName = "******";
            vm.Password = "******";

            vm.OkCommand.Execute(null);

            Assert.AreEqual(true, vm.DialogResult.Result.Value);

            var proxyServerConfiguration = ProxyServerConfigurationManager.Read();

            Assert.AreEqual("192.168.0.100", proxyServerConfiguration.Address);
            Assert.AreEqual("1234", proxyServerConfiguration.Port);
            Assert.AreEqual("John", proxyServerConfiguration.UserName);
            Assert.AreEqual("Doe", proxyServerConfiguration.Password);
        }
Beispiel #8
0
        public void Verify_that_when_cancel_executed_registry_is_not_written_and_result_is_false()
        {
            var vm = new ProxyServerViewModel();

            vm.Address  = "test.cdp4.org";
            vm.Port     = "1234";
            vm.UserName = "******";
            vm.Password = "******";

            vm.CancelCommand.Execute(null);

            Assert.AreEqual(false, vm.DialogResult.Result.Value);

            var proxyServerConfiguration = ProxyServerConfigurationManager.Read();

            Assert.AreNotEqual("test.cdp4.org", proxyServerConfiguration.Address);
            Assert.AreNotEqual("1234", proxyServerConfiguration.Port);
            Assert.AreNotEqual("John", proxyServerConfiguration.UserName);
            Assert.AreNotEqual("Doe", proxyServerConfiguration.Password);
        }
Beispiel #9
0
        /// <summary>
        /// Executes the <see cref="OpenProxyConfigurationCommand"/> to load and save the web-proxy configuration
        /// </summary>
        private void ExecuteOpenProxyConfigurationCommand()
        {
            var proxyServerViewModel = new ProxyServerViewModel();

            this.dialogNavigationService.NavigateModal(proxyServerViewModel);
        }