wpf DragDrop FileList
wpf DragDrop
ポイント 1. Window でAllowSrop=“True” 2. PreviewDragOverとDropイベント使用
Window x:Class="DragFromExplorerSample.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:my="clr-namespace:DragFromExplorerSample" Title="MainWindow" Height="350" Width="525" AllowDrop="True" Drop="Window_Drop" PreviewDragOver="Window_PreviewDragOver"> <Window.DataContext> <my:MyFileList /> </Window.DataContext> <Grid> <ListBox HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ItemsSource="{Binding FileNames}" /> </Grid> </Window>
using System.Collections.ObjectModel; using System.Windows; namespace DragFromExplorerSample { /// <summary> /// MainWindow.xaml の相互作用ロジック /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void Window_Drop(object sender, DragEventArgs e) { MyFileList list = this.DataContext as MyFileList; string[] files = e.Data.GetData(DataFormats.FileDrop) as string[]; if (files != null) { foreach (var s in files) list.FileNames.Add(s); } } private void Window_PreviewDragOver(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop, true)) e.Effects = DragDropEffects.Copy; else e.Effects = DragDropEffects.None; e.Handled = true; } } public class MyFileList { public MyFileList() { FileNames = new ObservableCollection<string>(); } public ObservableCollection<string> FileNames { get; private set; } } }
参考
盛岡
8/14 盛岡にて
途中に泊まった盛岡。わんこそば、冷麺、じゃじゃ麺と麺ばかりが有名な町。軽く飲んだ後に、名物という事で初めて食べたじゃじゃ麺は、なるほど、他には無く、独自性あり。味噌とにんにく等を自分で混ぜて食べるのだが、食卓に調味料が在るので、それぞれの好みで追加できる。酢とにんにくを増量して食べてみたが、中々美味しい。
翌日、駅で冷やし蕎麦を食べたが、東京と違い蕎麦が黒目で腰があって、これも美味い。山の中で期待していなかったのが功を奏したのか、盛岡の食は中々行けそう。次に来た時は、焼肉と冷麺を試してみたい。
因みに、シンプリシティ盛岡菜園は今一。バスルームの匂いが合わない。傷も所々にあり、ちょっと。
Windows LBFO チーミング
Windows チーミング
Win2012R2以降に実装されたOS標準のチーミング機能。
- LBFO : Load Balance and Fail Over
チーミングモードは3つ
- LACP動的
- LAG 静的
- スイッチに依存しない
スタンバイアダプター
- 個別に指定
- 全てアクティブ
負荷分散モード(送信)
- 動的
- アドレスハッシュモード
- IPアドレス、PowerShell設定
- MACアドレス,PowerShell設定
- Hyper-Vポートモード
制限など
スイッチに依存しない
チーミングモードがスイッチに依存しない場合の動作。
補足
タグVLANを使った仮想NICをメンバーとするチーミングが出来ないのが残念。
チーミングメンバーの中でタグVLANを構成できるが、その場合、受信パケットが固定的にプライマリ物理NICとなり、負荷分散が出来ない。
スイッチ冗長構成で、複数スイッチにまたがるLACPができる=スタックできるスイッチが高価なので、スタック出来ないスイッチでスイッチ冗長、かつ、負荷分散するとなるとVLANが不可欠なのだが。
参考
以上
WPF Window Tree列挙
Window要素を列挙、探索
LogicalTreeHelperクラスのGetChildren()メソッドを使う。
public static IEnumerae LogicalTreeHelper.GetChildren(DependencyObject current)
戻り値は、IEnumerable
パラメーター - current Type: System.Windows.DependencyObject The object from which to start processing the logical tree. This is expected to be either a FrameworkElement or FrameworkContentElement. - 戻り値 Type: System.Collections.IEnumerable The enumerable collection of immediate child objects from the logical tree of the specified object.
public static class DependencyObjectExtension { /// <summary> /// WalkInChildrenメソッドの本体 /// </summary> /// <param name="obj">DependencyObject</param> /// <param name="act">Action</param> private static void Walk(DependencyObject obj, Action<DependencyObject> act) { foreach (var child in LogicalTreeHelper.GetChildren(obj)) { if (child is DependencyObject) { act(child as DependencyObject); Walk(child as DependencyObject, act); } } } /// <summary> /// 子オブジェクトに対してデリゲートを実行する /// </summary> /// <param name="obj">this : DependencyObject</param> /// <param name="act">デリゲート : Action</param> public static void WalkInChildren(this DependencyObject obj, Action<DependencyObject> act) { if (act == null) throw new ArgumentNullException(); Walk(obj, act); } }
親オブジェクト探索
LogicalTreeHelper.GetParent(DepandencyObject)
名前探索
探索方法
- 名前探索 FindName()
- 子を全て列挙 GetChildren()
- ルートウインドウ探索 GetParent()の繰り返し。
- 所属エレメント列挙 GetParent()でルートを見つけてGetChildren()
- 所属エレメント列挙、ルートの名前が分かっている FindName(ルートの名前)でルートを見つけてGetChildren()で列挙。
参考
- http://msdn.microsoft.com/ja-jp/library/ms598654(v=vs.110).aspx
- http://qiita.com/hugo-sb/items/4347214669a99cd2c775
- https://msdn.microsoft.com/ja-jp/library/system.windows.logicaltreehelper(v=vs.110).aspx
- Visual Tree Logical tree - xaml Visual tree - 更に内部の要素を含める http://blog.xin9le.net/entry/2013/10/29/222336
溝の口、盛岡ラーメン
盛岡ラーメン/醤油が売りのお店で何故かニラ松府麺700円。 松府麺ソーフーメンは550なので、ニラが150円。因みに、盛岡醤油らーめんが670円、多分。
さて、どんなのが出てくるかな。
武蔵新城
今日は武蔵新城に寄ってみる。通過した事はあっても、降りるのは初めて。とりあえず、喫茶店探しから。
北口
とんかつ千代勝 松屋 CoCo壱番屋 Seiyu らぁめん花月 東秀 立ち食い蕎麦屋 少し西側に行くと ミニストップ みずほ銀行 東京三菱 大戸屋 文教堂書店 モスバーガー ツルハドラッグ 餃子の王将 新城西通商店街 中に、中華喜楽 セブンイレブン
南
串カツでんがな ジョナサン 大庄水産 ケーキ屋さん 居酒屋庄屋 ドトール マクドナルド アコム ローソン
とりあえず、一旦締め。
南西側の商店街に居酒屋多数あり、この辺りなら呑むのに困らない。とんかつ屋が多いのが不思議なものの、住みやすいかもしれない。