Exemplo n.º 1
0
        protected override void OnKeyUp(KeyEventArgs e)
        {
            base.OnKeyUp(e);

            if (this.IsGetFKey == false)
            {
                return;
            }

            Utl_FunctionKey utlFunctionKey = null;

            switch (e.Key)
            {
            case Key.F1:
            case Key.F2:
            case Key.F3:
            case Key.F4:
            case Key.F5:
            case Key.F6:
            case Key.F7:
            case Key.F8:
            case Key.F9:
            case Key.F11:
            case Key.F12:
                utlFunctionKey = ExVisualTreeHelper.GetUtlFunctionKey(this);
                break;
            }

            switch (e.Key)
            {
            case Key.F1: this.FunctionKey_Click(utlFunctionKey.btnF1, e); break;

            case Key.F2: this.FunctionKey_Click(utlFunctionKey.btnF2, e); break;

            case Key.F3: this.FunctionKey_Click(utlFunctionKey.btnF3, e); break;

            case Key.F4: this.FunctionKey_Click(utlFunctionKey.btnF4, e); break;

            case Key.F5: this.FunctionKey_Click(utlFunctionKey.btnF5, e); break;

            case Key.F6: this.FunctionKey_Click(utlFunctionKey.btnF6, e); break;

            case Key.F7: this.FunctionKey_Click(utlFunctionKey.btnF7, e); break;

            case Key.F8: this.FunctionKey_Click(utlFunctionKey.btnF8, e); break;

            case Key.F9: this.FunctionKey_Click(utlFunctionKey.btnF9, e); break;

            //case Key.F10: btnF10_Click(null, e); break;
            case Key.F11: this.FunctionKey_Click(utlFunctionKey.btnF11, e); break;

            case Key.F12: this.FunctionKey_Click(utlFunctionKey.btnF12, e); break;

            default: break;
            }
        }
        public static void SetFunctionKeyEnabled(string strFunctionKeyName, bool enable, DependencyObject depObj)
        {
            DependencyObject obj = ExVisualTreeHelper.FindPerentChildWindow(depObj);

            if (obj == null)
            {
                obj = ExVisualTreeHelper.FindPerentPage(depObj);
                if (obj == null)
                {
                    return;
                }
            }

            Utl_FunctionKey utlKey = null;

            foreach (Utl_FunctionKey key in FindVisualChildren <Utl_FunctionKey>(obj))
            {
                utlKey = key;
                break;
            }
            if (utlKey == null)
            {
                return;
            }

            switch (strFunctionKeyName)
            {
            case "F1": utlKey.btnF1.IsEnabled = enable; break;

            case "F2": utlKey.btnF2.IsEnabled = enable; break;

            case "F3": utlKey.btnF3.IsEnabled = enable; break;

            case "F4": utlKey.btnF4.IsEnabled = enable; break;

            case "F5": utlKey.btnF5.IsEnabled = enable; break;

            case "F6": utlKey.btnF6.IsEnabled = enable; break;

            case "F7": utlKey.btnF7.IsEnabled = enable; break;

            case "F8": utlKey.btnF8.IsEnabled = enable; break;

            case "F9": utlKey.btnF9.IsEnabled = enable; break;

            case "F11": utlKey.btnF11.IsEnabled = enable; break;

            case "F12": utlKey.btnF12.IsEnabled = enable; break;

            default: break;
            }

            return;
        }
        public static void FoucsNextControlNoFocus(Control ctl)
        {
            ExPage page = (ExPage)ExVisualTreeHelper.FindPerentPage(ctl);

            if (page != null)
            {
                page.OnNextControl();
            }
            else
            {
                ExChildWindow _win = (ExChildWindow)ExVisualTreeHelper.FindPerentChildWindow(ctl);
                if (_win != null)
                {
                    _win.OnNextControl();
                }
            }
        }
Exemplo n.º 4
0
        private void OnEndControlFocus()
        {
            ExUserControl utl = (ExUserControl)ExVisualTreeHelper.FindPerentUserControl(this);

            if (utl == null)
            {
                return;
            }
            Control ctl = ExVisualTreeHelper.SearchControlForTag(utl, "End");

            if (ctl == null)
            {
                return;
            }
            this.CommitEdit();
            ExBackgroundWorker.DoWork_Focus(ctl, 10);
            ExBackgroundWorker.DoWork_Focus(ctl, 100);
        }
Exemplo n.º 5
0
        public void MoveNextCell()
        {
            DataGridColumn currentcol = this.CurrentColumn;

            // 現在のカラムが最大かどうか
            bool isLastCol = (currentcol.DisplayIndex == this.Columns.Count - 2);

            if (!isLastCol)
            {
                // 編集を終了して次へ
                this.CommitEdit();
                if (IsMinusIndex == true)
                {
                    int before_selectedIndex = this.SelectedIndex;
                    if (before_selectedIndex >= 1)
                    {
                        this.SelectedIndex = before_selectedIndex - 1;
                    }
                }
                this.CurrentColumn = this.Columns[currentcol.DisplayIndex + 1];
                this.BeginEdit();
            }
            else
            {
                int nextIndex = this.SelectedIndex + 1;

                if (this.ItemsSource is ICollection)
                {
                    ICollection lists = (ICollection)this.ItemsSource;
                    if (nextIndex <= (lists.Count - 1))
                    {
                        this.CurrentColumn = this.Columns[0];
                        this.SelectedIndex = nextIndex;
                    }
                    else
                    {
                        ExUserControl utl = (ExUserControl)ExVisualTreeHelper.FindPerentUserControl(this);
                        utl.btnF7_Click(null, null);
                        return;
                    }
                }
            }
            this.ScrollIntoView(this.CurrentItem, this.CurrentColumn);
        }
        public static ExUserControl GetMainUserControlForWindow(DependencyObject depObj)
        {
            DependencyObject obj = ExVisualTreeHelper.FindPerentChildWindow(depObj);

            if (obj == null)
            {
                return(null);
            }

            foreach (ExUserControl utl in FindVisualChildren <ExUserControl>(obj))
            {
                if (utl.Tag.ToString() == "Main")
                {
                    return(utl);
                }
            }

            return(null);
        }
        public static void SetMode(Utl_FunctionKey.geFunctionKeyEnable mode, DependencyObject depObj)
        {
            DependencyObject obj = ExVisualTreeHelper.FindPerentChildWindow(depObj);

            if (obj == null)
            {
                obj = ExVisualTreeHelper.FindPerentPage(depObj);
                if (obj == null)
                {
                    return;
                }
                else
                {
                    Grid dg = ExVisualTreeHelper.FindGrid(obj, "GirdMenu");
                    if (dg != null)
                    {
                        if (dg.Visibility == Visibility.Visible)
                        {
                            return;
                        }
                    }
                }
            }

            Utl_Mode utlKey = null;

            foreach (Utl_Mode utlMode in FindVisualChildren <Utl_Mode>(obj))
            {
                utlMode.Mode = mode;
                break;
            }

            if (mode == Utl_FunctionKey.geFunctionKeyEnable.Sel)
            {
                SetEnabled(obj, false);
            }
            else
            {
                SetEnabled(obj, true);
            }

            return;
        }
        public static Utl_FunctionKey GetUtlFunctionKey(DependencyObject depObj)
        {
            bool search = false;

            int cnt = 1;

            while (cnt <= 10)
            {
                System.Threading.Thread.Sleep(cnt * 100);
                cnt += 1;

                search = false;

                DependencyObject obj = ExVisualTreeHelper.FindPerentChildWindow(depObj);
                if (obj == null)
                {
                    obj = ExVisualTreeHelper.FindPerentPage(depObj);
                    if (obj != null)
                    {
                        search = true;
                    }
                }
                else
                {
                    search = true;
                }

                if (search == true)
                {
                    Utl_FunctionKey utlKey = null;
                    foreach (Utl_FunctionKey key in FindVisualChildren <Utl_FunctionKey>(obj))
                    {
                        return(key);
                    }
                }
            }

            return(null);
        }
Exemplo n.º 9
0
        // 次コントロールフォーカス移動
        public void OnNextControl()
        {
            try
            {
                if (this.listDisplayTabIndex == null)
                {
                    return;
                }
                if (this.listDisplayTabIndex.Count == 0)
                {
                    return;
                }

                // 現在フォーカスがあるコントロールを取得
                Control ctl = (Control)FocusManager.GetFocusedElement();
                if (ctl == null)
                {
                    return;
                }

                // DatePickerTextBoxの場合、親を取得
                if (ctl is System.Windows.Controls.Primitives.DatePickerTextBox)
                {
                    try
                    {
                        DependencyObject obj  = VisualTreeHelper.GetParent(ctl);
                        Control          ctl2 = (Control)VisualTreeHelper.GetParent(obj);
                        if (ctl2 is System.Windows.Controls.DatePicker)
                        {
                            ctl = ctl2;
                        }
                    }
                    catch
                    {
                    }
                }

                // UserControlタイプの場合
                if (ctl.Name == "txtID" || ctl.Name == "txtBindID")
                {
                    DependencyObject obj = (DependencyObject)ctl;
                    ExUserControl    utl = (ExUserControl)ExVisualTreeHelper.FindPerentUserControl((DependencyObject)ctl);

                    if (utl == null)
                    {
                        return;
                    }
                    if (utl.Tag == null)
                    {
                        return;
                    }
                    if (utl.Tag.ToString().Length == 0)
                    {
                        return;
                    }
                    if (utl.Tag.ToString().IndexOf("TabSearchOn") == -1)
                    {
                        return;
                    }

                    ctl = utl;
                }

                string tag = ExVisualTreeHelper.GetTagDisplayTabIndex(this.listDisplayTabIndex, ctl.Name);
                if (tag.IndexOf("End") == -1)
                {
                    // 次のコントロールを取得
                    Control ctlNext = null;
                    ctlNext = ExVisualTreeHelper.GetNextDisplayTabIndexCtl(this.listDisplayTabIndex, ctl.Name);
                    if (ctlNext == null)
                    {
                        return;
                    }
                    if (ctlNext.IsTabStop == false)
                    {
                        return;
                    }
                    ExBackgroundWorker.DoWork_Focus(ctlNext, 10);
                }
                else
                {
                    // データグリッドを取得
                    ExDataGrid dg = null;
                    dg = ExVisualTreeHelper.FindDataGrid(this);
                    if (dg == null)
                    {
                        return;
                    }
                    ExBackgroundWorker.DoWork_DataGridSelectedFirst(dg, 10);
                }

                //ctlNext.Focus();

                IsEnterKeyDown = true;
            }
            catch
            {
            }
        }
Exemplo n.º 10
0
        protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            base.OnMouseLeftButtonDown(e);

            bool _flg = false;

            try
            {
                DateTime dtNow = DateTime.Now;

                // 前回ミリ秒設定有り時
                if (intBeforeHour != 0 || intBeforeMinute != 0 || intBeforeSecond != 0 || intBeforeMilliSecond != 0)
                {
                    // 今回ミリ秒取得
                    int intHour        = dtNow.Hour;
                    int intMinute      = dtNow.Minute;
                    int intSecond      = dtNow.Second;
                    int intMilliSecond = dtNow.Millisecond;

                    // 時間間隔取得
                    TimeSpan ts       = new TimeSpan(0, intHour, intMinute, intSecond, intMilliSecond);
                    TimeSpan tsBefore = new TimeSpan(0, intBeforeHour, intBeforeMinute, intBeforeSecond, intBeforeMilliSecond);
                    TimeSpan diff     = tsBefore - ts;
                    double   dbl      = ExCast.zCDbl(diff.Duration().ToString().Replace(":", ""));

                    // 初期化
                    intBeforeHour        = 0;
                    intBeforeMinute      = 0;
                    intBeforeSecond      = 0;
                    intBeforeMilliSecond = 0;

                    // マウスダウンの時間間隔が0.5秒以内
                    if (dbl <= 0.5)
                    {
                        OnMouseDoubleClick(this, e);
                        _flg = true;
                    }
                }
                else
                {
                    // 前回時刻設定
                    intBeforeHour        = dtNow.Hour;
                    intBeforeMinute      = dtNow.Minute;
                    intBeforeSecond      = dtNow.Second;
                    intBeforeMilliSecond = dtNow.Millisecond;
                }

                if (this._IsDataGridSelectCell && _flg == false)
                {
                    ExDataGrid dg = (ExDataGrid)ExVisualTreeHelper.FindPerentDataGrid(this);
                    if (dg != null)
                    {
                        dg.SelectedCell(ExCast.zCInt(this.DataGridRecNo), this.DataGridSelectedColumnIndex);
                        //ExBackgroundWorker.DoWork_DataGridSelectCell(dg, ExCast.zCInt(this.DataGridRecNo) - 1, this.DataGridSelectedColumnIndex);
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 11
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            switch (e.Key)
            {
            case Key.Enter:

                #region DataForm

                ExDataForm _df = (ExDataForm)ExVisualTreeHelper.FindPerentDataForm(this);
                if (_df != null)
                {
                    ExUserControl _utl = (ExUserControl)ExVisualTreeHelper.FindPerentUserControl(this);

                    #region DataForm EstimateDetail

                    Utl_DataFormEstimate utlEstimate = null;
                    try
                    {
                        utlEstimate = (Utl_DataFormEstimate)_utl;
                    }
                    catch
                    {
                    }
                    if (utlEstimate != null)
                    {
                        if (Keyboard.Modifiers == ModifierKeys.Shift)
                        {
                            utlEstimate.OnBeforeControl();
                            e.Handled = true;
                            return;
                        }
                        else
                        {
                            utlEstimate.OnNextControl();
                            e.Handled = true;
                            return;
                        }
                    }

                    #endregion

                    #region DataForm OrderDetail

                    Utl_DataFormOrder utlOrder = null;
                    try
                    {
                        utlOrder = (Utl_DataFormOrder)_utl;
                    }
                    catch
                    {
                    }
                    if (utlOrder != null)
                    {
                        if (Keyboard.Modifiers == ModifierKeys.Shift)
                        {
                            utlOrder.OnBeforeControl();
                            e.Handled = true;
                            return;
                        }
                        else
                        {
                            utlOrder.OnNextControl();
                            e.Handled = true;
                            return;
                        }
                    }

                    #endregion

                    #region DataForm SalesDetail

                    Utl_DataFormSales utlSales = null;
                    try
                    {
                        utlSales = (Utl_DataFormSales)_utl;
                    }
                    catch
                    {
                    }
                    if (utlSales != null)
                    {
                        if (Keyboard.Modifiers == ModifierKeys.Shift)
                        {
                            utlSales.OnBeforeControl();
                            e.Handled = true;
                            return;
                        }
                        else
                        {
                            utlSales.OnNextControl();
                            e.Handled = true;
                            return;
                        }
                    }

                    #endregion
                }

                #endregion

                #region DataGrid

                ExDataGrid _dg = (ExDataGrid)ExVisualTreeHelper.FindPerentDataGrid(this);
                if (_dg != null)
                {
                    if (Keyboard.Modifiers == ModifierKeys.Shift)
                    {
                        //_dg.MoveBeforeCell();
                        e.Handled = true;
                        return;
                    }
                    else
                    {
                        //_dg.MoveNextCell();
                        e.Handled = true;
                        return;
                    }
                }

                #endregion

                #region Page

                ExPage _page = (ExPage)ExVisualTreeHelper.FindPerentPage(this);
                if (_page != null)
                {
                    if (Keyboard.Modifiers == ModifierKeys.Shift)
                    {
                        _page.OnBeforeControl();
                        e.Handled = true;
                        return;
                    }
                    else
                    {
                        _page.OnNextControl();
                        e.Handled = true;
                        return;
                    }
                }

                #endregion

                #region ChildWindow

                ExChildWindow _win = (ExChildWindow)ExVisualTreeHelper.FindPerentChildWindow(this);
                if (_win != null)
                {
                    if (Keyboard.Modifiers == ModifierKeys.Shift)
                    {
                        _win.OnBeforeControl();
                        e.Handled = true;
                        return;
                    }
                    else
                    {
                        _win.OnNextControl();
                        e.Handled = true;
                        return;
                    }
                }

                #endregion

                break;
            }

            base.OnKeyDown(e);
        }