fixed #220
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
<local:LocalizedStrings xmlns:local="clr-namespace:CampusAppWP8" x:Key="LocalizedStrings"/>
|
||||
<local:ThemelizedIcons xmlns:local="clr-namespace:CampusAppWP8" x:Key="ThemelizedIcons"/>
|
||||
<local:Const xmlns:local="clr-namespace:CampusAppWP8" x:Key="Const"/>
|
||||
<local:BoolToVisibilityConverter xmlns:local="clr-namespace:CampusAppWP8.Utility" x:Key="BoolToVisibilityConverter"/>
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
|
||||
@@ -162,6 +162,7 @@
|
||||
</Compile>
|
||||
<Compile Include="Utility\AppUriMapper.cs" />
|
||||
<Compile Include="Utility\BackgroundTasks.cs" />
|
||||
<Compile Include="Utility\BoolToVisibilityConverter.cs" />
|
||||
<Compile Include="Utility\Lui\Button\AddPersonButton.cs" />
|
||||
<Compile Include="Utility\Lui\Header\DefaultHeader.xaml.cs">
|
||||
<DependentUpon>DefaultHeader.xaml</DependentUpon>
|
||||
|
||||
@@ -32,14 +32,14 @@
|
||||
</DataTemplate>
|
||||
</phone:Pivot.HeaderTemplate>
|
||||
<phone:Pivot.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<DataTemplate x:Name="DataTemp">
|
||||
<Grid x:Name="EventParentGrid">
|
||||
<Grid.RowDefinitions>
|
||||
<!--<RowDefinition Height="100"/>-->
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid x:Name="EventTextGrid" Grid.Row="0">
|
||||
<Grid x:Name="EventTextGrid" Grid.Row="0" Visibility="{Binding Path=TextVisibility, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" MaxHeight="300"/>
|
||||
<RowDefinition Height="*" />
|
||||
@@ -51,7 +51,7 @@
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
|
||||
<phone:WebBrowser x:Name="EventWebBrowser" Source="{Binding Path=Link, Mode=OneWay}" Grid.Row="0" IsScriptEnabled="True" Visibility="Collapsed"/>
|
||||
<phone:WebBrowser x:Name="EventWebBrowser" Source="{Binding Path=Link, Mode=OneWay}" Grid.Row="0" IsScriptEnabled="True" Visibility="{Binding Path=BrowserVisibility, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</phone:Pivot.ItemTemplate>
|
||||
|
||||
@@ -20,6 +20,8 @@ namespace CampusAppWP8.Pages.Events
|
||||
using Windows.Phone.Speech.Synthesis;
|
||||
using CampusAppWPortalLib8.Model.RSS;
|
||||
|
||||
using System.Windows.Media;
|
||||
|
||||
/// <summary>
|
||||
/// EventPage, where every event feed has his own PivotItem.
|
||||
/// </summary>
|
||||
@@ -32,11 +34,6 @@ namespace CampusAppWP8.Pages.Events
|
||||
/// </summary>
|
||||
private bool isSourceSet = false;
|
||||
|
||||
/// <summary>
|
||||
/// To store the last selected pivot index.
|
||||
/// </summary>
|
||||
private int lastSelectedIndex = -1;
|
||||
|
||||
/// <summary>
|
||||
/// For checking if the instance is back from tombstone.
|
||||
/// </summary>
|
||||
@@ -181,15 +178,15 @@ namespace CampusAppWP8.Pages.Events
|
||||
/// <param name="e">event args</param>
|
||||
private void OnPivotSelectionChange(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
int selIndex = (sender as Pivot).SelectedIndex;
|
||||
|
||||
if (this.lastSelectedIndex > -1)
|
||||
if (e.RemovedItems.Count > 0)
|
||||
{
|
||||
Utilities.SetElementVisibility(this.EventPivot, "EventParentGrid", "EventWebBrowser", Visibility.Collapsed, this.lastSelectedIndex);
|
||||
Utilities.SetElementVisibility(this.EventPivot, "EventParentGrid", "EventTextGrid", Visibility.Visible, this.lastSelectedIndex);
|
||||
}
|
||||
RSSModel last = e.RemovedItems[0] as RSSModel;
|
||||
|
||||
this.lastSelectedIndex = selIndex;
|
||||
if (last != null && last.TextVisibility == false)
|
||||
{
|
||||
last.TextVisibility = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -201,15 +198,13 @@ namespace CampusAppWP8.Pages.Events
|
||||
/// <param name="e">event args</param>
|
||||
private void EventLink_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Visibility.Visible == Utilities.GetElementVisibility(this.EventPivot, "EventParentGrid", "EventTextGrid", this.EventPivot.SelectedIndex))
|
||||
RSSModel cur = this.EventPivot.SelectedItem as RSSModel;
|
||||
|
||||
this.EventPivot.UpdateLayout();
|
||||
|
||||
if (cur != null)
|
||||
{
|
||||
Utilities.SetElementVisibility(this.EventPivot, "EventParentGrid", "EventTextGrid", Visibility.Collapsed, this.EventPivot.SelectedIndex);
|
||||
Utilities.SetElementVisibility(this.EventPivot, "EventParentGrid", "EventWebBrowser", Visibility.Visible, this.EventPivot.SelectedIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
Utilities.SetElementVisibility(this.EventPivot, "EventParentGrid", "EventWebBrowser", Visibility.Collapsed, this.EventPivot.SelectedIndex);
|
||||
Utilities.SetElementVisibility(this.EventPivot, "EventParentGrid", "EventTextGrid", Visibility.Visible, this.EventPivot.SelectedIndex);
|
||||
cur.TextVisibility = (cur.TextVisibility) ? false : true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid x:Name="NewsTextGrid" Grid.Row="0">
|
||||
<Grid x:Name="NewsTextGrid" Grid.Row="0" Visibility="{Binding Path=TextVisibility, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" MaxHeight="300"/>
|
||||
<RowDefinition Height="*" />
|
||||
@@ -50,7 +50,7 @@
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
|
||||
<phone:WebBrowser x:Name="NewsWebBrowser" Source="{Binding Path=Link, Mode=OneWay}" Grid.Row="0" IsScriptEnabled="True" Visibility="Collapsed"/>
|
||||
<phone:WebBrowser x:Name="NewsWebBrowser" Source="{Binding Path=Link, Mode=OneWay}" Grid.Row="0" IsScriptEnabled="True" Visibility="{Binding Path=BrowserVisibility, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</phone:Pivot.ItemTemplate>
|
||||
|
||||
@@ -30,11 +30,6 @@ namespace CampusAppWP8.Pages.News
|
||||
/// </summary>
|
||||
private bool isSourceSet = false;
|
||||
|
||||
/// <summary>
|
||||
/// To store the index of the last selected PivotItem.
|
||||
/// </summary>
|
||||
private int lastSelectedIndex = -1;
|
||||
|
||||
/// <summary>
|
||||
/// For checking if the instance is back from tombstone.
|
||||
/// </summary>
|
||||
@@ -176,15 +171,15 @@ namespace CampusAppWP8.Pages.News
|
||||
/// <param name="e">event args</param>
|
||||
private void OnPivotSelectionChange(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
int selIndex = (sender as Pivot).SelectedIndex;
|
||||
|
||||
if (this.lastSelectedIndex > -1)
|
||||
if (e.RemovedItems.Count > 0)
|
||||
{
|
||||
Utilities.SetElementVisibility(this.NewsPivot, "NewsParentGrid", "NewsWebBrowser", Visibility.Collapsed, this.lastSelectedIndex);
|
||||
Utilities.SetElementVisibility(this.NewsPivot, "NewsParentGrid", "NewsTextGrid", Visibility.Visible, this.lastSelectedIndex);
|
||||
}
|
||||
RSSModel last = e.RemovedItems[0] as RSSModel;
|
||||
|
||||
this.lastSelectedIndex = selIndex;
|
||||
if (last != null && last.TextVisibility == false)
|
||||
{
|
||||
last.TextVisibility = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -196,15 +191,13 @@ namespace CampusAppWP8.Pages.News
|
||||
/// <param name="e">event args</param>
|
||||
private void NewsLink_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Visibility.Visible == Utilities.GetElementVisibility(this.NewsPivot, "NewsParentGrid", "NewsTextGrid", this.NewsPivot.SelectedIndex))
|
||||
RSSModel cur = this.NewsPivot.SelectedItem as RSSModel;
|
||||
|
||||
this.NewsPivot.UpdateLayout();
|
||||
|
||||
if (cur != null)
|
||||
{
|
||||
Utilities.SetElementVisibility(this.NewsPivot, "NewsParentGrid", "NewsTextGrid", Visibility.Collapsed, this.NewsPivot.SelectedIndex);
|
||||
Utilities.SetElementVisibility(this.NewsPivot, "NewsParentGrid", "NewsWebBrowser", Visibility.Visible, this.NewsPivot.SelectedIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
Utilities.SetElementVisibility(this.NewsPivot, "NewsParentGrid", "NewsWebBrowser", Visibility.Collapsed, this.NewsPivot.SelectedIndex);
|
||||
Utilities.SetElementVisibility(this.NewsPivot, "NewsParentGrid", "NewsTextGrid", Visibility.Visible, this.NewsPivot.SelectedIndex);
|
||||
cur.TextVisibility = (cur.TextVisibility) ? false : true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// <copyright file="BoolToVisibilityConverter.cs" company="BTU/IIT">
|
||||
// Company copyright tag.
|
||||
// </copyright>
|
||||
// <author>fiedlchr</author>
|
||||
// <sience>10.10.2013</sience>
|
||||
//-----------------------------------------------------------------------------
|
||||
namespace CampusAppWP8.Utility
|
||||
{
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
public sealed class BoolToVisibilityConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo language)
|
||||
{
|
||||
return (value is bool && (bool)value) ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo language)
|
||||
{
|
||||
return (value is Visibility && (Visibility)value == Visibility.Visible);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -136,22 +136,22 @@ namespace CampusAppWP8.Utility
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Search for a UIElement with the specified name in the parent Grid and set its visibility.
|
||||
/// Return the element.
|
||||
/// </summary>
|
||||
/// <param name="rootObj">root object</param>
|
||||
/// <param name="parentGridName">name of the parent grid</param>
|
||||
/// <param name="elemName">name of the UIElement</param>
|
||||
/// <param name="vis">new visibility property state</param>
|
||||
/// <param name="index">index of the element in the parent child list</param>
|
||||
public static void SetElementVisibility(DependencyObject rootObj, string parentGridName, string elemName, Visibility vis, int index = 0)
|
||||
/// <param name="rootObj"></param>
|
||||
/// <param name="parentGridName"></param>
|
||||
/// <param name="elemName"></param>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
public static FrameworkElement GetElement(DependencyObject rootObj, string parentGridName, string elemName, int index = 0)
|
||||
{
|
||||
List<DependencyObject> l = Utilities.GetChild(rootObj, parentGridName);
|
||||
|
||||
// hotfix: OutofRangeIndex Assert
|
||||
if (index > l.Count - 1)
|
||||
{
|
||||
return;
|
||||
throw new IndexOutOfRangeException("index (" + index + ") out of range (<" + l.Count + ")");
|
||||
}
|
||||
|
||||
Grid parentGrid = l[index] as Grid;
|
||||
FrameworkElement elem = null;
|
||||
|
||||
@@ -163,6 +163,21 @@ namespace CampusAppWP8.Utility
|
||||
}
|
||||
}
|
||||
|
||||
return elem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Search for a UIElement with the specified name in the parent Grid and set its visibility.
|
||||
/// </summary>
|
||||
/// <param name="rootObj">root object</param>
|
||||
/// <param name="parentGridName">name of the parent grid</param>
|
||||
/// <param name="elemName">name of the UIElement</param>
|
||||
/// <param name="vis">new visibility property state</param>
|
||||
/// <param name="index">index of the element in the parent child list</param>
|
||||
public static void SetElementVisibility(DependencyObject rootObj, string parentGridName, string elemName, Visibility vis, int index = 0)
|
||||
{
|
||||
FrameworkElement elem = GetElement(rootObj, parentGridName, elemName, index);
|
||||
|
||||
if (elem != null)
|
||||
{
|
||||
elem.Visibility = vis;
|
||||
@@ -180,25 +195,8 @@ namespace CampusAppWP8.Utility
|
||||
public static Visibility GetElementVisibility(DependencyObject rootObj, string parentGridName, string elemName, int index = 0)
|
||||
{
|
||||
Visibility retValue;
|
||||
|
||||
List<DependencyObject> l = Utilities.GetChild(rootObj, parentGridName);
|
||||
|
||||
if (index >= l.Count)
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
|
||||
Grid parentGrid = l[index] as Grid;
|
||||
FrameworkElement elem = null;
|
||||
|
||||
foreach (FrameworkElement tempElem in parentGrid.Children)
|
||||
{
|
||||
if (tempElem.Name == elemName)
|
||||
{
|
||||
elem = tempElem;
|
||||
}
|
||||
}
|
||||
|
||||
FrameworkElement elem = GetElement(rootObj, parentGridName, elemName, index);
|
||||
|
||||
if (elem != null)
|
||||
{
|
||||
retValue = elem.Visibility;
|
||||
|
||||
@@ -10,13 +10,16 @@ namespace CampusAppWPortalLib8.Model.RSS
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
using System.ComponentModel;
|
||||
|
||||
/// <summary>
|
||||
/// Contains the RSS feed information.
|
||||
/// </summary>
|
||||
public class RSSModel
|
||||
public class RSSModel : INotifyPropertyChanged
|
||||
{
|
||||
#region Member
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Index of this object.
|
||||
@@ -43,8 +46,10 @@ namespace CampusAppWPortalLib8.Model.RSS
|
||||
/// </summary>
|
||||
private string link;
|
||||
|
||||
#endregion
|
||||
private bool textVisible = true;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Property
|
||||
|
||||
/// <summary>
|
||||
@@ -195,6 +200,38 @@ namespace CampusAppWPortalLib8.Model.RSS
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visibility of the text.
|
||||
/// </summary>
|
||||
public bool TextVisibility
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.textVisible;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value != this.textVisible)
|
||||
{
|
||||
this.textVisible = value;
|
||||
this.NotifyPropertyChanged("TextVisibility");
|
||||
this.NotifyPropertyChanged("BrowserVisibility");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visibility of the browser.
|
||||
/// </summary>
|
||||
public bool BrowserVisibility
|
||||
{
|
||||
get
|
||||
{
|
||||
return !this.textVisible;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Method
|
||||
@@ -224,6 +261,14 @@ namespace CampusAppWPortalLib8.Model.RSS
|
||||
|
||||
#region private
|
||||
|
||||
private void NotifyPropertyChanged(string info)
|
||||
{
|
||||
if (PropertyChanged != null)
|
||||
{
|
||||
this.PropertyChanged(this, new PropertyChangedEventArgs(info));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove or transform html-unicode specific tags into ASCII.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user