/// <summary> /// 画面を閉じる時のイベント /// </summary> /// <param name="sender">イベント送信オブジェクト</param> /// <param name="e">イベントパラメータ</param> public void WindowClosing(object sender, System.ComponentModel.CancelEventArgs e) { this.IsClosing = true; ViewBaseCommon.WindowClosing(this); appLog.Info("<FW> □ {0} Closing", string.IsNullOrWhiteSpace(this.Title) ? this.GetType().Name : this.Title); }
/// <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); } }
private void WindowViewBase_Initialized(object sender, EventArgs e) { this.WindowTitle = base.Title; object appdata = null; if (this.Owner is WindowViewBase) { appdata = (this.Owner as WindowViewBase).viewsCommData.AppData; } else if (this.Owner is RibbonWindowViewBase) { appdata = (this.Owner as RibbonWindowViewBase).viewsCommData.AppData; } if (this.viewsCommData == null) { this.viewsCommData = new ViewsCommon(appdata); this.viewsCommData.Initialize(); } threadmgr = new ThreadManeger(this.viewsCommData.DacConf, this.appLog); threadmgr.Name = this.GetType().Name; threadmgr.OnReceived += new MessageReceiveHandler(OnReceived); ViewBaseCommon.SetConfigToControls(this, this.viewsCommData); functionList.Add(MessageType.ResponseData, this.OnReceivedResponseData); functionList.Add(MessageType.Error, this.OnReveivedError); functionList.Add(MessageType.ResponseStored, this.OnReceivedResponseStored); functionList.Add(MessageType.ResponseWithFree, this.OnReceivedResponseData); functionList.Add(MessageType.ErrorWithFree, this.OnReveivedError); functionList.Add(MessageType.TimerLoop, this.OnReceivedTimer); funckeyInitialize(); }
/// <summary> /// マスターメンテナンス画面の呼び出しを行う /// </summary> /// <param name="mntwndTypes">マスター種別の一覧</param> public static void CallMasterMainte(Dictionary <string, List <Type> > mntwndTypes) { UcLabelTwinTextBox twintextbox = ViewBaseCommon.GetCurrentTwinText(); if (twintextbox == null) { return; } if (mntwndTypes == null) { return; } try { var wndtp = mntwndTypes.Where(x => x.Key == twintextbox.DataAccessName).FirstOrDefault(); if ((wndtp.Value is List <Type>) != true) { return; } Type tp = (wndtp.Value as List <Type>)[0]; if (tp == null) { return; } WindowMasterMainteBase mstmnt = Activator.CreateInstance(tp) as WindowMasterMainteBase; var wnd = Window.GetWindow(twintextbox); mstmnt.ShowDialog(wnd); } catch (Exception ex) { throw ex; } }
/// <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> //キーボードで押下されたkeyはここで拾えます //PreviewKeyDown="Window_PreviewKeyDown"をxamlのwindowプロパティに追加 //</summary> /// <param name="sender">イベント発生オブジェクト</param> /// <param name="e">イベント引数</param> private void Window_PreviewKeyDown(object sender, KeyEventArgs e) { if (IsRenderFinished != true) { e.Handled = true; return; } this.ErrorMessage = string.Empty; ViewBaseCommon.CallFunctionKeyMethod(this, sender, e, this.funckeymethodlist); }
/// <summary> /// データ受信イベント /// </summary> /// <param name="message"></param> public void OnReceived(CommunicationObject message) { appLog.Debug("<FW> {0} Received {1}({2})", this.GetType().Name, message.mType, message.GetMessageName()); lock (RequestList) { RequestList.Remove(message.GetMessageName()); } Dispatcher.Invoke(new ReceivedDelegate(OnResponseEmpty), message); ViewBaseCommon.OnReceived(message, Dispatcher, this.functionList); }
/// <summary> /// Window内のValidatorプロパティを持つ全項目をチェックする。 /// </summary> /// <returns>true:全項目OK、false:チェックNG項目あり</returns> public bool CheckAllValidation(bool setfocustop = false) { this.ErrorMessage = ViewBaseCommon.CheckAllValidation(this, setfocustop); if (string.IsNullOrWhiteSpace(this.ErrorMessage)) { return(true); } else { return(false); } }
/// <summary> /// マスター検索画面の呼び出しを行う /// </summary> /// <param name="wnd">呼び出し元Window</param> /// <param name="srchwndTypeList">マスター種別の一覧</param> public static void CallMasterSearch(Window wnd, Dictionary <string, List <Type> > srchwndTypeList) { UcLabelTwinTextBox twintextbox = ViewBaseCommon.GetCurrentTwinText(); if (twintextbox == null) { return; } if (srchwndTypeList == null) { return; } try { var wndtp = srchwndTypeList.Where(x => x.Key == twintextbox.DataAccessName).FirstOrDefault(); if ((wndtp.Value is List <Type>) != true) { return; } Type tp = (wndtp.Value as List <Type>)[1]; if (tp == null) { return; } if (tp.BaseType != typeof(WindowMasterSearchBase)) { ViewBaseException ex = new ViewBaseException(string.Format("{0}がWindowMasterSearchBaseの派生クラスではないため処理できません。", tp)); throw ex; } twintextbox.BeforeCode = twintextbox.Text1; WindowMasterSearchBase mstsrch = Activator.CreateInstance(tp) as WindowMasterSearchBase; mstsrch.TwinTextBox = twintextbox; if (mstsrch.ShowDialog(wnd) == true) { twintextbox.AfterCode = twintextbox.Text1; // 検索結果を選択して閉じられた場合、該当するTwinTextboxにPreviewKeyDownイベントを送信する。 IInputElement element = Keyboard.FocusedElement; var s = PresentationSource.FromDependencyObject(element as DependencyObject); var eventArgs = new KeyEventArgs(Keyboard.PrimaryDevice, s, (int)System.DateTime.Now.Ticks, Key.Enter); eventArgs.RoutedEvent = Keyboard.PreviewKeyDownEvent; InputManager.Current.ProcessInput(eventArgs); eventArgs.RoutedEvent = Keyboard.PreviewKeyUpEvent; InputManager.Current.ProcessInput(eventArgs); } } catch (Exception ex) { throw ex; } }
/// <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; }
/// <summary> /// Windowを入力可能にする(マウスカーソルを戻す) /// </summary> public void SetFreeForInput() { ViewBaseCommon.SetFreeForInput(this); }
/// <summary> /// Windowを入力不可にする(マウスカーソルを砂時計にする) /// </summary> public void SetBusyForInput() { ViewBaseCommon.SetBusyForInput(this); }
/// <summary> /// Window内のValidationのチェック結果を全てリセットする。 /// </summary> public void ResetAllValidation() { ViewBaseCommon.ResetAllValidation(this); }
/// <summary> /// 指定されたカラム及びRowの情報からDataGridのCellを取得する /// </summary> /// <param name="col">DataGridのColumn情報</param> /// <param name="grow">DataGridのRowオブジェクト</param> /// <returns>検索結果</returns> public DataGridCell GetDataGridCell(DataGridColumn col, DataGridRow grow) { return(ViewBaseCommon.GetDataGridCell(col, grow)); }
/// <summary> /// DataGridのCellの値チェック結果(NG)をセットする /// </summary> /// <param name="cell"></param> public void SetInvalidDataGridCell(DataGridCell cell) { ViewBaseCommon.SetInvalidDataGridCell(cell); }
/// <summary> /// DataGridから指定されたタイプの要素をもつCellを検索する /// </summary> /// <typeparam name="T">検索対象のコントロールタイプ</typeparam> /// <param name="cell">DataGridのCellオブジェクト</param> /// <returns>検索結果</returns> public List <T> FindUIElementListInDataGridCell <T>(DataGridCell cell) where T : FrameworkElement { return(ViewBaseCommon.FindUIElementListInDataGridCell <T>(cell)); }
/// <summary> /// 指定されたコントロールの内側に存在するDataGridを探し、そのDataGridRowを取得する /// </summary> /// <param name="curctl">検索対象コントロール</param> /// <returns>検索結果</returns> public DataGridRow GetDataGridRow(object curctl) { return(ViewBaseCommon.GetDataGridRow(curctl as DependencyObject)); }
/// <summary> /// エラー受信時の処理 /// </summary> /// <param name="message"></param> public virtual void OnReveivedError(CommunicationObject message) { this.ErrorMessage = ViewBaseCommon.OnReveivedError(message, this.viewsCommData); }
/// <summary> /// 現在フォーカスのあるDataGridを取得する /// </summary> /// <param name="curctl">検索対象コントロール</param> /// <returns>検索結果</returns> public DataGrid GetCurrentDataGrid(object curctl) { return(ViewBaseCommon.GetCurrentDataGrid(curctl as DependencyObject)); }
/// <summary> /// フォーカスを先頭のコントロールに移動する /// </summary> /// <returns>true:移動した、false:移動していない</returns> public bool SetFocusToTopControl() { return(ViewBaseCommon.SetFocusToTopControl(this)); }
/// <summary> /// DataGridCellのマウスクリックイベントの処理(Cellのフォーカス移動を強制する) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void DataGridCell_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { ViewBaseCommon.DataGridCell_PreviewMouseLeftButtonDown(sender, e); }
/// <summary> /// 親Panelが非表示の場合、子コントロールを非表示にする /// </summary> public void ChangePanelVisibility() { ViewBaseCommon.ChangePanelVisibility(this, Visibility.Visible); }
/// <summary> /// 接続文字列のセットアップ /// </summary> /// <param name="server">サーバー名</param> /// <param name="db">Database名</param> /// <param name="user">ユーザ名</param> /// <param name="passwd">パスワード</param> public void SetupConnectStringuserDB(string server, string db, string user, string passwd) { ViewBaseCommon.SetupConnectStringuserDB(this, server, db, user, passwd); }
/// <summary> /// キー項目としてマークされた項目の入力可否を切り替える /// </summary> /// <param name="flag">true:入力可、false:入力不可</param> public void ChangeKeyItemChangeable(bool flag) { ViewBaseCommon.ChangeKeyItemChangeable(flag, this); }