示例#1
0
        /// <summary>
        /// This method is called when the ScheduleForm's Load event has been fired.
        /// </summary>
        /// <param name="sender">The <see cref="object"/> that fired the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> of the event.</param>
        private void ScheduleForm_Load(object sender, EventArgs e)
        {
            tbName.Text = Job.Name;
            try {
                AdvancedCRONControl cc = new AdvancedCRONControl(Job.CronConfig);
                cronControl = cc;
                pnlCron.Controls.Add(cc);
            } catch {
                SimpleCRONControl cc = new SimpleCRONControl();
                cronControl = cc;
                pnlCron.Controls.Add(cc);
            }
            cbScheduleType.SelectedIndex  = cronControl is AdvancedCRONControl ? 0 : 1;
            cronControl.SelectionChanged += cronControl_SelectionChanged;
            int ind = -1;

            for (int i = 0; i < Configuration.JobPlugins.Count; i++)
            {
                IBackupSchedule plug = Configuration.JobPlugins[i];
                cbJobType.Items.Add(new PlugWrapper(plug));
                if (string.Equals(Job.JobType, plug.GetType().FullName))
                {
                    ind = i;
                }
            }
            if (ind > -1)
            {
                cbJobType.SelectedIndex = ind;
                if (Job.ID > 0)
                {
                    cbJobType.Enabled = false;
                }
            }
            lvPreCommands.ListViewItemSorter = new ListViewItemComparer();
            List <CommandWrapper> commands = CommandWrapper.Parse(Job.PreCommands);

            if (commands.Count > 0)
            {
                int index = 0;
                foreach (CommandWrapper cw in commands)
                {
                    ListViewItem li = lvPreCommands.Items.Add(cw.Command);
                    li.Tag = index++;
                    li.SubItems.Add(cw.Arguments);
                }
                FixLVSize(lvPreCommands);
            }
            lvPostCommands.ListViewItemSorter = new ListViewItemComparer();
            commands = CommandWrapper.Parse(Job.PostCommands);
            if (commands.Count > 0)
            {
                int index = 0;
                foreach (CommandWrapper cw in commands)
                {
                    ListViewItem li = lvPostCommands.Items.Add(cw.Command);
                    li.Tag = index++;
                    li.SubItems.Add(cw.Arguments);
                }
                FixLVSize(lvPostCommands);
            }
            ind = -1;
            for (int i = 0; i < Configuration.TargetPlugins.Count; i++)
            {
                IBackupTarget tt = Configuration.TargetPlugins[i];
                cbTargetType.Items.Add(new TargetWrapper(tt));
                if (string.Equals(tt.GetType().FullName, Job.TargetType))
                {
                    ind = i;
                }
            }
            if (ind > -1)
            {
                cbTargetType.SelectedIndex = ind;
            }
            UpdateNext();
            isLoaded = true;
        }