void addItemTextBox(int address, int index, Node node) { List <string> items = node.Extra.Split('_').ToList(); //判断何时用下拉框 bool useCbox = (node.NodeAuthority != Authority.R) && ((node.ShowType == 1 && node.Extra.Contains('_')) || node.ShowType == 2); Control box = useCbox ? new ComboBox() as Control : new TextBox() as Control; box.Name = "Box" + address; box.Tag = node; if (useCbox) { AutoBox.setBoxItems(box as ComboBox); } //取值0.8*,使行间留白,上下各留白0.1*,如下Margin.Top box.Height = 0.8 * rowHeight; box.VerticalContentAlignment = VerticalAlignment.Center; box.HorizontalContentAlignment = HorizontalAlignment.Center; box.VerticalAlignment = VerticalAlignment.Top; box.Margin = new Thickness(0, index / 5 * rowHeight + 0.1 * rowHeight, 10, 0); Grid.SetColumn(box, index % 5 * 3 + 1); Grid.SetColumnSpan(box, 2); grid_content.Children.Add(box); if (node.ShowType == 3 || node.ShowType == 11 || node.ShowType == 13) { box.MouseDoubleClick += tbox_MouseDoubleClick; box.BorderBrush = Tools.GetBrush("#FFFF6501"); box.BorderThickness = new Thickness(2); } if (node.NodeAuthority != Authority.R) { box.GotFocus += tbox_GotFocus; } }
public void executeInfluence(Panel parent, int nResult, string strResult) { nResult = InfBitType < 0 ? nResult : Tools.GetBit(nResult, InfBitType); if (InfName != null) { Label lblName = Tools.GetChild <Label>(parent, "Name" + Address); lblName.Content = InfName[nResult] == "-" ? string.Empty : InfName[nResult]; } if (InfUnit != null) { Label lblUnit = Tools.GetChild <Label>(parent, "Unit" + Address); lblUnit.Content = InfUnit[nResult] == "-" ? string.Empty : InfUnit[nResult]; } if (InfFactor != null) { Control box = Tools.GetChild <Control>(parent, "Box" + Address); Node node = box.Tag as Node; string factor = InfFactor.Count == 0 ? nResult.ToString() : InfFactor[nResult]; node.Extra = Regex.Replace(node.Extra, @"^\d+(\.\d+)?", factor); } if (InfItems != null) { ComboBox box = Tools.GetChild <ComboBox>(parent, "Box" + Address); Node node = box.Tag as Node; bool infExtra = true; if (node.Address == 0x200B) { infExtra = false; bool isTg = (node.Extra.Contains("接地") || node.Extra.Contains("*")) && InfItems.Values.First().Contains('*'); bool isTf = (node.Extra.Contains("漏电") || node.Extra.Contains("0.8")) && InfItems.Values.First().Contains("0.8"); bool isFirst = node.Extra.Contains("Null"); infExtra |= isTg | isTg | isFirst; } if (infExtra) { node.Extra = Regex.Match(node.Extra, @"^\d+").Value + "_" + InfItems[nResult]; AutoBox.setBoxItems(box); } } if (InfItemsLinkage != InfLinkage.NULL) { ComboBox box = Tools.GetChild <ComboBox>(parent, "Box" + Address); Node node = box.Tag as Node; string pattern = InfItemsLinkage == InfLinkage.LOWER ? @"(?<=_)\d+(\.\d+)?(?=\*)" : @"(?<=\*)\d+(\.\d+)?$"; node.Extra = Regex.Replace(node.Extra, pattern, strResult); AutoBox.setBoxItems(box); } }