Example #1
0
        private string GetEditorValue(EditorControlType controlType)
        {
            Control control = GetEditor(controlType);

            if (control == null)
            {
                return(null);
            }

            TextBox textBox = control as TextBox;

            if (textBox != null)
            {
                return(textBox.Text);
            }

            PasswordBox passwordBox = control as PasswordBox;

            if (passwordBox != null)
            {
                return(passwordBox.Password);
            }

            return(null);
        }
Example #2
0
        private string GetEditorValue(EditorControlType controlType)
        {
            Control control = GetEditor(controlType);

            if (control == null)
            {
                return(null);
            }

            TextBox textBox = control as TextBox;

            if (textBox != null && controlType == EditorControlType.IdpServer)
            {
                return(AuthMgr.LoginDetails.RedirectIfIdpPointsAtLoginSso(textBox.Text));
            }

            if (textBox != null)
            {
                return(textBox.Text);
            }

            PasswordBox passwordBox = control as PasswordBox;

            if (passwordBox != null)
            {
                return(passwordBox.Password);
            }
            return(null);
        }
Example #3
0
 private void SetControlVisibility(EditorControlType controlType, bool isVisible)
 {
     if (isVisible)
     {
         controlRowElements[controlType].Height = new GridLength(ROW_HEIGHT);
     }
     else
     {
         controlRowElements[controlType].Height = new GridLength(0.0);
     }
 }
Example #4
0
        private bool GetEditorValueAsBool(EditorControlType controlType)
        {
            Control control = GetEditor(controlType);

            if (control == null)
            {
                return(false);
            }

            CheckBox checkBox = control as CheckBox;

            if (checkBox != null)
            {
                if (checkBox.IsChecked.HasValue)
                {
                    return(checkBox.IsChecked.Value);
                }
            }

            return(false);
        }
Example #5
0
        private void AddInputToTabGrid(Grid tabGrid, string labelText, EditorControlType controlType, bool skipReadOnlyLabel = false)
        {
            Control control  = GetEditor(controlType);
            int     rowIndex = tabGrid.RowDefinitions.Count;

            AddRowDefinition(tabGrid, controlType, ROW_HEIGHT);
            Label label = new Label();

            label.Content    = labelText;
            label.FontWeight = FontWeights.Bold;
            AddControlToGrid(tabGrid, label, rowIndex, 0);

            if (control != null)
            {
                AddControlToGrid(tabGrid, control, rowIndex, 1);
                if (!skipReadOnlyLabel)
                {
                    Label readOnlyLabel = new Label();
                    controlReadOnlyLabels.Add(control, readOnlyLabel);
                    AddControlToGrid(tabGrid, readOnlyLabel, rowIndex, 1);
                }
            }
        }
		private void AddRowDefinition(Grid grid, EditorControlType? controlType, int pixels = Int32.MaxValue)
		{
			RowDefinition rowDef = new RowDefinition();
			if (pixels == Int32.MaxValue)
				rowDef.Height = GridLength.Auto;
			else
				rowDef.Height = new GridLength(pixels, GridUnitType.Pixel);
			grid.RowDefinitions.Add(rowDef);

			if (controlType.HasValue)
				controlRowElements.Add(controlType.Value, rowDef);

			if (pixels != Int32.MaxValue)
			{
				grid.MinHeight += pixels + 2;
				grid.Height = grid.MinHeight;
			}
			else
				grid.Height = double.NaN;
		}
		private bool GetEditorValueAsBool(EditorControlType controlType)
		{
			Control control = GetEditor(controlType);
			if (control == null)
				return false;

			CheckBox checkBox = control as CheckBox;
			if (checkBox != null)
			{
				if (checkBox.IsChecked.HasValue)
					return checkBox.IsChecked.Value;
			}

			return false;
		}
		private string GetEditorValue(EditorControlType controlType)
		{
			Control control = GetEditor(controlType);
			if (control == null)
				return null;

			TextBox textBox = control as TextBox;
			if (textBox != null && controlType == EditorControlType.IdpServer)
				return AuthMgr.LoginDetails.RedirectIfIdpPointsAtLoginSso(textBox.Text);

			if (textBox != null)
				return textBox.Text;

			PasswordBox passwordBox = control as PasswordBox;
			if (passwordBox != null)
				return passwordBox.Password;
			return null;
		}
		private void SetControlVisibility(EditorControlType controlType, bool isVisible)
		{
			if (isVisible)
			{
				controlRowElements[controlType].Height = new GridLength(ROW_HEIGHT);
			}
			else
			{
				controlRowElements[controlType].Height = new GridLength(0.0);
			}
		}
		private Control GetEditor(EditorControlType controlType, string defaultValue = null)
		{
			Control control = null;
			if (controls.ContainsKey(controlType))
				control = controls[controlType];
			else
			{
				switch (controlType)
				{
					case EditorControlType.Username:
					case EditorControlType.RallyServer:
					case EditorControlType.IdpServer:
					case EditorControlType.ProxyServer:
					case EditorControlType.ProxyUsername:
						TextBox textBox = new TextBox();
						control = textBox;
						break;
					case EditorControlType.Password:
					case EditorControlType.ProxyPassword:
						PasswordBox passwordBox = new PasswordBox();
						passwordBox.PasswordChar = '*';
						control = passwordBox;
						break;
					case EditorControlType.ConnectionType:
						ComboBox comboBox = new ComboBox();
						comboBox.SelectedValuePath = "Key";
						comboBox.DisplayMemberPath = "Value";

						if ((!RestApiAuthMgrWpf.AllowIdpBasedSso) &&
							(connectionTypes.ContainsKey(ConnectionType.IdpBasedSso)))
						{
							connectionTypes.Remove(ConnectionType.IdpBasedSso);
						}

						comboBox.ItemsSource = connectionTypes;
						comboBox.SelectionChanged += ConnectionTypeChanged;
						control = comboBox;
						break;
					case EditorControlType.TrustAllCertificates:
						CheckBox checkBox = new CheckBox();
						control = checkBox;
						break;
					default:
						throw new NotImplementedException();
				}

				control.Margin = new Thickness(0, 0, 10, 0);
				control.HorizontalAlignment = HorizontalAlignment.Stretch;
				control.MinWidth = 150;
				control.Height = 20;
				controls.Add(controlType, control);
			}

			return control;
		}
		private void AddInputToTabGrid(Grid tabGrid, string labelText, EditorControlType controlType, bool skipReadOnlyLabel = false)
		{
			Control control = GetEditor(controlType);
			int rowIndex = tabGrid.RowDefinitions.Count;
			AddRowDefinition(tabGrid, controlType, ROW_HEIGHT);
			Label label = new Label();
			label.Content = labelText;
			label.FontWeight = FontWeights.Bold;
			AddControlToGrid(tabGrid, label, rowIndex, 0);

			if (control != null)
			{
				AddControlToGrid(tabGrid, control, rowIndex, 1);
				if (!skipReadOnlyLabel)
				{
					Label readOnlyLabel = new Label();
					controlReadOnlyLabels.Add(control, readOnlyLabel);
					AddControlToGrid(tabGrid, readOnlyLabel, rowIndex, 1);
				}
			}
		}
Example #12
0
        private Control GetEditor(EditorControlType controlType, string defaultValue = null)
        {
            Control control = null;

            if (controls.ContainsKey(controlType))
            {
                control = controls[controlType];
            }
            else
            {
                switch (controlType)
                {
                case EditorControlType.Username:
                case EditorControlType.RallyServer:
                case EditorControlType.IdpServer:
                case EditorControlType.ProxyServer:
                case EditorControlType.ProxyUsername:
                    TextBox textBox = new TextBox();
                    control = textBox;
                    break;

                case EditorControlType.Password:
                case EditorControlType.ProxyPassword:
                    PasswordBox passwordBox = new PasswordBox();
                    passwordBox.PasswordChar = '*';
                    control = passwordBox;
                    break;

                case EditorControlType.ConnectionType:
                    ComboBox comboBox = new ComboBox();
                    comboBox.SelectedValuePath = "Key";
                    comboBox.DisplayMemberPath = "Value";

                    if ((!RestApiAuthMgrWpf.AllowIdpBasedSso) &&
                        (connectionTypes.ContainsKey(ConnectionType.IdpBasedSso)))
                    {
                        connectionTypes.Remove(ConnectionType.IdpBasedSso);
                    }

                    comboBox.ItemsSource       = connectionTypes;
                    comboBox.SelectionChanged += ConnectionTypeChanged;
                    control = comboBox;
                    break;

                case EditorControlType.TrustAllCertificates:
                    CheckBox checkBox = new CheckBox();
                    control = checkBox;
                    break;

                default:
                    throw new NotImplementedException();
                }

                control.Margin = new Thickness(0, 0, 10, 0);
                control.HorizontalAlignment = HorizontalAlignment.Stretch;
                control.MinWidth            = 150;
                control.Height = 20;
                controls.Add(controlType, control);
            }

            return(control);
        }