コード例 #1
0
ファイル: Functions.cs プロジェクト: c3333/MediaPortal-1
        public static object SkinSetString(params object[] args)
        {
            // args[0] - setting name
            // args[1] - (optional) new value
            // args[2] - (optional) keyboard prompt
            string newValue = "";

            // Set the setting to the specified string.  If no value is specified then present the keyboard to input the value.
            if (args.Length == 2)
            {
                int condition = GUIInfoManager.TranslateSingleString("skin.setstring(" + args[0] + ")");
                newValue = args[1].ToString();
                GUIInfoManager.SetString(condition, newValue, 0);
            }
            else
            {
                // No value was provided for the skin setting.  Display a keyboard and ask for a value.
                string prompt = "";
                if (args.Length >= 3)
                {
                    newValue = args[1].ToString();
                    prompt   = args[2].ToString();
                    GUILocalizeStrings.LocalizeLabel(ref prompt);
                }

                // Get the current value to initialize the keyboard.
                int    condition = GUIInfoManager.TranslateSingleString("skin.setstring(" + args[0] + "," + newValue + "," + prompt + ")");
                string userInput = GUIInfoManager.GetString(condition, 0);

                if (GetUserInputString(ref userInput, prompt))
                {
                    GUIInfoManager.SetString(condition, userInput, 0);
                }
                else
                {
                    // Keyboard cancelled; no value supplied and no input was entered into the keyboard.
                }
            }
            return(newValue);
        }