protected void CreateChildItem() { for (int i = 0; i < 30; i++) { TestItemController.Create(parentObj, prefabObj); } parentObj.GetComponent <UIGrid>().Reposition(); }
public static TestItemController Create(GameObject parent, GameObject child) { GameObject obj = NGUITools.AddChild(parent, child); obj.SetActive(true); TestItemController ret = obj.GetComponent <TestItemController>(); return(ret); }
private void AddColumns() { SessionInfo.BatchIndex++; DataGridTemplateColumn _DataGridTemplateColumn = new DataGridTemplateColumn() { Header = "检测项目", Width = new DataGridLength(100, DataGridLengthUnitType.Star) }; var TestItems = new TestItemController().GetActiveTestItemConfigurations(); FrameworkElementFactory _StackPanel = new FrameworkElementFactory(typeof(StackPanel)); _StackPanel.SetValue(StackPanel.VerticalAlignmentProperty, System.Windows.VerticalAlignment.Center); _StackPanel.SetValue(StackPanel.HorizontalAlignmentProperty, System.Windows.HorizontalAlignment.Center); _StackPanel.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal); foreach (TestingItemConfiguration _TestingItem in TestItems) { FrameworkElementFactory checkBox = new FrameworkElementFactory(typeof(CheckBox)); checkBox.SetValue(CheckBox.DataContextProperty, _TestingItem); checkBox.SetValue(CheckBox.MarginProperty, new System.Windows.Thickness(5, 0, 5, 0)); checkBox.SetValue(CheckBox.IsCheckedProperty, false); checkBox.SetValue(CheckBox.ContentProperty, _TestingItem.TestingItemName); checkBox.AddHandler(CheckBox.CheckedEvent, new RoutedEventHandler(checkBox_Checked)); checkBox.AddHandler(CheckBox.UncheckedEvent, new RoutedEventHandler(checkBox_Unchecked)); _StackPanel.AppendChild(checkBox); TextBlock textBlock = new TextBlock(); textBlock.Height = 16; textBlock.Margin = new Thickness(5, 0, 0, 0); textBlock.Width = 16; textBlock.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; textBlock.VerticalAlignment = System.Windows.VerticalAlignment.Center; textBlock.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(_TestingItem.TestingItemColor)); sp_pointout.Children.Add(textBlock); Label label = new Label(); label.Content = _TestingItem.TestingItemName; label.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; label.VerticalAlignment = System.Windows.VerticalAlignment.Center; label.Width = 65; sp_pointout.Children.Add(label); } DataTemplate dataTemplate = new DataTemplate(); dataTemplate.VisualTree = _StackPanel; _DataGridTemplateColumn.CellTemplate = dataTemplate; dg_TubesGroup.Columns.Insert(2, _DataGridTemplateColumn); PoolingRules = new WanTai.Controller.PoolingRulesConfigurationController().GetPoolingRulesConfiguration(); List <LiquidType> LiquidTypeList = SessionInfo.LiquidTypeList = WanTai.Common.Configuration.GetLiquidTypes(); StringBuilder stringBuilder = new StringBuilder(); foreach (LiquidType _LiquidType in LiquidTypeList) { if (_LiquidType.TypeId == 1) { txt_Complement.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(_LiquidType.Color)); lab_Complement.Content = _LiquidType.TypeName; } if (_LiquidType.TypeId == 2) { txt_PositiveControl.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(_LiquidType.Color)); lab_PositiveControl.Content = _LiquidType.TypeName; } if (_LiquidType.TypeId == 3) { txt_NegativeControl.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(_LiquidType.Color)); lab_NegativeControl.Content = _LiquidType.TypeName; } stringBuilder.Append(_LiquidType.TypeName + "、"); } if (stringBuilder.ToString().Length > 0) { lab_tip.Content = "(" + stringBuilder.ToString().Substring(0, stringBuilder.ToString().Length - 1) + "不能分组!)"; } // dg_TubesGroup.ItemsSource = (TubeGroupList=new List<TubeGroup>()); //<TextBlock Height="20" Margin="5,0,0,0" Width="20" Grid.Row="1" Name="txt_NegativeControl" HorizontalAlignment="Left" Background="LightGray" VerticalAlignment="Center" /> // <Label Content="阴性对照物" Name="lab_NegativeControl" Grid.Row="1" HorizontalAlignment="Left" VerticalAlignment="Center" /> // StringBuilder SBuilder = new StringBuilder(); //SBuilder.Append("<DataGridTemplateColumn "); //SBuilder.Append("xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' "); //SBuilder.Append("xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' "); //SBuilder.Append("xmlns:local='clr-namespace:WanTai.View;assembly=WanTai.View' "); //SBuilder.Append("Header=\"混样模式\" Width=\"120\" >"); //SBuilder.Append("<DataGridTemplateColumn.CellTemplate>"); //SBuilder.Append("<DataTemplate >"); //SBuilder.Append(" <ComboBox Name=\"cb_PoolingRulesConfigurations\" HorizontalAlignment=\"Stretch\" SelectedIndex=\"0\" SelectedValue=\"{Binding PoolingRulesID}\" SelectedValuePath=\"PoolingRulesID\" DisplayMemberPath=\"PoolingRulesName\" ItemsSource=\"{Binding Source={StaticResource PoolingRulesConfigurations }}\" VerticalAlignment=\"Stretch\" />"); //SBuilder.Append("</DataTemplate>"); //SBuilder.Append("</DataGridTemplateColumn.CellTemplate>"); //SBuilder.Append("</DataGridTemplateColumn>"); //SBuilder.Append("<DataGridTemplateColumn "); //SBuilder.Append("xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' "); //SBuilder.Append("xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' "); //SBuilder.Append("xmlns:local='clr-namespace:WanTai.View;assembly=WanTai.View' "); //SBuilder.Append("Header=\"检测项目\" Width=\"200\" >"); //SBuilder.Append("<DataGridTemplateColumn.CellTemplate>"); //SBuilder.Append("<DataTemplate >"); //SBuilder.Append("<StackPanel HorizontalAlignment=\"Center\" VerticalAlignment=\"Center\" >"); //SBuilder.Append("</StackPanel>"); //SBuilder.Append("</DataTemplate>"); //SBuilder.Append("</DataGridTemplateColumn.CellTemplate>"); //SBuilder.Append("</DataGridTemplateColumn>"); //Stream stream = new MemoryStream(System.Text.ASCIIEncoding.ASCII.GetBytes(SBuilder.ToString())); //DataGridTemplateColumn colIcon = XamlReader.Load(stream) as DataGridTemplateColumn; //this.dg_TubesGroup.Columns.Insert(1, colIcon); //SBuilder.Append("<DataGridTemplateColumn "); //SBuilder.Append("xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' "); //SBuilder.Append("xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' "); //SBuilder.Append("xmlns:local='clr-namespace:WanTai.View;assembly=WanTai.View' "); //SBuilder.Append("Header=\"操作\" Width=\"100\">"); //SBuilder.Append(" <DataGridTemplateColumn.CellTemplate>"); //SBuilder.Append("<DataTemplate >"); //SBuilder.Append("<StackPanel Orientation=\"Horizontal\" HorizontalAlignment=\"Center\" VerticalAlignment=\"Center\" >"); //SBuilder.Append("<Button Content=\"删除\" Height=\"26\" Width=\"75\" HorizontalAlignment=\"Center\" Click=\"btn_del_Click\" Name=\"btn_del\" VerticalAlignment=\"Center\" />"); //SBuilder.Append(" </StackPanel>"); //SBuilder.Append("</DataTemplate>"); //SBuilder.Append("</DataGridTemplateColumn.CellTemplate>"); //SBuilder.Append("</DataGridTemplateColumn>"); //SBuilder.Append("<DataGridTemplateColumn "); //SBuilder.Append("xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' "); //SBuilder.Append("xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' "); //SBuilder.Append("xmlns:local='clr-namespace:WanTai.View;assembly=WanTai.View' "); //SBuilder.Append("Header=\"采血管\" Width=\"*\" >"); //SBuilder.Append("<DataGridTemplateColumn.CellTemplate>"); //SBuilder.Append(" <DataTemplate >"); //SBuilder.Append("<StackPanel Orientation=\"Horizontal\" HorizontalAlignment=\"Left\" VerticalAlignment=\"Center\" >"); //SBuilder.Append(" <Label Content=\"{Binding Path=TubesPosition}\" HorizontalAlignment=\"Left\" Name=\"lab_TubesPosition\" VerticalAlignment=\"Center\" />"); //SBuilder.Append("</StackPanel>"); //SBuilder.Append("</DataTemplate>"); //SBuilder.Append("</DataGridTemplateColumn.CellTemplate>"); //SBuilder.Append("</DataGridTemplateColumn>"); //Stream stream = new MemoryStream(System.Text.ASCIIEncoding.ASCII.GetBytes(SBuilder.ToString())); // DataGridTemplateColumn colIcon = XamlReader.Load(stream) as DataGridTemplateColumn; // colIcon.Header = i.ToString(); // dg_Bules.Columns.Add(colIcon); }
private void Window_Loaded(object sender, RoutedEventArgs e) { var TestItems = new TestItemController().GetActiveTestItemConfigurations(); StackPanel sp_pointout = new StackPanel(); Label label = new Label(); label.Content = this.Title; label.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; label.VerticalAlignment = System.Windows.VerticalAlignment.Center; sp_pointout.Children.Add(label); foreach (TestingItemConfiguration _TestingItem in TestItems) { TextBlock textBlock = new TextBlock(); textBlock.Height = 20; textBlock.Margin = new Thickness(5, 0, 0, 0); textBlock.Width = 20; textBlock.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; textBlock.VerticalAlignment = System.Windows.VerticalAlignment.Center; textBlock.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(_TestingItem.TestingItemColor)); sp_pointout.Children.Add(textBlock); label = new Label(); label.Content = _TestingItem.TestingItemName; label.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; label.VerticalAlignment = System.Windows.VerticalAlignment.Center; sp_pointout.Children.Add(label); } // dg_Bules.Columns.Clear(); StringBuilder SBuilder = new StringBuilder(); for (int i = 1; i < 0; i++) { SBuilder.Append("<DataGridTemplateColumn Width=\"*\" "); //SBuilder.Append("xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' "); //SBuilder.Append("xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' "); //SBuilder.Append("xmlns:local='clr-namespace:WanTai.View;assembly=WanTai.View' "); //SBuilder.Append("xmlns:my1='clr-namespace:ScottLogic.PieChart;assembly=ScottLogic.PieChart' "); SBuilder.Append(">"); //SBuilder.Append("<DataGridTemplateColumn.HeaderTemplate>"); //SBuilder.Append("<DataTemplate>"); //SBuilder.Append("<StackPanel Orientation=\"Horizontal\">"); //SBuilder.Append("<TextBlock HorizontalAlignment=\"Left\" Text=\""+i.ToString()+"\" VerticalAlignment=\"Top\" />"); //SBuilder.Append("<TextBlock HorizontalAlignment=\"Left\" Text=\"{Binding Path=TubePosBarCode" + i.ToString() + ",Converter={StaticResource TubeShowID}}\" Margin=\"10,0,0,0\" VerticalAlignment=\"Top\" />"); //SBuilder.Append("</StackPanel>"); //SBuilder.Append("</DataTemplate>"); //SBuilder.Append("</DataGridTemplateColumn.HeaderTemplate>"); SBuilder.Append("<DataGridTemplateColumn.CellTemplate>"); SBuilder.Append("<DataTemplate>"); SBuilder.Append("<StackPanel Orientation=\"Horizontal\">"); SBuilder.Append("<StackPanel VerticalAlignment=\"Center\">"); SBuilder.Append("<my1:PieLoayout ToolTip=\"{Binding Path=TubeType" + i.ToString() + "}\" Visibility=\"{Binding Path=Visibility" + i.ToString() + "}\" PlottedProperty=\"{Binding Path=TextItemCount" + i.ToString() + "}\" x:Name=\"pie_" + i.ToString() + "\" />"); SBuilder.Append("</StackPanel>"); SBuilder.Append("<StackPanel Margin=\"10,0,0,0\" Orientation=\"Vertical\" VerticalAlignment=\"Center\">"); SBuilder.Append("<TextBlock HorizontalAlignment=\"Left\" Text=\"{Binding Path=BarCode" + i.ToString() + "}\" VerticalAlignment=\"Top\" />"); SBuilder.Append("<ContentControl Content=\"{Binding Path=DetailView" + i.ToString() + ", Converter={StaticResource hv}}\" />"); //SBuilder.Append("<StackPanel Orientation=\"Horizontal\">"); //SBuilder.Append("<TextBlock HorizontalAlignment=\"Left\" Text=\"{Binding Path=TubeGroupName" + i.ToString() + "}\" VerticalAlignment=\"Top\" />"); //SBuilder.Append("<TextBlock HorizontalAlignment=\"Left\" Margin=\"5,0,0,0\" Text=\"{Binding Path=PoolingRulesName" + i.ToString() + "}\" VerticalAlignment=\"Top\" />"); //SBuilder.Append(" </StackPanel>"); SBuilder.Append("</StackPanel>"); SBuilder.Append("</StackPanel>"); SBuilder.Append("</DataTemplate>"); SBuilder.Append("</DataGridTemplateColumn.CellTemplate>"); SBuilder.Append("</DataGridTemplateColumn>"); //Stream stream = new MemoryStream(System.Text.ASCIIEncoding.ASCII.GetBytes(SBuilder.ToString())); // DataGridTemplateColumn colIcon = XamlReader.Load(stream) as DataGridTemplateColumn; // colIcon.Header = i.ToString(); // dg_Bules.Columns.Add(colIcon); } }