コード例 #1
0
ファイル: PromptServices.cs プロジェクト: annajoyw/CloseUp
        //add admin authentication here?

        //private readonly Guid _userId;

        //public PromptServices(Guid userId)
        //{
        //    _userId = userId;
        //}

        public bool CreatePrompt(PromptCreate model)
        {
            var entity =
                new PromptItem()
            {
                Category = model.Category,
                Prompt   = model.Prompt
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.PromptItems.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
コード例 #2
0
ファイル: KeyboardPrompt.cs プロジェクト: Skodeva/SDK4
    public void Init(Action <string> onPromptItemClick)
    {
        for (int i = 0; i < promptItems.Length; i++)
        {
            PromptItem promptItem = promptItems[i];
            promptItem.onPromptItemClick = OnPromptItemClickCallback;
        }

        enteredRect.GetComponent <KeyboardKeydownBtn>().onClick.RemoveAllListeners();
        enteredRect.GetComponent <KeyboardKeydownBtn>().onClick.AddListener(OnEnteredPromptItemClickCallback);

        turnLeftBtn.onClick.RemoveAllListeners();
        turnLeftBtn.onClick.AddListener(TurnLeft);
        turnRightBtn.onClick.RemoveAllListeners();
        turnRightBtn.onClick.AddListener(TurnRight);

        this.onPromptItemClick = onPromptItemClick;
    }
コード例 #3
0
ファイル: KeyboardPrompt.cs プロジェクト: Skodeva/SDK4
    private void RefreshPromptItem()
    {
        int startIndex    = currentPageCount * PROMPT_PER_PAGE;
        int endIndex      = totalPageCount != currentPageCount ? startIndex + PROMPT_PER_PAGE - 1 : startIndex + wordCount % PROMPT_PER_PAGE - 1;
        int loopWordCount = endIndex - startIndex;

        for (int i = 0; i < promptItems.Length; i++)
        {
            int        wordIndex  = startIndex + i;
            PromptItem promptItem = promptItems[i];
            if (i <= loopWordCount)
            {
                string chineseWord = ChineseIMEManager.Instance.GetWord(wordIndex);
                promptItem.SetChineseWord(chineseWord, wordIndex);
            }
            else
            {
                promptItem.SetChineseWord(null, -1);
            }
        }
        SetChineseFirstEnteredText();
        LayoutRebuilder.ForceRebuildLayoutImmediate(this.GetComponent <RectTransform>());
    }
コード例 #4
0
        private void loadCellPrompts()
        {
            //读取Tabs
            for (int i = 0; i < PromptCells.Rows.RowCount; i++)
            {
                string TabName = PromptCells[i, 13].Text;
                if (!string.IsNullOrEmpty(TabName))
                {                   
                    //logger.Debug("增加Tab:" + TabName);
                    this.PromptTabs.Add(TabName);
                }
                else
                    break;
            }

            //读取计算器
            for (int i = 0; i < PromptCells.Rows.RowCount; i++)
            {
                string CalName = PromptCells[i, 17].Text;
                if (!string.IsNullOrEmpty(CalName))
                {
                    //logger.Debug("增加计算器:" + CalName);

                    var strs = CalName.Split('|');
                    if (strs.Length < 3)
                        continue;

                    string name = strs[0];

                    double upperBound;
                    if (!double.TryParse(strs[1], out upperBound))
                    { continue; }

                    double gap;
                    if (!double.TryParse(strs[2], out gap))
                    { continue; }

                    Calcuators.Add(new CalculatorItem()
                    {
                        Name = name,
                        UpperBound = upperBound,
                        Gap = gap,
                        Index = i
                    });
                }
                else
                    break;
            }

            for (int i = 0; i < PromptCells.Rows.RowCount; i++)
            {
                var name = PromptCells[i, 0].Text;

                if (string.IsNullOrEmpty(name))
                {
                    //logger.Info("空行中断读取,行号:" + i.ToString());
                    break;
                }

                //忽略宽度、高度、深度三个变量
                if (i == 0 || i == 1 || i == 2)
                { continue; }

                string value = PromptCells[i, 1].Text;
                string controlType = PromptCells[i, 2].Text;
                string helpMessage = PromptCells[i, 3].Text;
                string verifyCode = PromptCells[i, 4].Text;
                string comboString = PromptCells[i, 5].Text;
                string color = PromptCells[i, 7].Text;
                string picture = PromptCells[i, 9].Text;
                string visible = PromptCells[i, 10].Text;
                string hideInReport = PromptCells[i, 11].Text;
                string tabIndex = PromptCells[i, 12].Text;
                string calculatorIndex = PromptCells[i, 16].Text;


                //logger.Debug(string.Format("Prompt变量数据:{0}/{1}/{2}/{3}/{4}/{5}/{6}/{7}/{8}/{9}/{10}/{11}",
                //                           name,
                //                           value,
                //                           controlType,
                //                           helpMessage,
                //                           verifyCode,
                //                           comboString,
                //                           color,
                //                           picture,
                //                           visible,
                //                           hideInReport,
                //                           tabIndex,
                //                           calculatorIndex));

                PromptItem prompt = new PromptItem(name, value, controlType, helpMessage, verifyCode, comboString, color, picture, visible, hideInReport, tabIndex, calculatorIndex, i, this);
                Prompts.Add(prompt);
            }
        }
コード例 #5
0
 public void RecordControlTypeChange(PromptItem prompt)
 {
     PromptsChangedControlType.Add(prompt);
 }
コード例 #6
0
        /// <summary>
        /// 变量修改触发重新检查数据
        /// </summary>
        /// <param name="prompt">那个被修改的变量,要把修改值写回表格中</param>
        public void ReloadValues(PromptItem prompt)
        {
            PromptCells[prompt.RowNumber, 1].Value = prompt.PromptValue;

            PromptsChangedControlType.Clear();

            foreach (var p in Prompts)
            {
                if (p == prompt)
                    continue;

                string name = PromptCells[p.RowNumber, 0].Text;
                string value = PromptCells[p.RowNumber, 1].Text;
                string controlType = PromptCells[p.RowNumber, 2].Text;
                string helpMessage = PromptCells[p.RowNumber, 3].Text;
                string verifyCode = PromptCells[p.RowNumber, 4].Text;
                string comboString = PromptCells[p.RowNumber, 5].Text;
                string color = PromptCells[p.RowNumber, 7].Text;
                string picture = PromptCells[p.RowNumber, 9].Text;
                string visible = PromptCells[p.RowNumber, 10].Text;
                string hideInReport = PromptCells[p.RowNumber, 11].Text;
                string tabIndex = PromptCells[p.RowNumber, 12].Text;
                string calculatorIndex = PromptCells[p.RowNumber, 16].Text;  //TODO:这里和之前的逻辑貌似是重叠了?

                //标记一下,防止循环更新导致死循环
                p.IsPassive = true;
                p.LoadProperty(name, value, controlType, helpMessage, verifyCode, comboString, color, picture, visible, hideInReport, tabIndex, calculatorIndex);
                p.IsPassive = false;
            }

            ControlTypeChangedAction(PromptsChangedControlType);
            //ControlTypeChanged(PromptsChangedControlType);
        }
コード例 #7
0
ファイル: KeyboardPrompt.cs プロジェクト: Skodeva/SDK4
    public string GetFirstChineseWord()
    {
        PromptItem firstPromptItem = promptItems[0];

        return(firstPromptItem.chineseWord);
    }
コード例 #8
0
        private void HandlePrompt()
        {
            ICondition?condition     = null;
            TimeSpan?  timeLimit     = null;
            string?    defaultChoice = null;
            var        randomOrder   = false;

            if (reader.IsEmptyElement)
            {
                throw new StoryboardParsingException(reader, $"O elemento '{Prompt}' não pode estar vazio.");
            }

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case When:
                    condition = GetCondition(reader.Value);
                    break;

                case Time:
                    if (!int.TryParse(reader.Value, out var seconds))
                    {
                        throw new StoryboardParsingException(reader, $"O valor '{reader.Value}' não é válido para o atributo '{Time}'. É esperado um número inteiro.");
                    }
                    timeLimit = TimeSpan.FromSeconds(seconds);
                    break;

                case Default:
                    if (!Regex.IsMatch(reader.Value, @"^[a-z]$"))
                    {
                        throw new StoryboardParsingException(reader, $"O valor '{reader.Value}' não é válido para o atributo '{Default}'. É esperada uma opção de 'a' a 'z'.");
                    }
                    defaultChoice = reader.Value;
                    break;

                case RandomOrder:
                    switch (reader.Value)
                    {
                    case "true":
                    case "1":
                        randomOrder = true;
                        break;

                    case "false":
                    case "0":
                        randomOrder = false;
                        break;

                    default:
                        throw new StoryboardParsingException(reader, $"O valor '{reader.Value}' não é válido para o atributo '{RandomOrder}'. É esperado '1' ou '0'.");
                    }
                    break;

                default:
                    throw new StoryboardParsingException(reader, $"O atributo '{reader.LocalName}' não é suportado para o elemento '{Prompt}'.");
                }
            }

            var             choices      = new List <Choice>();
            var             triggerFound = false;
            IStoryboardItem?trigger      = null;

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (Regex.IsMatch(reader.LocalName, @"^[a-z]$"))
                    {
                        choices.Add(LoadChoice());
                    }
                    else
                    {
                        trigger      = HandlePromptTriggerElement(triggerFound);
                        triggerFound = true;
                    }
                }
                else if (reader.NodeType == XmlNodeType.EndElement)
                {
                    if (reader.LocalName == Prompt)
                    {
                        if (choices.Count == 0)
                        {
                            throw new StoryboardParsingException(reader, $"Nenhuma escolha definida no elemento '{Prompt}'. Favor definir um ou mais elementos de 'a' a 'z'.");
                        }
                        break;
                    }
                }
            }

            if (trigger == null)
            {
                throw new StoryboardParsingException(reader, $"O elemento '{Prompt}' precisa conter um elemento '{Narration}', '{Tutorial}', '{Observe}', '{Speech}' ou '{Thought}'.");
            }

            var prompt     = new Prompt(choices, timeLimit, defaultChoice, randomOrder);
            var promptItem = new PromptItem(prompt, condition);

            promptItem.Block.ForwardQueue.Enqueue(trigger);
            Add(promptItem);
        }