Exemple #1
0
    // Use this for initialization
    private void Start()
    {
        modalWindow.Initialize();
        modalWindow.OnShow += CustomModalWindowPop;
        modalWindow.OnHide  = CustomModalWindowPop;

        toggleWindowBtn.onClick.AddListener(() => {
            if (!modalWindow.IsActive())
            {
                modalWindow.Show();
            }
            else
            {
                modalWindow.Hide();
            }
        });
    }
Exemple #2
0
        private void ConfigureModalOk(ModalWindow modal, string okText = "OK")
        {
            var no = Buttons.ModalButton(modal, okText, 0, 35, ColorStyle.Green);

            no.Move((modal.Width - no.Width) / 2, no.Y);
            no.OnRelease += caller =>
            {
                if (modal.OnOkRelease != null)
                {
                    modal.OnOkRelease();
                }

                modal.Hide();
            };
            no.Name = okText;

            const int kSize  = 22;
            const int kWidth = 350;

            var header = new TextArea(modal, (Application.Screen.Width - kWidth) / 2, 215, kWidth, kSize);

            header.SetAlign(Align.Center, new GfxPoint(0, 5));
            header.SetFont(Palette.Black, kSize + 4);

            var       text    = new List <TextArea[]>();
            const int kWidth0 = 225;
            const int kWidth1 = 125;

            for (var i = 0; i < 6; i++) // 6 строк
            {
                var line0 = new TextArea(modal, 60, 90 + kSize * i, kWidth0, kSize);
                var line1 = new TextArea(modal, (60 + kWidth0), 90 + kSize * i, kWidth1, kSize);

                line0.SetAlign(Align.Left, new GfxPoint(5, 5));
                line0.SetFont(Palette.Black, kSize);

                line1.SetAlign(Align.Left, new GfxPoint(5, 5));
                line1.SetFont(Palette.Black, kSize);

                text.Add(new[] { line0, line1 });
            }

            modal.OnShow += caller =>
            {
                if (!string.IsNullOrEmpty(modal.Header))
                {
                    header.Text = modal.Header;
                }

                if (string.IsNullOrEmpty(modal.Message))
                {
                    return;
                }

                var lines = modal.Message.Split(new[] { "\\t" }, StringSplitOptions.None);
                for (var i = 0; i < (lines.Length / 2); i++)
                {
                    text[i][0].Text = lines[lines.Length - 2 * i - 2];
                    text[i][1].Text = lines[lines.Length - 2 * i - 1];
                }
            };
        }
Exemple #3
0
        private void ConfigureModalYesNo(ModalWindow modal, string yesText = "Yes", string noText = "No")
        {
            var no = Buttons.ModalButton(modal, yesText, 65, 35, ColorStyle.Red);

            no.OnRelease += caller =>
            {
                if (modal.OnNoRelease != null)
                {
                    modal.OnNoRelease();
                }

                modal.Hide();
            };
            no.Name = noText;

            var yes = Buttons.ModalButton(modal, yesText, 320, 35, ColorStyle.Green);

            yes.OnRelease += caller =>
            {
                if (modal.OnYesRelease != null)
                {
                    modal.OnYesRelease();
                }

                modal.Hide();
            };
            yes.Name = yesText;

            const int kSize  = 22;
            const int kWidth = 350;

            var header = new TextArea(modal, (Application.Screen.Width - kWidth) / 2, 215, kWidth, kSize);

            header.SetAlign(Align.Center, new GfxPoint(0, 5));
            header.SetFont(Palette.Black, kSize + 4);

            var text = new List <TextArea>();

            for (var i = 0; i < 6; i++) // 6 строк
            {
                var line = new TextArea(modal, (Application.Screen.Width - kWidth) / 2, 90 + kSize * i, kWidth, kSize);

                line.SetAlign(Align.Center, new GfxPoint(0, 5));
                line.SetFont(Palette.Black, kSize);
                text.Add(line);
            }

            modal.OnShow += caller =>
            {
                if (!string.IsNullOrEmpty(modal.Header))
                {
                    header.Text = modal.Header;
                }

                if (string.IsNullOrEmpty(modal.Message))
                {
                    return;
                }

                var lines = modal.Message.Split(new[] { "\\r", "\\n" }, StringSplitOptions.None);
                for (var i = 0; i < ((lines.Length < 5) ? lines.Length : 5); i++)
                {
                    text[i].Text = lines[lines.Length - i - 1];
                }
            };
        }