예제 #1
0
 private void LoadLengthValue(SSWC.DataGridLength dataGridLength)
 {
     this._loadingValue = true;
     try
     {
         if (dataGridLength.IsAuto)
         {
             _comboBox.SelectedItem = DataGridLengthUnitType.Auto;
             DisableTextBox();
         }
         else if (dataGridLength.IsSizeToCells)
         {
             _comboBox.SelectedItem = DataGridLengthUnitType.SizeToCells;
             DisableTextBox();
         }
         else if (dataGridLength.IsSizeToHeader)
         {
             _comboBox.SelectedItem = DataGridLengthUnitType.SizeToHeader;
             DisableTextBox();
         }
         else
         {
             _comboBox.SelectedItem = DataGridLengthUnitType.Pixel;
             this.Text          = dataGridLength.Value.ToString(CultureInfo.InvariantCulture);
             _textBox.IsEnabled = true;
         }
     }
     finally
     {
         this._loadingValue = false;
     }
 }
예제 #2
0
        private void SetLengthValue()
        {
            SSWC.DataGridLengthUnitType unitType = (SSWC.DataGridLengthUnitType)_comboBox.SelectedItem;
            switch (unitType)
            {
            case SSWC.DataGridLengthUnitType.Auto:
                this.Value = SSWC.DataGridLength.Auto;
                break;

            case SSWC.DataGridLengthUnitType.SizeToCells:
                this.Value = SSWC.DataGridLength.SizeToCells;
                break;

            case SSWC.DataGridLengthUnitType.SizeToHeader:
                this.Value = SSWC.DataGridLength.SizeToHeader;
                break;

            case SSWC.DataGridLengthUnitType.Star:
                double starValue;
                if (double.TryParse(_textBox.Text, out starValue))
                {
                    // Store the last good star value
                    _lastValidStarValue = starValue;
                    this.Value          = new SSWC.DataGridLength(starValue, SSWC.DataGridLengthUnitType.Star);
                }
                else
                {
                    // The user entered something bad so revert to the last good value
                    _textBox.Text = _lastValidStarValue.ToString(CultureInfo.InvariantCulture);
                    // The Text binding does not update the Value in this case so set it explicitly
                    this.Value = new SSWC.DataGridLength(_lastValidStarValue, SSWC.DataGridLengthUnitType.Star);
                }
                break;

            default:
                // Treat it as a Pixel length
                double pixels;
                if (double.TryParse(_textBox.Text, out pixels))
                {
                    // Store the last good pixel value
                    _lastValidPixelWidth = pixels;
                    this.Value           = new SSWC.DataGridLength(pixels);
                }
                else
                {
                    // The user entered something bad so revert to the last good value
                    _textBox.Text = _lastValidPixelWidth.ToString(CultureInfo.InvariantCulture);
                    // The Text binding does not update the Value in this case so set it explicitly
                    this.Value = new SSWC.DataGridLength(_lastValidPixelWidth);
                }
                break;
            }
        }
예제 #3
0
        private void SetLengthValue()
        {
            DataGridLengthUnitType unitType = (DataGridLengthUnitType)_comboBox.SelectedItem;

            switch (unitType)
            {
            case DataGridLengthUnitType.Auto:
                // To get around grow only in the designer, set the width to a small value
                this.SetValueNoCallback(DataGridLengthEditorGrid.ValueProperty, new SSWC.DataGridLength(1));
                this.Value = SSWC.DataGridLength.Auto;
                break;

            case DataGridLengthUnitType.SizeToCells:
                // To get around grow only in the designer, set the width to a small value
                this.SetValueNoCallback(DataGridLengthEditorGrid.ValueProperty, new SSWC.DataGridLength(1));
                this.Value = SSWC.DataGridLength.SizeToCells;
                break;

            case DataGridLengthUnitType.SizeToHeader:
                // To get around grow only in the designer, set the width to a small value
                this.SetValueNoCallback(DataGridLengthEditorGrid.ValueProperty, new SSWC.DataGridLength(1));
                this.Value = SSWC.DataGridLength.SizeToHeader;
                break;

            default:
                // Treat it as a Pixel length
                double pixels;
                if (double.TryParse(_textBox.Text, out pixels))
                {
                    // Store the last good pixel value
                    _lastValidPixelWidth = pixels;
                    this.Value           = new SSWC.DataGridLength(pixels);
                }
                else
                {
                    // The user entered something bad so revert to the last good value
                    _textBox.Text = _lastValidPixelWidth.ToString(CultureInfo.InvariantCulture);
                    // The Text binding does not update the Value in this case so set it explicitly
                    this.Value = new SSWC.DataGridLength(_lastValidPixelWidth);
                }
                break;
            }
        }
 private void SetLengthValue()
 {
     DataGridLengthUnitType unitType = (DataGridLengthUnitType)_comboBox.SelectedItem;
     switch (unitType)
     {
         case DataGridLengthUnitType.Auto:
             // To get around grow only in the designer, set the width to a small value
             this.SetValueNoCallback(DataGridLengthEditorGrid.ValueProperty, new SSWC.DataGridLength(1));
             this.Value = SSWC.DataGridLength.Auto;
             break;
         case DataGridLengthUnitType.SizeToCells:
             // To get around grow only in the designer, set the width to a small value
             this.SetValueNoCallback(DataGridLengthEditorGrid.ValueProperty, new SSWC.DataGridLength(1));
             this.Value = SSWC.DataGridLength.SizeToCells;
             break;
         case DataGridLengthUnitType.SizeToHeader:
             // To get around grow only in the designer, set the width to a small value
             this.SetValueNoCallback(DataGridLengthEditorGrid.ValueProperty, new SSWC.DataGridLength(1));
             this.Value = SSWC.DataGridLength.SizeToHeader;
             break;
         default:
             // Treat it as a Pixel length
             double pixels;
             if (double.TryParse(_textBox.Text, out pixels))
             {
                 // Store the last good pixel value
                 _lastValidPixelWidth = pixels;
                 this.Value = new SSWC.DataGridLength(pixels);
             }
             else
             {
                 // The user entered something bad so revert to the last good value
                 _textBox.Text = _lastValidPixelWidth.ToString(CultureInfo.InvariantCulture);
                 // The Text binding does not update the Value in this case so set it explicitly
                 this.Value = new SSWC.DataGridLength(_lastValidPixelWidth);
             }
             break;
     }
 }
 private void SetLengthValue()
 {
     SSWC.DataGridLengthUnitType unitType = (SSWC.DataGridLengthUnitType)_comboBox.SelectedItem;
     switch (unitType)
     {
         case SSWC.DataGridLengthUnitType.Auto:
             this.Value = SSWC.DataGridLength.Auto;
             break;
         case SSWC.DataGridLengthUnitType.SizeToCells:
             this.Value = SSWC.DataGridLength.SizeToCells;
             break;
         case SSWC.DataGridLengthUnitType.SizeToHeader:
             this.Value = SSWC.DataGridLength.SizeToHeader;
             break;
         case SSWC.DataGridLengthUnitType.Star:
             double starValue;
             if (double.TryParse(_textBox.Text, out starValue))
             {
                 // Store the last good star value
                 _lastValidStarValue = starValue;
                 this.Value = new SSWC.DataGridLength(starValue, SSWC.DataGridLengthUnitType.Star);
             }
             else
             {
                 // The user entered something bad so revert to the last good value
                 _textBox.Text = _lastValidStarValue.ToString(CultureInfo.InvariantCulture);
                 // The Text binding does not update the Value in this case so set it explicitly
                 this.Value = new SSWC.DataGridLength(_lastValidStarValue, SSWC.DataGridLengthUnitType.Star);
             }
             break;
         default:
             // Treat it as a Pixel length
             double pixels;
             if (double.TryParse(_textBox.Text, out pixels))
             {
                 // Store the last good pixel value
                 _lastValidPixelWidth = pixels;
                 this.Value = new SSWC.DataGridLength(pixels);
             }
             else
             {
                 // The user entered something bad so revert to the last good value
                 _textBox.Text = _lastValidPixelWidth.ToString(CultureInfo.InvariantCulture);
                 // The Text binding does not update the Value in this case so set it explicitly
                 this.Value = new SSWC.DataGridLength(_lastValidPixelWidth);
             }
             break;
     }
 }