add toogleButton and in import in Studentcouncil
This commit is contained in:
@@ -211,6 +211,7 @@
|
||||
<Compile Include="Utility\Logger.cs" />
|
||||
<Compile Include="Utility\HttpRequest.cs" />
|
||||
<Compile Include="Utility\Lui\Button\GoToMapButton.cs" />
|
||||
<Compile Include="Utility\Lui\Button\ToggleButton.cs" />
|
||||
<Compile Include="Utility\Lui\Button\NavigateButton.cs" />
|
||||
<Compile Include="Utility\Lui\Button\PhoneButton.cs" />
|
||||
<Compile Include="Utility\Lui\Button\LinkButton.cs" />
|
||||
|
||||
@@ -30,27 +30,27 @@
|
||||
<phone:Pivot.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ListBox x:Name="ListPanel" ItemsSource="{Binding Value}">
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel>
|
||||
<Button Content="{Binding Name}" Background="Gray" BorderBrush="Gray" Foreground="Black" Margin="-10,-10,-10,-10" Click="ToggleOptions"/>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Visibility="Collapsed">
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel>
|
||||
<lui:ToggleButton Content="{Binding Name}" ToggleContentTag="{Binding Path=Constants.ToggleContent, Source={StaticResource Const}}" Background="Gray" BorderBrush="Gray" Foreground="Black" Margin="-10,-10,-10,-10"/>
|
||||
<StackPanel Tag="{Binding Path=Constants.ToggleContent, Source={StaticResource Const}}" Orientation="Horizontal" HorizontalAlignment="Center" Visibility="Collapsed">
|
||||
<lui:LinkButton Height="75" Url="{Binding Url}" />
|
||||
<lui:EmailButton Height="75" EmailAddress="{Binding Email}"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</DataTemplate>
|
||||
</phone:Pivot.ItemTemplate>
|
||||
</phone:Pivot>
|
||||
</Grid>
|
||||
|
||||
|
||||
</phone:PhoneApplicationPage>
|
||||
@@ -29,11 +29,6 @@ namespace CampusAppWP8.Pages.StudentCouncil
|
||||
/// </summary>
|
||||
private StudentCouncilFeed feed;
|
||||
|
||||
/// <summary>
|
||||
/// last visible UI element.
|
||||
/// </summary>
|
||||
private UIElement lastOpenUIElem = null;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
@@ -72,36 +67,6 @@ namespace CampusAppWP8.Pages.StudentCouncil
|
||||
#endregion
|
||||
#region private
|
||||
|
||||
/// <summary>
|
||||
/// Method toggle the Visibility of the Link- and Details-Buttons
|
||||
/// </summary>
|
||||
/// <param name="sender">Caller of the function</param>
|
||||
/// <param name="e">some EventArgs</param>
|
||||
private void ToggleOptions(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (this.lastOpenUIElem != null)
|
||||
{
|
||||
this.lastOpenUIElem.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
FrameworkElement btn = sender as FrameworkElement;
|
||||
StackPanel parent = btn.Parent as StackPanel;
|
||||
|
||||
if (parent.Children.Count() >= 2)
|
||||
{
|
||||
if (!parent.Children[1].Equals(this.lastOpenUIElem))
|
||||
{
|
||||
this.lastOpenUIElem = parent.Children[1];
|
||||
this.lastOpenUIElem.Visibility = Visibility.Visible;
|
||||
this.ProgressBar.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.lastOpenUIElem = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method initialize the Feed
|
||||
/// </summary>
|
||||
|
||||
@@ -285,6 +285,15 @@ namespace CampusAppWP8.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die ToggleContent ähnelt.
|
||||
/// </summary>
|
||||
public static string ToggleContent {
|
||||
get {
|
||||
return ResourceManager.GetString("ToggleContent", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die http://www.zv.tu-cottbus.de/LSFveranst/LSF4 ähnelt.
|
||||
/// </summary>
|
||||
|
||||
@@ -213,4 +213,7 @@
|
||||
<data name="PathStudentCouncil_StudentCouncilPage" xml:space="preserve">
|
||||
<value>/Pages/StudentCouncil/StudentCouncilPage.xaml</value>
|
||||
</data>
|
||||
<data name="ToggleContent" xml:space="preserve">
|
||||
<value>ToggleContent</value>
|
||||
</data>
|
||||
</root>
|
||||
257
CampusAppWP8/CampusAppWP8/Utility/Lui/Button/ToggleButton.cs
Normal file
257
CampusAppWP8/CampusAppWP8/Utility/Lui/Button/ToggleButton.cs
Normal file
@@ -0,0 +1,257 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="ToggleButton.cs" company="BTU/IIT">
|
||||
// Company copyright tag.
|
||||
// </copyright>
|
||||
// <author>stubbfel</author>
|
||||
// <sience>08.07.2013</sience>
|
||||
//----------------------------------------------------------------------
|
||||
namespace CampusAppWP8.Utility.Lui.Button
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
/// <summary>
|
||||
/// This class create an Button which can toggle the Visibility of certain FrameworkElements
|
||||
/// </summary>
|
||||
public class ToggleButton : System.Windows.Controls.Button
|
||||
{
|
||||
#region Members
|
||||
|
||||
#region public
|
||||
/// <summary>
|
||||
/// Register the ToggleContentTag
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ToggleContentTagProperty = DependencyProperty.Register("ToggleContentTag", typeof(object), typeof(ToggleButton), new PropertyMetadata(false));
|
||||
|
||||
#endregion
|
||||
#region private
|
||||
|
||||
/// <summary>
|
||||
/// List of FrameworkElement which can change their Visibility by this button
|
||||
/// </summary>
|
||||
private List<FrameworkElement> toggleElements = null;
|
||||
|
||||
/// <summary>
|
||||
/// EventHandler of the ToggleButton
|
||||
/// </summary>
|
||||
private ToggleButtonHandler eventHandler;
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ToggleButton" /> class.
|
||||
/// </summary>
|
||||
public ToggleButton()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
|
||||
/// <summary>
|
||||
/// Delegate for the ToggleButton events
|
||||
/// </summary>
|
||||
private delegate void ToggleButtonHandler();
|
||||
|
||||
/// <summary>
|
||||
/// The closeButtonEvent
|
||||
/// </summary>
|
||||
private static event ToggleButtonHandler CloseButtonEvent;
|
||||
#endregion
|
||||
|
||||
#region Proberties
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ToggleContentTag
|
||||
/// </summary>
|
||||
public object ToggleContentTag
|
||||
{
|
||||
get { return (object)this.GetValue(ToggleContentTagProperty); }
|
||||
set { this.SetValue(ToggleContentTagProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
#region public
|
||||
|
||||
/// <summary>
|
||||
/// Method close the ToggleContent of the old ToggleContent and then show the new one
|
||||
/// </summary>
|
||||
public void ToggleToggleContent()
|
||||
{
|
||||
if (this.toggleElements != null)
|
||||
{
|
||||
// close the old (other) Button
|
||||
if (CloseButtonEvent != null && !CloseButtonEvent.Equals(this.eventHandler))
|
||||
{
|
||||
CloseButtonEvent();
|
||||
}
|
||||
|
||||
foreach (UIElement elment in this.toggleElements)
|
||||
{
|
||||
this.ToggleToggleContentElement(elment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method show all Element of the ToggleContent
|
||||
/// </summary>
|
||||
public void ShowToggleContent()
|
||||
{
|
||||
if (this.toggleElements != null)
|
||||
{
|
||||
foreach (UIElement elment in this.toggleElements)
|
||||
{
|
||||
this.ShowToggleContentElement(elment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method show all Element of the ToggleContent
|
||||
/// </summary>
|
||||
public void HideToggleContent()
|
||||
{
|
||||
if (this.toggleElements != null)
|
||||
{
|
||||
foreach (UIElement elment in this.toggleElements)
|
||||
{
|
||||
this.HideToggleContentElement(elment);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region protected
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the OnClick-Method from button
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// now method toggle the visibility of some FrameWorkElements
|
||||
/// </remarks>
|
||||
protected override void OnClick()
|
||||
{
|
||||
if (this.toggleElements == null)
|
||||
{
|
||||
this.SetupToggleElements();
|
||||
}
|
||||
|
||||
this.ToggleToggleContent();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region private
|
||||
|
||||
/// <summary>
|
||||
/// Method look for some ToggleContent
|
||||
/// </summary>
|
||||
private void SetupToggleElements()
|
||||
{
|
||||
this.toggleElements = new List<FrameworkElement>();
|
||||
Panel parent = this.Parent as Panel;
|
||||
if (parent == null)
|
||||
{
|
||||
parent = this.GetFirstParentPanel();
|
||||
}
|
||||
|
||||
foreach (FrameworkElement element in parent.Children)
|
||||
{
|
||||
string elementTag = element.Tag as string;
|
||||
if (elementTag != null && elementTag.Contains(this.ToggleContentTag as string))
|
||||
{
|
||||
this.toggleElements.Add(element);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first panel, which is a parent of this button
|
||||
/// </summary>
|
||||
/// <returns> first panel of the parents</returns>
|
||||
private Panel GetFirstParentPanel()
|
||||
{
|
||||
FrameworkElement parentElement = this.Parent as FrameworkElement;
|
||||
Panel parentPanel = parentElement as Panel;
|
||||
while (parentPanel == null)
|
||||
{
|
||||
parentElement = parentElement.Parent as FrameworkElement;
|
||||
if (parentElement == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
parentPanel = parentElement as Panel;
|
||||
}
|
||||
|
||||
return parentPanel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method toggle the visibility of a certain element
|
||||
/// </summary>
|
||||
/// <param name="element">element of the ToggleContent</param>
|
||||
private void ToggleToggleContentElement(UIElement element)
|
||||
{
|
||||
if (element != null)
|
||||
{
|
||||
if (Visibility.Collapsed.Equals(element.Visibility))
|
||||
{
|
||||
this.ShowToggleContentElement(element);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.HideToggleContentElement(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method show the visibility of a certain element
|
||||
/// </summary>
|
||||
/// <param name="element">element of the ToggleContent</param>
|
||||
private void ShowToggleContentElement(UIElement element)
|
||||
{
|
||||
if (element != null)
|
||||
{
|
||||
element.Visibility = Visibility.Visible;
|
||||
if (this.eventHandler == null)
|
||||
{
|
||||
this.eventHandler = new ToggleButtonHandler(this.HideToggleContent);
|
||||
CloseButtonEvent += this.eventHandler;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method hide the visibility of a certain element
|
||||
/// </summary>
|
||||
/// <param name="element">element of the ToggleContent</param>
|
||||
private void HideToggleContentElement(UIElement element)
|
||||
{
|
||||
if (element != null)
|
||||
{
|
||||
element.Visibility = Visibility.Collapsed;
|
||||
if (this.eventHandler != null)
|
||||
{
|
||||
CloseButtonEvent -= this.eventHandler;
|
||||
this.eventHandler = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user