Beispiel #1
0
        protected override void SetBindingContext()
        {
            typePicker = ControlFactory.CreatePicker();
            typePicker.SelectedIndexChanged += TypePicker_SelectedIndexChanged;
            typePicker.SelectedItemChanged  += Picker_SelectedItemChanged;

            projectPicker = ControlFactory.CreatePicker();
            projectPicker.HorizontalOptions    = LayoutOptions.FillAndExpand;
            projectPicker.SelectedItemChanged += Picker_SelectedItemChanged;

            // Create a filter for showing projects only if the time entry can be edited.
            if (this.ViewModel.CanEdit())
            {
                filterIcon = ControlFactory.CreateIcon(LabelHandler.FILTER_SYMBOL, ControlFactory.Small_Label_Icon);
            }

            projectTaskPicker = ControlFactory.CreatePicker();
            projectTaskPicker.HorizontalOptions    = LayoutOptions.FillAndExpand;
            projectTaskPicker.SelectedItemChanged += Picker_SelectedItemChanged;

            transactionDatePicker = ControlFactory.CreateDatePicker("Time.msdyn_date_utc", DateTime.MaxValue, "D");

            // Use a one-way binding from view model to view because of the custom formatting that we have. We want the user to be able to type anything in the text box
            // but on losing focus from the field, we validate and store the duration in the view model.
            durationEntry            = ControlFactory.CreateEntry("Time.msdyn_duration", BindingMode.OneWay, Keyboard.Default, null, "", new DurationTo24HourStringConverter());
            durationEntry.Unfocused += DurationEntry_Unfocused;

            internalDescriptionEditor              = ControlFactory.CreateEditor("Time.msdyn_description");
            internalDescriptionEditor.TextChanged += this.createEditorTextChangedHandler(msdyn_timeentry.DescriptionLength);
            externalDescriptionEditor              = ControlFactory.CreateEditor("Time.msdyn_externalDescription");
            externalDescriptionEditor.TextChanged += this.createEditorTextChangedHandler(msdyn_timeentry.DescriptionLength);

            this.BindingContext = ViewModel;
        }
        protected override void OnElementChanged(ElementChangedEventArgs <DatePicker> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null)
            {
                var toolbar = (UIToolbar)Control.InputAccessoryView;
                if (toolbar != null && toolbar.Items.Length > 1)
                {
                    _datePicker = null;
                    var doneBtn = toolbar.Items[1];
                    doneBtn.Clicked -= OnDoneClicked;
                }
            }

            if (e.NewElement != null)
            {
                _datePicker = this.Element as DatePickerEx;
                var toolbar = (UIToolbar)Control.InputAccessoryView;
                if (toolbar != null && toolbar.Items.Length > 1)
                {
                    var doneBtn = toolbar.Items[1];
                    doneBtn.Clicked += OnDoneClicked;
                }
            }
        }
Beispiel #3
0
        protected override void SetBindingContext()
        {
            projectPicker                  = ControlFactory.CreatePicker(null, ViewModel.OnProjectSelected);
            categoryPicker                 = ControlFactory.CreatePicker(null, ViewModel.OnCategorySelected);
            currencyPicker                 = ControlFactory.CreatePicker(null, ViewModel.OnCurrencySelected);
            transactionDatePicker          = ControlFactory.CreateDatePicker("Expense.msdyn_TransactionDate_utc", DateTime.Today, "D");
            descriptionEditor              = ControlFactory.CreateEditor("Expense.msdyn_name");
            descriptionEditor.TextChanged += this.createEditorTextChangedHandler(msdyn_timeentry.DescriptionLength);

            amountEntry          = ControlFactory.CreateEntry("Expense.TransactionAmount", BindingMode.TwoWay, Keyboard.Numeric, "{0:N2}", String.Format("{0:N2}", 0));
            amountEntry.Focused += (s, e) =>
            {
                if (amountEntry.Text.Equals("0.00") || amountEntry.Text.Equals("0"))
                {
                    amountEntry.Text = String.Empty;
                }
            };

            salesTaxEntry          = ControlFactory.CreateEntry("Expense.SalesTaxAmount", BindingMode.TwoWay, Keyboard.Numeric, "{0:N2}", String.Format("{0:N2}", 0));
            salesTaxEntry.Focused += (s, e) =>
            {
                if (salesTaxEntry.Text.Equals("0.00") || salesTaxEntry.Text.Equals("0"))
                {
                    salesTaxEntry.Text = String.Empty;
                }
            };
            this.BindingContext = ViewModel;
        }
        /// <summary>
        /// Creates DatePickerEx with given binding path, maximumDate and format
        /// </summary>
        /// <param name="path"></param>
        /// <param name="maximumDate"></param>
        /// <param name="format"></param>
        /// <returns></returns>
        public static DatePickerEx CreateDatePicker(string path, DateTime maximumDate, string format = null)
        {
            DatePickerEx datePicker = new DatePickerEx
            {
                MaximumDate = maximumDate,
                Format      = format
            };

            datePicker.SetBinding(DatePickerEx.DateProperty, path);
            return(datePicker);
        }
        public MaskedDatePicker()
        {
            InitializeComponent();

            _datePicker = Helpers.VisualTreeHelper.GetTemplateChild <DatePickerEx>(this, "_dtPicker");
            _button     = Helpers.VisualTreeHelper.GetTemplateChild <ButtonEx>(this, "_btnDtPicker");

            if (_datePicker != null)
            {
                _datePicker.OKClicked += (s, e) => { FireOkClicked(e); };
            }

            HandleButtonClick = new Command(() => _datePicker?.Focus());
        }
Beispiel #6
0
 /// <summary>
 /// Initializes a new instance of the
 /// <see cref="T:System.Windows.Automation.Peers.DatePickerAutomationPeer" />
 /// class.
 /// </summary>
 /// <param name="owner">
 /// The <see cref="T:System.Windows.Controls.DatePicker" /> to associate
 /// with the
 /// <see cref="T:System.Windows.Automation.Peers.DatePickerAutomationPeer" />.
 /// </param>
 public DatePickerExAutomationPeer(DatePickerEx owner)
     : base(owner)
 {
 }
 public DatePickerDialogEx(DatePickerEx picker, Context context, IOnDateSetListener callBack, int year,
                           int monthOfYear, int dayOfMonth)
     : base(context, callBack, year, monthOfYear, dayOfMonth)
 {
     _datePicker = picker;
 }