コード例 #1
0
ファイル: CProfile.cs プロジェクト: bm98/FS20_HudBar
        // 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
                }
            }
        }
コード例 #2
0
ファイル: CProfile.cs プロジェクト: bm98/FS20_HudBar
 /// <summary>
 /// Update this profile from the FontSize ComboBox
 /// </summary>
 /// <param name="box">The ComboBox</param>
 public void GetFontSizeFromCombo(ComboBox box)
 {
     m_fontSize = (GUI.FontSize)box.SelectedIndex;
 }