Example #1
0
    /////////////////////////////////////////////////////////////////////////////////////

    /// <summary>
    /// Selects the first control with the tab stop.
    /// </summary>
    ///
    private void FocusOnFirstTabStop()
    {
        if (FirstField.TabStop)
        {
            FirstField.Focus();
        }
        else
        {
            MdiForm.SelectNextControl(FirstField, /*forward*/ true,
                                      /*tabStopOnly*/ true, /*nested*/ true, /*wrap*/ true);
        }
    }
Example #2
0
    /// <summary>
    /// Sets the ReadOnly property of the form.
    /// </summary>
    /// <remarks>
    /// Configures whether membership, priceClass and minQuantity fields are
    /// enabled.
    /// </remarks>
    ///
    protected override void SetReadOnly(bool readOnly)
    {
        base.SetReadOnly(readOnly);

        /////////////////////////////////////////////////////////////////////////////////

        this.membership.TabStop  = IsAddNew;
        this.membership.ReadOnly = readOnly || !IsAddNew;

        this.priceClass.TabStop  = IsAddNew;
        this.priceClass.ReadOnly = readOnly || !IsAddNew;

        this.textMinQuantity.TabStop  = IsAddNew;
        this.textMinQuantity.ReadOnly = readOnly || !IsAddNew;

        FirstField = IsAddNew ? (Control)this.membership : this.textRentalFee;

        if (MdiForm.ActiveChild == null || !MdiForm.ActiveChild.TabStop)
        {
            FirstField.Focus();
        }
    }
Example #3
0
    /// <summary>
    /// Sets the ReadOnly property of the form.
    /// </summary>
    /// <remarks>
    /// Configures whether locker-button is visible.
    /// </remarks>
    ///
    protected override void SetReadOnly(bool readOnly)
    {
        readOnly = readOnly || this.Movie == null;

        /////////////////////////////////////////////////////////////////////////////////

        base.SetReadOnly(readOnly);

        /////////////////////////////////////////////////////////////////////////////////

        FirstField = this.media;

        if (MdiForm.ActiveChild == null || !MdiForm.ActiveChild.TabStop)
        {
            FirstField.Focus();
        }

        if (this.Movie == null && IsAddNew)
        {
            Button_Locker.TabStop = false;
            Button_Locker.Enabled = false;
        }
    }
Example #4
0
    /// <summary>
    /// Sets the ReadOnly property of the form.
    /// </summary>
    /// <remarks>
    /// Configures buttons' text and whether exemplarSelect field is enabled.
    /// </remarks>
    ///
    protected override void SetReadOnly(bool readOnly)
    {
        base.SetReadOnly(readOnly);

        /////////////////////////////////////////////////////////////////////////////////

        Button_OK.Text     = ReadOnly ? "Cl&ose" : IsAddNew ? "&Rent Item" : "&Update";
        Button_Delete.Text = "&Return Item";

        LayoutButtonPanel();

        /////////////////////////////////////////////////////////////////////////////////

        this.exemplarSelect.TabStop = !ReadOnly && IsAddNew;
        this.exemplarSelect.Enabled = !ReadOnly && IsAddNew;
        this.exemplarSelect.Visible = this.exemplarSelect.Enabled;

        FirstField = IsAddNew ? this.exemplarSelect : (Control)this.dueDate;

        if (MdiForm.ActiveChild != null && !MdiForm.ActiveChild.TabStop)
        {
            FirstField.Focus();
        }
    }
Example #5
0
    /////////////////////////////////////////////////////////////////////////////////////

    /// <summary>
    /// Initializes UI components of the DetailsForm.
    /// </summary>
    /// <remarks>
    /// Sets the FirstField control and creates ButtonPanel.
    /// </remarks>
    ///
    protected override void InitializeComponents()
    {
        FirstField = MdiForm.Children[0] as Control;

        foreach (var child in MdiForm.Children)
        {
            Control ctrl = child as Control;
            if (ctrl != null && ctrl.TabStop)
            {
                FirstField = ctrl;
                break;
            }
        }

        FirstField.Focus();

        /////////////////////////////////////////////////////////////////////////////////

        if (Em.IsTextUI)
        {
            MdiForm.ForeColor = Color.DarkCyan;
        }

        /////////////////////////////////////////////////////////////////////////////////
        // Buttons

        Button_OK = new MyButton()
        {
            AutoSize = true, TabStop = false
        };
        Button_Locker = new MyButton()
        {
            AutoSize = true, TabStop = false
        };
        Button_Delete = new MyButton()
        {
            AutoSize = true, TabStop = false
        };
        Button_Link = new MyButton()
        {
            AutoSize = true, TabStop = false
        };
        Button_Info = new MyButton()
        {
            AutoSize = true, TabStop = false
        };
        Button_Cancel = new MyButton()
        {
            AutoSize = true, TabStop = false
        };

        /////////////////////////////////////////////////////////////////////////////////

        Button_OK.Click += delegate
        {
            if (ReadOnly)
            {
                QuitForm();
            }
            else
            {
                SaveAndLock();
            }
        };

        Button_Locker.Click += (sender, e) => ToggleReadOnlyMode();
        Button_Delete.Click += (sender, e) => RaiseDeleteClick();
        Button_Link.Click   += (sender, e) => RaiseLinkClick();
        Button_Info.Click   += (sender, e) => RaiseInfoClick();
        Button_Cancel.Click += (sender, e) => QuitForm();

        /////////////////////////////////////////////////////////////////////////////////

        buttonCollection = new MyButton[]
        {
            Button_OK,
            Button_Locker,
            Button_Delete,
            Button_Link,
            Button_Info,
            Button_Cancel,
        };

        /////////////////////////////////////////////////////////////////////////////////

        #if TEXTUI
        MdiForm.DrawFrame(1, MdiForm.Height - 4, MdiForm.Width - 2, 1);
        #else
        MdiForm.Controls.Add(new MyLineSeparator()
        {
            Dock = DockStyle.Bottom
        });

        ButtonPanel = new FlowLayoutPanel()
        {
            Dock    = DockStyle.Bottom, AutoSize = true,
            Padding = new Padding(2 * Em.Width, Em.Height / 2, 0, Em.Height / 2),
            TabStop = false, TabIndex = 10000,
        };

        MdiForm.Controls.Add(ButtonPanel);
        #endif

        /////////////////////////////////////////////////////////////////////////////////

        base.InitializeComponents();
    }