/// <summary> /// Returns the Break Tag Color from its Enum /// </summary> /// <param name="breakType">The BreakType Enum</param> /// <returns>A Break Tag Color</returns> public static Color BreakColorFromEnum(GUI.BreakType breakType) { if (breakType == GUI.BreakType.FlowBreak) { return(GUI.GUI_Colors.c_FBCol); } if (breakType == GUI.BreakType.DivBreak1) { return(GUI.GUI_Colors.c_DB1Col); } if (breakType == GUI.BreakType.DivBreak2) { return(GUI.GUI_Colors.c_DB2Col); } return(GUI.GUI_Colors.c_NBCol); }
/// <summary> /// Returns the Break Tag from its Enum /// </summary> /// <param name="breakType">The BreakType Enum</param> /// <returns>A Break Tag</returns> public static char BreakTagFromEnum(GUI.BreakType breakType) { return(Convert.ToChar(Convert.ToByte('0') + (byte)breakType)); }
// Load the profile from stored strings (Settings) private void LoadProfile(string profileName, string profile, string flowBreak, string sequence, GUI.FontSize fontSize, GUI.Placement placement, GUI.Kind kind, Point location, bool condensed, GUI.Transparent transparent) { // save props in Profile PName = profileName; m_fontSize = fontSize; m_placement = placement; m_kind = kind; m_location = location; m_condensed = condensed; m_transparent = transparent; // The Dictionaries and stored strings of it maintain the Enum Sequence // even if items are relocated for display // If a stored string does not contain a value (too short) then a default is taken // i.e. we always want a complete Dictionary when leaving the method!!! // Get the visibility status for each item string[] e = profile.Split(new char[] { Divider }, StringSplitOptions.RemoveEmptyEntries); m_profile.Clear( ); foreach (LItem i in Enum.GetValues(typeof(LItem))) { bool show = (i == LItem.MSFS)?true : false; // default OFF except the first 20210708 if (e.Length > (int)i) { show = e[(int)i] == "1"; // found an element in the string } m_profile.Add(i, show); } // Get the flow break status for each item e = flowBreak.Split(new char[] { Divider }, StringSplitOptions.RemoveEmptyEntries); m_flowBreak.Clear( ); foreach (LItem i in Enum.GetValues(typeof(LItem))) { GUI.BreakType fbreak = GUI.BreakType.None; // default OFF if (e.Length > (int)i) { fbreak = EnumFromBreakTagString(e[(int)i]); // found an element in the string } m_flowBreak.Add(i, fbreak); } // Get the item position - don't validate the sequence here e = sequence.Split(new char[] { Divider }, StringSplitOptions.RemoveEmptyEntries); m_sequence.Clear( ); foreach (LItem i in Enum.GetValues(typeof(LItem))) { int idx = (int)i; // default Enum Sequence if (e.Length > idx) { if (int.TryParse(e[idx], NumberStyles.Integer, CultureInfo.InvariantCulture, out int iPos)) { if (iPos < m_profile.Count) { m_sequence.Add(i, iPos); // found an integer } else { m_sequence.Add(i, m_profile.Count - 1); // found an integer - was out of the range ?? } } else { m_sequence.Add(i, idx); // default } } else { m_sequence.Add(i, idx); // default } } }