Skip to content

Instantly share code, notes, and snippets.

@pinzolo
pinzolo / gist:2814091
Created May 27, 2012 12:48
WPF再描画のためのDoEventsメソッド
using System.Windows.Threading;
/// <summary>
/// 現在メッセージ待ち行列の中にある全てのUIメッセージを処理します。
/// </summary>
private void DoEvents()
{
DispatcherFrame frame = new DispatcherFrame();
var callback = new DispatcherOperationCallback(obj =>
{
@pinzolo
pinzolo / gist:2814099
Created May 27, 2012 12:50
INotifyPropertyChanged 実装クラスのためのプロパティスニペット
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>propc</Title>
<Shortcut>propc</Shortcut>
<Description>INotifyPropertyChanged 用のプロパティとバッキング フィールド用のコード スニペット</Description>
<Author>pinzolo</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
@pinzolo
pinzolo / gist:2814250
Created May 27, 2012 13:40
独自イベント定義用コードスニペット
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>ev</Title>
<Shortcut>ev</Shortcut>
<Description>イベント用のコード スニペット</Description>
<Author>pinzolo</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
@pinzolo
pinzolo / gist:2814411
Created May 27, 2012 14:22
WPFでのファイル or ディレクトリのドラッグアンドドロップ処理
/// <summary>
/// DragOver イベント処理
/// </summary>
/// <param name="sender">イベント発生元</param>
/// <param name="e">イベント引数</param>
private void Window_DragOver(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
e.Effects = DragDropEffects.Copy;
@pinzolo
pinzolo / gist:2817083
Created May 28, 2012 03:40
WPFアプリケーションにおける集約例外処理
using System;
using System.Windows;
using System.Windows.Threading;
namespace MktSys.UI.Sample
{
/// <summary>
/// App.xaml の相互作用ロジック
/// </summary>
public partial class App : Application
@pinzolo
pinzolo / gist:2817715
Created May 28, 2012 06:41
特定のインターフェースを実装しているかどうかを調べる(ジェネリクス込)
// 基底クラス
public class Base {}
// サブクラス
public class SubClass : Base {}
// とあるクラス
public class Foo
{
// 実体は List だけど IEnumerable として公開
@pinzolo
pinzolo / gist:2946301
Created June 18, 2012 01:27
Object クラス拡張
using System;
namespace MktSys.Lib.Extensions
{
/// <summary>
/// Object 拡張メソッド定義クラス
/// </summary>
public static class ObjectExtension
{
/// <summary>
@pinzolo
pinzolo / gist:2947230
Created June 18, 2012 07:06
タブを非表示にしたタブコントロール
<Window x:Class="MktSys.Gui.NoHeaderTabItemWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="タブのない TabControl" Height="525" Width="300">
<Window.Resources>
<!--
フォーカスがあたらないように IsTabStop を False
LayoutTransFormで無理やりタブを非表示にする
-->
<Style x:Key="noHeaderTabItemStyle" TargetType="{x:Type TabItem}">
@pinzolo
pinzolo / gist:2947240
Created June 18, 2012 07:10
DataGrid に入力可能な ComboBox を配置する
<Window x:Class="MktSys.Gui.InputableDataGridComboBoxWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="DataGrid に入力可能な ComboBox を配置する" Height="525" Width="300">
<Grid>
<DataGrid Name="dataGrid" ItemsSource="{Binding Collection}" AutoGenerateColumns="False" CanUserAddRows="False">
<DataGrid.Columns>
<DataGridTemplateColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False" Header="タイプ">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
@pinzolo
pinzolo / gist:2951970
Created June 19, 2012 02:26
例外発生検査メソッド
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace MktSys.Test
{
/// <summary>
/// 独自 Assert クラス
/// </summary>
public static class AssertEx
{