コード例 #1
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            bool runTests = false;

            if (runTests)
            {
                if (e.KeyData == Keys.T)
                {
                    // Let's run some style tests.
                    GridStyleInfo style = new GridStyleInfo();
                    MessageBox.Show(style.ToString("d"), "Empty Style");

                    MessageBox.Show(GridStyleInfo.Default.ToString(), "GridStyleInfo.Default.ToString()");

                    MessageBox.Show(Model.TableStyle.ToString(), "TableStyle.ToString()");
                    MessageBox.Show(Model.TableStyle.ToString("d"), "TableStyle.ToString(\"d\")");

                    MessageBox.Show(Model[1, 1].ToString(), "Model[1, 1].ToString()");
                    MessageBox.Show(Model[1, 1].ToString("d"), "Model[1, 1].ToString(\"d\")");

                    MessageBox.Show(Model.RowStyles[1].ToString(), "RowStyles[1].ToString()");
                    MessageBox.Show(Model.RowStyles[1].ToString("d"), "RowStyles[1].ToString(\"d\")");

                    string        t          = Model.TableStyle.ToString();
                    GridStyleInfo parseStyle = new GridStyleInfo();
                    parseStyle.ParseString(t);
                    MessageBox.Show(parseStyle.ToString(), "parseStyle.ToString()");
                }

                if (e.KeyData == Keys.F1)
                {
                    // TODO: hangs when you change base style in property grid.
                    StyleInfoForm form = new StyleInfoForm(Model.ColStyles[1]);
                    form.ShowDialog();
                    Refresh();
                }

                if (e.KeyData == Keys.F3)
                {
                    CurrentCell.MoveTo(5, 4, GridSetCurrentCellOptions.SetFocus);
                    return;
                }

                if (e.KeyData == Keys.F4)
                {
                    // TODO: hangs when you change base style in property grid.
                    StyleInfoForm form = new StyleInfoForm(Model[0, 0]);
                    form.ShowDialog();
                    Refresh();
                }

                if (e.KeyData == Keys.F5)
                {
                    Model.Selections.Clear();
                }

                if (e.KeyData == Keys.F6)
                {
                    Model.Selections.Add(GridRangeInfo.Cells(2, 2, 10, 4));
                }
#if !NETCORE
                if (e.KeyData == Keys.M)
                {
                    // TODO: Show Default value for base style in property grid
                    GridBaseStyleCollectionEditor      ce  = new GridBaseStyleCollectionEditor(typeof(GridBaseStylesMap));
                    WindowsFormsEditorServiceContainer esc = new WindowsFormsEditorServiceContainer(null);
                    PropertyDescriptor    pd  = TypeDescriptor.GetProperties(Model)["GridBaseStylesMap"];
                    TypeDescriptorContext tdc = new TypeDescriptorContext(Model, pd);
                    tdc.ServiceProvider = esc;
                    object v = ce.EditValue(tdc, esc, Model.BaseStylesMap.Clone());
                    if (esc.DialogResult == DialogResult.OK)
                    {
                        Model.BaseStylesMap = (GridBaseStylesMap)v;
                    }
                }
#endif
            }

            base.OnKeyDown(e);
        }