Exemplo n.º 1
0
        /// <summary>
        /// CheckAndAssign
        /// </summary>
        /// <param name="dataFieldCheckBox"></param>
        /// <param name="sourceNew"></param>
        /// <param name="path"></param>
        private static void CheckAndAssign(DataFieldCheckBox dataFieldCheckBox, object sourceNew, string path)
        {
            Contract.Requires((dataFieldCheckBox != null) &&
                              (sourceNew != null) &&
                              !string.IsNullOrEmpty(path));


            var propValue = ComponentUtils.GetPropValue(sourceNew, path);
            int value     = 0;

            if (propValue != null)
            {
                if (propValue is string)
                {
                    value = int.Parse(propValue as string);
                    dataFieldCheckBox.IsChecked = value != 0;
                }

                if (propValue is bool)
                {
                    dataFieldCheckBox.IsChecked = (bool)propValue;
                }
                if (propValue is byte)
                {
                    value = Convert.ToByte(propValue);
                    dataFieldCheckBox.IsChecked = value != 0;
                }
                if (propValue.GetType().IsAssignableFrom(typeof(int)))
                {
                    // here we have a tinyint.
                    value = Convert.ToInt32(propValue);
                    dataFieldCheckBox.IsChecked = value != 0;
                }
            }
        }
Exemplo n.º 2
0
        private static void CheckBox_DataUnChecked(object sender, RoutedEventArgs e)
        {
            DataFieldCheckBox dataFieldCheckBox = sender as DataFieldCheckBox;
            var path = ControlExt.GetDataSourcePath(dataFieldCheckBox);

            if (path != null)
            {
                var tmp = ControlExt.GetDataSource(dataFieldCheckBox);
                if (tmp is bool)
                {
                    ControlExt.SetDataSource(dataFieldCheckBox, false);
                    EnforceDoChange(dataFieldCheckBox, path, 0);
                }
            }
        }
Exemplo n.º 3
0
        private void OnUnchecked(object sender, RoutedEventArgs routedEventArgs)
        {
            DataFieldCheckBox checkBox = sender as DataFieldCheckBox;

            if (checkBox != null)
            {
                if (checkBox.IsChecked != null)
                {
                    _isChecked = checkBox.IsChecked.Value;
                }
                times = 1;
                if (times > 0)
                {
                    if (_previous.Value != _isChecked.Value)
                    {
                        SendEventOnChanged();
                    }
                }

                _previous = _isChecked;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        ///  This is a property changed util.
        /// </summary>
        /// <param name="dependencyObject"></param>
        /// <param name="eventArgs"></param>
        public static void PropertyChangedCb(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs eventArgs)
        {
            // dry : the change is handled by the PasswordBox properties as well.
            if (dependencyObject is PasswordBox)
            {
                return;
            }
            if (dependencyObject is PercentTextBox)
            {
                PercentTextBox box = dependencyObject as PercentTextBox;
                box.LostFocus += Box_LostFocus1;
                return;
            }
            if (dependencyObject is SfDataGrid currentDataGrid)
            {
                //  currentDataGrid.CurrentCellEndEdit += CurrentDataGrid_CurrentCellEndEdit;
                currentDataGrid.RecordDeleted       += CurrentDataGrid_RecordDeleted;
                currentDataGrid.AddNewRowInitiating += CurrentDataGrid_AddNewRowInitiating;

                currentDataGrid.RowValidated   += CurrentDataGrid_RowValidated;
                currentDataGrid.PreviewKeyDown += CurrentDataGrid_PreviewKeyDown;
            }
            if (dependencyObject is DataArea)
            {
                var dataArea = dependencyObject as DataArea;
                dataArea.ItemChangedCommand = GetItemChangedCommand(dataArea);
                dataArea.DataSource         = GetDataSource(dataArea);
                dataArea.DataSourcePath     = GetDataSourcePath(dataArea);
                return;
            }
            if (dependencyObject is SfTimePicker)
            {
                SfTimePicker picker = dependencyObject as SfTimePicker;
                picker.ValueChanged += Picker_ValueChanged;
            }
            if (dependencyObject is DatePicker datePicker)
            {
                datePicker.SelectedDateChanged += SelectedDate_Changed;
            }
            if (dependencyObject is DataDatePicker)
            {
                DataDatePicker dataDatePicker = dependencyObject as DataDatePicker;
                dataDatePicker.DataDatePickerChanged += DataDatePicker_DataDatePickerChanged;
                return;
            }

            if (dependencyObject is TextBox)
            {
                TextBox box = dependencyObject as TextBox;
                box.TextChanged += TextBox_ChangedBehaviour;
                box.LostFocus   += Box_LostFocus;
                return;
            }
            if (dependencyObject is DataFieldCheckBox)
            {
                DataFieldCheckBox checkBox = dependencyObject as DataFieldCheckBox;
                var path = ControlExt.GetDataSourcePath(checkBox);
                if (!string.IsNullOrEmpty(path))
                {
                    var tmp = ControlExt.GetDataSource(checkBox);
                    if (tmp != null)
                    {
                        var propValue = ComponentUtils.GetPropValue(tmp, path);
                        if (propValue is string)
                        {
                            byte value = Convert.ToByte(propValue);
                            if (value > 0)
                            {
                                checkBox.IsChecked = true;
                            }
                        }
                        else
                        {
                            checkBox.IsChecked = Convert.ToBoolean(propValue);
                        }
                    }
                }
                //checkBox.Checked += CheckBox_DataChecked;
                // checkBox.Unchecked += CheckBox_DataUnChecked;
                checkBox.DataFieldCheckBoxChanged += CheckBox_DataFieldCheckBoxChanged;
                return;
            }
            if (dependencyObject is CheckBox checkBox1)
            {
                checkBox1.Checked   += CheckBox_Checked;
                checkBox1.Unchecked += CheckBox_Unchecked;
                checkBox1.Click     += checkBox_Clicked;
                return;
            }
            if (dependencyObject is ComboBox comboBox)
            {
                // here we do the combox box.
                comboBox.SelectionChanged += ComboBox_SelectionChanged;
            }
        }