Inheritance: Xceed.Wpf.Toolkit.AutoSelectTextBox
        private static void ValuePropertyChangedCallback(object sender, DependencyPropertyChangedEventArgs e)
        {
            ValueRangeTextBox valueRangeTextBox = sender as ValueRangeTextBox;

            if (valueRangeTextBox.IsForcingValue)
            {
                return;
            }

            // The ValueChangedCallback can be raised even though both values are the same since the property
            // datatype is Object.
            if (object.Equals(e.NewValue, e.OldValue))
            {
                return;
            }

            valueRangeTextBox.IsInValueChanged = true;
            try
            {
                valueRangeTextBox.Text = valueRangeTextBox.GetTextFromValue(e.NewValue);
            }
            finally
            {
                valueRangeTextBox.IsInValueChanged = false;
            }
        }
        private static object NullValueCoerceValueCallback(DependencyObject sender, object value)
        {
            ValueRangeTextBox valueRangeTextBox = sender as ValueRangeTextBox;

            if (!valueRangeTextBox.IsInitialized)
            {
                return(DependencyProperty.UnsetValue);
            }

            if ((value == null) || (value == DBNull.Value))
            {
                return(value);
            }

            Type type = valueRangeTextBox.ValueDataType;

            if (type == null)
            {
                throw new InvalidOperationException("An attempt was made to set a null value when the ValueDataType property is null.");
            }

            if (valueRangeTextBox.IsFinalizingInitialization)
            {
                value = ValueRangeTextBox.ConvertValueToDataType(value, valueRangeTextBox.ValueDataType);
            }

            if (value.GetType() != type)
            {
                throw new ArgumentException("The value is not of type " + type.Name + ".", "NullValue");
            }

            return(value);
        }
        protected override void OnInitialized(EventArgs e)
        {
            this.IsFinalizingInitialization = true;
            try
            {
                this.CoerceValue(ValueRangeTextBox.ValueDataTypeProperty);

                this.IsNumericValueDataType = ValueRangeTextBox.IsNumericType(this.ValueDataType);
                this.RefreshConversionHelpers();

                this.CoerceValue(ValueRangeTextBox.MinValueProperty);
                this.CoerceValue(ValueRangeTextBox.MaxValueProperty);

                this.CoerceValue(ValueRangeTextBox.ValueProperty);

                this.CoerceValue(ValueRangeTextBox.NullValueProperty);

                this.CoerceValue(ValueRangeTextBox.TextProperty);
            }
            catch (Exception exception)
            {
                throw new InvalidOperationException("Initialization of the ValueRangeTextBox failed.", exception);
            }
            finally
            {
                this.IsFinalizingInitialization = false;
            }

            base.OnInitialized(e);
        }
        private static void FormatProviderPropertyChangedCallback(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            ValueRangeTextBox valueRangeTextBox = ( ValueRangeTextBox )sender;

            if (!valueRangeTextBox.IsInitialized)
            {
                return;
            }

            valueRangeTextBox.OnFormatProviderChanged();
        }
        private static void ValueDataTypePropertyChangedCallback(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            ValueRangeTextBox valueRangeTextBox = sender as ValueRangeTextBox;

            Type valueDataType = e.NewValue as Type;

            valueRangeTextBox.IsNumericValueDataType = ValueRangeTextBox.IsNumericType(valueDataType);

            valueRangeTextBox.RefreshConversionHelpers();

            valueRangeTextBox.ConvertValuesToDataType(valueDataType);
        }
        private static object TextCoerceValueCallback(object sender, object value)
        {
            ValueRangeTextBox valueRangeTextBox = sender as ValueRangeTextBox;

            if (!valueRangeTextBox.IsInitialized)
            {
                return(DependencyProperty.UnsetValue);
            }

            if (value == null)
            {
                return(string.Empty);
            }

            return(value);
        }
        private static object MaxValueCoerceValueCallback(DependencyObject sender, object value)
        {
            ValueRangeTextBox valueRangeTextBox = sender as ValueRangeTextBox;

            if (!valueRangeTextBox.IsInitialized)
            {
                return(DependencyProperty.UnsetValue);
            }

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

            Type type = valueRangeTextBox.ValueDataType;

            if (type == null)
            {
                throw new InvalidOperationException("An attempt was made to set a maximum value when the ValueDataType property is null.");
            }

            if (valueRangeTextBox.IsFinalizingInitialization)
            {
                value = ValueRangeTextBox.ConvertValueToDataType(value, valueRangeTextBox.ValueDataType);
            }

            if (value.GetType() != type)
            {
                throw new ArgumentException("The value is not of type " + type.Name + ".", "MinValue");
            }

            IComparable comparable = value as IComparable;

            if (comparable == null)
            {
                throw new InvalidOperationException("MaxValue does not implement the IComparable interface.");
            }

            object minValue = valueRangeTextBox.MinValue;

            // ValidateValueInRange will throw if it must.
            valueRangeTextBox.ValidateValueInRange(minValue, value, valueRangeTextBox.Value);

            return(value);
        }
        private void ConvertValuesToDataType(Type type)
        {
            if (type == null)
            {
                this.MinValue  = null;
                this.MaxValue  = null;
                this.NullValue = null;

                this.Value = null;

                return;
            }

            object minValue = this.MinValue;

            if ((minValue != null) && (minValue.GetType() != type))
            {
                this.MinValue = ValueRangeTextBox.ConvertValueToDataType(minValue, type);
            }

            object maxValue = this.MaxValue;

            if ((maxValue != null) && (maxValue.GetType() != type))
            {
                this.MaxValue = ValueRangeTextBox.ConvertValueToDataType(maxValue, type);
            }

            object nullValue = this.NullValue;

            if (((nullValue != null) && (nullValue != DBNull.Value)) &&
                (nullValue.GetType() != type))
            {
                this.NullValue = ValueRangeTextBox.ConvertValueToDataType(nullValue, type);
            }

            object value = this.Value;

            if (((value != null) && (value != DBNull.Value)) &&
                (value.GetType() != type))
            {
                this.Value = ValueRangeTextBox.ConvertValueToDataType(value, type);
            }
        }
        private static void NullValuePropertyChangedCallback(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            ValueRangeTextBox valueRangeTextBox = sender as ValueRangeTextBox;

            if (e.OldValue == null)
            {
                if (valueRangeTextBox.Value == null)
                {
                    valueRangeTextBox.RefreshValue();
                }
            }
            else
            {
                if (e.OldValue.Equals(valueRangeTextBox.Value))
                {
                    valueRangeTextBox.RefreshValue();
                }
            }
        }
        private static object ValueCoerceValueCallback(object sender, object value)
        {
            ValueRangeTextBox valueRangeTextBox = sender as ValueRangeTextBox;

            if (!valueRangeTextBox.IsInitialized)
            {
                return(DependencyProperty.UnsetValue);
            }

            if (valueRangeTextBox.IsFinalizingInitialization)
            {
                value = ValueRangeTextBox.ConvertValueToDataType(value, valueRangeTextBox.ValueDataType);
            }

            if (!valueRangeTextBox.IsForcingValue)
            {
                valueRangeTextBox.ValidateValue(value);
            }

            return(value);
        }
        private static object ValueDataTypeCoerceValueCallback(DependencyObject sender, object value)
        {
            ValueRangeTextBox valueRangeTextBox = sender as ValueRangeTextBox;

            if (!valueRangeTextBox.IsInitialized)
            {
                return(DependencyProperty.UnsetValue);
            }

            Type valueDataType = value as Type;

            try
            {
                valueRangeTextBox.ValidateDataType(valueDataType);
            }
            catch (Exception exception)
            {
                throw new ArgumentException("An error occured while trying to change the ValueDataType.", exception);
            }

            return(value);
        }
Esempio n. 12
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.headerBox = ((Xceed.Wpf.Toolkit.Primitives.ValueRangeTextBox)(target));

            #line 50 "..\..\createCard.xaml"
                this.headerBox.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.ChangeContentOnTb);

            #line default
            #line hidden
                return;

            case 2:
                this.contentTextBox = ((System.Windows.Controls.TextBox)(target));

            #line 62 "..\..\createCard.xaml"
                this.contentTextBox.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.ChangeContentOnTb);

            #line default
            #line hidden
                return;

            case 3:
                this.dateTime = ((Xceed.Wpf.Toolkit.DateTimePicker)(target));

            #line 79 "..\..\createCard.xaml"
                this.dateTime.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <object>(this.ChangeDateValue);

            #line default
            #line hidden
                return;

            case 4:
                this.myCard = ((MaterialDesignThemes.Wpf.Card)(target));
                return;

            case 5:
                this.cardHeader = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 6:
                this.cardContent = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 7:
                this.cardDateTime = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 8:
                this.cardAddButton = ((System.Windows.Controls.Button)(target));

            #line 115 "..\..\createCard.xaml"
                this.cardAddButton.Click += new System.Windows.RoutedEventHandler(this.ClickOnAddBtn);

            #line default
            #line hidden
                return;

            case 9:
                this.counter = ((System.Windows.Controls.TextBlock)(target));
                return;
            }
            this._contentLoaded = true;
        }