예제 #1
0
    /////////////////////////////////////////////////////////////////////////////////////

    #region [ Private Methods ]

    /// <summary>
    /// Initializes event handlers of the MdiForm and its visual components.
    /// </summary>
    ///
    private void InitializeMdiForm()
    {
        // Hook our event handlers

        this.UiStateChanged += (sender, e) =>
        {
            MdiForm.UpdateVisualStatus();
        };

        MdiForm.Validating += (sender, e) =>
        {
            e.Cancel = !IsSafeToLeaveTheForm();
        };

        MdiForm.FormClosed += (sender, e) =>
        {
            DisconnectFromCollection();
        };

        MdiForm.KeyDown += (sender, e) =>
        {
            if (e.KeyCode == Keys.F2 && e.Modifiers == 0)
            {
                ToggleReadOnlyMode();
                e.Handled = true;
            }
        };

        // In GUI mode we need also to initialize MdiForm's font and icon
        // and, in case of list form, adjust MdiForm's width/height ratio.

        #if !TEXTUI
        MdiForm.Font = MainForm.Font;
        MdiForm.SetupIcon(this.Caption);

        if (IsListForm)
        {
            MdiForm.Width       = (int)(MdiForm.Width * 1.25f);
            MdiForm.Height      = (int)(MdiForm.Height * 0.75f);
            MdiForm.MinimumSize = MdiForm.Size;
        }
        #endif
    }