public void MoveUp(OctopusLib.Action selectedAction, object obj) { if (selectedAction != null) { var collection = ((IList)obj).Cast <OctopusLib.Command>(); OctopusLib.Command selectedCommand = new List <OctopusLib.Command>(collection)[0]; int targetIndex = selectedCommand.Sequence - 1; OctopusLib.Command targetCommand = selectedAction.ActionCommands.Where(o => o.Sequence == targetIndex).Single() as OctopusLib.Command; targetCommand.Sequence = targetIndex + 1; selectedCommand.Sequence = targetIndex; selectedAction.ActionCommands.Sort(o => o.Sequence); IsModified = true; } }
private void actionsCommandsDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (actionsCommandsDataGrid.SelectedItem != null) { if (actionsCommandsDataGrid.SelectedItems.Count == 1) { OctopusLib.Command selectedCommand = actionsCommandsDataGrid.SelectedItem as OctopusLib.Command; if (selectedCommand != null) { gridCMDProperties.Children.Clear(); selectedCommand.ParameterCollection = m_paramsVM.ParameterCollection; switch (selectedCommand.CommandType) { case OctopusLib.RunCommandType.LinuxSSH: LinuxSSHCommandProperty linuxCommandCtrl = new LinuxSSHCommandProperty() { DataContext = selectedCommand as OctopusLib.LinuxSSHCommand }; linuxCommandCtrl.ParameterCollection = m_paramsVM.ParameterCollection; linuxCommandCtrl.OwnerWindow = this; gridCMDProperties.Children.Add(linuxCommandCtrl); gridCMDProperties.UpdateLayout(); break; case OctopusLib.RunCommandType.Copy: CopyCommandProperty copyCommandCtrl = new CopyCommandProperty() { DataContext = selectedCommand as OctopusLib.CopyCommand }; copyCommandCtrl.ParameterCollection = m_paramsVM.ParameterCollection; copyCommandCtrl.OwnerWindow = this; gridCMDProperties.Children.Add(copyCommandCtrl); gridCMDProperties.UpdateLayout(); break; case OctopusLib.RunCommandType.Remote: RemoteCommandProperty remoteCommandCtrl = new RemoteCommandProperty() { DataContext = selectedCommand as OctopusLib.RemoteCommand }; remoteCommandCtrl.ParameterCollection = m_paramsVM.ParameterCollection; remoteCommandCtrl.OwnerWindow = this; gridCMDProperties.Children.Add(remoteCommandCtrl); gridCMDProperties.UpdateLayout(); break; case OctopusLib.RunCommandType.Local: LocalCommandProperty localCommandCtrl = new LocalCommandProperty() { DataContext = selectedCommand as OctopusLib.LocalCommand }; localCommandCtrl.ParameterCollection = m_paramsVM.ParameterCollection; localCommandCtrl.OwnerWindow = this; gridCMDProperties.Children.Add(localCommandCtrl); gridCMDProperties.UpdateLayout(); break; } } } else { gridCMDProperties.Children.Clear(); } } else { gridCMDProperties.Children.Clear(); } }