Exemplo n.º 1
0
        static void MaskPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            MaskBox box = (MaskBox)d;

            if (box._isLoaded)
            {
                box._maskManager.Initialize();
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 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();
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// 构造方法
 /// </summary>
 /// <param name="p_maskBox">编辑器</param>
 public MaskMediator(MaskBox p_maskBox)
 {
     _owner            = p_maskBox;
     _updateTextLocker = new Locker();
 }
Exemplo n.º 5
0
 /// <summary>
 /// 构造方法
 /// </summary>
 /// <param name="p_maskBox">编辑器</param>
 public MaskBoxInput(MaskBox p_maskBox)
 {
     _owner = p_maskBox;
 }
Exemplo n.º 6
0
        static void ValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            MaskBox box = (MaskBox)d;

            box.RaiseValueChanged();
        }
Exemplo n.º 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;
        }
Exemplo n.º 8
0
Arquivo: CMask.cs Projeto: Daoting/dt
 public CMask()
 {
     DefaultStyleKey = typeof(CMask);
     _box            = new MaskBox();
 }