CmisSync.SettingWPF.ApplyController C# (CSharp) Method

ApplyController() public method

public ApplyController ( SettingController controller ) : void
controller SettingController
return void
        public void ApplyController(SettingController controller)
        {
            ProxyNone.Checked += delegate { controller.CheckProxyNone(); };
            ProxySystem.Checked += delegate { controller.CheckProxySystem(); };
            ProxyCustom.Checked += delegate { controller.CheckProxyCustom(); };
            LoginCheck.Checked += delegate { controller.CheckLogin(true); };
            LoginCheck.Unchecked += delegate { controller.CheckLogin(false); };
            AddressText.TextChanged += delegate(object sender, TextChangedEventArgs e)
            {
                controller.ValidateServer(AddressText.Text);
            };

            controller.CheckProxyNoneEvent += (check) =>
            {
                if (check != ProxyNone.IsChecked)
                {
                    ProxyNone.IsChecked = check;
                }
            };

            controller.CheckProxySystemEvent += (check) =>
            {
                if (check != ProxySystem.IsChecked)
                {
                    ProxySystem.IsChecked = check;
                }
            };

            controller.CheckProxyCutomEvent += (check) =>
            {
                if (check != ProxyCustom.IsChecked)
                {
                    ProxyCustom.IsChecked = check;
                }
                AddressText.IsEnabled = check;
                CheckAddress(controller);
            };

            controller.EnableLoginEvent += (enable) =>
            {
                LoginCheck.IsEnabled = enable;
                if (enable)
                {
                    controller.CheckLogin(LoginCheck.IsChecked.GetValueOrDefault());
                }
                else
                {
                    UserText.IsEnabled = false;
                    PasswordText.IsEnabled = false;
                }
            };

            controller.CheckLoginEvent += (check) =>
            {
                if (check != LoginCheck.IsChecked)
                {
                    LoginCheck.IsChecked = check;
                }
                UserText.IsEnabled = check;
                PasswordText.IsEnabled = check;
            };

            controller.UpdateServerHelpEvent += (message) =>
            {
                AddressError.Text = message;
            };

            controller.UpdateSaveEvent += (enable) =>
            {
                FinishButton.IsEnabled = enable;
            };

        }

Usage Example

Ejemplo n.º 1
0
        private void LoadSetting()
        {
            System.Uri resourceLocater = new System.Uri("/DataSpaceSync;component/SettingWPF.xaml", System.UriKind.Relative);
            SettingWPF wpf             = Application.LoadComponent(resourceLocater) as SettingWPF;

            ProxyNone     = wpf.FindName("ProxyNone") as RadioButton;
            ProxySystem   = wpf.FindName("ProxySystem") as RadioButton;
            ProxyCustom   = wpf.FindName("ProxyCustom") as RadioButton;
            LoginCheck    = wpf.FindName("LoginCheck") as CheckBox;
            AddressLabel  = wpf.FindName("AddressLabel") as TextBlock;
            AddressText   = wpf.FindName("AddressText") as TextBox;
            UserLabel     = wpf.FindName("UserLabel") as TextBlock;
            UserText      = wpf.FindName("UserText") as TextBox;
            PasswordLabel = wpf.FindName("PasswordLabel") as TextBlock;
            PasswordText  = wpf.FindName("PasswordText") as PasswordBox;

            NotificationsCheck = wpf.FindName("NotificationToggle") as CheckBox;

            FinishButton = wpf.FindName("FinishButton") as Button;
            CancelButton = wpf.FindName("CancelButton") as Button;

            wpf.ApplyController(Controller);

            Content = wpf;
        }