private void createNewIntListRow(PropertyInfo prop, int row, PropertyFieldAttribute attr) { if (!uiElementMap.ContainsKey(prop.Name)) { gridAddRowDef(); MultTextBox mutb = new MultTextBox(); mutb.Margin = new Thickness(0, 2, 2, 0); mutb.BorderThickness = new Thickness(0); mutb.VerticalAlignment = VerticalAlignment.Stretch; mutb.titleName.Text = CONST_STRING.GetTitleText(prop.ReflectedType, prop.Name); Grid.SetColumn(mutb, 0); Grid.SetColumnSpan(mutb, 2); mutb.HorizontalAlignment = HorizontalAlignment.Stretch; Grid.SetRow(mutb, _panelParent.RowDefinitions.Count - 1); mutb.SelectObject = _selectedObject; mutb.inputPropertyInfo = prop; _panelParent.Children.Add(mutb); _panelParent.RowDefinitions[_panelParent.RowDefinitions.Count - 1].Height = new GridLength(mutb.TotalHeight); mutb.EnterComplete += Mutb_EnterComplete; uiElementMap[prop.Name] = mutb; gridAddEnd(); } }
private void createTableRow(PropertyInfo prop, int row, PropertyFieldAttribute attr) { if (!uiElementMap.ContainsKey(prop.Name)) { gridAddRowDef(); var ed = createDropDownBox(row); ed.Title = CONST_STRING.GetTitleText(prop.ReflectedType, prop.Name); ed.AllowDrop = true; ed.Tag = prop; ed.SelectText = prop.GetValue(_selectedObject).ToString(); ed.PreviewKeyUp += dropDown_PreviewKeyUp; //ed.ItemSource = TableManager.GetNodeList(attr.Param.ToString()); ed.DorpDownEvent += dropDown_DorpDownEvent; ed.DropDownSelected += dropDown_DropDownSelected; ed.PreviewDragOver += new DragEventHandler((object sender, DragEventArgs e) => { table_dragOver(attr, sender, e); }); ed.PreviewDragLeave += control_PreviewDragLeave; ed.PreviewDrop += new DragEventHandler((object sender, DragEventArgs e) => { table_PreviewDrop(sender, e.Data.GetData(typeof(string)).ToString(), attr.Param.ToString()); }); uiElementMap[prop.Name] = ed; gridAddEnd(); } }
private void createControl() { TotalHeight = 30; _grid.Children.Clear(); _grid.RowDefinitions.Clear(); _grid.ColumnDefinitions.Clear(); Type contentType = getListContentType(inputPropertyInfo.PropertyType); List <PropertyInfo> properties = new List <PropertyInfo>(); properties.AddRange(contentType.GetProperties()); var col = new ColumnDefinition(); col.Width = new GridLength(20); _grid.ColumnDefinitions.Add(col); for (int i = 0; i < properties.Count; i++) { var attr = properties[i].GetCustomAttributes(typeof(PropertyFieldAttribute), false); if (attr.Length == 0) { continue; } col = new ColumnDefinition(); col.Width = new GridLength(80); _grid.ColumnDefinitions.Add(col); _grid.ColumnDefinitions.Add(new ColumnDefinition()); } newLine(VerticalAlignment.Top, 5, 0); for (int n = 0; n < _number; n++) { var rowDef = new RowDefinition(); rowDef.Height = new GridLength(Math.Max(20, this.FontSize * 2)); _grid.RowDefinitions.Add(rowDef); object src = null; if (objectList.Count > n) { src = objectList[n]; } else { src = Activator.CreateInstance(contentType); } for (int i = 0; i < properties.Count; i++) { string name = CONST_STRING.GetTitleText(contentType, properties[i].Name); newTextBlock(name, i); newTextbox(i, properties[i], src, n); newLine(VerticalAlignment.Bottom, 4, 1); } TotalHeight += 30; } }
private void gridAddTitle(PropertyInfo prop) { TextBlock tb = null; if (uiElementMap.ContainsKey(prop.Name)) { tb = uiElementMap[prop.Name] as TextBlock; tb.Text = CONST_STRING.GetTitleText(prop.ReflectedType, prop.Name); } else { tb = new TextBlock() { Text = CONST_STRING.GetTitleText(prop.ReflectedType, prop.Name) }; tb.Foreground = new SolidColorBrush(Colors.White); tb.Margin = new Thickness(4); Grid.SetColumn(tb, 0); Grid.SetRow(tb, _panelParent.RowDefinitions.Count - 1); _panelParent.Children.Add(tb); uiElementMap[prop.Name] = tb; } }