public void Should_Highlight_Keywords_In_Input() { List <Keyword> keywords = new List <Keyword> { new Keyword("as", "blue", "capital", "normal"), new Keyword("if", "red", "lower", "bold"), new Keyword("and", "red", "capital", "bold"), new Keyword("then", "green", "lower", "normal"), new Keyword("when", "blue", "lower", "normal"), }; //string input = "If we write a program and compile it, then we can run the program to get output"; string input = "If we write a program and compile it, then as we run the program, we will get output"; var keywordFinder = new KeywordFinder(keywords); var highLigher = new HighLighter( keywordFinder, new IDecorater[] { new WordCasing(), new WordStyle(), new Colorization(), }); var result = highLigher.HighLight(input); //var expected = "[red]If[red] we write a program [red]and[red] compile it, [blue]then[blue] we can run the program to get output"; //var expected = "[red]If[red] we write a program [red]and[red] compile it, [green]then[green] [blue]as[blue] we run the program, we will get output"; //var expected = "[red]if[red] we write a program [red]AND[red] compile it, [green]then[green] [blue]AS[blue] we run the program, we will get output"; var expected = "[red][bold]if[bold][red] we write a program [red][bold]AND[bold][red] compile it, [green]then[green] [blue]AS[blue] we run the program, we will get output"; Assert.Equal(expected, result); }
/// <summary> /// 开启高光 /// </summary> /// <param name="go"></param> /// <param name="useRecord">是否使用记录</param> public static GameObject OnHightligher(this GameObject go) { HighLighter listener = HighLighter.Get(go); listener.SetFlash(true); return(go); }
/// <summary> /// Updates the placement text to prompt placing a settlement or route depending on turn. /// Only displays one of the prompts at at time /// </summary> /// <param name="p_Highlighter">P highlighter.</param> private void updatePlacementText(HighLighter p_Highlighter) { //// If first settlement not placed, print a prompt saying so //if (p_Highlighter.placedFirstSettlement == false) //{ // _PlacementText.text = " - Place First Settlement"; // return; //} //// If first road/boat not placed, print a prompt saying so //if (p_Highlighter.placedFirstEdge == false) //{ // _PlacementText.text = " - Place First Road/Boat"; // return; //} //// If first city not placed, print a prompt saying so //if (p_Highlighter.placedFirstCity == false) //{ // _PlacementText.text = " - Place First City"; // return; //} //// If second road/boat not placed, print a prompt saying so //if (p_Highlighter.placedSecondEdge == false) //{ // _PlacementText.text = " - Place Second Road/Boat"; // return; //} }
////////////////////////////////////////////////////////////////////////// // START protected virtual void Start() { m_HighLighter = GetComponent <HighLighter>(); if (m_HighLighter == null) { m_HighLighter = gameObject.AddComponent <HighLighter>(); } }
/// <summary> /// Updates the UI Element /// </summary> /// <param name="p_Player">P player.</param> public override void uiUpdate(Player p_Player) { // Get the Highlighter component from the player parameter HighLighter _PlayerHighlighter = p_Player.GetComponent <HighLighter> (); // Check for if it is the first turn or second turn. Respond accordingly updateFirstTurnText(_PlayerHighlighter); }
public static void RemoveHL(GameObject go) { HighLighter component = go.GetComponent <HighLighter>(); if (component != null) { Destroy(component); Destroy(go.GetComponent <Highlighter>()); } }
public static HighLighter Get(GameObject go) { HighLighter component = go.GetComponent <HighLighter>(); if (component == null) { component = go.AddComponent <HighLighter>(); } return(component); }
/// <summary> /// 关闭高光 /// </summary> /// <param name="go"></param> public static GameObject OffHightligher(this GameObject go, bool deleteHighLighter = false) { HighLighter listener = HighLighter.Get(go); listener.SetFlash(false); if (deleteHighLighter) { UnityEngine.Object.Destroy(go.GetComponent <HighLighter>()); UnityEngine.Object.Destroy(go.GetComponent <Highlighter>()); } return(go); }
public static List <Resp_Oc_Abs> To_Resp_Oc_Abs(this IEnumerable <OrgCompanyCombine> set, Company company, bool flag = true) { var list = new List <Resp_Oc_Abs>(company.pg_size); var end_list = new List <Resp_Oc_Abs>(); var oc_name_input = company.oc_name?.Replace("公司", ""); foreach (var c in set) { var r = new Resp_Oc_Abs(); if (c != null) { r.flag = c.od_CreateTime.Year != 1900; r.oc_addr = c.oc_address ?? ""; r.oc_area = c.oc_area; r.oc_code = c.oc_code; r.oc_art_person = c.od_faRen ?? string.Empty; r.oc_issue_time = c.oc_issuetime.ToString("yyyy-MM-dd") ?? ""; r.oc_name_hl = flag ? HighLighter.HighLight(c.oc_name, company.oc_name) : c.oc_name; r.oc_name = c.oc_name; r.oc_reg_capital = c.od_regMoney ?? ""; r.oe_status = c.oc_issuetime < DateTime.Now; r.oc_type = c.oc_companytype ?? ""; r.oc_status = r.flag ? Util.To_OpStatus(c.od_ext) : "未知"; } if (string.IsNullOrEmpty(oc_name_input)) { list.Add(r); } else { bool b_existed = false; for (int i = 0; i < oc_name_input.Length; i++) { if (c.oc_name.Contains(oc_name_input[i])) { list.Add(r); b_existed = true; break; } } if (!b_existed) { end_list.Add(r); } } } list.AddRange(end_list); return(list); }
/// <summary> /// Updates the first turn text based on whether it is the First Turn or not /// and prompts player to place a piece /// If it is Second Turn, clear the PlacementText.text as well /// </summary> /// <param name="p_Highlighter">P highlighter.</param> private void updateFirstTurnText(HighLighter p_Highlighter) { //if (p_Highlighter.firstTurn == true) { // _TurnText.text = " FIRST TURN"; // updatePlacementText (p_Highlighter); //} //else if (p_Highlighter.firstTurn == false) { // _TurnText.text = ""; // _PlacementText.text = " WAITING FOR OTHER PLAYERS"; //} //if (p_Highlighter.secondTurn == true) //{ // _TurnText.text = " SECOND TURN"; // _PlacementText.text = ""; //} }
// Use this for initialization void Awake() { _SmartPanel.gameObject.SetActive(true); _vToHighlight = new List <Vertex> (); _eToHighlight = new List <Edge> (); recentMove = MoveType.NONE; _UIMoveManager = GetComponent <UIMoveManager> (); _CurrentPlayer = GameObject.Find(Network.player.ipAddress).GetComponent <Player>(); // Set UIMoveManager's Current Player to this instance's current player attribute _UIMoveManager.setCurrentPlayer(_CurrentPlayer); _PlayerHighlighter = _CurrentPlayer.GetComponent <HighLighter> (); if (_CurrentPlayer.gameObject.GetComponent <NetworkIdentity>().isLocalPlayer) { // Hide ContextPanel and its contents on startup setContextPanelChildren(); _ContextPanel.gameObject.SetActive(false); _VertexButtonsPanel.gameObject.SetActive(false); _EdgeButtonsPanel.gameObject.SetActive(false); // Get the GameManager Component off of the CurrentPlayer object _GameManager = _CurrentPlayer.GetComponent <GameManager>(); // Set the Trade Attributes to NONE. And the Maritime panel active to false _FromResource = Enums.ResourceType.NONE; _ToResource = Enums.ResourceType.NONE; _MaritimeTradePanel.gameObject.SetActive(false); // Set the Dice Roll panel to true at start. Only shows the rollDice button at the right turns though _DiceRollPanel.gameObject.SetActive(true); } }
public void HighLightRectangle(Rectangle2D rect, int color) { Map map = m_Stone.Map; for (int x = rect.Start.X; x <= rect.End.X; x++) { for (int y = rect.Start.Y; y <= rect.End.Y; y++) { Tile landtile = map.Tiles.GetLandTile(x, y); Point3D xyz = new Point3D(x, y, landtile.Z); Item item = new HighLighter(color); item.MoveToWorld(xyz, map); foreach (Item it in TileList) { if (it.Location == item.Location) { it.Hue = 33; item.Hue = 33; } } TileList.Add(item); } } }