示例#1
0
        /// <summary>
        /// Sets values to either singular or plural depending on the number picked in the spin edit.
        /// </summary>
        private void UpdatePluralization()
        {
            bool useSingular = (int)spinCount.Value == 1 || (int)spinCount.Value == -1;
            int  index       = comboUnits.SelectedIndex;

            comboUnits.Properties.Items[0] = useSingular ? TimeSpanRelative.Day : TimeSpanRelative.Days;
            comboUnits.Properties.Items[1] = useSingular ? TimeSpanRelative.Week : TimeSpanRelative.Weeks;
            comboUnits.Properties.Items[2] = useSingular ? TimeSpanRelative.Month : TimeSpanRelative.Months;
            comboUnits.Properties.Items[3] = useSingular ? TimeSpanRelative.Year : TimeSpanRelative.Years;

            comboUnits.SelectedIndex = index;

            if (comboUnits.SelectedIndex >= 0)
            {
                comboUnits.EditValue = comboUnits.Properties.Items[comboUnits.SelectedIndex];
                WinFormsUtility.DoEvents();
            }
        }
示例#2
0
        /// <summary>
        /// Loads the Prompt Items into the list box
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MultiOptionButtonForm_Load(object sender, EventArgs e)
        {
            if (Choices != null && Choices.Count > 0)
            {
                foreach (string str in Choices)
                {
                    var button = new SimpleButton {
                        Text         = str,
                        Font         = new Font("Arial", 9F),
                        Name         = Guid.NewGuid().ToString(),
                        DialogResult = DialogResult.OK
                    };

                    button.Appearance.Options.UseFont        = true;
                    button.Appearance.TextOptions.HAlignment = HorzAlignment.Near;

                    string strVal = str;
                    button.Click += (obj, args) =>
                    {
                        SelectedIndex = _buttons.IndexOf((SimpleButton)obj);
                        SelectedText  = strVal;
                        Close();
                    };
                    var item = new LayoutControlItem
                    {
                        Control     = button,
                        TextVisible = false,
                        Name        = Guid.NewGuid().ToString(),
                        Padding     = new Padding(5)
                    };
                    layoutControlGroupButtons.AddItem(item);
                    _buttons.Add(button);
                }

                if (!ShowCancelButton)
                {
                    layoutMain.HideItem(lciCancel);
                }
            }

            BringToFront();
            Focus();
            WinFormsUtility.DoEvents();
        }
示例#3
0
        /// <summary>
        /// Loads the Prompt Items into the list box
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ListPromptForm_Load(object sender, EventArgs e)
        {
            if (Choices != null && Choices.Count > 0)
            {
                lookupEditItems.Properties.DataSource   = Choices;
                lookupEditItems.Properties.DropDownRows = Choices.Count;
                lookupEditItems.EditValue = Choices[0];
            }

            if (!ShowCancelButton)
            {
                layoutMain.HideItem(lciCancelButton);
            }

            SetWindowHeight();

            BringToFront();
            Focus();
            WinFormsUtility.DoEvents();
        }
示例#4
0
        /// <summary>
        /// Loads the Prompt Items into the radio group
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RadioGroupWithCheckListFormLoad(object sender, EventArgs e)
        {
            // Init the height of the form based on number of items in radio group and check list
            int controlHeight = 0;

            // Add supplied items to the radio group box
            if (RadioGroupItems != null)
            {
                // Make sure supplied default index is within valid range
                if (DefaultIndex < -1 || DefaultIndex > RadioGroupItems.Count - 1)
                {
                    DefaultIndex = -1;
                }

                // Loop through items and add each to the radio group
                for (int i = 0; i < RadioGroupItems.Count; i++)
                {
                    if (RadioGroupItems[i] == null)
                    {
                        rdoRadioGroup.Properties.Items.Add(new RadioGroupItem(i, string.Empty));
                        rdoRadioGroup.Properties.Items[i].Enabled = false;
                        if (DefaultIndex == i)
                        {
                            DefaultIndex = -1;
                        }
                    }
                    else
                    {
                        rdoRadioGroup.Properties.Items.Add(new RadioGroupItem(i, RadioGroupItems[i].Trim()));
                    }
                    controlHeight = controlHeight + rdoRadioGroup.Font.Height + 10;
                }

                // Set the default selection of the radio group
                rdoRadioGroup.SelectedIndex = DefaultIndex;

                // To address Defect-8782, handle mouse wheel specially
                rdoRadioGroup.MouseWheel += rdoRadioGroupMouseWheel;
            }
            else
            {
                rgbRadioGroupBox.Hide(); // Hide radio group box if no items available
            }

            // Set height of radio group based on number of items
            rgbRadioGroupBox.Height = controlHeight + 25;
            rgbRadioGroupBox.Top    = 0;
            rgbRadioGroupBox.Left   = 0;

            // Add supplied items to check list box
            controlHeight = 0;
            if (CheckListItems != null)
            {
                for (int i = 0; i < CheckListItems.Count; i++)
                {
                    if (CheckListItems[i] == null)
                    {
                        chkCheckedListBox.Items.Add(new CheckedListBoxItem(i, " "));
                        chkCheckedListBox.Items[i].Enabled = false;
                    }
                    else
                    {
                        chkCheckedListBox.Items.Add(new CheckedListBoxItem(i, CheckListItems[i].Trim()));
                    }
                    controlHeight = controlHeight + chkCheckedListBox.Font.Height + 4;
                }
                chkCheckedListBox.SelectedIndex = -1;
            }
            else
            {
                rgbCheckListGroupBox.Hide(); // Hide check list box in case of no items
            }

            // Set height of check list box based on number of items
            rgbCheckListGroupBox.Height = controlHeight + 25;
            rgbCheckListGroupBox.Top    = rgbRadioGroupBox.Bottom;
            rgbCheckListGroupBox.Left   = 0;

            // Position the ok and cancel buttons
            okButton.Top     = rgbCheckListGroupBox.Bottom + 10;
            cancelButton.Top = okButton.Top;

            // Set the height of the complete form
            Height = cancelButton.Bottom + 5;

            BringToFront();
            Focus();
            WinFormsUtility.DoEvents();
        }