private RowDefinitionCollection CreateRowDefinitions() { var rowDefinitions = new RowDefinitionCollection(); if (this.VerticalContentAlignment == TemplatedGridContentAlignment.Center) { rowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); } foreach (var row in this.ItemsSource.First()) { rowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); } if (this.VerticalContentAlignment == TemplatedGridContentAlignment.Center) { rowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); } return(rowDefinitions); }
private void UpdateCalendar() { Debug.WriteLine("Start UpdateCalendar()"); var rowNum = CalendarUtils.CalcRowSize(_year, _month); var calendarDateRowHeight = (Height * 0.8) / rowNum; var rowCollections = new RowDefinitionCollection(); rowCollections.Add(calendarGrid.RowDefinitions[0]); for (var i = 0; i < rowNum; i++) { rowCollections.Add(new RowDefinition { Height = calendarDateRowHeight }); } calendarGrid.RowDefinitions = rowCollections; var prevMonthDay = CalendarUtils.CalcPrevMonthDays(_year, _month); Debug.WriteLine("既存のカレンダー削除"); calendarGrid.Children.Clear(); Debug.WriteLine("カレンダー作成"); InitCalendarHeader(); for (var i = 0; i < rowNum; i++) { for (var j = 1; j <= 7; j++) { var idx = (i * 7) + j; var dateTime = CalendarUtils.CalcDate(_year, _month, prevMonthDay, idx); var cell = new Cell(dateTime.Year, dateTime.Month, dateTime.Day) { Index = idx - 1 }; if (dateTime.Year == _year && dateTime.Month == _month) { cell.BackgroundColor = Color.White; } else { cell.BackgroundColor = Color.Gray; } Debug.WriteLine("{0}-{1}-{2}", dateTime.Year, dateTime.Month, dateTime.Day); calendarGrid.Children.Add(cell, j - 1, i + 1); } } var pickerDateTime = new DateTime(_year, _month, 1); thisMonth.Text = $"{pickerDateTime.Year}年{pickerDateTime.Month}月"; Debug.WriteLine("End UpdateCalendar()"); }
public static void ManiRows(this RowDefinitionCollection rowDef, string format) { if (rowDef == null) { throw new NullReferenceException("rowDef nust not be null"); } rowDef.Clear(); if (string.IsNullOrWhiteSpace(format)) { return; } string[] value = format.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (var item in value) { if (item.Contains("auto")) { RowDefinition cd = new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }; rowDef.Add(cd); } else if (item.Equals("*")) { RowDefinition cd = new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) }; rowDef.Add(cd); } else if (item.EndsWith("*")) { double length; if (double.TryParse(item.Substring(0, item.Length - 1), out length)) { RowDefinition cd = new RowDefinition() { Height = new GridLength(length, GridUnitType.Star) }; rowDef.Add(cd); } } else { RowDefinition cd = new RowDefinition() { Height = new GridLength(double.Parse(item)) }; rowDef.Add(cd); } } }
public static void AddMultiple(this RowDefinitionCollection RowDefinitionCollection, params RowDefinition[] RowDefinitions) { foreach (var definition in RowDefinitions) { RowDefinitionCollection.Add(definition); } }
public static void AddRange(this RowDefinitionCollection collection, IEnumerable <RowDefinition> rows) { foreach (var row in rows) { collection.Add(row); } }
private static RowDefinitionCollection InitRowDefinitionCollectionByCount(int trailsCount) { var rowDefinitionsCollection = new RowDefinitionCollection(); for (int i = 0; i < trailsCount; i++) { rowDefinitionsCollection.Add(new RowDefinition { Height = 200 }); } rowDefinitionsCollection.Add(new RowDefinition { Height = 50 }); return(rowDefinitionsCollection); }
/// <summary> /// Loads the operators. /// </summary> /// <param name="viewModel">The view model.</param> private void LoadOperators(MobileTopupSelectOperatorViewModel viewModel) { RowDefinitionCollection rowDefinitionCollection = new RowDefinitionCollection(); for (Int32 i = 0; i < viewModel.Operators.Count; i++) { rowDefinitionCollection.Add(new RowDefinition { Height = 80 }); } this.OperatorsGrid.RowDefinitions = rowDefinitionCollection; Int32 rowCount = 0; foreach (String viewModelOperator in viewModel.Operators) { SfButton button = new SfButton { Text = viewModelOperator, HorizontalOptions = LayoutOptions.FillAndExpand, //HeightRequest = 100, //WidthRequest = 400, AutomationId = viewModelOperator, Command = new Command <SelectedItemChangedEventArgs>(this.Execute), CommandParameter = new SelectedItemChangedEventArgs(viewModelOperator, rowCount) }; button.SetDynamicResource(VisualElement.StyleProperty, "SfButtonStyleMobileTopup"); this.OperatorsGrid.Children.Add(button, 0, rowCount); rowCount++; } }
public SchedulePage() { selectDate = DateTime.Now; Title = "Schedule"; isChangedMonth = true; // set Button beforeBtn.Clicked += BeforeBtn_Clicked; nextBtn.Clicked += NextBtn_Clicked; // set grid layout for calendar RowDefinitionCollection rowDef = new RowDefinitionCollection(); for (int i = 0; i < 6; i++) { rowDef.Add(new RowDefinition { Height = new GridLength(30, GridUnitType.Absolute) }); } ColumnDefinitionCollection colDef = new ColumnDefinitionCollection(); for (int i = 0; i < 7; i++) { colDef.Add(new ColumnDefinition { Width = new GridLength(20, GridUnitType.Star) }); } calenderGrid.RowDefinitions = rowDef; calenderGrid.ColumnDefinitions = colDef; }
private void GridRowDefinition() { RowDefinition row01 = new RowDefinition() { Height = _app.DefaultTemplateHeightNavegationBar }; RowDefinition row03 = new RowDefinition() { Height = _app.DefaultTemplateHeightContent }; RowDefinitions = new RowDefinitionCollection(); RowDefinitions.Add(row01); RowDefinitions.Add(row03); }
private void GenerateGrid() { for (int i = 0; i < 6; i++) { ColumnDefinitionCollection coldefs = ScheduleGrid.ColumnDefinitions; coldefs.Add(new ColumnDefinition()); } DateTime time = _start; for (int i = 0; i < _numintervals; i++) { RowDefinitionCollection rowdefs = ScheduleGrid.RowDefinitions; rowdefs.Add(new RowDefinition() { MaxHeight = _rowheight, MinHeight = _rowheight, }); Label TimeLabel = new Label() { Content = time.ToString("HH:mm"), }; Grid.SetRow(TimeLabel, i); Grid.SetColumn(TimeLabel, 0); ScheduleGrid.Children.Add(TimeLabel); time = time.Add(_interval); } DrawCourses(); }
protected override void OnExecute(UIMessageContext ctx) { var req = ctx.Get <CreateGridRequest>(); if (req == null) { return; } var target = Surface[req.ParentId]; if (target == null) { return; } var attached = false; var rowCollection = new RowDefinitionCollection(); var colCollection = new ColumnDefinitionCollection(); for (var i = 0; i < req.Rows; i++) { var row = new RowDefinition(); rowCollection.Add(row); } for (var j = 0; j < req.Columns; j++) { var col = new ColumnDefinition(); colCollection.Add(col); } var view = new Grid { RowDefinitions = rowCollection, ColumnDefinitions = colCollection, ColumnSpacing = req.ColumnSpacing, RowSpacing = req.RowSpacing }; Thread.Invoke(() => { attached = Surface.SetParent(view, target); }); if (!attached) { return; } var pair = Surface[view.Id]; ctx.SetResponse <CreateWidgetResponse>(res => { res.Widget = pair.UIWidget; res.Parent = target.UIWidget; res.Suggest <GetVisualTreeRequest>(); }); }
public static RowDefinition AddStarRow(this RowDefinitionCollection defn, int NumberUnits = 1) { var rowdef = new RowDefinition(); rowdef.Height = new GridLength(NumberUnits, GridUnitType.Star); defn.Add(rowdef); return(rowdef); }
public static RowDefinition AddAutoRow(this RowDefinitionCollection defn) { var rowdef = new RowDefinition(); rowdef.Height = GridLength.Auto; defn.Add(rowdef); return(rowdef); }
public StuartTemplate() { RowDefinitions = new RowDefinitionCollection(); RowDefinition rd0 = new RowDefinition(); rd0.Height = 30; RowDefinitions.Add(rd0); RowDefinition rd1 = new RowDefinition(); rd1.Height = GridLength.Auto; RowDefinitions.Add(rd1); RowDefinition rd2 = new RowDefinition(); rd2.Height = 30; RowDefinitions.Add(rd2); //var topBox = new BoxView(); //topBox.Color = Color.Teal; //Children.Add(topBox, 0, 0); var topLabel = new Label(); topLabel.TextColor = Color.White; topLabel.Text = "ADP Solutons"; topLabel.FontSize = 24; topLabel.BackgroundColor = Color.Teal; Children.Add(topLabel, 0, 0); var contentPresenter = new ContentPresenter(); Children.Add(contentPresenter, 0, 1); //var bottomBox = new BoxView(); //bottomBox.Color = Color.Teal; //Children.Add(bottomBox, 0, 2); var bottomLabel = new Label(); bottomLabel.TextColor = Color.White; bottomLabel.Text = "Stuart Servey ..."; bottomLabel.FontSize = 32; bottomLabel.BackgroundColor = Color.Teal; Children.Add(bottomLabel, 0, 2); }
/// <summary> /// Clears the Collection and creates n amount of new definitions /// </summary> /// <param name="rows">The collection to refresh</param> /// <param name="n">the amount of rows required</param> private static void ResetRows(RowDefinitionCollection rows, int n) { rows.Clear(); for (int i = 0; i < n; i++) { rows.Add(new RowDefinition()); } }
private Grid DefineSliderGrid(RegisterBankDefinition bankDef) { Grid grid = new Grid { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, RowSpacing = 35, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(40, GridUnitType.Absolute) }, new ColumnDefinition { Width = GridLength.Auto }, new ColumnDefinition { Width = new GridLength(100, GridUnitType.Star) } } }; RowDefinitionCollection rdc = new RowDefinitionCollection(); foreach (var item in bankDef.Registers) { rdc.Add(new RowDefinition { Height = GridLength.Auto }); } for (int i = 0; i < bankDef.Registers.Length; i++) { grid.Children.Add(new Label { Text = i.ToString("000"), FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center }, 0, i); grid.Children.Add(new Label { Text = bankDef.Registers[i], FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)), HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center }, 1, i); Slider slider = new Slider(0, 255, 0); slider.HorizontalOptions = LayoutOptions.FillAndExpand; slider.VerticalOptions = LayoutOptions.Center; slider.ValueChanged += OnRegisterValueChanged; sliders.Add(slider); grid.Children.Add(slider, 2, i); } return(grid); }
private void flipGrid(PlayerShip ship) { Grid GridToTurn = ((Grid)(ship.ImageToShow)); RowDefinitionCollection rdc = GridToTurn.RowDefinitions; ColumnDefinitionCollection cdc = GridToTurn.ColumnDefinitions; if (!IsHorizontal) { double temp = GridToTurn.Width; GridToTurn.Width = GridToTurn.Height; GridToTurn.Height = temp; foreach (RowDefinition rd in rdc) { ColumnDefinition cd = new ColumnDefinition(); cd.Width = new GridLength(10, GridUnitType.Star); cdc.Add(cd); } for (int i = 0; i < GridToTurn.Children.Count; i++) { Grid.SetColumn(GridToTurn.Children[i], i); Grid.SetRow(GridToTurn.Children[i], 0); } while (rdc.Count > 0) { rdc.RemoveAt(rdc.Count - 1); } } else { double temp = GridToTurn.Height; GridToTurn.Height = GridToTurn.Width; GridToTurn.Width = temp; foreach (ColumnDefinition cd in cdc) { RowDefinition rd = new RowDefinition(); rd.Height = new GridLength(10, GridUnitType.Star); rdc.Add(rd); } for (int i = 0; i < GridToTurn.Children.Count; i++) { Grid.SetRow(GridToTurn.Children[i], i); Grid.SetColumn(GridToTurn.Children[i], 0); } while (cdc.Count > 0) { cdc.RemoveAt(cdc.Count - 1); } } IsHorizontal = !IsHorizontal; }
public MainWindow() { InitializeComponent(); var _grid = new Grid(); RowDefinitionCollection mesLignes = _grid.RowDefinitions; mesLignes.Add(new RowDefinition() { Height = new GridLength(40, GridUnitType.Star) }); mesLignes.Add(new RowDefinition() { Height = new GridLength(20, GridUnitType.Star) }); mesLignes.Add(new RowDefinition() { Height = new GridLength(40, GridUnitType.Star) }); var _texBox = new TextBox() { Text = "Saisisser votre question ici", }; Grid.SetRow(_texBox, 0); _grid.Children.Add(_texBox); this.Content = _grid; var bouton = new Button() { Content = "Ask the Eight Ball" }; Grid.SetRow(bouton, 1); _grid.Children.Add(bouton); this.Content = _grid; bouton.Click += Button_Click; Grid.SetRow(_textBlock2, 2); _grid.Children.Add(_textBlock2); this.Content = _grid; }
private void CentralPage() { Clear(); CloseMenu(); ClearWorkPlace(); Grid centralGrid = new Grid { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand }; RowDefinitionCollection rd = centralGrid.RowDefinitions; rd.Add(new RowDefinition { Height = new GridLength(0.1, GridUnitType.Star), }); rd.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star), }); CentralWindow.Children.Add(centralGrid); StackLayout topStack = new StackLayout { Orientation = StackOrientation.Horizontal, BackgroundColor = StyleColor.color1, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, }; AddTopStack(topStack); Grid.SetRow(topStack, 0); centralGrid.Children.Add(topStack); centralGrid.Children.Add(CreateGridWithMenu()); MainMenu(); }
/// <summary> /// Adds the specified amount of rows as simple 'new RowDefinition()' with Height set to 'new GridLength(0, GridUnitType.Auto)' /// </summary> /// <param name="collection"></param> /// <param name="amount"></param> public static void AddAmount(this RowDefinitionCollection collection, int amount) { for (int i = 0; i < amount; i++) { collection.Add(new RowDefinition() { Height = new GridLength(0, GridUnitType.Auto) }); } }
private RowDefinitionCollection GetRows(int count) { var rows = new RowDefinitionCollection(); for (int i = 0; i < count; i++) { rows.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); } return(rows); }
public static RowDefinitionCollection GenerateRowDefinition(params GridLength[] definitions) { var rowDefinitionCollection = new RowDefinitionCollection(); foreach (var gridLength in definitions) { rowDefinitionCollection.Add(new RowDefinition { Height = gridLength }); } return(rowDefinitionCollection); }
public static RowDefinitionCollection Rows(GridUnitType Unit, params double[] Heights) { RowDefinitionCollection Return = new RowDefinitionCollection(); foreach (int Height in Heights) { Return.Add(new RowDefinition { Height = new GridLength(Height, Unit) }); } return(Return); }
/* * public static readonly BindableProperty LampProperty = * BindableProperty.Create(nameof(Lamp), typeof(string), typeof(PlayerEquipment), default(string), BindingMode.TwoWay); * public string Lamp * { * get * { * return (string)GetValue(LampProperty); * } * * set * { * SetValue(LampProperty, value); * } * } * * public static readonly BindableProperty PickProperty = * BindableProperty.Create(nameof(Pick), typeof(string), typeof(PlayerEquipment), default(string), BindingMode.TwoWay); * public string Pick * { * get * { * return (string)GetValue(PickProperty); * } * * set * { * SetValue(PickProperty, value); * } * } * * public static readonly BindableProperty TrolleyProperty = * BindableProperty.Create(nameof(Trolley), typeof(string), typeof(PlayerEquipment), default(string), BindingMode.TwoWay); * public string Trolley * { * get * { * return (string)GetValue(TrolleyProperty); * } * * set * { * SetValue(TrolleyProperty, value); * } * } */ protected override void OnPropertyChanged(string propertyName = null) { base.OnPropertyChanged(propertyName); if (propertyName == EquipmentListProperty.PropertyName) { var columnDefinitions = new ColumnDefinitionCollection(); for (int i = 0; i < EquipmentList.Count; i++) { columnDefinitions.Add(new ColumnDefinition { Width = new GridLength(41, GridUnitType.Absolute) }); } var rowDefinitions = new RowDefinitionCollection(); rowDefinitions.Add(new RowDefinition { Height = new GridLength(60, GridUnitType.Absolute) }); EquipmentGrid.ColumnDefinitions = columnDefinitions; EquipmentGrid.RowDefinitions = rowDefinitions; for (int i = 0; i < EquipmentList.Count; i++) { var tapGestureRecognizer = new TapGestureRecognizer(); tapGestureRecognizer.SetBinding(TapGestureRecognizer.CommandProperty, "SelectEquipment"); tapGestureRecognizer.CommandParameter = EquipmentList[i].Image; var image = new Image { Source = EquipmentList[i].Image, Aspect = Aspect.AspectFill, }; image.GestureRecognizers.Add(tapGestureRecognizer); EquipmentGrid.Children.Add(image, i, 0); } } /* * if (propertyName == LampProperty.PropertyName) * { * LampImage.Source = Lamp; * } * else if (propertyName == PickProperty.PropertyName) * { * PickImage.Source = Pick; * } * else if (propertyName == TrolleyProperty.PropertyName) * { * TrolleyImage.Source = Trolley; * }*/ }
/// <summary> /// Recomputes rows and update children. /// </summary> private void InvalidateGridParameters() { RowDefinitionCollection rowCollection = RowDefinitions; UIElementCollection children = Children; // Determine how many rows we need int remainder; int neededRowCount = Math.DivRem(children.Count, 2, out remainder) + remainder; int currentRowCount = rowCollection.Count; int deltaRowCount = neededRowCount - currentRowCount; // Add/remove rows if (deltaRowCount > 0) { for (int i = 0; i < deltaRowCount; i++) { rowCollection.Add(new RowDefinition { Height = new GridLength(0.0, GridUnitType.Auto) }); } } else if (deltaRowCount < 0) { rowCollection.RemoveRange(currentRowCount + deltaRowCount, -deltaRowCount); } // Update Grid.Row and Grid.Column dependency properties on each child control int row = 0; int column = 0; foreach (UIElement element in children) { element.SetValue(ColumnProperty, column); element.SetValue(RowProperty, row); if (column == 0 && GetUseFullRow(element)) { element.SetValue(ColumnSpanProperty, 2); row++; } else { column++; if (column > 1) { column = 0; row++; } } } }
public static Grid SetRowDefinition(this Grid grid, params GridLength[] definitions) { var rowDefinitionCollection = new RowDefinitionCollection(); foreach (var gridLength in definitions) { rowDefinitionCollection.Add(new RowDefinition { Height = gridLength }); } grid.RowDefinitions = rowDefinitionCollection; return(grid); }
public static RowDefinitionCollection Define(params GridLength[] heights) { var rowDefinitions = new RowDefinitionCollection(); for (var i = 0; i < heights.Length; i++) { rowDefinitions.Add(new RowDefinition { Height = heights[i] }); } return(rowDefinitions); }
private RowDefinitionCollection CreateRowDefinitions(WLLViewModel vmContext) { var rowDefinitionCollection = new RowDefinitionCollection(); for (var i = 0; i < vmContext.GetIDsCount(); i++) { rowDefinitionCollection.Add(new RowDefinition { Height = ButtonGridRowDefHeight }); } return(rowDefinitionCollection); }
//Grid bat dau voi 3 row. // row dau va row cuoi co chieu cao mac dinh la 30 // row thu 2 co chieu cao la auto, row thu 2 nay danh cho 'cau hoi'(textblock) private void InitGrid() { rowDefCollection = LayoutRoot.RowDefinitions; RowDefinition rowDef; rowDef = new RowDefinition(); rowDef.Height = new GridLength(10.00); rowDefCollection.Add(rowDef); for (int i = 0; i < iNumOption + 1; ++i) { rowDef = new RowDefinition(); GridLength gridLength = new GridLength(); rowDef.Height = gridLength; rowDef.MinHeight = 30.00; rowDefCollection.Add(rowDef); } rowDef = new RowDefinition(); rowDef.Height = new GridLength(10.00); rowDefCollection.Add(rowDef); }
private void InvalidateGridParameters() { RowDefinitionCollection rowCollection = RowDefinitions; UIElementCollection children = Children; int remainder; int neededRowCount = Math.DivRem(children.Count, 2, out remainder); if (remainder > 0) { neededRowCount++; } int currentRowCount = rowCollection.Count; int deltaRowCount = neededRowCount - currentRowCount; if (deltaRowCount > 0) { for (int i = 0; i < deltaRowCount; i++) { rowCollection.Add(new RowDefinition { Height = new GridLength(0.0, GridUnitType.Auto) }); } } else if (deltaRowCount < 0) { rowCollection.RemoveRange(currentRowCount + deltaRowCount, -deltaRowCount); } int row = 0; int column = 0; foreach (UIElement element in children) { element.SetValue(Grid.ColumnProperty, column); element.SetValue(Grid.RowProperty, row); column++; if (column > 1) { column = 0; row++; } } }
private static RowDefinitionCollection InitRowDefinitionCollectionByCount(int trailsCount) { var rowDefinitionsCollection = new RowDefinitionCollection(); for (int i = 0; i < trailsCount; i++) { rowDefinitionsCollection.Add(new RowDefinition { Height = 200 }); } rowDefinitionsCollection.Add(new RowDefinition { Height = 50 }); return rowDefinitionsCollection; }
private RowDefinitionCollection CreateRowDefinitions() { var rowDefinitions = new RowDefinitionCollection(); if(this.VerticalContentAlignment == TemplatedTableViewContentAlignment.Center) { rowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); } foreach(var row in this.ItemsSource.First()) { rowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); } if(this.VerticalContentAlignment == TemplatedTableViewContentAlignment.Center) { rowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); } return rowDefinitions; }