finished multi appointment

This commit is contained in:
Christian Fiedler
2013-09-24 17:02:19 +02:00
parent 543247cea2
commit 29efcd8ddb
7 changed files with 275 additions and 68 deletions

View File

@@ -25,13 +25,14 @@ namespace CampusAppWP8.Model.TimeTable
[XmlRoot("root")]
public class AppointmentModel
{
public static readonly double DAY_HOUR_SPACING = 50;
private static double DAY_HOUR_SPACING = 50;
/// <summary>The Visual object.</summary>
private Rectangle rect = null;
private Canvas canvas = null;
private double offsetY = 0;
private double height = 0;
private double width = 100;
private ICalObject icalObj = null;
@@ -44,6 +45,7 @@ namespace CampusAppWP8.Model.TimeTable
this.rect = new Rectangle();
this.canvas = new Canvas();
this.canvas.DoubleTap += new EventHandler<System.Windows.Input.GestureEventArgs>(this.OnCanvasClick);
this.canvas.SizeChanged += new SizeChangedEventHandler(this.OnCanvasSizeChanged);
}
public AppointmentModel(string icsData) : this()
@@ -51,9 +53,22 @@ namespace CampusAppWP8.Model.TimeTable
this.icalObj = ICSManager.ImportFromICS(icsData);
this.CalcYOffset();
this.CalcHeight();
this.CalcRect();
}
public static double HourSpacing
{
get
{
return DAY_HOUR_SPACING;
}
set
{
DAY_HOUR_SPACING = value;
}
}
public double GetYOffset
{
get
@@ -70,9 +85,16 @@ namespace CampusAppWP8.Model.TimeTable
}
}
public Canvas GetCanvas()
public Canvas Canvas
{
return this.canvas;
get
{
return this.canvas;
}
set
{
this.canvas = value;
}
}
public int IsDate(DateTime date, int daySpan = 0)
@@ -142,13 +164,26 @@ namespace CampusAppWP8.Model.TimeTable
return retValue;
}
public int[] IntersectArray(AppointmentModel[] modelList)
{
List<int> retValue = new List<int>();
for (int i = 0; i < modelList.Length; i++)
{
if (this.Equals(modelList[i]) == false && this.Intersect(modelList[i]) == true)
{
retValue.Add(i);
}
}
return retValue.ToArray();
}
private void CalcRect()
{
this.CalcHeight();
this.canvas.Children.Clear();
this.rect.Width = 200;
this.rect.MinHeight = this.height;
this.rect.MaxHeight = 600;
this.rect.Width = this.width;
this.rect.Height = this.height;
this.rect.StrokeThickness = 1;
@@ -166,7 +201,7 @@ namespace CampusAppWP8.Model.TimeTable
TextBlock txtTitle = new TextBlock();
txtTitle.Text = title.Value;
txtTitle.FontSize = 12;
txtTitle.FontSize = DAY_HOUR_SPACING / 3;
txtTitle.FontWeight = FontWeights.Bold;
txtTitle.TextWrapping = TextWrapping.Wrap;
txtTitle.Width = this.rect.Width - 4.0;
@@ -233,6 +268,12 @@ namespace CampusAppWP8.Model.TimeTable
}
}
public void SetWidth(double maxWidth)
{
this.width = maxWidth - this.canvas.Margin.Left;
this.CalcRect();
}
private ICalObject GetVEventObj()
{
ICalObject retValue = this.icalObj.GetProperty(ICSTag.VEVENT) as ICalObject;
@@ -253,6 +294,11 @@ namespace CampusAppWP8.Model.TimeTable
}
}
private void OnCanvasSizeChanged(object sender, SizeChangedEventArgs e)
{
//this.CalcRect();
}
// ------------------------------------------------------
public string Title
{

View File

@@ -33,6 +33,7 @@ namespace CampusAppWP8.Pages.TimeTable
});
public static int AutoScrollToHour = 7;
public static int VisualScale = 0; //0 - small, 1 - medium, 2 - large
public TimeTable()
{

View File

@@ -18,9 +18,9 @@ namespace CampusAppWP8.Pages.TimeTable
public partial class TimeTableDay : PhoneApplicationPage
{
private readonly double DAY_TABLE_HEAD_WIDTH = 48;
private readonly double DAY_TABLE_HEAD_HALF = 8;
private readonly double DAY_TABLE_CELL_HEIGHT = AppointmentModel.DAY_HOUR_SPACING;
private readonly double DAY_TABLE_HEAD_WIDTH = 48;// * (1 + (TimeTable.VisualScale / 4));
private readonly double DAY_TABLE_HEAD_HALF = 8;// * (1 + (TimeTable.VisualScale / 4));
private readonly double DAY_TABLE_CELL_HEIGHT = 72;// * (1 + (TimeTable.VisualScale / 2));
private readonly double DAY_TABLE_HEAD_THICKNESS = 2;
private readonly double DAY_TABLE_INNER_THICKNESS = 1;
private readonly double DAY_TABLE_ZINDEX_SHIFT = 10;
@@ -36,12 +36,13 @@ namespace CampusAppWP8.Pages.TimeTable
private int lastSelectedIndex = 0;
private List<List<AppointmentModel>>[] appointmentStackList = new List<List<AppointmentModel>>[PIVOT_ITEM_PAGES];
public TimeTableDay()
{
this.InitializeComponent();
AppointmentModel.HourSpacing = DAY_TABLE_CELL_HEIGHT;
for (int i = 0; i < PIVOT_ITEM_PAGES; i++)
{
this.appointmentStackList[i] = new List<List<AppointmentModel>>();
@@ -151,15 +152,44 @@ namespace CampusAppWP8.Pages.TimeTable
private void EventOnMultiBubbleClick(object sender, System.Windows.Input.GestureEventArgs e)
{
double width_s_1 = (this.itemPages[this.lastSelectedIndex].Content as ScrollViewer).ActualWidth;
double width_s_2 = (this.itemPages[this.lastSelectedIndex].Content as ScrollViewer).Width;
double width_c_1 = ((this.itemPages[this.lastSelectedIndex].Content as ScrollViewer).Content as Canvas).ActualWidth;
double width_c_2 = ((this.itemPages[this.lastSelectedIndex].Content as ScrollViewer).Content as Canvas).Width;
int indexVal = (int)(sender as Canvas).Tag;
int stackIndex = indexVal >> 12;
int listIndex = indexVal & 0x00000FFF;
AppointmentModel tempModel = this.appointmentStackList[stackIndex][listIndex].First();
this.appointmentStackList[stackIndex][listIndex].Remove(tempModel);
this.appointmentStackList[stackIndex][listIndex].Add(tempModel);
for (int i = 0; i < this.appointmentStackList[stackIndex][listIndex].Count(); i++)
{
((this.itemPages[stackIndex].Content as ScrollViewer).Content as Canvas).Children.Remove(this.appointmentStackList[stackIndex][listIndex][i].Canvas);
if (i > 0)
{
this.DrawAppointmentModel(this.appointmentStackList[stackIndex][listIndex][i], stackIndex, 0.5, i, this.appointmentStackList[stackIndex][listIndex].Count() - 1 - i);
}
else
{
this.DrawAppointmentModel(this.appointmentStackList[stackIndex][listIndex][i], stackIndex, 1.0, i, this.appointmentStackList[stackIndex][listIndex].Count() - 1 - i);
}
}
((this.itemPages[stackIndex].Content as ScrollViewer).Content as Canvas).Children.Remove(sender as Canvas);
this.DrawMultiBubble(
((this.itemPages[stackIndex].Content as ScrollViewer).Content as Canvas),
stackIndex,
listIndex,
this.appointmentStackList[stackIndex][listIndex].Count(),
this.appointmentStackList[stackIndex][listIndex][0].GetPosRight,
this.appointmentStackList[stackIndex][listIndex][0].GetYOffset);
}
private void EventAutoScroll(object sender, RoutedEventArgs e)
{
(sender as ScrollViewer).ScrollToVerticalOffset(DAY_TABLE_CELL_HEIGHT * TimeTable.AutoScrollToHour);
if ((sender as ScrollViewer).VerticalOffset == 0.0)
{
(sender as ScrollViewer).ScrollToVerticalOffset(DAY_TABLE_CELL_HEIGHT * TimeTable.AutoScrollToHour);
}
}
private void OnClickToDay(object sender, EventArgs e)
@@ -185,13 +215,10 @@ namespace CampusAppWP8.Pages.TimeTable
{
List<AppointmentModel> tempList = new List<AppointmentModel>();
this.appointmentStackList[index].Clear();
this.itemPages[index].Header = string.Format("{0:ddd dd.MM.yy}", date);
if (this.itemPages[index].Content != null)
{
((this.itemPages[index].Content as ScrollViewer).Content as Canvas).Children.Clear();
}
this.SetupItemPageBackground(this.itemPages[index]);
for (int i = 0; i < TimeTable.AppointmentsModel.Appointments.Count(); i++)
@@ -206,21 +233,25 @@ namespace CampusAppWP8.Pages.TimeTable
// -------------------------------------------------------------
for (int i = 0; i < tempList.Count(); i++)
{
int intersectIndex = tempList[i].Intersect(tempList.ToArray());
int[] intersectIndex = tempList[i].IntersectArray(tempList.ToArray());
if (intersectIndex > -1)
if (intersectIndex.Count() == 0)
{
this.DrawAppointmentModel(tempList[i], index);
}
else if (intersectIndex.Count() == 1)
{
int addIndex = -1;
for(int k = 0; k < this.appointmentStackList[index].Count(); k++)
for (int k = 0; k < this.appointmentStackList[index].Count(); k++)
{
if (this.appointmentStackList[index][k].IndexOf(tempList[intersectIndex]) >= 0)
if (this.appointmentStackList[index][k].IndexOf(tempList[intersectIndex[0]]) >= 0)
{
addIndex = k;
}
}
if(addIndex >= 0)
if (addIndex >= 0)
{
this.appointmentStackList[index][addIndex].Add(tempList[i]);
}
@@ -233,7 +264,42 @@ namespace CampusAppWP8.Pages.TimeTable
}
else
{
this.DrawAppointmentModel(tempList[i], index);
List<List<AppointmentModel>> intersectLists = new List<List<AppointmentModel>>();
for (int k = 0; k < intersectIndex.Count(); k++)
{
for (int m = 0; m < this.appointmentStackList[index].Count(); m++)
{
if (this.appointmentStackList[index][m].IndexOf(tempList[intersectIndex[k]]) > -1)
{
if(intersectLists.IndexOf(this.appointmentStackList[index][m]) < 0)
{
intersectLists.Add(this.appointmentStackList[index][m]);
}
}
}
}
if(intersectLists.Count() == 0)
{
List<AppointmentModel> newList = new List<AppointmentModel>();
newList.Add(tempList[i]);
this.appointmentStackList[index].Add(newList);
}
else if(intersectLists.Count() == 1)
{
intersectLists[0].Add(tempList[i]);
}
else
{
for(int k = 1; k < intersectLists.Count(); k++)
{
intersectLists[0].AddRange(intersectLists[k].ToArray());
this.appointmentStackList[index].Remove(intersectLists[k]);
}
intersectLists[0].Add(tempList[i]);
}
}
}
@@ -243,46 +309,65 @@ namespace CampusAppWP8.Pages.TimeTable
{
if (k > 0)
{
this.DrawAppointmentModel(this.appointmentStackList[index][i][k], index, 0.5, k);
this.DrawAppointmentModel(this.appointmentStackList[index][i][k], index, 0.5, k, this.appointmentStackList[index][i].Count() - 1 - k);
}
else
{
this.DrawAppointmentModel(this.appointmentStackList[index][i][k], index);
this.DrawAppointmentModel(this.appointmentStackList[index][i][k], index, 1.0, k, this.appointmentStackList[index][i].Count() - 1 - k);
}
}
/*
this.DrawMultiBubble(
((this.itemPages[index].Content as ScrollViewer).Content as Canvas),
index,
index, i,
this.appointmentStackList[index][i].Count(),
this.appointmentStackList[index][i][0].GetPosRight,
this.appointmentStackList[index][i][0].GetYOffset);
*/
}
}
private void SetupItemPageBackground(PivotItem item)
{
ScrollViewer sv = new ScrollViewer();
Canvas ca = new Canvas();
ScrollViewer sv = null;
Canvas ca = null;
bool alreadyInit = false;
if ((item.Content != null) && (item.Content.GetType().Equals(typeof(ScrollViewer)) == true)
&& ((item.Content as ScrollViewer).Content != null) && ((item.Content as ScrollViewer).Content.GetType().Equals(typeof(Canvas)) == true))
{
sv = item.Content as ScrollViewer;
ca = sv.Content as Canvas;
sv.ScrollToVerticalOffset(0);
ca.Children.Clear();
alreadyInit = true;
}
else
{
sv = new ScrollViewer();
ca = new Canvas();
}
this.DrawDayViewBackground(ca);
sv.Content = ca;
sv.Loaded += new RoutedEventHandler(this.EventAutoScroll);
item.Content = sv;
if (alreadyInit == false)
{
sv.Content = ca;
sv.Loaded += new RoutedEventHandler(this.EventAutoScroll);
item.Content = sv;
}
}
private void DrawAppointmentModel(AppointmentModel model, int index, double opacity = 1.0, int zIndex = 0)
private void DrawAppointmentModel(AppointmentModel model, int index, double opacity = 1.0, int zIndex = 0, int modelCount = 0)
{
model.OnClick += new AppointmentModel.OnAppointmentClick(this.EventOnAppointmentClick);
Canvas temp = model.GetCanvas();
temp.Opacity = opacity;
temp.SetValue(Canvas.ZIndexProperty, DAY_TABLE_ZINDEX_MAX - zIndex);
temp.Margin = new Thickness(DAY_TABLE_HEAD_WIDTH + 2 + (zIndex * DAY_TABLE_ZINDEX_SHIFT), model.GetYOffset, 0, 0);
((this.itemPages[index].Content as ScrollViewer).Content as Canvas).Children.Add(temp);
model.Canvas.Opacity = opacity;
model.Canvas.SetValue(Canvas.ZIndexProperty, DAY_TABLE_ZINDEX_MAX - zIndex);
model.Canvas.Margin = new Thickness(DAY_TABLE_HEAD_WIDTH + 2 + (zIndex * DAY_TABLE_ZINDEX_SHIFT), model.GetYOffset, 0, 0);
model.SetWidth(this.itemPages[index].ActualWidth - (modelCount * DAY_TABLE_ZINDEX_SHIFT) - 6.0);
((this.itemPages[index].Content as ScrollViewer).Content as Canvas).Children.Add(model.Canvas);
}
private void DrawMultiBubble(Canvas dayView, int stackIndex, int number, double xOffset, double yOffset)
private void DrawMultiBubble(Canvas dayView, int stackIndex, int listIndex, int number, double xOffset, double yOffset)
{
Canvas can = new Canvas();
@@ -293,7 +378,7 @@ namespace CampusAppWP8.Pages.TimeTable
rect.RadiusY = DAY_TABLE_CELL_HEIGHT / 4;
rect.StrokeThickness = 1;
rect.Stroke = new SolidColorBrush(Colors.DarkGray);
rect.Fill = new SolidColorBrush(Colors.Blue);
rect.Fill = new SolidColorBrush(Colors.Black);
TextBlock block = new TextBlock();
block.Height = DAY_TABLE_CELL_HEIGHT / 2;
@@ -308,7 +393,7 @@ namespace CampusAppWP8.Pages.TimeTable
can.Children.Add(rect);
can.Children.Add(block);
can.Tap += new EventHandler<System.Windows.Input.GestureEventArgs>(this.EventOnMultiBubbleClick);
can.Tag = stackIndex;
can.Tag = (stackIndex << 12) | (listIndex & 0x00000FFF);
can.SetValue(Canvas.LeftProperty, xOffset - rect.Width);
can.SetValue(Canvas.TopProperty, yOffset);
can.SetValue(Canvas.ZIndexProperty, DAY_TABLE_ZINDEX_MAX + 1);

View File

@@ -29,28 +29,22 @@
<!--ContentPanel - zusätzliche Inhalte hier platzieren-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Border BorderBrush="{StaticResource PhoneBorderBrush}" BorderThickness="0,2,0,0" Grid.Row="0">
<StackPanel >
<TextBlock Text="{Binding Path=LocalizedResources.AutoScrollToHour, Source={StaticResource LocalizedStrings}}"/>
<!-- Listpicket of courses -->
<toolkit:ListPicker Name="AutoScroll" ExpansionMode="FullScreenOnly" FullModeHeader="{Binding Path=LocalizedResources.ListPickerHeaderCourse, Source={StaticResource LocalizedStrings}}" >
<!--
<toolkit:ListPicker.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Text}"/>
</StackPanel>
</DataTemplate>
</toolkit:ListPicker.ItemTemplate>
<toolkit:ListPicker.FullModeItemTemplate>
<DataTemplate>
<Border BorderBrush="{StaticResource PhoneAccentBrush}" BorderThickness="12,0,0,0" Margin="0,0,0,6">
<TextBlock Text="{Binding Text}" Style="{StaticResource PhoneTextGroupHeaderStyle}" TextWrapping="Wrap"/>
</Border>
</DataTemplate>
</toolkit:ListPicker.FullModeItemTemplate>
-->
</toolkit:ListPicker>
<toolkit:ListPicker Name="AutoScroll" ExpansionMode="FullScreenOnly" FullModeHeader="{Binding Path=LocalizedResources.ListPickerHeaderAutoScroll, Source={StaticResource LocalizedStrings}}" />
</StackPanel>
</Border>
<Border BorderBrush="{StaticResource PhoneBorderBrush}" BorderThickness="0,2,0,0" Grid.Row="1">
<StackPanel >
<TextBlock Text="{Binding Path=LocalizedResources.VisualScale, Source={StaticResource LocalizedStrings}}"/>
<toolkit:ListPicker Name="VisualScale" ExpansionMode="FullScreenOnly" FullModeHeader="{Binding Path=LocalizedResources.ListPickerHeaderVisualScale, Source={StaticResource LocalizedStrings}}" />
</StackPanel>
</Border>
</Grid>

View File

@@ -7,15 +7,19 @@ using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using CampusAppWP8.Resources;
namespace CampusAppWP8.Pages.TimeTable
{
public partial class TimeTableProperties : PhoneApplicationPage
{
public string[] VisualScaleText = new string[] { AppResources.Small, AppResources.Medium, AppResources.Large };
public TimeTableProperties()
{
this.InitializeComponent();
// AutoScroll
string[] tempAutoScroll = new string[25];
for (int i = 0; i < 24; i++)
@@ -25,6 +29,10 @@ namespace CampusAppWP8.Pages.TimeTable
this.AutoScroll.ItemsSource = tempAutoScroll;
this.AutoScroll.SelectedIndex = TimeTable.AutoScrollToHour;
// VisualSize
this.VisualScale.ItemsSource = VisualScaleText;
this.VisualScale.SelectedIndex = TimeTable.VisualScale;
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
@@ -32,6 +40,7 @@ namespace CampusAppWP8.Pages.TimeTable
base.OnNavigatedFrom(e);
TimeTable.AutoScrollToHour = this.AutoScroll.SelectedIndex;
TimeTable.VisualScale = this.VisualScale.SelectedIndex;
}
}
}

View File

@@ -348,6 +348,15 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die groß ähnelt.
/// </summary>
public static string Large {
get {
return ResourceManager.GetString("Large", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Studiengang ähnelt.
/// </summary>
@@ -483,6 +492,15 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Autoscrollauswahl ähnelt.
/// </summary>
public static string ListPickerHeaderAutoScroll {
get {
return ResourceManager.GetString("ListPickerHeaderAutoScroll", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Campusauswahl ähnelt.
/// </summary>
@@ -528,6 +546,15 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Anzeigegrößenauswahl ähnelt.
/// </summary>
public static string ListPickerHeaderVisualScale {
get {
return ResourceManager.GetString("ListPickerHeaderVisualScale", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Webmail ähnelt.
/// </summary>
@@ -537,6 +564,15 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die mittel ähnelt.
/// </summary>
public static string Medium {
get {
return ResourceManager.GetString("Medium", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die 84 ähnelt.
/// </summary>
@@ -996,6 +1032,15 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die klein ähnelt.
/// </summary>
public static string Small {
get {
return ResourceManager.GetString("Small", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die vorlesen ähnelt.
/// </summary>
@@ -1095,6 +1140,15 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Anzeige Größe ähnelt.
/// </summary>
public static string VisualScale {
get {
return ResourceManager.GetString("VisualScale", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Willkommen zur BTU-CampusApp WP8 ähnelt.
/// </summary>

View File

@@ -467,4 +467,22 @@
<data name="Properties" xml:space="preserve">
<value>Einstellungen</value>
</data>
<data name="Large" xml:space="preserve">
<value>groß</value>
</data>
<data name="ListPickerHeaderAutoScroll" xml:space="preserve">
<value>Autoscrollauswahl</value>
</data>
<data name="ListPickerHeaderVisualScale" xml:space="preserve">
<value>Anzeigegrößenauswahl</value>
</data>
<data name="Medium" xml:space="preserve">
<value>mittel</value>
</data>
<data name="Small" xml:space="preserve">
<value>klein</value>
</data>
<data name="VisualScale" xml:space="preserve">
<value>Anzeige Größe</value>
</data>
</root>