private void HandleGroupIM(InstantMessageEventArgs e) { // Ignore group IM from a muted group if (null != client.Self.MuteList.Find(me => me.Type == MuteType.Group && (me.ID == e.IM.IMSessionID || me.ID == e.IM.FromAgentID))) { return; } if (TabExists(e.IM.IMSessionID.ToString())) { RadegastTab tab = Tabs[e.IM.IMSessionID.ToString()]; tab.Highlight(); return; } instance.MediaManager.PlayUISound(UISounds.IM); Control active = FindFocusedControl(instance.MainForm); GroupIMTabWindow imTab = AddGroupIMTab(e.IM.IMSessionID, Utils.BytesToString(e.IM.BinaryBucket)); imTab.TextManager.ProcessIM(e, true); Tabs[e.IM.IMSessionID.ToString()].Highlight(); active?.Focus(); }
/// <summary> /// Creates new IM tab if needed /// </summary> /// <param name="agentID">IM session with agentID</param> /// <param name="label">Tab label</param> /// <param name="makeActive">Should tab be selected and focused</param> /// <returns>True if there was an existing IM tab, false if it was created</returns> public bool ShowIMTab(UUID agentID, string label, bool makeActive) { if (instance.TabConsole.TabExists((client.Self.AgentID ^ agentID).ToString())) { if (makeActive) { instance.TabConsole.SelectTab((client.Self.AgentID ^ agentID).ToString()); } return(false); } if (makeActive) { instance.MediaManager.PlayUISound(UISounds.IMWindow); } else { instance.MediaManager.PlayUISound(UISounds.IM); } Control active = FindFocusedControl(instance.MainForm); instance.TabConsole.AddIMTab(agentID, client.Self.AgentID ^ agentID, label); if (makeActive) { instance.TabConsole.SelectTab((client.Self.AgentID ^ agentID).ToString()); } else { active?.Focus(); } return(true); }
private void ChangeActiveReviewPanel(Panel panel, Control controlToFocus = null) { _activeReviewPanel.Visible = false; _activeReviewPanel = panel; _activeReviewPanel.Visible = true; controlToFocus?.Focus(); }
/// <summary> /// Se ejecuta cuando la celda entra en modo edicion /// </summary> /// <history> /// [erosado] 08/08/2016 Created. /// </history> private void dtgGifts_PreparingCellForEdit(object sender, DataGridPreparingCellForEditEventArgs e) { //Sirve para agregar el Focus a las celdas Control ctrl = e.EditingElement as Control; ctrl?.Focus(); }
protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); var reset = e.NavigationMode == NavigationMode.New; var restore = e.NavigationMode == NavigationMode.Back; if (reset) { this.needResetView = true; } else if (restore) { this.needRestoreView = true; } this.VM = await GalleryVM.GetVMAsync((long)e.Parameter); Control restoreElement = null; var idx = this.VM.CurrentIndex; if (reset) { resetView(); } else if (restore) { var animation = ConnectedAnimationService.GetForCurrentView().GetAnimation("ImageAnimation"); if (animation != null) { var con = this.gv.ContainerFromIndex(idx); if (con != null) { animation.TryStart(con.Descendants <Image>().First()); } else { animation.Cancel(); } } } await Dispatcher.YieldIdle(); if (reset) { this.pv.Focus(FocusState.Programmatic); await Task.Delay(50); this.pv.SelectedIndex = 0; } else if (restore) { if (restoreElement == null) { restoreElement = (Control)this.gv.ContainerFromIndex(this.VM.CurrentIndex); } await Dispatcher.YieldIdle(); restoreElement?.Focus(FocusState.Programmatic); } }
void Element_FocusChangeRequested(object sender, VisualElement.FocusRequestArgs e) { if (e.Focus && Control != null) { Control?.Focus(); e.Result = true; } }
private void Dispatcher_AcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs args) { _lastFocusElement = FocusManager.GetFocusedElement() as Control; if (args.VirtualKey == VirtualKey.Menu && !args.KeyStatus.WasKeyDown) { _altHandled = false; } else if (args.KeyStatus.IsMenuKeyDown && args.KeyStatus.IsKeyReleased && !_altHandled) { _altHandled = true; string gestureKey = MapInputToGestureKey(args.VirtualKey); if (gestureKey == null) { return; } if (MenuItemInputGestureCache.ContainsKey(gestureKey)) { var cachedMenuItem = MenuItemInputGestureCache[gestureKey]; if (cachedMenuItem is MenuItem) { var menuItem = (MenuItem)cachedMenuItem; menuItem.ShowMenu(); menuItem.Focus(FocusState.Keyboard); } } } else if (args.VirtualKey == VirtualKey.Menu && args.KeyStatus.IsKeyReleased && !_altHandled) { _altHandled = true; if (!IsOpened) { if (_isLostFocus) { LostFocus -= Menu_LostFocus; Focus(FocusState.Programmatic); _lastFocusElementBeforeMenu = _lastFocusElement; _isLostFocus = false; if (AllowTooltip) { ShowSubItemToolTips(); } LostFocus += Menu_LostFocus; } else { _lastFocusElementBeforeMenu?.Focus(FocusState.Keyboard); } } } }
private static void ElementToFocusPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var button = d as ToggleButton; if (button == null) { return; } button.Click += (s, args) => { Control control = GetElementToFocus(button); control?.Focus(); }; }
void SetFocusOnUIParam(DataList g) { Control c = uiParams.Where(x => x.Key == g).SelectMany(x => x.Value).OfType <TextBox>().OrderBy(x => x.Parent?.Left).ThenBy(x => x.Left).FirstOrDefault(); if (c == null) { c = uiParams.Where(x => x.Key == g).SelectMany(x => x.Value).OfType <Control>().OrderBy(x => x.Parent?.Left).ThenBy(x => x.Left).FirstOrDefault(); c?.Select(); } else { ((TextBox)c).Select(0, 0); } c?.Focus(); }
/// <summary> /// Set the initial focus on the given control /// </summary> /// <param name="window">Childwindow for which the focus must be set</param> /// <param name="controlFocus">Control to set the focus on</param> public static void SetInitialFocus(this Window window, Control controlFocus) { var routedHandler = default(RoutedEventHandler); // set to null to prevent unassigned compiler error routedHandler = delegate { controlFocus.Focus(); var textBox = controlFocus as TextBox; if (null != textBox) { textBox.SelectAll(); } // unsubscribe after first execute window.GotFocus -= routedHandler; }; window.GotFocus += routedHandler; }
//-------------------------------------------------------------------------------- private void frmTaskDialog_Shown(object sender, EventArgs e) { if (CTaskDialog.PlaySystemSounds) { switch (_mainIcon) { case ESysIcons.Error: System.Media.SystemSounds.Hand.Play(); break; case ESysIcons.Information: System.Media.SystemSounds.Asterisk.Play(); break; case ESysIcons.Question: System.Media.SystemSounds.Asterisk.Play(); break; case ESysIcons.Warning: System.Media.SystemSounds.Exclamation.Play(); break; } } _focusControl?.Focus(); }
private void HandleConferenceIM(InstantMessageEventArgs e) { if (TabExists(e.IM.IMSessionID.ToString())) { RadegastTab tab = Tabs[e.IM.IMSessionID.ToString()]; tab.Highlight(); return; } instance.MediaManager.PlayUISound(UISounds.IM); Control active = FindFocusedControl(instance.MainForm); ConferenceIMTabWindow imTab = AddConferenceIMTab(e.IM.IMSessionID, Utils.BytesToString(e.IM.BinaryBucket)); Tabs[e.IM.IMSessionID.ToString()].Highlight(); imTab.TextManager.ProcessIM(e, true); active?.Focus(); }
private void cMyUserControl_Load(object sender, EventArgs e) { try { ParentForm.AcceptButton = AcceptButton; } catch { //not loaded } try { AutoFocus?.Focus(); } catch { //not loaded } }
/// <summary> /// setSiireJisseki /// データをグリッドビューに追加 /// </summary> private void setSiireJisseki() { // データ検索用 List <string> lstItem = new List <string>(); //年月日の日付フォーマット後を入れる用 string strYMDformat = ""; // 空文字判定(仕入先コード、型番、備考、伝票年月日) if (labelSet_Shiiresaki.CodeTxtText.Equals("") && txtKataban.Text.Equals("") && txtBikou.Text.Equals("") && txtCalendarYMDStart.Text.Equals("") && txtCalendarYMDEnd.Text.Equals("")) { // メッセージボックスの処理、項目が空の場合のウィンドウ(OK) BaseMessageBox basemessagebox = new BaseMessageBox(this, CommonTeisu.TEXT_INPUT, "条件を指定してください。 ", CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR); basemessagebox.ShowDialog(); labelSet_Shiiresaki.codeTxt.Focus(); return; } //仕入先チェック if (labelSet_Shiiresaki.chkTxtShiresaki()) { labelSet_Shiiresaki.Focus(); return; } //開始年月日がある場合 if (txtCalendarYMDStart.blIsEmpty() == true) { //日付フォーマット生成、およびチェック strYMDformat = txtCalendarYMDStart.chkDateDataFormat(txtCalendarYMDStart.Text); //開始年月日の日付チェック if (strYMDformat == "") { // メッセージボックスの処理、項目が日付でない場合のウィンドウ(OK) BaseMessageBox basemessagebox = new BaseMessageBox(this, CommonTeisu.TEXT_INPUT, "入力された日付が正しくありません。", CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR); basemessagebox.ShowDialog(); txtCalendarYMDStart.Focus(); return; } else { txtCalendarYMDStart.Text = strYMDformat; } } //初期化 strYMDformat = ""; //終了年月日がある場合 if (txtCalendarYMDEnd.blIsEmpty() == true) { //日付フォーマット生成、およびチェック strYMDformat = txtCalendarYMDEnd.chkDateDataFormat(txtCalendarYMDEnd.Text); //終了年月日の日付チェック if (strYMDformat == "") { // メッセージボックスの処理、項目が日付でない場合のウィンドウ(OK) BaseMessageBox basemessagebox = new BaseMessageBox(this, CommonTeisu.TEXT_INPUT, "入力された日付が正しくありません。", CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR); basemessagebox.ShowDialog(); txtCalendarYMDEnd.Focus(); return; } else { txtCalendarYMDEnd.Text = strYMDformat; } } // ビジネス層のインスタンス生成 D0690_SiireJissekiKakuninAS400_B siireB = new D0690_SiireJissekiKakuninAS400_B(); try { // 検索するデータをリストに格納 lstItem.Add(labelSet_Shiiresaki.CodeTxtText); lstItem.Add(txtCalendarYMDStart.Text); lstItem.Add(txtCalendarYMDEnd.Text); //lstItem.Add(txtKataban.Text); double dblKensaku = 0; string strUkata; if (!double.TryParse(txtKataban.Text, out dblKensaku)) { //そのまま確保 strUkata = txtKataban.Text; } else { //空白削除 strUkata = txtKataban.Text.Trim(); } //英字を大文字に strUkata = strUkata.ToUpper(); strUkata = strUkata.Replace(" ", ""); lstItem.Add(strUkata); lstItem.Add(txtBikou.Text); // 検索実行 DataTable dtSiireJissekiList = siireB.getSiireJissekiList(lstItem); // データテーブルからデータグリッドへセット gridSiireJisseki.DataSource = dtSiireJissekiList; if (dtSiireJissekiList.Rows.Count > 0) { for (int cnt = 0; cnt < gridSiireJisseki.RowCount; cnt++) { // 数量 decimal decSuuryo = decimal.Parse(gridSiireJisseki.Rows[cnt].Cells["数量"].Value.ToString()); // 金額・粗利 decimal decKingaku = decimal.Parse(gridSiireJisseki.Rows[cnt].Cells["仕入金額"].Value.ToString()); // 数量又は金額・粗利がマイナスの場合はフォントカラーを変更 if (decSuuryo < 0 || decKingaku < 0) { gridSiireJisseki.Rows[cnt].DefaultCellStyle.ForeColor = Color.Red; } } Control cNow = this.ActiveControl; cNow.Focus(); } } catch (Exception ex) { // エラーロギング new CommonException(ex); return; } return; }
private void Dispatcher_AcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs args) { if (Items.Count == 0) { return; } if (ControlHelpers.IsXamlRootAvailable && XamlRoot != null) { _lastFocusElement = FocusManager.GetFocusedElement(XamlRoot) as Control; } else { _lastFocusElement = FocusManager.GetFocusedElement() as Control; } if (args.KeyStatus.ScanCode != AltScanCode) { _onlyAltCharacterPressed = false; } if (args.VirtualKey == VirtualKey.Menu) { if (!IsOpened) { if (_isLostFocus) { if (_onlyAltCharacterPressed && args.KeyStatus.IsKeyReleased) { ((MenuItem)Items[0]).Focus(FocusState.Programmatic); if (!(_lastFocusElement is MenuItem)) { _lastFocusElementBeforeMenu = _lastFocusElement; } } if (AllowTooltip) { ShowMenuItemsToolTips(); } else { UnderlineMenuItems(); } if (args.KeyStatus.IsKeyReleased) { _isLostFocus = false; } } else if (args.KeyStatus.IsKeyReleased) { HideToolTip(); _lastFocusElementBeforeMenu?.Focus(FocusState.Keyboard); } } } else if ((args.KeyStatus.IsMenuKeyDown || !_isLostFocus) && args.KeyStatus.IsKeyReleased) { var gestureKey = MapInputToGestureKey(args.VirtualKey, !_isLostFocus); if (gestureKey == null) { return; } if (MenuItemInputGestureCache.ContainsKey(gestureKey)) { var cachedMenuItem = MenuItemInputGestureCache[gestureKey]; if (cachedMenuItem is MenuItem) { var menuItem = (MenuItem)cachedMenuItem; menuItem.ShowMenu(); menuItem.Focus(FocusState.Keyboard); } } } if (args.KeyStatus.IsKeyReleased && args.EventType == CoreAcceleratorKeyEventType.KeyUp) { _onlyAltCharacterPressed = true; _isLostFocus = true; HideToolTip(); } }
private void ShowDropDownControl (Control control, bool resizeable) { dropdown_form.Size = control.Size; control.Dock = DockStyle.Fill; if (resizeable) { dropdown_form.Padding = dropdown_form_padding; dropdown_form.Width += dropdown_form_padding.Right; dropdown_form.Height += dropdown_form_padding.Bottom; dropdown_form.FormBorderStyle = FormBorderStyle.Sizable; dropdown_form.SizeGripStyle = SizeGripStyle.Show; } else { dropdown_form.FormBorderStyle = FormBorderStyle.None; dropdown_form.SizeGripStyle = SizeGripStyle.Hide; dropdown_form.Padding = Padding.Empty; } dropdown_form.Controls.Add (control); dropdown_form.Width = Math.Max (ClientRectangle.Width - SplitterLocation - (vbar.Visible ? vbar.Width : 0), control.Width); dropdown_form.Location = PointToScreen (new Point (grid_textbox.Right - dropdown_form.Width, grid_textbox.Location.Y + row_height)); RepositionInScreenWorkingArea (dropdown_form); Point location = dropdown_form.Location; Form owner = FindForm (); owner.AddOwnedForm (dropdown_form); dropdown_form.Show (); if (dropdown_form.Location != location) dropdown_form.Location = location; System.Windows.Forms.MSG msg = new MSG (); object queue_id = XplatUI.StartLoop (Thread.CurrentThread); control.Focus (); while (dropdown_form.Visible && XplatUI.GetMessage (queue_id, ref msg, IntPtr.Zero, 0, 0)) { switch (msg.message) { case Msg.WM_NCLBUTTONDOWN: case Msg.WM_NCMBUTTONDOWN: case Msg.WM_NCRBUTTONDOWN: case Msg.WM_LBUTTONDOWN: case Msg.WM_MBUTTONDOWN: case Msg.WM_RBUTTONDOWN: if (!HwndInControl (dropdown_form, msg.hwnd)) CloseDropDown (); break; case Msg.WM_ACTIVATE: case Msg.WM_NCPAINT: if (owner.window.Handle == msg.hwnd) CloseDropDown (); break; } XplatUI.TranslateMessage (ref msg); XplatUI.DispatchMessage (ref msg); } XplatUI.EndLoop (Thread.CurrentThread); }
private void Dispatcher_AcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs args) { if (Items.Count == 0) { return; } _lastFocusElement = FocusManager.GetFocusedElement() as Control; if (args.VirtualKey == VirtualKey.Menu) { if (!IsOpened) { if (_isLostFocus) { ((MenuItem)Items[0]).Focus(FocusState.Programmatic); if (!(_lastFocusElement is MenuItem)) { _lastFocusElementBeforeMenu = _lastFocusElement; } if (AllowTooltip) { ShowMenuItemsToolTips(); } else { UnderlineMenuItems(); } if (args.KeyStatus.IsKeyReleased) { _isLostFocus = false; } } else if (!_isLostFocus && args.KeyStatus.IsKeyReleased) { if (AllowTooltip) { HideMenuItemsTooltips(); } else { RemoveUnderlineMenuItems(); } _lastFocusElementBeforeMenu?.Focus(FocusState.Keyboard); } } } else if ((args.KeyStatus.IsMenuKeyDown || !_isLostFocus) && args.KeyStatus.IsKeyReleased) { var gestureKey = MapInputToGestureKey(args.VirtualKey, !_isLostFocus); if (gestureKey == null) { return; } if (MenuItemInputGestureCache.ContainsKey(gestureKey)) { var cachedMenuItem = MenuItemInputGestureCache[gestureKey]; if (cachedMenuItem is MenuItem) { var menuItem = (MenuItem)cachedMenuItem; menuItem.ShowMenu(); menuItem.Focus(FocusState.Keyboard); } } } }