Ejemplo n.º 1
0
        public void DeleteTaskAction(OctopusLib.Task selectedTask, object obj)
        {
            if (selectedTask != null)
            {
                var collection = ((IList)obj).Cast <OctopusLib.TaskAction>();

                List <OctopusLib.TaskAction> selectedTaskActions = new List <OctopusLib.TaskAction>(collection);

                if (selectedTaskActions.Count > 0)
                {
                    MessageBoxResult result = MessageBox.Show("Are you sure you want to delete the selected items?", "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Question);
                    if (result == MessageBoxResult.Yes)
                    {
                        foreach (OctopusLib.TaskAction taskAction in selectedTaskActions)
                        {
                            this.SelectedRow.TaskActionCollection.Remove(taskAction);
                        }
                        ReSequence(this.SelectedRow);
                        IsModified = true;
                        Message    = "Task actions be deleted.";
                    }
                    else
                    {
                        return;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void InsertTaskAction(OctopusLib.Task selectedTask)
        {
            if (selectedTask != null)
            {
                int sequence = selectedTask.TaskActionCollection.Count + 1;

                TaskActionSelect rasWindow = new TaskActionSelect()
                {
                    Title                 = "Task Action selection Dialog",
                    ShowInTaskbar         = false,               // don't show the dialog on the taskbar
                    Topmost               = true,                // ensure we're Always On Top
                    ResizeMode            = ResizeMode.NoResize, // remove excess caption bar buttons
                    Owner                 = Application.Current.MainWindow,
                    WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner,
                };
                rasWindow.BindingAvailableActionList();
                rasWindow.ShowDialog();

                if (rasWindow.SelectedTaskAction != null)
                {
                    OctopusLib.TaskAction selectedTaskAction = rasWindow.SelectedTaskAction;
                    selectedTaskAction.Sequence = sequence;

                    this.SelectedTaskActionRow = selectedTaskAction;

                    selectedTask.TaskActionCollection.Add(selectedTaskAction);
                    selectedTask.TaskActionCollection.ItemPropertyChanged += PropertyChangedHandler;
                    IsModified = true;
                    Message    = "New task action be added.";
                }
            }
        }
Ejemplo n.º 3
0
 private void taskDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (taskDataGrid.SelectedItems.Count == 1)
     {
         OctopusLib.Task selectedTask = taskDataGrid.SelectedItem as OctopusLib.Task;
         if (selectedTask != null)
         {
             m_taskVM.SelectedRow            = selectedTask;
             taskActionsDataGrid.ItemsSource = selectedTask.TaskActionCollection;
         }
     }
     else
     {
         taskActionsDataGrid.ItemsSource = null;
     }
 }
Ejemplo n.º 4
0
        public void InsertTask()
        {
            OctopusLib.Task newTask = new OctopusLib.Task
            {
                Name                 = string.Format("New Task {0}", TaskCollection.Count() + 1),
                IsEnabled            = true,
                TaskActionCollection = new ObservableCollectionEx <OctopusLib.TaskAction>(),
                Machines             = new ObservableCollectionEx <Machine>(),
                Sequence             = 0,
            };
            this.SelectedRow = newTask;
            this.TaskCollection.Add(newTask);

            IsModified = true;
            Message    = "New task be added.";
        }
Ejemplo n.º 5
0
        public void MoveUpTaskAction(OctopusLib.Task selectedTask, object obj)
        {
            if (selectedTask != null)
            {
                var collection = ((IList)obj).Cast <OctopusLib.TaskAction>();
                OctopusLib.TaskAction selectedTaskAction = new List <OctopusLib.TaskAction>(collection)[0];

                int targetIndex = selectedTaskAction.Sequence - 1;

                OctopusLib.TaskAction targetTaskAction = selectedTask.TaskActionCollection.Where(o => o.Sequence == targetIndex).Single() as OctopusLib.TaskAction;

                targetTaskAction.Sequence   = targetIndex + 1;
                selectedTaskAction.Sequence = targetIndex;
                selectedTask.TaskActionCollection.Sort(o => o.Sequence);
                IsModified = true;
            }
        }
Ejemplo n.º 6
0
 private void ReSequence(OctopusLib.Task selectedTask)
 {
     if (selectedTask != null)
     {
         int index = 0;
         foreach (OctopusLib.TaskAction taskAction in selectedTask.TaskActionCollection.OrderBy(o => o.Sequence))
         {
             index++;
             if (taskAction.Sequence == index)
             {
                 continue;
             }
             else
             {
                 taskAction.Sequence = index;
             }
         }
     }
 }