Example #1
0
        /// <summary>
        /// Overrides the <c>MouseDown</c> handler on this
        /// <c>YataPanelFrozen</c>. Accepts or cancels an active edit.
        /// <list type="bullet">
        /// <item><c>LMB</c> - accept edit</item>
        /// <item><c>RMB</c> - cancel edit</item>
        /// <item><c>MMB</c> - accept or cancel based on
        /// <c><see cref="Settings._acceptedit">Settings._acceptedit</see></c></item>
        /// </list>
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseDown(MouseEventArgs e)
        {
#if Clicks
            logfile.Log("YataPanelFrozen.OnMouseDown() e.Button= " + e.Button);
#endif
            if (ModifierKeys == Keys.None)
            {
                if (_grid._editor.Visible)
                {
#if Clicks
                    logfile.Log(". _grid._editor.Visible");
#endif
                    switch (e.Button)
                    {
                    case MouseButtons.Left:                             // accept edit
#if Clicks
                        logfile.Log(". . accept edit");
#endif
                        _grid._bypassleaveditor = true;
                        _grid.editresultaccept();
                        break;

                    case MouseButtons.Right:                             // cancel edit
#if Clicks
                        logfile.Log(". . cancel edit");
#endif
                        _grid._bypassleaveditor = true;
                        _grid.editresultcancel(YataGrid.INVALID_GRID);
                        break;

                    default:
#if Clicks
                        logfile.Log(". . default edit result");
#endif
                        _grid._editor.Visible = false;                                 // do this or else the leave event fires twice.
                        break;
                    }
                }
                else
                {
                    Propanel propanel = _grid.Propanel;
                    if (propanel != null && propanel._editor.Visible)
                    {
#if Clicks
                        logfile.Log(". _grid.Propanel._editor.Visible");
#endif
                        switch (e.Button)
                        {
                        case MouseButtons.Left:                                 // accept edit
#if Clicks
                            logfile.Log(". . accept edit");
#endif
                            propanel._bypassleaveditor = true;
                            propanel.editresultaccept();
                            break;

                        case MouseButtons.Right:                                 // cancel edit
#if Clicks
                            logfile.Log(". . cancel edit");
#endif
                            propanel._bypassleaveditor = true;
                            propanel.editresultcancel();
                            break;

                        default:
#if Clicks
                            logfile.Log(". . default edit result");
#endif
                            propanel._editor.Visible = false;                                     // do this or else the leave event fires twice.
                            break;
                        }
                    }
                }
            }

            _grid.Select();
        }