Skip to content

Instantly share code, notes, and snippets.

View mfakane's full-sized avatar

mfakane mfakane

View GitHub Profile
@mfakane
mfakane / Equatable.cs
Created August 18, 2011 21:02
かんたん Equatable
using System;
using System.Linq;
namespace Ignition
{
public static class Equatable
{
public static int GetMemberwiseHashCode(object obj)
{
return obj.GetType().GetProperties()
using System;
namespace Ignition
{
partial class Extension
{
public static void TypeMatch<T1>(this object value, Action<T1> d1)
{
if (value is T1)
d1((T1)value);
@mfakane
mfakane / SortedNotifyCollection.cs
Created September 3, 2011 05:31
ソート済み通知コレクション
using System.Collections.Generic;
namespace Ignition.Collections
{
public class SortedNotifyCollection<T> : NotifyCollection<T>
{
public IComparer<T> Comparer
{
get;
set;
@mfakane
mfakane / DragDropBehavior.cs
Created September 6, 2011 09:51
ListBox などの項目のドラッグアンドドロップ移動のビヘイビア
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Windows;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Interactivity;
@mfakane
mfakane / gist:1230495
Created September 20, 2011 21:44
Async CTP の async/await による coroutine の簡易実装
using System;
using System.Reactive.Linq;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
var ctx = new CoroutineContext<int>();
@mfakane
mfakane / ApplicationBarIconButtonProxy.cs
Created October 28, 2011 15:40
Bindable な ApplicationBar プロキシ
using System;
using System.Windows;
using System.Windows.Input;
using Microsoft.Phone.Reactive;
using Microsoft.Phone.Shell;
namespace Slashboard.Views
{
public class ApplicationBarIconButtonProxy : FrameworkElement
{
@mfakane
mfakane / TurnstileTransition.cs
Created January 13, 2012 23:01
Silverlight Toolkit for Windows Phone に含まれる TurnstileTransition の回転の基準点がシステムと違い左端ぴったりで違和感があるのを補正
using System.Windows;
using System.Windows.Data;
using System.Windows.Media;
using Controls = Microsoft.Phone.Controls;
namespace Linearstar.Lavis.Presentation
{
public class TurnstileTransition : Controls.TransitionElement
{
Controls.TurnstileTransition inner = new Controls.TurnstileTransition();
@mfakane
mfakane / ObservableCollectionWrapper.cs
Last active September 29, 2015 17:41
M→VM 用コレクションラッパ
// usage:
//
// Model のコレクションの変化を自動的に反映する ViewModel コレクションを作成
// ObservableCollectionWrapper.Create(modelCollection, (Model m) => new ViewModel(m))
//
// 任意の ViewModel 側コレクションを Model コレクションに同期させる
// ViewModel コレクションへの操作を Model 側に反映させることもできる (Caliburn.Micro での Conductor の Items に使用するなど)
// ObservableCollectionWrapper.Create(modelCollection, viewModelCollection, (Model m) => new ViewModel(m), vm => vm.Model)
using System;
using System.Collections;
An implemention of WeakEvent pattern for WPF/Silverlight/Windows Phone
----
Using the Model-View-ViewModel pattern, you always need to keep your events clean when they are not used.
In example, if the object "Foo" handles an event, when you finished using the Foo and forgot to release the event handlers,
the event would keep grabbing references to the Foo. This means that a memory leak is happening.
This page would be helpful:
Weak Event Patterns
@mfakane
mfakane / Program.cs
Created April 4, 2012 16:43
XNA と MMDX をコンソールウィンドウで。
/*
* コンソールウィンドウで XNA をドライヴする
* MMDX を動かしてコンソールウィンドウ上に描画、または画像ファイルに出力
* ・XNA Windows Game を新規作成して、Game1.cs を消して、Program.cs にこれを突っ込む
* ・コンテントプロジェクトに任意のモデルと任意のモーションを追加 (既定ではモデルは Miku、モーションは TrueMyHeart となっているものを使用する)
*/
// tmp/ フォルダを作ってそこに png を出力する
// undef するとコンソールウィンドウ上に描画するだけ
#define RENDER_TO_FILE