Exemple #1
0
 public virtual void Clear()
 {
     Children.Clear();
     ColumnDefinitions.Clear();
     RowDefinitions.Clear();
     init();
 }
Exemple #2
0
        public SectionFooter()
        {
            HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;

            ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Auto)
            });
            ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Star)
            });

            Children.Add((textBlock = new TextBlock()
            {
                Margin = new Thickness(6, 6, 6, 11),
                VerticalAlignment = System.Windows.VerticalAlignment.Center
            }));

            Loaded += (o, e) =>
            {
                var control = Parent as ContentControl;
                if (control != null)
                {
                    control.IsTabStop = false;
                }
            };
        }
Exemple #3
0
 public MyGird()
 {
     this.BindingContextChanged += MyGird_BindingContextChanged;
     for (int i = 0; i < 8; i++)
     {
         RowDefinitions.Add(new RowDefinition {
             Height = new GridLength(1, GridUnitType.Star)
         });
     }
     for (int i = 0; i < 8; i++)
     {
         ColumnDefinitions.Add(new ColumnDefinition {
             Width = new GridLength(1, GridUnitType.Star)
         });
     }
     first  = new Label {
     };
     second = new Label {
     };
     third  = new Label {
     };
     fourth = new Label {
     };
     Children.Add(first, 0, 0);
     Children.Add(second, 2, 2);
     Children.Add(third, 5, 2);
     Children.Add(fourth, 7, 0);
 }
Exemple #4
0
 private void Reset()
 {
     _keys = null;
     Children.Clear();
     RowDefinitions.Clear();
     ColumnDefinitions.Clear();
 }
Exemple #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TabHeader"/> class.
        /// </summary>
        /// <param name="name">The name of the tab.</param>
        /// <param name="OnClose">Action to take when the tab requests to be closed.</param>
        public TabHeader(string name, TabItem tabItem, RoutedEventHandler OnClose)
        {
            this.tabItem        = tabItem;
            this.onCloseHandler = OnClose;
            RowDefinitions.Add(new RowDefinition());
            ColumnDefinitions.Add(new ColumnDefinition());
            ColumnDefinitions.Add(new ColumnDefinition());

            NameLabel         = new Label();
            NameLabel.Content = name;
            Children.Add(NameLabel);
            Grid.SetRow(NameLabel, 0);
            Grid.SetColumn(NameLabel, 0);

            CloseButton                     = new Button();
            CloseButton.Background          = null;
            CloseButton.BorderBrush         = null;
            CloseButton.HorizontalAlignment = HorizontalAlignment.Right;
            CloseButton.VerticalAlignment   = VerticalAlignment.Top;
            CloseButton.Content             = "x";
            CloseButton.FontWeight          = FontWeights.Bold;
            CloseButton.FontSize            = 14;
            CloseButton.Click              += CloseButton_Click;
            Children.Add(CloseButton);
            Grid.SetRow(CloseButton, 0);
            Grid.SetColumn(CloseButton, 1);
        }
Exemple #6
0
        private void ArrangeChildren()
        {
            var isHorizontal = this.Orientation == Orientation.Horizontal;
            var rowCount     = this.RowDefinitions.Count;
            var columnCount  = this.ColumnDefinitions.Count;

            if (isHorizontal && rowCount == 0 || !isHorizontal && columnCount == 0)
            {
                return;
            }

            var position = 0;

            foreach (UIElement child in Children)
            {
                if (isHorizontal)
                {
                    var row = Math.Min(position % rowCount, rowCount - 1);
                    var col = position / rowCount;

                    Grid.SetRow(child, row);
                    Grid.SetColumn(child, col);
                    position++;
                }
                else
                {
                    var row = position / columnCount;
                    var col = Math.Min(position % columnCount, columnCount - 1);

                    if (row >= rowCount)
                    {
                        RowDefinitions.Add(new RowDefinition()
                        {
                            Height = GridLength.Auto
                        });
                    }

                    Grid.SetRow(child, row);
                    Grid.SetColumn(child, col);
                    position++;
                }
            }

            if (isHorizontal)
            {
                var totalCols = (position / rowCount) + 1;
                if (totalCols < columnCount)
                {
                    ColumnDefinitions.RemoveRange(totalCols - 1, columnCount - totalCols);
                }
            }
            else
            {
                var totalRows = (position / columnCount) + 1;
                if (totalRows < rowCount)
                {
                    RowDefinitions.RemoveRange(totalRows, rowCount - totalRows);
                }
            }
        }
            public TextKeyTranslateView(TextKey sourcekey, TextKey translatekey)
            {
                this.SourceKey    = sourcekey;
                this.TranslateKey = translatekey;

                ColumnDefinitions.Add(1, GridUnitType.Star);
                ColumnDefinitions.Add(1, GridUnitType.Star);

                _LblSource = new Label()
                {
                    Column = 0, Text = SourceKey.Value
                };
                _LblTranslate = new Label()
                {
                    Column = 1, Text = TranslateKey.Value
                };
                _TxtTranslate = new UI.PasteTextField()
                {
                    Column = 1, Visibility = Skill.Framework.UI.Visibility.Hidden
                };
                _TxtTranslate.TextField.Text = TranslateKey.Value;

                this.Controls.Add(_LblSource);
                this.Controls.Add(_LblTranslate);
                this.Controls.Add(_TxtTranslate);

                _TxtTranslate.TextField.TextChanged += _TxtTranslate_TextChanged;

                this.Margin = new Thickness(0, 0, 17, 0);
            }
Exemple #8
0
        /// <summary>
        /// This creates the 3*3 WPF grid used by the buttons, and creates 8 buttons labeled '1' to '8'
        /// </summary>
        private void SetupGridStructure()
        {
            //create an instance of puzzleLogic
            _puzzleLogic = new PuzzleLogic(NumRows);

            // Define rows and columns in the Grid
            for (var row = 0; row < NumRows; row++)
            {
                var r = new RowDefinition {
                    Height = GridLength.Auto
                };
                RowDefinitions.Add(r);

                var c = new ColumnDefinition {
                    Width = GridLength.Auto
                };
                ColumnDefinitions.Add(c);
            }

            //add the buttons in a pile (they are placed according to the underlying PuzzleLogic later)
            for (var i = 0; i < 8; i++)
            {
                var button = GetNewButton();
                button.SetValue(RowProperty, 0);
                button.SetValue(ColumnProperty, 0);
                button.Content = "" + (i + 1);
                Children.Add(button);
            }
        }
Exemple #9
0
        public bool CreateCells(object item)
        {
            var columnIndex = 0;
            var hasStar     = false;

            foreach (var column in DataGrid.Columns)
            {
                var cell = column.CreateCell(DataGrid, item);
                cell.Control.Tag         = cell;
                cell.Control.DataContext = item;

                var cellControl = new ContentPresenter();
                cellControl.Content                    = cell;
                cellControl.ContentTemplate            = DataGrid.CellTemplate;
                cellControl.Padding                    = new Thickness(0);
                cellControl.Margin                     = new Thickness(0);
                cellControl.Height                     = 43;
                cellControl.HorizontalContentAlignment = HorizontalAlignment.Stretch;
                cellControl.VerticalContentAlignment   = VerticalAlignment.Stretch;
                SetColumn(cellControl, columnIndex++);
                Children.Add(cellControl);

                var columnDefinition = column.CreateGridColumnDefinition();
                hasStar = hasStar || columnDefinition.Width.IsStar;

                ColumnDefinitions.Add(columnDefinition);
            }
            return(hasStar);
        }
 private void Initialize()
 {
     ColumnDefinitions.Add(new ColumnDefinition()
     {
         Width = new GridLength(1, GridUnitType.Star)
     });
     RowDefinitions.Add(new RowDefinition()
     {
         Height = new GridLength(1, GridUnitType.Star)
     });
     ButtonFrame = new Frame()
     {
         BackgroundColor   = Color.Transparent,
         HasShadow         = true,
         VerticalOptions   = LayoutOptions.FillAndExpand,
         HorizontalOptions = LayoutOptions.FillAndExpand,
         Padding           = 0,
         CornerRadius      = 0
     };
     ButtonBehide = new SupportButton()
     {
         BackgroundColor   = Color.Transparent,
         VerticalOptions   = LayoutOptions.FillAndExpand,
         HorizontalOptions = LayoutOptions.FillAndExpand,
         Command           = ClickedCommand,
         CommandParameter  = CommandParameter
     };
     ButtonTitleLabel = new Label();
     ButtonImage      = new Image();
     Children.Add(ButtonFrame, 0, 1, 0, 1);
     Children.Add(ButtonBehide, 0, 1, 0, 1);
 }
        private void InitContent()
        {
            int count = 0;

            for (int i = 0; i < _model.Children.Count + 5; i++)
            {
                ColumnDefinition gridCol = new ColumnDefinition()
                {
                    Width = GridLength.Auto
                };
                ColumnDefinitions.Add(gridCol);
            }
            foreach (var item in _model.Children)
            {
                SetColumn(item, ++count);
                Children.Add(item);
                if (count < _model.Children.Count + 3)
                {
                    var gs1 = new GridSplitter();
                    gs1.HorizontalAlignment = HorizontalAlignment.Center;
                    gs1.VerticalAlignment   = VerticalAlignment.Stretch;
                    gs1.Width = 5; //or whatever other height you desire.
                    SetColumn(gs1, ++count);
                    Children.Add(gs1);
                }
            }
            MeasureOverride(new Size(ActualWidth, ActualHeight));
            ArrangeOverride(new Size(ActualWidth, ActualHeight));
        }
Exemple #12
0
 public void SetupOrientation()
 {
     ColumnDefinitions.Clear();
     RowDefinitions.Clear();
     if (Orientation == LayoutSystemOrientation.HORIZONTAL)
     {
         RowDefinition rd = new RowDefinition();
         if (HorizontalAlignment == HorizontalAlignment.Stretch)
         {
             rd.Height = new GridLength(1, GridUnitType.Star);
         }
         else
         {
             rd.Height = new GridLength(1, GridUnitType.Auto);
         }
         RowDefinitions.Add(rd);
     }
     else
     {
         ColumnDefinition cd = new ColumnDefinition();
         if (VerticalAlignment == VerticalAlignment.Stretch)
         {
             cd.Width = new GridLength(1, GridUnitType.Star);
         }
         else
         {
             cd.Width = new GridLength(1, GridUnitType.Auto);
         }
         ColumnDefinitions.Add(cd);
     }
 }
 protected override void OnRender(DrawingContext dc)
 {
     if (ShowCustomGridLines)
     {
         if (GridLinesVisibility == GridLinesVisibilityEnum.Both)
         {
             foreach (var rowDefinition in RowDefinitions.Skip(1))
             {
                 dc.DrawLine(new Pen(GridLineBrush, GridLineThickness), new Point(0, rowDefinition.Offset), new Point(ActualWidth, rowDefinition.Offset));
             }
             foreach (var columnDefinition in ColumnDefinitions.Skip(1))
             {
                 dc.DrawLine(new Pen(GridLineBrush, GridLineThickness), new Point(columnDefinition.Offset, 0), new Point(columnDefinition.Offset, ActualHeight));
             }
             //dc.DrawRectangle(Brushes.Transparent, new Pen(GridLineBrush, GridLineThickness), new Rect(0, 0, ActualWidth, ActualHeight));
         }
         else if (GridLinesVisibility == GridLinesVisibilityEnum.Vertical)
         {
             foreach (var columnDefinition in ColumnDefinitions)
             {
                 dc.DrawLine(new Pen(GridLineBrush, GridLineThickness), new Point(columnDefinition.Offset, 0), new Point(columnDefinition.Offset, ActualHeight));
             }
             dc.DrawRectangle(Brushes.Transparent, new Pen(GridLineBrush, GridLineThickness), new Rect(0, 0, ActualWidth, ActualHeight));
         }
         else if (GridLinesVisibility == GridLinesVisibilityEnum.Horizontal)
         {
             foreach (var rowDefinition in RowDefinitions)
             {
                 dc.DrawLine(new Pen(GridLineBrush, GridLineThickness), new Point(0, rowDefinition.Offset), new Point(ActualWidth, rowDefinition.Offset));
             }
             dc.DrawRectangle(Brushes.Transparent, new Pen(GridLineBrush, GridLineThickness), new Rect(0, 0, ActualWidth, ActualHeight));
         }
     }
     base.OnRender(dc);
 }
Exemple #14
0
        internal DataGridRow(DataGrid dataGrid, object item)
        {
            Item     = item;
            DataGrid = dataGrid;

            var x       = 0;
            var hasStar = false;

            foreach (var c in dataGrid.Columns)
            {
                var cell = c.GenerateElement(item);

                var content = new ContentPresenter();
                content.Content = cell.Control;
                //content.ContentTemplate = dataGrid.CellTemplate;
                content.Margin = new Thickness(10, 0, 0, 5); // TODO: Use template and remove margin
                content.Tag    = cell;

                SetColumn(content, x++);
                Children.Add(content);

                var def = c.CreateGridColumnDefinition();
                hasStar = hasStar || def.Width.IsStar;

                ColumnDefinitions.Add(def);
            }

            if (!hasStar)
            {
                ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Star)
                });
            }

            // second row used for details view
            RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });
            RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });

            Loaded += delegate
            {
                if (DataGrid.SelectionMode == SelectionMode.Single)
                {
                    if (DataGrid.SelectedItem != null)
                    {
                        IsSelected = DataGrid.SelectedItem.Equals(item);
                    }
                }
                else
                {
                    if (DataGrid.SelectedItems != null)
                    {
                        IsSelected = DataGrid.SelectedItems.Contains(item);
                    }
                }
            };
        }
Exemple #15
0
        private void AddCols(int count)
        {
            ColumnDefinitions.Clear();
            ColumnDefinition firstColumn = new ColumnDefinition();

            firstColumn.Width = new GridLength(1, GridUnitType.Star);
            ColumnDefinitions.Add(firstColumn);

            for (int i = 0; i < count; i++)
            {
                ColumnDefinition spaceBetween = new ColumnDefinition();
                spaceBetween.Width = new GridLength(20);
                ColumnDefinitions.Add(spaceBetween);

                ColumnDefinition cards = new ColumnDefinition();
                cards.Width = GridLength.Auto;
                ColumnDefinitions.Add(cards);
            }

            ColumnDefinition lastSpaceBetween = new ColumnDefinition();

            lastSpaceBetween.Width = new GridLength(20);
            ColumnDefinitions.Add(lastSpaceBetween);

            ColumnDefinition lastColumn = new ColumnDefinition();

            lastColumn.Width = new GridLength(1, GridUnitType.Star);
            ColumnDefinitions.Add(lastColumn);
        }
Exemple #16
0
        public GameUi(UIElement gameStats, UIElement gameGrid)
        {
            var gameColumnDefinition = new ColumnDefinition {
                Width = new GridLength(GameConstants.MainWindowWidth - 16)
            };

            var gameGridDefinition = new RowDefinition
            {
                Height = new GridLength(GameConstants.GameViewCanvasHeight - 48)
            };
            var gameStatsDefinition = new RowDefinition {
                Height = new GridLength(48)
            };

            ColumnDefinitions.Add(gameColumnDefinition);

            RowDefinitions.Add(gameGridDefinition);
            RowDefinitions.Add(gameStatsDefinition);

            gameGrid.SetValue(RowProperty, 0);
            gameStats.SetValue(RowProperty, 1);

            Children.Add(gameGrid);
            Children.Add(gameStats);

            Visibility = Visibility.Hidden;
        }
Exemple #17
0
        public TitleWithIcon()
        {
            _Icon  = new Image();
            _Title = new Label();

            RowDefinitions.Add(new RowDefinition());
            RowDefinitions.Add(new RowDefinition());
            ColumnDefinitions.Add(new ColumnDefinition());
            RowDefinitions[0].Height   = GridLength.Auto;
            RowDefinitions[1].Height   = GridLength.Auto;
            ColumnDefinitions[0].Width = GridLength.Auto;

            RowSpacing    = 0;
            ColumnSpacing = 0;

            Children.Add(_Icon);
            Children.Add(_Title);
            Grid.SetRow(_Title, 1);

            _Title.FontSize          = FontSize;
            _Title.HorizontalOptions = LayoutOptions.Center;
            _Title.VerticalOptions   = LayoutOptions.Center;
            _Icon.HorizontalOptions  = LayoutOptions.Center;
            _Icon.VerticalOptions    = LayoutOptions.Center;
        }
Exemple #18
0
        public CStockRecord(decimal price)
            : base()
        {
            _price = price;


            RowDefinitions.Add(new RowDefinition());

            for (int i = 0; i < 3; i++)
            {
                ColumnDefinitions.Add(new ColumnDefinition());
            }



            _stockGrid = new CStockGrid(_price);


            Grid.SetRow(_stockGrid, 0);
            Grid.SetColumn(_stockGrid, 2);
            this.Children.Add(_stockGrid);

            //AddStockElement();

            //CWPFUtils.ConstructGrid((Grid) this, 1, 3);
        }
        /// <summary>
        /// Sets the commands, column order and event handlers.
        /// After this the VM is ready for operation
        /// </summary>
        /// <param name="column"></param>
        private void InitializeColumn(ColumnDefinitionVM column)
        {
            int nonZeroOrderColumns = ColumnDefinitions.Count(c => c.ColumnOrder > 0);

            if (column.ColumnOrder == 0)
            {
                column.ColumnOrder = nonZeroOrderColumns + 1;
            }

            column.RemoveCommand = new DelegateCommand((parameter) =>
            {
                int order = (int)parameter;

                List <ColumnDefinitionVM> higherOrder = ColumnDefinitions.Where(cd => cd.ColumnOrder > order).ToList();
                List <ColumnDefinitionVM> lowerOrder  = ColumnDefinitions.Where(cd => cd.ColumnOrder < order).ToList();

                foreach (ColumnDefinitionVM cdVM in higherOrder)
                {
                    cdVM.ColumnOrder--;
                }

                ColumnDefinitions = lowerOrder.Concat(higherOrder).ToArray();
            });

            column.MoveLeft  = MoveColumnLeft;
            column.MoveRight = MoveColumnRight;
            MoveColumnLeft.RaiseCanExecuteChanged();
            MoveColumnRight.RaiseCanExecuteChanged();
        }
Exemple #20
0
        private void SetUpPage()
        {
            Padding = new Thickness(0, 20, 0, 0);
            RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });
            RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(50)
            });
            ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });

            options.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            options.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            options.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            options.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });

            Children.Add(options, 0, 1);
        }
 public LabeledPricesPanel()
 {
     ColumnDefinitions.Add(new ColumnDefinition());
     ColumnDefinitions.Add(new ColumnDefinition {
         Width = new GridLength(0, GridUnitType.Auto)
     });
 }
Exemple #22
0
        public ButtonGrid(UIElement icon, string text)
        {
            RowDefinitions.Add(new RowDefinition());
            RowDefinitions.Add(new RowDefinition()
            {
                Height = GridLength.Auto
            });
            ColumnDefinitions.Add(new ColumnDefinition());

            this.textBlock = new TextBlock()
            {
                Text = text,
                HorizontalAlignment = HorizontalAlignment.Center,
                Margin = new Thickness(4, 0, 4, 0)
            };
            Grid.SetRow(textBlock, 1);

            IsChecked      = false;
            selection.Fill = new SolidColorBrush(Color.FromArgb(255, 150, 210, 255));
            selection.HorizontalAlignment = HorizontalAlignment.Stretch;
            selection.VerticalAlignment   = VerticalAlignment.Stretch;
            Grid.SetRowSpan(selection, 2);

            Children.Add(selection);
            Children.Add(iconHolder);
            iconHolder.VerticalAlignment   = VerticalAlignment.Center;
            iconHolder.HorizontalAlignment = HorizontalAlignment.Center;
            iconHolder.Margin = new Thickness(4, 4, 4, 0);

            this.Icon          = icon;
            textBlock.FontSize = Settings.DefaultToolbarFontSize;
            Children.Add(textBlock);
        }
Exemple #23
0
        private void UpdateChildren()
        {
            var alreadyContainedChildren = Children.OfType <ILayoutControl>().ToArray();

            DetachOldSplitters();
            DetachPropertyChangeHandler();
            Children.Clear();
            ColumnDefinitions.Clear();
            RowDefinitions.Clear();
            var manager = _model?.Root?.Manager;

            if (manager == null)
            {
                return;
            }
            foreach (var child in _model.Children)
            {
                var foundContainedChild = alreadyContainedChildren.FirstOrDefault(chVM => chVM.Model == child);
                if (foundContainedChild != null)
                {
                    Children.Add(foundContainedChild as UIElement);
                }
                else
                {
                    Children.Add(manager.CreateUIElementForModel(child));
                }
            }
            CreateSplitters();
            UpdateRowColDefinitions();
            AttachNewSplitters();
            AttachPropertyChangeHandler();
        }
Exemple #24
0
        private void Init(int row, int column)
        {
            _game = new Game(row, column, row * column / 6, this);

            RowDefinitions.Clear();
            for (int i = 0; i < row; i++)
            {
                RowDefinitions.Add(new RowDefinition());
            }

            ColumnDefinitions.Clear();
            for (int i = 0; i < column; i++)
            {
                ColumnDefinitions.Add(new ColumnDefinition());
            }

            for (int i = 0; i < row; i++)
            {
                for (int j = 0; j < column; j++)
                {
                    var cell = new Cell(i, j, this);
                    SetRow(cell, i);
                    SetColumn(cell, j);
                    Children.Add(cell);
                }
            }

            Invalidate();
        }
        public UiEncodingLabeledWatermark(string label, string watermark, int width, TextChangedEventHandler onValueChanged)
        {
            ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = GridLength.Auto
            });
            ColumnDefinitions.Add(new ColumnDefinition());

            Margin = new Thickness(5);

            UiTextBlock labelControl = UiTextBlockFactory.Create(label);

            {
                labelControl.Margin            = new Thickness(5, 5, 2, 5);
                labelControl.VerticalAlignment = VerticalAlignment.Center;
                AddUiElement(labelControl, 0, 0);
            }

            _textControl = UiWatermarkTextBoxFactory.Create(watermark);
            {
                _textControl.Width        = width;
                _textControl.Margin       = new Thickness(2, 5, 5, 5);
                _textControl.TextChanged += onValueChanged;
                AddUiElement(_textControl, 0, 1);
            }
        }
Exemple #26
0
 public GridView()
 {
     for (var i = 0; i < MaxColumns; i++)
     {
         ColumnDefinitions.Add(new ColumnDefinition());
     }
 }
Exemple #27
0
        private void OnDataContextChanged(FrameworkElement sender, DataContextChangedEventArgs args)
        {
            Children.Clear();
            ColumnDefinitions.Clear();

            for (int i = 0; i < Children.Count; i++)
            {
                var child = Children[i] as FrameworkElement;
            }

            var items = DataContext as IList <MosaicMediaPosition>;

            if (items == null)
            {
                return;
            }

            for (int i = 0; i < items.Count; i++)
            {
                var item   = items[i];
                var border = new Border();
                border.Background = new SolidColorBrush(Colors.Red);
                border.Margin     = new Thickness(2);

                SetColumn(border, i);
                ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(item.Width, GridUnitType.Star)
                });
                Children.Add(border);
            }
        }
        public void BindGridStructure()
        {
            RowDefinitions.Clear();
            ColumnDefinitions.Clear();


            Observable.Range(0, Rows)
            .Subscribe(c =>
            {
                var rowDef = new RowDefinition();
                if (CellHeight > 0)
                {
                    rowDef.Height = new GridLength(CellHeight);
                }
                RowDefinitions.Add(rowDef);
            });

            Observable.Range(0, Columns)
            .Subscribe(c =>
            {
                var def = new ColumnDefinition();
                if (CellWidth > 0)
                {
                    def.Width = new GridLength(CellWidth);
                }
                ColumnDefinitions.Add(def);
            });
        }
Exemple #29
0
        // Used to interleave specified column dimensions with automatic columns added to use
        // underlying Grid layout for main arrange of UniformGrid.
        internal void SetupColumnDefinitions(int columns)
        {
            // Mark initial definitions so we don't erase them.
            foreach (var cd in ColumnDefinitions)
            {
                if (GetAutoLayout(cd) == null)
                {
                    SetAutoLayout(cd, false);
                }
            }

            // Remove non-autolayout columns we've added and then add them in the right spots.
            if (columns != ColumnDefinitions.Count)
            {
                for (int c = ColumnDefinitions.Count - 1; c >= 0; c--)
                {
                    if (GetAutoLayout(ColumnDefinitions[c]) == true)
                    {
                        this.ColumnDefinitions.RemoveAt(c);
                    }
                }

                for (int c = ColumnDefinitions.Count; c < columns; c++)
                {
                    var cd = new ColumnDefinition();
                    SetAutoLayout(cd, true);
                    ColumnDefinitions.Insert(c, cd);
                }
            }
        }
Exemple #30
0
 private void init()
 {
     ColumnDefinitions.Add(new ColumnDefinition());
     ColumnDefinitions.Add(new ColumnDefinition());
     VerticalAlignment = VerticalAlignment.Top;
     MinHeight         = 0;
 }
Exemple #31
-1
        public void Vertical_Stays_Within_Constraints()
        {
            var cursorFactoryImpl = new Mock<IStandardCursorFactory>();
            PerspexLocator.CurrentMutable.Bind<IStandardCursorFactory>().ToConstant(cursorFactoryImpl.Object);

            var control1 = new Border { [Grid.ColumnProperty] = 0 };
            var splitter = new GridSplitter
            {
                Orientation = Orientation.Vertical,
                [Grid.ColumnProperty] = 1,
            };
            var control2 = new Border { [Grid.ColumnProperty] = 2 };

            var columnDefinitions = new ColumnDefinitions()
            {
                new ColumnDefinition(1, GridUnitType.Star) {MinWidth = 10, MaxWidth = 190},
                new ColumnDefinition(GridLength.Auto),
                new ColumnDefinition(1, GridUnitType.Star) {MinWidth = 80, MaxWidth =  120},
            };

            var grid = new Grid()
            {
                ColumnDefinitions = columnDefinitions,
                Children = new Controls()
                {
                    control1, splitter, control2
                }
            };

            var root = new TestRoot { Child = grid };
            Assert.Equal(splitter.Orientation, Orientation.Vertical);

            root.Measure(new Size(200, 100));
            root.Arrange(new Rect(0, 0, 200, 100));

            splitter.RaiseEvent(new VectorEventArgs
            {
                RoutedEvent = Thumb.DragDeltaEvent,
                Vector = new Vector(-100,0)
            });
            Assert.Equal(columnDefinitions[0].Width, new GridLength(80,GridUnitType.Star));
            Assert.Equal(columnDefinitions[2].Width, new GridLength(120,GridUnitType.Star));
            splitter.RaiseEvent(new VectorEventArgs
            {
                RoutedEvent = Thumb.DragDeltaEvent,
                Vector = new Vector(100, 0)
            });
            Assert.Equal(columnDefinitions[0].Width, new GridLength(120, GridUnitType.Star));
            Assert.Equal(columnDefinitions[2].Width, new GridLength(80, GridUnitType.Star));
        }
Exemple #32
-1
			public RowCell(ResizableGrid owner, ColumnBase gridColumn, ContentControl contentControl)
				: base(owner) {
				GridColumnControl = contentControl;
				GridColumn = gridColumn;
				Row = BandedViewBehavior.GetRow(GridColumn);
				RowSpan = BandedViewBehavior.GetRowSpan(GridColumn);
				Column = BandedViewBehavior.GetColumn(GridColumn);
				ColumnSpan = BandedViewBehavior.GetColumnSpan(GridColumn);
				ColumnDefinitions = new ColumnDefinitions();
				for(int i = Column; i < Column + ColumnSpan; i++)
					ColumnDefinitions.Add(Owner.BandBehavior.ColumnDefinitions[i]);
			}
 public void InitList(ColumnDefinitions definitions, string selectPrompt, string buttonName)
 {
     SelectPrompt.Text = selectPrompt;
     RemoveButton.Content = buttonName;
     ColumnsList.ItemsSource = definitions;
 }
Exemple #34
-1
        public void Vertical_Stays_Within_Constraints()
        {
            var control1 = new Border { [Grid.ColumnProperty] = 0 };
            var splitter = new GridSplitter
                           {
                               [Grid.ColumnProperty] = 1,
                           };
            var control2 = new Border { [Grid.ColumnProperty] = 2 };

            var columnDefinitions = new ColumnDefinitions()
                                    {
                                        new ColumnDefinition(1, GridUnitType.Star) { MinWidth = 10, MaxWidth = 190 },
                                        new ColumnDefinition(GridLength.Auto),
                                        new ColumnDefinition(1, GridUnitType.Star) { MinWidth = 80, MaxWidth = 120 },
                                    };

            var grid = new Grid()
                       {
                           ColumnDefinitions = columnDefinitions,
                           Children = new Controls()
                                      {
                                          control1, splitter, control2
                                      }
                       };

            var root = new TestRoot { Child = grid };

            root.Measure(new Size(200, 100));
            root.Arrange(new Rect(0, 0, 200, 100));

            splitter.RaiseEvent(new VectorEventArgs
                                {
                                    RoutedEvent = Thumb.DragDeltaEvent,
                                    Vector = new Vector(-100, 0)
                                });
            Assert.Equal(columnDefinitions[0].Width, new GridLength(80, GridUnitType.Star));
            Assert.Equal(columnDefinitions[2].Width, new GridLength(120, GridUnitType.Star));
            splitter.RaiseEvent(new VectorEventArgs
                                {
                                    RoutedEvent = Thumb.DragDeltaEvent,
                                    Vector = new Vector(100, 0)
                                });
            Assert.Equal(columnDefinitions[0].Width, new GridLength(120, GridUnitType.Star));
            Assert.Equal(columnDefinitions[2].Width, new GridLength(80, GridUnitType.Star));
        }