Skip to content

Instantly share code, notes, and snippets.

View Grabacr07's full-sized avatar
🏠
Working from home

Manato Kameya Grabacr07

🏠
Working from home
View GitHub Profile
@Grabacr07
Grabacr07 / HideSystemMenuBehavior.cs
Created May 25, 2012 19:48
http://grabacr.net/archives/208 に張ったコードをそのまま。ただのテストですよ?
using System;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Interactivity;
using System.Windows.Interop;
namespace SystemMenuSample
{
public class HideSystemMenuBehavior : Behavior<Window>
{
@Grabacr07
Grabacr07 / XmlSerializableDictionary`2.cs
Last active December 30, 2015 13:59
昔何かを参考にして作ったやつ。 設定ファイル用に、System.Xml.Serialization.XmlSerializer で保存/復元するためのもの。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using System.Xml.Serialization;
using System.Xml.Schema;
namespace Grabacr07.Utilities.Data.Xml
{
/// <summary>
A「煙草吸ってもよろしいですか?」
B「どうぞ。ところで一日に何本くらいお吸いに?」
A「ふた箱くらいですね」
B「喫煙年数はどれくらいですか?
A「30 年くらいですね」
B「なるほど。あそこにベンツが停まってますね」
A「停まってますね」
B「もしあなたが煙草を吸わなければ」
C「ちくわ大明神 (@kurosawa0626)」
B「あれくらい買えたんですよ」
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Interop;
@Grabacr07
Grabacr07 / DragAndDropSample.cs
Last active November 30, 2018 23:02
@hivesbee 誕生日おめでとう
public partial class MainWindow : Window
{
/// <summary>
/// D&D の軌跡のコレクションのコレクション。
/// </summary>
private readonly List<List<Point>> points = new List<List<Point>>();
public MainWindow()
{
InitializeComponent();
@Grabacr07
Grabacr07 / TimerBehavior.cs
Last active August 29, 2015 13:56
TextBlock をタイマーにするやつ。何も設定しなければ、1 秒ごとにアタッチ先 TextBlock.Text に現在時刻を設定する。Interval プロパティで更新頻度、Proc プロパティで更新時に TextBlock.Text に出力する内容を指定できる。
/// <summary>
/// <see cref="TextBlock"/> にタイマー機能を付与します。
/// </summary>
public class TimerBehavior : Behavior<TextBlock>
{
private DispatcherTimer timer;
#region Interval 依存関係プロパティ
/// <summary>
<StackPanel x:Name="LayoutRoot"
Background="White">
<TextBlock FontFamily="Segoe UI Light">
<Run Text="RepeatButton Sample "
FontSize="20" />
<Run Text="(Silverlight)"
FontSize="16" />
</TextBlock>
<StackPanel Orientation="Horizontal">
<StackPanel x:Name="LayoutRoot"
Background="White">
<TextBlock FontFamily="Segoe UI Light">
<Run Text="ToggleButton Sample "
FontSize="20" />
<Run Text="(Silverlight)"
FontSize="16" />
</TextBlock>
@Grabacr07
Grabacr07 / ScrollBar.template.xaml
Last active August 29, 2015 13:57
ScrollBar の標準テンプレート (の抜粋)
<Grid x:Name="Bg"
SnapsToDevicePixels="true">
<Grid.ColumnDefinitions>
<ColumnDefinition MaxWidth="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarButtonWidthKey}}" />
<ColumnDefinition Width="0.00001*" />
<ColumnDefinition MaxWidth="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarButtonWidthKey}}" />
</Grid.ColumnDefinitions>
<Border BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
static class Extensions
{
public static IEnumerable<T[]> ふぁぼツバめそっど<T>(this IEnumerable<T> source, Func<T, bool> predicate)
{
var buffer = new List<T>();
foreach (var value in source)
{
if (predicate(value))
{