Skip to content

Instantly share code, notes, and snippets.

@biac
biac / Downloader1.cs
Created November 27, 2012 00:08
WP8 で WebRequest を使うとき、GetResponse() を await したいよね!
private static Task<WebResponse> GetResponseAsync(WebRequest request)
{
return Task.Run<WebResponse>(() =>
{
AutoResetEvent autoResetEvent = new AutoResetEvent(false);
// BeginGetResponse で autoResetEvent を発火させる
IAsyncResult asyncResult = request.BeginGetResponse(r => autoResetEvent.Set(), null);
// autoResetEvent.Set() の発火を待つ。すなわちここでブロックする
@biac
biac / 参加者.cs
Created June 11, 2012 09:29
Kujian - 参加者.cs (Create 時に並びをランダムにする)
public static IList<参加者> Create()
{
// …前略
}).ToList();
int count = list.Count;
var rnd = new Random();
for (int i = 0; i < count; i++)
{
int src = rnd.Next(0, count);
@biac
biac / SplitPage.xaml.cs
Created June 11, 2012 09:13
Kujian - SplitPage.xaml.cs (STOP ボタン)
private async void Button_Click_2(object sender, RoutedEventArgs e)
{
_isContinue = false;
while (!_isBreaking)
await Task.Delay(50);
itemListView.Background = new SolidColorBrush(Colors.DarkGray);
int remain = 5000;
@biac
biac / SplitPage.xaml.cs
Created June 11, 2012 09:07
Kujian - SplitPage.xaml.cs (START ボタン)
private void Button_Click_1(object sender, RoutedEventArgs e)
{
itemListView.Background = backButton.Background;
Rotate();
}
private bool _isContinue;
private bool _isBreaking;
@biac
biac / SampleDataSource.cs
Created June 11, 2012 08:35
Kujian - DataModel/SampleDataSource (変更前)
public SampleDataSource()
{
String ITEM_CONTENT = String.Format("Item Content: {0}\n\n{0}\n\n{0}\n\n{0}\n\n{0}\n\n{0}\n\n{0}",
"Curabitur class …中略…");
var group1 = new SampleDataGroup("Group-1",
"Group Title: 1",
"Group Subtitle: 1",
"Assets/DarkGray.png",
"Group Description: Lorem ipsum …中略… ante a ante");
@biac
biac / SplitPage.xaml.cs
Created June 11, 2012 09:20
Kujian - SplitPage.xaml.cs (NEXT ボタン)
private void NextButton_Click_1(object sender, RoutedEventArgs e)
{
itemListView.Background = backButton.Background;
var selected = itemListView.SelectedItem as Kujian.Data.SampleDataItem;
var dataGroup = itemListView.DataContext as Kujian.Data.SampleDataGroup;
dataGroup.Items.Remove(selected);
}
@biac
biac / SampleDataSource.cs
Created June 11, 2012 08:40
Kujian - DataModel/SampleDataSource (変更後)
public SampleDataSource()
{
String ITEM_CONTENT = String.Format("Item Content: {0}\n\n{0}\n\n{0}\n\n{0}\n\n{0}\n\n{0}\n\n{0}",
"Curabitur class …中略…");
var group1 = new SampleDataGroup("Group-1",
"くじ庵", //"Group Title: 1",
"Group Subtitle: 1",
"Assets/DarkGray.png",
"Group Description: Lorem ipsum …中略… ante a ante");
@biac
biac / gist:2909056
Created June 11, 2012 08:20
Kujian - ボタンを追加
<Grid Grid.Column="1" x:Name="ControlGrid" >
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Button x:Name="StartButton" Content="START" Click="Button_Click_1" />
<Button x:Name="StopButton" Content="STOP" Click="Button_Click_2" Grid.Column="1" />
<Button x:Name="NextButton" Content="Next" Click="NextButton_Click_1" Grid.Column="2" />
@biac
biac / gist:2909045
Created June 11, 2012 08:16
Kujian - データテンプレートを持ってきて修正
<DataTemplate x:Key="DataTemplate1">
<Grid Height="Auto" Margin="6" Opacity="{Binding DataContext.Content, RelativeSource={RelativeSource Mode=Self}}" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border Background="{StaticResource ListViewItemPlaceholderBackgroundThemeBrush}" Width="110" Height="110"
VerticalAlignment="Center" >
<Image Source="{Binding Image}" Stretch="UniformToFill"/>
</Border>
@biac
biac / 参加者.cs
Created June 11, 2012 07:38
Kujian - 参加者.cs
public class 参加者
{
private const string OriginalData = @"…略(約40人分)…";
public string Name { get; set; }
public string ImageUrl { get; set; }
public static IList<参加者> Create()
{
XName img = XName.Get("img");