lundi 11 janvier 2016

Replacing hundreds of files with one simple check box check

Is there a simple or a more compact way to do this with a large number of files with one check-box (checked/unchecked), i have i think few thousand lines to put inside the code and i can sort them by year, or by type:

private void CheckBox()
{
    try
    {
        switch (checkBox.IsChecked)
        {
            case true:
            {
                const string disable_picture100 = "images/disabled/picture100.png";
                const string picture100 = "images\\disabled\\picture100.png";
                Records[picture100].ReplaceContents(imagesPath, disable_picture100, content.FileRoot);

                const string disable_picture101 = "images/disabled/picture101.png";
                const string picture101 = "images\\disabled\\picture101.png";
                Records[picture101].ReplaceContents(imagesPath, disable_picture101, content.FileRoot);

                const string disable_picture102 = "images/disabled/picture102.png";
                const string picture102 = "images\\disabled\\picture102.png";
                Records[picture102].ReplaceContents(imagesPath, disable_picture102, content.FileRoot);

                UpdateImage();
            }
            break;

            case false:
            {
                const string enable_picture100 = "images/enabled/picture100.png";
                const string picture100 = "images\\enabled\\picture100.png";
                Records[picture100].ReplaceContents(imagesPath, enable_picture100, content.FileRoot);

                const string enable_picture101 = "images/enabled/picture101.png";
                const string picture101 = "images\\enabled\\picture101.png";
                Records[picture101].ReplaceContents(imagesPath, enable_picture101, content.FileRoot);

                const string enable_picture102 = "images/enabled/picture102.png";
                const string picture102 = "images\\enabled\\picture102.png";
                Records[picture102].ReplaceContents(imagesPath, enable_picture102, content.FileRoot);

                UpdateImage();
            }
            break;
        }
    }
    catch (Exception ex)
    {
        //ignored
    }
}

Thank you!




Aucun commentaire:

Enregistrer un commentaire