Exemple #1
0
        private void ResetCombo()
        {
            int curType = actionsCombo.SelectedIndex == -1 ? -1 : Convert.ToInt32(((DropDownCheckListItem)actionsCombo.SelectedItem).Value);

            actionsCombo.BeginUpdate();
            actionsCombo.Items.Clear();
            long allVal;

            ComboBoxExtension.InitializeFromEnum(actionsCombo.Items, typeof(TaskActionType), EditorProperties.Resources.ResourceManager, "ActionType", out allVal);
            if (!isV2)
            {
                actionsCombo.Items.RemoveAt(actionsCombo.Items.IndexOf((long)TaskActionType.ComHandler));
                actionsCombo.Items.RemoveAt(actionsCombo.Items.IndexOf((long)TaskActionType.SendEmail));
                actionsCombo.Items.RemoveAt(actionsCombo.Items.IndexOf((long)TaskActionType.ShowMessage));
            }
            else if (useUnifiedSchedulingEngine)
            {
                actionsCombo.Items.RemoveAt(actionsCombo.Items.IndexOf((long)TaskActionType.SendEmail));
                actionsCombo.Items.RemoveAt(actionsCombo.Items.IndexOf((long)TaskActionType.ShowMessage));
            }
            if (curType > -1)
            {
                curType = actionsCombo.Items.IndexOf((long)curType);
            }
            if (curType == -1)
            {
                curType = 0;
            }
            actionsCombo.SelectedIndex = curType;
            actionsCombo.EndUpdate();
            runActionBtn.Visible = AllowRun;
        }
        private void ResetControls()
        {
            // Setup list of triggers available
            long allVal;

            triggerComboItems.Clear();
            ComboBoxExtension.InitializeFromEnum(triggerComboItems, typeof(TaskTriggerDisplayType), EditorProperties.Resources.ResourceManager, "TriggerType", out allVal);
            if (!isV2)
            {
                triggerComboItems.RemoveRange(4, 7);
            }
            triggerTypeCombo.BeginUpdate();
            triggerTypeCombo.DataSource    = null;
            triggerTypeCombo.DisplayMember = "Text";
            triggerTypeCombo.ValueMember   = "Value";
            triggerTypeCombo.DataSource    = triggerComboItems;
            triggerTypeCombo.EndUpdate();

            // Enable/disable version specific features
            stopIfRunsCheckBox.Enabled = stopIfRunsSpan.Enabled = delayCheckBox.Enabled = delaySpan.Enabled = isV2;
            dailyTriggerUI1.IsV2       = weeklyTriggerUI1.IsV2 = monthlyTriggerUI1.IsV2 = isV2;

            // Set date/time controls
            schedStartDatePicker.UTCPrompt  = activateDatePicker.UTCPrompt = expireDatePicker.UTCPrompt = isV2 ? EditorProperties.Resources.DateTimeSyncText : null;
            schedStartDatePicker.TimeFormat = (isV2) ? FullDateTimePickerTimeFormat.LongTime : FullDateTimePickerTimeFormat.ShortTime;
            activateDatePicker.TimeFormat   = (isV2) ? FullDateTimePickerTimeFormat.LongTime : FullDateTimePickerTimeFormat.ShortTime;
            expireDatePicker.TimeFormat     = (isV2) ? FullDateTimePickerTimeFormat.LongTime : FullDateTimePickerTimeFormat.Hidden;

            // Disable logon trigger options
            foreach (Control c in logonTab.Controls)
            {
                c.Enabled = isV2;
            }
        }
        /// <summary>
        /// Initializes the check list from an enumerated type.
        /// </summary>
        /// <param name="enumType">The enumerated type.</param>
        /// <param name="mgr">The <see cref="System.Resources.ResourceManager"/> that holds the display text for each enumerated value.</param>
        /// <param name="prefix">(Optional) The prefix used in front of the enumeration value to pull from the resource file. If <c>null</c>, then this value defaults to the name of the enumerated type specified by <paramref name="enumType"/>.</param>
        /// <param name="exclude">(Optional) The excluded items from the enumerated type.</param>
        public void InitializeFromEnum(Type enumType, System.Resources.ResourceManager mgr, string prefix = null, string[] exclude = null)
        {
            if (!enumType.IsEnum)
            {
                throw new ArgumentException("Specified type is not an enumeration.", nameof(enumType));
            }
            if (mgr == null)
            {
                throw new ArgumentNullException(nameof(mgr), "A valid ResourceManager instance must be provided.");
            }
            long allVal;

            checkedListBox1.BeginUpdate();
            ComboBoxExtension.InitializeFromEnum(checkedListBox1.Items, enumType, mgr, prefix, out allVal, exclude);
            if (!string.IsNullOrEmpty(CheckAllText))
            {
                checkedListBox1.Items.Insert(0, new DropDownCheckListItem(CheckAllText, allVal));
            }
            checkedListBox1.EndUpdate();
        }