new copyfunction and guifixes (mensapige)
This commit is contained in:
@@ -13,12 +13,19 @@ namespace CampusAppWP8.Feed.Mensa
|
||||
using CampusAppWP8.Model;
|
||||
using CampusAppWPortalLib8.Model.Mensa;
|
||||
using CampusAppWPortalLib8.Model;
|
||||
using CampusAppWP8.Resources;
|
||||
using CampusAppWPortalLib8.Model.Settings;
|
||||
|
||||
/// <summary> This Class is for MensaFeeds. </summary>
|
||||
/// <remarks> Stubbfel, 14.10.2013. </remarks>
|
||||
/// <seealso cref="T:CampusAppWP8.Model.XmlModel{CampusAppWPortalLib8.Model.Mensa.MenuWeekModel}"/>
|
||||
public abstract class MensaFeed : XmlModel<MenuWeekModel>
|
||||
{
|
||||
#region Member
|
||||
/// <summary> The price feed. </summary>
|
||||
private PriceFeed priceFeed = null;
|
||||
|
||||
#endregion
|
||||
#region Constructor
|
||||
|
||||
/// <summary> Initializes a new instance of the <see cref="MensaFeed" /> class. </summary>
|
||||
@@ -31,6 +38,11 @@ namespace CampusAppWP8.Feed.Mensa
|
||||
this.IsFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDate);
|
||||
this.IsModelUpToDateOnLoad += new IsModelUpToDate(this.CheckIsModelUpToDate);
|
||||
this.IsFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDate);
|
||||
|
||||
this.priceFeed = new PriceFeed();
|
||||
this.priceFeed.OnLoaded += this.PriceFeedIsReady;
|
||||
this.priceFeed.OnFailedLoad += this.PriceFeedIsFailed;
|
||||
this.priceFeed.LoadData();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -41,6 +53,10 @@ namespace CampusAppWP8.Feed.Mensa
|
||||
/// <value> The title. </value>
|
||||
public string Title { get; protected set; }
|
||||
|
||||
/// <summary> Gets the title. </summary>
|
||||
/// <value> The title. </value>
|
||||
public Campus Campus { get; protected set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Method
|
||||
@@ -119,6 +135,79 @@ namespace CampusAppWP8.Feed.Mensa
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ändert die Quelldaten vor der Übergabe an das Ziel zur Anzeige in der Benutzeroberfläche.
|
||||
/// </summary>
|
||||
/// <remarks> Fiedler, 14.11.2013. </remarks>
|
||||
/// <seealso cref="M:System.Windows.Data.IValueConverter.Convert(object,Type,object,System.Globalization.CultureInfo)"/>
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo language)
|
||||
{
|
||||
string retValue = string.Empty;
|
||||
int intVal = -1;
|
||||
int intParam = -1;
|
||||
|
||||
if (value is int)
|
||||
{
|
||||
intVal = (int)value;
|
||||
}
|
||||
else if (value is string)
|
||||
{
|
||||
intVal = int.Parse((string)value);
|
||||
}
|
||||
|
||||
if (parameter is int)
|
||||
{
|
||||
intParam = (int)parameter;
|
||||
}
|
||||
else if (parameter is string)
|
||||
{
|
||||
intParam = int.Parse((string)parameter);
|
||||
}
|
||||
|
||||
if ((intVal >= 0) && (intParam >= 0))
|
||||
{
|
||||
if (this.priceFeed != null && this.priceFeed.Model != null)
|
||||
{
|
||||
PriceMealModel model = this.priceFeed.Model.GetCanteen(intParam).GetPriceMealModel(intVal);
|
||||
retValue = AppResources.Students + ": " + model.PriceStudentStr + " € " + AppResources.Employees + ": " + model.PriceEmployeeStr + " € " + AppResources.Guests + ": " + model.PriceGuestStr + " €";
|
||||
}
|
||||
}
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
/// <summary> Price feed is ready. </summary>
|
||||
/// <remarks> Fiedler, 14.11.2013. </remarks>
|
||||
private void PriceFeedIsReady()
|
||||
{
|
||||
this.priceFeed.SaveData();
|
||||
}
|
||||
|
||||
/// <summary> Sets the prices. </summary>
|
||||
/// <remarks> Stubbfel, 18.11.2013. </remarks>
|
||||
public void SetPrices()
|
||||
{
|
||||
if (this.Model == null || this.Model.Menus == null || this.priceFeed == null || this.priceFeed.Model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach(MenuModel menu in this.Model.Menus) {
|
||||
foreach (MealModel meal in menu.Meals)
|
||||
{
|
||||
PriceMealModel model = this.priceFeed.Model.GetCanteen(this.Campus).GetPriceMealModel(meal.MealId);
|
||||
meal.Price = AppResources.Students + ": " + model.PriceStudentStr + " € " + AppResources.Employees + ": " + model.PriceEmployeeStr + " € " + AppResources.Guests + ": " + model.PriceGuestStr + " €";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary> Price feed is failed. </summary>
|
||||
/// <remarks> Fiedler, 14.11.2013. </remarks>
|
||||
private void PriceFeedIsFailed()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace CampusAppWP8.Feed.Mensa
|
||||
: base(Constants.FileMensa_Shedule_CBMain, CampusAppWPortalLib8.Resources.Constants.UrlMensa_Week_CBMain)
|
||||
{
|
||||
this.Title = CampusAppWPortalLib8.Resources.AppResources.Campus_CBMain;
|
||||
this.Campus = CampusAppWPortalLib8.Model.Settings.Campus.CB_MAIN;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace CampusAppWP8.Feed.Mensa
|
||||
: base(Constants.FileMensa_Shedule_CBNorth, CampusAppWPortalLib8.Resources.Constants.UrlMensa_Week_CBNorth)
|
||||
{
|
||||
this.Title = CampusAppWPortalLib8.Resources.AppResources.Campus_CBNorth;
|
||||
this.Campus = CampusAppWPortalLib8.Model.Settings.Campus.CB_NORTH;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace CampusAppWP8.Feed.Mensa
|
||||
: base(Constants.FileMensa_Shedule_CBSouth, CampusAppWPortalLib8.Resources.Constants.UrlMensa_Week_CBSouth)
|
||||
{
|
||||
this.Title = CampusAppWPortalLib8.Resources.AppResources.Campus_CBSouth;
|
||||
this.Campus = CampusAppWPortalLib8.Model.Settings.Campus.CB_SOUTH;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace CampusAppWP8.Feed.Mensa
|
||||
: base(Constants.FileMensa_Shedule_SBFMain, CampusAppWPortalLib8.Resources.Constants.UrlMensa_Week_SBFMain)
|
||||
{
|
||||
this.Title = CampusAppWPortalLib8.Resources.AppResources.Campus_SFBMain;
|
||||
this.Campus = CampusAppWPortalLib8.Model.Settings.Campus.SFB_MAIN;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -19,11 +19,7 @@
|
||||
SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
|
||||
shell:SystemTray.IsVisible="True"
|
||||
x:Name="root">
|
||||
|
||||
<page:PortraitLandscapePage.Resources>
|
||||
<utility:MealIdToPriceConverter x:Key="MealConverter"/>
|
||||
</page:PortraitLandscapePage.Resources>
|
||||
|
||||
|
||||
<!--LayoutRoot ist das Stammraster, in dem alle anderen Seiteninhalte platziert werden-->
|
||||
<Grid x:Name="LayoutRoot" Background="Transparent">
|
||||
<Grid.RowDefinitions>
|
||||
@@ -33,7 +29,7 @@
|
||||
<StackPanel Grid.Row="0">
|
||||
<header:DefaultHeader Name="DefHeader" HeaderName="{Binding Path=LocalizedResources.LocalizedResources.MensaApp_Title, Source={StaticResource LocalizedStrings}}"/>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
<!--Pivotsteuerelement-->
|
||||
<phone:Pivot Grid.Row="1" Name="MensaPivot">
|
||||
<phone:Pivot.HeaderTemplate>
|
||||
@@ -56,7 +52,7 @@
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto"></ColumnDefinition>
|
||||
@@ -71,8 +67,7 @@
|
||||
</StackPanel>
|
||||
<TextBlock Text="{Binding MealDesc}" TextWrapping="Wrap" Grid.Column="1"/>
|
||||
</Grid>
|
||||
|
||||
<lu:MultiValueTextBlock Value1="{Binding MealId}" Value2="{Binding LocationID, ElementName=root, Mode=OneWay}" Converter="{StaticResource MealConverter}" Grid.Row="1" FontSize="14" HorizontalAlignment="Center" Margin="0,10,0,0"/>
|
||||
<TextBlock Text="{Binding Price}" TextWrapping="Wrap" Grid.Row="1" FontSize="14" HorizontalAlignment="Left" Margin="0,10,0,0" TextAlignment="Left" />
|
||||
</Grid>
|
||||
<toolkit:ContextMenuService.ContextMenu>
|
||||
<toolkit:ContextMenu>
|
||||
@@ -96,6 +91,9 @@
|
||||
<shell:ApplicationBarMenuItem Text="Campus1" Click="ApplicationBarMenuItem_Click"/>
|
||||
<shell:ApplicationBarMenuItem Text="Campus2" Click="ApplicationBarMenuItem2_Click"/>
|
||||
<shell:ApplicationBarMenuItem Text="Campus3" Click="ApplicationBarMenuItem3_Click"/>
|
||||
<shell:ApplicationBarMenuItem Text="Tagesplan kopieren" Click="CopyDay"/>
|
||||
<shell:ApplicationBarMenuItem Text="Wochenplan kopieren" Click="CopyWeek"/>
|
||||
|
||||
</shell:ApplicationBar.MenuItems>
|
||||
</shell:ApplicationBar>
|
||||
</phone:PhoneApplicationPage.ApplicationBar>
|
||||
|
||||
@@ -65,6 +65,8 @@ namespace CampusAppWP8.Pages.Mensa
|
||||
ApplicationBarMenuItem menuItem1 = ApplicationBar.MenuItems[0] as ApplicationBarMenuItem;
|
||||
ApplicationBarMenuItem menuItem2 = ApplicationBar.MenuItems[1] as ApplicationBarMenuItem;
|
||||
ApplicationBarMenuItem menuItem3 = ApplicationBar.MenuItems[2] as ApplicationBarMenuItem;
|
||||
ApplicationBarMenuItem menuItem4 = ApplicationBar.MenuItems[3] as ApplicationBarMenuItem;
|
||||
ApplicationBarMenuItem menuItem5 = ApplicationBar.MenuItems[4] as ApplicationBarMenuItem;
|
||||
|
||||
if (menuItem1 != null)
|
||||
{
|
||||
@@ -81,6 +83,16 @@ namespace CampusAppWP8.Pages.Mensa
|
||||
menuItem3.Text = CampusAppWPortalLib8.Resources.AppResources.Campus_SFBMain;
|
||||
}
|
||||
|
||||
if (menuItem4 != null)
|
||||
{
|
||||
menuItem4.Text = AppResources.MensaApp_Dayplan + " " + AppResources.Copy;
|
||||
}
|
||||
|
||||
if (menuItem5 != null)
|
||||
{
|
||||
menuItem5.Text = AppResources.MensaApp_Weekplan + " " + AppResources.Copy;
|
||||
}
|
||||
|
||||
this.DefHeader.ProgressVisibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
@@ -185,12 +197,12 @@ namespace CampusAppWP8.Pages.Mensa
|
||||
this.InitializeFeed(mensaCampus);
|
||||
}
|
||||
}
|
||||
|
||||
/* this.campusApi = new CampusSpsApi();
|
||||
this.campusApi.OnLoaded += new SpsApi.OnIO(this.SpsApiIsReady);
|
||||
this.campusApi.OnFailedLoad += new SpsApi.OnFailed(this.SpsApiIsFail);
|
||||
this.campusApi.SetupCurrentCampusRequest();
|
||||
this.campusApi.LoadData();*/
|
||||
|
||||
/* this.campusApi = new CampusSpsApi();
|
||||
this.campusApi.OnLoaded += new SpsApi.OnIO(this.SpsApiIsReady);
|
||||
this.campusApi.OnFailedLoad += new SpsApi.OnFailed(this.SpsApiIsFail);
|
||||
this.campusApi.SetupCurrentCampusRequest();
|
||||
this.campusApi.LoadData();*/
|
||||
}
|
||||
|
||||
/// <summary> Method initialize the Feed depends of a campus. </summary>
|
||||
@@ -234,6 +246,7 @@ namespace CampusAppWP8.Pages.Mensa
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
private void FeedIsReady()
|
||||
{
|
||||
this.feed.SetPrices();
|
||||
this.SetupMensaPivot();
|
||||
this.DefHeader.ProgressVisibility = Visibility.Collapsed;
|
||||
}
|
||||
@@ -404,6 +417,80 @@ namespace CampusAppWP8.Pages.Mensa
|
||||
Clipboard.SetText(copyText);
|
||||
}
|
||||
|
||||
/// <summary> Copies the menu of the selected day. </summary>
|
||||
/// <remarks> Stubbfel, 18.11.2013. </remarks>
|
||||
/// <param name="sender"> button object. </param>
|
||||
/// <param name="e"> Event information. </param>
|
||||
private void CopyDay(object sender, EventArgs e)
|
||||
{
|
||||
if (this.MensaPivot == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int selecetdIndex = this.MensaPivot.SelectedIndex;
|
||||
|
||||
if (this.feed == null || this.feed.Model == null || selecetdIndex >= this.feed.Model.Menus.Count || selecetdIndex < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MenuModel menu = this.feed.Model.Menus[selecetdIndex];
|
||||
string copyText = AppResources.MensaApp_Dayplan + " (" + menu.Day + " - " + menu.Date + ") - " + AppResources.Setting_UserCampus + " " + this.feed.Title + " :";
|
||||
copyText = Wp8StringManager.AddNewLine(copyText);
|
||||
|
||||
foreach (MealModel meal in menu.Meals)
|
||||
{
|
||||
copyText += meal.MealName + ": " + meal.MealDesc;
|
||||
copyText = Wp8StringManager.AddNewLine(copyText);
|
||||
}
|
||||
|
||||
|
||||
Clipboard.SetText(copyText);
|
||||
}
|
||||
|
||||
/// <summary> Copies all meals from the week. </summary>
|
||||
/// <remarks> Stubbfel, 18.11.2013. </remarks>
|
||||
/// <param name="sender"> button object. </param>
|
||||
/// <param name="e"> Event information. </param>
|
||||
private void CopyWeek(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (this.MensaPivot == null || this.feed == null || this.feed.Model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string startDate = null;
|
||||
string endDate = null;
|
||||
|
||||
string copyText = string.Empty;
|
||||
foreach (MenuModel menu in this.feed.Model.Menus)
|
||||
{
|
||||
if (startDate == null)
|
||||
{
|
||||
startDate = menu.Date;
|
||||
}
|
||||
endDate = menu.Date;
|
||||
|
||||
copyText += menu.Day + " (" + menu.Date + "):";
|
||||
copyText = Wp8StringManager.AddNewLine(copyText);
|
||||
|
||||
foreach (MealModel meal in menu.Meals)
|
||||
{
|
||||
copyText += meal.MealName + ": " + meal.MealDesc;
|
||||
copyText = Wp8StringManager.AddNewLine(copyText);
|
||||
}
|
||||
copyText = Wp8StringManager.AddNewLine(copyText);
|
||||
|
||||
}
|
||||
|
||||
string headline = AppResources.MensaApp_Weekplan + " (" + startDate + " - " + endDate + ") - " + AppResources.Setting_UserCampus + " " + this.feed.Title + " :";
|
||||
headline = Wp8StringManager.AddNewLine(headline);
|
||||
|
||||
Clipboard.SetText(headline + copyText);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -276,6 +276,15 @@ namespace CampusAppWP8.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Kopieren ähnelt.
|
||||
/// </summary>
|
||||
public static string Copy {
|
||||
get {
|
||||
return ResourceManager.GetString("Copy", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Erstellen ähnelt.
|
||||
/// </summary>
|
||||
@@ -744,6 +753,15 @@ namespace CampusAppWP8.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Tagesplan ähnelt.
|
||||
/// </summary>
|
||||
public static string MensaApp_Dayplan {
|
||||
get {
|
||||
return ResourceManager.GetString("MensaApp_Dayplan", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die 84 ähnelt.
|
||||
/// </summary>
|
||||
@@ -762,6 +780,15 @@ namespace CampusAppWP8.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Wochenplan ähnelt.
|
||||
/// </summary>
|
||||
public static string MensaApp_Weekplan {
|
||||
get {
|
||||
return ResourceManager.GetString("MensaApp_Weekplan", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die BTU-Tag ähnelt.
|
||||
/// </summary>
|
||||
|
||||
@@ -605,4 +605,13 @@
|
||||
<data name="Students" xml:space="preserve">
|
||||
<value>Studenten</value>
|
||||
</data>
|
||||
<data name="Copy" xml:space="preserve">
|
||||
<value>Kopieren</value>
|
||||
</data>
|
||||
<data name="MensaApp_Dayplan" xml:space="preserve">
|
||||
<value>Tagesplan</value>
|
||||
</data>
|
||||
<data name="MensaApp_Weekplan" xml:space="preserve">
|
||||
<value>Wochenplan</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -112,6 +112,10 @@ namespace CampusAppWPortalLib8.Model.Mensa
|
||||
/// <value> The icon URL. </value>
|
||||
public string IconUrl { get; set; }
|
||||
|
||||
/// <summary> Gets or sets the price. </summary>
|
||||
/// <value> The price. </value>
|
||||
public string Price { get; set; }
|
||||
|
||||
/// <summary> Gets or sets the icon name. </summary>
|
||||
/// <value> The name of the icon. </value>
|
||||
[XmlAttribute("icon")]
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
//-----------------------------------------------------------------------
|
||||
namespace CampusAppWPortalLib8.Model.Mensa
|
||||
{
|
||||
using CampusAppWPortalLib8.Model.Settings;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
@@ -51,15 +52,25 @@ namespace CampusAppWPortalLib8.Model.Mensa
|
||||
{
|
||||
PriceCanteenModel retValue = null;
|
||||
|
||||
for (int i = 0; i < this.canteens.Count; i++)
|
||||
foreach (PriceCanteenModel prize in this.canteens)
|
||||
{
|
||||
if (this.canteens[i].Id.Equals(id))
|
||||
if (prize.Id == id)
|
||||
{
|
||||
retValue = this.canteens[i];
|
||||
retValue = prize;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
/// <summary> Gets a canteen. </summary>
|
||||
/// <remarks> Stubbfel, 18.11.2013. </remarks>
|
||||
/// <param name="campus"> The campus. </param>
|
||||
/// <returns> The canteen. </returns>
|
||||
public PriceCanteenModel GetCanteen(Campus campus)
|
||||
{
|
||||
return this.GetCanteen((int)campus - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user