From e95d0a0ef37ca5490a44de2c556b0714c3014395 Mon Sep 17 00:00:00 2001 From: stubbfel Date: Mon, 2 Sep 2013 11:13:06 +0200 Subject: [PATCH 1/5] add pngsadd IsUniNetworkAvailable() --- .../IconCreator/scripts/IconCreator.pyc | Bin 1502 -> 2248 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/CampusAppWP8/IconCreator/scripts/IconCreator.pyc b/CampusAppWP8/IconCreator/scripts/IconCreator.pyc index 4889a6ff23ff1a64e8bcbffcfe4ab07a08fbaf6b..4517557c2549225eef96e0f7b19078dc6fcbe1bd 100644 GIT binary patch delta 732 zcmcb|eL_&0`7tL0jWCkc;Vqjo!U|?VkOiqFC2R}~3`MEA`DLk_|1$k#R2O3uXA)$RVB}{KV-#Z) zVA5seWlH8?U|5-yNzGb5P60umIhzfi<_Z_m!XCa?9&n+hAdu&6b6P8eufeThAaV)<5E~bVUfblkix;x%*fQt2vST(I9pZ3lwZYAj5*VKwKUW!3QGvK?Ep3 zg9Je=ArJx9D*|GPf(S7XAr2xWK!hZSkYWg7V9)^TlLql+K!hxakOL9&AVL8|fE}m^ zVkvhc#m6}`7(9FodSZK{qp+51hgaA833L8TW8$&Y_17l$gL-=M<#`}yyYzzzxMX9;@WvM01 zAmdU?HnTDRWE2x%5@VELl3?U#5@Qr&6kyV2 Date: Mon, 2 Sep 2013 12:38:19 +0200 Subject: [PATCH 2/5] add to startpage --- .../Assets/Icons/DarkTheme/exams_159.png | Bin 0 -> 3158 bytes .../Assets/Icons/LightTheme/exams_159.png | Bin 0 -> 2590 bytes CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj | 9 ++++ .../CampusAppWP8/Pages/Exams/Exams.xaml | 35 ++++++++++++ .../CampusAppWP8/Pages/Exams/Exams.xaml.cs | 20 +++++++ .../CampusAppWP8/Pages/StartPage.xaml | 18 +++++++ .../Resources/AppResources.Designer.cs | 9 ++++ .../CampusAppWP8/Resources/AppResources.resx | 3 ++ .../Resources/Constants.Designer.cs | 9 ++++ .../CampusAppWP8/Resources/Constants.resx | 3 ++ CampusAppWP8/CampusAppWP8/Resources/Icons.cs | 11 ++++ .../CampusAppWP8/Resources/Icons.resx | 3 ++ work/images/scripts/IconCreator.py | 50 ++++++++++++++++++ work/images/scripts/IconCreator.pyc | Bin 0 -> 2248 bytes work/images/scripts/createspng.py | 44 +++++++++++++++ 15 files changed, 214 insertions(+) create mode 100644 CampusAppWP8/CampusAppWP8/Assets/Icons/DarkTheme/exams_159.png create mode 100644 CampusAppWP8/CampusAppWP8/Assets/Icons/LightTheme/exams_159.png create mode 100644 CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml create mode 100644 CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml.cs create mode 100644 work/images/scripts/IconCreator.py create mode 100644 work/images/scripts/IconCreator.pyc create mode 100644 work/images/scripts/createspng.py diff --git a/CampusAppWP8/CampusAppWP8/Assets/Icons/DarkTheme/exams_159.png b/CampusAppWP8/CampusAppWP8/Assets/Icons/DarkTheme/exams_159.png new file mode 100644 index 0000000000000000000000000000000000000000..6ada1ad4eca4101fc233fdb5c53ce7b01a5ef3a4 GIT binary patch literal 3158 zcmeAS@N?(olHy`uVBq!ia0y~yV3-fW9Bd2>49}&xA22X5uqAoByD$SS5Z!gDG;o4c# zmV~TcDYVGL!~2PV);C?wMO$4~HLbdQEifq4d!_0$k4F>z|Nl69xU@L^S^4|o`PJ|5 z{I31`^5@z7eLv>Rv^L()I;Z%Y<#Q5=xyNV4IxP0M#c*Tk&C)N8c@NBtU+0x6UX5CK zlhx#c-+`}Z^%nKtQGcmmT)p^aYsljG&D;g08`(chSmHY?*2C1M=54ZeLf?|}=DR0E z$nE>KNv~l4lE1TJJ$U%ze@C+J2)uOite#4L`+D22?0S<*7A~3gxBkwi)}6Z~81E=# z25jbDdF1f*e|!vS-cieMwodu{p|nkw)BjMk$?ge3a{JC1ic~~g$~&vKq`iIp<~59G zrhJ*3Ce9?c&u@#6f$OCkY2uF_X50T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ffH3*oNpXDIq`ijgE#Zr(9G92KghQ0zMuIt;cv^I zUz+y96?@e?{_mRG{8fFLtVZkki|x98cTO?xR%pK--*I;OqrG8UX0!cSd12L#uPHwc zoYN?u@V9|C>2&?JRrWu2MR(})|2`-7uTLw-R@!cZ<(qYCza4kCAA5bytw!;}KZTc9 z>)fn+zNNQ@|L`*6n_X-By76}%_xi6fe^yIG-j2KM^fvTnm0gXpo%grq?`=G9{SVlA z?KP8M{8MUMvToMGXIi;j_ch{GZXdku^+&1x$@RAaA66z*|2<%DbS-+T??dTSn*!aN zd<(YMFx=>$?UDYe?2+>1*F~JZ4^Jns-Td`mPHC@30u6v`8to!oW!-ffqE{l9y~?E{Rh>v@k)&duul z-1dETkG=7q6W^K>bT4nbt$LcT=g@V>$X#*ojvr%p(_6@!xOv}s&TEC4ZC0-~Y1Z^z zK2hc{U0B|8k5S;_^)4=PV@s5VwfFXg+h@L{jnxBVI)<~TQOzFooVxuW>T0kM

4)-i zG^-|V>pia5>)Q0)Iq7eeQlj`IzPq(Il4_N9TDLu0?U1KrH*>Lvciy9w2Y2(;&#aob zZEr7g^LDP^b{auDJZ&nopQK*d&%gO~>E)S;@@CZscx`sF?DaVA^Lf4!9&q>d|DI`O WFaGu`{A6HYVDNPHb6Mw<&;$UWIW1HG literal 0 HcmV?d00001 diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index b2d262b0..1095c1f1 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -119,6 +119,9 @@ + + Exams.xaml + @@ -295,6 +298,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -396,6 +403,7 @@ + @@ -409,6 +417,7 @@ + diff --git a/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml b/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml new file mode 100644 index 00000000..04231637 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml.cs new file mode 100644 index 00000000..e66731e7 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Navigation; +using Microsoft.Phone.Controls; +using Microsoft.Phone.Shell; + +namespace CampusAppWP8.Pages.Exams +{ + public partial class Exams : PhoneApplicationPage + { + public Exams() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml index df83d9b0..99e5cc03 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml @@ -158,6 +158,24 @@ + + + + + + + + + + + + + + + + + + diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs index 9d229538..06891e9a 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs @@ -222,6 +222,15 @@ namespace CampusAppWP8.Resources { } } + ///

+ /// Sucht eine lokalisierte Zeichenfolge, die Prüfungs- ordnungen ähnelt. + /// + public static string ExaminationApp_Title { + get { + return ResourceManager.GetString("ExaminationApp_Title", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die Fakultät ähnelt. /// diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx index 0f2c1050..2a71e34a 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx @@ -419,4 +419,7 @@ Nur mit Wlan laden + + Prüfungs- ordnungen + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs index 0de55340..c4d59f0c 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs @@ -609,6 +609,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die /Pages/Exams/Exams.xaml ähnelt. + /// + public static string PathExams_ExamsPage { + get { + return ResourceManager.GetString("PathExams_ExamsPage", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die /Pages/Lecture/LecturePage.xaml ähnelt. /// diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx index ef601ff0..999143ae 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx @@ -435,4 +435,7 @@ SearchAlias + + /Pages/Exams/Exams.xaml + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Resources/Icons.cs b/CampusAppWP8/CampusAppWP8/Resources/Icons.cs index 4d91d96d..d381d0e4 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Icons.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/Icons.cs @@ -99,6 +99,17 @@ namespace CampusAppWP8.Resources } } + /// + /// Gets the uri string of the Exams icon. + /// + public static string Exams + { + get + { + return Themerize("exams_159.png"); + } + } + /// /// Gets the uri string of the Favorite icon. /// diff --git a/CampusAppWP8/CampusAppWP8/Resources/Icons.resx b/CampusAppWP8/CampusAppWP8/Resources/Icons.resx index 7cd96949..4a349994 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Icons.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/Icons.resx @@ -138,6 +138,9 @@ departments_159.png + + exams_159.png + favorite_159.png diff --git a/work/images/scripts/IconCreator.py b/work/images/scripts/IconCreator.py new file mode 100644 index 00000000..474cdffa --- /dev/null +++ b/work/images/scripts/IconCreator.py @@ -0,0 +1,50 @@ +import cairo +import rsvg +import xml.etree.ElementTree as ET + +def convertSVGToPNG(src, dst, dstWidth, dstHeight, srcWidth, srcHeight, style,layerID): + ET.register_namespace("","http://www.w3.org/2000/svg") + + tree = ET.parse(src) + root = tree.getroot() + + for layer in root.findall('./{http://www.w3.org/2000/svg}g'): + name = layer.get('{http://www.inkscape.org/namespaces/inkscape}label') + if name in layerID : + for path in layer.findall('./{http://www.w3.org/2000/svg}path'): + path.set("style",style) + else : + root.remove(layer) + + img = cairo.ImageSurface(cairo.FORMAT_ARGB32, dstWidth, dstHeight) + ctx = cairo.Context(img) + + width_ratio = float(dstWidth) / float(srcWidth) + height_ratio = float(dstHeight) / float(srcHeight) + ctx.scale(width_ratio, height_ratio) + + handler= rsvg.Handle(None,str(ET.tostring(root, encoding='utf8', method='xml'))) + handler.render_cairo(ctx) + + img.write_to_png(dst) + +def convertSVGToPNG2(src, dst, dstWidth, dstHeight, srcWidth, srcHeight, style,layerID): + ET.register_namespace("","http://www.w3.org/2000/svg") + + tree = ET.parse(src) + root = tree.getroot() + + for path in root.findall('./{http://www.w3.org/2000/svg}path'): + path.set("style",style) + + img = cairo.ImageSurface(cairo.FORMAT_ARGB32, dstWidth, dstHeight) + ctx = cairo.Context(img) + + width_ratio = float(dstWidth) / float(srcWidth) + height_ratio = float(dstHeight) / float(srcHeight) + ctx.scale(width_ratio, height_ratio) + + handler= rsvg.Handle(None,str(ET.tostring(root, encoding='utf8', method='xml'))) + handler.render_cairo(ctx) + + img.write_to_png(dst) \ No newline at end of file diff --git a/work/images/scripts/IconCreator.pyc b/work/images/scripts/IconCreator.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4517557c2549225eef96e0f7b19078dc6fcbe1bd GIT binary patch literal 2248 zcmZSn%**vUSS2W#0ScHH7#JKF7#NB{L<$2#3L`@f149%81C-6k5XA^%GcjZ_Gi0$a zM6oiYFfp_+FhsF2q%eaS>>!Q78Y~P944MD`|Nrlo%)!9GAjH7Hz{$YC;0&_BgOP!u zgn=Q85u`MQiJ_T^ff2-KVyIzYXl7)n!wIr2g&8F45*y7> z%f(Q`#gN6ykir5Is^w;=;by2|XUJw_DC%UWFbB)BFr=`8WL;v#7;1SKYIqp3*cejS z7;4zSHWubEgcn+ajb;a_Z)Rj*EVO0_FX3Rw;$#4kTnsf#3^mLQ&CCq7ykHS-h8kXw zk+pmbB|IS6W=1dr>D=NlZ%3DOMtAbU|WCMhPn@_Dd>r zQcFN-A~i2LKP59Sy#$n2N=wo#O4t|}7;;lfGV)VOm>C!tDspo)L>U+uNB9vGmA@7i{jyq0h?NoSX7)^!p^|Jke*snl%HP$W~XK5r6lI$fDKDeEdkTTsU={0 zic)j)%TmFblM^$G@=JIa7#KWr6Vp?JON-JHlT%B085kJc{DXWQL*gBS+?|Y#z-Bt< z=ar;Zlz=s+<>V(qSjEYSIjLZe6cv}HgDvn#%u9ia`Q_)OLM$&S0(-qAzqq6bpt6LYfq@}8Kd&scs3bVdJtRNC&mH6=aQb9m6ky_KxF3AczafB|%`lA|NiP)Cdv-vBW`y1c;CX5uhSc1FTIN#FYUNvLHeZM1V@j zAO#Q$lvRQhK`fAmf|NllH4vc=B0vc_NE5`;0ukB_3=AM42tm^X4stqL0yhG=8XPT% z6fT06vNgcr2o5+<_>_Rcry@5;FBO#g^;~mOb5rw5LO>+}C=$S;;Ovbg1BnzJkbiYi i{0sIuO+5{AyiIO?N@-529VlXoK>|FCJd8q2oKgUl#^%!i literal 0 HcmV?d00001 diff --git a/work/images/scripts/createspng.py b/work/images/scripts/createspng.py new file mode 100644 index 00000000..756f8668 --- /dev/null +++ b/work/images/scripts/createspng.py @@ -0,0 +1,44 @@ +import IconCreator +import os + +os.chdir("srcImages/functions") +for files in os.listdir("."): + if files.endswith(".svg"): + fileName, fileExtension = os.path.splitext(files) + IconCreator.convertSVGToPNG(files, "../../dstImages/wp8/159x159/LightTheme/functions/"+fileName+".png",159,159,256,256,"fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none" , "Icon") + IconCreator.convertSVGToPNG(files, "../../dstImages/wp8/159x159/DarkTheme/functions/"+fileName+".png",159,159,256,256,"fill:#FFFFFF;fill-opacity:1;fill-rule:evenodd;stroke:none", "Icon") +os.chdir("../../") + +os.chdir("srcImages/emotions") +for files in os.listdir("."): + if files.endswith(".svg"): + fileName, fileExtension = os.path.splitext(files) + IconCreator.convertSVGToPNG(files, "../../dstImages/wp8/159x159/LightTheme/emotions/"+fileName+".png",159,159,256,256,"fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none" , "Emotion Speechbubble") + IconCreator.convertSVGToPNG(files, "../../dstImages/wp8/159x159/DarkTheme/emotions/"+fileName+".png",159,159,256,256,"fill:#FFFFFF;fill-opacity:1;fill-rule:evenodd;stroke:none", "Emotion Speechbubble") +os.chdir("../../") + +os.chdir("srcImages/listicons") +for files in os.listdir("."): + if files.endswith(".svg"): + fileName, fileExtension = os.path.splitext(files) + IconCreator.convertSVGToPNG2(files, "../../dstImages/wp8/159x159/LightTheme/listicons/"+fileName+".png",159,159,256,256,"fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none" , "Icon") + IconCreator.convertSVGToPNG2(files, "../../dstImages/wp8/159x159/DarkTheme/listicons/"+fileName+".png",159,159,256,256,"fill:#FFFFFF;fill-opacity:1;fill-rule:evenodd;stroke:none", "Icon") +os.chdir("../../") + +os.chdir("srcImages/optionbuttons") +for files in os.listdir("."): + if files.endswith(".svg"): + fileName, fileExtension = os.path.splitext(files) + IconCreator.convertSVGToPNG2(files, "../../dstImages/wp8/159x159/LightTheme/optionbuttons/"+fileName+".png",159,159,256,256,"fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none" , "Icon") + IconCreator.convertSVGToPNG2(files, "../../dstImages/wp8/159x159/DarkTheme/optionbuttons/"+fileName+".png",159,159,256,256,"fill:#FFFFFF;fill-opacity:1;fill-rule:evenodd;stroke:none", "Icon") +os.chdir("../../") + +os.chdir("srcImages/others") +for files in os.listdir("."): + if files.endswith(".svg"): + fileName, fileExtension = os.path.splitext(files) + IconCreator.convertSVGToPNG2(files, "../../dstImages/wp8/159x159/LightTheme/others/"+fileName+".png",159,159,256,256,"fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none" , "Icon") + IconCreator.convertSVGToPNG2(files, "../../dstImages/wp8/159x159/DarkTheme/others/"+fileName+".png",159,159,256,256,"fill:#FFFFFF;fill-opacity:1;fill-rule:evenodd;stroke:none", "Icon") +os.chdir("../../") + + From 557f8617746445c3d2dedf2b95e1eb621bf5f68e Mon Sep 17 00:00:00 2001 From: stubbfel Date: Mon, 2 Sep 2013 16:44:33 +0200 Subject: [PATCH 3/5] add exams model and page --- CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj | 3 + .../CampusAppWP8/Feed/Exams/ExamFeed.cs | 59 +++++++ .../CampusAppWP8/Model/Exams/ExamListModel.cs | 23 +++ .../CampusAppWP8/Model/Exams/ExamModel.cs | 67 ++++++++ .../CampusAppWP8/Pages/Exams/Exams.xaml | 85 ++++++++-- .../CampusAppWP8/Pages/Exams/Exams.xaml.cs | 148 ++++++++++++++++-- .../Resources/AppResources.Designer.cs | 9 ++ .../CampusAppWP8/Resources/AppResources.resx | 3 + .../Resources/Constants.Designer.cs | 27 ++++ .../CampusAppWP8/Resources/Constants.resx | 9 ++ .../CampusAppWP8/Utility/StringManager.cs | 5 +- 11 files changed, 410 insertions(+), 28 deletions(-) create mode 100644 CampusAppWP8/CampusAppWP8/Feed/Exams/ExamFeed.cs create mode 100644 CampusAppWP8/CampusAppWP8/Model/Exams/ExamListModel.cs create mode 100644 CampusAppWP8/CampusAppWP8/Model/Exams/ExamModel.cs diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index 1095c1f1..78353d3f 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -100,6 +100,7 @@ + @@ -108,6 +109,8 @@ + + diff --git a/CampusAppWP8/CampusAppWP8/Feed/Exams/ExamFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/Exams/ExamFeed.cs new file mode 100644 index 00000000..c2dc6ccb --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Feed/Exams/ExamFeed.cs @@ -0,0 +1,59 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 02.09.2013 +//---------------------------------------------------------------------- +namespace CampusAppWP8.Feed.Exams +{ + using System.IO; + using CampusAppWP8.Model; + using CampusAppWP8.Model.Exams; + using CampusAppWP8.Resources; + + /// Exam feed. + /// Stubbfel, 02.09.2013. + public class ExamFeed : XmlModel + { + /// Initializes a new instance of the ExamFeed class. + /// Stubbfel, 02.09.2013. + public ExamFeed() + : base(ModelType.FileAndFeed, Constants.FileExamApp_ExamFeed, Constants.UrlExamApp_ExamFeed) + { + this.IsFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDate); + this.IsModelUpToDateOnLoad += new IsModelUpToDate(this.CheckIsModelUpToDate); + this.IsFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDate); + this.ValidRootName = Constants.ExamXmlValidRootName; + } + + /// Check is model up to date. + /// Stubbfel, 02.09.2013. + /// The model. + /// true if it succeeds, false if it fails. + private bool CheckIsModelUpToDate(ExamListModel model) + { + if (model == null) + { + return false; + } + + return true; + } + + /// Check is file up to date. + /// Stubbfel, 02.09.2013. + /// The model. + /// Information describing the file. + /// true if it succeeds, false if it fails. + private bool CheckIsFileUpToDate(ExamListModel model, FileInfo fileInfo) + { + if (fileInfo == null || !fileInfo.Exists || fileInfo.Length < 1) + { + return false; + } + + return true; + } + } +} diff --git a/CampusAppWP8/CampusAppWP8/Model/Exams/ExamListModel.cs b/CampusAppWP8/CampusAppWP8/Model/Exams/ExamListModel.cs new file mode 100644 index 00000000..12cbb196 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Model/Exams/ExamListModel.cs @@ -0,0 +1,23 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 02.09.2013 +//---------------------------------------------------------------------- +namespace CampusAppWP8.Model.Exams +{ + using System.Collections.ObjectModel; + using System.Xml.Serialization; + + /// Exam list model. + /// Stubbfel, 02.09.2013. + [XmlRoot("links")] + public class ExamListModel + { + /// Gets or sets the exams. + /// The exams. + [XmlElement("link")] + public ObservableCollection Exams { get; set; } + } +} diff --git a/CampusAppWP8/CampusAppWP8/Model/Exams/ExamModel.cs b/CampusAppWP8/CampusAppWP8/Model/Exams/ExamModel.cs new file mode 100644 index 00000000..5b68c879 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Model/Exams/ExamModel.cs @@ -0,0 +1,67 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 02.09.2013 +//---------------------------------------------------------------------- +namespace CampusAppWP8.Model.Exams +{ + using CampusAppWP8.Utility; + using System.Xml.Serialization; + + /// Exam model. + /// Stubbfel, 02.09.2013. + public class ExamModel + { + /// Gets or sets the course number. + /// The course number. + [XmlAttribute("stg")] + public string CourseNumber { get; set; } + + /// Gets or sets the course text. + /// The course text. + [XmlAttribute("stgtext")] + public string CourseText { get; set; } + + /// Gets or sets the degree number. + /// The degree number. + [XmlAttribute("abschl")] + public string DegreeNumber { get; set; } + + /// Gets or sets the version. + /// The version. + [XmlAttribute("pversion")] + public string Version { get; set; } + + /// Gets or sets the type. + /// The type. + [XmlAttribute("typ")] + public string Type { get; set; } + + /// Gets or sets the title. + /// The title. + [XmlAttribute("dtxt")] + public string Title { get; set; } + + /// Gets or sets the date. + /// The date. + [XmlAttribute("datum")] + public string Date { get; set; } + + /// Gets or sets the link. + /// The link. + [XmlAttribute("link")] + public string Link { get; set; } + + /// Gets the caption. + /// The caption. + public string Caption + { + get + { + return StringManager.StripHTML(this.CourseText + " (" + this.Type + "/" + this.Version + ")"); + } + } + } +} diff --git a/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml b/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml index 04231637..d8774e03 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml @@ -6,6 +6,7 @@ xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:lui="clr-namespace:CampusAppWP8.Utility.Lui.Button" FontFamily="{StaticResource PhoneFontFamilyNormal}" FontSize="{StaticResource PhoneFontSizeNormal}" Foreground="{StaticResource PhoneForegroundBrush}" @@ -15,21 +16,75 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml.cs index e66731e7..1fec754a 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml.cs @@ -1,20 +1,146 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Navigation; -using Microsoft.Phone.Controls; -using Microsoft.Phone.Shell; - +// +// Company copyright tag. +// +// stubbfel +// 02.09.2013 +//---------------------------------------------------------------------- namespace CampusAppWP8.Pages.Exams { + using System.Linq; + using System.Windows; + using System.Windows.Navigation; + using CampusAppWP8.Feed.Exams; + using CampusAppWP8.Resources; + using CampusAppWP8.Utility; + using CampusAppWP8.Utility.Lui.MessageBoxes; + using Microsoft.Phone.Controls; + + /// Exams. + /// Stubbfel, 02.09.2013. public partial class Exams : PhoneApplicationPage { + /// The feed. + private ExamFeed feed; + + /// Initializes a new instance of the Exams class. + /// Stubbfel, 02.09.2013. public Exams() { - InitializeComponent(); + this.InitializeComponent(); + this.InitializeFeed(); + } + + /// Wird aufgerufen, wenn eine Seite die aktive Seite in einem Frame wird. + /// Stubbfel, 02.09.2013. + /// Ein Objekt, das die Ereignisdaten enthält. + protected override void OnNavigatedTo(NavigationEventArgs e) + { + base.OnNavigatedTo(e); + if (this.feed == null) + { + this.InitializeFeed(); + } + + this.ProgressBar.Visibility = System.Windows.Visibility.Visible; + this.feed.LoadData(Utilities.getLoadModus()); + } + + /// + /// Wird aufgerufen, wenn eine Seite nicht mehr die aktive Seite in einem Frame ist. + /// + /// Stubbfel, 02.09.2013. + /// Ein Objekt, das die Ereignisdaten enthält. + protected override void OnNavigatedFrom(NavigationEventArgs e) + { + if (NavigationMode.Back == e.NavigationMode) + { + this.feed.SaveData(); + } + } + + /// Method initialize the Feed. + /// Stubbfel, 02.09.2013. + private void InitializeFeed() + { + this.feed = new ExamFeed(); + this.feed.OnLoaded += new ExamFeed.OnIO(this.FeedIsReady); + this.feed.OnFailedWeb += new ExamFeed.OnFailed(this.FeedIsFailWeb); + this.feed.OnFailedFile += new ExamFeed.OnFailed(this.FeedIsFailFile); + } + + /// Method will be execute if the feed is ready. + /// Stubbfel, 02.09.2013. + private void FeedIsReady() + { + this.SetupExamList(); + this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed; + } + + /// Sets up the exam list. + /// Stubbfel, 02.09.2013. + private void SetupExamList() + { + var bachelorList = from exam in this.feed.Model.Exams + where exam.DegreeNumber.Equals(((int)CampusAppWP8.Model.Setting.UserProfilModel.DegreeType.BACHELOR).ToString()) + orderby exam.CourseText, exam.Version + select exam; + + var masterList = from exam in this.feed.Model.Exams + where exam.DegreeNumber.Equals(((int)CampusAppWP8.Model.Setting.UserProfilModel.DegreeType.MASTER).ToString()) + orderby exam.CourseText, exam.Version + select exam; + + var diplomaList = from exam in this.feed.Model.Exams + where exam.DegreeNumber.Equals(((int)CampusAppWP8.Model.Setting.UserProfilModel.DegreeType.DIPLOM).ToString()) + orderby exam.CourseText, exam.Version + select exam; + + this.BachelorPanel.ItemsSource = bachelorList; + this.MasterPanel.ItemsSource = masterList; + this.DiplomaPanel.ItemsSource = diplomaList; + this.ExamPivot.SelectedIndex = this.CalcSelectedIndex(); + } + + /// Calculates the selected index. + /// Stubbfel, 02.09.2013. + /// The calculated selected index. + private int CalcSelectedIndex() + { + int result = 0; + Model.Setting.UserProfilModel.DegreeType degree = Settings.UserProfil.Degree; + + switch (degree) + { + case Model.Setting.UserProfilModel.DegreeType.BACHELOR: + result = 0; + break; + case Model.Setting.UserProfilModel.DegreeType.MASTER: + result = 1; + break; + case Model.Setting.UserProfilModel.DegreeType.DIPLOM: + result = 2; + break; + default: + result = 0; + break; + } + return result; + } + + /// Method will be execute if the feed is failed. + /// Stubbfel, 02.09.2013. + private void FeedIsFailWeb() + { + MessageBoxResult result = MessageBoxes.ShowMainModelErrorMessageBox(AppResources.MsgBox_ErrorMainModelLoadWeb); + this.feed.ForceReadFile(); + } + + /// Method will be execute if the feed is failed. + /// Stubbfel, 02.09.2013. + private void FeedIsFailFile() + { + MessageBoxResult result = MessageBoxes.ShowMainModelErrorMessageBox(AppResources.MsgBox_ErrorMainModelLoadFile); + this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed; } } } \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs index 06891e9a..86a670dd 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs @@ -222,6 +222,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die Prüfungsordnungen ähnelt. + /// + public static string ExaminationApp_Header { + get { + return ResourceManager.GetString("ExaminationApp_Header", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die Prüfungs- ordnungen ähnelt. /// diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx index 2a71e34a..43dcd186 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx @@ -422,4 +422,7 @@ Prüfungs- ordnungen + + Prüfungsordnungen + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs index c4d59f0c..bc4f1e44 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs @@ -132,6 +132,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die links ähnelt. + /// + public static string ExamXmlValidRootName { + get { + return ResourceManager.GetString("ExamXmlValidRootName", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die DepartmentFavoriteFeed.xml ähnelt. /// @@ -159,6 +168,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die examlist.xml ähnelt. + /// + public static string FileExamApp_ExamFeed { + get { + return ResourceManager.GetString("FileExamApp_ExamFeed", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die ClubLinks.xml ähnelt. /// @@ -825,6 +843,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die https://www.zv.tu-cottbus.de/CMS-Webservice/Pruefungsordnung/Uebersicht ähnelt. + /// + public static string UrlExamApp_ExamFeed { + get { + return ResourceManager.GetString("UrlExamApp_ExamFeed", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die http://www.zv.tu-cottbus.de/LSFveranst/LSF4 ähnelt. /// diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx index 999143ae..cedfe545 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx @@ -438,4 +438,13 @@ /Pages/Exams/Exams.xaml + + links + + + examlist.xml + + + https://www.zv.tu-cottbus.de/CMS-Webservice/Pruefungsordnung/Uebersicht + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/StringManager.cs b/CampusAppWP8/CampusAppWP8/Utility/StringManager.cs index 2ead4228..2181dd89 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/StringManager.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/StringManager.cs @@ -31,8 +31,9 @@ namespace CampusAppWP8.Utility /// String with Html-Tags /// String without Html-Tags public static string StripHTML(string inputString) - { - return Regex.Replace(inputString, HtmlTagPattern, string.Empty); + { + string result = Regex.Replace(inputString, HtmlTagPattern, string.Empty); + return System.Net.HttpUtility.HtmlDecode(result); } /// From 90a11179bdab069dcb46d4090d2597e95a82b356 Mon Sep 17 00:00:00 2001 From: stubbfel Date: Tue, 3 Sep 2013 11:18:14 +0200 Subject: [PATCH 4/5] change string to byte[] in File.cs and MainModel --- CampusAppWP8/CampusAppWP8/Model/MainModel.cs | 31 ++-- .../CampusAppWP8/Pages/Exams/Exams.xaml.cs | 3 + CampusAppWP8/CampusAppWP8/Utility/File.cs | 135 ++---------------- .../CampusAppWP8/Utility/HttpRequest.cs | 7 + 4 files changed, 36 insertions(+), 140 deletions(-) diff --git a/CampusAppWP8/CampusAppWP8/Model/MainModel.cs b/CampusAppWP8/CampusAppWP8/Model/MainModel.cs index 8a549d87..a88d6a99 100644 --- a/CampusAppWP8/CampusAppWP8/Model/MainModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/MainModel.cs @@ -335,7 +335,7 @@ namespace CampusAppWP8 { if (this.file != null) { - string data = this.file.ReadFile(); + byte[] data = this.file.ReadFile(); if (data == null) { @@ -343,9 +343,9 @@ namespace CampusAppWP8 } else { - if (!data.Equals(string.Empty)) + if (data.Length > 0) { - this.DeserializeModel(Encoding.UTF8.GetBytes(data)); + this.DeserializeModel(data); } this.RunOnIOCallback(this.OnLoaded); @@ -494,7 +494,7 @@ namespace CampusAppWP8 if ((this.IsFile() == true) && (fileName.Equals(string.Empty) == false)) { - this.InitFile(CampusAppWP8.Utility.File.IOTypeRead.ReadSync, CampusAppWP8.Utility.File.IOTypeWrite.WriteAsync); + this.InitFile(); } if ((this.IsHttpApi() == true) @@ -507,16 +507,12 @@ namespace CampusAppWP8 /// /// Initializes the file object. /// - /// read io type (Default: sync) - /// write io type (Default: async) - private void InitFile( - CampusAppWP8.Utility.File.IOTypeRead readType = CampusAppWP8.Utility.File.IOTypeRead.ReadSync, - CampusAppWP8.Utility.File.IOTypeWrite writeType = CampusAppWP8.Utility.File.IOTypeWrite.WriteAsync) + private void InitFile() { if ((this.IsFile() == true) && (this.file == null)) { - this.file = new CampusAppWP8.Utility.File(this.fileName, readType, writeType); + this.file = new CampusAppWP8.Utility.File(this.fileName); } } @@ -537,7 +533,7 @@ namespace CampusAppWP8 /// /// sending object /// event args - private void OnLoadDataComplete(object sender, DownloadStringCompletedEventArgs e) + private void OnLoadDataComplete(object sender, OpenReadCompletedEventArgs e) { Exception downloadError = e.Error; if (downloadError != null) @@ -546,11 +542,16 @@ namespace CampusAppWP8 } else { - string downloadResult = e.Result; - - if (downloadResult != null && !downloadResult.Equals(string.Empty)) + byte[] data; + using (MemoryStream ms = new MemoryStream()) { - this.DeserializeModel(Encoding.UTF8.GetBytes(downloadResult)); + e.Result.CopyTo(ms); + data = ms.ToArray(); + } + + if (data != null && data.Length > 0) + { + this.DeserializeModel(data); } this.RunOnIOCallback(this.OnLoaded); diff --git a/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml.cs index 1fec754a..78c5c024 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml.cs @@ -14,6 +14,8 @@ namespace CampusAppWP8.Pages.Exams using CampusAppWP8.Utility; using CampusAppWP8.Utility.Lui.MessageBoxes; using Microsoft.Phone.Controls; + using System.Net; + using System.IO; /// Exams. /// Stubbfel, 02.09.2013. @@ -74,6 +76,7 @@ namespace CampusAppWP8.Pages.Exams { this.SetupExamList(); this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed; + HttpRequest api = new HttpRequest(); } /// Sets up the exam list. diff --git a/CampusAppWP8/CampusAppWP8/Utility/File.cs b/CampusAppWP8/CampusAppWP8/Utility/File.cs index 189a7250..61c6e1a1 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/File.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/File.cs @@ -27,27 +27,15 @@ namespace CampusAppWP8.Utility /// private string filename = string.Empty; - /// - /// Read type. - /// - private IOTypeRead readType; - - /// - /// Write type. - /// - private IOTypeWrite writeType; - /// /// Initializes a new instance of the class. /// /// file name /// read type /// write type - public File(string filename, IOTypeRead read, IOTypeWrite write) + public File(string filename) { this.filename = filename; - this.readType = (read == IOTypeRead.INVALID) ? IOTypeRead.ReadAsync : read; - this.writeType = write; } /// @@ -55,80 +43,18 @@ namespace CampusAppWP8.Utility /// public delegate void WriteCallbackFunc(); - /// - /// IO read type ENUM. - /// - public enum IOTypeRead - { - /// - /// Invalid/unset state. - /// - INVALID = 0, - - /// - /// Sync read. - /// - ReadSync = 1, - - /// - /// Async read. - /// - ReadAsync = 2 - } - - /// - /// IO write type ENUM. - /// - public enum IOTypeWrite - { - /// - /// Invalid/unset state. - /// - INVALID = 0, - - /// - /// Sync write. - /// - WriteSync = 1, - - /// - /// Async write. - /// - WriteAsync = 2, - - /// - /// Read only, no writing. - /// - ReadOnly = 3 - } - /// /// Read data from file to a string. /// /// read type /// data string - public string ReadFile(IOTypeRead ioType = IOTypeRead.INVALID) + public byte[] ReadFile() { - string retValue = null; + byte[] retValue = null; if (this.Exist() == true) { - IOTypeRead tempType = ioType; - - if (tempType == IOTypeRead.INVALID) - { - tempType = this.readType; - } - - if (tempType == IOTypeRead.ReadAsync) - { - // retValue = this.ReadAsync(); - retValue = this.ReadSync(); - } - else if (tempType == IOTypeRead.ReadSync) - { - retValue = this.ReadSync(); - } + retValue = this.ReadSync(); } return retValue; @@ -141,27 +67,8 @@ namespace CampusAppWP8.Utility /// callback function, called after writing is done. /// callback function, called when writing failed. /// write type. - public void WriteFile(byte[] data, WriteCallbackFunc onSavedCallback, WriteCallbackFunc onFailedCallback, IOTypeWrite ioType = IOTypeWrite.INVALID) + public void WriteFile(byte[] data, WriteCallbackFunc onSavedCallback, WriteCallbackFunc onFailedCallback) { - IOTypeWrite tempType = ioType; - - if (tempType == IOTypeWrite.INVALID) - { - tempType = this.writeType; - } - - /* - if (tempType == IOTypeWrite.WriteAsync) - { - this.WriteAsync(data, onSavedCallback, onFailedCallback); - } - else if (tempType == IOTypeWrite.WriteSync) - { - // this.WriteSync(data); - this.WriteAsync(data, onSavedCallback, onFailedCallback); - } - */ - Thread th = new Thread(delegate() { this.WriteAsync(data, onSavedCallback, onFailedCallback); }); th.Start(); } @@ -189,44 +96,22 @@ namespace CampusAppWP8.Utility /// Read data synchronous from file. /// /// data string - private string ReadSync() + private byte[] ReadSync() { - string retValue = null; + byte[] retValue = null; using (Stream fileStream = File.LocalFolder.OpenStreamForReadAsync(this.filename).Result) { - using (StreamReader streamReader = new StreamReader(fileStream)) + using (MemoryStream ms = new MemoryStream()) { - retValue = streamReader.ReadToEnd(); + fileStream.CopyTo(ms); + retValue = ms.ToArray(); } } return retValue; } - /// - /// Read data asynchronous from file. - /// - /// data string - private string ReadAsync() - { - string retValue = string.Empty; - - return retValue; - } - - /// - /// Write data synchronous to file. - /// - /// data array - /// true, if succeeded - private bool WriteSync(byte[] data) - { - bool retValue = true; - - return retValue; - } - /// /// Write data asynchronous to file. /// diff --git a/CampusAppWP8/CampusAppWP8/Utility/HttpRequest.cs b/CampusAppWP8/CampusAppWP8/Utility/HttpRequest.cs index 810bd29b..87ce11dc 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/HttpRequest.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/HttpRequest.cs @@ -60,6 +60,13 @@ namespace CampusAppWP8.Utility client.DownloadStringAsync(url); } + public void HttpGet(Uri url, Action action) + { + WebClient client = new WebClient(); + client.OpenReadCompleted += new OpenReadCompletedEventHandler(action); + client.OpenReadAsync(url); + } + /// /// Method create the Url for the http-get-method /// From 54ce4e6ee17e570001bbd93a7326b028a89f33b5 Mon Sep 17 00:00:00 2001 From: stubbfel Date: Tue, 3 Sep 2013 14:04:29 +0200 Subject: [PATCH 5/5] add pdflaunch --- CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj | 2 + .../CampusAppWP8/File/Exams/ExamFile.cs | 94 +++++++++++++++++++ .../CampusAppWP8/Model/BinaryModel.cs | 62 ++++++++++++ .../CampusAppWP8/Model/Exams/ExamModel.cs | 2 +- CampusAppWP8/CampusAppWP8/Model/MainModel.cs | 29 ++---- CampusAppWP8/CampusAppWP8/Model/XmlModel.cs | 2 +- .../CampusAppWP8/Pages/Exams/Exams.xaml | 21 ++--- .../CampusAppWP8/Pages/Exams/Exams.xaml.cs | 94 +++++++++++++++---- .../Resources/Constants.Designer.cs | 9 ++ .../CampusAppWP8/Resources/Constants.resx | 3 + CampusAppWP8/CampusAppWP8/Utility/File.cs | 41 ++++---- .../CampusAppWP8/Utility/HttpRequest.cs | 4 + 12 files changed, 286 insertions(+), 77 deletions(-) create mode 100644 CampusAppWP8/CampusAppWP8/File/Exams/ExamFile.cs create mode 100644 CampusAppWP8/CampusAppWP8/Model/BinaryModel.cs diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index 78353d3f..8c591a6c 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -105,6 +105,8 @@ + + diff --git a/CampusAppWP8/CampusAppWP8/File/Exams/ExamFile.cs b/CampusAppWP8/CampusAppWP8/File/Exams/ExamFile.cs new file mode 100644 index 00000000..bbd8ceb4 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/File/Exams/ExamFile.cs @@ -0,0 +1,94 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 03.09.2013 +//---------------------------------------------------------------------- + +namespace CampusAppWP8.File.Exams +{ + using System.IO; + using CampusAppWP8.Model; + using Windows.Storage; + + /// Exam file. + /// Stubbfel, 03.09.2013. + public class ExamFile : BinaryModel + { + /// The storage file. + private StorageFile storageFile; + + /// Initializes a new instance of the ExamFile class. + /// Stubbfel, 03.09.2013. + /// Filename of the file. + /// URL of the document. + public ExamFile(string fileName, string url) + : base(ModelType.FileAndFeed, fileName, url) + { + this.IsFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDate); + this.IsModelUpToDateOnLoad += new IsModelUpToDate(this.CheckIsModelUpToDate); + this.IsFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDate); + } + + /// Executes the file operation. + /// Stubbfel, 03.09.2013. + public async void LaunchFile() + { + if (this.storageFile == null) + { + this.storageFile = await this.file.AsStorageFile(); + } + + if (this.storageFile != null) + { + var options = new Windows.System.LauncherOptions(); + Windows.System.Launcher.LaunchFileAsync(this.storageFile); + } + } + + /// Saves the and launch file. + /// Stubbfel, 03.09.2013. + public void SaveAndLaunchFile() + { + if (this.file.Exist()) + { + this.LaunchFile(); + } + else + { + this.OnSaved += new ExamFile.OnIO(this.LaunchFile); + this.SaveData(); + } + } + + /// Check is model up to date. + /// Stubbfel, 03.09.2013. + /// The model. + /// true if it succeeds, false if it fails. + private bool CheckIsModelUpToDate(byte[] model) + { + if (model == null) + { + return false; + } + + return true; + } + + /// Check is file up to date. + /// Stubbfel, 03.09.2013. + /// The model. + /// Information describing the file. + /// true if it succeeds, false if it fails. + private bool CheckIsFileUpToDate(byte[] model, FileInfo fileInfo) + { + if (fileInfo == null || !fileInfo.Exists || fileInfo.Length < 1) + { + return false; + } + + return true; + } + } +} diff --git a/CampusAppWP8/CampusAppWP8/Model/BinaryModel.cs b/CampusAppWP8/CampusAppWP8/Model/BinaryModel.cs new file mode 100644 index 00000000..6cf9fe7b --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Model/BinaryModel.cs @@ -0,0 +1,62 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 03.09.2013 +//---------------------------------------------------------------------- + +namespace CampusAppWP8.Model +{ + /// Binary model. + /// Stubbfel, 03.09.2013. + public abstract class BinaryModel : MainModel + { + /// Initializes a new instance of the BinaryModel class. + /// Stubbfel, 03.09.2013. + /// Type of the model. + /// Filename of the file. + /// URL of the document. + public BinaryModel(ModelType modelType, string fileName, string url) + : base(modelType, fileName, url) + { + } + + /// Initializes a new instance of the BinaryModel class. + /// Stubbfel, 03.09.2013. + /// Type of the model. + /// Name of the source. + public BinaryModel(ModelType modelType, string sourceName) + : base(modelType, sourceName) + { + } + + /// Deserialize model. + /// Stubbfel, 03.09.2013. + /// Information describing the model. + /// true if it succeeds, false if it fails. + protected override bool DeserializeModel(byte[] modelData) + { + bool retValue = true; + + if (modelData != null) + { + this.Model = modelData; + } + else + { + retValue = false; + } + + return retValue; + } + + /// Gets the serialize model. + /// Stubbfel, 03.09.2013. + /// an byte Array. + protected override byte[] SerializeModel() + { + return this.Model; + } + } +} diff --git a/CampusAppWP8/CampusAppWP8/Model/Exams/ExamModel.cs b/CampusAppWP8/CampusAppWP8/Model/Exams/ExamModel.cs index 5b68c879..57752d26 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Exams/ExamModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Exams/ExamModel.cs @@ -7,8 +7,8 @@ //---------------------------------------------------------------------- namespace CampusAppWP8.Model.Exams { - using CampusAppWP8.Utility; using System.Xml.Serialization; + using CampusAppWP8.Utility; /// Exam model. /// Stubbfel, 02.09.2013. diff --git a/CampusAppWP8/CampusAppWP8/Model/MainModel.cs b/CampusAppWP8/CampusAppWP8/Model/MainModel.cs index a88d6a99..6a01db2b 100644 --- a/CampusAppWP8/CampusAppWP8/Model/MainModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/MainModel.cs @@ -11,7 +11,6 @@ namespace CampusAppWP8 using System.Collections.Generic; using System.IO; using System.Net; - using System.Text; using CampusAppWP8.Model.Utility; using CampusAppWP8.Utility; @@ -19,8 +18,13 @@ namespace CampusAppWP8 /// Base model io handling class. /// /// model type - public abstract class MainModel : IDisposable + public abstract class MainModel { + /// + /// File object. + /// + protected CampusAppWP8.Utility.File file = null; + /// /// Model io type. /// @@ -31,11 +35,6 @@ namespace CampusAppWP8 /// private T model = default(T); - /// - /// File object. - /// - private CampusAppWP8.Utility.File file = null; - /// /// Web object. /// @@ -88,14 +87,6 @@ namespace CampusAppWP8 } } - /// - /// Finalizes an instance of the class. - /// - ~MainModel() - { - this.SaveData(); - } - /// /// Delegate of the OnIO callback function. /// @@ -238,14 +229,6 @@ namespace CampusAppWP8 } } - /// - /// Called before finalizing. Can maybe be removed. - /// - public void Dispose() - { - this.SaveData(); - } - /// /// Forces a update from web. /// diff --git a/CampusAppWP8/CampusAppWP8/Model/XmlModel.cs b/CampusAppWP8/CampusAppWP8/Model/XmlModel.cs index e606f082..5a2cbdbe 100644 --- a/CampusAppWP8/CampusAppWP8/Model/XmlModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/XmlModel.cs @@ -15,7 +15,7 @@ namespace CampusAppWP8.Model /// Xml model io handler class. /// /// model type - public class XmlModel : MainModel + public abstract class XmlModel : MainModel { /// /// Initializes a new instance of the class. diff --git a/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml b/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml index d8774e03..c4a7d7cd 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml @@ -29,12 +29,9 @@ - + @@ -51,12 +48,9 @@ - + @@ -73,12 +67,9 @@ - + diff --git a/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml.cs index 78c5c024..6bcaebe2 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml.cs @@ -8,22 +8,25 @@ namespace CampusAppWP8.Pages.Exams { using System.Linq; using System.Windows; + using System.Windows.Controls; using System.Windows.Navigation; using CampusAppWP8.Feed.Exams; + using CampusAppWP8.File.Exams; using CampusAppWP8.Resources; using CampusAppWP8.Utility; using CampusAppWP8.Utility.Lui.MessageBoxes; using Microsoft.Phone.Controls; - using System.Net; - using System.IO; - /// Exams. + /// class of ExamsPage. /// Stubbfel, 02.09.2013. public partial class Exams : PhoneApplicationPage { /// The feed. private ExamFeed feed; + /// The exam file. + private ExamFile file; + /// Initializes a new instance of the Exams class. /// Stubbfel, 02.09.2013. public Exams() @@ -56,8 +59,13 @@ namespace CampusAppWP8.Pages.Exams { if (NavigationMode.Back == e.NavigationMode) { + App.SaveToIsolatedStorage(Constants.ExamPageModelKey, -1); this.feed.SaveData(); } + else + { + App.SaveToIsolatedStorage(Constants.ExamPageModelKey, this.ExamPivot.SelectedIndex); + } } /// Method initialize the Feed. @@ -76,7 +84,14 @@ namespace CampusAppWP8.Pages.Exams { this.SetupExamList(); this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed; - HttpRequest api = new HttpRequest(); + } + + /// Executes the PDF reader operation. + /// Stubbfel, 03.09.2013. + private void LaunchPDFReader() + { + this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed; + this.file.SaveAndLaunchFile(); } /// Sets up the exam list. @@ -109,24 +124,28 @@ namespace CampusAppWP8.Pages.Exams /// The calculated selected index. private int CalcSelectedIndex() { - int result = 0; - Model.Setting.UserProfilModel.DegreeType degree = Settings.UserProfil.Degree; - - switch (degree) + int result = App.LoadFromIsolatedStorage(Constants.ExamPageModelKey); + if (result < 0 || result > 2) { - case Model.Setting.UserProfilModel.DegreeType.BACHELOR: - result = 0; - break; - case Model.Setting.UserProfilModel.DegreeType.MASTER: - result = 1; - break; - case Model.Setting.UserProfilModel.DegreeType.DIPLOM: - result = 2; - break; - default: - result = 0; - break; + Model.Setting.UserProfilModel.DegreeType degree = Settings.UserProfil.Degree; + + switch (degree) + { + case Model.Setting.UserProfilModel.DegreeType.BACHELOR: + result = 0; + break; + case Model.Setting.UserProfilModel.DegreeType.MASTER: + result = 1; + break; + case Model.Setting.UserProfilModel.DegreeType.DIPLOM: + result = 2; + break; + default: + result = 0; + break; + } } + return result; } @@ -145,5 +164,40 @@ namespace CampusAppWP8.Pages.Exams MessageBoxResult result = MessageBoxes.ShowMainModelErrorMessageBox(AppResources.MsgBox_ErrorMainModelLoadFile); this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed; } + + /// Event handler. Called by Button for click events. + /// Stubbfel, 03.09.2013. + /// Source of the event. + /// Routed event information. + private void Button_Click(object sender, RoutedEventArgs e) + { + Button button = sender as Button; + if (button == null) + { + return; + } + + string url = button.Tag as string; + if (url == null) + { + return; + } + + // create filename + string[] filenames = url.Split('/'); + string filename = url; + + if (filenames.Length > 0) + { + filename = filenames[filenames.Length - 1]; + } + + this.file = new ExamFile(filename, url); + this.file.OnLoaded += new ExamFile.OnIO(this.LaunchPDFReader); + this.file.OnFailedWeb += new ExamFile.OnFailed(this.FeedIsFailWeb); + this.file.OnFailedFile += new ExamFile.OnFailed(this.FeedIsFailFile); + this.file.LoadData(); + this.ProgressBar.Visibility = System.Windows.Visibility.Visible; + } } } \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs index bc4f1e44..ca04fe9e 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs @@ -132,6 +132,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die ExamsPage.LastPivotIndex ähnelt. + /// + public static string ExamPageModelKey { + get { + return ResourceManager.GetString("ExamPageModelKey", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die links ähnelt. /// diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx index cedfe545..827f5f98 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx @@ -447,4 +447,7 @@ https://www.zv.tu-cottbus.de/CMS-Webservice/Pruefungsordnung/Uebersicht + + ExamsPage.LastPivotIndex + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/File.cs b/CampusAppWP8/CampusAppWP8/Utility/File.cs index 61c6e1a1..3a444a0d 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/File.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/File.cs @@ -10,6 +10,7 @@ namespace CampusAppWP8.Utility using System; using System.IO; using System.Threading; + using System.Threading.Tasks; using Windows.Storage; /// @@ -27,12 +28,9 @@ namespace CampusAppWP8.Utility /// private string filename = string.Empty; - /// - /// Initializes a new instance of the class. - /// - /// file name - /// read type - /// write type + /// Initializes a new instance of the class. + /// Stubbfel, 03.09.2013. + /// file name. public File(string filename) { this.filename = filename; @@ -43,11 +41,9 @@ namespace CampusAppWP8.Utility /// public delegate void WriteCallbackFunc(); - /// - /// Read data from file to a string. - /// - /// read type - /// data string + /// Read data from file to a string. + /// Stubbfel, 03.09.2013. + /// data string. public byte[] ReadFile() { byte[] retValue = null; @@ -60,13 +56,11 @@ namespace CampusAppWP8.Utility return retValue; } - /// - /// Write bytes to the file. - /// - /// data byte array. - /// callback function, called after writing is done. + /// Write bytes to the file. + /// Stubbfel, 03.09.2013. + /// data byte array. + /// callback function, called after writing is done. /// callback function, called when writing failed. - /// write type. public void WriteFile(byte[] data, WriteCallbackFunc onSavedCallback, WriteCallbackFunc onFailedCallback) { Thread th = new Thread(delegate() { this.WriteAsync(data, onSavedCallback, onFailedCallback); }); @@ -92,6 +86,19 @@ namespace CampusAppWP8.Utility return this.GetFileInfo().Exists; } + /// Converts this object to a storage file. + /// Stubbfel, 03.09.2013. + /// Storage File + public async Task AsStorageFile() + { + if (this.Exist()) + { + return await File.LocalFolder.GetFileAsync(this.filename); + } + + return null; + } + /// /// Read data synchronous from file. /// diff --git a/CampusAppWP8/CampusAppWP8/Utility/HttpRequest.cs b/CampusAppWP8/CampusAppWP8/Utility/HttpRequest.cs index 87ce11dc..e8cd4db7 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/HttpRequest.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/HttpRequest.cs @@ -60,6 +60,10 @@ namespace CampusAppWP8.Utility client.DownloadStringAsync(url); } + /// Method realize the http-get-method resource. + /// Stubbfel, 03.09.2013. + /// Url of the resource. + /// The action. public void HttpGet(Uri url, Action action) { WebClient client = new WebClient();