public FdoSequentialProcessCtl(string name, SequentialProcessDefinition def)
     : this()
 {
     _def = def;
     _taskName = name;
     txtName.Text = name;
     txtName.ReadOnly = true;
 }
        private void btnSave_Click(object sender, EventArgs e)
        {
            using (new TempCursor(Cursors.WaitCursor))
            {
                if (string.IsNullOrEmpty(txtName.Text))
                {
                    MessageService.ShowError("Name required");
                    return;
                }

                TaskManager tmgr = ServiceManager.Instance.GetService<TaskManager>();
                LoggingService.Info("Updating loaded task. Please wait.");
                List<SequentialOperation> ops = new List<SequentialOperation>();
                foreach (var obj in lstProcesses.Items)
                {
                    ops.Add((SequentialOperation)obj);
                }
                if (_def == null) //is new
                {
                    _def = new SequentialProcessDefinition();
                    foreach(var op in ops)
                    {
                        _def.AddOperation(op);
                    }
                    var proc = new FdoSequentialProcess(_def);
                    tmgr.AddTask(txtName.Text, proc);
                }
                else
                {
                    _def.ClearOperations();
                    foreach (var op in ops)
                    {
                        _def.AddOperation(op);
                    }
                }
                this.Close();
            }
        }