void RenderSpecialNode(object sender, DrawTreeNodeEventArgs e) { List <string[]> TextColorList = null; if (e.Node.Text == String.Empty || e.Node.Text[0] != '{') { string[] Simple = new string[2]; Simple[0] = GlobalConstants.TREEVIEW_BLACK; Simple[1] = e.Node.Text; TextColorList = new List <string[]>(); TextColorList.Add(Simple); } else { Stream ColorStream = new MemoryStream(); byte[] StreamByte = Encoding.Unicode.GetBytes(e.Node.Text); ColorStream.Write(StreamByte, 0, StreamByte.Length); ColorStream.Seek(0, SeekOrigin.Begin); DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(TreeViewColorTool)); TreeViewColorTool Instance = (TreeViewColorTool)ser.ReadObject(ColorStream); TextColorList = Instance.TextColorList; } string BuildedString = string.Empty; Point newst = e.Bounds.Location; VO_Line CurrentLine = (VO_Line)e.Node.Tag; foreach (string[] CurrentText in TextColorList) { #region Si le VO_Line n'est pas valide, alors remplacer le texte en rouge if (CurrentLine != null && CurrentLine.Valid == false) { CurrentText[0] = GlobalConstants.TREEVIEW_RED; } #endregion e.Graphics.DrawString(CurrentText[1], new Font(this.Font, FontStyle.Regular), new SolidBrush(ColorTranslator.FromHtml(CurrentText[0])), newst); BuildedString += CurrentText[1]; newst.X = newst.X + (int)e.Graphics.MeasureString(CurrentText[1], new Font(this.Font, FontStyle.Regular)).Width; } e.Node.ToolTipText = BuildedString; //e.Graphics.DrawString(s[0], new Font("Arial", 10f), Brushes.Red, e.Bounds.Location); //if (s.Length > 1) //{ // Point newst = e.Bounds.Location; // newst.X = newst.X + (int)e.Graphics.MeasureString(s[0], new Font("Arial", 10f)).Width; // e.Graphics.DrawString(s[1], new Font("Arial", 10f), Brushes.Green, newst); //} }
/// <summary> /// Retire une ligne dans un script de manière récursive /// </summary> /// <param name="LineToRemove"></param> /// <param name="CurrentList"></param> /// <returns></returns> public bool RemoveLineInScript(VO_Line LineToRemove, List <VO_Line> CurrentList) { if (CurrentList.Find(VO_Line => VO_Line == LineToRemove) == null) { foreach (VO_Line CurrentLine in CurrentList) { if (CurrentLine is VO_Script_Loop) { VO_Script_Loop CurrentLoop = CurrentLine as VO_Script_Loop; if (RemoveLineInScript(LineToRemove, CurrentLoop.WhileSubLines) == true) { return(true); } } else if (CurrentLine is VO_Script_Condition) { VO_Script_Condition CurrentCondition = CurrentLine as VO_Script_Condition; if (RemoveLineInScript(LineToRemove, CurrentCondition.ElseSubLines) == true) { return(true); } if (RemoveLineInScript(LineToRemove, CurrentCondition.IfSubLines) == true) { return(true); } } else if (CurrentLine is VO_Script_ChoiceMessage) { VO_Script_ChoiceMessage CurrentChoice = CurrentLine as VO_Script_ChoiceMessage; foreach (VO_LineChoices CurrentLineChoice in CurrentChoice.Choices) { if (RemoveLineInScript(LineToRemove, CurrentLineChoice.SubLines) == true) { return(true); } } } } } else { CurrentList.Remove(LineToRemove); return(true); } return(false); }
/// <summary> /// Trouve la prochaine ligne du même niveau /// </summary> /// <param name="currentLine"></param> private static VO_Line FindLine(List <VO_Line> lines, Guid currentLineId) { foreach (VO_Line line in lines) { if (line.Id == currentLineId) { return(line); } else if (line is VO_Script_Condition) { VO_Line condition = null; condition = FindLine(((VO_Script_Condition)line).IfSubLines, currentLineId); if (condition == null) { condition = FindLine(((VO_Script_Condition)line).ElseSubLines, currentLineId); } if (condition != null) { return(condition); } } else if (line is VO_Script_Loop) { VO_Line loop = FindLine(((VO_Script_Loop)line).WhileSubLines, currentLineId); if (loop != null) { return(loop); } } else if (line is VO_Script_ChoiceMessage) { VO_Line choiceLine = null; VO_Script_ChoiceMessage choiceScript = (VO_Script_ChoiceMessage)line; foreach (VO_LineChoices choice in choiceScript.Choices) { choiceLine = FindLine(choice.SubLines, currentLineId); if (choiceLine != null) { return(choiceLine); } } } } return(null); }
public static bool EventScriptIntegritySublinesCheck(VO_Line CurrentLine) { bool IsValid = true; if (CurrentLine is VO_Script_Condition) { VO_Script_Condition CurrentScriptCondition = CurrentLine as VO_Script_Condition; CurrentScriptCondition.Valid = CurrentScriptCondition.IsScriptValid(); IsValid = CurrentScriptCondition.Valid; foreach (IScriptable CurrentIfSubLine in CurrentScriptCondition.IfSubLines) { if ((CurrentIfSubLine.Valid = CurrentIfSubLine.IsScriptValid()) == false) { IsValid = false; } if (EventScriptIntegritySublinesCheck(CurrentIfSubLine as VO_Line) == false) { IsValid = false; } } foreach (IScriptable CurrentElseSubLine in CurrentScriptCondition.ElseSubLines) { if ((CurrentElseSubLine.Valid = CurrentElseSubLine.IsScriptValid()) == false) { IsValid = false; } if (EventScriptIntegritySublinesCheck(CurrentElseSubLine as VO_Line) == false) { IsValid = false; } } } if (CurrentLine is VO_Script_Loop) { VO_Script_Loop CurrentLoop = CurrentLine as VO_Script_Loop; CurrentLoop.Valid = CurrentLoop.IsScriptValid(); IsValid = CurrentLoop.Valid; foreach (IScriptable CurrentWhileSubLine in CurrentLoop.WhileSubLines) { if ((CurrentWhileSubLine.Valid = CurrentWhileSubLine.IsScriptValid()) == false) { IsValid = false; } if (EventScriptIntegritySublinesCheck(CurrentWhileSubLine as VO_Line) == false) { IsValid = false; } } } if (CurrentLine is VO_Script_ChoiceMessage) { VO_Script_ChoiceMessage CurrentChoiceMessage = CurrentLine as VO_Script_ChoiceMessage; CurrentChoiceMessage.Valid = CurrentChoiceMessage.IsScriptValid(); IsValid = CurrentChoiceMessage.Valid; foreach (VO_LineChoices CurrentChoiceSubLine in CurrentChoiceMessage.Choices) { foreach (IScriptable CurrentLineChoiceChoice in CurrentChoiceSubLine.SubLines) { if ((CurrentLineChoiceChoice.Valid = CurrentLineChoiceChoice.IsScriptValid()) == false) { IsValid = false; } if (EventScriptIntegritySublinesCheck(CurrentLineChoiceChoice as VO_Line) == false) { IsValid = false; } } } } return(IsValid); }