Exemplo n.º 1
0
 public static string Show(string text, string caption, string defaultText, int maxLength)
 {
     using (var itb = new InputTextBox(text, caption, defaultText, maxLength))
     {
         itb.ShowDialog();
         return(itb.InputText);
     }
 }
Exemplo n.º 2
0
        void addTranslationLL_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            var result =
                InputTextBox.Show("Enter the locale code you wish to use for your new translation",
                                  "Enter locale code", "es-ES", 5);

            if (string.IsNullOrEmpty(result))
            {
                statusCSL.SetWarn("Adding locale operation cancelled");
            }
            else // if the result is not null, add it
            {
                addTranslation(Resourcer.GetStringsResName(result));
            }
        }
        public static void ShowAddCustomResource()
        {
            // sanitized path
            string       sanitized = string.Empty;
            DialogResult retry;

            do
            {
                retry = DialogResult.No;
                var result = InputTextBox.Show(
                    "Enter the name of the new custom resources XAML file", "Enter a name",
                    sanitized, MAX_PATH_LENGTH - Resourcer.GetResourcesFolderPath().Length - 7);
                // -7 = -(@"\.xaml".Length + 1) // it must be LESS than, not less or equal ^ (so substract 1 extra)

                if (string.IsNullOrEmpty(result))
                {
                    return;
                }

                sanitized = string.Join("_", result.Split(Path.GetInvalidFileNameChars(),
                                                          StringSplitOptions.RemoveEmptyEntries)).TrimEnd('.');

                if (!string.IsNullOrWhiteSpace(sanitized))
                {
                    var path = Resourcer.GetXamlResPath(result);
                    if (File.Exists(path))
                    {
                        retry = MessageBox.Show("A file with this name already exists! Do you want to change it?",
                                                "Existing file", MessageBoxButtons.YesNo, MessageBoxIcon.Error);

                        continue;
                    }
                    Resourcer.CreateXamlRes(path, true);
                }
            }while (retry == DialogResult.Yes);
        }