Changeset 14667
- Timestamp:
- 06/26/08 23:32:50 (5 years ago)
- Location:
- platform/silverlight/eLearn/trunk
- Files:
-
- 2 added
- 8 modified
-
eLearn/Page.xaml (modified) (2 diffs)
-
eLearn/Page.xaml.cs (modified) (1 diff)
-
eLearn/UI/AddStudyView.xaml (added)
-
eLearn/UI/AddStudyView.xaml.cs (added)
-
eLearn/UI/QuestionView.xaml (modified) (2 diffs)
-
eLearn/eLearn.csproj (modified) (2 diffs)
-
eLearn_Web/Content/Site.css (modified) (1 diff)
-
eLearn_Web/Controllers/StudyController.cs (modified) (4 diffs)
-
eLearn_Web/Views/Shared/Site.Master (modified) (1 diff)
-
eLearn_Web/eLearn_Web.csproj.user (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
platform/silverlight/eLearn/trunk/eLearn/Page.xaml
r14610 r14667 1 1 <UserControl x:Class="eLearn.Page" 2 2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 4 xmlns:v="clr-namespace:eLearn.UI" 4 5 Width="400" Height="220"> 5 6 … … 30 31 31 32 <StackPanel Grid.Column="1" HorizontalAlignment="Left" Margin="8,0,0,0"> 32 <Button x:Name="addButton" Width="80" Content="追加" Style="{StaticResource button}" /> 33 <Button x:Name="addButton" Width="80" Content="追加" 34 Click="addButton_Click" Style="{StaticResource button}" /> 35 33 36 <Button x:Name="editButton" Width="80" Content="編集" IsEnabled="False" Margin="0,5,0,0" Style="{StaticResource button}" /> 34 37 <Button x:Name="remButton" Width="80" Content="削除" IsEnabled="False" Margin="0,5,0,0" Style="{StaticResource button}" /> 35 38 </StackPanel> 39 40 <v:AddStudyView x:Name="addStudyView" Grid.ColumnSpan="2" Visibility="Collapsed" /> 36 41 </Grid> 37 42 -
platform/silverlight/eLearn/trunk/eLearn/Page.xaml.cs
r14610 r14667 91 91 } 92 92 93 /// <summary> 94 /// [追加] 95 /// </summary> 96 /// <param name="sender"></param> 97 /// <param name="e"></param> 98 private void addButton_Click(object sender, RoutedEventArgs e) { 99 addStudyView.Show(); 100 } 101 93 102 } 94 103 } -
platform/silverlight/eLearn/trunk/eLearn/UI/QuestionView.xaml
r14610 r14667 3 3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 4 4 xmlns:data="clr-namespace:eLearn.UI.Data" 5 Width="360" Height=" 300">5 Width="360" Height="290"> 6 6 7 7 <UserControl.Resources> … … 71 71 <Grid x:Name="LayoutRoot" Background="White"> 72 72 <Grid.RowDefinitions> 73 <RowDefinition Height=" 70" />73 <RowDefinition Height="60" /> 74 74 <RowDefinition /> 75 75 <RowDefinition Height="40" /> -
platform/silverlight/eLearn/trunk/eLearn/eLearn.csproj
r14610 r14667 73 73 <Compile Include="StudyManager.cs" /> 74 74 <Compile Include="StudyResult.cs" /> 75 <Compile Include="UI\AddStudyView.xaml.cs"> 76 <DependentUpon>AddStudyView.xaml</DependentUpon> 77 </Compile> 75 78 <Compile Include="UI\Data\QuestionConverter.cs" /> 76 79 <Compile Include="UI\FinishView.xaml.cs"> … … 93 96 <Generator>MSBuild:MarkupCompilePass1</Generator> 94 97 <SubType>Designer</SubType> 98 </Page> 99 <Page Include="UI\AddStudyView.xaml"> 100 <SubType>Page</SubType> 101 <Generator>MSBuild:MarkupCompilePass1</Generator> 95 102 </Page> 96 103 <Page Include="UI\FinishView.xaml"> -
platform/silverlight/eLearn/trunk/eLearn_Web/Content/Site.css
r14610 r14667 1 1 2 2 .page { 3 width: 400px; 3 4 } 4 5 5 6 .silverlight { 6 7 width: 400px; 7 height: 400px;8 height: 330px; 8 9 } 9 10 10 11 #header { 11 height: 55px;12 margin-bottom: 20px; 12 13 } -
platform/silverlight/eLearn/trunk/eLearn_Web/Controllers/StudyController.cs
r14610 r14667 27 27 using System.Web; 28 28 using System.Web.Mvc; 29 using System.Net; 30 using System.Linq; 29 31 using System.Text; 30 32 using System.Xml.Linq; 31 33 using System.Diagnostics; 34 35 using Ele = System.Xml.Linq.XElement; 36 using Attr = System.Xml.Linq.XAttribute; 32 37 33 38 #endregion … … 41 46 /// </summary> 42 47 public sealed class StudyController : Controller { 43 48 49 #region const 50 51 /// <summary> 52 /// インデックスファイル 53 /// </summary> 54 private const string INDEX_FILE = "~/App_Data/Repo/index.xml"; 55 /// <summary> 56 /// コンテントファイルのフォーマット 57 /// </summary> 58 private const string CONTENT_FILE_FORMAT = "~/App_Data/Repo/study/{0}.xml"; 59 60 #endregion 61 44 62 #region constructors 45 63 … … 59 77 /// <returns>スタディ情報の一覧</returns> 60 78 public ActionResult Index() { 61 var path = Request.MapPath( "~/App_Data/Repo/index.xml");79 var path = Request.MapPath(INDEX_FILE); 62 80 63 81 using(var sr = new StreamReader(path, Encoding.UTF8)) { 64 return Content(sr.ReadToEnd(), "text/xml" , Encoding.UTF8);82 return Content(sr.ReadToEnd(), "text/xml"); 65 83 } 66 84 } … … 74 92 if(id != null) { 75 93 try { 76 var path = Request.MapPath(string.Format( "~/App_Data/Repo/study/{0}.xml", id));94 var path = Request.MapPath(string.Format(CONTENT_FILE_FORMAT, id)); 77 95 78 96 using(var sr = new StreamReader(path, Encoding.UTF8)) { 79 return Content(sr.ReadToEnd(), "text/xml" , Encoding.UTF8);97 return Content(sr.ReadToEnd(), "text/xml"); 80 98 } 81 99 82 100 } catch(Exception exp) { 83 throw new HttpException( 404, "指定したスタディは存在しません", exp);101 throw new HttpException((int)HttpStatusCode.NotFound, "指定したStudyは存在しません。", exp); 84 102 } 85 103 86 104 } else { 87 throw new HttpException(400, "idを指定して下さい"); 88 } 89 } 105 throw new HttpException((int)HttpStatusCode.BadRequest, "[id]を指定して下さい。"); 106 } 107 } 108 109 /// <summary> 110 /// スタディを新規作成します。 111 /// </summary> 112 /// <param name="title">タイトル</param> 113 /// <returns>スタディ情報</returns> 114 public ActionResult New(string title) { 115 if(string.IsNullOrEmpty(title)) { 116 throw new HttpException((int)HttpStatusCode.BadRequest, "[title]を指定して下さい。"); 117 } 118 var indexXml = OpenIndex(); 119 var id = indexXml.Descendants("study").Max(s => (int)s.Attribute("id")) + 1; 120 121 indexXml.Root.Add( 122 new Ele("study", 123 new Attr("id", id), new Attr("title", title) 124 ) 125 ); 126 SaveIndex(indexXml); 127 128 var contentXml = new XDocument( 129 new Ele("study", 130 new Attr("id", id), new Attr("title", title) 131 ) 132 ); 133 return Content( 134 SaveContent(contentXml, id).ToString(), "text/xml" 135 ); 136 } 137 138 /// <summary> 139 /// 指定したIdのスタディを削除します。 140 /// </summary> 141 /// <param name="id">Id</param> 142 /// <returns>削除できたかどうか</returns> 143 public ActionResult Remove(int? id) { 144 if(id == null) { 145 throw new HttpException((int)HttpStatusCode.BadRequest, "[id]を指定して下さい。"); 146 } 147 var indexXml = OpenIndex(); 148 149 var study = indexXml.Descendants("study") 150 .FirstOrDefault(s => (int)s.Attribute("id") == id.Value); 151 152 if(study == null) { 153 throw new HttpException((int)HttpStatusCode.NotFound, "指定したStudyは存在しません。"); 154 } 155 study.Remove(); 156 157 SaveIndex(indexXml); 158 159 return Content("0", "text/plain"); 160 } 161 162 /// <summary> 163 /// 指定したIdのスタディに指定した質問を追加します。 164 /// </summary> 165 /// <param name="id">Id</param> 166 /// <param name="content">質問内容を表すXML</param> 167 /// <returns>スタディ情報</returns> 168 public ActionResult AddQuestion(int? id, string content) { 169 if(id == null || string.IsNullOrEmpty(content)) { 170 throw new HttpException((int)HttpStatusCode.BadRequest, "[id][content]を指定して下さい。"); 171 } 172 var xml = OpenContent(id); 173 xml.Root.Add(content); 174 175 return Content( 176 SaveContent(xml, id).ToString(), "text/xml" 177 ); 178 } 179 180 /// <summary> 181 /// 指定したIdのスタディの指定した位置の質問を削除します。 182 /// </summary> 183 /// <param name="id">Id</param> 184 /// <param name="index">質問の位置</param> 185 /// <returns>削除後のスタディ情報</returns> 186 public ActionResult RemoveQuestion(int? id, int? index) { 187 if(id == null || index == null) { 188 throw new HttpException((int)HttpStatusCode.BadRequest, "[id][index]を指定して下さい。"); 189 } 190 var contentXml = OpenContent(id); 191 // 一度リストに変換しないと駄目よ!! 192 contentXml.Descendants("question") 193 .Where((q, i) => i == index) 194 .ToList().ForEach(q => q.Remove()); 195 196 return Content( 197 SaveContent(contentXml, id).ToString(), "text/xml" 198 ); 199 } 200 201 #region private 202 203 /// <summary> 204 /// インデックスファイルを開きます。 205 /// </summary> 206 /// <returns>インデックスファイル</returns> 207 XDocument OpenIndex() { 208 return XDocument.Load(Request.MapPath(INDEX_FILE)); 209 } 210 211 /// <summary> 212 /// 指定したインデックスを保存します。 213 /// </summary> 214 /// <param name="xml">インデックス</param> 215 /// <returns>インデックス</returns> 216 XDocument SaveIndex(XDocument xml) { 217 xml.Save(Request.MapPath(INDEX_FILE)); 218 219 return xml; 220 } 221 222 /// <summary> 223 /// 指定したIdのコンテントを開きます。 224 /// </summary> 225 /// <param name="id">Id</param> 226 /// <returns>コンテント</returns> 227 XDocument OpenContent(int? id) { 228 return XDocument.Load( 229 Request.MapPath(string.Format(CONTENT_FILE_FORMAT, id)) 230 ); 231 } 232 233 /// <summary> 234 /// 指定したコンテントを保存します。 235 /// </summary> 236 /// <param name="xml">コンテント</param> 237 /// <param name="id">Id</param> 238 /// <returns>コンテント</returns> 239 XDocument SaveContent(XDocument xml, int? id) { 240 xml.Save( 241 Request.MapPath(string.Format(CONTENT_FILE_FORMAT, id)) 242 ); 243 return xml; 244 } 245 246 #endregion 90 247 91 248 #endregion -
platform/silverlight/eLearn/trunk/eLearn_Web/Views/Shared/Site.Master
r14610 r14667 10 10 11 11 <body> 12 <div id="header"> 13 <a href="../Home/Index.aspx"><img src="../Content/logo.png" border="0" /></a> 14 </div> 15 <div class="page"> 16 <asp:ContentPlaceHolder ID="MainContent" runat="server" /> 17 </div> 12 <table border="0" cellspacing="0" cellpadding="0" width="100%"> 13 <tr><td align="center"> 14 <table> 15 <tr><td align="left" class="page"> 16 <div id="header"> 17 <a href="../Home/Index.aspx"><img src="../Content/logo.png" border="0" /></a> 18 </div> 19 20 <asp:ContentPlaceHolder ID="MainContent" runat="server" /> 21 </td></tr> 22 </table> 23 </td></tr> 24 </table> 18 25 </body> 19 26 </html> -
platform/silverlight/eLearn/trunk/eLearn_Web/eLearn_Web.csproj.user
r14610 r14667 1 1 <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 2 <PropertyGroup> 3 <ProjectView>ProjectFiles</ProjectView> 4 </PropertyGroup> 2 5 <ProjectExtensions> 3 6 <VisualStudio>
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)