示例#1
0
        void AddGridRow()
        {
            if (Orientation == Orientation.Vertical)
            {
                var rowDefinition = new RowDefinition();
                rowDefinition.SetBinding(
                    RowDefinition.HeightProperty,
                    new Binding(CellVerticalLengthProperty.Name)
                {
                    Source = this
                }
                    );

                grid.RowDefinitions.Add(rowDefinition);
            }
            else
            {
                var columnDefinition = new ColumnDefinition();
                columnDefinition.SetBinding(
                    ColumnDefinition.WidthProperty,
                    new Binding(CellVerticalLengthProperty.Name)
                {
                    Source = this
                }
                    );

                grid.ColumnDefinitions.Add(columnDefinition);
            }
        }
示例#2
0
        public void When_Grid_DataBound_Setters()
        {
            var grid = new Grid();

            grid.DataContext = new { a = "42", b = "43" };

            var columnDefinition = new ColumnDefinition();

            object columnDefinitionDataContextValue = null;

            columnDefinition.DataContextChanged += (_, e) => {
                columnDefinitionDataContextValue = e.NewValue;
            };

            grid.ColumnDefinitions.Add(columnDefinition);

            var rowDefinition = new RowDefinition();

            object rowDefinitionDataContextValue = null;

            rowDefinition.DataContextChanged += (_, e) => {
                rowDefinitionDataContextValue = e.NewValue;
            };

            grid.RowDefinitions.Add(rowDefinition);

            Assert.IsNull(rowDefinitionDataContextValue);
            Assert.AreEqual(GridUnitType.Star, columnDefinition.Width.GridUnitType);

            Assert.IsNull(columnDefinitionDataContextValue);
            Assert.AreEqual(GridUnitType.Star, rowDefinition.Height.GridUnitType);

            columnDefinition.SetBinding(ColumnDefinition.WidthProperty, new Binding()
            {
                Path = "a"
            });

            Assert.IsNotNull(columnDefinitionDataContextValue);
            Assert.AreEqual(GridUnitType.Pixel, columnDefinition.Width.GridUnitType);
            Assert.AreEqual(42, columnDefinition.Width.Value);

            Assert.IsNull(rowDefinitionDataContextValue);
            Assert.AreEqual(GridUnitType.Star, rowDefinition.Height.GridUnitType);

            rowDefinition.SetBinding(RowDefinition.HeightProperty, new Binding()
            {
                Path = "b"
            });

            Assert.IsNotNull(rowDefinitionDataContextValue);
            Assert.AreEqual(GridUnitType.Pixel, rowDefinition.Height.GridUnitType);
            Assert.AreEqual(43, rowDefinition.Height.Value);
        }
        void AddRowDefinition()
        {
            var rowDefinition = new RowDefinition();

            rowDefinition.SetBinding(
                RowDefinition.HeightProperty,
                new Binding(nameof(RowHeight))
            {
                Source = this
            }
                );
            grid.RowDefinitions.Add(rowDefinition);
        }
示例#4
0
        void DrawGrid(int count1, int count2)
        {
            gridItem.RowDefinitions.Clear();
            gridItem.Children.Clear();
            RowDefinition rowDefinition;
            Binding       binding;

            foreach (var v in GetTextBox(count1 + count2))
            {
                binding        = new Binding();
                rowDefinition  = new RowDefinition();
                binding.Source = v;
                binding.Path   = new PropertyPath("ActualHeight");
                rowDefinition.SetBinding(RowDefinition.HeightProperty, binding);
                gridItem.RowDefinitions.Add(rowDefinition);
                gridItem.Children.Add(v);
            }
            foreach (var v in GetTextBlock(count1, count2))
            {
                gridItem.Children.Add(v);
            }
        }
示例#5
0
        private void AddRowHeader(RowDefinition nwMainGridRow)
        {
            var nwRowHeaderDefenition = new RowDefinition()
            {
                Height    = GridLength.Auto,
                MinHeight = MIN_CELL_HEIGHT
            };
            var heightBinding = new Binding("Height")
            {
                Source = nwMainGridRow,
                Mode   = BindingMode.TwoWay
            };

            nwRowHeaderDefenition.SetBinding(RowDefinition.HeightProperty, heightBinding);
            nwRowHeaderDefenition.Height = new GridLength(MIN_CELL_HEIGHT);
            RowNumberGrid.RowDefinitions.Add(nwRowHeaderDefenition);

            var rowHeaderContent = CreateRowHeaderContent(RowNumberGrid.RowDefinitions.Count - 1);

            Grid.SetRow(rowHeaderContent, RowNumberGrid.RowDefinitions.Count - 1);
            RowNumberGrid.Children.Add(rowHeaderContent);

            var nwGridSplitter = new GridSplitter()
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Bottom,
                Background          = new SolidColorBrush(),
                Height = 6
            };

            Grid.SetRow(nwGridSplitter, RowNumberGrid.RowDefinitions.Count - 1);
            RowNumberGrid.Children.Add(nwGridSplitter);

            rowNumberStructure.Add((rowHeaderContent, nwGridSplitter));
            Debug.Assert(rowNumberStructure.Count == RowNumberGrid.RowDefinitions.Count);
        }
        private void CreateAndBindRowAndColumnDefinitions()
        {
            if (ParentWindow == null)
            {
                return;
            }

            RowDefinitions.Clear();

            var row0 = new RowDefinition();

            RowDefinitions.Add(row0);

            var row1 = new RowDefinition()
            {
                Height = new GridLength(1, GridUnitType.Star)
            };

            RowDefinitions.Add(row1);

            var row2 = new RowDefinition();

            RowDefinitions.Add(row2);

            var column0 = new ColumnDefinition();

            ColumnDefinitions.Add(column0);

            var column1 = new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Star)
            };

            ColumnDefinitions.Add(column1);

            var column2 = new ColumnDefinition();

            ColumnDefinitions.Add(column2);

            row0.SetBinding(RowDefinition.HeightProperty, new Binding()
            {
                Path   = new PropertyPath("GlassFrameThickness.Top"),
                Source = ParentWindow,
            }
                            );

            row2.SetBinding(RowDefinition.HeightProperty, new Binding()
            {
                Path   = new PropertyPath("GlassFrameThickness.Bottom"),
                Source = ParentWindow,
            }
                            );

            column0.SetBinding(ColumnDefinition.WidthProperty, new Binding()
            {
                Path   = new PropertyPath("GlassFrameThickness.Left"),
                Source = ParentWindow,
            }
                               );

            column2.SetBinding(ColumnDefinition.WidthProperty, new Binding()
            {
                Path   = new PropertyPath("GlassFrameThickness.Right"),
                Source = ParentWindow,
            }
                               );
        }
示例#7
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            #region 加载数据

            new BLL.ExtraBLL.EquipmentInfoBLL().GetEquipmentInfo();

            planGridContainers = new Grid[StoreInfoModel.EquipmentInfos.Count + 1];

            #region 加载返回工单磁贴

            planGridContainers[0] = new Grid
            {
                Margin     = new Thickness(5),
                Cursor     = Cursors.Hand,
                Width      = 250,
                Height     = 160,
                Background = new SolidColorBrush(Color.FromRgb(66, 166, 247)),
                Focusable  = true
            };

            planGridContainers[0].Children.Add(new Label()
            {
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
                FontSize            = 28,
                Foreground          = new SolidColorBrush(ConfigInfoModel.ColorSetting.TxtColorA),
                Content             = "<< 返回工单"
            });

            planInfoContainer.Children.Add(planGridContainers[0]);

            #endregion

            #region 加载保养计划任务磁贴

            for (int i = 0; i < StoreInfoModel.EquipmentInfos.Count; i++)
            {
                EquipmentInfoModel.DataModel model = StoreInfoModel.EquipmentInfos[i];

                planGridContainers[i + 1] = new Grid
                {
                    Margin   = new Thickness(5),
                    Cursor   = Cursors.Hand,
                    MinWidth = 250,
                    //Background = new SolidColorBrush(Color.FromRgb(73, 140, 241)),
                    Background = new SolidColorBrush(model.GetEquipmentMaintenancePlan.ActualStartTime == null ? Color.FromRgb(73, 140, 241) : Color.FromRgb(250, 92, 60)),
                    Focusable  = true,
                    Tag        = model
                };
                Binding bdingGridWidth = new Binding
                {
                    ElementName = "pInfoColWidth",
                    Path        = new PropertyPath("Width")
                };
                planGridContainers[i + 1].SetBinding(WidthProperty, bdingGridWidth);

                Grid grid = new Grid()
                {
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    VerticalAlignment   = VerticalAlignment.Stretch
                };

                grid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(5)
                });
                for (int j = 0; j < 4; j++)
                {
                    RowDefinition rowHeight      = new RowDefinition();
                    Binding       bdingRowHeight = new Binding
                    {
                        ElementName = "pInfoRowHeight",
                        Path        = new PropertyPath("Height")
                    };
                    rowHeight.SetBinding(RowDefinition.HeightProperty, bdingRowHeight);

                    grid.RowDefinitions.Add(rowHeight);
                }
                grid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(5)
                });

                grid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(5)
                });
                ColumnDefinition colWidth      = new ColumnDefinition();
                Binding          bdingColWidth = new Binding
                {
                    ElementName = "pInfoColWidth",
                    Path        = new PropertyPath("Width")
                };
                colWidth.SetBinding(ColumnDefinition.WidthProperty, bdingColWidth);
                grid.ColumnDefinitions.Add(colWidth);
                grid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(5)
                });

                string[] contentArr = new string[] {
                    model.GetEquipmentMaintenancePlan.EquipmentName,                                                                                         //设备名称
                    model.GetEquipmentMaintenancePlan.MaintenanceName + "(" + (model.GetEquipmentMaintenancePlan.ActualStartTime == null?"未开始":"已开始") + ")", //保养类型
                    model.GetEquipmentMaintenancePlan.PlanedContent,                                                                                         //维护内容
                    model.GetEquipmentMaintenancePlan.PlanedStartTime == null?"":Convert.ToDateTime(model.GetEquipmentMaintenancePlan.PlanedStartTime).ToString("yyyy-MM-dd")
                };
                for (int j = 0; j < 4; j++)
                {
                    Label lblContent = new Label()
                    {
                        HorizontalAlignment = HorizontalAlignment.Left,
                        VerticalAlignment   = VerticalAlignment.Center,
                        FontSize            = j.Equals(2) ? 16 : 20,
                        Foreground          = new SolidColorBrush(ConfigInfoModel.ColorSetting.TxtColorA),
                        Content             = contentArr[j]
                    };
                    grid.Children.Add(lblContent);

                    Grid.SetColumn(lblContent, 1);
                    Grid.SetRow(lblContent, j + 1);
                }

                planGridContainers[i + 1].Children.Add(grid);
                planInfoContainer.Children.Add(planGridContainers[i + 1]);
            }

            #endregion

            #region 默认选择返回工单

            Border border = new Border();
            border.BorderBrush     = new SolidColorBrush(Color.FromRgb(255, 255, 255));
            border.BorderThickness = new Thickness(2);
            planGridContainers[0].Children.Add(border);

            #endregion


            #endregion


            pageContainer.Focus();
        }
示例#8
0
        private void FormViewer_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (!(this.DataContext is FormInstance))
            {
                return;
            }
            ///Ok so the datacontex wil be a Forminstance
            FormInstance f = (FormInstance)this.DataContext;

            //does this forminstance already have dataitems

            //We clear all the existing elements from the Grid
            FormGrid.Children.Clear();
            //Set up the rows and columns
            FormGrid.RowDefinitions.Clear();
            FormGrid.ColumnDefinitions.Clear();
            var rows = f.FormTemplate.Rows.Split(',');

            for (int i = 0; i < f.FormTemplate.NumberOfRows; i++)
            {
                RowDefinition def          = new RowDefinition();
                Binding       widthBinding = new Binding("ActualHeight");
                widthBinding.Source             = FormGrid;
                widthBinding.Converter          = new FractionConverter();
                widthBinding.ConverterParameter = Convert.ToDouble(rows[i]);
                def.SetBinding(RowDefinition.HeightProperty, widthBinding);
                FormGrid.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(Convert.ToDouble(rows[i]), GridUnitType.Star)
                });
            }
            var cols = f.FormTemplate.Columns.Split(',');

            for (int i = 0; i < f.FormTemplate.NumberOfColumns; i++)
            {
                ColumnDefinition def          = new ColumnDefinition();
                Binding          widthBinding = new Binding("ActualWidth");
                widthBinding.Source             = FormGrid;
                widthBinding.Converter          = new FractionConverter();
                widthBinding.ConverterParameter = Convert.ToDouble(cols[i]);
                def.SetBinding(ColumnDefinition.WidthProperty, widthBinding);
                //FormGrid.ColumnDefinitions.Add(def);
                FormGrid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(Convert.ToDouble(cols[i]), GridUnitType.Star)
                });
            }

            ///Now we iterate the elements that make up this template
            ///and add them to the grid
            ///for each form element, we add a control, and we check if the FormInstance already has a
            ///QADataItem that matches in terms of its DataDictionaryEntry and EquipmentItem
            ///if we have match, then we assign that dataitem to the Control we just added
            foreach (FormElement elm in f.FormTemplate.FormElements)
            {
                if (elm is LabelFormElement)
                {
                    LabelFormElement l = (LabelFormElement)elm;
                    Label            X = new Label();
                    X.HorizontalContentAlignment = HorizontalAlignment.Center;
                    X.VerticalContentAlignment   = VerticalAlignment.Center;
                    X.Content = l.LabelText;

                    setControlLayout(l, X);
                }
                else if (elm is BooleanFormElement)
                {
                    BooleanFormElement b          = (BooleanFormElement)elm;
                    CheckBox           X          = new CheckBox();
                    QADataItem         qaDataItem = null;
                    if (f.DataItems.Where(x => x.DataDictionaryEntry.FullName == b.DataDictionaryEntry.FullName).Any())
                    {
                        //qaDataItem = (QADataItem)f.DataItems.Where(x => x.DataDictionaryEntry.FullName == b.DataDictionaryEntry.FullName).First();
                    }
                    else
                    {
                        //qaDataItem = new QADataItem();
                        //qaDataItem.EquipmentItem = b.EquipmentItem;
                    }

                    setControlLayout(b, X);
                }
                else if (elm is NumericFormElement)
                {
                    ///create refernce to native type
                    NumericFormElement n = (NumericFormElement)elm;
                    ///Create the control
                    MahApps.Metro.Controls.NumericUpDown t = new MahApps.Metro.Controls.NumericUpDown();
                    t.Maximum      = n.Maximum;
                    t.MinHeight    = n.Minimum;
                    t.StringFormat = "{}{0:F" + n.NumberOfDecimals.ToString() + "} " + n.Unit;

                    ///We should never have a NumericFormElement without a DataDictionaryEntry
                    if (n.DataDictionaryEntry != null)
                    {
                        ///This object is the underlying QADataItem that the control will bind to.
                        QADataItem d = null;
                        if (f.DataItems.Where(x => x.DataDictionaryEntry.FullName == n.DataDictionaryEntry.FullName && (x as QADataItem).EquipmentItem.FullName == n.EquipmentItem.FullName).Any())
                        {
                            ///This FormInstance already has a QADataItem that matches on DataDictionaryEntry and EquipmentItem, so let's retrieve that one.
                            d = f.DataItems.Where(x => x.DataDictionaryEntry.FullName == n.DataDictionaryEntry.FullName && (x as QADataItem).EquipmentItem.FullName == n.EquipmentItem.FullName).First() as QADataItem;
                        }
                        else
                        {
                            d = new QuantifiableQADataItem
                            {
                                EquipmentItem       = n.EquipmentItem,
                                DataDictionaryEntry = n.DataDictionaryEntry,
                                QAFormInstance      = f as QAFormInstance
                            };
                        }

                        Binding bd = new Binding("Value");
                        bd.Source = d;

                        bd.Mode = BindingMode.TwoWay;
                        BindingOperations.SetBinding(t, MahApps.Metro.Controls.NumericUpDown.ValueProperty, bd);
                    }
                    else
                    {
                        // / we should log this
                    }


                    //t.LostFocus += new RoutedEventHandler((senderX, eX) => FormatNumericElement(senderX, eX, n.Format + n.NumberOfDecimals));
                    setControlLayout(n, t);
                }
                else if (elm is TextFormElement)
                {
                    TextFormElement tfe = (TextFormElement)elm;
                    TextBox         t   = new TextBox();
                    setControlLayout(tfe, t);
                }
            }
        }
示例#9
0
        public TabLayout()
        {
            this.GridView = new Grid
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                RowSpacing        = 0,
            };
            this.GridView.SetBinding(Grid.ColumnSpacingProperty, new Binding(path: "TabSpacing", source: this));

            this.VerticalOptions   = LayoutOptions.FillAndExpand;
            this.HorizontalOptions = LayoutOptions.FillAndExpand;
            this.Padding           = 0;

            TabContentView = new Grid
            {
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                RowSpacing        = 0
            };
            TabContentView.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Auto)
            });
            TabContentView.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });

            View view = null;

            if (ScrollEnabled)
            {
                view = new HorizontalScrollView
                {
                    Padding     = 0,
                    Orientation = ScrollOrientation.Horizontal,
                    Content     = this.GridView
                };

                CurrentScrollView = view as HorizontalScrollView;
            }
            else
            {
                view = this.GridView;
            }

            var box = new BoxView();

            box.SetBinding(BoxView.HeightRequestProperty, new Binding()
            {
                Source = this, Path = "SeparatorHeight"
            });
            box.SetBinding(BoxView.ColorProperty, new Binding()
            {
                Source = this, Path = "LineColor"
            });

            var box1 = new BoxView();

            box1.SetBinding(BoxView.HeightRequestProperty, new Binding()
            {
                Source = this, Path = "SeparatorHeight"
            });
            box1.SetBinding(BoxView.ColorProperty, new Binding()
            {
                Source = this, Path = "LineColor"
            });

            //this.GridView.Children.Add(box, idx, 1);

            isSettingContent = true;
            var contentLayout = new StackLayout
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Orientation       = StackOrientation.Vertical,
                Padding           = 0,
                Spacing           = 0,
                Children          =
                {
                    box,
                    view,
                    box1
                },
            };

            TabContentView.Children.Add(contentLayout, 0, 0);
            this.Content = TabContentView;

            isSettingContent = false;

            tabHeight        = new RowDefinition();
            tabHeight.Height = new GridLength(this.TabHeight);
            //tabHeight.SetBinding(RowDefinition.HeightProperty, new Binding { Source = this, Path = "HeightRequest" });
            //this.GridView.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) });
            this.GridView.RowDefinitions.Add(tabHeight);

            var lineRow = new RowDefinition();

            lineRow.SetBinding(RowDefinition.HeightProperty, new Binding {
                Source = this, Path = "LineHeight"
            });
            //this.GridView.RowDefinitions.Add(lineRow);
            //this.GridView.ColumnSpacing = 0;
            //this.GridView.RowSpacing = 0;
            _tabChildren.CollectionChanged += _tabChildren_CollectionChanged;

            // TODO: implement XChanged as an event from listview
            //Resolver.Get<IScrollListener>().XChanged += TabLayout_XChanged;
        }
示例#10
0
        protected void BindTabbedExpanders(ref TabbedExpander TopTE, ref TabbedExpander BottomTE, ref T tab, ref RowDefinition rowDef)
        {
            TopTE.SetBinding(
                TabbedExpander.ItemsSourceProperty,
                new Binding()
            {
                Source = tab,
                //Path = new PropertyPath((tab as aTabsWithTabExpVM).TopTabbedExpanderItemsSource),
                Path = new PropertyPath("TopTabbedExpanderItemsSource"),
                Mode = BindingMode.OneWay
            });
            TopTE.SetBinding(
                TabbedExpander.SelectedIndexProperty,
                new Binding()
            {
                Source = tab,
                Path   = new PropertyPath("TopTabbedExpanderSelectedIndex"),
                Mode   = BindingMode.TwoWay
            });

            BottomTE.SetBinding(
                TabbedExpander.ItemsSourceProperty,
                new Binding()
            {
                Source = tab,
                Path   = new PropertyPath("BottomTabbedExpanderItemsSource"),
                Mode   = BindingMode.TwoWay
            });
            BottomTE.SetBinding(
                TabbedExpander.SelectedIndexProperty,
                new Binding()
            {
                Source = tab,
                Path   = new PropertyPath("BottomTabbedExpanderSelectedIndex"),
                Mode   = BindingMode.TwoWay
            });
            BottomTE.SetBinding(
                TabbedExpander.IsExpandedProperty,
                new Binding()
            {
                Source = tab,
                Path   = new PropertyPath("BTEExpanded"),
                Mode   = BindingMode.OneWayToSource
            });
            BottomTE.SetBinding(
                TabbedExpander.EXPANDER_EXPANDED_HEIGHTProperty,
                new Binding()
            {
                Source = tab,
                Path   = new PropertyPath("ExpandedHeight"),
                Mode   = BindingMode.OneWay
            });

            double height = BottomTE.EXPANDER_NOTEXPANDED_HEIGHT;

            BottomTE.SetBinding(
                TabbedExpander.EXPANDER_NOTEXPANDED_HEIGHTProperty,
                new Binding()
            {
                Source = tab,
                Path   = new PropertyPath("NotExpandedHeight"),
                Mode   = BindingMode.OneWayToSource
            });
            BottomTE.EXPANDER_NOTEXPANDED_HEIGHT = height;

            rowDef.SetBinding(
                RowDefinition.HeightProperty,
                new Binding()
            {
                Source = tab,
                Path   = new PropertyPath("BTEGridHeight"),
                Mode   = BindingMode.TwoWay
            });

            /*MultiBinding MBind = new MultiBinding();
             * MBind.Bindings.Add(new Binding() { Source = BottomTE, Path = new PropertyPath("IsExpanded"), Mode = BindingMode.OneWay });
             * MBind.Bindings.Add(new Binding() { Source = tab, Path = new PropertyPath("BTEGridHeight"), Mode = BindingMode.TwoWay });
             * MBind.Bindings.Add(new Binding() { Source = BottomTE, Path = new PropertyPath("EXPANDER_NOTEXPANDED_HEIGHT"), Mode = BindingMode.OneWay });
             * MBind.Converter = new BoolHeightToHeightMulticonverter();
             * MBind.ConverterParameter = "GRID";
             * MBind.Mode = BindingMode.TwoWay;
             * MBind.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
             * rowDef.SetBinding(RowDefinition.HeightProperty, MBind);*/
        }
示例#11
0
		//https://bugzilla.xamarin.com/show_bug.cgi?id=31967
		public void ChangingRowHeightViaBindingTriggersRedraw ()
		{
			var rowdef = new RowDefinition ();
			rowdef.SetBinding (RowDefinition.HeightProperty, "Height");
			var grid = new Grid {
//				RowDefinitions = new RowDefinitionCollection {
//					new RowDefinition { Height = GridLength.Auto },
//					rowdef
//				},
				RowSpacing = 0,
				Platform = new UnitPlatform (),
				IsPlatformEnabled = true,
			};
			grid.RowDefinitions.Add (new RowDefinition { Height = GridLength.Auto });
			grid.RowDefinitions.Add (rowdef);

			var label0 = new Label { IsPlatformEnabled = true };
			Grid.SetRow (label0, 0);
			var label1 = new Label { IsPlatformEnabled = true };
			Grid.SetRow (label1, 1);

			grid.BindingContext = new {Height = 0};
			grid.Children.Add (label0);
			grid.Children.Add (label1);

			Assert.AreEqual (new SizeRequest (new Size (100, 20), new Size (0, 20)), grid.GetSizeRequest (double.PositiveInfinity, double.PositiveInfinity));
			grid.BindingContext = new {Height = 42};
			Assert.AreEqual (new SizeRequest (new Size (100, 62), new Size (0, 62)), grid.GetSizeRequest (double.PositiveInfinity, double.PositiveInfinity));
		}
示例#12
0
		//https://bugzilla.xamarin.com/show_bug.cgi?id=31608
		public void ColAndRowDefinitionsAreActuallyBindable ()
		{
			var rowdef = new RowDefinition ();
			rowdef.SetBinding (RowDefinition.HeightProperty, "Height");
			var grid = new Grid {
				RowDefinitions = new RowDefinitionCollection { rowdef },
			};
			Assert.AreEqual (RowDefinition.HeightProperty.DefaultValue, rowdef.Height);
			grid.BindingContext = new {Height = 32};
			Assert.AreEqual (new GridLength(32), rowdef.Height);
		}
示例#13
0
 private void CreateDefinitions( )
 {
     Debug.WriteLine($"{GameBoard.ActualHeight} x {GameBoard.ActualWidth}");
     var rows = App.GameModel.Rows;
     var columns = App.GameModel.Columns;
     for(var i = 1; i <= rows; i++)
     {
         var heightBinding = new Binding("ActualHeight")
         {
             Converter = new SizeToGridLengthConverter(),
             Source = GameBoard,
             ConverterParameter = "Height"
         };
         var r = new RowDefinition();
         r.SetBinding(RowDefinition.HeightProperty, heightBinding);
         GameBoard.RowDefinitions.Add(r);
     }
     for(var i = 1; i <= columns; i++)
     {
         var widthBinding = new Binding("ActualWidth")
         {
             Converter = new SizeToGridLengthConverter(),
             Source = GameBoard,
             ConverterParameter = "Width"
         };
         var c = new ColumnDefinition();
         c.SetBinding(ColumnDefinition.WidthProperty, widthBinding);
         GameBoard.ColumnDefinitions.Add(c);
     }
 }
        /// <summary>
        /// 页面加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            #region 加载数据

            lblUserName.Content = StoreInfoModel.WorkGroupInfo.GetWorkGroupDetail.UserName;
            lblUserCode.Content = StoreInfoModel.WorkGroupInfo.GetWorkGroupDetail.UserCode;

            //获取计划任务
            ProducePlanInfoModel GetPPlanInfo = new BLL.ExtraBLL.ProducePlanInfoBLL().GetProducePlanInfo();
            if (!GetPPlanInfo.Result)
            {
                MessageBox.Show(GetPPlanInfo.Msg, "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            //获取班组所有生产计划
            planGridContainers = new Grid[GetPPlanInfo.Data.Count];

            #endregion

            #region 加载任务计划列表数据

            long Num = 0;
            lvwPlanInfo.ItemsSource = GetPPlanInfo.Data.Select(item =>
            {
                Num++;
                return(new
                {
                    Num = Num,
                    //PartFigureCode = item.GetProductProcessRoute.FigureCode,
                    PartFigureCode = item.GetProcessBOM.PartFigureCode,
                    ProductName = item.GetProductProcessRoute.ProcessName
                });
            }).ToList();

            #endregion

            #region 加载任务计划磁贴

            for (int i = 0; i < GetPPlanInfo.Data.Count; i++)
            {
                ProducePlanInfoModel.DataModel model = GetPPlanInfo.Data[i];

                planGridContainers[i] = new Grid
                {
                    Margin     = new Thickness(5),
                    Cursor     = Cursors.Hand,
                    MinWidth   = 250,
                    Background = new SolidColorBrush(GetRandomColor()),
                    Focusable  = true,
                    Tag        = model
                };

                Grid grid = new Grid()
                {
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    VerticalAlignment   = VerticalAlignment.Stretch
                };

                Binding bdingGridWidth = new Binding
                {
                    ElementName = "pInfoColWidth",
                    Path        = new PropertyPath("Width")
                };
                grid.SetBinding(WidthProperty, bdingGridWidth);

                grid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(5)
                });
                for (int j = 0; j < 4; j++)
                {
                    RowDefinition rowHeight      = new RowDefinition();
                    Binding       bdingRowHeight = new Binding
                    {
                        ElementName = "pInfoRowHeight",
                        Path        = new PropertyPath("Height")
                    };
                    rowHeight.SetBinding(RowDefinition.HeightProperty, bdingRowHeight);

                    grid.RowDefinitions.Add(rowHeight);
                }
                grid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(5)
                });

                grid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(5)
                });
                ColumnDefinition colWidth      = new ColumnDefinition();
                Binding          bdingColWidth = new Binding
                {
                    ElementName = "pInfoColWidth",
                    Path        = new PropertyPath("Width")
                };
                colWidth.SetBinding(ColumnDefinition.WidthProperty, bdingColWidth);
                grid.ColumnDefinitions.Add(colWidth);
                grid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(5)
                });

                string[] contentArr = new string[] {
                    model.GetProjectProduceDetial.ContractCode,                                                    //合同编号
                    model.GetProject.ProjectName,                                                                  //工程项目
                    model.GetProductProcessRoute.ProcessName + "(" + model.GetProjectProduceDetial.Quantity + ")", //工序名称
                    model.GetProjectProduceDetial.PlanedStartTime == null?(model.GetProjectProduceDetial.PlanedFinishTime == null?"--------":
                                                                           Convert.ToDateTime(model.GetProjectProduceDetial.PlanedFinishTime).ToString("---- - MM:dd HH:mm:ss")):(model.GetProjectProduceDetial.PlanedFinishTime == null?
                                                                                                                                                                                  Convert.ToDateTime(model.GetProjectProduceDetial.PlanedStartTime).ToString("MM-dd HH:mm:ss - ----"):(Convert.ToDateTime(model.GetProjectProduceDetial.PlanedStartTime).ToString("MM-dd HH:mm:ss - ") +
                                                                                                                                                                                                                                                                                       Convert.ToDateTime(model.GetProjectProduceDetial.PlanedFinishTime).ToString("HH:mm:ss")))
                };
                for (int j = 0; j < 4; j++)
                {
                    Label lblContent = new Label()
                    {
                        HorizontalAlignment = HorizontalAlignment.Left,
                        VerticalAlignment   = VerticalAlignment.Center,
                        FontSize            = j.Equals(3) ? 16 : 20,
                        Foreground          = new SolidColorBrush(ConfigInfoModel.ColorSetting.TxtColorA),
                        Content             = contentArr[j]
                    };
                    grid.Children.Add(lblContent);

                    Grid.SetColumn(lblContent, 1);
                    Grid.SetRow(lblContent, j + 1);
                }

                planGridContainers[i].MouseDown += new MouseButtonEventHandler(Grid_MouseDown);
                planGridContainers[i].MouseUp   += new MouseButtonEventHandler(Grid_MouseUp);

                planGridContainers[i].Children.Add(grid);
                planInfoContainer.Children.Add(planGridContainers[i]);
            }

            #endregion

            #region 页面区域焦点

            //默认选择第一个生产计划
            if (planGridContainers.Length > 0)
            {
                Border borderGrid = new Border();
                borderGrid.BorderBrush     = new SolidColorBrush(Color.FromRgb(158, 183, 241));
                borderGrid.BorderThickness = new Thickness(2);
                planGridContainers[0].Children.Add(borderGrid);
            }

            Border border = new Border();
            border.BorderBrush     = new SolidColorBrush(Color.FromRgb(0, 255, 255));
            border.BorderThickness = new Thickness(2);
            if (focusArea.Equals(FocusAreaEnum.LeftFocus))
            {
                tbPlanInfoList.Children.Add(border);
            }
            else if (focusArea.Equals(FocusAreaEnum.RightFocus))
            {
                tbPlanInfoContainer.Children.Add(border);
            }
            else
            {
            }

            //任务计划列表默认选中第一条
            lvwPlanInfo.Focus();
            if (lvwPlanInfo.Items.Count > 0)
            {
                lvwPlanInfo.SelectedIndex = 0;
            }

            #endregion
        }