Changeset 9961
- Timestamp:
- 04/20/08 11:31:49 (5 years ago)
- Location:
- platform/silverlight/Todo/trunk/src
- Files:
-
- 2 added
- 11 modified
-
Todo/App.xaml (modified) (1 diff)
-
Todo/App.xaml.cs (modified) (2 diffs)
-
Todo/Controls/CoolButton.xaml (added)
-
Todo/Controls/CoolButton.xaml.cs (added)
-
Todo/Controls/ItemListBox.xaml (modified) (1 diff)
-
Todo/Controls/ItemListBox.xaml.cs (modified) (2 diffs)
-
Todo/Controls/NumericUpDown.xaml.cs (modified) (1 diff)
-
Todo/Page.xaml (modified) (1 diff)
-
Todo/Page.xaml.cs (modified) (5 diffs)
-
Todo/Todo.csproj (modified) (2 diffs)
-
Todo/Views/AddItemView.xaml (modified) (3 diffs)
-
Todo/Views/AddItemView.xaml.cs (modified) (6 diffs)
-
Todo_Web/Views/Home/Index.aspx (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
platform/silverlight/Todo/trunk/src/Todo/App.xaml
r9642 r9961 6 6 <Style x:Key="button" TargetType="Button"> 7 7 <Setter Property="Width" Value="70" /> 8 <Setter Property="Height" Value="28" />9 8 <Setter Property="Margin" Value="0,0,6,0" /> 10 <Setter Property="Template">11 <Setter.Value>12 <ControlTemplate TargetType="Button">13 <Border Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" CornerRadius="12"14 BorderBrush="Black" BorderThickness="1" Cursor="Hand">15 <Border.Background>16 <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">17 <GradientStop Color="Silver" Offset="0" />18 <GradientStop Color="Black" Offset="0.6" />19 <GradientStop Color="White" Offset="1" />20 </LinearGradientBrush>21 </Border.Background>22 23 <ContentPresenter Content="{TemplateBinding Content}" Foreground="White"24 HorizontalAlignment="Center" VerticalAlignment="Center" />25 </Border>26 </ControlTemplate>27 </Setter.Value>28 </Setter>29 9 </Style> 30 10 31 11 <Style x:Key="label" TargetType="TextBlock"> 32 12 <Setter Property="FontSize" Value="12" /> -
platform/silverlight/Todo/trunk/src/Todo/App.xaml.cs
r9625 r9961 30 30 31 31 namespace Todo { 32 /// <summary> 33 /// 34 /// </summary> 32 35 public partial class App : Application { 33 36 … … 48 51 49 52 private void Application_Startup(object sender, StartupEventArgs e) { 50 this.RootVisual = new Page { 51 AppBase = e.InitParams["appBase"] 52 }; 53 this.RootVisual = new Page(); 53 54 } 54 55 -
platform/silverlight/Todo/trunk/src/Todo/Controls/ItemListBox.xaml
r9712 r9961 4 4 5 5 <UserControl.Resources> 6 <ToolTip x: Key="tooltipTemplate">6 <ToolTip x:Name="tooltipTemplate"> 7 7 <ToolTip.Template> 8 8 <ControlTemplate TargetType="ToolTip"> -
platform/silverlight/Todo/trunk/src/Todo/Controls/ItemListBox.xaml.cs
r9712 r9961 45 45 /// </summary> 46 46 private DateTime lastClickTime = DateTime.MinValue; 47 48 /// <summary>49 /// ToolTipのテンプレート50 /// </summary>51 private readonly ToolTip tooltipTemplate;52 47 53 48 #endregion … … 130 125 public ItemListBox() { 131 126 InitializeComponent(); 132 133 tooltipTemplate = (ToolTip)this.Resources["tooltipTemplate"];134 127 } 135 128 -
platform/silverlight/Todo/trunk/src/Todo/Controls/NumericUpDown.xaml.cs
r9625 r9961 26 26 using System.Windows; 27 27 using System.Windows.Controls; 28 using System.Diagnostics; 28 29 29 30 #endregion -
platform/silverlight/Todo/trunk/src/Todo/Page.xaml
r9712 r9961 22 22 23 23 <StackPanel Margin="0,0,0,6" Orientation="Horizontal"> 24 <Button x:Name="addButton" Content="Add" 25 Style="{StaticResource button}" Click="addButton_Click" /> 26 <Button x:Name="delButton" Content="Delete" 24 <ctrl:CoolButton x:Name="addButton" Text="Add" 25 Style="{StaticResource button}" Click="addButton_Click" /> 26 27 <ctrl:CoolButton x:Name="delButton" Text="Delete" 27 28 Style="{StaticResource button}" Click="delButton_Click" /> 28 29 </StackPanel> -
platform/silverlight/Todo/trunk/src/Todo/Page.xaml.cs
r9712 r9961 33 33 using System.Windows.Controls; 34 34 using System.Collections.Generic; 35 using System.Globalization; 35 36 using System.Diagnostics; 36 37 37 38 using Todo.Views; 38 39 using Todo.Controls; 39 using System.Globalization;40 40 41 41 #endregion … … 66 66 public Page() { 67 67 InitializeComponent(); 68 69 var rootUrl = HtmlPage.Document.DocumentUri.ToString(); 70 71 var pos = rootUrl.LastIndexOf('/'); 72 // ケツから/までのURLを取得する。 73 // http://localhost:1100/ 74 // http://localhost:1100/Default.aspx 75 // ↑どちらの場合でも欲しいのは「http://localhost:1100/」 76 if(pos != -1) rootUrl = rootUrl.Substring(0, pos + 1); 77 78 AppBase = rootUrl; 68 79 } 69 80 … … 202 213 #endregion 203 214 204 private void UserControl_Loaded(object sender, RoutedEventArgs e) { LoadItems(); } 205 private void addButton_Click(object sender, RoutedEventArgs e) { 206 addItemView.Mode = EditMode.Add; 207 addItemView.Item = new Item(); 208 addItemView.Show(); 209 } 210 211 private void delButton_Click(object sender, RoutedEventArgs e) { 212 var selItem = itemList.SelectedItem; 213 214 if(selItem != null) { 215 if(HtmlPage.Window.Confirm("選択したアイテムを削除しますか?")) { 216 DeleteItem(selItem.Id, () => { 217 PrintMessage("アイテムを削除しました。"); 218 219 LoadItems(() => PrintMessage("アイテムの一覧を読み込みました。")); 220 }); 221 } 222 } 223 } 224 225 private void itemList_ItemCompleting(object sender, ItemCompletingEventArgs e) { 226 SetItem(e.Id, e.Complete, 227 () => PrintMessage(e.Complete ? "アイテムを完了しました。" : "アイテムを未完了にしました。") 228 ); 229 } 230 231 private void itemList_ItemDoubleClick(object sender, RoutedEventArgs e) { 232 var item = itemList.SelectedItem; 233 234 addItemView.Mode = EditMode.Update; 235 addItemView.Item = item; 236 addItemView.Show(); 237 } 238 239 private void addItemView_ItemAdd(object sender, RoutedEventArgs e) { 240 var item = addItemView.Item; 241 242 AddItem( 243 item.Title, item.Description, item.Date, item.Priority, 244 () => { 245 PrintMessage("アイテムを追加しました。"); 246 247 LoadItems(() => PrintMessage("アイテムの一覧を読み込みました。")); 248 } 249 ); 250 } 251 252 private void addItemView_ItemUpdate(object sender, RoutedEventArgs e) { 253 var item = addItemView.Item; 254 255 UpdateItem(item, () => { 256 PrintMessage("アイテムを更新しました。"); 257 258 LoadItems(() => PrintMessage("アイテムの一覧を読み込みました。")); 259 }); 260 } 215 #region handlers 216 217 private void UserControl_Loaded(object sender, RoutedEventArgs e) { LoadItems(); } 218 219 private void addButton_Click(object sender, RoutedEventArgs e) { 220 addItemView.Mode = EditMode.Add; 221 addItemView.Item = new Item(); 222 addItemView.Show(); 223 } 224 225 private void delButton_Click(object sender, RoutedEventArgs e) { 226 var selItem = itemList.SelectedItem; 227 228 if(selItem != null) { 229 if(HtmlPage.Window.Confirm("選択したアイテムを削除しますか?")) { 230 DeleteItem(selItem.Id, () => { 231 PrintMessage("アイテムを削除しました。"); 232 233 LoadItems(() => PrintMessage("アイテムの一覧を読み込みました。")); 234 }); 235 } 236 } 237 } 238 239 private void itemList_ItemCompleting(object sender, ItemCompletingEventArgs e) { 240 SetItem(e.Id, e.Complete, 241 () => PrintMessage(e.Complete ? "アイテムを完了しました。" : "アイテムを未完了にしました。") 242 ); 243 } 244 245 private void itemList_ItemDoubleClick(object sender, RoutedEventArgs e) { 246 var item = itemList.SelectedItem; 247 248 addItemView.Mode = EditMode.Update; 249 addItemView.Item = item; 250 addItemView.Show(); 251 } 252 253 private void addItemView_ItemAdd(object sender, RoutedEventArgs e) { 254 var item = addItemView.Item; 255 256 AddItem( 257 item.Title, item.Description, item.Date, item.Priority, 258 () => { 259 PrintMessage("アイテムを追加しました。"); 260 261 LoadItems(() => PrintMessage("アイテムの一覧を読み込みました。")); 262 } 263 ); 264 } 265 266 private void addItemView_ItemUpdate(object sender, RoutedEventArgs e) { 267 var item = addItemView.Item; 268 269 UpdateItem(item, () => { 270 PrintMessage("アイテムを更新しました。"); 271 272 LoadItems(() => PrintMessage("アイテムの一覧を読み込みました。")); 273 }); 274 } 275 276 #endregion 261 277 262 278 } … … 268 284 /// </summary> 269 285 static class HttpWebRequestExtension { 270 271 #region const272 273 /// <summary>274 /// 日付のフォーマットプロバイダー275 /// </summary>276 private static readonly DateTimeFormatInfo dtFormat = new CultureInfo("en-US").DateTimeFormat;277 278 #endregion279 286 280 287 #region methods … … 316 323 private static string Convert(this object value) { 317 324 if(value is DateTime) { 318 return ((DateTime)value).ToString("yyyy-MM-ddTHH:mm:ss", dtFormat);325 return ((DateTime)value).ToString("yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); 319 326 } 320 327 return value != null ? value.ToString() : string.Empty; -
platform/silverlight/Todo/trunk/src/Todo/Todo.csproj
r9625 r9961 62 62 <DependentUpon>App.xaml</DependentUpon> 63 63 </Compile> 64 <Compile Include="Controls\CoolButton.xaml.cs"> 65 <DependentUpon>CoolButton.xaml</DependentUpon> 66 </Compile> 64 67 <Compile Include="Controls\ItemListBox.xaml.cs"> 65 68 <DependentUpon>ItemListBox.xaml</DependentUpon> … … 103 106 </SilverlightPage> 104 107 </ItemGroup> 108 <ItemGroup> 109 <SilverlightPage Include="Controls\CoolButton.xaml"> 110 <Generator>MSBuild:CompileXaml</Generator> 111 </SilverlightPage> 112 </ItemGroup> 105 113 <Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight\v2.0\Microsoft.Silverlight.CSharp.targets" /> 106 114 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
platform/silverlight/Todo/trunk/src/Todo/Views/AddItemView.xaml
r9642 r9961 2 2 xmlns="http://schemas.microsoft.com/client/2007" 3 3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 4 xmlns:ctrl="clr-namespace:Todo.Controls"> 4 xmlns:ctrl="clr-namespace:Todo.Controls" 5 KeyDown="UserControl_KeyDown"> 5 6 6 7 <UserControl.Resources> 7 <Storyboard x: Key="titleErrorAnime">8 <Storyboard x:Name="titleErrorAnime"> 8 9 <DoubleAnimation From="0" To="2" Duration="0:0:0.5" RepeatBehavior="0:0:3" 9 10 Storyboard.TargetName="titleError" Storyboard.TargetProperty="StrokeThickness" /> … … 31 32 <StackPanel> 32 33 <TextBlock Text="重要度" Style="{StaticResource label}" /> 33 <ctrl:NumericUpDown x:Name="priorityInput" Height="2 0" Value="{Binding Priority, Mode=TwoWay}" Minimum="1" Maximum="5" />34 <ctrl:NumericUpDown x:Name="priorityInput" Height="25" Value="{Binding Priority, Mode=TwoWay}" Minimum="1" Maximum="5" /> 34 35 </StackPanel> 35 36 … … 55 56 56 57 <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center"> 57 < Button x:Name="addButton" Content="Add"58 <ctrl:CoolButton x:Name="addButton" Text="Add" 58 59 Style="{StaticResource button}" Click="addButton_Click" /> 59 60 60 < Button x:Name="updateButton" Content="Update"61 <ctrl:CoolButton x:Name="updateButton" Text="Update" 61 62 Style="{StaticResource button}" Click="updateButton_Click" /> 62 63 63 < Button x:Name="cancelButton" Content="Cancel"64 <ctrl:CoolButton x:Name="cancelButton" Text="Cancel" 64 65 Style="{StaticResource button}" Click="cancelButton_Click" /> 65 66 </StackPanel> -
platform/silverlight/Todo/trunk/src/Todo/Views/AddItemView.xaml.cs
r9642 r9961 25 25 using System; 26 26 using System.Windows; 27 using System.Windows.Input; 27 28 using System.Windows.Browser; 28 29 using System.Windows.Controls; 29 30 using System.Diagnostics; 30 using System.Windows.Media.Animation;31 31 32 32 #endregion … … 38 38 public partial class AddItemView : UserControl { 39 39 40 #region fields41 42 private Storyboard titleErrorAnime;43 44 #endregion45 46 40 #region properties 47 41 … … 120 114 public AddItemView() { 121 115 InitializeComponent(); 122 123 titleErrorAnime = (Storyboard)this.Resources["titleErrorAnime"];124 116 } 125 117 … … 174 166 #endregion 175 167 176 /// <summary> 177 /// [Add]ボタンがクリックされた時 178 /// </summary> 179 /// <param name="sender"></param> 180 /// <param name="e"></param> 181 private void addButton_Click(object sender, RoutedEventArgs e) { 168 #region handlers 169 170 /// <summary> 171 /// [Add]ボタンがクリックされた時 172 /// </summary> 173 /// <param name="sender"></param> 174 /// <param name="e"></param> 175 private void addButton_Click(object sender, RoutedEventArgs e) { 182 176 if(Validate()) { 183 177 OnItemAdd(new RoutedEventArgs { … … 186 180 Close(); 187 181 } 188 }189 190 /// <summary>191 /// [Update]ボタンがクリックされた時192 /// </summary>193 /// <param name="sender"></param>194 /// <param name="e"></param>195 private void updateButton_Click(object sender, RoutedEventArgs e) {182 } 183 184 /// <summary> 185 /// [Update]ボタンがクリックされた時 186 /// </summary> 187 /// <param name="sender"></param> 188 /// <param name="e"></param> 189 private void updateButton_Click(object sender, RoutedEventArgs e) { 196 190 if(Validate()) { 197 191 OnItemUpdate(new RoutedEventArgs { … … 200 194 Close(); 201 195 } 202 } 203 204 /// <summary> 205 /// [Cancel]ボタンがクリックされた時 206 /// </summary> 207 /// <param name="sender"></param> 208 /// <param name="e"></param> 209 private void cancelButton_Click(object sender, RoutedEventArgs e) { 210 Close(); 211 } 196 } 197 198 /// <summary> 199 /// [Cancel]ボタンがクリックされた時 200 /// </summary> 201 /// <param name="sender"></param> 202 /// <param name="e"></param> 203 private void cancelButton_Click(object sender, RoutedEventArgs e) { 204 Close(); 205 } 206 207 private void UserControl_KeyDown(object sender, KeyEventArgs e) { 208 if(e.Key == Key.Escape) Close(); 209 } 210 211 #endregion 212 212 213 213 } -
platform/silverlight/Todo/trunk/src/Todo_Web/Views/Home/Index.aspx
r9712 r9961 13 13 <asp:Silverlight ID="Silverlight1" runat="server" Version="2.0" 14 14 Height="100%" Width="100%" Source="~/ClientBin/Todo.xap" 15 InitParameters="appBase=http://:1100/"16 15 /> 17 16 </div>
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)