diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index 0fa040ea..ee755e20 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -130,8 +130,9 @@ TimeTableDay.xaml + - + diff --git a/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentModel.cs b/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentModel.cs index ec071ba8..8dc202a2 100644 --- a/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentModel.cs @@ -13,6 +13,8 @@ namespace CampusAppWP8.Model.TimeTable using System.Text.RegularExpressions; using System.Windows.Shapes; using System.Xml.Serialization; + using System.Windows.Controls; + using System.Windows.Media; using CampusAppWP8.Utility; /// @@ -24,17 +26,18 @@ namespace CampusAppWP8.Model.TimeTable /// The Visual object. private Rectangle rect = null; - private ICSObject icsObj; + private ICalObject icalObj = null; /// Initializes a new instance of the class. public AppointmentModel() { - this.icsObj = new ICSObject(); + this.rect = new Rectangle(); } public AppointmentModel(string icsData) : this() { - this.icsObj.ImportFromICS(icsData); + this.icalObj = ICSManager.ImportFromICS(icsData); + this.CalcRect(); } public Rectangle GetRectangle() @@ -42,9 +45,33 @@ namespace CampusAppWP8.Model.TimeTable return this.rect; } - - private void CreateRect() + private void CalcRect() { + this.rect.Width = 200; + this.rect.MinHeight = 16; + this.rect.MaxHeight = 600; + this.rect.Height = 200; + + this.rect.StrokeThickness = 4; + + SolidColorBrush borderBrush = new SolidColorBrush(); + borderBrush.Color = Colors.Red; + + this.rect.Stroke = borderBrush; + + Vis + + VisualBrush myBrush = new VisualBrush(); + StackPanel aPanel = new StackPanel(); + + + if (this.icalObj != null) + { + TextBlock tb = new TextBlock(); + tb.Text = this.icalObj.Header.Value; + + this.rect.Resources = tb; + } } } } diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableDay.xaml b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableDay.xaml index 7a7746ae..4f8d4fda 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableDay.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableDay.xaml @@ -14,24 +14,22 @@ shell:SystemTray.IsVisible="True"> - - - - + + - + --> \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableDay.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableDay.xaml.cs index f6e10131..140b18e8 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableDay.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableDay.xaml.cs @@ -8,7 +8,7 @@ using System.Windows.Navigation; using Microsoft.Phone.Controls; using Microsoft.Phone.Shell; using CampusAppWP8.Model.TimeTable; - +using CampusAppWP8.Utility; namespace CampusAppWP8.Pages.TimeTable { @@ -20,6 +20,23 @@ namespace CampusAppWP8.Pages.TimeTable { InitializeComponent(); this.testMod = new AppointmentModel("BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:ownCloud Calendar 0.6.3\r\nX-WR-CALNAME:Das is der Titel\r\nBEGIN:VEVENT\r\nCREATED;VALUE=DATE-TIME:20130827T113216Z\r\nUID:c9904ea73c\r\nLAST-MODIFIED;VALUE=DATE-TIME:20130827T113216Z\r\nDTSTAMP;VALUE=DATE-TIME:20130827T113216Z\r\nSUMMARY:Das is der Titel\r\nDTSTART;VALUE=DATE:20130828\r\nDTEND;VALUE=DATE:20130829\r\nCLASS:PUBLIC\r\nLOCATION:BTU Campus\r\nDESCRIPTION:For Outlook 2003, the behavior is peculiar. It can save the sa\r\n me calendar entry in both .ics and .vcs format, but it only read & displa\r\n y .vcs file correctly. It can read .ics file but it omits some fields and \r\n does not display it in calendar mode. My guess is that back then Microsoft\r\n wanted to provide .ics to be compatible with Mac's iCal but not quite com\r\n mitted to v2.0 yet.\r\nCATEGORIES:Projekte\r\nEND:VEVENT\r\nEND:VCALENDAR"); + + } + + protected override void OnNavigatedTo(NavigationEventArgs e) + { + base.OnNavigatedTo(e); + + //List elemList = Utilities.GetChild(this.thePivot.Items[0] as UIElement, "TestGrid"); + + //if (elemList.Count() > 0) + { + TextBlock tb = new TextBlock(); + tb.Text = "kk"; + + this.LayoutRoot.Children.Add(tb); + this.LayoutRoot.Children.Add(this.testMod.GetRectangle()); + } } } } \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSObject.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSObject.cs deleted file mode 100644 index 0ca56588..00000000 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSObject.cs +++ /dev/null @@ -1,243 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Company copyright tag. -// -// fiedlchr -// 27.08.2013 -//----------------------------------------------------------------------------- -namespace CampusAppWP8.Utility -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; - using System.Text.RegularExpressions; - using System.Threading.Tasks; - using System.Windows.Shapes; - using System.Xml.Serialization; - - /// Ics object. - public class ICSObject - { - private List readParentList = null; - - private struct VCalendar - { - public List props; - } - - private struct VEvent - { - public List props; - } - - private struct ContentLine - { - public string name; - public List paramList; - //public List valueList; - public string valueString; - } - - private Dictionary data = null; - - - /// Default constructor. - /// Fiedler, 27.08.2013. - public ICSObject() - { - this.readParentList = new List(); - this.data = new Dictionary(); - } - - public ICSObject(string icsData) : this() - { - this.ImportFromICS(icsData); - } - - public void ImportFromICS(string icsData) - { - string[] elems = Regex.Split(this.Unfold(icsData), "\r\n"); - - List parentList = new List(); - parentList.Add(ICSDict.Root); - - foreach (string e in elems) - { - ContentLine prop = this.ToContentLine(e); - ICSDict.ICSElemDesc tempElem = null; - - if ((tempElem = parentList.Last().GetValue(prop.name)) != null) - { - object propObj = tempElem.CreateObj(prop.valueString, prop.paramList.ToArray()); - - ICSDict.ICSValueDesc va = null; - - if (this.Is((propObj as ICSClasses.Interface).GetName(), ICSTag.BEGIN)) - { - parentList.Add(this.GetSubValue((propObj as ICSProperties.Begin).Value, tempElem)); - } - else if (this.Is((propObj as ICSClasses.Interface).GetName(), ICSTag.END)) - { - if (this.GetSubValue((propObj as ICSProperties.End).Value, tempElem) != null) - { - parentList.RemoveAt(parentList.Count - 1); - } - } - else - { - - } - } - else - { - if (prop.name.IndexOf("X-") == 0) - { - // TODO - } - else - { - throw new NotSupportedException("Tag (" + prop.name + ") was not found in (" + parentList.Last().Name + ")"); - } - } - - } - } - - public string ExportToICS() - { - string retValue = string.Empty; - - - return retValue; - } - - // TOOLS - - private DateTime ParseUTCDateTime(string datetime) - { - // see http://tools.ietf.org/html/rfc5545 3.3.5. - - datetime = datetime.Insert(4, "-"); - datetime = datetime.Insert(7, "-"); - datetime = datetime.Insert(13, ":"); - datetime = datetime.Insert(16, ":"); - - return DateTime.Parse(datetime); - } - - private DateTime ParseUTCDate(string date) - { - date = date.Insert(4, "-"); - date = date.Insert(7, "-"); - - return DateTime.Parse(date); - } - - private string Unfold(string icsData) - { - return icsData.Replace("\r\n ", "").Replace("\r\n\x09", ""); - } - - private string Fold(string data) - { - string retValue = string.Empty; - - string[] lines = Regex.Split(data, "\r\n"); - - for (int i = 0; i < lines.Count(); i++) - { - for (int k = 0; k < lines[i].Length; ) - { - if (k == 0) - { - retValue += lines[i].Substring(k, (((lines[i].Length - k - 75) >= 0) ? 75 : (lines[i].Length - k))); - k += 75; - } - else - { - retValue += " " + lines[i].Substring(k, (((lines[i].Length - k - 74) >= 0) ? 74 : (lines[i].Length - k))); - k += 74; - } - - retValue += "\r\n"; - } - } - - return retValue; - } - - private string[] SplitParam(string paramStr) - { - return paramStr.Split('='); - } - - private ICSDict.ICSValueDesc GetSubValue(string tag, ICSDict.ICSElemDesc elemDesc) - { - ICSDict.ICSValueDesc retValue = null; - - if ((retValue = elemDesc.GetValue(tag)) == null) - { - throw new NotSupportedException("Tag (" + tag + ") was not found in VALUE list of (" + elemDesc.Name + ")"); - } - - return retValue; - } - - private bool Is(ContentLine obj, string tag) - { - return obj.name.Equals(tag); - } - - private bool Is(string str1, string str2) - { - return str1.Equals(str2); - } - - /// Converts an icsLine to a content line. - /// Fiedler, 27.08.2013. - /// Thrown when the requested operation is unimplemented. - /// The ics line. - /// icsLine as a ContentLine. - private ContentLine ToContentLine(string icsLine) - { - ContentLine retValue; - - string[] valueSplit = icsLine.Split(new char[] {':'}, 2); - - if (valueSplit.Length != 2) - { - throw new NotSupportedException("ics string has no value"); - } - - // values - //retValue.valueList = new List(); - //retValue.valueList.AddRange(valueSplit[1].Split(',')); - retValue.valueString = valueSplit[1]; - - // params - int paramNum = StringManager.CountChar(valueSplit[0], ';'); - - if (paramNum > 0) - { - retValue.paramList = new List(); - - string[] paramSplit = valueSplit[0].Split(';'); - - retValue.name = paramSplit[0].ToUpper(); - - for (int i = 1; i < paramSplit.Length; i++) - { - retValue.paramList.Add(paramSplit[i].ToUpper()); - } - } - else - { - retValue.paramList = null; - retValue.name = valueSplit[0].ToUpper(); - } - - return retValue; - } - } -} diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/AccessClass.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/AccessClass.cs index 7927e2cd..578392b8 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/AccessClass.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/AccessClass.cs @@ -72,9 +72,12 @@ namespace CampusAppWP8.Utility.ICSProperties /// List of parameter strings. public override void Set(string valueStr, string[] paramStrList) { - if (paramStrList.Count() > 0) + if (paramStrList != null) { - throw new NotSupportedException("in (" + Name + ") is no param supported"); + if (paramStrList.Count() > 0) + { + throw new NotSupportedException("in (" + Name + ") is no param supported"); + } } if (this.ValueList.IndexOf(valueStr) >= 0) diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Categories.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Categories.cs index f0a8f6e0..0ecd8e16 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Categories.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Categories.cs @@ -77,27 +77,30 @@ namespace CampusAppWP8.Utility.ICSProperties /// List of parameter strings. public override void Set(string valueStr, string[] paramStrList) { - if (paramStrList.Count() > 1) + if (paramStrList != null) { - throw new NotSupportedException("in (" + Name + ") is only the (" + ICSParam.LANGUAGE + ") param supported"); - } - else if (paramStrList.Count() == 1) - { - string[] p = paramStrList[0].Split('='); - - if (p.Length != 2) + if (paramStrList.Count() > 1) { - throw new NotSupportedException("the number of '=' in the parameter (" + paramStrList[0] + ") is less or greater then 1"); + throw new NotSupportedException("in (" + Name + ") is only the (" + ICSParam.LANGUAGE + ") param supported"); } - - switch (p[0]) + else if (paramStrList.Count() == 1) { - case ICSParam.LANGUAGE: - this.languageType = p[1]; - break; + string[] p = paramStrList[0].Split('='); - default: - throw new NotSupportedException("Parameter with tag (" + p[0] + ") is not supported"); + if (p.Length != 2) + { + throw new NotSupportedException("the number of '=' in the parameter (" + paramStrList[0] + ") is less or greater then 1"); + } + + switch (p[0]) + { + case ICSParam.LANGUAGE: + this.languageType = p[1]; + break; + + default: + throw new NotSupportedException("Parameter with tag (" + p[0] + ") is not supported"); + } } } diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Comment.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Comment.cs index 25ad5713..d3d3b707 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Comment.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Comment.cs @@ -95,27 +95,30 @@ namespace CampusAppWP8.Utility.ICSProperties /// List of parameter strings. public override void Set(string valueStr, string[] paramStrList) { - foreach (string param in paramStrList) + if (paramStrList != null) { - string[] p = param.Split('='); - - if (p.Count() != 2) + foreach (string param in paramStrList) { - throw new NotSupportedException("the number of '=' in the parameter (" + param + ") is less or greater then 1"); - } + string[] p = param.Split('='); - switch (p[0]) - { - case ICSParam.LANGUAGE: - this.languageType = p[1]; - break; - case ICSParam.ALT_REPRESENTATION: - // TODO: test, remove DQUOTES " - this.altrep = p[1]; - break; + if (p.Count() != 2) + { + throw new NotSupportedException("the number of '=' in the parameter (" + param + ") is less or greater then 1"); + } - default: - throw new NotSupportedException("Parameter with tag (" + p[0] + ") is not supported"); + switch (p[0]) + { + case ICSParam.LANGUAGE: + this.languageType = p[1]; + break; + case ICSParam.ALT_REPRESENTATION: + // TODO: test, remove DQUOTES " + this.altrep = p[1]; + break; + + default: + throw new NotSupportedException("Parameter with tag (" + p[0] + ") is not supported"); + } } } diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTCreated.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTCreated.cs index 00a5ec96..c86de83d 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTCreated.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTCreated.cs @@ -22,7 +22,15 @@ namespace CampusAppWP8.Utility.ICSProperties /// Options for controlling the operation. public static readonly List> PParams - = new List>(); + = new List>( + new Tuple[] + { + new Tuple( + ICSParam.VALUE_TYPE, new string[] { ICSParamValue.DATE_TIME }) + }); + + /// List of parameters. + private List> paramList = null; /// Date/Time of the value. private DateTime value = DateTime.MinValue; @@ -31,6 +39,7 @@ namespace CampusAppWP8.Utility.ICSProperties /// Fiedler, 05.09.2013. public DTCreated() { + this.paramList = new List>(); } /// Gets or sets the Date/Time of the value. @@ -48,6 +57,29 @@ namespace CampusAppWP8.Utility.ICSProperties } } + /// Gets or sets the parameter. + /// The parameter. + public List> Param + { + get + { + return this.paramList; + } + + set + { + for (int i = 0; i < value.Count(); i++) + { + if (!ICSClasses.CheckParamAndParamValue(value[i].Item1, value[i].Item2, PParams.ToArray())) + { + throw new NotSupportedException("param (" + value[i] + ") is not supported"); + } + } + + this.paramList = value; + } + } + /// Sets the property/class values. Used for import from a ICS file. /// Fiedler, 05.09.2013. /// Thrown when the requested operation is not supported. @@ -55,9 +87,26 @@ namespace CampusAppWP8.Utility.ICSProperties /// (Optional) List of parameter strings. public override void Set(string valueStr, string[] paramStrList = null) { - if (paramStrList != null && paramStrList.Count() > 0) + if (paramStrList != null) { - throw new NotSupportedException("there are no params supported"); + for (int i = 0; i < paramStrList.Count(); i++) + { + string[] p = paramStrList[i].Split('='); + + if (p.Count() != 2) + { + throw new FormatException("unsupported param format (" + paramStrList + ") in (" + Name + ")"); + } + + if (ICSClasses.CheckParamAndParamValue(p[0], p[1], PParams.ToArray())) + { + this.paramList.Add(new Tuple(p[0], p[1])); + } + else + { + throw new NotSupportedException("unsupported param (" + paramStrList[i] + ") in (" + Name + ")"); + } + } } this.value = ICSClasses.UTCStringToDateTime(valueStr); diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICalObject.cs b/CampusAppWP8/CampusAppWP8/Utility/ICalObject.cs new file mode 100644 index 00000000..a8f52b21 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICalObject.cs @@ -0,0 +1,97 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 09.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility +{ + using System.Collections.Generic; + using System.Linq; + + /// Cal object. + /// Fiedler, 09.09.2013. + public class ICalObject + { + /// The header. + private ICSProperties.Begin header = null; + + /// The properties. + private List props = null; + + /// Initializes a new instance of the class. + /// Fiedler, 09.09.2013. + public ICalObject() + { + this.props = new List(); + } + + /// Gets or sets the header. + /// The header. + public ICSProperties.Begin Header + { + get + { + return this.header; + } + + set + { + this.header = value; + } + } + + /// Gets or sets a list of properties. + /// A List of properties. + public List PropertieList + { + get + { + return this.props; + } + + set + { + this.props = value; + } + } + + /// Gets header type. + /// Fiedler, 09.09.2013. + /// The header type. + public string GetHeaderType() + { + if (this.header != null) + { + return this.header.Value; + } + else + { + return string.Empty; + } + } + + /// Gets a property. + /// Fiedler, 09.09.2013. + /// Name of the property. + /// The property. + public object GetProperty(string propName) + { + object retValue = null; + + for (int i = 0; i < this.props.Count(); i++) + { + if (!this.props[i].GetType().Equals(this.GetType())) + { + if ((this.props[i] as ICSClasses.Interface).GetName().Equals(propName)) + { + retValue = this.props[i]; + } + } + } + + return retValue; + } + } +} \ No newline at end of file