Exemplo n.º 1
0
        private static LuaWpfCreator CreateComboField(IPpsDataFieldReadOnlyProperties properties)
        {
            dynamic ui = new LuaUI();
            //dynamic combo = LuaWpfCreator.CreateFactory(ui, typeof(ComboBox));
            dynamic combo = LuaWpfCreator.CreateFactory(ui, typeof(PpsComboBox));

            combo.SelectedValue = PpsDataFieldBinding.CreateWpfBinding(properties.GetService <PpsDataFieldInfo>(true));

            return(combo);
        }         // func CreateComboField
Exemplo n.º 2
0
        private LuaWpfCreator CreateCheckField(IPpsDataFieldReadOnlyProperties properties)
        {
            dynamic ui    = new LuaUI();
            dynamic check = LuaWpfCreator.CreateFactory(ui, typeof(CheckBox));

            //check.Content = properties.displayName;
            check.IsThreeState = false;
            check.IsChecked    = PpsDataFieldBinding.CreateWpfBinding(properties.GetService <PpsDataFieldInfo>(true));

            return(check);
        }         // func CreateCheckField
Exemplo n.º 3
0
        private LuaWpfCreator CreateRelationField(IPpsDataFieldReadOnlyProperties properties, PpsDataColumnDefinition columnDefinition)
        {
            dynamic combobox = CreateSelector(properties);

            // bind items source
            if (!properties.TryGetProperty <string>("TableBindingPath", out var baseBindingPath))
            {
                baseBindingPath = properties.GetService <PpsDataSetResolver>(true).BindingPath;
            }

            var codeBase = properties.GetService <IPpsXamlCode>(true);

            dynamic itemsSourceBinding = LuaWpfCreator.CreateFactory(new LuaUI(), typeof(Binding));

            itemsSourceBinding.Path   = PpsDataFieldBinding.CombinePath(baseBindingPath, columnDefinition.ParentColumn.Table.Name);
            itemsSourceBinding.Source = codeBase;
            combobox.ItemsSource      = itemsSourceBinding;

            // bind value
            combobox.SelectedValue = PpsDataFieldBinding.CreateWpfBinding(properties.GetService <PpsDataFieldInfo>(true));

            return(combobox);
        }         // func CreateRelationField
Exemplo n.º 4
0
 private LuaWpfCreator CreateDefaultField(IPpsDataFieldReadOnlyProperties properties)
 {
     // test for creator
     if (properties.DataType == typeof(string) ||
         properties.DataType == typeof(int) ||
         properties.DataType == typeof(float) ||
         properties.DataType == typeof(double) ||
         properties.DataType == typeof(decimal) ||
         properties.DataType == typeof(DateTime))
     {
         return(CreateTextField(properties));
     }
     else if (properties.DataType == typeof(bool))
     {
         return(CreateCheckField(properties));
     }
     else if (properties.DataType == typeof(PpsMasterDataExtendedValue))
     {
         // test for master table
         if (properties.TryGetProperty <string>("refTable", out var refTable))
         {
             return(CreateMasterDataField(properties, refTable));
         }
         else
         {
             throw new ArgumentNullException("refTable", "refTable is null.");
         }
     }
     else if (properties.DataType == typeof(PpsFormattedStringValue))
     {
         return(CreateTextField(properties, true));
     }
     else
     {
         var columnDefinition = properties.GetService <PpsDataColumnDefinition>(false);
         if (columnDefinition?.IsRelationColumn ?? false)
         {
             return(CreateRelationField(properties, columnDefinition));
         }
         else
         {
             throw new NotImplementedException();
         }
     }
 }         // func CreateDefaultField
Exemplo n.º 5
0
        private LuaWpfCreator CreateMasterDataField(IPpsDataFieldReadOnlyProperties properties, string refTableName)
        {
            dynamic combobox = CreateSelector(properties);

            var table = Environment.MasterData.GetTable(refTableName, true);

            combobox.ItemsSource   = table;
            combobox.SelectedValue = PpsDataFieldBinding.CreateWpfBinding(properties.GetService <PpsDataFieldInfo>());

            if (properties.TryGetProperty("TemplateResourceKey", out var templateResource) ||
                table.Definition.Meta.TryGetProperty("Wpf.TemplateResourceKey", out templateResource))
            {
                combobox.ItemTemplate = Environment.FindResource <DataTemplate>(templateResource);

                //if (properties.TryGetProperty("SelectedValueTemplateResourceKey", out var selectedValueResourceKey)
                //	|| table.Definition.Meta.TryGetProperty("Wpf.SelectedValueTemplateResourceKey", out selectedValueResourceKey))
                //	combobox.SelectedValueTemplate = Environment.FindResource<DataTemplate>(selectedValueResourceKey);
                //else
                //	combobox.SelectedValueTemplate = combobox.ItemTemplate;
            }

            return(combobox);
        }         // func CreateMasterDataField
Exemplo n.º 6
0
        private LuaWpfCreator CreateTextField(IPpsDataFieldReadOnlyProperties properties, bool formattedText = false)
        {
            var     ui  = new LuaUI();
            dynamic txt = LuaWpfCreator.CreateFactory(ui, typeof(PpsTextBox));

            var isReadOnly = properties.TryGetProperty <bool>("IsReadOnly", out var tmpReadOnly) ? (bool?)tmpReadOnly : null;

            var textBinding = PpsDataFieldBinding.CreateWpfBinding(properties.GetService <PpsDataFieldInfo>(true), append: formattedText ? "Value" : null, isReadOnly: isReadOnly);

            var inputType    = formattedText ? PpsTextBoxInputType.MultiLine : PpsTextBoxInputType.None;
            var setMaxLength = true;

            switch (Type.GetTypeCode(properties.DataType))
            {
            case TypeCode.Decimal:
                PpsDataFieldFactory.SetNumericBinding(ui, txt, textBinding, true, 2);
                inputType    = PpsTextBoxInputType.DecimalNegative;
                setMaxLength = false;
                break;

            case TypeCode.Single:
                PpsDataFieldFactory.SetNumericBinding(ui, txt, textBinding, true, 3);
                inputType    = PpsTextBoxInputType.DecimalNegative;
                setMaxLength = false;
                break;

            case TypeCode.Double:
                PpsDataFieldFactory.SetNumericBinding(ui, txt, textBinding, true, 6);
                inputType    = PpsTextBoxInputType.DecimalNegative;
                setMaxLength = false;
                break;

            case TypeCode.SByte:
                PpsDataFieldFactory.SetNumericBinding(ui, txt, textBinding, true, 0);
                inputType = PpsTextBoxInputType.IntegerNegative;
                break;

            case TypeCode.Int16:
                PpsDataFieldFactory.SetNumericBinding(ui, txt, textBinding, true, 0);
                inputType = PpsTextBoxInputType.IntegerNegative;
                break;

            case TypeCode.Int32:
                PpsDataFieldFactory.SetNumericBinding(ui, txt, textBinding, true, 0);
                inputType = PpsTextBoxInputType.IntegerNegative;
                break;

            case TypeCode.Int64:
                PpsDataFieldFactory.SetNumericBinding(ui, txt, textBinding, true, 0);
                inputType = PpsTextBoxInputType.IntegerNegative;
                break;

            case TypeCode.Byte:
                PpsDataFieldFactory.SetNumericBinding(ui, txt, textBinding, false, 0);
                inputType = PpsTextBoxInputType.Integer;
                break;

            case TypeCode.UInt16:
                SetNumericBinding(ui, txt, textBinding, false, 0);
                inputType = PpsTextBoxInputType.Integer;
                break;

            case TypeCode.UInt32:
                PpsDataFieldFactory.SetNumericBinding(ui, txt, textBinding, false, 0);
                inputType = PpsTextBoxInputType.Integer;
                break;

            case TypeCode.UInt64:
                PpsDataFieldFactory.SetNumericBinding(ui, txt, textBinding, false, 0);
                inputType = PpsTextBoxInputType.Integer;
                break;

            case TypeCode.DateTime:
                if (inputType != PpsTextBoxInputType.Date &&
                    inputType != PpsTextBoxInputType.Time)
                {
                    inputType = PpsTextBoxInputType.Date;
                }

                if (inputType == PpsTextBoxInputType.Date)                         // we can set a binding converter
                {
                    PpsDataFieldFactory.SetDateBinding(ui, txt, textBinding, false, 0);
                }
                break;
            }

            if (properties.TryGetProperty <PpsTextBoxInputType>("InputType", out var tmpInputType))
            {
                inputType = tmpInputType;
            }

            txt.InputType = inputType;
            txt.Text      = textBinding;

            SetTextFieldProperties((object)txt, properties);

            if (setMaxLength && properties.TryGetProperty <int>("MaxLength", out var maxInputLength))
            {
                txt.MaxLength = maxInputLength;
            }

            if (properties.TryGetProperty <bool>("Nullable", out var tmpNullable))
            {
                txt.IsNullable = tmpNullable;
            }

            if (isReadOnly.HasValue)
            {
                txt.IsReadOnly = isReadOnly;
            }

            if (formattedText)
            {
                txt.FormattedValue = PpsDataFieldBinding.CreateWpfBinding(properties.GetService <PpsDataFieldInfo>(true), append: "FormattedValue", isReadOnly: true);
            }

            return(txt);
        }         // func CreateTextField
Exemplo n.º 7
0
 private LuaWpfCreator CreateFieldBinding(IPpsDataFieldReadOnlyProperties properties, bool?isReadOnly = null, string append = null)
 => PpsDataFieldBinding.CreateWpfBinding(properties.GetService <PpsDataFieldInfo>(true), isReadOnly, append);