Beispiel #1
0
 private List<DataFieldItem> GetFieldItems(List<string[]> ItemInfo)
 {
     List<DataFieldItem> items = new List<DataFieldItem>();
     for (int i = 0; i < ItemInfo.Count; i++)
     {
         DataFieldItem df = new DataFieldItem();
         df.PropertyDisplayName = ItemInfo[i][0];
         df.PropertyName = ItemInfo[i][1];
         df.ValueMember = ItemInfo[i][2];
         df.CType = (DataFieldItem.ControlType)(int.Parse(ItemInfo[i][3]));
         df.Requited = Convert.ToBoolean(int.Parse(ItemInfo[i][4]));
         items.Add(df);
     }
     return items;
 }
Beispiel #2
0
        private static DataPanelInfo GetDataPanel(XElement xe)
        {
            DataPanelInfo p = new DataPanelInfo();

            if (xe.Elements("DataFieldItem") == null)
            {
                return(p);
            }
            foreach (XElement item in xe.Elements("DataFieldItem"))
            {
                DataFieldItem dfItem = new DataFieldItem();
                SetValue(dfItem, item);
                dfItem.Order = XMLHelper.RuntimeOrder;
                //dfItem.CType = (ControlType)int.Parse(item.Attribute("CType").Value);
                //dfItem.Name = item.Attribute("Name").Value;
                //dfItem.PropertyDisplayName = item.Attribute("PropertyDisplayName").Value;
                //dfItem.Requited = Convert.ToBoolean(int.Parse(item.Attribute("Requited").Value));
                //dfItem.PropertyName = item.Attribute("PropertyName").Value;

                XElement xeISource = item.Element("ReferencedData");

                if (xeISource != null)
                {
                    ReferencedDataInfo r = new ReferencedDataInfo();
                    SetValue(r, xeISource);

                    string rType         = xeISource.Attribute("Type").Value;
                    string rDefaultValue = GetValue(xeISource, "DefaultValue");
                    r.ReferencedName = dfItem.PropertyName;
                    XMLHelper.RuntimeOrder.RegisterReferenceData(r);
                    dfItem.ReferenceDataInfo = r;
                    r.Parameters             = GetParameters(xeISource);
                }


                p.Items.Add(dfItem);
            }
            return(p);
        }
Beispiel #3
0
        private void ShowSampleData()
        {
            List<string[]> FInfo = new List<string[]>();
            FInfo.Add(new string[] { "字段1", "OrderCode", "OrderCode", "1" });
            FInfo.Add(new string[] { "字段2", "OrderStates", "OrderStates", "1" });
            FInfo.Add(new string[] { "字段3", "CreateUser", "CreateUser", "1" });
            FInfo.Add(new string[] { "字段4", "CreateDate", "CreateDate", "1" });

            for (int i = 0; i < FInfo.Count; i++)
            {
                DataFieldItem df = new DataFieldItem();
                df.PropertyDisplayName = FInfo[i][0];
                df.Name = FInfo[i][1];
                df.PropertyName = FInfo[i][2];
                df.CType = (ControlType)(int.Parse(FInfo[i][3]));
                Items.Add(df);
            }
            this.InitForm();
        }
Beispiel #4
0
        private GridLength GetRowHeight(DataFieldItem dfItem)
        {
            ControlType cType = dfItem.CType;

            switch (cType)
            {
                case ControlType.Label:
                case ControlType.TextBox:
                case ControlType.Combobox:
                case ControlType.LookUp:
                    return new GridLength(30);
                case ControlType.Remark:
                    return new GridLength(30, GridUnitType.Auto);
                default:
                    return new GridLength(30);
            }
        }
Beispiel #5
0
        private FrameworkElement CreateControl(DataFieldItem dfItem)
        {
            ControlType cType = dfItem.CType;
            Binding binding = new Binding();
            binding.Path = new PropertyPath(dfItem.PropertyName);
            binding.Mode = BindingMode.TwoWay;
            binding.Converter = new CommonConvert(dfItem);
            
            FrameworkElement c = null;
            switch (cType)
            {
                case ControlType.Label:
                    TextBlock tbx = new TextBlock();
                    
                    if (dfItem.ReferenceDataInfo != null)
                    {
                        binding.Path = new PropertyPath(dfItem.ReferenceDataInfo.ReferencedMember + ".Text");
                    }
                    tbx.SetBinding(TextBlock.TextProperty, binding);
                    
                    c = tbx;
                    break;
                case ControlType.TextBox:
                    TextBox tb = new TextBox();
                    tb.SetBinding(TextBox.TextProperty, binding);
                    tb.IsReadOnly = (IsReadOnly || dfItem.IsReadOnly);
                    tb.MaxLength = dfItem.MaxLength;
                    if ( dfItem.DataType.ToLower() == "decimal" || dfItem.DataType.ToLower() == "datetime")
                    {
                        tb.TextAlignment = TextAlignment.Right;
                    }
                    c = tb;
                    break;
                case ControlType.Combobox:

                    ComboBox cbb = new ComboBox();

                    if (dfItem.ReferenceDataInfo != null)
                    {
                        cbb.ItemsSource = this.GetItemSource(dfItem.ReferenceDataInfo.Type);
                        cbb.DisplayMemberPath = "Text";
                        binding.Path = new PropertyPath(dfItem.ReferenceDataInfo.ReferencedMember);
                    }

                    cbb.SetBinding(ComboBox.SelectedItemProperty, binding);
                    cbb.IsEnabled = !(IsReadOnly || dfItem.IsReadOnly);
                   
                    c = cbb;
                    
                    break;
                case ControlType.LookUp:
                    FBLookUp lookUp = new FBLookUp();
                    lookUp.OperationType = this.OperationType;
                    lookUp.DisplayMemberPath = dfItem.PropertyName;
                    if (dfItem.ReferenceDataInfo != null)
                    {
                        lookUp.DisplayMemberPath = dfItem.ReferenceDataInfo.ReferencedMember + ".Text";
                        if (!string.IsNullOrEmpty(dfItem.ReferenceDataInfo.TextPath))
                        {
                            lookUp.DisplayMemberPath = dfItem.ReferenceDataInfo.TextPath;
                        }
                        lookUp.LookUpType = dfItem.ReferenceDataInfo.Type;
                        binding.Path = new PropertyPath(dfItem.ReferenceDataInfo.ReferencedMember);
                    }
                    lookUp.SetBinding(LookUp.SelectItemProperty, binding);
                    lookUp.ReferencedDataInfo = dfItem.ReferenceDataInfo;
                    lookUp.Parameters = dfItem.ReferenceDataInfo.Parameters;
                    lookUp.IsReadOnly = (IsReadOnly || dfItem.IsReadOnly);
                    c = lookUp;
                    break;
                case ControlType.Remark:
                    TextBox tbRemark = new TextBox();
                    tbRemark.AcceptsReturn = true;
                    tbRemark.TextWrapping = TextWrapping.Wrap;
                    //tbRemark.Height = 66;
                    //tbRemark.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;
                    //tbRemark.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
                    tbRemark.SetBinding(TextBox.TextProperty, binding);
                    c = tbRemark;

                    tbRemark.IsReadOnly = (IsReadOnly || dfItem.IsReadOnly);

                    tbRemark.MaxLength = dfItem.MaxLength;
                    
                    break;
                case ControlType.DatePicker:
                    DatePicker datePicker = new DatePicker();
                    datePicker.SelectedDateFormat = DatePickerFormat.Short;
                    datePicker.SetBinding(DatePicker.SelectedDateProperty, binding);                    
                    c = datePicker;
                    datePicker.IsEnabled = !(IsReadOnly || dfItem.IsReadOnly);
                    break;
                case ControlType.DateTimePicker:
                    DateTimePicker dateTimePicker = new DateTimePicker();
                    dateTimePicker.SetBinding(DateTimePicker.ValueProperty, binding);
                    c = dateTimePicker;
                    dateTimePicker.IsEnabled = !(IsReadOnly || dfItem.IsReadOnly);
                    break;
                // Add By LVCHAO 2011.01.30 14:46
                case ControlType.HyperlinkButton:
                    HyperlinkButton hb = new HyperlinkButton();
                    if (dfItem.ReferenceDataInfo != null)
                    {
                        binding.Path = new PropertyPath(dfItem.ReferenceDataInfo.ReferencedMember + ".Text");
                    }
                    hb.Click += (o, e) =>
                        {
                            var sourceOjb = hb.DataContext.GetObjValue(dfItem.ReferenceDataInfo.ReferencedMember + ".Value");
                            CommonFunction.ShowExtendForm(sourceOjb);
                        };
                    hb.SetBinding(HyperlinkButton.ContentProperty, binding);
                    c = hb;
                    break;
            }
            return c;

        }
Beispiel #6
0
        private static DataPanelInfo GetDataPanel(XElement xe)
        {
            DataPanelInfo p = new DataPanelInfo();
            if (xe.Elements("DataFieldItem") == null)
            {
                return p;
            }
            foreach (XElement item in xe.Elements("DataFieldItem"))
            {
                DataFieldItem dfItem = new DataFieldItem();
                SetValue(dfItem, item);
                dfItem.Order = XMLHelper.RuntimeOrder;
                //dfItem.CType = (ControlType)int.Parse(item.Attribute("CType").Value);
                //dfItem.Name = item.Attribute("Name").Value;
                //dfItem.PropertyDisplayName = item.Attribute("PropertyDisplayName").Value;
                //dfItem.Requited = Convert.ToBoolean(int.Parse(item.Attribute("Requited").Value));
                //dfItem.PropertyName = item.Attribute("PropertyName").Value;

                XElement xeISource = item.Element("ReferencedData");

                if (xeISource != null)
                {
                    ReferencedDataInfo r = new ReferencedDataInfo();
                    SetValue(r, xeISource);

                    string rType = xeISource.Attribute("Type").Value;
                    string rDefaultValue = GetValue(xeISource, "DefaultValue");
                    r.ReferencedName = dfItem.PropertyName;
                    XMLHelper.RuntimeOrder.RegisterReferenceData(r);
                    dfItem.ReferenceDataInfo = r;
                    r.Parameters = GetParameters(xeISource);
                }

                
                p.Items.Add(dfItem);

            }
            return p;
        }