Ejemplo n.º 1
0
        public IPrompt BuildFrom(PromptInfo promptInfo)
        {
            var items        = new ObservableCollection <T>();
            var defaultItems = new ObservableCollection <T>();

            foreach (var availableItem in promptInfo.PromptLevelInfo.AvailableItems)
            {
                var promptItem = _promptItemProvider.Get(
                    promptInfo.Name
                    , promptInfo.PromptLevelInfo.ParameterName
                    , availableItem);

                foreach (var defaultValidValue in promptInfo.DefaultValues)
                {
                    if (availableItem.Value == defaultValidValue.Value)
                    {
                        if (defaultValidValue.IsAllMember)
                        {
                            promptItem.IsDefaultAll = true;
                        }
                        defaultItems.Add(promptItem);
                    }
                }

                items.Add(promptItem);
            }

            return(_shoppingCartProvider.Get(promptInfo, items, defaultItems));
        }
Ejemplo n.º 2
0
        public IPrompt BuildFrom(PromptInfo promptInfo)
        {
            switch (promptInfo.PromptType)
            {
            case PromptType.Tree:
                return(_treeBuilder.BuildFrom(promptInfo));

            case PromptType.ShoppingCart:
                return(_shoppingCartBuilder.BuildFrom(promptInfo));

            case PromptType.DropDown:
                return(_dropDownBuilder.BuildFrom(promptInfo));

            case PromptType.CasscadingSearch:
                return(_casscadingSearchShoppingCartBuilder.BuildFrom(promptInfo));

            case PromptType.SingleSelectTree:
                return(_singleSelectTreeBuilder.BuildFrom(promptInfo));

            case PromptType.Empty:
                return(_emptyPromptBuilder.BuildFrom(promptInfo));

            case PromptType.RecursiveTree:
                return(_recursiveTreeBuilder.BuildFrom(promptInfo));

            case PromptType.RecursiveSingleSelectTree:
                return(_recursiveSingleSelectTreeBuilder.BuildFrom(promptInfo));

            default:
                throw new Exception();
            }
        }
Ejemplo n.º 3
0
        protected static string userPrompt(PromptInfo promptInfo)
        {
            Console.Clear();
            Console.WriteLine(promptInfo.Question);
            Console.WriteLine();
            string optionLine;

            foreach (var item in promptInfo.Options)
            {
                optionLine = $"\t'{item.Key}'\t– {item.Value}";
                if (item.Key == promptInfo.Default)
                {
                    optionLine += " (default)";
                }
                Console.WriteLine(optionLine);
            }
            Console.WriteLine("\nType one of the following options and press Enter key. \nPress only Enter key to choose default option.\n");
            string resultValue = Console.ReadLine().Trim();

            if (String.IsNullOrEmpty(resultValue))
            {
                resultValue = promptInfo.Default;
            }
            if (promptInfo.Options.ContainsKey(resultValue))
            {
                return(resultValue);
            }
            return(Program.userPrompt(promptInfo));
        }
Ejemplo n.º 4
0
        public IPrompt BuildFrom(PromptInfo promptInfo)
        {
            var availableItems = _promptItemCollectionProvider.Get(
                promptInfo.Name,
                promptInfo.PromptLevelInfo.ParameterName,
                promptInfo.PromptLevelInfo.AvailableItems);

            var defaultItems = _promptItemCollectionProvider.Get(
                promptInfo.Name,
                promptInfo.PromptLevelInfo.ParameterName,
                promptInfo.DefaultValues);

            var prompt = _casscadingSearchProvider.Get(
                promptInfo.Label,
                promptInfo.Name,
                promptInfo.PromptLevelInfo.ParameterName,
                availableItems,
                defaultItems);

            if (promptInfo.DefaultValues.Count == 1)
            {
                prompt.SearchString = promptInfo.DefaultValues.Single().labelField;
            }

            return(prompt);
        }
        public IPrompt BuildFrom(PromptInfo promptInfo)
        {
            var promptItems = new ObservableCollection <T>();

            if (promptInfo.DefaultValues.Count() > 1)
            {
                throw new DropDownBuilderException();
            }

            var defaultValue = promptInfo.DefaultValues.SingleOrDefault();

            IPromptItem defaultItem = null;

            foreach (var availableItem in promptInfo.PromptLevelInfo.AvailableItems)
            {
                var promptItem = _promptItemProvider.Get(
                    promptInfo.Name
                    , promptInfo.PromptLevelInfo.ParameterName
                    , availableItem);

                if (defaultValue != null)
                {
                    if (defaultValue.Value == availableItem.Value)
                    {
                        defaultItem = promptItem;
                    }
                }

                promptItems.Add(promptItem);
            }

            return(_promptProvider.Get(promptInfo.Name, promptInfo.Label, promptItems, defaultItem));
        }
Ejemplo n.º 6
0
 public void HidePrompt()
 {
     if (CurrentPrompt != null)
     {
         TogglePromptPanel(false);
         CurrentPrompt = null;
     }
 }
Ejemplo n.º 7
0
 public IPrompt Get(PromptInfo promptInfo, ObservableCollection <ITreeNode> availableItems, ObservableCollection <ITreeNode> defaultSelections)
 {
     return(new MultiSelectHierarchy(
                promptInfo.Name,
                promptInfo.Label,
                availableItems,
                defaultSelections));
 }
Ejemplo n.º 8
0
    /// <summary>
    /// 说明界面信息
    /// </summary>
    public static void ShowHelpPanel(List <object> decsList)
    {
        PromptInfo promptInfo = new PromptInfo();

        promptInfo.type    = PromptType.Help;
        promptInfo.objList = decsList;
        Facade.Instance.SendNotification(NotificationID.Prompt_Show, promptInfo);
    }
Ejemplo n.º 9
0
    /// <summary>
    /// 界面显示时调用
    /// </summary>
    protected override void OnShow(INotification notification)
    {
        PromptInfo info = notification.Body as PromptInfo;

        if (info.type == PromptType.Choose)
        {
            m_Panel.tishiUI.gameObject.SetActive(true);
            m_Panel.ok.gameObject.SetActive(true);
            m_Panel.no.gameObject.SetActive(true);
            m_Panel.content.text = info.content;
            clickOk = info.clickOk;
        }
        else if (info.type == PromptType.Tishi)
        {
            m_Panel.tishiUI.gameObject.SetActive(true);
            m_Panel.ok.gameObject.SetActive(false);
            m_Panel.no.gameObject.SetActive(false);
            m_Panel.content.text = info.content;
            close = info.close;
        }
        else if (info.type == PromptType.Help)
        {
            m_Panel.tishiUI.gameObject.SetActive(false);
            m_Panel.helpUI.gameObject.SetActive(true);
            m_Panel.helpText.text = string.Empty;
            if (info.objList.Count > 1)
            {
                List <object> list = info.objList;
                for (int i = 0; i < list.Count; ++i)
                {
                    if (i > 0)
                    {
                        m_Panel.helpText.text += "\n\n" + (list[i] as string);
                        continue;
                    }
                    m_Panel.helpText.text += (list[i] as string);
                }
            }
            else
            {
                m_Panel.helpUI.FindChild("ScrollView").GetComponent <UIScrollView>().gameObject.SetActive(false);
                m_Panel.helpUI.FindChild("biaoti/di").GetComponent <UISprite>().SetDimensions(360, 236);
                m_Panel.helpUI.FindChild("biaoti/di").GetComponent <UISprite>().transform.localPosition = new Vector3(-163, 124, 0);
                m_Panel.helpUI.FindChild("Label").GetComponent <UILabel>().text = info.objList[0] as string;
                m_Panel.helpUI.transform.localPosition = new Vector3(0, -103, 0);
            }
        }
        else if (info.type == PromptType.Properties)
        {
        }
        else
        {
            LogSystem.LogError("----------------promptpanel------info----error");
            ClosePanel(null);
        }
    }
Ejemplo n.º 10
0
    /// <summary>
    /// 设置选项界面
    /// </summary>
    public static void SetPromptInfoChoose(string title, string content, PromptMediator.ClickOk clickOk)
    {
        PromptInfo info = new PromptInfo();

        info.type    = PromptType.Choose;
        info.tishi   = title;
        info.content = content;
        info.clickOk = clickOk;
        Facade.Instance.SendNotification(NotificationID.Prompt_Show, info);
    }
Ejemplo n.º 11
0
    /// <summary>
    /// 设置提示语句
    /// </summary>
    public static void SetPromptInfo(string content, PromptMediator.Close close)
    {
        PromptInfo info = new PromptInfo();

        info.type    = PromptType.Tishi;
        info.tishi   = TextManager.GetUIString("UICreate1");
        info.content = content;
        info.close   = close;
        Facade.Instance.SendNotification(NotificationID.Prompt_Show, info);
    }
        public IPrompt BuildFrom(PromptInfo promptInfo)
        {
            var prompt = (IMultiSelectPrompt)_shoppingCartbuilder.BuildFrom(promptInfo);

            if (prompt.SelectedItems.Count() == 1)
            {
                prompt.SearchString = prompt.SelectedItems.Single().Label;
            }

            return(prompt);
        }
Ejemplo n.º 13
0
 private void button3_Click(object sender, EventArgs e)
 {
     var info = new PromptInfo<string>("Podaj swój numer karty kredytowej");
     if(_messageBoxService.Prompt(info))
     {
         if(_messageBoxService.Confirm("czy potwierdzasz swój nr karty"))
         {
             _messageBoxService.ShowMessage("a");
         }
     }
 }
Ejemplo n.º 14
0
 private void button4_Click(object sender, EventArgs e)
 {
     var info = new PromptInfo<int>("Podaj swój wiek");
     if (_messageBoxService.Prompt(info))
     {
         if (_messageBoxService.Confirm(string.Format("czy potwierdzasz swój wiek: {0}", info.ReturnValue)))
         {
             _messageBoxService.ShowMessage("a");
         }
     }
 }
Ejemplo n.º 15
0
        private void button3_Click(object sender, EventArgs e)
        {
            var info = new PromptInfo <string>("Podaj swój numer karty kredytowej");

            if (_messageBoxService.Prompt(info))
            {
                if (_messageBoxService.Confirm("czy potwierdzasz swój nr karty"))
                {
                    _messageBoxService.ShowMessage("a");
                }
            }
        }
Ejemplo n.º 16
0
        private void button4_Click(object sender, EventArgs e)
        {
            var info = new PromptInfo <int>("Podaj swój wiek");

            if (_messageBoxService.Prompt(info))
            {
                if (_messageBoxService.Confirm(string.Format("czy potwierdzasz swój wiek: {0}", info.ReturnValue)))
                {
                    _messageBoxService.ShowMessage("a");
                }
            }
        }
        public void AddInstance(GameObject promptInstance, Bounds bounds, PromptType type, bool active)
        {
            m_BasePosition = transform.InverseTransformPoint(new Vector3(bounds.center.x, bounds.center.y + bounds.extents.y, bounds.center.z));

            if (!m_Prompts.ContainsKey(type))
            {
                var promptInfo = new PromptInfo {
                    Instance = promptInstance, Active = active
                };
                m_Prompts.Add(type, promptInfo);
            }
            else
            {
                m_Prompts[type].Active |= active;
            }
        }
        public IPrompt Get(
            PromptInfo promptInfo,
            ObservableCollection <ISearchablePromptItem> availableItems,
            ObservableCollection <ISearchablePromptItem> defaultSelections)
        {
            var searchablePromptItemCollection = new SearchablePromptItems(availableItems);
            var searchProvider     = new SearchProvider();
            var searchStringParser = new SearchStringParser <ISearch>("*", searchProvider);
            var searchService      = new SearchService(searchablePromptItemCollection, searchStringParser);

            return(new MultiSelectSearch(
                       promptInfo.Label,
                       promptInfo.Name,
                       searchService,
                       defaultSelections));
        }
Ejemplo n.º 19
0
        public IPrompt BuildFrom(PromptInfo promptInfo)
        {
            string defaultText = null;

            if (promptInfo.DefaultValues != null)
            {
                if (promptInfo.DefaultValues.Count() == 1)
                {
                    defaultText = promptInfo.DefaultValues.Single().Value;
                }
            }

            return(new EmptyPrompt(promptInfo.Name, promptInfo.Label)
            {
                Text = defaultText
            });
        }
Ejemplo n.º 20
0
    private void RefreshPumpState()
    {
        switch (this.CurrentPumpStatus)
        {
        case PumpStatus.PumpOff:
            this.PumpHandle.localRotation             = Quaternion.Euler(0, 0, 0);
            this.IconRenderer.transform.localRotation = Quaternion.Euler(0, -90, 0);
            this.IconRenderer.sprite       = this.PumpSprites[0];
            CurrentPromptBasedOnPumpStatus = this.ValveMode ? Prompts.OpenPumpHint : Prompts.TurnPumpOnHint;
            break;

        case PumpStatus.PumpIn:
            this.PumpHandle.localRotation             = Quaternion.Euler(0, 90, 0);
            this.IconRenderer.transform.localRotation = Quaternion.Euler(0, -90, -90);
            this.IconRenderer.sprite       = this.PumpSprites[1];
            CurrentPromptBasedOnPumpStatus = Prompts.StopPumpingInHint;
            break;

        case PumpStatus.PumpOut:
            this.PumpHandle.localRotation             = Quaternion.Euler(0, -90, 0);
            this.IconRenderer.transform.localRotation = Quaternion.Euler(0, -90, 90);
            this.IconRenderer.sprite       = this.PumpSprites[1];
            CurrentPromptBasedOnPumpStatus = Prompts.StopPumpingInHint;
            break;

        case PumpStatus.PumpOpen:
            this.PumpHandle.localRotation             = Quaternion.Euler(0, 90, 0);
            this.IconRenderer.transform.localRotation = Quaternion.Euler(0, -90, 0);
            this.IconRenderer.sprite       = this.PumpSprites[2];
            CurrentPromptBasedOnPumpStatus = Prompts.ClosePumpHint;
            break;
        }

        this.IconRenderer.color = this.CurrentPumpStatus == PumpStatus.PumpOff ? this.OffColor : this.OnColor;

        if (connectedPumpable != null && capturedResource != null)
        {
            capturedResource.transform.tag = this.CurrentPumpStatus == PumpStatus.PumpOff ? "movable" : "Untagged";
            PumpHandle.tag = "pumpHandle";
        }
        else
        {
            PumpHandle.tag = "Untagged";
        }
    }
Ejemplo n.º 21
0
        public IPrompt Get(
            PromptInfo promptInfo,
            ObservableCollection <ISearchablePromptItem> availableItems,
            ObservableCollection <ISearchablePromptItem> defaultSelections)
        {
            var promptName    = promptInfo.Name;
            var parameterName = promptInfo.PromptLevelInfo.ParameterName;
            var label         = promptInfo.Label;

            var searchService = _asynchronousSearchServiceBuilder.Build(promptName, parameterName);

            return(new MultiSelectCasscadingSearch(
                       label
                       , promptName
                       , searchService
                       , availableItems
                       , defaultSelections));
        }
Ejemplo n.º 22
0
    public void ShowPrompt(PromptInfo prompt)
    {
        Prompts.Key.text = prompt.Key;
        Prompts.Key.transform.parent.gameObject.SetActive(prompt.Key != null);
        Prompts.Description.text = prompt.Description;

        Prompts.ProgressBar.gameObject.SetActive(prompt.UsesProgress);
        Prompts.ProgressFill.fillAmount = prompt.Progress;

        Prompts.SecondaryDescription.gameObject.SetActive(prompt.HasSecondary);
        Prompts.SecondaryDescription.text = prompt.SecondaryDescription;

        Prompts.SecondaryKey.transform.parent.gameObject.SetActive(prompt.HasSecondary);
        Prompts.SecondaryKey.text = prompt.SecondaryKey;

        Prompts.Background.offsetMin = new Vector2(0, prompt.HasSecondary ? -66 : 0);

        Prompts.TypeText.text = prompt.ItalicizedText;

        TogglePromptPanel(true);
        CurrentPrompt = prompt;
    }
        //外部で指定したGLineについて、CurrentLineまでの領域に関して判定を行う
        public bool DeterminePromptLine(GLine line, int limit_line_id, int limit_column, out string prompt, out string command)
        {
            prompt = command = null;
            if (_promptExpression == null)
            {
                return(false);
            }
            if (_terminal.TerminalMode == TerminalMode.Application)
            {
                return(false);                                                 //アプリケーションモードは通知の必要なし
            }
            PromptInfo promptInfo = CheckPrompt(line);

            if (promptInfo.Prompt == null) //プロンプトではないとき
            {
                return(false);
            }
            else
            {
                prompt  = promptInfo.Prompt;
                command = ParseCommand(line, limit_line_id, limit_column, promptInfo);
                return(true);
            }
        }
Ejemplo n.º 24
0
        //コマンド全容を見る 見る位置の終端をlimit_line_id, limit_columnで決められる
        private string ParseCommand(GLine promptCandidate, int limitLineID, int limitColumn, PromptInfo promptInfo)
        {
            _commandBuffer.Remove(0, _commandBuffer.Length);

            Debug.Assert(promptCandidate.ID <= _terminal.GetDocument().CurrentLine.ID);

            int firstLineID = promptCandidate.ID;
            int offset      = promptInfo.NextOffset; // initial offset of the first line

            for (GLine line = promptCandidate; line != null && line.ID <= limitLineID; line = line.NextLine)
            {
                bool forceUpdate;
                if (line.ID == _lastCachedLineID && line.ID != firstLineID)
                {
                    // If the line was last-cached line, retrieve new text from the line.
                    // But if the line was promptCandidate, the latest text has been already cached in CheckPrompt().
                    forceUpdate = true;
                }
                else
                {
                    forceUpdate = false;
                }
                string lineText = GetTextAndUpdateCache(line, forceUpdate);

                if (offset < lineText.Length)
                {
                    int copyLength;
                    if (line.ID == limitLineID && limitColumn < lineText.Length)
                    {
                        copyLength = limitColumn - offset;
                    }
                    else
                    {
                        copyLength = lineText.Length - offset;
                    }

                    if (copyLength > 0)
                    {
                        _commandBuffer.Append(lineText, offset, copyLength);
                    }
                }

                offset = 0; // initial offset of the next line
            }

            return(_commandBuffer.ToString());
        }
Ejemplo n.º 25
0
        //コマンド全容を見る 見る位置の終端をlimit_line_id, limit_columnで決められる
        private string ParseCommand(GLine promptCandidate, int limitLineID, int limitColumn, PromptInfo promptInfo)
        {
            _commandBuffer.Remove(0, _commandBuffer.Length);

            Debug.Assert(promptCandidate.ID <= _terminal.GetDocument().CurrentLine.ID);

            int firstLineID = promptCandidate.ID;
            int offset = promptInfo.NextOffset; // initial offset of the first line
            for (GLine line = promptCandidate; line != null && line.ID <= limitLineID; line = line.NextLine) {
                bool forceUpdate;
                if (line.ID == _lastCachedLineID && line.ID != firstLineID) {
                    // If the line was last-cached line, retrieve new text from the line.
                    // But if the line was promptCandidate, the latest text has been already cached in CheckPrompt().
                    forceUpdate = true;
                }
                else {
                    forceUpdate = false;
                }
                string lineText = GetTextAndUpdateCache(line, forceUpdate);

                if (offset < lineText.Length) {
                    int copyLength;
                    if (line.ID == limitLineID && limitColumn < lineText.Length)
                        copyLength = limitColumn - offset;
                    else
                        copyLength = lineText.Length - offset;

                    if (copyLength > 0)
                        _commandBuffer.Append(lineText, offset, copyLength);
                }

                offset = 0; // initial offset of the next line
            }

            return _commandBuffer.ToString();
        }
        //コマンド全容を見る 見る位置の終端をlimit_line_id, limit_columnで決められる
        private string ParseCommand(GLine prompt_candidate, int limit_line_id, int limit_column, PromptInfo promptInfo)
        {
            _commandBuffer.Remove(0, _commandBuffer.Length);

            Debug.Assert(prompt_candidate.ID <= _terminal.GetDocument().CurrentLine.ID);

            int offset = promptInfo.NextOffset; // initial offset of the first line

            for (GLine line = prompt_candidate; line != null && line.ID <= limit_line_id; line = line.NextLine)
            {
                //行全体を放り込む
                char[] content = line.Text;
                int    limit   = line.ID == limit_line_id?Math.Min(limit_column, content.Length) : content.Length;

                while (offset < limit)
                {
                    char ch = content[offset];
                    if (ch == '\0')
                    {
                        break;
                    }
                    else if (ch != GLine.WIDECHAR_PAD)
                    {
                        _commandBuffer.Append(ch);
                    }

                    offset++;
                }
                offset = 0; // initial offset of the next line
            }

            return(_commandBuffer.ToString());
        }
Ejemplo n.º 27
0
        protected string userPrompt(PromptInfo promptInfo)
        {
            string textContentStr = promptInfo.Question + "\n";
            string optionLine;

            foreach (var item in promptInfo.Options)
            {
                optionLine = $"\t'{item.Key}'\t– {item.Value}";
                if (item.Key == promptInfo.Default)
                {
                    optionLine += " (default)";
                }
                textContentStr += "\n" + optionLine;
            }
            textContentStr += @"\n\nType one of the following options and press Enter key. "
                              + @"\nPress only Enter key to choose default option.\n";
            Form prompt = new Form()
            {
                Width           = 600,
                Height          = 330,
                FormBorderStyle = FormBorderStyle.FixedDialog,
                Text            = "Question",
                StartPosition   = FormStartPosition.CenterScreen
            };
            TextBox textContent = new TextBox()
            {
                Left        = 20,
                Top         = 20,
                Width       = 540,
                Height      = 170,
                Text        = textContentStr.Replace("\n", "\r\n"),
                BackColor   = this.BackColor,
                BorderStyle = BorderStyle.None,
                Multiline   = true,
                ReadOnly    = true
            };
            TextBox textInput = new TextBox()
            {
                Left  = 20,
                Top   = 200,
                Width = 540,
                Text  = promptInfo.Default
            };
            Button confirmBtn = new Button()
            {
                Text         = "Ok",
                Left         = 460,
                Width        = 100,
                Top          = 240,
                DialogResult = DialogResult.OK
            };

            confirmBtn.Click += (sender, e) => {
                prompt.Close();
            };
            prompt.Controls.Add(textContent);
            textContent.DeselectAll();
            prompt.Controls.Add(textInput);
            prompt.Controls.Add(confirmBtn);
            textInput.Focus();
            textInput.SelectAll();
            prompt.AcceptButton = confirmBtn;
            string resultValue = prompt.ShowDialog() == DialogResult.OK
                                ? textInput.Text.Trim()
                                : "";

            if (String.IsNullOrEmpty(resultValue))
            {
                resultValue = promptInfo.Default;
            }
            if (promptInfo.Options.ContainsKey(resultValue))
            {
                return(resultValue);
            }
            return(this.userPrompt(promptInfo));
        }