Changeset 14717 for platform/silverlight
- Timestamp:
- 06/27/08 22:35:40 (5 years ago)
- Location:
- platform/silverlight/eLearn/trunk
- Files:
-
- 4 added
- 15 modified
-
eLearn/App.xaml (modified) (5 diffs)
-
eLearn/Page.xaml (modified) (3 diffs)
-
eLearn/Page.xaml.cs (modified) (6 diffs)
-
eLearn/StudyManager.cs (modified) (4 diffs)
-
eLearn/StudyPage.xaml (modified) (2 diffs)
-
eLearn/StudyPage.xaml.cs (modified) (6 diffs)
-
eLearn/UI/AddQuestionView.xaml (added)
-
eLearn/UI/AddQuestionView.xaml.cs (added)
-
eLearn/UI/AddStudyView.xaml (modified) (2 diffs)
-
eLearn/UI/AddStudyView.xaml.cs (modified) (5 diffs)
-
eLearn/UI/EditStudyView.xaml (added)
-
eLearn/UI/EditStudyView.xaml.cs (added)
-
eLearn/UI/FinishView.xaml (modified) (1 diff)
-
eLearn/UI/QuestionView.xaml (modified) (1 diff)
-
eLearn/UI/QuestionView.xaml.cs (modified) (3 diffs)
-
eLearn/eLearn.csproj (modified) (2 diffs)
-
eLearn_Web/App_Data/Repo/index.xml (modified) (1 diff)
-
eLearn_Web/Controllers/StudyController.cs (modified) (5 diffs)
-
eLearn_Web/eLearn_Web.csproj.user (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
platform/silverlight/eLearn/trunk/eLearn/App.xaml
r14610 r14717 5 5 <Application.Resources> 6 6 7 <Style x:Key="button" TargetType="Button"> 7 <!-- リッチな外観のボタン --> 8 <Style x:Key="Rich-Button" TargetType="Button"> 8 9 <Setter Property="Height" Value="30" /> 9 10 <Setter Property="Cursor" Value="Hand" /> … … 11 12 <Setter.Value> 12 13 <ControlTemplate> 13 <Border Border Brush="Black" BorderThickness="2" CornerRadius="15">14 <Border BorderThickness="2" CornerRadius="15"> 14 15 <Border.Background> 15 16 <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> … … 18 19 </LinearGradientBrush> 19 20 </Border.Background> 21 <Border.BorderBrush> 22 <SolidColorBrush x:Name="borderBrush" Color="Gray" /> 23 </Border.BorderBrush> 20 24 21 25 <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"> … … 38 42 <VisualState x:Name="MouseOver"> 39 43 <Storyboard> 40 <DoubleAnimation To="0.4" 44 <DoubleAnimation To="0.4" Duration="0:0:0" 41 45 Storyboard.TargetName="bgcolor2" Storyboard.TargetProperty="Offset" /> 42 46 </Storyboard> 43 47 </VisualState> 48 </VisualStateGroup> 49 50 <VisualStateGroup x:Name="FocusState"> 51 <VisualState x:Name="Focused"> 52 <Storyboard> 53 <ColorAnimation To="Black" Duration="0:0:0" 54 Storyboard.TargetName="borderBrush" Storyboard.TargetProperty="Color" /> 55 </Storyboard> 56 </VisualState> 57 <VisualState x:Name="Unfocused" /> 44 58 </VisualStateGroup> 45 59 </VisualStateManager.VisualStateGroups> … … 50 64 </Style> 51 65 66 <!-- ダイアログ風のボーダー --> 67 <Style x:Key="Dialog-Border" TargetType="Border"> 68 <Setter Property="BorderBrush" Value="Black" /> 69 <Setter Property="BorderThickness" Value="2" /> 70 <Setter Property="CornerRadius" Value="12" /> 71 <Setter Property="Background"> 72 <Setter.Value> 73 <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> 74 <GradientStop Color="White" Offset="0" /> 75 <GradientStop Color="Silver" Offset="1" /> 76 </LinearGradientBrush> 77 </Setter.Value> 78 </Setter> 79 </Style> 80 <!-- ダイアログの背景にフィルタをかけるための四角形 --> 81 <Style x:Key="Dialog-Filter" TargetType="Rectangle"> 82 <Setter Property="Fill" Value="Silver" /> 83 <Setter Property="Opacity" Value="0.2" /> 84 </Style> 85 86 <!-- テーブルに表示する時のラベル --> 87 <Style x:Key="Table-Label" TargetType="TextBlock"> 88 <Setter Property="FontSize" Value="12" /> 89 <Setter Property="VerticalAlignment" Value="Center" /> 90 <Setter Property="HorizontalAlignment" Value="Center" /> 91 </Style> 92 <!-- テーブルに表示する時のテキストボックス --> 93 <Style x:Key="Table-Input" TargetType="TextBox"> 94 <Setter Property="Height" Value="22" /> 95 <Setter Property="Margin" Value="0,0,10,0" /> 96 </Style> 97 <!-- テーブルに表示するコマンドボタンのパネル --> 98 <Style x:Key="Table-CommandPane" TargetType="StackPanel"> 99 <Setter Property="Margin" Value="0,0,0,6" /> 100 <Setter Property="HorizontalAlignment" Value="Center" /> 101 <Setter Property="VerticalAlignment" Value="Bottom" /> 102 <Setter Property="Orientation" Value="Horizontal" /> 103 </Style> 104 105 <!-- シンプルな外観のリストボックス --> 106 <Style x:Name="Simple-ListBox" TargetType="ListBox"> 107 <Setter Property="Template"> 108 <Setter.Value> 109 <ControlTemplate TargetType="ListBox"> 110 <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"> 111 <ItemsPresenter /> 112 </ScrollViewer> 113 </ControlTemplate> 114 </Setter.Value> 115 </Setter> 116 </Style> 117 52 118 </Application.Resources> 53 119 </Application> -
platform/silverlight/eLearn/trunk/eLearn/Page.xaml
r14667 r14717 3 3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 4 4 xmlns:v="clr-namespace:eLearn.UI" 5 Width="4 00" Height="220">5 Width="420" Height="300" Loaded="UserControl_Loaded"> 6 6 7 7 <Grid x:Name="LayoutRoot" Background="White"> … … 12 12 13 13 <ListBox x:Name="studyList" Width="300" Height="200" 14 HorizontalAlignment="Left" VerticalAlignment="Top" SelectionChanged="studyList_SelectionChanged"> 15 <ListBox.Template> 16 <ControlTemplate TargetType="ListBox"> 17 <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"> 18 <ItemsPresenter /> 19 </ScrollViewer> 20 </ControlTemplate> 21 </ListBox.Template> 14 HorizontalAlignment="Left" VerticalAlignment="Top" 15 SelectionChanged="studyList_SelectionChanged" Style="{StaticResource Simple-ListBox}"> 22 16 <ListBox.ItemTemplate> 23 17 <DataTemplate> … … 32 26 <StackPanel Grid.Column="1" HorizontalAlignment="Left" Margin="8,0,0,0"> 33 27 <Button x:Name="addButton" Width="80" Content="追加" 34 Click="addButton_Click" Style="{StaticResource button}" />28 Click="addButton_Click" Style="{StaticResource Rich-Button}" /> 35 29 36 <Button x:Name="editButton" Width="80" Content="編集" IsEnabled="False" Margin="0,5,0,0" Style="{StaticResource button}" /> 37 <Button x:Name="remButton" Width="80" Content="削除" IsEnabled="False" Margin="0,5,0,0" Style="{StaticResource button}" /> 30 <Button x:Name="editButton" Width="80" Content="編集" 31 IsEnabled="False" Margin="0,5,0,0" Click="editButton_Click" Style="{StaticResource Rich-Button}" /> 32 33 <Button x:Name="remButton" Width="80" Content="削除" 34 IsEnabled="False" Margin="0,5,0,0" Click="remButton_Click" Style="{StaticResource Rich-Button}" /> 38 35 </StackPanel> 39 36 40 <v:AddStudyView x:Name="addStudyView" Grid.ColumnSpan="2" Visibility="Collapsed" /> 37 <!-- コードから生成してね!! 38 <v:AddStudyView x:Name="addStudyView" Grid.ColumnSpan="2" 39 AddStudy="addStudyView_AddStudy" Visibility="Collapsed" /> 40 41 <v:EditStudyView x:Name="editStudyView" Grid.ColumnSpan="2" 42 UpdateStudy="editStudyView_UpdateStudy" Visibility="Collapsed" /> 43 --> 41 44 </Grid> 42 45 -
platform/silverlight/eLearn/trunk/eLearn/Page.xaml.cs
r14667 r14717 27 27 using System.Windows.Browser; 28 28 using System.Windows.Controls; 29 using System.Diagnostics; 30 31 using eLearn.UI; 29 32 30 33 #endregion … … 38 41 #region fields 39 42 40 private StudyManager studyMgr; 43 private AddStudyView addView; 44 private EditStudyView editView; 41 45 42 46 #endregion … … 50 54 get; 51 55 set; 56 } 57 58 /// <summary> 59 /// スタディ管理オブジェクトを取得、設定します。 60 /// </summary> 61 public StudyManager StudyManager { 62 get; 63 set; 64 } 65 66 /// <summary> 67 /// スタディ追加画面を取得します。 68 /// </summary> 69 private AddStudyView AddStudyView { 70 [DebuggerStepThrough] 71 get { 72 if(addView == null) { 73 addView = new AddStudyView { 74 Visibility=Visibility.Collapsed 75 }; 76 addView.AddStudy += AddStudyView_AddStudy; 77 78 Grid.SetColumnSpan(addView, 2); 79 80 LayoutRoot.Children.Add(addView); 81 } 82 return addView; 83 } 84 } 85 86 /// <summary> 87 /// スタディ編集画面を取得します。 88 /// </summary> 89 private EditStudyView EditStudyView { 90 [DebuggerStepThrough] 91 get { 92 if(editView == null) { 93 editView = new EditStudyView { 94 Visibility=Visibility.Collapsed, 95 StudyManager=this.StudyManager 96 }; 97 editView.UpdateStudy += EditStudyView_UpdateStudy; 98 99 Grid.SetColumnSpan(editView, 2); 100 101 LayoutRoot.Children.Add(editView); 102 } 103 return editView; 104 } 52 105 } 53 106 … … 73 126 RootUrl = rootUrl + "/"; 74 127 75 studyMgr = new StudyManager(RootUrl); 76 studyMgr.GetStudies(studies => studyList.ItemsSource = studies); 77 } 78 79 #endregion 128 StudyManager = new StudyManager(RootUrl); 129 } 130 131 #endregion 132 133 #region methods 134 135 /// <summary> 136 /// スタディの一覧を読み込みます。 137 /// </summary> 138 void LoadStudies() { LoadStudies(null); } 139 /// <summary> 140 /// スタディの一覧を読み込んで指定したデリゲートをコールバックします。 141 /// </summary> 142 /// <param name="callback">コールバックするデリゲート</param> 143 void LoadStudies(Action callback) { 144 studyList.IsHitTestVisible = false; 145 146 StudyManager.GetStudies(studies => { 147 studyList.ItemsSource = studies; 148 studyList.IsHitTestVisible = true; 149 150 if(callback != null) callback(); 151 }); 152 } 153 154 /// <summary> 155 /// 状態を初期化します。 156 /// </summary> 157 void InitState() { 158 editButton.IsEnabled = remButton.IsEnabled = false; 159 } 160 161 #endregion 162 163 private void UserControl_Loaded(object sender, RoutedEventArgs e) { LoadStudies(); } 80 164 81 165 private void HyperlinkButton_Click(object sender, RoutedEventArgs e) { … … 87 171 } 88 172 89 private void studyList_SelectionChanged(object sender, SelectionChangedEventArgs e) {90 editButton.IsEnabled = remButton.IsEnabled = e.AddedItems.Count > 0;91 }92 93 173 /// <summary> 94 174 /// [追加] … … 97 177 /// <param name="e"></param> 98 178 private void addButton_Click(object sender, RoutedEventArgs e) { 99 addStudyView.Show(); 179 AddStudyView.Show(); 180 } 181 private void AddStudyView_AddStudy(object sender, RoutedEventArgs e) { 182 var addView = (AddStudyView)sender; 183 184 StudyManager.AddStudy( 185 // 追加した後だけ、何故かボタンの描画がおかしくなるのでInitStateしておく。 186 addView.Title, study => LoadStudies(() => InitState()) 187 ); 188 } 189 190 /// <summary> 191 /// [編集] 192 /// </summary> 193 /// <param name="sender"></param> 194 /// <param name="e"></param> 195 private void editButton_Click(object sender, RoutedEventArgs e) { 196 var study = studyList.SelectedItem as Study; 197 198 if(study != null) { 199 StudyManager.GetStudy(study.Id, s => { 200 EditStudyView.Study = s; 201 EditStudyView.Show(); 202 }); 203 } 204 } 205 private void EditStudyView_UpdateStudy(object sender, RoutedEventArgs e) { 206 var study = ((EditStudyView)sender).Study; 207 208 StudyManager.UpdateStudy(study.Id, study.Title, s => LoadStudies()); 209 } 210 211 /// <summary> 212 /// [削除] 213 /// </summary> 214 /// <param name="sender"></param> 215 /// <param name="e"></param> 216 private void remButton_Click(object sender, RoutedEventArgs e) { 217 if(HtmlPage.Window.Confirm("本当に削除しますか?")) { 218 var study = (Study)studyList.SelectedItem; 219 220 StudyManager.RemoveStudy(study.Id, () => LoadStudies()); 221 } 222 } 223 224 private void studyList_SelectionChanged(object sender, SelectionChangedEventArgs e) { 225 editButton.IsEnabled = remButton.IsEnabled = e.AddedItems.Count > 0; 100 226 } 101 227 -
platform/silverlight/eLearn/trunk/eLearn/StudyManager.cs
r14610 r14717 26 26 using System.Xml.Linq; 27 27 using System.Net; 28 using System.Text; 28 29 using System.Linq; 30 using System.Windows.Browser; 29 31 using System.Collections.Generic; 30 32 using System.Diagnostics; … … 93 95 var wc = new WebClient(); 94 96 wc.DownloadStringCompleted += (s, e) => { 95 if(e.Error == null) { 97 // TODO エラー処理がまだ 98 if(e.Error == null && callback != null) { 96 99 var xml = XDocument.Parse(e.Result); 97 100 var studies = from study in xml.Descendants("study") 98 101 select new Study { 99 Id =(int)study.Attribute("id"),100 Title =(string)study.Attribute("title")102 Id = (int)study.Attribute("id"), 103 Title = (string)study.Attribute("title") 101 104 }; 102 105 103 if(callback != null)callback(new List<Study>(studies));106 callback(new List<Study>(studies)); 104 107 } 105 108 }; … … 112 115 /// <param name="id">Id</param> 113 116 /// <param name="callback">取得が完了した時に呼び出されるコールバック</param> 117 /// <exception cref="ArgumentException">引数が不正な時</exception> 114 118 public void GetStudy(int id, Action<Study> callback) { 119 #region ArgumentValidation 120 ArgumentValidation.CheckForGreaterEqualZero(id, "id"); 121 #endregion 122 115 123 var wc = new WebClient(); 116 124 wc.DownloadStringCompleted += (s, e) => { 117 if(e.Error == null) { 125 // TODO エラー処理がまだ 126 if(e.Error == null && callback != null) { 118 127 var xml = XDocument.Parse(e.Result); 119 128 var questions = from q in xml.Descendants("question") 120 select new Question(121 (string)q.Attribute("value"),122 from a in q.Descendants("answer")123 select new Answer {124 Value=(string)a.Attribute("value"),125 IsCorrect=(bool)a.Attribute("correct")126 }127 );129 select new Question( 130 (string)q.Attribute("value"), 131 from a in q.Descendants("answer") 132 select new Answer { 133 Value = (string)a.Attribute("value"), 134 IsCorrect = (bool)a.Attribute("correct") 135 } 136 ); 128 137 129 138 var study = new Study((string)xml.Root.Attribute("title"), questions) { 130 Id =(int)xml.Root.Attribute("id")139 Id = (int)xml.Root.Attribute("id") 131 140 }; 132 133 if(callback != null) callback(study); 141 callback(study); 134 142 } 135 143 }; … … 139 147 } 140 148 149 /// <summary> 150 /// 指定したタイトルで新しいスタディを追加します。 151 /// </summary> 152 /// <param name="title">タイトル</param> 153 /// <param name="callback">追加が完了した時に呼び出されるコールバック</param> 154 /// <returns>追加したスタディ情報</returns> 155 /// <exception cref="ArgumentException">引数が不正な時</exception> 156 /// <exception cref="ArgumentNullException">引数がnullの時</exception> 157 public void AddStudy(string title, Action<Study> callback) { 158 #region ArgumentValidation 159 ArgumentValidation.CheckForNullOrEmpty(title, "title"); 160 #endregion 161 162 var wc = new WebClient(); 163 wc.Encoding = Encoding.UTF8; 164 wc.Headers["content-type"] = "application/x-www-form-urlencoded"; 165 wc.UploadStringCompleted += (s, e) => { 166 // TODO エラー処理がまだ 167 if(e.Error == null && callback != null) { 168 var xml = XDocument.Parse(e.Result); 169 var study = new Study { 170 Id=(int)xml.Root.Attribute("id"), 171 Title=(string)xml.Root.Element("title") 172 }; 173 callback(study); 174 } 175 }; 176 wc.UploadStringAsync( 177 new Uri(RootUrl + "Study/New.aspx"), "POST", string.Format("title={0}", title) 178 ); 179 } 180 181 /// <summary> 182 /// 指定したIdのスタディの情報を更新します。 183 /// </summary> 184 /// <param name="id">Id</param> 185 /// <param name="title">タイトル</param> 186 /// <param name="callback">更新が完了した時に呼び出されるコールバック</param> 187 /// <exception cref="ArgumentException">引数が不正な時</exception> 188 /// <exception cref="ArgumentNullException">引数がnullの時</exception> 189 public void UpdateStudy(int id, string title, Action<Study> callback) { 190 #region ArgumentValidation 191 ArgumentValidation.CheckForGreaterEqualZero(id, "id"); 192 ArgumentValidation.CheckForNullOrEmpty(title, "title"); 193 #endregion 194 195 var wc = new WebClient(); 196 wc.Encoding = Encoding.UTF8; 197 wc.Headers["content-type"] = "application/x-www-form-urlencoded"; 198 wc.UploadStringCompleted += (s, e) => { 199 // TODO エラー処理がまだ 200 if(e.Error == null && callback != null) { 201 var xml = XDocument.Parse(e.Result); 202 var study = new Study { 203 Id = (int)xml.Root.Attribute("id"), 204 Title = (string)xml.Root.Element("title") 205 }; 206 callback(study); 207 } 208 }; 209 wc.UploadStringAsync( 210 new Uri(RootUrl + "Study/Update.aspx"), "POST", string.Format("id={0}&title={1}", id, title) 211 ); 212 } 213 214 /// <summary> 215 /// 指定したIdのスタディを削除します。 216 /// </summary> 217 /// <param name="id">スタディのId</param> 218 /// <param name="callback">削除が完了した時に呼び出されるコールバック</param> 219 /// <exception cref="ArgumentException">引数が不正な時</exception> 220 public void RemoveStudy(int id, Action callback) { 221 #region ArgumentValidation 222 ArgumentValidation.CheckForGreaterEqualZero(id, "id"); 223 #endregion 224 225 var wc = new WebClient(); 226 wc.DownloadStringCompleted += (s, e) => { 227 // TODO エラー処理がまだ 228 if(e.Error == null && callback != null) { 229 callback(); 230 } 231 }; 232 wc.DownloadStringAsync( 233 new Uri(RootUrl + string.Format("Study/Remove.aspx?id={0}", id)) 234 ); 235 } 236 237 /// <summary> 238 /// 指定したIdのスタディに指定した質問を追加します。 239 /// </summary> 240 /// <param name="id">Id</param> 241 /// <param name="question">質問</param> 242 /// <param name="callback">追加が完了した時に呼び出されるコールバック</param> 243 public void AddQuestion(int id, Question question, Action callback) { 244 #region ArgumentValidation 245 ArgumentValidation.CheckForGreaterEqualZero(id, "id"); 246 ArgumentValidation.CheckForNullReference(question, "question"); 247 #endregion 248 249 var ele = new XElement("question", 250 new XAttribute("value", question.Value) 251 ); 252 ele.Add(question.Answers.Select( 253 a => new XElement("answer", 254 new XAttribute("value", a.Value), 255 new XAttribute("correct", a.IsCorrect)) 256 ) 257 ); 258 var wc = new WebClient(); 259 wc.OpenWriteCompleted += (s, e) => { 260 // TODO エラー処理がまだ 261 if(e.Error == null) { 262 var buf = Encoding.UTF8.GetBytes(ele.ToString()); 263 264 e.Result.Write(buf, 0, buf.Length); 265 e.Result.Close(); 266 267 if(callback != null) callback(); 268 } 269 }; 270 wc.OpenWriteAsync( 271 new Uri(RootUrl + string.Format("Study/AddQuestion.aspx?id={0}", id)), "POST" 272 ); 273 } 274 275 /// <summary> 276 /// 指定したIdのスタディから指定した位置にある質問を削除します。 277 /// </summary> 278 /// <param name="id">Id</param> 279 /// <param name="index">質問の位置</param> 280 /// <param name="callback">削除が完了した時に呼び出されるコールバック</param> 281 public void RemoveQuestion(int id, int index, Action callback) { 282 #region ArgumentValidation 283 ArgumentValidation.CheckForGreaterEqualZero(id, "id"); 284 ArgumentValidation.CheckForGreaterEqualZero(index, "index"); 285 #endregion 286 287 var wc = new WebClient(); 288 wc.DownloadStringCompleted += (s, e) => { 289 // TODO エラー処理がまだ 290 if(e.Error == null && callback != null) { 291 callback(); 292 } 293 }; 294 wc.DownloadStringAsync( 295 new Uri(RootUrl + string.Format("Study/RemoveQuestion.aspx?id={0}&index={1}", id, index)) 296 ); 297 } 298 141 299 #endregion 142 300 -
platform/silverlight/eLearn/trunk/eLearn/StudyPage.xaml
r14610 r14717 2 2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 3 3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 4 xmlns:v="clr-namespace:eLearn.UI" >4 xmlns:v="clr-namespace:eLearn.UI" Loaded="UserControl_Loaded"> 5 5 6 6 <Grid x:Name="LayoutRoot" HorizontalAlignment="Left" VerticalAlignment="Top"> … … 14 14 15 15 <Grid Grid.Row="1"> 16 <StackPanel x:Name="hintPane" Visibility="Collapsed"> 17 <TextBlock Text="質問がまだありません。質問を追加して下さい。" /> 18 19 <Button x:Name="addButton" Width="100" Content="質問を追加する" 20 Margin="0,40,0,0" Click="addButton_Click" Style="{StaticResource Rich-Button}" /> 21 </StackPanel> 22 16 23 <v:QuestionView x:Name="questionView" 17 24 Next="questionView_Next" Visibility="Collapsed" /> -
platform/silverlight/eLearn/trunk/eLearn/StudyPage.xaml.cs
r14610 r14717 26 26 using System.Linq; 27 27 using System.Windows; 28 using System.Windows.Browser; 28 29 using System.Windows.Controls; 29 30 using System.Collections.Generic; 30 using System.Windows.Browser; 31 using System.Diagnostics; 32 33 using eLearn.UI; 31 34 32 35 #endregion … … 40 43 #region fields 41 44 42 private StudyManager studyMgr;45 private int studyId; 43 46 /// <summary> 44 47 /// 現在の質問 45 48 /// </summary> 46 49 private LinkedListNode<Question> currentQuestion; 50 51 private EditStudyView editView; 47 52 48 53 #endregion … … 58 63 } 59 64 65 /// <summary> 66 /// スタディ管理オブジェクトを取得、設定します。 67 /// </summary> 68 public StudyManager StudyManager { 69 get; 70 set; 71 } 72 73 /// <summary> 74 /// スタディ編集画面を取得します。 75 /// </summary> 76 private EditStudyView EditStudyView { 77 [DebuggerStepThrough] 78 get { 79 if(editView == null) { 80 editView = new EditStudyView { 81 Visibility=Visibility.Collapsed, 82 StudyManager = this.StudyManager 83 }; 84 editView.UpdateStudy += EditStudyView_UpdateStudy; 85 editView.AddQuestionView.AddQuestion += AddQuestionView_AddQuestion; 86 87 Grid.SetRowSpan(editView, 2); 88 89 LayoutRoot.Children.Add(editView); 90 } 91 return editView; 92 } 93 } 94 60 95 #endregion 61 96 … … 65 100 /// 表示するスタディのIdを設定するコンストラクタ 66 101 /// </summary> 67 /// <param name=" id">Id</param>68 public StudyPage(int id) {102 /// <param name="studyId">Id</param> 103 public StudyPage(int studyId) { 69 104 InitializeComponent(); 70 105 … … 80 115 RootUrl = rootUrl + "/"; 81 116 82 studyMgr = new StudyManager(RootUrl); 83 studyMgr.GetStudy(id, study => { 84 this.DataContext = study; 85 86 currentQuestion = new LinkedList<Question>(study.Questions).First; 87 88 ShowQuestion(); 89 }); 117 StudyManager = new StudyManager(RootUrl); 118 119 this.studyId = studyId; 90 120 } 91 121 … … 134 164 } 135 165 136 #endregion 137 138 void questionView_Next(object sender, RoutedEventArgs e) { NextQuestion(); } 166 /// <summary> 167 /// 指定したIdのスタディを実行します。 168 /// </summary> 169 /// <param name="study"></param> 170 void RunStudy(int studyId) { 171 StudyManager.GetStudy(studyId, study => { 172 this.DataContext = study; 173 174 if(study.Questions.Count > 0) { 175 currentQuestion = new LinkedList<Question>(study.Questions).First; 176 177 ShowQuestion(); 178 179 } else hintPane.Visibility = Visibility.Visible; 180 }); 181 } 182 183 #endregion 184 185 private void UserControl_Loaded(object sender, RoutedEventArgs e) { RunStudy(studyId); } 186 187 /// <summary> 188 /// [追加] 189 /// </summary> 190 /// <param name="sender"></param> 191 /// <param name="e"></param> 192 private void addButton_Click(object sender, RoutedEventArgs e) { 193 EditStudyView.Study = (Study)this.DataContext; 194 EditStudyView.Show(); 195 } 196 private void EditStudyView_UpdateStudy(object sender, RoutedEventArgs e) { 197 var study = ((EditStudyView)sender).Study; 198 199 StudyManager.UpdateStudy(study.Id, study.Title, s => RunStudy(s.Id)); 200 } 201 private void AddQuestionView_AddQuestion(object sender, RoutedEventArgs e) { 202 var study = EditStudyView.Study; 203 204 StudyManager.UpdateStudy(study.Id, study.Title, s => RunStudy(s.Id)); 205 } 206 207 private void questionView_Next(object sender, RoutedEventArgs e) { NextQuestion(); } 139 208 140 209 } -
platform/silverlight/eLearn/trunk/eLearn/UI/AddStudyView.xaml
r14667 r14717 1 1 <UserControl x:Class="eLearn.UI.AddStudyView" 2 2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> 4 5 <UserControl.Resources> 6 <Style x:Key="label" TargetType="TextBlock"> 7 <Setter Property="FontSize" Value="12" /> 8 <Setter Property="VerticalAlignment" Value="Center" /> 9 <Setter Property="HorizontalAlignment" Value="Center" /> 10 </Style> 3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 4 KeyDown="UserControl_KeyDown"> 5 6 <Grid x:Name="LayoutRoot"> 7 <Rectangle Style="{StaticResource Dialog-Filter}" /> 11 8 12 <Style x:Key="textBox" TargetType="TextBox"> 13 <Setter Property="Height" Value="22" /> 14 <Setter Property="Margin" Value="0,0,10,0" /> 15 </Style> 16 </UserControl.Resources> 17 18 <Grid x:Name="LayoutRoot"> 19 <Rectangle Fill="Silver" Opacity="0.2" /> 20 21 <Border Width="320" Height="95" CornerRadius="12" BorderBrush="Black" BorderThickness="2"> 22 <Border.Background> 23 <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> 24 <GradientStop Color="White" Offset="0" /> 25 <GradientStop Color="Silver" Offset="1" /> 26 </LinearGradientBrush> 27 </Border.Background> 28 9 <Border Width="320" Height="95" Style="{StaticResource Dialog-Border}"> 29 10 <Grid Margin="0,5,0,0"> 30 11 <Grid.ColumnDefinitions> … … 37 18 </Grid.RowDefinitions> 38 19 39 <TextBlock Text="タイトル" Style="{StaticResource label}" /> 40 <TextBox x:Name="titleInput" Grid.Column="1" Style="{StaticResource textBox}" /> 20 <TextBlock Text="タイトル" Style="{StaticResource Table-Label}" /> 21 <TextBox x:Name="titleInput" Grid.Column="1" 22 TextChanged="titleInput_TextChanged" Style="{StaticResource Table-Input}" /> 41 23 42 <StackPanel Grid.Row="1" Grid.ColumnSpan="2" Orientation="Horizontal" 43 Margin="0,0,0,6" HorizontalAlignment="Center" VerticalAlignment="Bottom"> 44 <Button x:Name="addButton" Content="追加" 45 Width="80" Margin="0,0,4,0" Click="addButton_Click" Style="{StaticResource button}" /> 24 <StackPanel Grid.Row="1" Grid.ColumnSpan="2" Style="{StaticResource Table-CommandPane}"> 25 <Button x:Name="addButton" Content="追加" IsEnabled="False" 26 Width="80" Margin="0,0,4,0" Click="addButton_Click" Style="{StaticResource Rich-Button}" /> 46 27 47 28 <Button x:Name="cancelButton" Content="Cancel" 48 Width="80" Margin="4,0,0,0" Click="cancelButton_Click" Style="{StaticResource button}" />29 Width="80" Margin="4,0,0,0" Click="cancelButton_Click" Style="{StaticResource Rich-Button}" /> 49 30 </StackPanel> 50 31 </Grid> -
platform/silverlight/eLearn/trunk/eLearn/UI/AddStudyView.xaml.cs
r14667 r14717 25 25 using System; 26 26 using System.Windows; 27 using System.Windows.Input; 27 28 using System.Windows.Controls; 28 29 using System.Diagnostics; … … 35 36 /// </summary> 36 37 public partial class AddStudyView : UserControl { 38 39 #region properties 40 41 /// <summary> 42 /// タイトルを取得、設定します。 43 /// </summary> 44 public string Title { 45 get { 46 return titleInput.Text; 47 } 48 set { 49 titleInput.Text = value; 50 } 51 } 52 53 #endregion 54 55 #region event 56 57 /// <summary> 58 /// スタディが追加された時に呼び出されます。 59 /// </summary> 60 public event RoutedEventHandler AddStudy; 61 /// <summary> 62 /// AddStudyイベントを呼び出します。 63 /// </summary> 64 /// <param name="e">イベント引数</param> 65 protected virtual void OnAddStudy(RoutedEventArgs e) { 66 if(AddStudy != null) AddStudy(this, e); 67 } 68 69 #endregion 37 70 38 71 #region constructors … … 60 93 } 61 94 95 /// <summary> 96 /// 画面を閉じます。 97 /// </summary> 98 [DebuggerStepThrough] 99 void Close() { 100 this.Visibility = Visibility.Collapsed; 101 } 102 62 103 #endregion 63 104 … … 68 109 /// <param name="e"></param> 69 110 private void addButton_Click(object sender, RoutedEventArgs e) { 111 OnAddStudy( 112 new RoutedEventArgs { Source = this } 113 ); 70 114 this.Visibility = Visibility.Collapsed; 71 115 } … … 77 121 /// <param name="e"></param> 78 122 private void cancelButton_Click(object sender, RoutedEventArgs e) { 79 this.Visibility = Visibility.Collapsed;123 Close(); 80 124 } 125 126 private void titleInput_TextChanged(object sender, TextChangedEventArgs e) { 127 addButton.IsEnabled = titleInput.Text.Trim().Length > 0; 128 } 129 130 private void UserControl_KeyDown(object sender, KeyEventArgs e) { if(e.Key == Key.Escape) Close(); } 81 131 82 132 } -
platform/silverlight/eLearn/trunk/eLearn/UI/FinishView.xaml
r14610 r14717 23 23 24 24 <Button x:Name="descButton" Grid.Row="2" Content="詳細情報" Width="100" FontSize="14" 25 VerticalAlignment="Top" Click="descButton_Click" Style="{StaticResource button}" />25 VerticalAlignment="Top" Click="descButton_Click" Style="{StaticResource Rich-Button}" /> 26 26 </Grid> 27 27 </Grid> -
platform/silverlight/eLearn/trunk/eLearn/UI/QuestionView.xaml
r14667 r14717 80 80 81 81 <StackPanel x:Name="answerPane" Grid.Row="1" Margin="6" VerticalAlignment="Center"> 82 <!-- 82 83 <RadioButton Content="テスト1" Style="{StaticResource radio}" /> 83 84 <RadioButton Content="テスト2" Style="{StaticResource radio}" /> 84 85 <RadioButton Content="テスト3" Style="{StaticResource radio}" /> 85 86 <RadioButton Content="テスト4" Style="{StaticResource radio}" /> 87 --> 86 88 </StackPanel> 87 89 88 90 <Grid Grid.Row="2"> 89 <Button x:Name="nextButton" Content="Next" Width="60" Margin="0,0,4,4" 90 HorizontalAlignment="Right" VerticalAlignment="Bottom" Click="nextButton_Click" Style="{StaticResource button}" /> 91 <Button x:Name="nextButton" Content="Next" Width="60" 92 Margin="0,0,4,4" HorizontalAlignment="Right" VerticalAlignment="Bottom" 93 Click="nextButton_Click" Style="{StaticResource Rich-Button}" /> 91 94 </Grid> 92 95 </Grid> -
platform/silverlight/eLearn/trunk/eLearn/UI/QuestionView.xaml.cs
r14610 r14717 25 25 using System; 26 26 using System.Windows; 27 using System.Windows.Data; 27 28 using System.Windows.Controls; 28 29 using System.Diagnostics; 29 using System.Windows.Data;30 30 31 31 #endregion … … 54 54 #endregion 55 55 56 #region fields57 58 private Question question;59 60 #endregion61 62 56 #region properties 63 57 58 /// <summary> 59 /// Question 60 /// </summary> 61 private static readonly DependencyProperty QuestionProperty = DependencyProperty.Register( 62 "Question", typeof(Question), typeof(QuestionView), 63 new PropertyMetadata((d, e) => ((QuestionView)d).OnQuestionChanged(e)) 64 ); 64 65 /// <summary> 65 66 /// 質問情報を取得、設定します。 66 67 /// </summary> 67 68 public Question Question { 68 get { return question; } 69 get { 70 return (Question)this.GetValue(QuestionProperty); 71 } 69 72 set { 70 var oldValue = this.question; 71 72 this.question = value; 73 74 if(oldValue != value) { 75 OnQuestionChanged(EventArgs.Empty); 76 } 73 this.SetValue(QuestionProperty, value); 77 74 } 78 75 } … … 113 110 /// </summary> 114 111 /// <param name="e"></param> 115 protected virtual void OnQuestionChanged(EventArgs e) {116 this.DataContext = this.Question;112 void OnQuestionChanged(DependencyPropertyChangedEventArgs e) { 113 this.DataContext = e.NewValue; 117 114 118 115 InitState(); -
platform/silverlight/eLearn/trunk/eLearn/eLearn.csproj
r14667 r14717 73 73 <Compile Include="StudyManager.cs" /> 74 74 <Compile Include="StudyResult.cs" /> 75 <Compile Include="UI\AddQuestionView.xaml.cs"> 76 <DependentUpon>AddQuestionView.xaml</DependentUpon> 77 </Compile> 75 78 <Compile Include="UI\AddStudyView.xaml.cs"> 76 79 <DependentUpon>AddStudyView.xaml</DependentUpon> 77 80 </Compile> 78 81 <Compile Include="UI\Data\QuestionConverter.cs" /> 82 <Compile Include="UI\EditStudyView.xaml.cs"> 83 <DependentUpon>EditStudyView.xaml</DependentUpon> 84 </Compile> 79 85 <Compile Include="UI\FinishView.xaml.cs"> 80 86 <DependentUpon>FinishView.xaml</DependentUpon> … … 97 103 <SubType>Designer</SubType> 98 104 </Page> 105 <Page Include="UI\AddQuestionView.xaml"> 106 <SubType>Page</SubType> 107 <Generator>MSBuild:MarkupCompilePass1</Generator> 108 </Page> 99 109 <Page Include="UI\AddStudyView.xaml"> 110 <SubType>Page</SubType> 111 <Generator>MSBuild:MarkupCompilePass1</Generator> 112 </Page> 113 <Page Include="UI\EditStudyView.xaml"> 100 114 <SubType>Page</SubType> 101 115 <Generator>MSBuild:MarkupCompilePass1</Generator> -
platform/silverlight/eLearn/trunk/eLearn_Web/App_Data/Repo/index.xml
r14610 r14717 1 <?xml version="1.0" encoding="utf-8" ?>1 <?xml version="1.0" encoding="utf-8"?> 2 2 <studies> 3 <study id="1" title="C# 基礎知識検定" />4 <study id="2" title="Silverlight 基礎知識検定" />3 <study id="1" title="C# 基礎知識検定" /> 4 <study id="2" title="Silverlight 基礎知識検定" /> 5 5 </studies> -
platform/silverlight/eLearn/trunk/eLearn_Web/Controllers/StudyController.cs
r14667 r14717 137 137 138 138 /// <summary> 139 /// 指定したIdのスタディの情報を更新します。 140 /// </summary> 141 /// <param name="id">Id</param> 142 /// <param name="title">タイトル</param> 143 /// <returns>スタディ情報</returns> 144 public ActionResult Update(int? id, string title) { 145 if(id == null || string.IsNullOrEmpty(title)) { 146 throw new HttpException((int)HttpStatusCode.BadRequest, "[id][title]を指定して下さい。"); 147 } 148 var indexXml = OpenIndex(); 149 var study = indexXml.Descendants("study") 150 .FirstOrDefault(s => (int)s.Attribute("id") == id.Value); 151 152 study.SetAttributeValue("title", title); 153 154 SaveIndex(indexXml); 155 156 var contentXml = OpenContent(id); 157 contentXml.Root.SetAttributeValue("title", title); 158 159 return Content( 160 SaveContent(contentXml, id).ToString(), "text/xml" 161 ); 162 } 163 164 /// <summary> 139 165 /// 指定したIdのスタディを削除します。 140 166 /// </summary> … … 146 172 } 147 173 var indexXml = OpenIndex(); 148 149 174 var study = indexXml.Descendants("study") 150 175 .FirstOrDefault(s => (int)s.Attribute("id") == id.Value); … … 157 182 SaveIndex(indexXml); 158 183 184 File.Delete( 185 Request.MapPath(string.Format(CONTENT_FILE_FORMAT, id)) 186 ); 159 187 return Content("0", "text/plain"); 160 188 } … … 166 194 /// <param name="content">質問内容を表すXML</param> 167 195 /// <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); 196 public ActionResult AddQuestion(int? id) { 197 if(id == null) { 198 throw new HttpException((int)HttpStatusCode.BadRequest, "[id]を指定して下さい。"); 199 } 200 Ele ele; 201 202 using(var sr = new StreamReader(Request.InputStream)) { 203 var content = sr.ReadToEnd(); 204 // TODO エラー処理がまだ 205 ele = XElement.Parse(content); 206 } 207 var contentXml = OpenContent(id); 208 contentXml.Root.Add(ele); 174 209 175 210 return Content( 176 SaveContent( xml, id).ToString(), "text/xml"211 SaveContent(contentXml, id).ToString(), "text/xml" 177 212 ); 178 213 } … … 193 228 .Where((q, i) => i == index) 194 229 .ToList().ForEach(q => q.Remove()); 195 196 return Content(197 SaveContent(contentXml, id).ToString(), "text/xml" 198 );230 231 SaveContent(contentXml, id); 232 233 return Content("0", "text/plain"); 199 234 } 200 235 -
platform/silverlight/eLearn/trunk/eLearn_Web/eLearn_Web.csproj.user
r14667 r14717 14 14 <SQLDebugging>False</SQLDebugging> 15 15 <PublishCopyOption>RunFiles</PublishCopyOption> 16 <PublishTargetLocation> ftp://www.coma2n.com/demo/eLearn/</PublishTargetLocation>16 <PublishTargetLocation>http://www.coma2n.com/demo/eLearn/</PublishTargetLocation> 17 17 <PublishDeleteAllFiles>False</PublishDeleteAllFiles> 18 18 <PublishCopyAppData>True</PublishCopyAppData>
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)