示例#1
0
        void InitLayout()
        {
            // head

            imgButtonBack         = new Image();
            imgButtonBack.Source  = "@drawable/btn_back.png";
            tgrButtonBack         = new TapGestureRecognizer();
            tgrButtonBack.Tapped += OnButtonBackTapped;
            imgButtonBack.GestureRecognizers.Add(tgrButtonBack);
            layout.Children.Add
            (
                imgButtonBack,
                Constraint.RelativeToParent(parent => parent.Width * 0.036),
                Constraint.RelativeToParent(parent => parent.Height * 0.022)
            );

            lblCaption           = new CustomLabel();
            lblCaption.Text      = Localization.pageSetupCaption;
            lblCaption.Size      = CustomLabel.SIZE_CAPTION;
            lblCaption.TextColor = Color.FromHex("4D4C4A");
            layout.Children.Add
            (
                lblCaption,
                Constraint.RelativeToParent(parent => parent.Width * 0.5 - lblCaption.Width * 0.5),
                Constraint.RelativeToParent(parent => parent.Height * 0.03)
            );

            imgButtonHelp         = new Image();
            imgButtonHelp.Source  = "@drawable/btn_help_setup.png";
            tgrButtonHelp         = new TapGestureRecognizer();
            tgrButtonHelp.Tapped += OnButtonHelpTapped;
            imgButtonHelp.GestureRecognizers.Add(tgrButtonHelp);
            layout.Children.Add
            (
                imgButtonHelp,
                Constraint.RelativeToParent(parent => parent.Width * 0.81),
                Constraint.RelativeToParent(parent => parent.Height * 0.022)
            );

            // body

            lblMode      = new CustomLabel();
            lblMode.Size = CustomLabel.SIZE_CAPTION_DE;
            if (mode == ResultMode.Brake)
            {
                lblMode.Text = Localization.runModeBrake;
            }
            else if (mode == ResultMode.ZeroToZero)
            {
                lblMode.Text = Localization.runModeZeroToZero;
            }
            else
            {
                lblMode.Text = Localization.runModeAcceleration;
            }

            if (mode == ResultMode.Brake)
            {
                lblMode.TextColor = Color.FromHex("FFB02B");
            }
            else if (mode == ResultMode.ZeroToZero)
            {
                lblMode.TextColor = Color.FromHex("0CFF71");
            }
            else
            {
                lblMode.TextColor = Color.FromHex("00FFFF");
            }

            double modePosition;

            if (mode == ResultMode.Brake)
            {
                modePosition = 0.19;
            }
            else if (mode == ResultMode.ZeroToZero)
            {
                modePosition = 0.19;
            }
            else
            {
                modePosition = 0.13;
            }
            layout.Children.Add
            (
                lblMode,
                Constraint.RelativeToParent((parent) => parent.Width * 0.5 - lblMode.Width * 0.5),
                Constraint.RelativeToParent((parent) => parent.Height * modePosition)
            );

            if (mode == ResultMode.Speed)
            {
                // mode switch

                imgSwitchSpeedDistance         = new Image();
                imgSwitchSpeedDistance.Source  = Localization.btn_setup_switch_speed;
                tgrSwitchSpeedDistance         = new TapGestureRecognizer();
                tgrSwitchSpeedDistance.Tapped += OnButtonSwitchSpeedDistanceTapped;
                imgSwitchSpeedDistance.GestureRecognizers.Add(tgrSwitchSpeedDistance);
                layout.Children.Add
                (
                    imgSwitchSpeedDistance,
                    Constraint.RelativeToParent((parent) => parent.Width * 0.5 - imgSwitchSpeedDistance.Width * 0.5),
                    Constraint.RelativeToParent((parent) => parent.Height * 0.20)
                );
                imgSwitchSpeedDistance.SizeChanged += ((obj, sender) => layout.ForceLayout());
            }

            // button default

            btnDefault                 = new Button();
            btnDefault.Image           = "@drawable/btn_setup_default.png";
            btnDefault.BackgroundColor = Color.Transparent;
            btnDefault.Clicked        += OnButtonDefault;
            layout.Children.Add
            (
                btnDefault,
                Constraint.RelativeToParent((parent) => parent.Width - btnDefault.Width * 0.9),
                Constraint.RelativeToParent((parent) => parent.Height * 0.15)
            );

            // picker start

            if (mode == ResultMode.ZeroToZero)
            {
                CreatePickerZeroToZeroStart();
            }
            else if (mode == ResultMode.Brake)
            {
                CreatePickerBrakeStart();
            }
            else
            {
                CreatePickerSpeedStart();
            }
            pickerStart.IsVisible             = false;
            pickerStart.SelectedIndexChanged += OnPickerSelectedIndexChanged;
            layout.Children.Add
            (
                pickerStart,
                Constraint.RelativeToParent((parent) => parent.Width * 0.03),
                Constraint.RelativeToParent((parent) => parent.Height * 0.27)
            );

            // button picker start

            btnPickerStart                 = new Button();
            btnPickerStart.Image           = Localization.btn_setup_start;
            btnPickerStart.BackgroundColor = Color.Transparent;
            btnPickerStart.Clicked        += OnButtonPickerStartCicked;
            layout.Children.Add
            (
                btnPickerStart,
                Constraint.RelativeToView(pickerStart, (parent, view) => view.X),
                Constraint.RelativeToView(pickerStart, (parent, view) => view.Y)
            );

            // picker end

            if (mode == ResultMode.ZeroToZero)
            {
                CreatePickerZeroToZeroEnd();
            }
            else if (mode == ResultMode.Brake)
            {
                CreatePickerBrakeEnd();
            }
            else
            {
                CreatePickerSpeedEnd();
            }
            pickerEnd.IsVisible             = false;
            pickerEnd.SelectedIndexChanged += OnPickerSelectedIndexChanged;
            layout.Children.Add
            (
                pickerEnd,
                Constraint.RelativeToParent((parent) => parent.Width * 0.9 - pickerEnd.Width),
                Constraint.RelativeToParent((parent) => parent.Height * 0.27)
            );

            // button picker end

            btnPickerEnd                 = new Button();
            btnPickerEnd.Image           = Localization.btn_setup_stop;
            btnPickerEnd.BackgroundColor = Color.Transparent;
            btnPickerEnd.Clicked        += OnButtonPickerEndCicked;
            layout.Children.Add
            (
                btnPickerEnd,
                Constraint.RelativeToView(pickerEnd, (parent, view) => view.X + view.Width * 0.25),
                Constraint.RelativeToView(pickerEnd, (parent, view) => view.Y)
            );

            // debug

            if (Config.Setup.DebugLabelEnabled)
            {
                lblDebug = new Label();
                SetDebugText("item count: " + runResult.Count);
                layout.Children.Add
                (
                    lblDebug,
                    Constraint.RelativeToParent((parent) => parent.Width * 0.5 - lblDebug.Width * 0.5),
                    Constraint.RelativeToParent((parent) => parent.Height * 0.7)
                );
                lblDebug.SizeChanged += (sender, e) => layout.ForceLayout();
            }

            // add, remove

            btnAdd = new Button();
            btnAdd.BackgroundColor = Color.Transparent;
            SetButtonAddActive(false);
            btnAdd.Clicked += OnButtonAdd;
            layout.Children.Add
            (
                btnAdd,
                Constraint.RelativeToParent((parent) => parent.Width * 0.25 - btnAdd.Width * 0.5),
                Constraint.RelativeToParent((parent) => parent.Height - btnAdd.Height * 1.1)
            );

            btnRemove                 = new Button();
            btnRemove.Clicked        += OnButtonRemove;
            btnRemove.BackgroundColor = Color.Transparent;
            SetButtonRemoveActive(false);
            layout.Children.Add
            (
                btnRemove,
                Constraint.RelativeToParent((parent) => parent.Width * 0.75 - btnRemove.Width * 0.5),
                Constraint.RelativeToParent((parent) => parent.Height - btnRemove.Height * 1.1)
            );

            // list view

            layout.Children.Add
            (
                listView,
                Constraint.RelativeToParent(parent => parent.Width * 0.5 - listView.Width * 0.5),
                Constraint.RelativeToView(pickerStart, (parent, view) => view.Y + view.Height * 1.3),
                Constraint.RelativeToParent(parent => parent.Width * 0.8),
                Constraint.RelativeToParent(parent => btnAdd.Y - listView.Y)
            );
        }