/// <summary>
        /// Constructor
        /// </summary>
        internal MainWindowView(MainWindowModel m, SettingsCallback settings, ControlCallback control, UnityAction close) : base(
                CommonWindowProperties.mainListMinWidth + 20, // min width
                CommonWindowProperties.mainListMinHeight,     // min height
                CommonWindowProperties.mainWindowSpacing,     // spacing
                CommonWindowProperties.mainElementPadding,    // padding
                TextAnchor.UpperLeft                          // text anchor
                )
        {
            model            = m;
            settingsCallback = settings;
            controlCallback  = control;
            closeCallback    = close;

            // Filter
            AddChild(new DialogGUIHorizontalLayout(
                         new DialogGUIToggle(model.GetActiveControllersToggleState(), Localizer.Format("#LOC_BV_ActiveControllers"), model.ActiveControllersChecked, 140f),
                         new DialogGUIToggle(model.GetDisabledControllersToggleState(), Localizer.Format("#LOC_BV_DisabledControllers"), model.DisabledControllersChecked, 140f),
                         new DialogGUIFlexibleSpace(),
                         new DialogGUIButton(model.GetControlButtonText, ToggleControl, model.ControlButtonCanBeEnabled, 150f, CommonWindowProperties.buttonHeight, false, CommonWindowProperties.ActiveSkin.button)
                         ));

            // Column headers
            AddChild(new DialogGUIHorizontalLayout(
                         new DialogGUISpace(0f),
                         new DialogGUILabel(Localizer.Format("#LOC_BV_ColumnHeader_Name"), 150f)
            {
                guiStyle = CommonWindowProperties.Style_Label_Bold_Left
            },
                         new DialogGUISpace(10f),
                         new DialogGUILabel(Localizer.Format("#LOC_BV_ColumnHeader_Status"), 70f)
            {
                guiStyle = CommonWindowProperties.Style_Label_Bold_Center
            },
                         new DialogGUISpace(10f),
                         new DialogGUILabel(Localizer.Format("#LOC_BV_ColumnHeader_Body"), 60f)
            {
                guiStyle = CommonWindowProperties.Style_Label_Bold_Center
            },
                         new DialogGUISpace(10f),
                         new DialogGUILabel(Localizer.Format("#LOC_BV_ColumnHeader_Speed"), 60f)
            {
                guiStyle = CommonWindowProperties.Style_Label_Bold_Center
            },
                         new DialogGUISpace(10f),
                         new DialogGUILabel(Localizer.Format("#LOC_BV_ColumnHeader_Distance"), 90f)
            {
                guiStyle = CommonWindowProperties.Style_Label_Bold_Center
            }
                         ));

            AddChild(new DialogGUIScrollList(new Vector2(CommonWindowProperties.mainListMinWidth, CommonWindowProperties.mainListMinHeight + 220), false, true, model.GetVesselListLayout()));
        }
示例#2
0
        public async Task HandleAsync(IUpdateContext context, UpdateDelegate next, CancellationToken cancellationToken)
        {
            _telegramService = new TelegramService(context);
            CallbackQuery cq = context.Update.CallbackQuery;

            _telegramService.CallBackMessageId = cq.Message.MessageId;

            Log.Information("CallbackQuery" + cq.ToJson(true));
            // Log.Information($"CallBackData: {cq.Data}");

            var partsCallback = cq.Data.SplitText(" ");

            Log.Information($"Callbacks: {partsCallback.ToJson()}");

            switch (partsCallback[0]) // Level 0
            {
            case "action":
                var callbackResult = new ActionCallback(_telegramService);
                Log.Information($"ActionResult: {callbackResult.ToJson(true)}");
                break;

            case "help":
                var helpCallback = new HelpCallback(_telegramService);
                Log.Information($"HelpResult: {helpCallback.ToJson(true)}");
                break;

            case "setting":
                var settingsCallback = new SettingsCallback(_telegramService);
                Log.Information($"SettingsResult: {settingsCallback.ToJson(true)}");
                break;

            case "verify":
                var verifyCallback = new VerifyCallback(_telegramService);
                Log.Information($"VerifyResult: {verifyCallback.ToJson(true)}");
                break;
            }

            // await context.Bot.Client.AnswerCallbackQueryAsync(cq.Id, "PONG", true);

            await next(context, cancellationToken)
            .ConfigureAwait(false);
        }