/// <summary>
        /// レイアウトを初期化します。
        /// </summary>
        public VerticalCalculationPage()
        {
            Calculator = new NormalCalculator();

            InitMemberControl();
            Padding = DisplayPadding.Padding;
            Title   = "電卓";

            var AnswerView = new Frame {
                Margin            = new Thickness(10, 10, 10, 10),
                Padding           = new Thickness(5, 0, 5, 2),
                BackgroundColor   = Color.Cyan,
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HeightRequest     = 100,
                Content           = LblAnswer,
            };

            var ButtonView = new Grid {
                Margin            = new Thickness(10, 0, 10, 10),
                RowSpacing        = 5,
                ColumnSpacing     = 5,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.Fill,
                RowDefinitions    =
                {
                    new RowDefinition {
                        Height = new GridLength(1.0, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1.0, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1.0, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1.0, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1.0, GridUnitType.Star)
                    },
                },
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(1.0, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1.0, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1.0, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1.0, GridUnitType.Star)
                    },
                }
            };

            ButtonView.Children.Add(BtnAllClear, 0, 0);
            ButtonView.Children.Add(BtnClear, 1, 0);
            ButtonView.Children.Add(BtnDelete, 2, 0);

            foreach (var i in BtnsNumber.Skip(1).Select((v, ix) => new { val = v, ix = ix + 1 }))
            {
                if (i.ix == 0)
                {
                    throw new Exception();
                }
                ButtonView.Children.Add(i.val, (i.ix - 1) % 3, 3 - (i.ix - 1) / 3);
            }

            ButtonView.Children.Add(BtnsNumber[0], 0, 2, 4, 5);
            ButtonView.Children.Add(BtnPeriod, 2, 4);

            ButtonView.Children.Add(BtnDivide, 3, 0);
            ButtonView.Children.Add(BtnMulti, 3, 1);
            ButtonView.Children.Add(BtnMinus, 3, 2);
            ButtonView.Children.Add(BtnPlus, 3, 3);
            ButtonView.Children.Add(BtnEqual, 3, 4);


            Content = new StackLayout {
                BackgroundColor   = Color.Cyan,
                VerticalOptions   = LayoutOptions.Fill,
                HorizontalOptions = LayoutOptions.Fill,
                Children          = { AnswerView, ButtonView }
            };
        }
예제 #2
0
 public NormalCalculator(NormalCalculator ops)
 {
     Answer   = new CalculatorNumber(ops.Answer);
     OpsValue = new CalculatorNumber(ops.OpsValue);
     Operator = ops.Operator;
 }