Files
win8phoneApp/CampusAppWP8/CampusAppWP8/Model/Openinghours/OpeninghoursInstitutionModel.cs
Christian Fiedler 31b4e4459e #55
2013-06-25 14:06:27 +02:00

582 lines
15 KiB
C#

//-----------------------------------------------------------------------------
// <copyright file="OpeninghoursInstitutionModel.cs" company="BTU/IIT">
// Company copyright tag.
// </copyright>
// <author>fiedlchr</author>
// <sience>24.06.2013</sience>
//-----------------------------------------------------------------------------
namespace CampusAppWP8.Model.Openinghours
{
using System.Globalization;
using System.Windows;
using System.Xml.Serialization;
/// <summary>
/// Model for menu
/// </summary>
public class OpeninghoursInstitutionModel
{
#region Member
/// <summary>
/// German version of the institution title.
/// </summary>
private string titleDE = string.Empty;
/// <summary>
/// English version of the institution title.
/// </summary>
private string titleEN = string.Empty;
/// <summary>
/// Opening hours on monday.
/// </summary>
private string dayMonday = string.Empty;
/// <summary>
/// Opening hours on tuesday.
/// </summary>
private string dayTuesday = string.Empty;
/// <summary>
/// Opening hours on wednesday.
/// </summary>
private string dayWednesday = string.Empty;
/// <summary>
/// Opening hours on thursday.
/// </summary>
private string dayThursday = string.Empty;
/// <summary>
/// Opening hours on friday.
/// </summary>
private string dayFriday = string.Empty;
/// <summary>
/// Opening hours on saturday.
/// </summary>
private string daySaturday = string.Empty;
/// <summary>
/// Opening hours on sunday.
/// </summary>
private string daySunday = string.Empty;
/// <summary>
/// Email address of the institution.
/// </summary>
private string infoEmail = string.Empty;
/// <summary>
/// Phone number of the institution.
/// </summary>
private string infoPhone = string.Empty;
/// <summary>
/// Building name where the institution is located.
/// </summary>
private string infoBuilding = string.Empty;
/// <summary>
/// Room where the institution is located.
/// </summary>
private string infoRoom = string.Empty;
/// <summary>
/// German version of the comment.
/// </summary>
private string commentDE = string.Empty;
/// <summary>
/// English version of the comment.
/// </summary>
private string commentEN = string.Empty;
#endregion
#region Constructor
/// <summary>
/// Initializes a new instance of the <see cref="OpeninghoursInstitutionModel" /> class.
/// </summary>
public OpeninghoursInstitutionModel()
{
}
#endregion
#region Property
/// <summary>
/// Gets or sets the german title of the institution.
/// </summary>
[XmlAttribute("title_de")]
public string Title_DE
{
get
{
return this.titleDE;
}
set
{
this.titleDE = value;
}
}
/// <summary>
/// Gets or sets the english title of the institution.
/// </summary>
[XmlAttribute("title_en")]
public string Title_EN
{
get
{
return this.titleEN;
}
set
{
this.titleEN = value;
}
}
/// <summary>
/// Gets or sets the open hours on monday.
/// </summary>
[XmlAttribute("monday")]
public string Monday
{
get
{
return this.dayMonday;
}
set
{
this.dayMonday = this.FixOpeninghoursString(value);
}
}
/// <summary>
/// Gets or sets the open hours on tuesday.
/// </summary>
[XmlAttribute("tuesday")]
public string Tuesday
{
get
{
return this.dayTuesday;
}
set
{
this.dayTuesday = this.FixOpeninghoursString(value);
}
}
/// <summary>
/// Gets or sets the open hours on wednesday.
/// </summary>
[XmlAttribute("wednesday")]
public string Wednesday
{
get
{
return this.dayWednesday;
}
set
{
this.dayWednesday = this.FixOpeninghoursString(value);
}
}
/// <summary>
/// Gets or sets the open hours on thursday.
/// </summary>
[XmlAttribute("thursday")]
public string Thursday
{
get
{
return this.dayThursday;
}
set
{
this.dayThursday = this.FixOpeninghoursString(value);
}
}
/// <summary>
/// Gets or sets the open hours on friday.
/// </summary>
[XmlAttribute("friday")]
public string Friday
{
get
{
return this.dayFriday;
}
set
{
this.dayFriday = this.FixOpeninghoursString(value);
}
}
/// <summary>
/// Gets or sets the open hours on saturday.
/// </summary>
[XmlAttribute("saturday")]
public string Saturday
{
get
{
return this.daySaturday;
}
set
{
this.daySaturday = this.FixOpeninghoursString(value);
}
}
/// <summary>
/// Gets or sets the open hours on sunday.
/// </summary>
[XmlAttribute("sunday")]
public string Sunday
{
get
{
return this.daySunday;
}
set
{
this.daySunday = this.FixOpeninghoursString(value);
}
}
/// <summary>
/// Gets or sets the email address of the institution.
/// </summary>
[XmlAttribute("email")]
public string EMail
{
get
{
return this.infoEmail;
}
set
{
this.infoEmail = value;
}
}
/// <summary>
/// Gets or sets the phone number of the institution.
/// </summary>
[XmlAttribute("phone")]
public string Phone
{
get
{
return this.infoPhone;
}
set
{
this.infoPhone = value;
}
}
/// <summary>
/// Gets or sets the building where the institution is located.
/// </summary>
[XmlAttribute("location_building")]
public string Building
{
get
{
return this.infoBuilding;
}
set
{
this.infoBuilding = value;
}
}
/// <summary>
/// Gets or sets the room where the institution is located.
/// </summary>
[XmlAttribute("location_room")]
public string Room
{
get
{
return this.infoRoom;
}
set
{
this.infoRoom = value;
}
}
/// <summary>
/// Gets or sets the german comment.
/// </summary>
[XmlAttribute("comment_de")]
public string Comment_DE
{
get
{
return this.commentDE;
}
set
{
this.commentDE = value;
}
}
/// <summary>
/// Gets or sets the english comment.
/// </summary>
[XmlAttribute("comment_en")]
public string Comment_EN
{
get
{
return this.commentEN;
}
set
{
this.commentEN = value;
}
}
/// <summary>
/// Gets the localized title. If the phone is set to german language,
/// the german title will be returned otherwise the english title.
/// </summary>
public string Title
{
get
{
if (CultureInfo.CurrentUICulture.Name.StartsWith("de"))
{
return this.titleDE;
}
else
{
return this.titleEN;
}
}
}
/// <summary>
/// Gets the localized comment. if the phone is set to german language,
/// the german comment will be returned otherwise the english comment.
/// </summary>
public string Comment
{
get
{
if (CultureInfo.CurrentUICulture.Name.StartsWith("de"))
{
return this.commentDE;
}
else
{
return this.commentEN;
}
}
}
/// <summary>
/// Gets a string containing the email address and the institution
/// title separated by ':'.
/// </summary>
public string EMailTitle
{
get
{
return this.EMail + ":" + this.Title;
}
}
/// <summary>
/// Gets a string containing the phone number and the institution
/// title separated by ':'.
/// </summary>
public string PhoneTitle
{
get
{
return this.Phone + ":" + this.Title;
}
}
/// <summary>
/// Gets the visibility state of the monday TextBlock.
/// </summary>
public Visibility VisibleMonday
{
get
{
return ((this.dayMonday == string.Empty) || (this.dayMonday.Length == 0)) ? Visibility.Collapsed : Visibility.Visible;
}
}
/// <summary>
/// Gets the visibility state of the tuesday TextBlock.
/// </summary>
public Visibility VisibleTuesday
{
get
{
return ((this.dayTuesday == string.Empty) || (this.dayTuesday.Length == 0)) ? Visibility.Collapsed : Visibility.Visible;
}
}
/// <summary>
/// Gets the visibility state of the wednesday TextBlock.
/// </summary>
public Visibility VisibleWednesday
{
get
{
return ((this.dayWednesday == string.Empty) || (this.dayWednesday.Length == 0)) ? Visibility.Collapsed : Visibility.Visible;
}
}
/// <summary>
/// Gets the visibility state of the thursday TextBlock.
/// </summary>
public Visibility VisibleThursday
{
get
{
return ((this.dayThursday == string.Empty) || (this.dayThursday.Length == 0)) ? Visibility.Collapsed : Visibility.Visible;
}
}
/// <summary>
/// Gets the visibility state of the friday TextBlock.
/// </summary>
public Visibility VisibleFriday
{
get
{
return ((this.dayFriday == string.Empty) || (this.dayFriday.Length == 0)) ? Visibility.Collapsed : Visibility.Visible;
}
}
/// <summary>
/// Gets the visibility state of the saturday TextBlock.
/// </summary>
public Visibility VisibleSaturday
{
get
{
return ((this.daySaturday == string.Empty) || (this.daySaturday.Length == 0)) ? Visibility.Collapsed : Visibility.Visible;
}
}
/// <summary>
/// Gets the visibility state of the sunday TextBlock.
/// </summary>
public Visibility VisibleSunday
{
get
{
return ((this.daySunday == string.Empty) || (this.daySunday.Length == 0)) ? Visibility.Collapsed : Visibility.Visible;
}
}
/// <summary>
/// Gets the visibility state of the comment.
/// </summary>
public Visibility VisibleComment
{
get
{
return ((this.Comment == string.Empty) || (this.Comment.Length == 0)) ? Visibility.Collapsed : Visibility.Visible;
}
}
/// <summary>
/// Gets the visibility state of the email address.
/// </summary>
public Visibility VisibleEMail
{
get
{
return ((this.infoEmail == string.Empty) || (this.infoEmail.Length == 0)) ? Visibility.Collapsed : Visibility.Visible;
}
}
/// <summary>
/// Gets the visibility state of the phone number.
/// </summary>
public Visibility VisiblePhone
{
get
{
return ((this.infoPhone == string.Empty) || (this.infoPhone.Length == 0)) ? Visibility.Collapsed : Visibility.Visible;
}
}
/// <summary>
/// Gets the visibility state of the room.
/// </summary>
public Visibility VisibleRoom
{
get
{
return ((this.infoRoom == string.Empty) || (this.infoRoom.Length == 0)) ? Visibility.Collapsed : Visibility.Visible;
}
}
/// <summary>
/// Gets the visibility state of the building.
/// </summary>
public Visibility VisibleBuilding
{
get
{
return ((this.infoBuilding == string.Empty) || (this.infoBuilding.Length == 0)) ? Visibility.Collapsed : Visibility.Visible;
}
}
#endregion
#region Method
/// <summary>
/// Removes unwanted chars in a string.
/// </summary>
/// <param name="str">input string</param>
/// <returns>fixed string</returns>
private string FixOpeninghoursString(string str)
{
string retValue = string.Empty;
retValue = str.Replace(" | ", "\n");
return retValue;
}
#endregion
}
}