Exemplo n.º 1
0
        private static void DataDatePicker_DataDatePickerChanged(object sender, RoutedEventArgs e)
        {
            DataDatePicker.DataDatePickerEventArgs args = (DataDatePicker.DataDatePickerEventArgs)e;
            DataDatePicker picker = sender as DataDatePicker;

            if (picker != null)
            {
                ICommand changedCommand             = picker.GetValue(ItemChangedCommandProperty) as ICommand;
                IDictionary <string, object> evArgs = args.ChangedValuesObjects;
                if (changedCommand != null)
                {
                    changedCommand.Execute(evArgs);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// CheckAndAssignDate
        /// </summary>
        /// <param name="dataDatePicker">DataDatePicker component</param>
        /// <param name="sourceNew">Object to be assigned</param>
        /// <param name="path">Path of the date</param>
        private static void CheckAndAssignDate(DataDatePicker dataDatePicker, object sourceNew, string path)
        {
            Contract.Requires((dataDatePicker != null) &&
                              (sourceNew != null) &&
                              !string.IsNullOrEmpty(path));

            if ((dataDatePicker == null) ||
                (sourceNew == null) ||
                (string.IsNullOrEmpty(path)))
            {
                return;
            }
            var propValue = ComponentUtils.GetPropValue(sourceNew, path);

            if (propValue == null)
            {
                var otherPath = "Value." + path;
                propValue = ComponentUtils.GetPropValue(sourceNew, otherPath);
            }
            if (propValue != null)
            {
                DateTime timeValue = DateTime.Now;
                if (propValue is string)
                {
                    try
                    {
                        timeValue = DateTime.Parse(propValue as string);
                    }
                    // this is wanted. We need to provide a default.
#pragma warning disable 0168
                    catch (Exception e)
                    {
#pragma warning restore 0168
                        timeValue = DateTime.Now;
                    }
                }
                else
                {
                    timeValue = (DateTime)propValue;
                }
                dataDatePicker.DateContent = timeValue;
            }
        }
Exemplo n.º 3
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;
            }
        }