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)); }
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(); } }
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)); }
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)); }
public void HidePrompt() { if (CurrentPrompt != null) { TogglePromptPanel(false); CurrentPrompt = null; } }
public IPrompt Get(PromptInfo promptInfo, ObservableCollection <ITreeNode> availableItems, ObservableCollection <ITreeNode> defaultSelections) { return(new MultiSelectHierarchy( promptInfo.Name, promptInfo.Label, availableItems, defaultSelections)); }
/// <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); }
/// <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); } }
/// <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); }
/// <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); }
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"); } } }
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"); } } }
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"); } } }
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)); }
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 }); }
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"; } }
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)); }
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); } }
//コマンド全容を見る 見る位置の終端を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 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()); }
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)); }