예제 #1
0
        static void MaskPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            MaskBox box = (MaskBox)d;

            if (box._isLoaded)
            {
                box._maskManager.Initialize();
            }
        }
예제 #2
0
        static object CoerceValue(DependencyObject d, object p_newValue)
        {
            MaskBox box = (MaskBox)d;

            if (box._isLoaded)
            {
                box._maskManager.SetInitialEditValue(p_newValue);
            }
            return(p_newValue);
        }
예제 #3
0
        static void OnMaskTypeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            MaskBox  box = (MaskBox)d;
            MaskType mt  = (MaskType)e.NewValue;

            if (mt == MaskType.DateTime || mt == MaskType.DateTimeAdvancingCaret || mt == MaskType.Numeric)
            {
                box._tb.InputScope = CreateNumberScope();
            }
            else
            {
                box._tb.InputScope = CreateAlphaScope();
            }
            if (box._isLoaded)
            {
                box._maskManager.Initialize();
            }
        }
예제 #4
0
 /// <summary>
 /// 构造方法
 /// </summary>
 /// <param name="p_maskBox">编辑器</param>
 public MaskMediator(MaskBox p_maskBox)
 {
     _owner            = p_maskBox;
     _updateTextLocker = new Locker();
 }
예제 #5
0
 /// <summary>
 /// 构造方法
 /// </summary>
 /// <param name="p_maskBox">编辑器</param>
 public MaskBoxInput(MaskBox p_maskBox)
 {
     _owner = p_maskBox;
 }
예제 #6
0
        static void ValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            MaskBox box = (MaskBox)d;

            box.RaiseValueChanged();
        }
예제 #7
0
        void LoadContent()
        {
            if (_panel == null)
            {
                return;
            }

            _panel.Child = null;
            _grid        = new Grid();
            if (Kit.IsPhoneUI || AlwaysTouchPicker)
            {
                // 触摸模式
                _grid.Background = Res.TransparentBrush;
                TextBlock tb = new TextBlock {
                    Margin = new Thickness(10, 0, 10, 0), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Center
                };
                var bind = new Binding
                {
                    Path      = new PropertyPath("Value"),
                    Converter = new DateValUIConverter(this),
                    Source    = this
                };
                tb.SetBinding(TextBlock.TextProperty, bind);
                _grid.Children.Add(tb);

                if (_format == DateFormatType.Date)
                {
                    _grid.Tapped += OnDateFly;
                }
                else if (_format == DateFormatType.Time)
                {
                    _grid.Tapped += OnTimeFly;
                }
                else
                {
                    _grid.Tapped += OnDateTimeFly;
                }
            }
            else
            {
                // 非触摸模式
                MaskBox box = new MaskBox {
                    MaskType = MaskType.DateTimeAdvancingCaret, AllowNullInput = true, UseAsDisplayFormat = true
                };
                var bind = new Binding
                {
                    Path   = new PropertyPath("Format"),
                    Source = this
                };
                box.SetBinding(MaskBox.MaskProperty, bind);
                bind = new Binding
                {
                    Path      = new PropertyPath("Value"),
                    Mode      = BindingMode.TwoWay,
                    Converter = new ValMaskConverter(),
                    Source    = this
                };
                box.SetBinding(MaskBox.ValueProperty, bind);
                _grid.Children.Add(box);

                if (_format != DateFormatType.Time)
                {
                    _grid.ColumnDefinitions.Add(new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    });
                    _grid.ColumnDefinitions.Add(new ColumnDefinition {
                        Width = new GridLength(0, GridUnitType.Auto)
                    });

                    Button btn = new Button {
                        Style = Res.字符按钮, Content = "\uE047"
                    };
                    Grid.SetColumn(btn, 1);
                    btn.Click += OnShowCalendar;
                    _grid.Children.Add(btn);
                }
            }
            _panel.Child = _grid;
        }
예제 #8
0
파일: CMask.cs 프로젝트: Daoting/dt
 public CMask()
 {
     DefaultStyleKey = typeof(CMask);
     _box            = new MaskBox();
 }