ShootBlues.Script.AddEndpointDialog.AddEndpointDialog C# (CSharp) Method

AddEndpointDialog() public method

public AddEndpointDialog ( EndpointSettings settings ) : System
settings EndpointSettings
return System
        public AddEndpointDialog(EndpointSettings settings)
        {
            InitializeComponent();

            if (settings != null) {
                Settings = settings;
                EndpointName.ReadOnly = true;
            } else
                Settings = new EndpointSettings();

            Prefs = new[] {
                new Mapping(
                    BoundMember.New(() => Settings.Name),
                    BoundMember.New(() => EndpointName.Text)
                ),
                new Mapping(
                    BoundMember.New(() => Settings.Server),
                    BoundMember.New(() => Server.Text)
                ),
                new Mapping(
                    BoundMember.New(() => Settings.Username),
                    BoundMember.New(() => Username.Text)
                ),
                new Mapping(
                    BoundMember.New(() => Settings.Password),
                    BoundMember.New(() => Password.Text)
                ),
                new Mapping(
                    BoundMember.New(() => Settings.Resource),
                    BoundMember.New(() => Resource.Text)
                ),
                new Mapping(
                    BoundMember.New(() => Settings.ChatChannel),
                    BoundMember.New(() => ChatChannel.Text)
                ),
                new Mapping(
                    BoundMember.New(() => Settings.ChatAlias),
                    BoundMember.New(() => ChatAlias.Text)
                ),
                new Mapping(
                    BoundMember.New(() => Settings.ToUsername),
                    BoundMember.New(() => ToUsername.Text)
                )
            };

            foreach (var pref in Prefs)
                pref.Control.Value = pref.Setting.Value;

            SendToGroupChat.Checked = (ChatChannel.Text ?? "").Length > 0;
            SendToUser.Checked = (ToUsername.Text ?? "").Length > 0;

            RefreshEnabledState(null, EventArgs.Empty);
        }