public void SharedSizeGroup () { ColumnDefinition c = new ColumnDefinition (); Assert.IsNull (c.SharedSizeGroup, "1"); try { c.SharedSizeGroup = string.Empty; Assert.Fail ("2"); } catch (ArgumentException) { } try { c.SharedSizeGroup = " "; Assert.Fail ("3"); } catch (ArgumentException) { } try { c.SharedSizeGroup = "."; Assert.Fail ("4"); } catch (ArgumentException) { } try { c.SharedSizeGroup = "1"; Assert.Fail ("5"); } catch (ArgumentException) { } c.SharedSizeGroup = "_"; c.SharedSizeGroup = "A"; c.SharedSizeGroup = "A1"; c.SharedSizeGroup = null; Assert.IsNotNull (DefinitionBase.SharedSizeGroupProperty.ValidateValueCallback, "6"); }
public void write_column_for_widths() { var column = new ColumnDefinition<ColumnDefTarget, string>(FieldType.column, x => x.Name); column.Width(100, 80, 120); writeColumn(column).ShouldContain("width: 100, minWidth: 80, maxWidth: 120"); }
public void override_id() { var column = new ColumnDefinition<ColumnDefTarget, string>(x => x.Name); column.Id("else"); writeColumn(column).ShouldEqual("{name: \"Name\", field: \"Name\", id: \"else\", sortable: true}"); }
public static void AddPages(TabControl tabControl, string tabName, bool maxSize, params Page[] pages) { Grid grid = new Grid(); grid.Width = double.NaN; grid.Height = double.NaN; grid.Margin = new Thickness(0); grid.VerticalAlignment = VerticalAlignment.Top; if (maxSize) { grid.HorizontalAlignment = HorizontalAlignment.Stretch; grid.VerticalAlignment = VerticalAlignment.Stretch; } int index = 0; foreach (var item in pages) { ColumnDefinition col = new ColumnDefinition(); col.Width = GridLength.Auto; grid.ColumnDefinitions.Add(col); SetPageToGrid(item, grid, 0, index); index++; } TabItem tabItem = new TabItem(); tabItem.Header = tabName; tabItem.Content = grid; tabControl.Items.Add(tabItem); }
public void override_title() { var column = new ColumnDefinition<ColumnDefTarget, string>(x => x.Name); column.Title("else"); writeColumn(column).ShouldContain("name: \"else\""); }
/** * The constructor */ public VerticalLayout() { mGrid = new System.Windows.Controls.Grid(); mColDef = new ColumnDefinition(); mSpacerUp = new RowDefinition(); mSpacerDown = new RowDefinition(); mSpacerRight = new ColumnDefinition(); mSpacerLeft = new ColumnDefinition(); mColDef.Width = new System.Windows.GridLength(1, System.Windows.GridUnitType.Star); mSpacerUp.Height = new System.Windows.GridLength(0); mSpacerDown.Height = new System.Windows.GridLength(0); mSpacerRight.Width = new System.Windows.GridLength(0); mSpacerLeft.Width = new System.Windows.GridLength(0); mGrid.RowDefinitions.Add(mSpacerUp); mGrid.RowDefinitions.Add(mSpacerDown); mGrid.ColumnDefinitions.Add(mSpacerLeft); mGrid.ColumnDefinitions.Add(mColDef); mGrid.ColumnDefinitions.Add(mSpacerRight); this.fillSpaceVerticalyEnabled = false; this.fillSpaceHorizontalyEnabled = false; mView = mGrid; #if DEBUG mGrid.ShowGridLines = true; #endif }
public DataGridLengthEditorGrid() { this.ColumnDefinitions.Add(new ColumnDefinition()); ColumnDefinition columnDefinition = new ColumnDefinition(); columnDefinition.Width = GridLength.Auto; this.ColumnDefinitions.Add(columnDefinition); _textBox = new TextBox(); Binding binding = new Binding("Text"); binding.Mode = BindingMode.TwoWay; _textBox.SetBinding(TextBox.TextProperty, binding); _textBox.KeyDown += new KeyEventHandler(TextBox_KeyDown); _textBox.DataContext = this; this.Children.Add(_textBox); _comboBox = new ComboBox(); _comboBox.SetValue(Grid.ColumnProperty, 1); // Unfortunately, there's no built in way to tell the ComboBox to be as wide as the widest item _comboBox.MinWidth = 95; _comboBox.SelectionChanged += new SelectionChangedEventHandler(ComboBox_SelectionChanged); DataGridLengthUnitType[] items = { DataGridLengthUnitType.Auto, DataGridLengthUnitType.Pixel, DataGridLengthUnitType.SizeToCells, DataGridLengthUnitType.SizeToHeader }; _comboBox.ItemsSource = items; this.Children.Add(_comboBox); }
public override bool Equals(ColumnDefinition other) { if (!base.Equals(other)) return false; var otherInteger = (IntegerColumnDefinition)other; if (IdentitySeed != otherInteger.IdentitySeed) return false; return true; }
public ColumnOrderSet(ColumnDefinition column, ListSortDirection order) : this() { column.ThrowIfNull("column"); this.Column = column; this.Direction = order; }
public void will_not_write_a_null_property_because_that_wigs_out_at_runtime() { var column = new ColumnDefinition<ColumnDefTarget, string>(x => x.Name, theProjection); column.Property("something", null); // just wanna see it not blow up writeColumn(column); }
public FixedLengthTokenizer(ColumnDefinition[] columns) { if (columns == null) { throw new ArgumentNullException("columns"); } Columns = columns; }
public override bool Equals(ColumnDefinition other) { if (!base.Equals(other)) return false; var otherDecimal = (DecimalColumnDefinition)other; if (Precision != otherDecimal.Precision) return false; if (Scale != otherDecimal.Scale) return false; return true; }
public override bool Equals(ColumnDefinition other) { if (!base.Equals(other)) return false; var otherSize = (VariableSizeColumnDefinition)other; if (IsMaximumSize && otherSize.IsMaximumSize) return true; if (Size != otherSize.Size) return false; return true; }
/// <summary> /// Add a new column to the table. /// </summary> /// <param name="columndef">The column definition.</param> /// <returns>The table the column was added to.</returns> public override Table CreateColumn(ColumnDefinition columndef) { this.Tracer.TraceInfo("adding column {0} of type {1}", columndef.Name, columndef.Type); columndef.CreateColumn(this.TableCursor); // The meta-data has changed. Reload it. this.LoadMetaData(); return this; }
private string GetFormattedColumnLine(ColumnDefinition column) { return string.Format( "[{0}] {1}{2}{3}", column.Name, GetFormattedDataType(column), GetFormattedIdentity(column), GetFormattedNullable(column)); }
public override void AddColumn(ColumnDefinition columnDef) { using (var transaction = new Transaction(connection.session)) using (var table = new Microsoft.Isam.Esent.Interop.Table(connection.session, connection.dbid, name, OpenTableGrbit.None)) { var tableCreator = new EseTableCreator(connection); tableCreator.AddColumn(table, columnDef); transaction.Commit(CommitTransactionGrbit.None); } RefreshTableInfo(); }
public void ProcessColumnDefinition(ColumnDefinition ColumnDef) { _smells.ProcessTsqlFragment(ColumnDef.DataType); foreach (var Constraint in ColumnDef.Constraints) { _smells.ProcessTsqlFragment(Constraint); } }
private static string Extended(ColumnDefinition column) { var sizeColumn = column as VariableSizeColumnDefinition; if (sizeColumn != null) return string.Format(", {0} = {1}", nameof(sizeColumn.Size), sizeColumn.Size); var integerColumn = column as IntegerColumnDefinition; if (integerColumn != null && integerColumn.IdentitySeed.HasValue) return string.Format(", {0} = {1}", nameof(integerColumn.IdentitySeed), integerColumn.IdentitySeed); var decimalColumn = column as DecimalColumnDefinition; if (decimalColumn != null) return string.Format(", {0} = {1}, {2} = {3}", nameof(decimalColumn.Precision), decimalColumn.Precision, nameof(decimalColumn.Scale), decimalColumn.Scale); return null; }
public override void Visit(ColumnDefinition col) { String s = "<COL id='" + col.ColumnIdentifier.Value + "'"; SqlDataTypeReference dt = (SqlDataTypeReference)col.DataType; s = s + " type='" + dt.SqlDataTypeOption + "'></COL>"; sw.WriteLine(s); col.Accept(new NullVisitor()); }
public static void CreateTable(DataManagement.Configuration config, string tablePrefix = "") { var columns = new ColumnDefinition[] { new ColumnDefinition("Variable", DataType.LargeText), new ColumnDefinition("Value", DataType.LargeText), new ColumnDefinition("Timestamp", DataType.DateTime) }; Table.Create(config, tablePrefix + Names.Variables, columns, primaryKey); }
public virtual string GetAnsiStringExpression(ColumnDefinition dataType) { if (dataType.Length>0) { return this.pGetStringExpression("VARCHAR", dataType.Length, dataType.IsNullable, dataType.DefaultValue as string, true, dataType.IsIdentity, false,dataType.IsUnique, dataType.IsLong); } else { return this.pGetStringExpression ("TEXT",0,dataType.IsNullable, dataType.DefaultValue as string, true); } }
/// <summary> /// Generates table creation script for a database /// </summary> /// <param name="objectType"></param> /// <returns></returns> public string GenerateTableScript(string tableName, ColumnDefinition[] columns) { StringBuilder sb = new StringBuilder(); StringBuilder sbAfterTable = new StringBuilder(); StringBuilder sbBeforeTable = new StringBuilder(); StringBuilder sbPostGeneration = new StringBuilder(); sb.Append(string.Format(" CREATE TABLE {0}{1}{2}", _translator.OpeningIdentifier, tableName, _translator.ClosingIdentifier)); sb.Append(" ( \n "); foreach (ColumnDefinition column in columns) { StringBuilder sbField = new StringBuilder(); ProcessColumnForConstraint(column, sbBeforeTable, sbField, sbAfterTable, sbPostGeneration); string sql = GetCreateSQLForColumn(column); if (!sql.Equals(string.Empty)) { sb.Append("\t"); sb.Append(sql); if (sbField.Length > 0) { sb.Append(" " + sbField.ToString() + " "); } sb.Append(",\n"); } } sb.Remove(sb.Length - 2, 1); // TODO : Later //ProcessTypeForConstraints(objectType, sbBeforeTable, null, sbAfterTable, sbPostGeneration); StringBuilder sbFinal = new StringBuilder(); if (sbBeforeTable.Length > 0) { sbFinal.Append(sbBeforeTable.ToString()); } sbFinal.Append(sb.ToString()); if (sbAfterTable.Length > 0) { sbFinal.Append(sbAfterTable.ToString()); } sbFinal.Append(" ) \n"); if (sbPostGeneration.Length > 0) { sbFinal.Append(sbPostGeneration.ToString()); } return sbFinal.ToString(); }
public void alteration_delegates() { var column = new ColumnDefinition<GridDefinition_selecting_editors_specs.GridDefTarget, String>( x => x.Name, new Projection<GridDefinition_selecting_editors_specs.GridDefTarget>()); var rule = new LambdaColumnRule(a => a.PropertyType == typeof(string), c => c.Properties["foo"] = "bar"); rule.Alter(column); column.Property("foo").ShouldEqual("bar"); }
/// <summary> /// Generates a column altering SQL command and executes it. /// </summary> /// <param name="tableDefinition">Table definition for the table to modify.</param> /// <param name="columnDefinition">Column definition for the column to modify.</param> /// <param name="sqlType">New column type.</param> /// <param name="sqlPrecision">New column precision.</param> protected override void AlterColumn(TableDefinition tableDefinition, ColumnDefinition columnDefinition, ColumnType sqlType, int sqlPrecision) { string tableName = tableDefinition.Name; string columnName = columnDefinition.Name; if (columnDefinition.Committed) { if (sqlType == columnDefinition.SqlType) { //Log.WriteInfo("Altering column precision.\nTable: {0}\nColumn: {1}", tableName, columnName); string commandText = string.Format("ALTER TABLE [dbo].[{0}] ALTER COLUMN [{1}] {2} NULL", tableName, columnName, ConvertToString(sqlType, sqlPrecision)); ExecuteNonQuery(commandText); } else { //Log.WriteInfo("Altering column type.\nTable: {0}\nColumn: {1}", tableName, columnName); string commandText; string typeAndPrecision = ConvertToString(sqlType, sqlPrecision); commandText = string.Format("SELECT [_id], [{0}] INTO #temp FROM [dbo].[{1}]", columnName, tableName); ExecuteNonQuery(commandText); commandText = string.Format("ALTER TABLE [dbo].[{0}] DROP COLUMN [{1}]", tableName, columnName); ExecuteNonQuery(commandText); commandText = string.Format("ALTER TABLE [dbo].[{0}] ADD [{1}] {2} NULL", tableName, columnName, typeAndPrecision); ExecuteNonQuery(commandText); commandText = string.Format("UPDATE [dbo].[{0}] SET [dbo].[{0}].[{1}] = CONVERT({2}, [#temp].[{1}]) FROM #temp WHERE [#temp].[_id] = [dbo].[{0}].[_id]", tableName, columnName, typeAndPrecision); ExecuteNonQuery(commandText); commandText = string.Format("DROP TABLE #temp"); ExecuteNonQuery(commandText); } } else if (tableDefinition.Committed) { //Log.WriteInfo("Adding column.\nTable: {0}\nColumn: {1}", tableName, columnName); string commandText = string.Format("ALTER TABLE [dbo].[{0}] ADD [{1}] {2} NULL", tableName, columnName, ConvertToString(sqlType, sqlPrecision)); ExecuteNonQuery(commandText); columnDefinition.Committed = true; } columnDefinition.SqlType = sqlType; columnDefinition.SqlPrecision = sqlPrecision; }
public string MakeDataMemberName(ColumnDefinition definition, ColumnSubstitution substitution) { string ret = definition.Name; // generate the Property name using override values from the default.names data if (null != substitution) { ret = substitution.DataMemberName; } ret = string.Format("m_{0}", ret); return ret; }
public void DataRecordToColumnIdentity() { mockDataRecord.Setup(x => x.GetBoolean(DataRecordToColumnMapper.Columns.IsIdentity)).Returns(true); mockDataRecord.Setup(x => x.GetDecimal(DataRecordToColumnMapper.Columns.IdentitySeed)).Returns(5); expected = new IntegerColumnDefinition("r1", SqlDbType.Int) { IdentitySeed = 5, }; ColumnDefinition actual = mapper.ToColumnDefinition(mockDataRecord.Object); Assert.AreEqual(expected, actual); }
private string GetFormattedDataType(ColumnDefinition column) { var sizeColumn = column as VariableSizeColumnDefinition; if (sizeColumn != null) { string size = sizeColumn.IsMaximumSize ? "max" : sizeColumn.Size.ToString(); return string.Format("{0}({1})", column.DataType, size); } var decimalColumn = column as DecimalColumnDefinition; if (decimalColumn != null) { return string.Format("{0}({1},{2})", column.DataType, decimalColumn.Precision, decimalColumn.Scale); } return column.DataType.ToString(); }
public void DataRecordToColumnMaxAltSizeVarChar() { mockDataRecord.Setup(x => x.GetString(DataRecordToColumnMapper.Columns.DataType)).Returns("VarChar"); mockDataRecord.Setup(x => x.GetInt16(DataRecordToColumnMapper.Columns.Size)).Returns(-1); expected = new StringColumnDefinition("r1", SqlDbType.VarChar) { AllowNulls = false, Size = -1, IsMaximumSize = true }; ColumnDefinition actual = mapper.ToColumnDefinition(mockDataRecord.Object); Assert.AreEqual(expected, actual); }
public object Convert (object [] values, Type targetType, object parameter, CultureInfo culture) { try { double header_width = (double)values [0]; double width = (double)values [1]; double height = (double)values [2]; double visible_line_width; if (parameter is double) visible_line_width = (double)parameter; else { string parameter_string = parameter as string; if (parameter == null) return DependencyProperty.UnsetValue; visible_line_width = double.Parse (parameter_string); } Grid grid = new Grid (); grid.Height = height; grid.Width = width; ColumnDefinition column_definition = new ColumnDefinition (); column_definition.Width = new GridLength (visible_line_width); grid.ColumnDefinitions.Add (column_definition); column_definition = new ColumnDefinition (); column_definition.Width = new GridLength (header_width); grid.ColumnDefinitions.Add (column_definition); grid.ColumnDefinitions.Add (new ColumnDefinition ()); RowDefinition row_definition = new RowDefinition (); row_definition.Height = new GridLength (width); grid.RowDefinitions.Add (row_definition); grid.RowDefinitions.Add (new RowDefinition ()); Rectangle rectangle = new Rectangle (); rectangle.Fill = Brushes.Black; Grid.SetRowSpan (rectangle, 2); grid.Children.Add (rectangle); rectangle = new Rectangle (); rectangle.Fill = Brushes.Black; Grid.SetColumn (rectangle, 1); Grid.SetRow (rectangle, 1); grid.Children.Add (rectangle); rectangle = new Rectangle (); rectangle.Fill = Brushes.Black; Grid.SetColumn (rectangle, 2); Grid.SetRowSpan (rectangle, 2); grid.Children.Add (rectangle); return new VisualBrush (grid); } catch { return DependencyProperty.UnsetValue; } }
/** * The constructor */ public VerticalLayout() { mGrid = new System.Windows.Controls.Grid(); // The column definitions // The column that will contain the widgets mColDef = new ColumnDefinition(); // The columns used for padding mSpacerRight = new ColumnDefinition(); mSpacerLeft = new ColumnDefinition(); // The rows used for padding mSpacerUp = new RowDefinition(); mSpacerDown = new RowDefinition(); // Setting the main column to star (fill the layout) mColDef.Width = new System.Windows.GridLength(1, System.Windows.GridUnitType.Star); // Setting the paddings to 0 mSpacerUp.Height = new System.Windows.GridLength(0); mSpacerDown.Height = new System.Windows.GridLength(0); mSpacerRight.Width = new System.Windows.GridLength(0); mSpacerLeft.Width = new System.Windows.GridLength(0); // Add the top and bottom padding spacers mGrid.RowDefinitions.Add(mSpacerUp); mGrid.RowDefinitions.Add(mSpacerDown); // Add the left and right padding spacers. In the middle it goes the main column. mGrid.ColumnDefinitions.Add(mSpacerLeft); mGrid.ColumnDefinitions.Add(mColDef); mGrid.ColumnDefinitions.Add(mSpacerRight); mView = mGrid; mGrid.Margin = new Thickness(0.0); mStackPanels = new System.Collections.Generic.List<StackPanel>(); setHorizontalSizePolicyFlags(true, false); setVerticalSizePolicyFlags(true, false); //#if DEBUG //mGrid.ShowGridLines = true; //#endif }
public MainWindow() { InitializeComponent(); Grid DynamicGrid = new Grid(); DynamicGrid.Width = this.Width; DynamicGrid.HorizontalAlignment = HorizontalAlignment.Left; DynamicGrid.VerticalAlignment = VerticalAlignment.Top; // Create Columns for (int i = 0; i < 12; i++) { ColumnDefinition gridCol = new ColumnDefinition(); DynamicGrid.ColumnDefinitions.Add(gridCol); } for (int i = 0; i < 12; i++) { RowDefinition gridRow = new RowDefinition(); gridRow.Height = new GridLength(this.Height / 12); DynamicGrid.RowDefinitions.Add(gridRow); } List <gridXY> XY = new List <gridXY>(); XY.Add(new gridXY { x = 0, y = 4 }); XY.Add(new gridXY { x = 1, y = 4 }); XY.Add(new gridXY { x = 2, y = 4 }); XY.Add(new gridXY { x = 3, y = 4 }); XY.Add(new gridXY { x = 4, y = 4 }); XY.Add(new gridXY { x = 4, y = 3 }); XY.Add(new gridXY { x = 4, y = 2 }); XY.Add(new gridXY { x = 4, y = 1 }); XY.Add(new gridXY { x = 4, y = 0 }); XY.Add(new gridXY { x = 5, y = 0 }); XY.Add(new gridXY { x = 6, y = 0 }); XY.Add(new gridXY { x = 6, y = 1 }); XY.Add(new gridXY { x = 6, y = 2 }); XY.Add(new gridXY { x = 6, y = 3 }); XY.Add(new gridXY { x = 6, y = 4 }); XY.Add(new gridXY { x = 6, y = 4 }); XY.Add(new gridXY { x = 7, y = 4 }); XY.Add(new gridXY { x = 8, y = 4 }); XY.Add(new gridXY { x = 9, y = 4 }); XY.Add(new gridXY { x = 10, y = 4 }); XY.Add(new gridXY { x = 10, y = 5 }); XY.Add(new gridXY { x = 10, y = 6 }); XY.Add(new gridXY { x = 9, y = 6 }); XY.Add(new gridXY { x = 8, y = 6 }); XY.Add(new gridXY { x = 7, y = 6 }); XY.Add(new gridXY { x = 6, y = 6 }); XY.Add(new gridXY { x = 6, y = 7 }); XY.Add(new gridXY { x = 6, y = 8 }); XY.Add(new gridXY { x = 6, y = 9 }); XY.Add(new gridXY { x = 6, y = 10 }); XY.Add(new gridXY { x = 5, y = 10 }); XY.Add(new gridXY { x = 4, y = 10 }); XY.Add(new gridXY { x = 4, y = 9 }); XY.Add(new gridXY { x = 4, y = 8 }); XY.Add(new gridXY { x = 4, y = 7 }); XY.Add(new gridXY { x = 4, y = 6 }); XY.Add(new gridXY { x = 3, y = 6 }); XY.Add(new gridXY { x = 2, y = 6 }); XY.Add(new gridXY { x = 1, y = 6 }); XY.Add(new gridXY { x = 0, y = 6 }); XY.Add(new gridXY { x = 0, y = 5 }); foreach (var VARIABLE in XY) { Canvas canvas = new Canvas(); canvas.Height = this.Height / 12; canvas.Width = this.Width / 12; canvas.Background = System.Windows.Media.Brushes.Black; Ellipse ellipse = new Ellipse(); ellipse.Height = this.Height / 12; ellipse.Width = this.Width / 12; ellipse.Stroke = System.Windows.Media.Brushes.Black; ellipse.Fill = System.Windows.Media.Brushes.DarkBlue; ellipse.HorizontalAlignment = HorizontalAlignment.Left; ellipse.VerticalAlignment = VerticalAlignment.Center; canvas.Children.Add(ellipse); Fields.Add(ellipse); Grid.SetColumn(canvas, VARIABLE.x); Grid.SetRow(canvas, VARIABLE.y); DynamicGrid.Children.Add(canvas); } this.Content = DynamicGrid; //start(); }
private void BuildGrid(SolverIteration iterationBase) { //Set grid alignment Grid.HorizontalAlignment = HorizontalAlignment.Left; Grid.VerticalAlignment = VerticalAlignment.Top; //Clear previous grid info Grid.Children.Clear(); Grid.ColumnDefinitions.Clear(); Grid.RowDefinitions.Clear(); //Default columns var baseColumn = new ColumnDefinition(); Grid.ColumnDefinitions.Add(baseColumn); var objectiveColumn = new ColumnDefinition(); Grid.ColumnDefinitions.Add(objectiveColumn); foreach (var _ in iterationBase.Variables) { Grid.ColumnDefinitions.Add(new ColumnDefinition()); } var objectiveRow = new RowDefinition(); Grid.RowDefinitions.Add(objectiveRow); var nameRow = new RowDefinition(); Grid.RowDefinitions.Add(nameRow); foreach (var _ in Model.Constraints) { Grid.RowDefinitions.Add(new RowDefinition()); } var decisionRow = new RowDefinition(); Grid.RowDefinitions.Add(decisionRow); //Size rows and columns // var gridWidth = Grid.Width; // var cellWidth = gridWidth / Grid.ColumnDefinitions.Count; // // // var gridHeight = Grid.Height; // var cellHeight = gridHeight / Grid.RowDefinitions.Count; // // // foreach (var columnDefinition in Grid.ColumnDefinitions) // { // columnDefinition.Width = new GridLength(cellWidth); // } // // foreach (var rowDefinition in Grid.RowDefinitions) // { // rowDefinition.Height = new GridLength(cellHeight); // } //Build grid rectangles var rects = new List <List <Rectangle> >(); for (int i = 0; i < Grid.RowDefinitions.Count; i++) { var rectR = new List <Rectangle>(); for (int j = 0; j < Grid.ColumnDefinitions.Count; j++) { var rect = new Rectangle { Stroke = Brushes.Black, Fill = Brushes.Transparent }; rectR.Add(rect); Grid.SetRow(rect, i); Grid.SetColumn(rect, j); Grid.Children.Add(rect); } rects.Add(rectR); } Rectangles = rects.Select(r => r.ToArray()).ToArray(); //Build default grid blocks Tableau = new TextBlock { Text = "Tableau", FontWeight = FontWeights.Bold, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center }; Rectangles[0][0].Fill = new SolidColorBrush(Colors.CadetBlue); Grid.SetRow(Tableau, 0); Grid.SetColumn(Tableau, 0); Grid.Children.Add(Tableau); var baseBlock = new TextBlock { Text = "Base", FontWeight = FontWeights.Bold, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center }; Rectangles[1][0].Fill = new SolidColorBrush(Colors.CadetBlue); Grid.SetRow(baseBlock, 1); Grid.SetColumn(baseBlock, 0); Grid.Children.Add(baseBlock); var b = new TextBlock { Text = "b", FontWeight = FontWeights.Bold, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center };; Rectangles[1][1].Fill = new SolidColorBrush(Colors.CadetBlue); Grid.SetRow(b, 1); Grid.SetColumn(b, 1); Grid.Children.Add(b); var z = new TextBlock { Text = "Z", FontWeight = FontWeights.Bold, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center }; Rectangles[Grid.RowDefinitions.Count - 1][0].Fill = new SolidColorBrush(Colors.CadetBlue); Grid.SetRow(z, Grid.RowDefinitions.Count - 1); Grid.SetColumn(z, 0); Grid.Children.Add(z); Z = new TextBlock { Text = "0", FontWeight = FontWeights.Bold, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center };; Grid.SetRow(Z, Grid.RowDefinitions.Count - 1); Grid.SetColumn(Z, 1); Grid.Children.Add(Z); var objectiveBlocks = new List <TextBlock>(); for (int i = 2; i < Grid.ColumnDefinitions.Count; i++) { var block = new TextBlock { Text = $"X{i-1}", VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center }; objectiveBlocks.Add(block); Grid.SetRow(block, 0); Grid.SetColumn(block, i); Grid.Children.Add(block); } ObjectiveRows = objectiveBlocks.ToArray(); var variableBlocks = new List <TextBlock>(); for (int i = 2; i < Grid.ColumnDefinitions.Count; i++) { var block = new TextBlock { Text = $"X{i-1}", FontWeight = FontWeights.Bold, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center }; variableBlocks.Add(block); Rectangles[1][i].Fill = Brushes.CadetBlue; Grid.SetRow(block, 1); Grid.SetColumn(block, i); Grid.Children.Add(block); } Variables = variableBlocks.ToArray(); var baseBlocks = new List <TextBlock>(); for (int i = 2; i < Grid.RowDefinitions.Count - 1; i++) { var block = new TextBlock { Text = $"X{i-1}", VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center }; baseBlocks.Add(block); Grid.SetRow(block, i); Grid.SetColumn(block, 0); Grid.Children.Add(block); } Bases = baseBlocks.ToArray(); var baseVarBlocks = new List <TextBlock>(); for (int i = 2; i < Grid.RowDefinitions.Count - 1; i++) { var block = new TextBlock { Text = $"0", VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center }; baseVarBlocks.Add(block); Grid.SetRow(block, i); Grid.SetColumn(block, 1); Grid.Children.Add(block); } BaseVariables = baseVarBlocks.ToArray(); var varGrid = new List <List <TextBlock> >(); for (int i = 2; i < Grid.RowDefinitions.Count - 1; i++) { var varRow = new List <TextBlock>(); for (int j = 2; j < Grid.ColumnDefinitions.Count; j++) { var block = new TextBlock { Text = $"0", VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center }; varRow.Add(block); Grid.SetRow(block, i); Grid.SetColumn(block, j); Grid.Children.Add(block); } varGrid.Add(varRow); } VariableGrid = varGrid.Select(r => r.ToArray()).ToArray(); var decisionVars = new List <TextBlock>(); for (int i = 2; i < Grid.ColumnDefinitions.Count; i++) { var block = new TextBlock { Text = $"0", VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center }; decisionVars.Add(block); Grid.SetColumn(block, i); Grid.SetRow(block, Grid.RowDefinitions.Count - 1); Grid.Children.Add(block); } DecisionVariables = decisionVars.ToArray(); //BackButton.Content = Resources["BackArrowEnabled"]; //https://stackoverflow.com/questions/3789256/wpf-gridlines-changing-style //https://www.c-sharpcorner.com/UploadFile/mahesh/grid-in-wpf/#:~:text=The%20ColumnDefinitions%20property%20is%20used,three%20rows%20to%20a%20grid.&text=Any%20control%20in%20WPF%20can,Row%20and%20Grid. }
public ColumnConfigurationViewModel(ColumnDefinition definition) { Definition = definition; }
private async Task GenerateTable(Span addSpan, HtmlNode htmlNode, string textHeader) { try { //Check if node contains childs if (!htmlNode.ChildNodes.Any()) { Debug.WriteLine("No child nodes found to add to grid content."); return; } //Set image settings vImageShowAlt = false; //Grid Stackpanel StackPanel stackPanelGrid = new StackPanel(); //Grid Header if (!string.IsNullOrWhiteSpace(textHeader)) { TextBlock TextBlockHeader = new TextBlock(); TextBlockHeader.Text = textHeader + ":"; TextBlockHeader.TextWrapping = TextWrapping.Wrap; TextBlockHeader.HorizontalAlignment = HorizontalAlignment.Left; TextBlockHeader.Foreground = new SolidColorBrush((Color)Application.Current.Resources["SystemAccentColor"]); //Enable or disable text selection if ((bool)AppVariables.ApplicationSettings["ItemTextSelection"]) { TextBlockHeader.IsTextSelectionEnabled = true; } else { TextBlockHeader.IsTextSelectionEnabled = false; } //Add to stackpanel stackPanelGrid.Children.Add(TextBlockHeader); } int RowCurrentCount = 0; int RowTotalCount = htmlNode.Descendants("tr").Count(); if (RowTotalCount > 0) { //Add table child node elements Grid gridContent = new Grid(); gridContent.Background = new SolidColorBrush(Color.FromArgb(255, 136, 136, 136)) { Opacity = 0.20 }; foreach (HtmlNode TableRow in htmlNode.Descendants("tr")) { int ColumnCurrentCount = 0; //Create and add row RowDefinition gridRowDefinition = new RowDefinition(); gridContent.RowDefinitions.Add(gridRowDefinition); Grid gridRow = new Grid(); gridContent.Children.Add(gridRow); Grid.SetRow(gridRow, RowCurrentCount); RowCurrentCount++; //Set grid row style if (RowCurrentCount != RowTotalCount) { gridRow.BorderBrush = new SolidColorBrush((Color)Application.Current.Resources["SystemAccentColor"]) { Opacity = 0.60 }; gridRow.BorderThickness = new Thickness(0, 0, 0, 2); } //Table Header foreach (HtmlNode TableHeader in TableRow.Descendants("th")) { ColumnDefinition gridColDefinition = new ColumnDefinition(); gridRow.ColumnDefinitions.Add(gridColDefinition); TextBlock textBlock = new TextBlock(); textBlock.Foreground = new SolidColorBrush((Color)Application.Current.Resources["SystemAccentColor"]); textBlock.Text = TableHeader.InnerText; //Enable or disable text selection if ((bool)AppVariables.ApplicationSettings["ItemTextSelection"]) { textBlock.IsTextSelectionEnabled = true; } else { textBlock.IsTextSelectionEnabled = false; } gridRow.Children.Add(textBlock); Grid.SetColumn(textBlock, ColumnCurrentCount); ColumnCurrentCount++; } //Table Column foreach (HtmlNode TableColumn in TableRow.Descendants("td")) { ColumnDefinition gridColDefinition = new ColumnDefinition(); gridRow.ColumnDefinitions.Add(gridColDefinition); //Add other child node elements Span spanContent = new Span(); await AddNodes(spanContent, TableColumn, false); Paragraph paraContent = new Paragraph(); paraContent.Inlines.Add(spanContent); //Convert span to textblock RichTextBlock richTextBlock = new RichTextBlock(); richTextBlock.TextWrapping = TextWrapping.Wrap; //Enable or disable text selection if ((bool)AppVariables.ApplicationSettings["ItemTextSelection"]) { richTextBlock.IsTextSelectionEnabled = true; } else { richTextBlock.IsTextSelectionEnabled = false; } richTextBlock.Blocks.Add(paraContent); gridRow.Children.Add(richTextBlock); Grid.SetColumn(richTextBlock, ColumnCurrentCount); ColumnCurrentCount++; } } //Add to stackpanel grid stackPanelGrid.Children.Add(gridContent); } else { Debug.WriteLine("No row found in the table."); //Add other child node elements Span spanContent = new Span(); await AddNodes(spanContent, htmlNode, false); Paragraph paraContent = new Paragraph(); paraContent.Inlines.Add(spanContent); //Convert span to textblock RichTextBlock richTextBlock = new RichTextBlock(); richTextBlock.TextWrapping = TextWrapping.Wrap; //Enable or disable text selection if ((bool)AppVariables.ApplicationSettings["ItemTextSelection"]) { richTextBlock.IsTextSelectionEnabled = true; } else { richTextBlock.IsTextSelectionEnabled = false; } richTextBlock.Blocks.Add(paraContent); //StackPanel Content StackPanel stackPanelContent = new StackPanel(); stackPanelContent.Background = new SolidColorBrush(Color.FromArgb(255, 136, 136, 136)) { Opacity = 0.20 }; stackPanelContent.Children.Add(richTextBlock); //Add to stackpanel grid stackPanelGrid.Children.Add(stackPanelContent); } InlineUIContainer iui = new InlineUIContainer(); iui.Child = stackPanelGrid; addSpan.Inlines.Add(iui); //Set image settings vImageShowAlt = true; } catch { } }
private static void ColumnShouldBe(ColumnDefinition columnDefinition, string columnName, string columnFirstValue) { columnDefinition.Name.Should().Be(columnName); columnDefinition.FirstValue.Should().Be(columnFirstValue); }
public MemberControl(PivotGridControl owner, MemberInfo info) : base(owner) { BorderThickness = new Thickness(0, 0, 1, 1); DefaultStyleKey = typeof(MemberControl); HorizontalAlignment = HorizontalAlignment.Stretch; VerticalAlignment = VerticalAlignment.Stretch; HorizontalContentAlignment = HorizontalAlignment.Stretch; VerticalContentAlignment = VerticalAlignment.Top; if (info == null) { throw new ArgumentNullException("info"); } m_Member = info; m_LayoutRoot = new Grid(); m_LayoutRoot.Margin = new Thickness(2, 2 * Scale, 0, 0); m_LayoutRoot.VerticalAlignment = VerticalAlignment.Top; m_LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); m_LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition()); ColumnDefinition column02 = new ColumnDefinition(); column02.MaxWidth = 0; /* чтобы при сжимании иконка надвигалась на текст макс. ширину будем далее задавать жестко*/ m_LayoutRoot.ColumnDefinitions.Add(column02); m_LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); // Колонка для отображения режима сортировки m_LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); if (IsInteractive) { if (Member.ChildCount > 0 && !Member.IsCalculated && !Member.IsDublicate) { var expander = new PlusMinusButton(); if (Member.DrilledDown) { expander.IsExpanded = true; } expander.CheckedChanged += new EventHandler(expander_CheckedChanged); UseExpandingCommands = true; expander.Height = expander.Width = Math.Max(5, 9 * Scale); m_LayoutRoot.Children.Add(expander); } else { ListMemberControl ctrl = new ListMemberControl(); ctrl.Opacity = 0.35; ctrl.Height = ctrl.Width = Math.Max(5, 9 * Scale); m_LayoutRoot.Children.Add(ctrl); } } // Название элемента m_LayoutRoot.Children.Add(CaptionText); Grid.SetColumn(CaptionText, 1); // Визуализация DATAMEMBER, UNKNOWNMEMBER,CUSTOM_ROLLUP и UNARY_OPERATOR if (Member != null) { BitmapImage custom_image = null; if (Member.UniqueName.Trim().EndsWith("DATAMEMBER")) { custom_image = UriResources.Images.DataMember16; } if (Member.UniqueName.Trim().EndsWith("UNKNOWNMEMBER")) { custom_image = UriResources.Images.UnknownMember16; } // CUSTOM_ROLLUP отображается своей иконкой. // UNARY_OPERATOR - каждый своей иконкой. // Если оба свойства установлены, то отображаем скомбинированную иконку if (String.IsNullOrEmpty(Member.Unary_Operator)) { // Только CUSTOM_ROLLUP if (Member.HasCustomRollup) { custom_image = UriResources.Images.CalcFunction16; } } else { // UNARY_OPERATOR if (custom_image == null && Member.Unary_Operator.Trim() == "+") { if (Member.HasCustomRollup) { custom_image = UriResources.Images.CalcFunctionPlus16; } else { custom_image = UriResources.Images.CalcPlus16; } } if (custom_image == null && Member.Unary_Operator.Trim() == "-") { if (Member.HasCustomRollup) { custom_image = UriResources.Images.CalcFunctionMinus16; } else { custom_image = UriResources.Images.CalcMinus16; } } if (custom_image == null && Member.Unary_Operator.Trim() == "*") { if (Member.HasCustomRollup) { custom_image = UriResources.Images.CalcFunctionMultiply16; } else { custom_image = UriResources.Images.CalcMultiply16; } } if (custom_image == null && Member.Unary_Operator.Trim() == "/") { if (Member.HasCustomRollup) { custom_image = UriResources.Images.CalcFunctionDivide16; } else { custom_image = UriResources.Images.CalcDivide16; } } if (custom_image == null && Member.Unary_Operator.Trim() == "~") { if (Member.HasCustomRollup) { custom_image = UriResources.Images.CalcFunctionTilde16; } else { custom_image = UriResources.Images.CalcTilde16; } } if (custom_image == null && Member.Unary_Operator.Trim() == "=") { if (Member.HasCustomRollup) { custom_image = UriResources.Images.CalcFunctionEqual16; } else { custom_image = UriResources.Images.CalcEqual16; } } if (custom_image == null) { if (Member.HasCustomRollup) { custom_image = UriResources.Images.CalcFunctionPercent16; } else { custom_image = UriResources.Images.CalcPercent16; } } } if (custom_image != null) { Image image1 = new Image() { Margin = new Thickness(0, 0, 2, 0) }; image1.Width = Math.Max(8, 16 * Scale); image1.Height = Math.Max(8, 16 * Scale); image1.Source = custom_image; m_LayoutRoot.Children.Add(image1); Grid.SetColumn(image1, 3); } } m_EllipsisText = new TextBlock() { Text = "..." }; m_EllipsisText.FontSize = Owner.DefaultFontSize * Scale; m_LayoutRoot.Children.Add(m_EllipsisText); m_EllipsisText.Margin = new Thickness(-1, 0, 0, 0); m_EllipsisText.TextAlignment = TextAlignment.Left; m_EllipsisText.VerticalAlignment = VerticalAlignment.Center; Grid.SetColumn(m_EllipsisText, 2); m_EllipsisText.Visibility = Visibility.Collapsed; this.SizeChanged += new SizeChangedEventHandler(MemberControl_SizeChanged); this.Content = m_LayoutRoot; this.Click += new RoutedEventHandler(MemberControl_Click); m_SortByValueImage = new Image() { Width = 16, Height = 16 }; m_SortByValueImage.Visibility = Visibility.Collapsed; //var m_SortSelector = new SortTypeSelector() { VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center }; m_LayoutRoot.Children.Add(m_SortByValueImage); Grid.SetColumn(m_SortByValueImage, 4); }
private void SetSkin() { string packUri = "pack://application:,,,/Resources/androidBody.png"; Control.MainBg.ImageSource = new ImageSourceConverter().ConvertFromString(packUri) as ImageSource; // MAIN GRID DEFINITION RowDefinition r = new RowDefinition(); r.Height = new GridLength(0.1, GridUnitType.Star); RowDefinition r1 = new RowDefinition(); r1.Height = new GridLength(0.7, GridUnitType.Star); RowDefinition r2 = new RowDefinition(); r2.Height = new GridLength(0.2, GridUnitType.Star); Control.MainGrid.RowDefinitions.Add(r); Control.MainGrid.RowDefinitions.Add(r1); Control.MainGrid.RowDefinitions.Add(r2); ColumnDefinition c = new ColumnDefinition(); c.Width = new GridLength(0.09, GridUnitType.Star); ColumnDefinition c1 = new ColumnDefinition(); c1.Width = new GridLength(0.82, GridUnitType.Star); ColumnDefinition c2 = new ColumnDefinition(); c2.Width = new GridLength(0.09, GridUnitType.Star); Control.MainGrid.ColumnDefinitions.Add(c); Control.MainGrid.ColumnDefinitions.Add(c1); Control.MainGrid.ColumnDefinitions.Add(c2); Control.rdfWPF.SetValue(Grid.ColumnProperty, 1); Control.rdfWPF.SetValue(Grid.RowProperty, 1); Control.Footer.SetValue(Grid.ColumnProperty, 1); Control.Footer.SetValue(Grid.RowProperty, 2); // FOOTER GRID DEFINITION RowDefinition rf = new RowDefinition(); rf.Height = new GridLength(0.3, GridUnitType.Star); RowDefinition rf1 = new RowDefinition(); rf1.Height = new GridLength(0.3, GridUnitType.Star); RowDefinition rf2 = new RowDefinition(); rf2.Height = new GridLength(0.4, GridUnitType.Star); Control.Footer.RowDefinitions.Add(rf); Control.Footer.RowDefinitions.Add(rf1); Control.Footer.RowDefinitions.Add(rf2); ColumnDefinition cf = new ColumnDefinition(); cf.Width = new GridLength(0.25, GridUnitType.Star); ColumnDefinition cf1 = new ColumnDefinition(); cf1.Width = new GridLength(0.25, GridUnitType.Star); ColumnDefinition cf2 = new ColumnDefinition(); cf2.Width = new GridLength(0.25, GridUnitType.Star); ColumnDefinition cf3 = new ColumnDefinition(); cf3.Width = new GridLength(0.25, GridUnitType.Star); Control.Footer.ColumnDefinitions.Add(cf); Control.Footer.ColumnDefinitions.Add(cf1); Control.Footer.ColumnDefinitions.Add(cf2); Control.Footer.ColumnDefinitions.Add(cf3); // BACK BUTTON SurfaceButton backButton = new SurfaceButton(); backButton.Click += new RoutedEventHandler(backButton_Click); backButton.Background = System.Windows.Media.Brushes.Transparent; backButton.VerticalAlignment = VerticalAlignment.Stretch; backButton.HorizontalAlignment = HorizontalAlignment.Stretch; backButton.SetResourceReference(FrameworkElement.StyleProperty, "SurfaceButtonStyleInv"); Control.Footer.Children.Add(backButton); backButton.SetValue(Grid.ColumnProperty, 0); backButton.SetValue(Grid.RowProperty, 0); // MENU BUTTON SurfaceButton menuButton = new SurfaceButton(); menuButton.Click += new RoutedEventHandler(menuButton_Click); menuButton.Background = System.Windows.Media.Brushes.Transparent; menuButton.VerticalAlignment = VerticalAlignment.Stretch; menuButton.HorizontalAlignment = HorizontalAlignment.Stretch; menuButton.SetResourceReference(FrameworkElement.StyleProperty, "SurfaceButtonStyleInv"); Control.Footer.Children.Add(menuButton); menuButton.SetValue(Grid.ColumnProperty, 1); menuButton.SetValue(Grid.RowProperty, 0); // HOME BUTTON SurfaceButton homeButton = new SurfaceButton(); homeButton.Click += new RoutedEventHandler(homeButton_Click); homeButton.Background = System.Windows.Media.Brushes.Transparent; homeButton.VerticalAlignment = VerticalAlignment.Stretch; homeButton.HorizontalAlignment = HorizontalAlignment.Stretch; homeButton.SetResourceReference(FrameworkElement.StyleProperty, "SurfaceButtonStyleInv"); Control.Footer.Children.Add(homeButton); homeButton.SetValue(Grid.ColumnProperty, 2); homeButton.SetValue(Grid.RowProperty, 0); // HIDE BUTTON //SurfaceButton hideButton = new SurfaceButton(); //hideButton.Click += new RoutedEventHandler(hideButton_Click); //hideButton.Background = System.Windows.Media.Brushes.Green; //hideButton.BorderBrush = System.Windows.Media.Brushes.Transparent; //hideButton.Opacity = 0.3; //hideButton.VerticalAlignment = VerticalAlignment.Stretch; //hideButton.HorizontalAlignment = HorizontalAlignment.Stretch; //hideButton.SetResourceReference(FrameworkElement.StyleProperty, "SurfaceButtonStyleInv"); //Control.Footer.Children.Add(hideButton); //hideButton.SetValue(Grid.ColumnProperty, 0); //hideButton.SetValue(Grid.RowProperty, 2); //hideButton.SetValue(Grid.ColumnSpanProperty, 4); // EXIT BUTTON //SurfaceButton closeButton = new SurfaceButton(); //closeButton.Click += new RoutedEventHandler(Control.closeButton_Click); //closeButton.Background = System.Windows.Media.Brushes.Transparent; //closeButton.BorderBrush = System.Windows.Media.Brushes.Transparent; //closeButton.VerticalAlignment = VerticalAlignment.Top; //closeButton.HorizontalAlignment = HorizontalAlignment.Stretch; //closeButton.Padding = new Thickness(5); //closeButton.SetResourceReference(FrameworkElement.StyleProperty, "SurfaceButtonStyleInv"); //var img = new System.Windows.Controls.Image(); //string packUri1 = "pack://application:,,,/Resources/blackClose.png"; //img.Source = new ImageSourceConverter().ConvertFromString(packUri1) as ImageSource; //closeButton.Content = img; //Control.MainGrid.Children.Add(closeButton); //closeButton.SetValue(Grid.ColumnProperty, 2); //closeButton.SetValue(Grid.RowProperty, 2); }
private void BuildLabeledControl(PropertyInfo propertyInfo) { Grid grid = new Grid(); grid.Width = 270.0; grid.Height = 23.0; grid.Margin = new Thickness(0, 0, 15, 5); ColumnDefinition columnDefinition = new ColumnDefinition(); columnDefinition.Width = new GridLength(120); grid.ColumnDefinitions.Add(columnDefinition); columnDefinition = new ColumnDefinition(); columnDefinition.Width = new GridLength(150); grid.ColumnDefinitions.Add(columnDefinition); ControlType controlType = DisplayUtil.GetControlType(propertyInfo); Binding binding = this.CreateBinding(propertyInfo, controlType, this.DataContext); TextBox textBox = null; switch (controlType) { case ControlType.Button: Button button = new Button(); button.SetBinding(Button.CommandProperty, binding); button.Content = DisplayUtil.GetControlDescription(propertyInfo); button.HorizontalAlignment = HorizontalAlignment.Right; button.Margin = new Thickness(5, 0, 0, 0); button.Padding = new Thickness(15, 3, 15, 3); this.commandPanel.Children.Add(button); break; case ControlType.CheckBox: CheckBox checkBox = new CheckBox(); checkBox.SetBinding(CheckBox.IsCheckedProperty, binding); Grid.SetColumn(checkBox, 1); grid.Children.Add(checkBox); break; // combo box case ControlType.ComboBox: ComboBox comboBox = new ComboBox(); if (propertyInfo.PropertyType.IsEnum) { comboBox.ItemsSource = Enum.GetValues(propertyInfo.PropertyType); // populate? } else { comboBox.ItemsSource = RepositoryManager.GetLookupRepository(propertyInfo.PropertyType).LookupList; } comboBox.SetBinding(ComboBox.SelectedItemProperty, binding); Grid.SetColumn(comboBox, 1); grid.Children.Add(comboBox); break; case ControlType.DateBox: break; case ControlType.Label: textBox = new TextBox(); textBox.IsEnabled = false; textBox.SetBinding(TextBox.TextProperty, binding); Grid.SetColumn(textBox, 1); grid.Children.Add(textBox); break; case ControlType.None: break; case ControlType.TextBox: textBox = new TextBox(); textBox.SetBinding(TextBox.TextProperty, binding); Grid.SetColumn(textBox, 1); grid.Children.Add(textBox); break; default: break; } if (controlType != ControlType.Button) { Label label = new Label(); label.Content = DisplayUtil.GetControlDescription(propertyInfo); label.Margin = new Thickness(0, -2, 0, 0); Grid.SetColumn(label, 0); grid.Children.Add(label); RowDefinition rowDefinition = new RowDefinition(); rowDefinition.Height = GridLength.Auto; this.propertyGrid.RowDefinitions.Add(rowDefinition); Grid.SetRow(grid, this.propertyGrid.RowDefinitions.Count - 1); this.propertyGrid.Children.Add(grid); } }
protected override string FormatIdentity(ColumnDefinition column) { //Identity type is handled by FormatType return(string.Empty); }
/// <summary> /// Program entry point. /// </summary> /// <param name="app">Holds arguments and other info.</param> public void Execute(IExampleInterface app) { // Download the data that we will attempt to model. string irisFile = DownloadData(app.Args); // Define the format of the data file. // This area will change, depending on the columns and // format of the file that you are trying to model. IVersatileDataSource source = new CSVDataSource(irisFile, false, CSVFormat.DecimalPoint); var data = new VersatileMLDataSet(source); data.DefineSourceColumn("sepal-length", 0, ColumnType.Continuous); data.DefineSourceColumn("sepal-width", 1, ColumnType.Continuous); data.DefineSourceColumn("petal-length", 2, ColumnType.Continuous); data.DefineSourceColumn("petal-width", 3, ColumnType.Continuous); // Define the column that we are trying to predict. ColumnDefinition outputColumn = data.DefineSourceColumn("species", 4, ColumnType.Nominal); // Analyze the data, determine the min/max/mean/sd of every column. data.Analyze(); // Map the prediction column to the output of the model, and all // other columns to the input. data.DefineSingleOutputOthersInput(outputColumn); // Create feedforward neural network as the model type. MLMethodFactory.TYPE_FEEDFORWARD. // You could also other model types, such as: // MLMethodFactory.SVM: Support Vector Machine (SVM) // MLMethodFactory.TYPE_RBFNETWORK: RBF Neural Network // MLMethodFactor.TYPE_NEAT: NEAT Neural Network // MLMethodFactor.TYPE_PNN: Probabilistic Neural Network var model = new EncogModel(data); model.SelectMethod(data, MLMethodFactory.TypeFeedforward); // Send any output to the console. model.Report = new ConsoleStatusReportable(); // Now normalize the data. Encog will automatically determine the correct normalization // type based on the model you chose in the last step. data.Normalize(); // Hold back some data for a final validation. // Shuffle the data into a random ordering. // Use a seed of 1001 so that we always use the same holdback and will get more consistent results. model.HoldBackValidation(0.3, true, 1001); // Choose whatever is the default training type for this model. model.SelectTrainingType(data); // Use a 5-fold cross-validated train. Return the best method found. var bestMethod = (IMLRegression)model.Crossvalidate(5, true); // Display the training and validation errors. Console.WriteLine(@"Training error: " + model.CalculateError(bestMethod, model.TrainingDataset)); Console.WriteLine(@"Validation error: " + model.CalculateError(bestMethod, model.ValidationDataset)); // Display our normalization parameters. NormalizationHelper helper = data.NormHelper; Console.WriteLine(helper.ToString()); // Display the final model. Console.WriteLine(@"Final model: " + bestMethod); // Loop over the entire, original, dataset and feed it through the model. // This also shows how you would process new data, that was not part of your // training set. You do not need to retrain, simply use the NormalizationHelper // class. After you train, you can save the NormalizationHelper to later // normalize and denormalize your data. source.Close(); var csv = new ReadCSV(irisFile, false, CSVFormat.DecimalPoint); var line = new String[4]; IMLData input = helper.AllocateInputVector(); while (csv.Next()) { var result = new StringBuilder(); line[0] = csv.Get(0); line[1] = csv.Get(1); line[2] = csv.Get(2); line[3] = csv.Get(3); String correct = csv.Get(4); helper.NormalizeInputVector(line, ((BasicMLData)input).Data, false); IMLData output = bestMethod.Compute(input); String irisChosen = helper.DenormalizeOutputVectorToString(output)[0]; result.Append(line); result.Append(" -> predicted: "); result.Append(irisChosen); result.Append("(correct: "); result.Append(correct); result.Append(")"); Console.WriteLine(result.ToString()); } csv.Close(); // Delete data file ande shut down. File.Delete(irisFile); EncogFramework.Instance.Shutdown(); }
/// <summary> /// Constructor para crear la interfaz /// </summary> /// <param name="message"></param> // FIXME: 08/06/2020 Podriais haberla separado un poco public Info(string message) { //Creamos la ventana window = new Window { Title = "Info", Width = 590, Height = 192, ResizeMode = ResizeMode.NoResize }; //Centramos la ventana en la pantalla double screenWidth = SystemParameters.PrimaryScreenWidth; double screenHeight = SystemParameters.PrimaryScreenHeight; double windowWidth = window.Width; double windowHeight = window.Height; window.Left = (screenWidth / 2) - (windowWidth / 2); window.Top = (screenHeight / 2) - (windowHeight / 2); //Creamos el grid con el mismo tamaño Grid grid = new Grid { Width = window.Width, Height = window.Height, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, //Definimos un color de fondo Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#f7f7f7")) }; // Definimos las filas del grid. RowDefinition rowDef1 = new RowDefinition(); RowDefinition rowDef2 = new RowDefinition(); rowDef1.Height = new GridLength(124.8); rowDef2.Height = new GridLength(48); grid.RowDefinitions.Add(rowDef1); grid.RowDefinitions.Add(rowDef2); // Definimos las columnas del grid. ColumnDefinition colDef1 = new ColumnDefinition { Width = new GridLength(88.5) }; ColumnDefinition colDef2 = new ColumnDefinition { Width = new GridLength(472) }; grid.ColumnDefinitions.Add(colDef1); grid.ColumnDefinitions.Add(colDef2); //Icono de info Label icono = new Label { Content = Char.ConvertFromUtf32(0xE946), FontFamily = new FontFamily("Segoe MDL2 Assets"), Height = 50, Width = 50, FontSize = 32, HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Center, Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#1e88e5")) }; Grid.SetRow(icono, 0); Grid.SetColumn(icono, 0); Thickness marginImage = new Thickness { Left = 0, Right = 10, Top = 0, Bottom = 0 }; icono.Margin = marginImage; //Mensaje Label text = new Label { Height = 75, Width = 472, MinHeight = 75, MaxHeight = 100, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Left, Content = new TextBlock() { Text = message, TextWrapping = TextWrapping.Wrap } }; Grid.SetRow(text, 0); Grid.SetColumn(text, 1); // Creamos el botón de aceptar. accept = new Button { Content = "Aceptar", Height = 30, Width = 100 }; Grid.SetRow(accept, 1); Grid.SetColumn(accept, 1); // Definimos los margenes. accept.VerticalAlignment = VerticalAlignment.Top; accept.HorizontalAlignment = HorizontalAlignment.Right; // Establecemos la función lambda para cerrar la ventana al dar click en aceptar. accept.Click += (o, i) => { window.Close(); Acceptance?.Invoke(this, i); }; //Añadimos los elementos al grid grid.Children.Add(icono); grid.Children.Add(text); grid.Children.Add(accept); window.Content = grid; }
private void buildGrid(int groupFieldCount) { this.GroupFieldGrid.Children.Clear(); this.GroupFieldGrid.RowDefinitions.Clear(); this.GroupFieldGrid.ColumnDefinitions.Clear(); if (groupFieldCount <= 0) { return; } int row = 1; int col = 1; if (groupFieldCount == 1) { row = 1; col = 1; } else if (groupFieldCount == 2) { row = 1; col = 2; } else if (groupFieldCount == 3) { row = 2; col = 2; } else if (groupFieldCount == 4) { row = 2; col = 2; } else if (groupFieldCount == 5) { row = 2; col = 3; } else if (groupFieldCount == 6) { row = 2; col = 3; } else if (groupFieldCount == 7) { row = 3; col = 3; } else if (groupFieldCount == 8) { row = 3; col = 3; } else if (groupFieldCount == 9) { row = 3; col = 3; } else if (groupFieldCount == 10) { row = 4; col = 3; } else if (groupFieldCount == 11) { row = 4; col = 3; } else if (groupFieldCount == 12) { row = 4; col = 3; } else { row = 5; col = 3; } for (int i = 1; i <= row; i++) { RowDefinition def = new RowDefinition(); def.Height = new GridLength(ModelGroupField.Height + 20);//new GridLength(1, GridUnitType.Star); this.GroupFieldGrid.RowDefinitions.Add(def); } for (int i = 1; i <= col; i++) { ColumnDefinition def = new ColumnDefinition(); def.Width = new GridLength(1, GridUnitType.Star);//new GridLength(ModelBlock.Width + 30);//new GridLength(1, GridUnitType.Star); this.GroupFieldGrid.ColumnDefinitions.Add(def); } }
// height or width means the maximum number of squares contained public NextBlock(double h, double w) { InitializeComponent(); colorMap = SquareGenerator.colorMap; _squareSize = SquareGenerator.squareSize; canvasHeight = h; canvasWidth = w; nextBlockGrid = new Grid(); Canvas aCanvas = new Canvas(); aCanvas.Children.Add(nextBlockGrid); this.Height = canvasHeight; this.Width = canvasWidth; this.Child = aCanvas; aCanvas.Background = new SolidColorBrush(Colors.Transparent); squaresMatrix = new Rectangle[_gridHeight, _gridWidth]; // initialize the grid GridLength _gridLen = new GridLength(1, GridUnitType.Auto); int i = 0; int j = 0; for (i = 0; i < _gridHeight; i++) { RowDefinition aRow = new RowDefinition(); aRow.Height = _gridLen; nextBlockGrid.RowDefinitions.Add(aRow); } for (j = 0; j < _gridWidth; j++) { ColumnDefinition aCol = new ColumnDefinition(); aCol.Width = _gridLen; nextBlockGrid.ColumnDefinitions.Add(aCol); } nextBlockGrid.Background = new SolidColorBrush(Colors.Transparent); // add squares into the grid for (i = 0; i < _gridHeight; i++) { for (j = 0; j < _gridWidth; j++) { squaresMatrix[i, j] = new Rectangle(); nextBlockGrid.Children.Add(squaresMatrix[i, j]); squaresMatrix[i, j].SetValue(Grid.RowProperty, i); squaresMatrix[i, j].SetValue(Grid.ColumnProperty, j); squaresMatrix[i, j].Width = _squareSize; squaresMatrix[i, j].Height = _squareSize; squaresMatrix[i, j].Margin = new Thickness(1, 1, 1, 1); // put this into square generator } } }
private void AdaptRowsCols(Grid grid, List <TextBox> tbs, int rows, int cols) { if (grid == null || tbs == null) { return; } // have header rows & columns rows += 1; cols += 1; // rework grid's cols while (grid.ColumnDefinitions.Count < cols) { var gl = new ColumnDefinition(); gl.Width = new GridLength(1.0, GridUnitType.Star); grid.ColumnDefinitions.Add(gl); } while (grid.ColumnDefinitions.Count > cols) { grid.ColumnDefinitions.RemoveAt(grid.ColumnDefinitions.Count - 1); } // rework grid's rows while (grid.RowDefinitions.Count < rows) { var gl = new RowDefinition(); gl.Height = new GridLength(1.0, GridUnitType.Star); grid.RowDefinitions.Add(gl); } while (grid.RowDefinitions.Count > rows) { grid.RowDefinitions.RemoveAt(grid.RowDefinitions.Count - 1); } // more than required while (tbs.Count > rows * cols) { // delete last from grid var tb = tbs[tbs.Count - 1]; grid.Children.Remove(tb); tbs.Remove(tb); } // re-align the existing ones for (int i = 0; i < tbs.Count; i++) { var tb = tbs[i]; Grid.SetRow(tb, i / cols); Grid.SetColumn(tb, i % cols); } // new text boxes while (tbs.Count < rows * cols) { var tb = new TextBox(); tb.Margin = new Thickness(0, 0, 4, 4); tb.TextWrapping = TextWrapping.Wrap; tb.AcceptsReturn = true; grid.Children.Add(tb); Grid.SetRow(tb, (tbs.Count) / cols); Grid.SetColumn(tb, (tbs.Count) % cols); tbs.Add(tb); } // in any case, re-color text boxes foreach (var child in grid.Children) { var tb = child as TextBox; if (tb != null) { if (Grid.GetRow(tb) < 1 || Grid.GetColumn(tb) < 1) { tb.Foreground = Brushes.DarkGray; tb.Background = new SolidColorBrush(Color.FromArgb(0xff, 0x15, 0x1f, 0x33)); } else { tb.Foreground = TextBoxNumRows.Foreground; tb.Background = TextBoxNumRows.Background; } } } }
private void bwLoad_DoWork(object sender, DoWorkEventArgs e) { outsoleMaterialList = OutsoleMaterialController.Select().Where(w => productNoList.Contains(w.ProductNo)).ToList(); Dispatcher.Invoke(new Action(() => { DataTable dt = new DataTable(); dt.Columns.Add("ProductNo", typeof(String)); DataGridTextColumn column1 = new DataGridTextColumn(); column1.Header = "PO No."; column1.Binding = new Binding("ProductNo"); column1.FontWeight = FontWeights.Bold; dgInventory.Columns.Add(column1); Binding bindingWidth1 = new Binding(); bindingWidth1.Source = column1; bindingWidth1.Path = new PropertyPath("ActualWidth"); ColumnDefinition cd1 = new ColumnDefinition(); cd1.SetBinding(ColumnDefinition.WidthProperty, bindingWidth1); gridTotal.ColumnDefinitions.Add(cd1); dt.Columns.Add("ArticleNo", typeof(String)); DataGridTextColumn column1_1_1 = new DataGridTextColumn(); column1_1_1.Header = "Article No."; column1_1_1.Binding = new Binding("ArticleNo"); //column1_1_1.FontWeight = FontWeights.Bold; dgInventory.Columns.Add(column1_1_1); Binding bindingWidth1_1_1 = new Binding(); bindingWidth1_1_1.Source = column1_1_1; bindingWidth1_1_1.Path = new PropertyPath("ActualWidth"); ColumnDefinition cd1_1_1 = new ColumnDefinition(); cd1_1_1.SetBinding(ColumnDefinition.WidthProperty, bindingWidth1_1_1); gridTotal.ColumnDefinitions.Add(cd1_1_1); dt.Columns.Add("ETD", typeof(DateTime)); DataGridTextColumn column1_1 = new DataGridTextColumn(); column1_1.Header = "EFD"; Binding binding = new Binding(); binding.Path = new PropertyPath("ETD"); binding.StringFormat = "dd-MMM"; column1_1.Binding = binding; column1_1.FontWeight = FontWeights.Bold; dgInventory.Columns.Add(column1_1); Binding bindingWidth1_1 = new Binding(); bindingWidth1_1.Source = column1_1; bindingWidth1_1.Path = new PropertyPath("ActualWidth"); ColumnDefinition cd1_1 = new ColumnDefinition(); cd1_1.SetBinding(ColumnDefinition.WidthProperty, bindingWidth1_1); gridTotal.ColumnDefinitions.Add(cd1_1); dt.Columns.Add("Quantity", typeof(Int32)); DataGridTextColumn column1_2 = new DataGridTextColumn(); column1_2.Header = "Quantity"; Binding bindingQuantity = new Binding(); bindingQuantity.Path = new PropertyPath("Quantity"); //binding.StringFormat = "dd-MMM"; column1_2.Binding = bindingQuantity; //column1_2.FontWeight = FontWeights.Bold; dgInventory.Columns.Add(column1_2); Binding bindingWidth1_2 = new Binding(); bindingWidth1_2.Source = column1_2; bindingWidth1_2.Path = new PropertyPath("ActualWidth"); ColumnDefinition cd1_2 = new ColumnDefinition(); cd1_2.SetBinding(ColumnDefinition.WidthProperty, bindingWidth1_2); gridTotal.ColumnDefinitions.Add(cd1_2); dt.Columns.Add("Release", typeof(Int32)); DataGridTextColumn column1_3 = new DataGridTextColumn(); column1_3.Header = "Release"; Binding bindingRelease = new Binding(); bindingRelease.Path = new PropertyPath("Release"); //binding.StringFormat = "dd-MMM"; column1_3.Binding = bindingRelease; //column1_2.FontWeight = FontWeights.Bold; dgInventory.Columns.Add(column1_3); Binding bindingWidth1_3 = new Binding(); bindingWidth1_3.Source = column1_3; bindingWidth1_3.Path = new PropertyPath("ActualWidth"); ColumnDefinition cd1_3 = new ColumnDefinition(); cd1_3.SetBinding(ColumnDefinition.WidthProperty, bindingWidth1_3); gridTotal.ColumnDefinitions.Add(cd1_3); for (int i = 0; i <= outsoleSupplierList.Count - 1; i++) { OutsoleSuppliersModel outsoleSupplier = outsoleSupplierList[i]; dt.Columns.Add(String.Format("Column{0}", i), typeof(Int32)); DataGridTextColumn column = new DataGridTextColumn(); //column.SetValue(TagProperty, sizeRun.SizeNo); column.Header = outsoleSupplier.Name; column.Binding = new Binding(String.Format("Column{0}", i)); Style style = new Style(typeof(DataGridCell)); style.Setters.Add(new Setter(TextBlock.TextAlignmentProperty, TextAlignment.Center)); Setter setterForeground = new Setter(); setterForeground.Property = DataGridCell.ForegroundProperty; setterForeground.Value = Brushes.Black; style.Setters.Add(setterForeground); Setter setterBackground = new Setter(); setterBackground.Property = DataGridCell.BackgroundProperty; setterBackground.Value = new Binding(String.Format("Column{0}Background", i)); style.Setters.Add(setterBackground); column.CellStyle = style; dgInventory.Columns.Add(column); Binding bindingWidth = new Binding(); bindingWidth.Source = column; bindingWidth.Path = new PropertyPath("ActualWidth"); ColumnDefinition cd = new ColumnDefinition(); cd.SetBinding(ColumnDefinition.WidthProperty, bindingWidth); gridTotal.ColumnDefinitions.Add(cd); DataColumn columnBackground = new DataColumn(String.Format("Column{0}Background", i), typeof(SolidColorBrush)); columnBackground.DefaultValue = Brushes.Transparent; dt.Columns.Add(columnBackground); } dt.Columns.Add("Matching", typeof(Int32)); DataGridTextColumn column2 = new DataGridTextColumn(); column2.Header = "Matching"; column2.Binding = new Binding("Matching"); dgInventory.Columns.Add(column2); Binding bindingWidth2 = new Binding(); bindingWidth2.Source = column2; bindingWidth2.Path = new PropertyPath("ActualWidth"); ColumnDefinition cd2 = new ColumnDefinition(); cd2.SetBinding(ColumnDefinition.WidthProperty, bindingWidth2); gridTotal.ColumnDefinitions.Add(cd2); foreach (string productNo in productNoList) { var outsoleMaterialDetailPerPOList = OutsoleMaterialDetailController.Select(productNo).ToList(); if (productNo == "105-5900") { } List <OutsoleMaterialModel> outsoleMaterialList_D1 = outsoleMaterialList.Where(o => o.ProductNo == productNo).ToList(); List <OutsoleReleaseMaterialModel> outsoleReleaseMaterialList_D1 = outsoleReleaseMaterialList.Where(o => o.ProductNo == productNo).ToList(); DataRow dr = dt.NewRow(); dr["ProductNo"] = productNo; OrdersModel order = orderList.Where(o => o.ProductNo == productNo).FirstOrDefault(); if (order != null) { dr["ETD"] = order.ETD; dr["ArticleNo"] = order.ArticleNo; dr["Quantity"] = order.Quantity; } List <String> sizeNoList = outsoleMaterialList.Where(o => o.ProductNo == productNo).Select(o => o.SizeNo).Distinct().ToList(); int qtyMaterialTotalToCheck = 0; for (int i = 0; i <= outsoleSupplierList.Count - 1; i++) { OutsoleSuppliersModel outsoleSupplier = outsoleSupplierList[i]; List <OutsoleMaterialModel> outsoleMaterialList_D2 = outsoleMaterialList_D1.Where(o => o.OutsoleSupplierId == outsoleSupplier.OutsoleSupplierId).ToList(); int qtyMaterialTotal = 0; int qtyReleaseTotal = 0; foreach (string sizeNo in sizeNoList) { int qtyMax = outsoleMaterialList_D2.Where(o => o.SizeNo == sizeNo).Sum(o => (o.Quantity - o.QuantityReject)); int qtyRelease = outsoleReleaseMaterialList_D1.Where(o => o.SizeNo == sizeNo).Sum(o => o.Quantity); int qtyMaterial = qtyMax - qtyRelease; if (qtyMaterial < 0) { qtyMaterial = 0; } qtyMaterialTotal += qtyMaterial; qtyMaterialTotalToCheck += qtyMaterial; qtyReleaseTotal += qtyRelease; } dr["Release"] = qtyReleaseTotal; dr[String.Format("Column{0}", i)] = qtyMaterialTotal; var outsoleMaterialDetailPerPOPerSupplierList = outsoleMaterialDetailPerPOList.Where(w => w.OutsoleSupplierId == outsoleSupplierList[i].OutsoleSupplierId).ToList(); if (outsoleMaterialDetailPerPOPerSupplierList.Count > 0) { int qtyMaterialDetail = outsoleMaterialDetailPerPOPerSupplierList.Sum(s => s.Quantity); if (qtyMaterialDetail != 0 && qtyMaterialDetail < order.Quantity) { dr[String.Format("Column{0}Background", i)] = Brushes.Yellow; } if (qtyMaterialDetail != 0 && qtyMaterialDetail >= order.Quantity) { dr[String.Format("Column{0}Background", i)] = Brushes.Green; } } } int qtyMatchingTotal = 0; foreach (string sizeNo in sizeNoList) { int qtyMin = outsoleMaterialList_D1.Where(o => o.SizeNo == sizeNo).Select(o => (o.Quantity - o.QuantityReject)).Min(); int qtyRelease = outsoleReleaseMaterialList_D1.Where(o => o.SizeNo == sizeNo).Sum(o => o.Quantity); int qtyMatching = qtyMin - qtyRelease; if (qtyMatching < 0) { qtyMatching = 0; } qtyMatchingTotal += qtyMatching; } dr["Matching"] = qtyMatchingTotal; if (qtyMaterialTotalToCheck != 0) { dt.Rows.Add(dr); } } TextBlock lblTotal = new TextBlock(); lblTotal.Text = "TOTAL"; lblTotal.Margin = new Thickness(1, 0, 0, 0); lblTotal.FontWeight = FontWeights.Bold; Border bdrTotal = new Border(); Grid.SetColumn(bdrTotal, 2); Grid.SetColumnSpan(bdrTotal, 3); bdrTotal.BorderThickness = new Thickness(1, 0, 1, 1); bdrTotal.BorderBrush = Brushes.Black; bdrTotal.Child = lblTotal; gridTotal.Children.Add(bdrTotal); TextBlock lblQuantityTotal = new TextBlock(); lblQuantityTotal.Text = dt.Compute("Sum(Quantity)", "").ToString(); lblQuantityTotal.Margin = new Thickness(1, 0, 0, 0); lblQuantityTotal.FontWeight = FontWeights.Bold; Border bdrQuantityTotal = new Border(); Grid.SetColumn(bdrQuantityTotal, 5); bdrQuantityTotal.BorderThickness = new Thickness(0, 0, 1, 1); bdrQuantityTotal.BorderBrush = Brushes.Black; bdrQuantityTotal.Child = lblQuantityTotal; gridTotal.Children.Add(bdrQuantityTotal); dgInventory.ItemsSource = dt.AsDataView(); TextBlock lblReleaseTotal = new TextBlock(); lblReleaseTotal.Text = dt.Compute("Sum(Release)", "").ToString(); lblReleaseTotal.Margin = new Thickness(1, 0, 0, 0); lblReleaseTotal.FontWeight = FontWeights.Bold; Border bdrReleaseTotal = new Border(); Grid.SetColumn(bdrReleaseTotal, 6); bdrReleaseTotal.BorderThickness = new Thickness(0, 0, 1, 1); bdrReleaseTotal.BorderBrush = Brushes.Black; bdrReleaseTotal.Child = lblReleaseTotal; gridTotal.Children.Add(bdrReleaseTotal); dgInventory.ItemsSource = dt.AsDataView(); for (int i = 0; i <= outsoleSupplierList.Count - 1; i++) { TextBlock lblSupplierTotal = new TextBlock(); lblSupplierTotal.Text = dt.Compute(String.Format("Sum(Column{0})", i), "").ToString(); lblSupplierTotal.Margin = new Thickness(1, 0, 0, 0); lblSupplierTotal.FontWeight = FontWeights.Bold; Border bdrSupplierTotal = new Border(); Grid.SetColumn(bdrSupplierTotal, 7 + i); bdrSupplierTotal.BorderThickness = new Thickness(0, 0, 1, 1); bdrSupplierTotal.BorderBrush = Brushes.Black; bdrSupplierTotal.Child = lblSupplierTotal; gridTotal.Children.Add(bdrSupplierTotal); } TextBlock lblMatchingTotal = new TextBlock(); lblMatchingTotal.Text = dt.Compute("Sum(Matching)", "").ToString(); lblMatchingTotal.Margin = new Thickness(1, 0, 0, 0); lblMatchingTotal.FontWeight = FontWeights.Bold; Border bdrMatchingTotal = new Border(); Grid.SetColumn(bdrMatchingTotal, 7 + outsoleSupplierList.Count()); bdrMatchingTotal.BorderThickness = new Thickness(0, 0, 1, 1); bdrMatchingTotal.BorderBrush = Brushes.Black; bdrMatchingTotal.Child = lblMatchingTotal; gridTotal.Children.Add(bdrMatchingTotal); dgInventory.ItemsSource = dt.AsDataView(); })); }
public Grid BuildCell( PosicaoHistorico paramUnidadeRastreada , View paramView = null , Boolean ShowStatusRastreadorUnidadeRastreada = false ) { try { Double margin = 15; #region Grid Grid boxPrincipal = new Grid(); boxPrincipal.WidthRequest = _app.ScreenWidth; boxPrincipal.ColumnSpacing = 0; boxPrincipal.RowSpacing = 0; boxPrincipal.VerticalOptions = LayoutOptions.FillAndExpand; boxPrincipal.ColumnDefinitions = new ColumnDefinitionCollection(); ColumnDefinition col01 = new ColumnDefinition() { Width = GridLength.Auto }; ColumnDefinition col03 = new ColumnDefinition() { Width = GridLength.Auto }; ColumnDefinition col02; col02 = new ColumnDefinition() { Width = GridLength.Star }; boxPrincipal.ColumnDefinitions.Add(col01); boxPrincipal.ColumnDefinitions.Add(col02); boxPrincipal.ColumnDefinitions.Add(col03); boxPrincipal.RowDefinitions = new RowDefinitionCollection(); boxPrincipal.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Star }); #endregion #region Frame Frame boxRegra = new Frame() { CornerRadius = 2, Margin = new Thickness(margin, margin, 0, margin), HasShadow = false, Padding = 0, Opacity = 1, WidthRequest = 27, BackgroundColor = Color.Transparent, OutlineColor = Color.Transparent, VerticalOptions = LayoutOptions.Fill }; if (!String.IsNullOrEmpty(paramUnidadeRastreada.NomeRegraViolada)) { boxRegra.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(BoxRegra_Tap), CommandParameter = paramUnidadeRastreada, NumberOfTapsRequired = 1 }); if (String.IsNullOrEmpty(paramUnidadeRastreada.CorRegraPrioritaria)) { boxRegra.BackgroundColor = Color.FromHex("#FF2E2F3A"); } else { boxRegra.BackgroundColor = Color.FromHex(paramUnidadeRastreada.CorRegraPrioritaria); } } boxPrincipal.Children.Add(boxRegra, 0, 0); #endregion #region Texto StackLayout boxTexto = new StackLayout() { Margin = new Thickness(margin), Spacing = 0, Orientation = StackOrientation.Vertical, WidthRequest = col02.Width.Value, VerticalOptions = LayoutOptions.Center }; if (paramUnidadeRastreada.OrdemRastreador == null) { paramUnidadeRastreada.OrdemRastreador = 0; } Label labelUnidadeRastreada = new Label() { Text = paramUnidadeRastreada.IdentificacaoUnidadeRastreada, TextColor = Color.Black, FontAttributes = FontAttributes.Bold, FontSize = 15, Margin = new Thickness(0, 0, 0, 2), LineBreakMode = LineBreakMode.TailTruncation, HorizontalTextAlignment = TextAlignment.Start }; if (paramUnidadeRastreada.StatusRastreadorUnidadeRastreada == (byte)EnumStatusUnidadeRastreada.Atualizada) { labelUnidadeRastreada.TextColor = Color.DarkGreen; } else { labelUnidadeRastreada.TextColor = Color.DarkRed; } boxTexto.Children.Add(labelUnidadeRastreada); Label labelDataEvento = new Label() { Text = String.Format( "{0:dd/MM/yyyy HH:mm:ss}" , paramUnidadeRastreada.DataEvento.Value.ToLocalTime() ), TextColor = Color.FromHex("#9b9eb0"), FontSize = 14, Margin = labelUnidadeRastreada.Margin, LineBreakMode = LineBreakMode.TailTruncation, HorizontalTextAlignment = TextAlignment.Start }; boxTexto.Children.Add(labelDataEvento); if (!String.IsNullOrWhiteSpace(paramUnidadeRastreada.ResponsavelUnidadeRastreada)) { Label labelMotorista = new Label() { Text = paramUnidadeRastreada.ResponsavelUnidadeRastreada, TextColor = Color.FromHex("#9b9eb0"), FontSize = 14, Margin = new Thickness(0), LineBreakMode = LineBreakMode.TailTruncation, HorizontalTextAlignment = TextAlignment.Start }; boxTexto.Children.Add(labelMotorista); } StackLayout boxImagemUnidade = new StackLayout() { Margin = new Thickness(15, 0, 0, 0), Spacing = 0, Orientation = StackOrientation.Horizontal, WidthRequest = col01.Width.Value, VerticalOptions = LayoutOptions.Start }; String sourceImageUnidade = String.Empty; if (!String.IsNullOrEmpty(paramUnidadeRastreada.IconePadrao)) { sourceImageUnidade = paramUnidadeRastreada.IconePadrao; } Image ImageUnidade = new Image() { Source = sourceImageUnidade, //BackgroundColor = Color.Black, //HeightRequest = 15, //WidthRequest = 16, Margin = new Thickness(35, 0, margin, 0), Opacity = 1, VerticalOptions = LayoutOptions.Center, Scale = 3.5 }; boxPrincipal.Children.Add(ImageUnidade, 0, 0); boxPrincipal.Children.Add(boxTexto, 1, 0); #endregion #region Image String sourceImage = String.Empty; //Muda icone de ignicao if (paramUnidadeRastreada.Ignicao == true) { sourceImage = "ic_ignition_on.png"; } if (paramUnidadeRastreada.Ignicao == false) { sourceImage = "ic_ignition_off.png"; } Image ImageIgnicao = new Image() { Source = sourceImage, HeightRequest = 15, WidthRequest = 16, Margin = new Thickness(0, 0, margin, 0), Opacity = 1, VerticalOptions = LayoutOptions.Center }; if (paramUnidadeRastreada.Ignicao.HasValue) { if (paramUnidadeRastreada.Ignicao.Value == false) { ImageIgnicao.Opacity = 0.5f; } } else { ImageIgnicao.Opacity = 0; } StackLayout stack = new StackLayout(); stack.Orientation = StackOrientation.Horizontal; stack.HorizontalOptions = LayoutOptions.End; stack.Margin = new Thickness(0, 25, 0, 0); stack.Children.Add(ImageIgnicao); if (paramView != null) { stack.Children.Add(paramView); } boxPrincipal.Children.Add(stack, 1, 0); #endregion return(boxPrincipal); } catch { throw; } }
private void StartPreviewDragging(Windows.UI.Xaml.Input.PointerRoutedEventArgs e) { _isDraggingPreview = true; _previewPopup = new Popup { Width = _parentGrid.ActualWidth, Height = _parentGrid.ActualHeight }; _previewPopup.IsOpen = true; _previewPopupHostGrid = new Grid { VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Stretch, HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch }; _parentGrid.Children.Add(_previewPopupHostGrid); if (_parentGrid.RowDefinitions.Count > 0) { Grid.SetRowSpan(_previewPopupHostGrid, _parentGrid.RowDefinitions.Count); } if (_parentGrid.ColumnDefinitions.Count > 0) { Grid.SetColumnSpan(_previewPopupHostGrid, _parentGrid.ColumnDefinitions.Count); } _previewPopupHostGrid.Children.Add(_previewPopup); _previewGrid = new Grid { Width = _parentGrid.ActualWidth, Height = _parentGrid.ActualHeight }; _previewPopup.Child = _previewGrid; foreach (var definition in _parentGrid.RowDefinitions) { var definitionCopy = new RowDefinition { Height = definition.Height, MaxHeight = definition.MaxHeight, MinHeight = definition.MinHeight }; _previewGrid.RowDefinitions.Add(definitionCopy); } foreach (var definition in _parentGrid.ColumnDefinitions) { var w = definition.Width; var mxw = definition.MaxWidth; var mnw = definition.MinWidth; var definitionCopy = new ColumnDefinition(); definitionCopy.Width = w; definition.MinWidth = mnw; if (!double.IsInfinity(definition.MaxWidth)) { definition.MaxWidth = mxw; } //{ // Width = definition.Width, // MaxWidth = definition.MaxWidth, // MinWidth = definition.MinWidth //}; _previewGrid.ColumnDefinitions.Add(definitionCopy); } _previewGridSplitter = new CustomGridSplitter { Opacity = 0.0, ShowsPreview = false, Width = this.Width, Height = this.Height, Margin = this.Margin, VerticalAlignment = this.VerticalAlignment, HorizontalAlignment = this.HorizontalAlignment, ResizeBehavior = this.ResizeBehavior, ResizeDirection = this.ResizeDirection, KeyboardIncrement = this.KeyboardIncrement }; Grid.SetColumn(_previewGridSplitter, Grid.GetColumn(this)); var cs = Grid.GetColumnSpan(this); if (cs > 0) { Grid.SetColumnSpan(_previewGridSplitter, cs); } Grid.SetRow(_previewGridSplitter, Grid.GetRow(this)); var rs = Grid.GetRowSpan(this); if (rs > 0) { Grid.SetRowSpan(_previewGridSplitter, rs); } _previewGrid.Children.Add(_previewGridSplitter); _previewControlBorder = new Border { Width = this.Width, Height = this.Height, Margin = this.Margin, VerticalAlignment = this.VerticalAlignment, HorizontalAlignment = this.HorizontalAlignment, }; Grid.SetColumn(_previewControlBorder, Grid.GetColumn(this)); if (cs > 0) { Grid.SetColumnSpan(_previewControlBorder, cs); } Grid.SetRow(_previewControlBorder, Grid.GetRow(this)); if (rs > 0) { Grid.SetRowSpan(_previewControlBorder, rs); } _previewGrid.Children.Add(_previewControlBorder); _previewControl = new GridSplitterPreviewControl(); if (this.PreviewStyle != null) { _previewControl.Style = this.PreviewStyle; } _previewControlBorder.Child = _previewControl; _previewPopup.Child = _previewGrid; //await this.previewGridSplitter.WaitForLoadedAsync(); //this.previewGridSplitter.OnPointerPressed(e); _previewGridSplitter._dragPointer = e.Pointer.PointerId; _previewGridSplitter._effectiveResizeDirection = this.DetermineEffectiveResizeDirection(); _previewGridSplitter._parentGrid = _previewGrid; _previewGridSplitter._lastPosition = e.GetCurrentPoint(_previewGrid).Position; _previewGridSplitter._isDragging = true; _previewGridSplitter.StartDirectDragging(e); _previewGridSplitter.DraggingCompleted += PreviewGridSplitter_DraggingCompleted; }
private void Page_Loaded(object sender, RoutedEventArgs e) { try { JObject obj = Lang.Translated(); Dispatcher.BeginInvoke(new ThreadStart(delegate { lbLocales.Items.Clear(); })); if (obj != null) { foreach (var lang in obj) { Dispatcher.BeginInvoke(new ThreadStart(delegate { Grid grid = new Grid(); grid.Width = double.NaN; grid.Margin = new Thickness(0); grid.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; ColumnDefinition cd1 = new ColumnDefinition(); ColumnDefinition cd2 = new ColumnDefinition(); cd1.Width = new GridLength(1, GridUnitType.Auto); cd2.Width = new GridLength(1, GridUnitType.Star); grid.ColumnDefinitions.Add(cd1); grid.ColumnDefinitions.Add(cd2); Image img = new Image(); img.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; img.VerticalAlignment = System.Windows.VerticalAlignment.Center; img.Height = 20; img.Width = 20; img.Margin = new Thickness(10, 10, 5, 10); img.Source = new BitmapImage(new Uri(String.Format(@"pack://application:,,,/{0};component/Resources/flag_{1}.png", (string)MainWindow.JsonSettingsGet("info.ProductName"), (string)lang.Key))); TextBlock tb = new TextBlock(); tb.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; tb.VerticalAlignment = System.Windows.VerticalAlignment.Center; tb.Margin = new Thickness(5, 10, 10, 10); tb.TextWrapping = TextWrapping.NoWrap; tb.FontWeight = FontWeights.Bold; tb.FontSize = 14; tb.Text = ((string)lang.Value).Remove(0, 3); Grid.SetColumn(tb, 1); grid.Children.Add(img); grid.Children.Add(tb); ListBoxItem lbi = new ListBoxItem(); lbi.IsSelected = (string)lang.Key == (string)MainWindow.JsonSettingsGet("info.language"); lbi.VerticalAlignment = System.Windows.VerticalAlignment.Center; lbi.Cursor = Cursors.Hand; lbi.Content = grid; lbi.Name = (string)lang.Key; this.RegisterName(lbi.Name, lbi); lbLocales.Items.Add(lbi); })); } } } catch (Exception ex) { Debugging.Save("ChangeLocale.xaml", "Page_Loaded", ex.Message, ex.StackTrace); } Dispatcher.BeginInvoke(new ThreadStart(delegate { try { MainWindow.LoadPage.Visibility = Visibility.Hidden; } catch (Exception ex) { Task.Factory.StartNew(() => Debugging.Save("ChangeLocale.xaml", "Page_Loaded", ex.Message, ex.StackTrace)); } })); }
public FloatingObjectContainer(Dt.Cells.Data.FloatingObject floatingObject, CellsPanel parentViewport) { _floatingObject = floatingObject; base.Visibility = floatingObject.Visible ? Visibility.Visible : Visibility.Collapsed; ParentViewport = parentViewport; Loaded += FloatingObjectContainer_Loaded; _outBorder = new Border(); _outBorder.BorderBrush = BorderBrush; _outBorder.Background = BorderGapBrush; _outBorder.BorderThickness = new Thickness(2.0); _outBorder.CornerRadius = new Windows.UI.Xaml.CornerRadius(5.0); base.Children.Add(_outBorder); _glyphGrid = new Grid(); base.Children.Add(_glyphGrid); RowDefinition definition = new RowDefinition(); definition.Height = new Windows.UI.Xaml.GridLength(7.0); _glyphGrid.RowDefinitions.Add(definition); _glyphGrid.RowDefinitions.Add(new RowDefinition()); RowDefinition definition2 = new RowDefinition(); definition2.Height = new Windows.UI.Xaml.GridLength(7.0); _glyphGrid.RowDefinitions.Add(definition2); ColumnDefinition definition3 = new ColumnDefinition(); definition3.Width = new Windows.UI.Xaml.GridLength(7.0); _glyphGrid.ColumnDefinitions.Add(definition3); _glyphGrid.ColumnDefinitions.Add(new ColumnDefinition()); ColumnDefinition definition4 = new ColumnDefinition(); definition4.Width = new Windows.UI.Xaml.GridLength(7.0); _glyphGrid.ColumnDefinitions.Add(definition4); _leftRect = new Rectangle(); _leftRect.Margin = new Thickness(-1.0, 0.0, 1.0, 0.0); _leftRect.Fill = BorderGapBrush; _glyphGrid.Children.Add(_leftRect); Grid.SetColumn(_leftRect, 0); Grid.SetRowSpan(_leftRect, 3); _topRect = new Rectangle(); _topRect.Margin = new Thickness(0.0, -1.0, 0.0, 1.0); _topRect.Fill = BorderGapBrush; _glyphGrid.Children.Add(_topRect); Grid.SetRow(_topRect, 0); Grid.SetColumnSpan(_topRect, 3); _rightRect = new Rectangle(); _rightRect.Margin = new Thickness(1.0, 0.0, -1.0, 0.0); _rightRect.Fill = BorderGapBrush; _glyphGrid.Children.Add(_rightRect); Grid.SetColumn(_rightRect, 2); Grid.SetRowSpan(_rightRect, 3); _bottomRect = new Rectangle(); _bottomRect.Margin = new Thickness(0.0, 1.0, 0.0, -1.0); _bottomRect.Fill = BorderGapBrush; _glyphGrid.Children.Add(_bottomRect); Grid.SetRow(_bottomRect, 2); Grid.SetColumnSpan(_bottomRect, 3); _topLeftRect = new Image(); _topLeftRect.Width = 7.0; _topLeftRect.Height = 7.0; _glyphGrid.Children.Add(_topLeftRect); Grid.SetRow(_topLeftRect, 0); Grid.SetColumn(_topLeftRect, 0); _topCentertRect = new Image(); _topCentertRect.Width = 15.0; _topCentertRect.Height = 3.0; _topCentertRect.VerticalAlignment = VerticalAlignment.Top; _glyphGrid.Children.Add(_topCentertRect); Grid.SetRow(_topCentertRect, 0); Grid.SetColumn(_topCentertRect, 1); _topRightRect = new Image(); _topRightRect.Width = 7.0; _topRightRect.Height = 7.0; _glyphGrid.Children.Add(_topRightRect); Grid.SetRow(_topRightRect, 0); Grid.SetColumn(_topRightRect, 2); _middleLeftRect = new Image(); _middleLeftRect.Width = 3.0; _middleLeftRect.Height = 15.0; _middleLeftRect.HorizontalAlignment = HorizontalAlignment.Left; _glyphGrid.Children.Add(_middleLeftRect); Grid.SetRow(_middleLeftRect, 1); Grid.SetColumn(_middleLeftRect, 0); _middleRightRect = new Image(); _middleRightRect.Width = 3.0; _middleRightRect.Height = 15.0; _middleRightRect.HorizontalAlignment = HorizontalAlignment.Right; _glyphGrid.Children.Add(_middleRightRect); Grid.SetRow(_middleRightRect, 1); Grid.SetColumn(_middleRightRect, 2); _bottomLeftRect = new Image(); _bottomLeftRect.Width = 7.0; _bottomLeftRect.Height = 7.0; _glyphGrid.Children.Add(_bottomLeftRect); Grid.SetRow(_bottomLeftRect, 2); Grid.SetColumn(_bottomLeftRect, 0); _bottomCenterRect = new Image(); _bottomCenterRect.Width = 15.0; _bottomCenterRect.Height = 3.0; _bottomCenterRect.VerticalAlignment = VerticalAlignment.Bottom; _glyphGrid.Children.Add(_bottomCenterRect); Grid.SetRow(_bottomCenterRect, 2); Grid.SetColumn(_bottomCenterRect, 1); _bottomRightRect = new Image(); _bottomRightRect.Width = 7.0; _bottomRightRect.Height = 7.0; _glyphGrid.Children.Add(_bottomRightRect); Grid.SetRow(_bottomRightRect, 2); Grid.SetColumn(_bottomRightRect, 2); LoadImages(); _innerBorder = new Border(); _innerBorder.BorderBrush = BorderBrush; _innerBorder.BorderThickness = new Thickness(2.0); _innerBorder.CornerRadius = new Windows.UI.Xaml.CornerRadius(10.0); Children.Add(_innerBorder); _contentPanel = new Border(); _contentPanel.Background = new SolidColorBrush(Colors.Transparent); Children.Add(_contentPanel); _defaultContent = new Border(); _contentPanel.Child = _defaultContent; UpdateElements(false); }
private static bool IsStarColumn(ColumnDefinition definition) { return(((GridLength)definition.GetValue(ColumnDefinition.WidthProperty)).IsStar); }
void chart_Loaded(object sender, RoutedEventArgs e) { Chart chart = sender as Chart; chart.ColorSet = "Visifire1"; if (chart != null) { // 新建一个 ColorSet 集合 ColorSets emcs = new ColorSets(); string resourceName = "Visifire.Charts.ColorSets.xaml"; // Visifire 默认颜色集合的文件 using (System.IO.Stream s = typeof(Chart).Assembly.GetManifestResourceStream(resourceName)) { if (s != null) { System.IO.StreamReader reader = new System.IO.StreamReader(s); String xaml = reader.ReadToEnd(); emcs = System.Windows.Markup.XamlReader.Load(xaml) as ColorSets; reader.Close(); s.Close(); } } // 根据名称取得 Chart 的 ColorSet ( Chart 的 ColorSet 属性为颜色集的名称 ) ColorSet cs = emcs.GetColorSetByName(chart.ColorSet); // 显示图例的 StackPanel StackPanel sp = new StackPanel() { Orientation = Orientation.Horizontal, VerticalAlignment = System.Windows.VerticalAlignment.Top, HorizontalAlignment = System.Windows.HorizontalAlignment.Center }; // 图例文本 string[] legendText = { "离异", "已婚", "未婚" }; // 自定义图例 for (int i = 0; i < chart.Series[0].DataPoints.Count; i++) { Grid grid = new Grid(); grid.Margin = new Thickness(15, 0, 0, 0); ColumnDefinition cd1 = new ColumnDefinition(); grid.ColumnDefinitions.Add(cd1); ColumnDefinition cd2 = new ColumnDefinition(); grid.ColumnDefinitions.Add(cd2); Rectangle rect = new Rectangle() { Width = 10, Height = 10, Fill = cs.Brushes[i] }; rect.SetValue(Grid.ColumnProperty, 0); grid.Children.Add(rect); TextBlock tb = new TextBlock() { Text = legendText[i], Margin = new Thickness(5, 0, 0, 0), Foreground = cs.Brushes[i] }; tb.SetValue(Grid.ColumnProperty, 1); grid.Children.Add(tb); sp.Children.Add(grid); } ReportChartList.Children.Add(sp); } }
private Row CompareRows(Table targetTable, Row targetRow, Row updatedRow, out RowOperation operation, out bool keepRow) { Row comparedRow = null; keepRow = false; operation = RowOperation.None; if (null == targetRow ^ null == updatedRow) { if (null == targetRow) { operation = updatedRow.Operation = RowOperation.Add; comparedRow = updatedRow; } else if (null == updatedRow) { operation = targetRow.Operation = RowOperation.Delete; targetRow.SectionId = targetRow.SectionId + sectionDelimiter; comparedRow = targetRow; keepRow = true; } } else // possibly modified { updatedRow.Operation = RowOperation.None; if (!this.suppressKeepingSpecialRows && "_SummaryInformation" == targetTable.Name) { // ignore rows that shouldn't be in a transform if (Enum.IsDefined(typeof(SummaryInformation.Transform), (int)updatedRow[0])) { updatedRow.SectionId = targetRow.SectionId + sectionDelimiter + updatedRow.SectionId; comparedRow = updatedRow; keepRow = true; operation = RowOperation.Modify; } } else { if (this.preserveUnchangedRows) { keepRow = true; } for (int i = 0; i < updatedRow.Fields.Length; i++) { ColumnDefinition columnDefinition = updatedRow.Fields[i].Column; if (!columnDefinition.PrimaryKey) { bool modified = false; if (i >= targetRow.Fields.Length) { columnDefinition.Added = true; modified = true; } else if (ColumnType.Number == columnDefinition.Type && !columnDefinition.IsLocalizable) { if (null == targetRow[i] ^ null == updatedRow[i]) { modified = true; } else if (null != targetRow[i] && null != updatedRow[i]) { modified = ((int)targetRow[i] != (int)updatedRow[i]); } } else if (ColumnType.Preserved == columnDefinition.Type) { updatedRow.Fields[i].PreviousData = (string)targetRow.Fields[i].Data; // keep rows containing preserved fields so the historical data is available to the binder keepRow = !this.suppressKeepingSpecialRows; } else if (ColumnType.Object == columnDefinition.Type) { ObjectField targetObjectField = (ObjectField)targetRow.Fields[i]; ObjectField updatedObjectField = (ObjectField)updatedRow.Fields[i]; updatedObjectField.PreviousEmbeddedFileIndex = targetObjectField.EmbeddedFileIndex; updatedObjectField.PreviousBaseUri = targetObjectField.BaseUri; // always keep a copy of the previous data even if they are identical // This makes diff.wixmst clean and easier to control patch logic updatedObjectField.PreviousData = (string)targetObjectField.Data; // always remember the unresolved data for target build updatedObjectField.UnresolvedPreviousData = (string)targetObjectField.UnresolvedData; // keep rows containing object fields so the files can be compared in the binder keepRow = !this.suppressKeepingSpecialRows; } else { modified = ((string)targetRow[i] != (string)updatedRow[i]); } if (modified) { if (null != updatedRow.Fields[i].PreviousData) { updatedRow.Fields[i].PreviousData = targetRow.Fields[i].Data.ToString(); } updatedRow.Fields[i].Modified = true; operation = updatedRow.Operation = RowOperation.Modify; keepRow = true; } } } if (keepRow) { comparedRow = updatedRow; comparedRow.SectionId = targetRow.SectionId + sectionDelimiter + updatedRow.SectionId; } } } return(comparedRow); }
void AddGridHeader(Grid grid, List <Column> ls, int rowindex, ref int colSpan, ref int colIndex, List <Column> colNodes, int maxLayer) { if (ls.Count > 0) { if (rowindex == grid.RowDefinitions.Count) { RowDefinition hRow = new RowDefinition(); hRow.Height = GridLength.Auto; grid.RowDefinitions.Add(hRow); } for (int i = 0; i < ls.Count; i++) { Column col = ls[i]; TextBlock tb = new TextBlock() { Text = col.Text, FontWeight = FontWeights.Bold, FontSize = this.FontSize, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Margin = CellPadding, TextWrapping = this.TextWrap }; grid.Children.Add(tb); Grid.SetRow(tb, rowindex); Rectangle line = new Rectangle() { Width = 1, StrokeThickness = 0.5, Stroke = new SolidColorBrush(Colors.LightGray), HorizontalAlignment = HorizontalAlignment.Right }; //竖线 grid.Children.Add(line); Grid.SetRow(line, rowindex); Grid.SetColumn(line, colIndex); //横线 Rectangle line2 = new Rectangle() { Height = 1, StrokeThickness = 0.5, Stroke = new SolidColorBrush(Colors.LightGray), VerticalAlignment = VerticalAlignment.Bottom }; grid.Children.Add(line2); Grid.SetRow(line2, rowindex); int pcolSpan = colSpan; Grid.SetColumn(tb, colIndex); Grid.SetColumn(line2, colIndex); if (col.Columns.Count > 0) { AddGridHeader(grid, col.Columns, rowindex + 1, ref colSpan, ref colIndex, colNodes, maxLayer); if (colSpan > pcolSpan) { int cspan = colSpan - pcolSpan; Grid.SetColumnSpan(tb, cspan); Grid.SetColumnSpan(line, cspan); Grid.SetColumnSpan(line2, cspan); } } else { colNodes.Add(col); colSpan++; ColumnDefinition colDef = new ColumnDefinition(); colDef.Width = col.Width; grid.ColumnDefinitions.Add(colDef); if (maxLayer > rowindex + 1) { int rspan = maxLayer - rowindex; tb.VerticalAlignment = VerticalAlignment.Center; Grid.SetRowSpan(tb, rspan); Grid.SetRowSpan(line, rspan); Grid.SetRowSpan(line2, rspan); } colIndex++; } } } }
private void AddItem(string name, object value, string bindingName) { Func <ComboBoxItem, bool> predicate = null; Type type = value.GetType(); Grid element = new Grid { Margin = new Thickness(0.0, 0.0, 0.0, 10.0) }; ColumnDefinition definition4 = new ColumnDefinition { Width = new GridLength(126.0) }; element.ColumnDefinitions.Add(definition4); ColumnDefinition definition5 = new ColumnDefinition { Width = new GridLength(1.0, GridUnitType.Star) }; element.ColumnDefinitions.Add(definition5); TextBlock block = new TextBlock { Text = name, Foreground = System.Windows.Media.Brushes.White }; element.Children.Add(block); if (((type == typeof(double)) || (type == typeof(int))) || ((type == typeof(float)) || (type == typeof(Thickness)))) { Binding binding = new Binding(bindingName) { Mode = BindingMode.TwoWay }; TextBox textBox = new TextBox(); textBox.TextChanged += delegate(object o, TextChangedEventArgs e) { foreach (char ch in textBox.Text) { switch (ch) { case ',': case '.': return; } } textBox.Text = new string((from c in textBox.Text where char.IsDigit(c) select c).ToArray <char>()); textBox.SelectionStart = textBox.Text.Length; }; textBox.Text = value.ToString(); Grid.SetColumn(textBox, 1); textBox.SetBinding(TextBox.TextProperty, binding); element.Children.Add(textBox); } else if (type == typeof(SolidColorBrush)) { Binding binding2 = new Binding(bindingName) { Mode = BindingMode.TwoWay, Converter = base.Resources["brushToColorConverter"] as BrushToColorConverter }; ColorComboBox box = new ColorComboBox { Margin = new Thickness(0.0, -4.0, 0.0, 4.0) }; Grid.SetColumn(box, 1); box.SetBinding(ColorComboBox.SelectedColorProperty, binding2); element.Children.Add(box); } else { if (type == typeof(string)) { Grid grid2 = new Grid { Margin = new Thickness(0.0, 0.0, 0.0, 10.0) }; ColumnDefinition definition = new ColumnDefinition { Width = new GridLength(0.3, GridUnitType.Star) }; grid2.ColumnDefinitions.Add(definition); ColumnDefinition definition2 = new ColumnDefinition { Width = new GridLength(1.0, GridUnitType.Auto) }; grid2.ColumnDefinitions.Add(definition2); ColumnDefinition definition3 = new ColumnDefinition { Width = new GridLength(0.3, GridUnitType.Star) }; grid2.ColumnDefinitions.Add(definition3); Grid grid3 = new Grid { Height = 1.0, Background = System.Windows.Media.Brushes.White }; Grid.SetColumn(grid3, 0); Grid grid4 = new Grid { Height = 1.0, Background = System.Windows.Media.Brushes.White }; Grid.SetColumn(grid4, 2); TextBlock block2 = new TextBlock { Text = value.ToString(), Foreground = System.Windows.Media.Brushes.White, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(5.0, 0.0, 5.0, 0.0) }; Grid.SetColumn(block2, 1); grid2.Children.Add(grid3); grid2.Children.Add(grid4); grid2.Children.Add(block2); this.spEditor.Children.Add(grid2); return; } if (type == typeof(System.Windows.Media.FontFamily)) { Binding binding3 = new Binding(bindingName) { Mode = BindingMode.TwoWay }; List <ComboBoxItem> list = (from f in new InstalledFontCollection().Families select new ComboBoxItem { Content = f.Name, HorizontalContentAlignment = HorizontalAlignment.Stretch, VerticalContentAlignment = VerticalAlignment.Stretch, FontFamily = new System.Windows.Media.FontFamily(f.Name) }).ToList <ComboBoxItem>(); ComboBox combo = new ComboBox { ItemsSource = list }; combo.SetBinding(Control.FontFamilyProperty, binding3); combo.SelectionChanged += delegate(object o, SelectionChangedEventArgs e) { if (combo.SelectedItem != null) { ComboBoxItem selectedItem = (ComboBoxItem)combo.SelectedItem; combo.FontFamily = selectedItem.FontFamily; } }; if (predicate == null) { predicate = c => c.FontFamily.ToString() == value.ToString(); } combo.SelectedItem = combo.Items.Cast <ComboBoxItem>().FirstOrDefault <ComboBoxItem>(predicate); Grid.SetColumn(combo, 1); element.Children.Add(combo); } else if (type == typeof(FontWeight)) { Binding binding4 = new Binding(bindingName) { Mode = BindingMode.TwoWay }; ComboBox combo = new ComboBox { ItemsSource = base.Resources["fontWeights"] as FontWeight[] }; combo.SetBinding(Control.FontWeightProperty, binding4); combo.SelectionChanged += delegate(object o, SelectionChangedEventArgs e) { if (combo.SelectedItem != null) { combo.FontWeight = (FontWeight)combo.SelectedItem; } }; combo.SelectedItem = (FontWeight)value; Grid.SetColumn(combo, 1); element.Children.Add(combo); } } this.spEditor.Children.Add(element); }
public static Grid GetBackground() { Grid grid = new Grid(); grid.Width = 85; grid.Height = 65; for (int a = 0; a < 6; a++) { ColumnDefinition cd = new ColumnDefinition(); cd.Width = new GridLength(1, GridUnitType.Star); grid.ColumnDefinitions.Add(cd); } for (int b = 0; b < 5; b++) { RowDefinition rd = new RowDefinition(); rd.Height = new GridLength(1, GridUnitType.Star); grid.RowDefinitions.Add(rd); } for (int i = 0; i < 6; i++) { for (int j = 0; j < 5; j++) { if (i == 5 && j == 4) { CustomBorder cborder = new CustomBorder(); cborder.LeftBorderBrush = new SolidColorBrush(Colors.Black); cborder.RightBorderBrush = new SolidColorBrush(Colors.Red); cborder.TopBorderBrush = new SolidColorBrush(Colors.Black); cborder.BottomBorderBrush = new SolidColorBrush(Colors.Black); cborder.BorderThickness = new Thickness(0, 0, 2, 2); grid.Children.Add(cborder); Grid.SetColumn(cborder, i); Grid.SetRow(cborder, j); } else if (i == 5) { CustomBorder cborder = new CustomBorder(); cborder.LeftBorderBrush = new SolidColorBrush(Colors.Black); cborder.RightBorderBrush = new SolidColorBrush(Colors.Red); cborder.TopBorderBrush = new SolidColorBrush(Colors.Black); cborder.BottomBorderBrush = new SolidColorBrush(Colors.Black); cborder.BorderThickness = new Thickness(0, 0, 2, 1); grid.Children.Add(cborder); Grid.SetColumn(cborder, i); Grid.SetRow(cborder, j); } else if (j == 4) { Border border = new Border(); border.BorderBrush = new SolidColorBrush(Colors.Black); border.BorderThickness = new Thickness(0, 0, 1, 2); grid.Children.Add(border); Grid.SetColumn(border, i); Grid.SetRow(border, j); } else { Border border = new Border(); border.BorderBrush = new SolidColorBrush(Colors.Black); border.BorderThickness = new Thickness(0, 0, 1, 1); grid.Children.Add(border); Grid.SetColumn(border, i); Grid.SetRow(border, j); } } } return(grid); }
public UserColumn(IContextEntry context, ColumnDefinition definition, IConfig config, IStreamParser parser) : base(context, definition, config, parser) { UserId = definition.TargetAccounts.First(); SubTitle = ""; }
void CreateMatrix() { btnMatrixCellArray = new Button[maxRowLength, maxColLength]; eWDecode.btnMatrixCellArray = new Button[maxRowLength, maxColLength]; timeMatrixCellArray = new int[maxRowLength, maxColLength]; numberOfHintArray = new int[maxRowLength, maxColLength]; for (int i = 0; i <= maxColLength; i++) { ColumnDefinition columnDefinition = new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }; ColumnDefinition eWColumnDefinition = new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }; eWDecode.gridMatrixTable.ColumnDefinitions.Add(eWColumnDefinition); gridMatrixTable.ColumnDefinitions.Add(columnDefinition); } for (int i = 0; i <= maxRowLength; i++) { RowDefinition rowDefinition = new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }; RowDefinition eWRowDefinition = new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }; eWDecode.gridMatrixTable.RowDefinitions.Add(rowDefinition); gridMatrixTable.RowDefinitions.Add(eWRowDefinition); } for (int i = 1; i <= maxColLength; i++) { Viewbox viewboxColumnName = new Viewbox { Child = new TextBlock { Foreground = Brushes.White, FontFamily = new FontFamily("Open Sans"), Text = (char)(64 + i) + "" } }; viewboxColumnName.SetValue(Grid.ColumnProperty, i); viewboxColumnName.SetValue(Grid.RowProperty, 0); gridMatrixTable.Children.Add(viewboxColumnName); Viewbox eWViewboxColumnName = new Viewbox { Child = new TextBlock { Foreground = Brushes.White, FontFamily = new FontFamily("Open Sans"), Text = (char)(64 + i) + "" } }; eWViewboxColumnName.SetValue(Grid.ColumnProperty, i); eWViewboxColumnName.SetValue(Grid.RowProperty, 0); eWDecode.gridMatrixTable.Children.Add(eWViewboxColumnName); } for (int i = 1; i <= maxRowLength; i++) { Viewbox viewboxColumnName = new Viewbox { Child = new TextBlock { Foreground = Brushes.White, FontFamily = new FontFamily("Open Sans"), Text = i.ToString() } }; viewboxColumnName.SetValue(Grid.ColumnProperty, 0); viewboxColumnName.SetValue(Grid.RowProperty, i); gridMatrixTable.Children.Add(viewboxColumnName); Viewbox eWViewboxColumnName = new Viewbox { Child = new TextBlock { Foreground = Brushes.White, FontFamily = new FontFamily("Open Sans"), Text = i.ToString() } }; eWViewboxColumnName.SetValue(Grid.ColumnProperty, 0); eWViewboxColumnName.SetValue(Grid.RowProperty, i); eWDecode.gridMatrixTable.Children.Add(eWViewboxColumnName); } for (int i = 0; i < maxRowLength; i++) { for (int j = 0; j < maxColLength; j++) { btnMatrixCellArray[i, j] = new Button { BorderThickness = new Thickness(1.5), BorderBrush = Brushes.Black, Name = string.Format("Matrix_{0}_{1}", i, j), Background = Brushes.White, FontSize = 40, FontFamily = new FontFamily("Open Sans"), Content = string.Empty }; btnMatrixCellArray[i, j].SetValue(Grid.RowProperty, i + 1); btnMatrixCellArray[i, j].SetValue(Grid.ColumnProperty, j + 1); gridMatrixTable.Children.Add(btnMatrixCellArray[i, j]); eWDecode.btnMatrixCellArray[i, j] = new Button { BorderThickness = new Thickness(1.5), BorderBrush = Brushes.Black, Name = string.Format("Matrix_{0}_{1}", i, j), Background = Brushes.White, FontSize = 40, FontFamily = new FontFamily("Open Sans"), Content = string.Empty }; eWDecode.btnMatrixCellArray[i, j].SetValue(Grid.RowProperty, i + 1); eWDecode.btnMatrixCellArray[i, j].SetValue(Grid.ColumnProperty, j + 1); eWDecode.gridMatrixTable.Children.Add(eWDecode.btnMatrixCellArray[i, j]); timeMatrixCellArray[i, j] = 0; numberOfHintArray[i, j] = 0; } } Brush[] colorOfCell = { Brushes.Green, Brushes.Yellow, Brushes.Red }; for (int i = 1; i < decodeQuestionList.Count; i++) { int difficulty = decodeQuestionList[i].QuestionTypeID / 10 - 1; int row = decodeQuestionList[i].RowNo; int col = decodeQuestionList[i].ColNo; btnMatrixCellArray[row, col].Background = colorOfCell[difficulty]; eWDecode.btnMatrixCellArray[row, col].Background = colorOfCell[difficulty]; if (decodeQuestionList[i].QuestionTypeID % 10 == 1) { timeMatrixCellArray[row, col] = 15 + 5 * difficulty; btnMatrixCellArray[row, col].Uid = "Decode_ImgQuestionIcon.png"; } else { timeMatrixCellArray[row, col] = 10; numberOfHint++; btnMatrixCellArray[row, col].Uid = "Decode_ImgHintIcon.png"; Image hintImage = new Image(); mediaAct.Upload(hintImage, decodeQuestionList[i].QuestionImageName); hintImage.Stretch = Stretch.Fill; hintImageList.Add(hintImage); hintImage.Visibility = Visibility.Hidden; } btnMatrixCellArray[row, col].Click += BtnMatrixCell_Click; } SetUpNumberOfHint(); }
protected override void WriteIdentity(ColumnDefinition col) { Builder.Append(" primary key autoincrement"); }
private void InitializeComponent() { Binding binding__OwnedWindowsContent = new Binding("Windows"); this.SetBinding(UIRoot.OwnedWindowsContentProperty, binding__OwnedWindowsContent); InitializeElementResources(this); // e_0 element this.e_0 = new DockPanel(); this.Content = this.e_0; this.e_0.Name = "e_0"; // e_1 element this.e_1 = new Grid(); this.e_0.Children.Add(this.e_1); this.e_1.Name = "e_1"; RowDefinition row_e_1_0 = new RowDefinition(); row_e_1_0.Height = new GridLength(100F, GridUnitType.Pixel); this.e_1.RowDefinitions.Add(row_e_1_0); RowDefinition row_e_1_1 = new RowDefinition(); row_e_1_1.Height = new GridLength(20F, GridUnitType.Pixel); this.e_1.RowDefinitions.Add(row_e_1_1); RowDefinition row_e_1_2 = new RowDefinition(); row_e_1_2.Height = new GridLength(50F, GridUnitType.Pixel); this.e_1.RowDefinitions.Add(row_e_1_2); RowDefinition row_e_1_3 = new RowDefinition(); row_e_1_3.Height = new GridLength(50F, GridUnitType.Pixel); this.e_1.RowDefinitions.Add(row_e_1_3); RowDefinition row_e_1_4 = new RowDefinition(); row_e_1_4.Height = new GridLength(50F, GridUnitType.Pixel); this.e_1.RowDefinitions.Add(row_e_1_4); RowDefinition row_e_1_5 = new RowDefinition(); row_e_1_5.Height = new GridLength(50F, GridUnitType.Pixel); this.e_1.RowDefinitions.Add(row_e_1_5); RowDefinition row_e_1_6 = new RowDefinition(); row_e_1_6.Height = new GridLength(50F, GridUnitType.Pixel); this.e_1.RowDefinitions.Add(row_e_1_6); RowDefinition row_e_1_7 = new RowDefinition(); row_e_1_7.Height = new GridLength(50F, GridUnitType.Pixel); this.e_1.RowDefinitions.Add(row_e_1_7); RowDefinition row_e_1_8 = new RowDefinition(); row_e_1_8.Height = new GridLength(50F, GridUnitType.Pixel); this.e_1.RowDefinitions.Add(row_e_1_8); ColumnDefinition col_e_1_0 = new ColumnDefinition(); col_e_1_0.Width = new GridLength(1F, GridUnitType.Star); this.e_1.ColumnDefinitions.Add(col_e_1_0); ColumnDefinition col_e_1_1 = new ColumnDefinition(); col_e_1_1.Width = new GridLength(1F, GridUnitType.Star); this.e_1.ColumnDefinitions.Add(col_e_1_1); ColumnDefinition col_e_1_2 = new ColumnDefinition(); col_e_1_2.Width = new GridLength(1F, GridUnitType.Star); this.e_1.ColumnDefinitions.Add(col_e_1_2); ColumnDefinition col_e_1_3 = new ColumnDefinition(); col_e_1_3.Width = new GridLength(1F, GridUnitType.Star); this.e_1.ColumnDefinitions.Add(col_e_1_3); // e_2 element this.e_2 = new Image(); this.e_1.Children.Add(this.e_2); this.e_2.Name = "e_2"; BitmapImage e_2_bm = new BitmapImage(); e_2_bm.TextureAsset = "Images/CeriyoLogo"; this.e_2.Source = e_2_bm; Grid.SetColumn(this.e_2, 1); Grid.SetRow(this.e_2, 0); Grid.SetColumnSpan(this.e_2, 2); // e_3 element this.e_3 = new TextBlock(); this.e_1.Children.Add(this.e_3); this.e_3.Name = "e_3"; this.e_3.HorizontalAlignment = HorizontalAlignment.Center; Grid.SetColumn(this.e_3, 1); Grid.SetRow(this.e_3, 1); Grid.SetColumnSpan(this.e_3, 2); Binding binding_e_3_Text = new Binding("WelcomeText"); this.e_3.SetBinding(TextBlock.TextProperty, binding_e_3_Text); // e_4 element this.e_4 = new Button(); this.e_1.Children.Add(this.e_4); this.e_4.Name = "e_4"; this.e_4.Margin = new Thickness(4F, 4F, 4F, 4F); this.e_4.Content = "Join Server"; Grid.SetColumn(this.e_4, 1); Grid.SetRow(this.e_4, 2); Grid.SetColumnSpan(this.e_4, 2); Binding binding_e_4_Command = new Binding("JoinServerCommand"); this.e_4.SetBinding(Button.CommandProperty, binding_e_4_Command); // e_5 element this.e_5 = new Button(); this.e_1.Children.Add(this.e_5); this.e_5.Name = "e_5"; this.e_5.Margin = new Thickness(4F, 4F, 4F, 4F); this.e_5.Content = "Direct Connect"; Grid.SetColumn(this.e_5, 1); Grid.SetRow(this.e_5, 3); Grid.SetColumnSpan(this.e_5, 2); Binding binding_e_5_Command = new Binding("DirectConnectCommand"); this.e_5.SetBinding(Button.CommandProperty, binding_e_5_Command); // e_6 element this.e_6 = new Button(); this.e_1.Children.Add(this.e_6); this.e_6.Name = "e_6"; this.e_6.Margin = new Thickness(4F, 4F, 4F, 4F); this.e_6.Content = "Game Settings"; Grid.SetColumn(this.e_6, 1); Grid.SetRow(this.e_6, 4); Grid.SetColumnSpan(this.e_6, 2); Binding binding_e_6_Command = new Binding("GameSettingsCommand"); this.e_6.SetBinding(Button.CommandProperty, binding_e_6_Command); // e_7 element this.e_7 = new Button(); this.e_1.Children.Add(this.e_7); this.e_7.Name = "e_7"; this.e_7.Margin = new Thickness(4F, 4F, 4F, 4F); this.e_7.Content = "Manage Account"; Grid.SetColumn(this.e_7, 1); Grid.SetRow(this.e_7, 5); Grid.SetColumnSpan(this.e_7, 2); Binding binding_e_7_Command = new Binding("ManageAccountButtonCommand"); this.e_7.SetBinding(Button.CommandProperty, binding_e_7_Command); // e_8 element this.e_8 = new Button(); this.e_1.Children.Add(this.e_8); this.e_8.Name = "e_8"; this.e_8.Margin = new Thickness(4F, 4F, 4F, 4F); this.e_8.Content = "Log Out"; Grid.SetColumn(this.e_8, 1); Grid.SetRow(this.e_8, 6); Grid.SetColumnSpan(this.e_8, 2); Binding binding_e_8_Command = new Binding("LogOutButtonCommand"); this.e_8.SetBinding(Button.CommandProperty, binding_e_8_Command); // e_9 element this.e_9 = new Button(); this.e_1.Children.Add(this.e_9); this.e_9.Name = "e_9"; this.e_9.Margin = new Thickness(4F, 4F, 4F, 4F); this.e_9.Content = "Exit"; Grid.SetColumn(this.e_9, 1); Grid.SetRow(this.e_9, 7); Grid.SetColumnSpan(this.e_9, 2); Binding binding_e_9_Command = new Binding("ExitButtonCommand"); this.e_9.SetBinding(Button.CommandProperty, binding_e_9_Command); ImageManager.Instance.AddImage("Images/CeriyoLogo"); }
public SpanTheCells() { Title = "Span the Cells"; SizeToContent = SizeToContent.WidthAndHeight; Grid grid = new Grid(); grid.Margin = new Thickness(5); Content = grid; for (int i = 0; i < 6; i++) { RowDefinition rowdef = new RowDefinition(); rowdef.Height = GridLength.Auto; grid.RowDefinitions.Add(rowdef); } for (int i = 0; i < 4; i++) { ColumnDefinition coldef = new ColumnDefinition(); if (i == 1) { coldef.Width = new GridLength(100, GridUnitType.Star); } else { coldef.Width = GridLength.Auto; } grid.ColumnDefinitions.Add(coldef); } string[] astrLabel = { "_First name:", "_Last name:", "_Social security number:", "_Credit card number:", "_Other personal stuff:" }; for (int i = 0; i < astrLabel.Length; i++) { Label lbl = new Label(); lbl.Content = astrLabel[i]; lbl.VerticalContentAlignment = VerticalAlignment.Center; grid.Children.Add(lbl); Grid.SetRow(lbl, i); Grid.SetColumn(lbl, 0); TextBox txtbox = new TextBox(); txtbox.Margin = new Thickness(5); grid.Children.Add(txtbox); Grid.SetRow(txtbox, i); Grid.SetColumn(txtbox, 1); Grid.SetColumnSpan(txtbox, 3); } Button btn = new Button(); btn.Content = "Submit"; btn.Margin = new Thickness(5); btn.IsDefault = true; btn.Click += delegate { Close(); }; grid.Children.Add(btn); Grid.SetRow(btn, 5); Grid.SetColumn(btn, 2); btn = new Button(); btn.Content = "Cancel"; btn.Margin = new Thickness(5); btn.IsCancel = true; btn.Click += delegate { Close(); }; grid.Children.Add(btn); Grid.SetRow(btn, 5); Grid.SetColumn(btn, 3); grid.Children[1].Focus(); }