public MainWindow() { InitializeComponent(); DefaultTimer ti = this.timer.DataContext as DefaultTimer; OracleDataPager ds = this.DataContext as OracleDataPager; ti.Timer.Tick += new EventHandler(ds.EventHandler); }
// ページごとの件数が変更されたとき private static void OnPerPageChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { OracleDataPager oracleDataPager = obj as OracleDataPager; if (oracleDataPager != null) { oracleDataPager.ResetPageCount(); } }
// テーブル名 が変更されたときにデータをリセットする private static void OnTableChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { OracleDataPager oracleDataPager = obj as OracleDataPager; if (oracleDataPager != null) { oracleDataPager.Sql = "SELECT * FROM " + (String)e.NewValue; } }
// Sql が変更されたときに OracleDataAdapter を作成しなおす private static void OnSqlChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { OracleDataPager oracleDataPager = obj as OracleDataPager; if (oracleDataPager != null) { oracleDataPager.ResetCount(); oracleDataPager.Page = 1; oracleDataPager.ResetCursor(); oracleDataPager.FetchData(); } }
// ページが変更されたとき private static void OnPageChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { OracleDataPager oracleDataPager = obj as OracleDataPager; // 値の強制。。。。こうなの? if (oracleDataPager.Page < 1) { oracleDataPager.Page = 1; } if (oracleDataPager.Page > oracleDataPager.PageCount) { oracleDataPager.Page = oracleDataPager.PageCount; } if (oracleDataPager != null) { oracleDataPager.ResetCursor(); oracleDataPager.FetchData(); } }