Example #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;
        }
Example #2
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;
        }
        public static EditorEx CreateEditor(string path)
        {
            EditorEx editor = new EditorEx();

            editor.SetBinding(EditorEx.TextProperty, path);
            return(editor);
        }
Example #4
0
    public static void OpenDNACreationWindow()
    {
        //show prompt.
        DNACreationWindow window = ScriptableObject.CreateInstance <DNACreationWindow>();

        window.position = new Rect(0, 0, 200, 100);
        EditorEx.CenterOnMainWin(window);

        window.ShowPopup();
    }
Example #5
0
        private EventHandler <TextChangedEventArgs> createEditorTextChangedHandler(int allowedTextSize)
        {
            return((object sender, TextChangedEventArgs e) =>
            {
                EditorEx editor = sender as EditorEx;

                if (e.OldTextValue == null && this.ViewModel.HasPendingDataToSave)
                {
                    this.ViewModel.HasPendingDataToSave = false;
                }

                if (e.NewTextValue.Length > allowedTextSize)
                {
                    editor.Text = e.NewTextValue.Substring(0, allowedTextSize);

                    // Let user know you've truncated the text.
                    MessageCenter.ShowMessage(string.Format(AppResources.TextSizeLimitedTo, allowedTextSize)).DoNotAwait();
                }

                editor.InvalidateLayout();
            });
        }