/// <summary> /// 画面閉じるときの最終イベント /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void WindowViewBase_Closed(object sender, EventArgs e) { this.Initialized -= WindowViewBase_Initialized; this.Closing -= WindowClosing; this.Closed -= WindowViewBase_Closed; this.Loaded -= WindowViewBase_Loaded; this.PreviewKeyDown -= Window_PreviewKeyDown; this.MouseLeftButtonDown -= (dummy, arg) => this.DragMove(); this.SetFreeForInput(); if (this.threadmgr != null) { this.threadmgr.Dispose(); } var ctls = ViewBaseCommon.FindLogicalChildList <FrameworkControl>(this, false); foreach (var ctl in ctls) { if (ctl.thmgr != null) { ctl.thmgr.Dispose(); ctl.thmgr = null; } } if (OnFinishWindowClosed != null) { OnFinishWindowClosed(this); } }
/// <summary> /// 画面初期化完了時に発生するイベント /// </summary> /// <param name="e">イベント引数</param> protected override void OnInitialized(EventArgs e) { base.OnInitialized(e); var datagrid = ViewBaseCommon.FindLogicalChildList <DataGrid>(this, false); foreach (var item in datagrid) { item.SelectionMode = DataGridSelectionMode.Single; } }
/// <summary> /// データ処理要求を送信する(複数の要求一括) /// </summary> /// <param name="comobjlist"></param> public void SendRequest(CommunicationObject[] comobjlist) { if (this.IsClosing) { return; } bool busy = false; lock (RequestList) { try { foreach (var comobj in comobjlist) { if (comobj.mType == MessageType.RequestLicense) { var plist = (NameValueCollection)ConfigurationManager.GetSection("serviceSettings"); comobj.connection = plist["common"]; } else { comobj.connection = this.ConnString; } if (comobj.mType == MessageType.RequestDataWithBusy) { if (!busy) { var prgrs = ViewBaseCommon.FindLogicalChildList <ProgressBar>(this); foreach (var item in prgrs) { item.IsEnabled = true; item.Visibility = System.Windows.Visibility.Visible; } this.SetBusyForInput(); busy = true; } } RequestList.Add(comobj.GetMessageName()); this.threadmgr.SendRequest(comobj); } } catch (Exception ex) { if (busy) { this.SetFreeForInput(); } } } }
private void OnResponseEmpty(CommunicationObject message /* 引数はダミー */) { if (message.mType == MessageType.ResponseWithFree || message.mType == MessageType.ErrorWithFree) { this.SetFreeForInput(); var prgrs = ViewBaseCommon.FindLogicalChildList <ProgressBar>(this); foreach (var item in prgrs) { item.IsEnabled = false; item.Visibility = System.Windows.Visibility.Collapsed; } } }
/// <summary> /// 画面がロードされたときに発生するイベント /// </summary> /// <param name="sender">イベント送信元</param> /// <param name="e">イベント引数</param> public virtual void WindowViewBase_Loaded(object sender, RoutedEventArgs e) { appLog.Info("<FW> ■ {0} Loaded", string.IsNullOrWhiteSpace(this.Title) ? this.GetType().Name : this.Title); //this.WindowStyle = System.Windows.WindowStyle.None; // WINDOWメッセージハンドリングが必要な場合 //HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle); //source.AddHook(new HwndSourceHook(WndProc)); foreach (var ctl in ViewBaseCommon.FindLogicalChildList <FrameworkControl>(this, false)) { ctl.ConnectStringUserDB = this.ConnString; } SetFocusToTopControl(); IsLoadFinished = true; }