Example #1
0
        static string Substitute(string doc, Day day, int matchIndex, HTMLmode mode)
        {
            Match  match  = day.matches[matchIndex];
            string result = doc
                            .Replace("%rink%", GetControlForRink(day, matchIndex, mode))
                            .Replace("%size%", GetControlForTeamSize(day, matchIndex, mode))
                            .Replace("%delete%", GetControlForDelete(matchIndex, mode))
                            .Replace("%lead1%", GetName(day, matchIndex, 0, Position.Lead, mode))
                            .Replace("%lead2%", GetName(day, matchIndex, 1, Position.Lead, mode))
                            .Replace("%second1%", GetName(day, matchIndex, 0, Position.Second, mode))
                            .Replace("%second2%", GetName(day, matchIndex, 1, Position.Second, mode))
                            .Replace("%third1%", GetName(day, matchIndex, 0, Position.Third, mode))
                            .Replace("%third2%", GetName(day, matchIndex, 1, Position.Third, mode))
                            .Replace("%skip1%", GetName(day, matchIndex, 0, Position.Skip, mode))
                            .Replace("%skip2%", GetName(day, matchIndex, 1, Position.Skip, mode))
                            .Replace("%lead1pref%", GetPosition(day, matchIndex, 0, Position.Lead, mode))
                            .Replace("%lead2pref%", GetPosition(day, matchIndex, 1, Position.Lead, mode))
                            .Replace("%second1pref%", GetPosition(day, matchIndex, 0, Position.Second, mode))
                            .Replace("%second2pref%", GetPosition(day, matchIndex, 1, Position.Second, mode))
                            .Replace("%third1pref%", GetPosition(day, matchIndex, 0, Position.Third, mode))
                            .Replace("%third2pref%", GetPosition(day, matchIndex, 1, Position.Third, mode))
                            .Replace("%skip1pref%", GetPosition(day, matchIndex, 0, Position.Skip, mode))
                            .Replace("%skip2pref%", GetPosition(day, matchIndex, 1, Position.Skip, mode))
                            .Replace("%leadvisible%", match.PositionShouldBeFilled(Position.Lead)   ? "" : invisible)
                            .Replace("%secondvisible%", match.PositionShouldBeFilled(Position.Second) ? "" : invisible)
                            .Replace("%thirdvisible%", match.PositionShouldBeFilled(Position.Third)  ? "" : invisible)
                            .Replace("%skipvisible%", match.PositionShouldBeFilled(Position.Skip)   ? "" : invisible)
            ;

            return(Substitute(result, day, mode));
        }
Example #2
0
 static string GetControlForDelete(int matchIndex, HTMLmode mode)
 {
     if (mode != HTMLmode.FixMatches)
     {
         return(empty);
     }
     return(string.Format(deleteMatch, matchIndex));
 }
Example #3
0
        static string GetControlForTeamSize(Day day, int matchIndex, HTMLmode mode)
        {
            Match match = day.matches[matchIndex];

            if (mode != HTMLmode.FixMatches)
            {
                return(EnumStringConverter.NameOfTeamSize(match.Size));
            }
            string controls = string.Format(dropDownTeamSizeStart, matchIndex);

            for (int size = Team.MinSize; size <= Team.MaxSize; size++)
            {
                controls += string.Format(match.Size == size ? dropDownTeamSizeOptionSelected : dropDownTeamSizeOptionNotSelected, size, EnumStringConverter.NameOfTeamSize(size));
            }
            controls += dropDownTeamSizeEnd;
            return(controls);
        }
Example #4
0
        public static string GenerateDay(Day day, HTMLmode mode)
        {
            var split = format.Split(new[] { repeatMarker }, StringSplitOptions.None);

            string result = "";

            for (int i = 0; i < split.Length; i++)
            {
                if (i % 2 == 0)
                {
                    result += Substitute(split[i], day, mode);
                }
                else
                {
                    for (int matchIndex = 0; matchIndex < day.matches.Count; matchIndex++)
                    {
                        result += Substitute(split[i], day, matchIndex, mode);
                    }
                }
            }
            return(result);
        }
Example #5
0
 static string GetControlForDate(Day day, HTMLmode mode)
 {
     return(TextboxOrPlainText(mode != HTMLmode.ViewHistory, day.date, datePlaceholder, typeDateFunction, true));
 }
Example #6
0
 public static string Substitute(string doc, Day day, HTMLmode mode)
 {
     return(doc
            .Replace("%date%", GetControlForDate(day, mode)));
 }
Example #7
0
 static string GetControlForRink(Day day, int matchIndex, HTMLmode mode)
 {
     return(TextboxOrPlainText(mode != HTMLmode.ViewHistory, day.matches[matchIndex].rink, rinkPlaceHolder, string.Format(typeRinkFunction, matchIndex), false));
 }
Example #8
0
        static string GetPosition(Day day, int matchIndex, int teamIndex, Position position, HTMLmode mode)
        {
            if (mode != HTMLmode.ConfirmMatches)
            {
                return("");
            }
            Match match = day.matches[matchIndex];
            Team  team  = match.teams[teamIndex];

            if (!match.PositionShouldBeFilled(position))
            {
                return("");
            }
            Player player = team.Player(position);

            if (player == null)
            {
                return("");
            }
            string result = player.PreferencePrimary.Abbreviation();

            if (player.PreferenceSecondary.HasPreference)
            {
                result += " " + player.PreferenceSecondary.Abbreviation();
            }
            return(result);
        }
Example #9
0
        static string GetName(Day day, int matchIndex, int teamIndex, Position position, HTMLmode mode)
        {
            Match match = day.matches[matchIndex];
            Team  team  = match.teams[teamIndex];

            if (!match.PositionShouldBeFilled(position))
            {
                return("");
            }
            Player player = mode == HTMLmode.FixMatches ? team.players[(int)position] : team.Player(position);

            if (player == null && mode == HTMLmode.ViewHistory)
            {
                return(deletedPlayer);
            }
            string name = player?.Name ?? noPlayerSelected;

            if (string.IsNullOrEmpty(name))
            {
                name = player.TagNumber;
            }
            if (mode == HTMLmode.ViewHistory)
            {
                return(name);
            }
            return(string.Format(hyperlinkedPlayer, matchIndex, teamIndex, (int)position, name));
        }